Navigation Menu

Skip to content

Commit

Permalink
Checking for parent tombstones on 404 errors
Browse files Browse the repository at this point in the history
  • Loading branch information
escowles committed Oct 31, 2014
1 parent e619ab4 commit c7df2f3
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 5 deletions.
Expand Up @@ -477,6 +477,18 @@ public void testDeleteObject() throws Exception {
assertDeleted(location);
}

@Test
public void testDeleteHierarchy() throws Exception {
final String pid = getRandomUniquePid();

createObject(pid + "/foo");

final String location = serverAddress + pid;
assertEquals(204, getStatus(new HttpDelete(location)));
assertDeleted(location);
assertDeleted(location + "/foo");
}

@Test
public void testDeleteBinary() throws Exception {
final String pid = getRandomUniquePid();
Expand Down Expand Up @@ -2210,4 +2222,4 @@ public String apply(final Header h) {
}


}
}
Expand Up @@ -25,6 +25,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.getClosestExistingAncestor;
import static org.fcrepo.kernel.impl.utils.FedoraTypesUtils.isFrozenNode;
import static org.modeshape.jcr.api.JcrConstants.JCR_CONTENT;
import static org.slf4j.LoggerFactory.getLogger;
Expand All @@ -49,7 +50,9 @@
import org.fcrepo.kernel.models.FedoraResource;
import org.fcrepo.kernel.exception.IdentifierConversionException;
import org.fcrepo.kernel.exception.RepositoryRuntimeException;
import org.fcrepo.kernel.exception.TombstoneException;
import org.fcrepo.kernel.identifiers.IdentifierConverter;
import org.fcrepo.kernel.impl.TombstoneImpl;
import org.fcrepo.kernel.impl.identifiers.HashConverter;
import org.fcrepo.kernel.impl.identifiers.NamespaceConverter;
import org.glassfish.jersey.uri.UriTemplate;
Expand Down Expand Up @@ -103,11 +106,9 @@ private UriBuilder uriBuilder() {

@Override
protected FedoraResource doForward(final Resource resource) {
final HashMap<String, String> values = new HashMap<>();
final String path = asString(resource, values);
try {
final HashMap<String, String> values = new HashMap<>();

final String path = asString(resource, values);

if (path != null) {
final Node node = getNode(path);

Expand All @@ -124,6 +125,17 @@ protected FedoraResource doForward(final Resource resource) {
throw new IdentifierConversionException("Asked to translate a resource " + resource
+ " that doesn't match the URI template");
} catch (final RepositoryException e) {
try {
if ( e instanceof PathNotFoundException ) {
final Node preexistingNode = getClosestExistingAncestor(session, path);
if (TombstoneImpl.hasMixin(preexistingNode)) {
throw new TombstoneException(new TombstoneImpl(preexistingNode));
}
}
} catch (RepositoryException inner) {
LOGGER.debug("Error checking for parent tombstones", inner);
}

throw new RepositoryRuntimeException(e);
}
}
Expand Down

0 comments on commit c7df2f3

Please sign in to comment.