Skip to content

Commit

Permalink
Address checkstyle issues in preparation for tighter enforcement
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrew Woods committed May 21, 2014
1 parent 8af7da1 commit 7e3f87d
Show file tree
Hide file tree
Showing 23 changed files with 62 additions and 39 deletions.
Expand Up @@ -66,7 +66,7 @@ public class AccessRolesProvider {
* @param effective if true then search for effective roles
* @return a set of roles for each principal
*/
public Map<String, List<String>> getRoles(Node node, final boolean effective) throws RepositoryException {
public Map<String, List<String>> getRoles(final Node node, final boolean effective) throws RepositoryException {
final Map<String, List<String>> data = new HashMap<>();
final Session session = node.getSession();
registerPrefixes(session);
Expand All @@ -76,14 +76,12 @@ public Map<String, List<String>> getRoles(Node node, final boolean effective) th
}
if (effective) { // look up the tree
try {
for (node = node.getParent(); node != null; node =
node.getParent()) {
if (node.isNodeType(rbaclAssignable.getQualified())) {
for (Node n = node.getParent(); n != null; n = n.getParent()) {
if (n.isNodeType(rbaclAssignable.getQualified())) {
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("effective roles are assigned at node: {}",
node.getPath());
LOGGER.debug("effective roles are assigned at node: {}", n.getPath());
}
getAssignments(node, data);
getAssignments(n, data);
if (LOGGER.isDebugEnabled()) {
for (final Map.Entry<String, List<String>> entry : data.entrySet()) {
LOGGER.debug("{} has role(s) {}", entry.getKey(), entry.getValue());
Expand Down
Expand Up @@ -29,6 +29,12 @@
*/
public class Constants {

/**
* No public constructor for utility class
*/
private Constants() {
}

/**
* Authorization JCR names
*
Expand Down
Expand Up @@ -143,8 +143,8 @@ private HttpIdentifierTranslator getTranslator() {
return new HttpIdentifierTranslator(session, FedoraNodes.class, uriInfo);
}

private RdfStream getLockRdfStream(Node node, Lock lock) throws RepositoryException {
HttpIdentifierTranslator translator = getTranslator();
private RdfStream getLockRdfStream(final Node node, final Lock lock) throws RepositoryException {
final HttpIdentifierTranslator translator = getTranslator();
final com.hp.hpl.jena.graph.Node nodeSubject = translator.getSubject(node.getPath()).asNode();
final com.hp.hpl.jena.graph.Node lockSubject = createURI(nodeSubject.getURI() + "/" + FCR_LOCK);

Expand Down
Expand Up @@ -247,7 +247,7 @@ public RdfStream describe(@PathParam("path") final List<PathSegment> pathList,
}
}

List<String> appliedIncludes = new ArrayList<>();
final List<String> appliedIncludes = new ArrayList<>();

final boolean membership =
(!contains(includes, LDP_NAMESPACE + "PreferEmptyContainer") ||
Expand Down Expand Up @@ -726,11 +726,11 @@ public Response deleteObject(@PathParam("path")
session.save();
return noContent().build();
} catch (javax.jcr.ReferentialIntegrityException riex) {
StringBuffer msg = new StringBuffer("Unable to delete node because it is linked to "
final StringBuffer msg = new StringBuffer("Unable to delete node because it is linked to "
+ "by other nodes: ");

// lookup paths of linking nodes
Throwable inner = riex.getCause();
final Throwable inner = riex.getCause();
if ( inner instanceof ReferentialIntegrityException) {
for ( NodeKey node : ((ReferentialIntegrityException)inner).getReferrers() ) {
try {
Expand Down
Expand Up @@ -233,7 +233,7 @@ protected void addResponseInformationToStream(
}

private static void evaluateRequestPreconditions( final Request request, final FedoraResource resource,
boolean cacheControl ) throws RepositoryException {
final boolean cacheControl ) throws RepositoryException {

final EntityTag etag = new EntityTag(resource.getEtagValue());
final Date date = resource.getLastModifiedDate();
Expand Down
Expand Up @@ -41,8 +41,8 @@ public QuadOrdering(final PrefixMapping prefixMapping) {
}

@Override
public int compare(com.hp.hpl.jena.sparql.core.Quad left,
com.hp.hpl.jena.sparql.core.Quad right) {
public int compare(final com.hp.hpl.jena.sparql.core.Quad left,
final com.hp.hpl.jena.sparql.core.Quad right) {

final int s =
left.getSubject().toString(prefixMapping, false).compareTo(
Expand Down
Expand Up @@ -66,15 +66,15 @@ public PreferTag getReturn() {

private static final HttpHeaderReader.ListElementCreator<PreferTag> PREFER_CREATOR =
new HttpHeaderReader.ListElementCreator<PreferTag>() {
public PreferTag create(HttpHeaderReader reader) throws ParseException {
public PreferTag create(final HttpHeaderReader reader) throws ParseException {
return new PreferTag(reader);
}
};

private static Predicate<PreferTag> getPreferTag(final String tagName) {
return new Predicate<PreferTag>() {
@Override
public boolean apply(PreferTag tag) {
public boolean apply(final PreferTag tag) {
return tag.getTag().equals(tagName);
}
};
Expand Down
Expand Up @@ -36,7 +36,7 @@ public class PreferTag {
* @param reader
* @throws ParseException
*/
public PreferTag(HttpHeaderReader reader) throws ParseException {
public PreferTag(final HttpHeaderReader reader) throws ParseException {

// Skip any white space
reader.hasNext();
Expand Down
Expand Up @@ -39,7 +39,7 @@ public class AccessDeniedExceptionMapper implements
* @see javax.ws.rs.ext.ExceptionMapper#toResponse(java.lang.Throwable)
*/
@Override
public Response toResponse(AccessDeniedException e) {
public Response toResponse(final AccessDeniedException e) {
LOGGER.debug("{} intercepted exception:{} \n", this.getClass()
.getSimpleName(), e);
return status(FORBIDDEN).build();
Expand Down
Expand Up @@ -38,7 +38,7 @@ public class LockExceptionMapper implements ExceptionMapper<LockException> {
private static final Logger LOGGER = getLogger(LockExceptionMapper.class);

@Override
public Response toResponse(LockException exception) {
public Response toResponse(final LockException exception) {
LOGGER.debug("LockExceptionMapper intercepted exception: \n", exception);
if (exception.getMessage() != null) {
if (Pattern.matches("^\\QThe lock token '\\E.*'\\Q is not valid\\E$", exception.getMessage())) {
Expand Down
Expand Up @@ -52,6 +52,12 @@ public class RdfSerializationUtils {

private static final Logger LOGGER = getLogger(RdfSerializationUtils.class);

/**
* No public constructor on utility class
*/
private RdfSerializationUtils() {
}

/**
* The RDF predicate that will indicate the primary node type.
*/
Expand Down
Expand Up @@ -40,7 +40,7 @@ public RepositoryRuntimeException(final String msg) {
* @param msg
* @param rootCause
*/
public RepositoryRuntimeException(final String msg, Throwable rootCause) {
public RepositoryRuntimeException(final String msg, final Throwable rootCause) {
super(msg, rootCause);
}
}
Expand Up @@ -28,7 +28,7 @@ public class AllTypesPredicate extends BooleanTypesPredicate {
* True if all the types specified match.
* @param types
*/
public AllTypesPredicate(String...types) {
public AllTypesPredicate(final String...types) {
super(types);
this.test = types.length;
}
Expand Down
Expand Up @@ -26,7 +26,7 @@ public class AnyTypesPredicate extends BooleanTypesPredicate {
* True if any of the types specified match.
* @param types
*/
public AnyTypesPredicate(String...types) {
public AnyTypesPredicate(final String...types) {
super(types);
}

Expand Down
Expand Up @@ -39,12 +39,12 @@ public abstract class BooleanTypesPredicate implements Predicate<Node> {
* Base constructor for function peforming boolean ops on matched node types.
* @param types
*/
public BooleanTypesPredicate(String... types) {
public BooleanTypesPredicate(final String... types) {
nodeTypes = Arrays.asList(types);
}

@Override
public boolean apply(Node input) {
public boolean apply(final Node input) {
if (input == null) {
throw new IllegalArgumentException(
"null node passed to" + getClass().getName()
Expand All @@ -63,6 +63,6 @@ public boolean apply(Node input) {
return test(matched);
}

protected abstract boolean test(int matched);
protected abstract boolean test(final int matched);

}
Expand Up @@ -148,7 +148,7 @@ protected String responseToPid( final String responseText ) throws Exception {
/**
* Extract the desired identifier value from an XML response using XPath
**/
private static String xpath( String xml, XPathExpression xpath ) throws Exception {
private static String xpath( final String xml, final XPathExpression xpath ) throws Exception {
final DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
final Document doc = builder.parse(new ByteArrayInputStream(xml.getBytes()));
return xpath.evaluate(doc);
Expand Down
Expand Up @@ -34,6 +34,12 @@ public class ManagedRdf {

private static final Model model = createDefaultModel();

/**
* No public constructor on utility class
*/
private ManagedRdf() {
}

public static final Predicate<Triple> isManagedTriple =
new Predicate<Triple>() {

Expand Down
Expand Up @@ -124,7 +124,7 @@ private Iterator<Triple> childrenContext() throws RepositoryException {
final Iterator<javax.jcr.Node> salientChildren;

if (options.hasOffset()) {
int offset = options.getOffset();
final int offset = options.getOffset();
Iterators.advance(niceChildren, offset);
}

Expand Down
Expand Up @@ -164,12 +164,12 @@ private Version getVersionForLabel(final Workspace workspace, final String absPa
} else {
// there was no version with the given JCR Version Label, check to see if
// there's a version whose UUID is equal to the label
VersionIterator versionIt = history.getAllVersions();
final VersionIterator versionIt = history.getAllVersions();
if (versionIt == null) {
return null;
}
while (versionIt.hasNext()) {
Version v = versionIt.nextVersion();
final Version v = versionIt.nextVersion();
if (v.getFrozenNode().getIdentifier().equals(label)) {
return v;
}
Expand Down
Expand Up @@ -38,6 +38,12 @@
public class CacheEntryFactory {
private static GetBinaryStore getBinaryStore = new GetBinaryStore();

/**
* No public constructor on utility class
*/
private CacheEntryFactory() {
}

/**
* Load a store-specific CacheEntry model
* @param repository
Expand Down
Expand Up @@ -94,29 +94,30 @@ public int read() throws IOException {
}

@Override
public int read(final byte[] b, final int off, int len) throws IOException {
public int read(final byte[] b, final int off, final int len) throws IOException {
int length = len;
if (indexInBuffer == -1) {
return -1;
}
if (buffer == null) {
fillBuffer();
return read(b, off, len);
return read(b, off, length);
}
if (indexInBuffer >= buffer.length) {
return -1;
}
if (indexInBuffer + len > buffer.length) {
len = buffer.length - indexInBuffer;
if (indexInBuffer + length > buffer.length) {
length = buffer.length - indexInBuffer;
}
System.arraycopy(buffer, indexInBuffer, b, off, len);
indexInBuffer += len;
System.arraycopy(buffer, indexInBuffer, b, off, length);
indexInBuffer += length;
// if we've just exhausted the buffer, make sure we try a new buffer on
// next skip/read
if (indexInBuffer == buffer.length) {
buffer = null;
indexInBuffer = 0;
}
return len;
return length;
}

@Override
Expand Down
Expand Up @@ -65,7 +65,7 @@ protected void operateOnMixin(final Resource mixinResource,
final String mixinName = getPropertyNameFromPredicate(subjectNode, mixinResource);
if (!session().getWorkspace().getNodeTypeManager().hasNodeType(mixinName)) {
final NodeTypeManager mgr = session().getWorkspace().getNodeTypeManager();
NodeTypeTemplate type = mgr.createNodeTypeTemplate();
final NodeTypeTemplate type = mgr.createNodeTypeTemplate();
type.setName(mixinName);
type.setMixin(true);
type.setQueryable(true);
Expand Down
Expand Up @@ -97,7 +97,7 @@ public int hashCode() {
* @see java.lang.Object#equals(java.lang.Object)
*/
@Override
public boolean equals(Object obj) {
public boolean equals(final Object obj) {
if (this == obj) {
return true;
}
Expand Down

0 comments on commit 7e3f87d

Please sign in to comment.