Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Cleaning unused imports and changing variable to field for efficiency
  • Loading branch information
ajs6f committed Jan 31, 2013
1 parent c903992 commit 7d14804
Showing 1 changed file with 13 additions and 19 deletions.
32 changes: 13 additions & 19 deletions src/main/java/org/fcrepo/modeshape/observer/DefaultFilter.java
@@ -1,12 +1,12 @@
package org.fcrepo.modeshape.observer;

import java.util.Set;
import static com.google.common.collect.Iterables.any;
import static com.google.common.collect.Sets.newHashSet;

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import javax.inject.Inject;
import javax.jcr.LoginException;
import javax.jcr.Node;
import javax.jcr.PathNotFoundException;
import javax.jcr.RepositoryException;
import javax.jcr.Session;
Expand All @@ -17,8 +17,6 @@
import org.modeshape.jcr.api.Repository;

import com.google.common.base.Predicate;
import com.google.common.collect.Iterables;
import com.google.common.collect.Sets;

public class DefaultFilter implements EventFilter {

Expand All @@ -29,26 +27,22 @@ public class DefaultFilter implements EventFilter {
// the state of the repository
private Session session;

private Predicate<NodeType> isFedoraNodeType = new Predicate<NodeType>() {
@Override
public boolean apply(NodeType type) {
return type.getName().startsWith("fedora:");
}
};

@Override
public boolean apply(Event event) {

Predicate<NodeType> isFedoraNodeType = new Predicate<NodeType>() {
@Override
public boolean apply(NodeType type) {
return type.getName().startsWith("fedora:");
}
};

try {
Node node = null;
try {
node = session.getNode(event.getPath());
} catch (PathNotFoundException e) {
return false; // not a node in the fedora workspace
}
Set<NodeType> types = Sets.newHashSet(node.getMixinNodeTypes());
return Iterables.any(types, isFedoraNodeType);
return any(newHashSet(session.getNode(event.getPath())
.getMixinNodeTypes()), isFedoraNodeType);

} catch (PathNotFoundException e) {
return false; // not a node in the fedora workspace
} catch (LoginException e) {
throw new SystemFailureException(e);
} catch (RepositoryException e) {
Expand Down

0 comments on commit 7d14804

Please sign in to comment.