Skip to content

Commit

Permalink
Merge pull request #104 from futures/remove-fcr-new
Browse files Browse the repository at this point in the history
replace .../fcr:new with a POST to a Node
  • Loading branch information
ajs6f committed Jul 30, 2013
2 parents 8b3be13 + 0aba466 commit 88bfddc
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 352 deletions.
22 changes: 15 additions & 7 deletions fcrepo-http-api/src/main/java/org/fcrepo/api/FedoraNodes.java
Expand Up @@ -405,16 +405,25 @@ public Response createObject(@PathParam("path")
final UriInfo uriInfo, final InputStream requestBodyStream)
throws RepositoryException, IOException, InvalidChecksumException, URISyntaxException {

final String newObjectPath;
final String path = toPath(pathList);
logger.debug("Attempting to ingest with path: {}", path);


if (nodeService.exists(session, path)) {
final String pid = pidMinter.mintPid();
newObjectPath = path + "/" + pid;
} else {
newObjectPath = path;
}

logger.debug("Attempting to ingest with path: {}", newObjectPath);

try {
if (nodeService.exists(session, path)) {
if (nodeService.exists(session, newObjectPath)) {
return status(SC_CONFLICT).entity(
path + " is an existing resource!").build();
}


final URI checksumURI;

if (checksum != null && !checksum.equals("")) {
Expand All @@ -423,17 +432,16 @@ public Response createObject(@PathParam("path")
checksumURI = null;
}


final HttpGraphSubjects subjects = new HttpGraphSubjects(session, FedoraNodes.class, uriInfo);
final FedoraResource resource = createObjectOrDatastreamFromRequestContent(FedoraNodes.class,
session, path, mixin, uriInfo, requestBodyStream,
session, newObjectPath, mixin, uriInfo, requestBodyStream,
requestContentType, checksumURI);

session.save();
logger.debug("Finished creating {} with path: {}", mixin, path);
logger.debug("Finished creating {} with path: {}", mixin, newObjectPath);

return created(new URI(subjects.getGraphSubject(resource.getNode())
.getURI())).entity(path).build();
.getURI())).entity(newObjectPath).build();

} finally {
session.logout();
Expand Down
132 changes: 0 additions & 132 deletions fcrepo-http-api/src/main/java/org/fcrepo/api/FedoraUnnamedObjects.java

This file was deleted.

This file was deleted.

Expand Up @@ -156,7 +156,6 @@ public void testCreateObject() throws RepositoryException, IOException,
assertNotNull(actual);
assertEquals(CREATED.getStatusCode(), actual.getStatus());
assertTrue(actual.getEntity().toString().endsWith(pid));
verify(mockNodes).exists(mockSession, path);
verify(mockObjects).createObject(mockSession, path);
verify(mockSession).save();
}
Expand Down

This file was deleted.

Expand Up @@ -35,6 +35,7 @@
import static org.fcrepo.utils.FedoraJcrTypes.ROOT;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;

Expand Down Expand Up @@ -90,7 +91,7 @@ public void testIngest() throws Exception {

@Test
public void testIngestWithNew() throws Exception {
final HttpPost method = postObjMethod("fcr:new");
final HttpPost method = postObjMethod("");
final HttpResponse response = client.execute(method);
final String content = EntityUtils.toString(response.getEntity());
final int status = response.getStatusLine().getStatusCode();
Expand All @@ -100,9 +101,11 @@ public void testIngestWithNew() throws Exception {
.find());
assertTrue("new object did not mint a PID", !content
.endsWith("/fcr:new"));
final String location = response.getFirstHeader("Location").getValue();
assertNotEquals(serverAddress + "/objects", location);

assertEquals("Object wasn't created!", OK.getStatusCode(),
getStatus(new HttpGet(serverAddress + content)));
getStatus(new HttpGet(location)));
}

@Test
Expand Down

0 comments on commit 88bfddc

Please sign in to comment.