Skip to content

Commit

Permalink
Code cleanup and killing compiler warnings in fcrepo-kernel-impl
Browse files Browse the repository at this point in the history
  • Loading branch information
ajs6f committed Nov 13, 2014
1 parent 0fe56ce commit 1e40e1a
Show file tree
Hide file tree
Showing 20 changed files with 143 additions and 118 deletions.
Expand Up @@ -93,7 +93,7 @@ public class JcrRdfTools {
private final IdentifierConverter<Resource, FedoraResource> idTranslator;
private final ValueConverter valueConverter;

private Session session;
private final Session session;
private final NodePropertiesTools nodePropertiesTools = new NodePropertiesTools();

@VisibleForTesting
Expand Down Expand Up @@ -413,7 +413,7 @@ private Resource getSkolemizedResource(final IdentifierConverter<Resource, Fedor
return skolemizedBnodeMap.get(id);
}

private String skolemizedId() {
private static String skolemizedId() {
return "/.well-known/genid/" + randomUUID().toString();
}
}
Expand Up @@ -196,6 +196,7 @@ public RdfLiteralJcrValueBuilder(final String literal) {
}
}

@Override
public String toString() {
final StringBuilder b = new StringBuilder();

Expand Down Expand Up @@ -225,9 +226,8 @@ public String value() {
public RDFDatatype datatype() {
if (hasDatatypeUri()) {
return new BaseDatatype(datatypeUri);
} else {
return null;
}
return null;
}

public String lang() {
Expand Down
Expand Up @@ -106,7 +106,7 @@ public Iterator<Triple> apply(final Property input) {
final FedoraResource resource = nodeConverter.convert(input.getParent());

return memberRelations(resource);
} catch (RepositoryException e) {
} catch (final RepositoryException e) {
throw new RepositoryRuntimeException(e);
}
}
Expand Down Expand Up @@ -162,28 +162,26 @@ public Iterator<Triple> apply(final FedoraResource child) {
if (insertedContainerProperty.equals(MEMBER_SUBJECT.getURI())) {

return singletonIterator(create(subject(), memberRelation, childSubject));
} else {
}
final String insertedContentProperty = getPropertyNameFromPredicate(resource().getNode(),
createResource(insertedContainerProperty),
null);

final String insertedContentProperty = getPropertyNameFromPredicate(resource().getNode(),
createResource(insertedContainerProperty),
null);
if (!child.hasProperty(insertedContentProperty)) {
return emptyIterator();
}

if (!child.hasProperty(insertedContentProperty)) {
return emptyIterator();
}
final PropertyValueIterator values
= new PropertyValueIterator(child.getProperty(insertedContentProperty));

final PropertyValueIterator values
= new PropertyValueIterator(child.getProperty(insertedContentProperty));

return Iterators.transform(values, new Function<Value, Triple>() {
@Override
public Triple apply(final Value input) {
final RDFNode membershipResource = new ValueConverter(session(), translator())
.convert(input);
return create(subject(), memberRelation, membershipResource.asNode());
}
});
}
return Iterators.transform(values, new Function<Value, Triple>() {
@Override
public Triple apply(final Value input) {
final RDFNode membershipResource = new ValueConverter(session(), translator())
.convert(input);
return create(subject(), memberRelation, membershipResource.asNode());
}
});
} catch (final RepositoryException e) {
throw new RepositoryRuntimeException(e);
}
Expand Down
Expand Up @@ -30,7 +30,7 @@
* @author cabeer
*/
public class PropertyValueIterator extends AbstractIterator<Value> {
private Iterator<Property> properties;
private final Iterator<Property> properties;
private Iterator<Value> currentValues;

/**
Expand Down Expand Up @@ -62,10 +62,9 @@ protected Value computeNext() {
if (property.isMultiple()) {
currentValues = Iterators.forArray(property.getValues());
return currentValues.next();
} else {
currentValues = null;
return property.getValue();
}
currentValues = null;
return property.getValue();
}

return endOfData();
Expand Down
Expand Up @@ -63,9 +63,9 @@ protected Node findNode(final Session session, final String path) {
}
}

private void tagHierarchyWithPairtreeMixin(final Node baseNode,
final Node createdNode) throws RepositoryException {
Node parent = createdNode.getParent();
private static void tagHierarchyWithPairtreeMixin(final Node baseNode,
final Node createdNode) throws RepositoryException {
Node parent = createdNode.getParent();

while (parent.isNew() && !parent.equals(baseNode)) {
parent.addMixin(FEDORA_PAIRTREE);
Expand Down
Expand Up @@ -84,7 +84,7 @@ public FedoraBinary find(final Session session, final String path) {
}
}

private void initializeNewDatastreamProperties(final Node node) {
private static void initializeNewDatastreamProperties(final Node node) {
try {

if (node.canAddMixin(FEDORA_RESOURCE)) {
Expand Down Expand Up @@ -117,7 +117,7 @@ public FedoraBinary cast(final Node node) {
return new FedoraBinaryImpl(node);
}

private void assertIsType(final Node node) {
private static void assertIsType(final Node node) {
if (!FedoraBinaryImpl.hasMixin(node)) {
throw new ResourceTypeException(node + " can not be used as a binary");
}
Expand Down
Expand Up @@ -81,7 +81,7 @@ public Container find(final Session session, final String path) {
return cast(node);
}

private void initializeNewObjectProperties(final Node node) {
private static void initializeNewObjectProperties(final Node node) {
try {
LOGGER.debug("Setting object properties on node {}...", node.getPath());

Expand All @@ -105,7 +105,7 @@ public Container cast(final Node node) {
return new ContainerImpl(node);
}

private void assertIsType(final Node node) {
private static void assertIsType(final Node node) {
if (!ContainerImpl.hasMixin(node)) {
throw new ResourceTypeException(node + " can not be used as a object");
}
Expand Down
Expand Up @@ -125,9 +125,7 @@ public void testDatastreamContent() throws IOException,
}

@Test
public void testDatastreamContentType() throws IOException,
RepositoryException,
InvalidChecksumException {
public void testDatastreamContentType() throws RepositoryException, InvalidChecksumException {
final Session session = repo.login();
containerService.findOrCreate(session, "/testDatastreamObject");

Expand Down
Expand Up @@ -24,14 +24,11 @@

import javax.inject.Inject;
import javax.jcr.Repository;
import javax.jcr.RepositoryException;
import javax.jcr.Session;

import org.fcrepo.integration.kernel.impl.AbstractIT;
import org.fcrepo.kernel.impl.rdf.impl.DefaultIdentifierTranslator;
import org.fcrepo.kernel.services.BinaryService;
import org.fcrepo.kernel.services.RepositoryService;
import org.junit.Before;
import org.junit.Test;
import org.modeshape.jcr.api.Problems;
import org.springframework.test.context.ContextConfiguration;
Expand All @@ -53,12 +50,6 @@ public class RepositoryServiceImplIT extends AbstractIT {
@Inject
BinaryService binaryService;

private DefaultIdentifierTranslator idTranslator;

@Before
public void setUp() throws RepositoryException {
idTranslator = new DefaultIdentifierTranslator(repository.login());
}
@Test
public void testGetAllObjectsDatastreamSize() throws Exception {
Session session = repository.login();
Expand Down
Expand Up @@ -37,7 +37,6 @@
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import static org.mockito.MockitoAnnotations.initMocks;
import static org.modeshape.jcr.api.JcrConstants.NT_FOLDER;
import static org.slf4j.LoggerFactory.getLogger;

Expand Down Expand Up @@ -76,7 +75,9 @@
import org.fcrepo.kernel.utils.CacheEntry;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.runners.MockitoJUnitRunner;
import org.modeshape.jcr.api.JcrTools;
import org.modeshape.jcr.api.NamespaceRegistry;
import org.modeshape.jcr.value.BinaryValue;
Expand All @@ -95,7 +96,9 @@
* <p>JcrRdfToolsTest class.</p>
*
* @author awoods
* @author ajs6f
*/
@RunWith(MockitoJUnitRunner.class)
public class JcrRdfToolsTest implements FedoraJcrTypes {

private static final Logger LOGGER = getLogger(JcrRdfToolsTest.class);
Expand All @@ -113,7 +116,6 @@ public class JcrRdfToolsTest implements FedoraJcrTypes {

@Before
public final void setUp() throws RepositoryException {
initMocks(this);
testSubjects = new DefaultIdentifierTranslator(mockSession);
buildMockNodeAndSurroundings();
testObj = new JcrRdfTools(testSubjects, mockSession);
Expand Down
Expand Up @@ -125,7 +125,7 @@ public final void shouldRegisterUnknownUris() throws RepositoryException {
}

@Test (expected = InvalidPropertyURIException.class)
public void shouldThrowOnForward() throws RepositoryException {
public void shouldThrowOnForward() {
final javax.jcr.Property p = mock(javax.jcr.Property.class);
testObj.convert(p);
}
Expand All @@ -136,7 +136,7 @@ public void shouldThrowOnBackward() {
testObj.doBackward(property);
}

private void mockNamespaceRegistry(final NamespaceRegistry mockRegistry) throws RepositoryException {
private static void mockNamespaceRegistry(final NamespaceRegistry mockRegistry) throws RepositoryException {

when(mockRegistry.isRegisteredUri(mockUri)).thenReturn(true);
when(mockRegistry.isRegisteredUri("not-registered-uri#")).thenReturn(
Expand Down

0 comments on commit 1e40e1a

Please sign in to comment.