Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Remove fcr:batch DELETE; use POST with delete requests instead
  • Loading branch information
cbeer committed Sep 24, 2014
1 parent 8416f73 commit fa198c9
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 68 deletions.
29 changes: 0 additions & 29 deletions fcrepo-http-api/src/main/java/org/fcrepo/http/api/FedoraBatch.java
Expand Up @@ -19,7 +19,6 @@
import static java.nio.charset.StandardCharsets.UTF_8;
import static javax.ws.rs.core.MediaType.MULTIPART_FORM_DATA;
import static javax.ws.rs.core.Response.created;
import static javax.ws.rs.core.Response.noContent;
import static javax.ws.rs.core.Response.notAcceptable;
import static javax.ws.rs.core.Response.ok;
import static javax.ws.rs.core.Response.status;
Expand All @@ -45,7 +44,6 @@
import javax.jcr.NodeIterator;
import javax.jcr.RepositoryException;
import javax.jcr.Session;
import javax.ws.rs.DELETE;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
Expand Down Expand Up @@ -308,33 +306,6 @@ public Response batchModify(@PathParam("path") final List<PathSegment> pathList,
}
}

/**
* Delete multiple child objects given by the child query parameter
*
* @param pathList
* @param childList
* @return response
* @throws RepositoryException
*/
@DELETE
@Timed
public Response batchDelete(@PathParam("path") final List<PathSegment> pathList,
@QueryParam("child") final List<String> childList) throws RepositoryException {
try {
final String path = toPath(pathList);
for (final String dsid : childList) {
final String dsPath = path + "/" + dsid;
LOGGER.debug("purging node {}", dsPath);
nodeService.getObject(session, dsPath).delete();
}
session.save();
versionService.nodeUpdated(session, path);
return noContent().build();
} finally {
session.logout();
}
}

/**
* Retrieve multiple datastream bitstreams in a single request as a
* multipart/mixed response.
Expand Down
Expand Up @@ -19,7 +19,6 @@
import static javax.ws.rs.core.Response.notModified;
import static javax.ws.rs.core.Response.Status.CREATED;
import static javax.ws.rs.core.Response.Status.NOT_MODIFIED;
import static javax.ws.rs.core.Response.Status.NO_CONTENT;
import static org.apache.jena.riot.WebContent.contentTypeSPARQLUpdate;
import static org.apache.jena.riot.WebContent.contentTypeTurtle;
import static org.fcrepo.http.commons.test.util.PathSegmentImpl.createPathList;
Expand All @@ -45,7 +44,6 @@
import java.security.NoSuchAlgorithmException;
import java.text.ParseException;
import java.util.Date;
import java.util.List;
import java.util.Map;

import javax.jcr.Node;
Expand Down Expand Up @@ -316,24 +314,6 @@ public void testBatchDelete() throws Exception {
verify(mockSession).save();
}

@Test
public void testDeleteDatastreams() throws RepositoryException {
final String pid = "FedoraDatastreamsTest1";
final String path = "/" + pid;
final List<String> dsidList = asList("ds1", "ds2");

when(mockNodes.getObject(isA(Session.class), eq("/FedoraDatastreamsTest1/ds1"))).thenReturn(mockObject);
when(mockNodes.getObject(isA(Session.class), eq("/FedoraDatastreamsTest1/ds2"))).thenReturn(mockDatastream);

final Response actual =
testObj.batchDelete(createPathList(pid), dsidList);

assertEquals(NO_CONTENT.getStatusCode(), actual.getStatus());
verify(mockObject).delete();
verify(mockDatastream).delete();
verify(mockSession).save();
}

@Test
public void testGetDatastreamsContents() throws RepositoryException,
IOException,
Expand Down
Expand Up @@ -29,7 +29,6 @@
import static org.junit.Assert.assertTrue;

import org.apache.http.HttpResponse;
import org.apache.http.client.methods.HttpDelete;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.ContentType;
Expand Down Expand Up @@ -216,22 +215,4 @@ public void testNoChildren() throws Exception {
assertEquals(400, response.getStatusLine().getStatusCode());
}

@Test
public void testBatchDeleteDatastream() throws Exception {
final String pid = randomUUID().toString();
createObject(pid);

createDatastream(pid, "ds1", "foo1");
createDatastream(pid, "ds2", "foo2");

final HttpDelete dmethod =
new HttpDelete( serverAddress + pid + "/fcr:batch?child=ds1&child=ds2");
assertEquals(204, getStatus(dmethod));

final HttpGet method_test_get1 = new HttpGet(serverAddress + pid + "/ds1");
assertEquals(404, getStatus(method_test_get1));
final HttpGet method_test_get2 =
new HttpGet(serverAddress + pid + "/ds2");
assertEquals(404, getStatus(method_test_get2));
}
}

0 comments on commit fa198c9

Please sign in to comment.