Skip to content

Commit

Permalink
Fix version view error
Browse files Browse the repository at this point in the history
  • Loading branch information
osmandin authored and Andrew Woods committed Oct 23, 2014
1 parent 84ffee0 commit fb9075e
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 1 deletion.
Expand Up @@ -53,6 +53,7 @@
import static org.fcrepo.jcr.FedoraJcrTypes.FCR_VERSIONS;
import static org.fcrepo.kernel.impl.identifiers.NodeResourceConverter.nodeConverter;
import static org.fcrepo.kernel.impl.services.TransactionServiceImpl.getCurrentTransactionId;
import static org.fcrepo.kernel.impl.utils.FedoraTypesUtils.isFrozenNode;
import static org.modeshape.jcr.api.JcrConstants.JCR_CONTENT;
import static org.slf4j.LoggerFactory.getLogger;
import static org.springframework.web.context.ContextLoader.getCurrentWebApplicationContext;
Expand Down Expand Up @@ -295,7 +296,7 @@ private Node getFrozenNodeByLabel(final String baseResourcePath, final String la
}

private String getPath(final FedoraResource resource) throws RepositoryException {
if (resource.hasType("nt:frozenNode")) {
if (isFrozenNode.apply(resource)) {
try {
Node versionableFrozenNode = resource.getNode();
Node versionableNode = session.getNodeByIdentifier(
Expand Down
Expand Up @@ -17,6 +17,7 @@

import com.google.common.base.Predicate;
import org.fcrepo.jcr.FedoraJcrTypes;
import org.fcrepo.kernel.FedoraResource;
import org.fcrepo.kernel.exception.RepositoryRuntimeException;
import org.fcrepo.kernel.services.functions.AnyTypesPredicate;
import org.fcrepo.kernel.services.functions.JcrPropertyFunctions;
Expand Down Expand Up @@ -65,6 +66,40 @@ public abstract class FedoraTypesUtils implements FedoraJcrTypes {
public static Predicate<Node> isFedoraBinary =
new AnyTypesPredicate(FEDORA_BINARY);

/**
* Predicate for determining whether this {@link FedoraResource} has a frozen node
*/
public static Predicate<FedoraResource> isFrozenNode =
new Predicate<FedoraResource>() {

@Override
public boolean apply(final FedoraResource f) {
try {

if (f.hasType(FROZEN_NODE)) {
return true;
}

final Node node = f.getNode();

if (node != null) {
final String path = node.getPath();

if (path == null) {
return false;
}

if (path.contains(JCR_FROZEN_NODE)) {
return true;
}
}
return false;
} catch (final RepositoryException e) {
throw new RepositoryRuntimeException(e);
}
}
};

/**
* Check if a property is a reference property.
*/
Expand Down
Expand Up @@ -57,6 +57,8 @@ public interface FedoraJcrTypes {

String FROZEN_NODE = "nt:frozenNode";

String JCR_FROZEN_NODE = "jcr:frozenNode";

String FROZEN_MIXIN_TYPES = "jcr:frozenMixinTypes";

String JCR_UUID = "jcr:uuid";
Expand Down

0 comments on commit fb9075e

Please sign in to comment.