Skip to content

Commit

Permalink
More Sonar fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
ajs6f committed Apr 20, 2013
1 parent 48d0bdb commit 853bad8
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 25 deletions.
Expand Up @@ -39,16 +39,13 @@
@Produces({TEXT_XML, "text/turtle", TEXT_PLAIN})
public class DatastreamRdfGenerator extends AbstractResource {

List<TripleSource<Datastream>> dsGenerators;
private List<TripleSource<Datastream>> dsGenerators;

final private static ValueFactory valFactory = new MemValueFactory();
private static final ValueFactory valFactory = new MemValueFactory();

final private Logger logger = LoggerFactory
private final Logger logger = LoggerFactory
.getLogger(DatastreamRdfGenerator.class);

@Autowired
DatastreamService datastreamService;

@GET
@Path("/")
@Produces({TEXT_XML, "text/turtle", TEXT_PLAIN})
Expand Down
Expand Up @@ -7,6 +7,7 @@
import static com.google.common.collect.ImmutableList.builder;
import static com.google.common.collect.ImmutableList.copyOf;
import static com.google.common.collect.Iterables.concat;
import static org.fcrepo.utils.FedoraTypesUtils.isMultipleValuedProperty;

import java.util.List;

Expand All @@ -21,12 +22,11 @@
import org.slf4j.LoggerFactory;

import com.google.common.base.Function;
import com.google.common.base.Predicate;
import com.google.common.collect.ImmutableList.Builder;

public class PropertiesGenerator implements TripleSource<Node> {

final private Logger logger = LoggerFactory
private final Logger logger = LoggerFactory
.getLogger(PropertiesGenerator.class);

@Override
Expand All @@ -40,10 +40,10 @@ public List<Triple> getTriples(final Node source, final UriInfo... uriInfo)
final List<Property> properties = copyOf(source.getProperties());
logger.debug("Retrieved properties: " + properties.toString());

triples.addAll(transform(filter(properties, not(isMultiple)),
singlevaluedprop2triple));
triples.addAll(concat(transform(filter(properties, isMultiple),
multivaluedprop2triples)));
triples.addAll(transform(filter(properties,
not(isMultipleValuedProperty)), singlevaluedprop2triple));
triples.addAll(concat(transform(filter(properties,
isMultipleValuedProperty), multivaluedprop2triples)));

logger.trace("Leaving getTriples().");
return triples.build();
Expand Down Expand Up @@ -102,16 +102,4 @@ private static String expandJCRNamespace(final String name,
.getURI(predicatePrefix));
}

private static Predicate<Property> isMultiple = new Predicate<Property>() {

@Override
public boolean apply(final Property p) {
try {
return p == null ? false : p.isMultiple();
} catch (final RepositoryException e) {
throw new RuntimeException(e);
}
}
};

}
Expand Up @@ -10,7 +10,7 @@
import org.apache.any23.writer.TripleHandler;
import org.apache.any23.writer.TurtleWriter;

public class Utils {
public abstract class Utils {

public static TripleHandler selectWriter(final String mimeType,
final OutputStream out) {
Expand Down
Expand Up @@ -15,6 +15,7 @@
import javax.ws.rs.core.UriInfo;

import org.fcrepo.identifiers.PidMinter;
import org.fcrepo.services.DatastreamService;
import org.fcrepo.services.ObjectService;
import org.fcrepo.session.SessionFactory;
import org.modeshape.jcr.api.JcrTools;
Expand Down Expand Up @@ -47,6 +48,12 @@ public abstract class AbstractResource {
@Autowired
protected ObjectService objectService;

/**
* The fcrepo datastream service
*/
@Autowired
protected DatastreamService datastreamService;

/**
* A resource that can mint new Fedora PIDs.
*/
Expand Down
16 changes: 16 additions & 0 deletions fcrepo-kernel/src/main/java/org/fcrepo/utils/FedoraTypesUtils.java
Expand Up @@ -13,6 +13,7 @@

import javax.jcr.Binary;
import javax.jcr.Node;
import javax.jcr.Property;
import javax.jcr.RepositoryException;
import javax.jcr.Value;
import javax.jcr.ValueFactory;
Expand Down Expand Up @@ -111,6 +112,21 @@ public String apply(final Value v) {
}
};

public static Predicate<Property> isMultipleValuedProperty =
new Predicate<Property>() {

@Override
public boolean apply(final Property p) {
checkArgument(p != null,
"null is neither multiple or not multiple!");
try {
return p.isMultiple();
} catch (final RepositoryException e) {
throw new RuntimeException(e);
}
}
};

/**
* Retrieves a JCR {@link ValueFactory} for use with a {@ link Node}
*/
Expand Down

0 comments on commit 853bad8

Please sign in to comment.