Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Revert "Stefano's patch for user-defined primaryType"
This reverts commit a3506b6.
  • Loading branch information
Stefano Cossu committed Jan 27, 2014
1 parent a3506b6 commit f636281
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 34 deletions.
Expand Up @@ -379,8 +379,6 @@ public Response createOrReplaceObjectRdf(
@Timed
public Response createObject(@PathParam("path")
final List<PathSegment> pathList,
@QueryParam("primaryType")
final String primaryType,
@QueryParam("mixin")
final String mixin,
@QueryParam("checksum")
Expand Down Expand Up @@ -452,7 +450,7 @@ public Response createObject(@PathParam("path")

switch (objectType) {
case FEDORA_OBJECT:
result = objectService.createObject(session, newObjectPath, primaryType);
result = objectService.createObject(session, newObjectPath);
break;
case FEDORA_DATASTREAM:
result = datastreamService.createDatastream(session, newObjectPath);
Expand Down Expand Up @@ -544,14 +542,13 @@ public Response createObject(@PathParam("path")
@Timed
public Response createObjectFromFormPost(
@PathParam("path") final List<PathSegment> pathList,
@FormDataParam("primaryType") final String primaryType,
@FormDataParam("mixin") final String mixin,
@FormDataParam("slug") final String slug,
@Context final UriInfo uriInfo,
@FormDataParam("file") final InputStream file
) throws RepositoryException, URISyntaxException, InvalidChecksumException, ParseException, IOException {

return createObject(pathList, primaryType, mixin, null, null, null, slug, uriInfo, file);
return createObject(pathList, mixin, null, null, null, slug, uriInfo, file);

}

Expand Down
Expand Up @@ -176,16 +176,16 @@ public void testIngestAndMint() throws RepositoryException {
public void testCreateObject() throws Exception {
final String pid = "testObject";
final String path = "/" + pid;
when(mockObjects.createObject(mockSession, path, null)).thenReturn(mockObject);
when(mockObjects.createObject(mockSession, path)).thenReturn(mockObject);
when(mockObject.getNode()).thenReturn(mockNode);
when(mockNode.getPath()).thenReturn(path);
final Response actual =
testObj.createObject(createPathList(pid), null, FEDORA_OBJECT, null,
testObj.createObject(createPathList(pid), FEDORA_OBJECT, null,
null, null, null, getUriInfoImpl(), null);
assertNotNull(actual);
assertEquals(CREATED.getStatusCode(), actual.getStatus());
assertTrue(actual.getEntity().toString().endsWith(pid));
verify(mockObjects).createObject(mockSession, path, null);
verify(mockObjects).createObject(mockSession, path);
verify(mockSession).save();
}

Expand All @@ -197,16 +197,16 @@ public void testCreateChildObject() throws Exception {
final String path = "/" + pid + "/a";
when(mockNodes.exists(mockSession, "/" + pid)).thenReturn(true);
when(mockPidMinter.mintPid()).thenReturn("a");
when(mockObjects.createObject(mockSession, path, null)).thenReturn(mockObject);
when(mockObjects.createObject(mockSession, path)).thenReturn(mockObject);
when(mockObject.getNode()).thenReturn(mockNode);
when(mockNode.getPath()).thenReturn(path);
final Response actual =
testObj.createObject(createPathList(pid), null, FEDORA_OBJECT, null, null,
testObj.createObject(createPathList(pid), FEDORA_OBJECT, null, null,
null, null, getUriInfoImpl(), null);
assertNotNull(actual);
assertEquals(CREATED.getStatusCode(), actual.getStatus());
assertTrue(actual.getEntity().toString().endsWith("a"));
verify(mockObjects).createObject(mockSession, path, null);
verify(mockObjects).createObject(mockSession, path);
verify(mockSession).save();
}

Expand All @@ -217,16 +217,16 @@ public void testCreateChildObjectWithSlug() throws Exception {
final String pid = "testObject";
final String path = "/" + pid + "/some-slug";
when(mockNodes.exists(mockSession, "/" + pid)).thenReturn(true);
when(mockObjects.createObject(mockSession, path, null)).thenReturn(mockObject);
when(mockObjects.createObject(mockSession, path)).thenReturn(mockObject);
when(mockObject.getNode()).thenReturn(mockNode);
when(mockNode.getPath()).thenReturn(path);
final Response actual =
testObj.createObject(createPathList(pid), null, FEDORA_OBJECT, null, null,
testObj.createObject(createPathList(pid), FEDORA_OBJECT, null, null,
null, "some-slug", getUriInfoImpl(), null);
assertNotNull(actual);
assertEquals(CREATED.getStatusCode(), actual.getStatus());
assertTrue(actual.getEntity().toString().endsWith("some-slug"));
verify(mockObjects).createObject(mockSession, path, null);
verify(mockObjects).createObject(mockSession, path);
verify(mockSession).save();
}

Expand All @@ -249,7 +249,7 @@ public void testCreateDatastream() throws Exception {
when(mockDatastreams.createDatastream(mockSession, dsPath)).thenReturn(mockDatastream);
when(mockNode.getPath()).thenReturn(dsPath);
final Response actual =
testObj.createObject(createPathList(pid, dsId), null,
testObj.createObject(createPathList(pid, dsId),
FEDORA_DATASTREAM, null, null, APPLICATION_OCTET_STREAM_TYPE, null, getUriInfoImpl(),
dsContentStream);
assertEquals(CREATED.getStatusCode(), actual.getStatus());
Expand Down Expand Up @@ -278,7 +278,7 @@ public void testCreateDatastreamWithContentDisposition() throws Exception {
when(mockDatastreams.createDatastream(mockSession, dsPath)).thenReturn(mockDatastream);
when(mockNode.getPath()).thenReturn(dsPath);
final Response actual =
testObj.createObject(createPathList(pid, dsId), null,
testObj.createObject(createPathList(pid, dsId),
FEDORA_DATASTREAM, null, "inline; filename=\"xyz.jpg\"", APPLICATION_OCTET_STREAM_TYPE, null, getUriInfoImpl(),
dsContentStream);
assertEquals(CREATED.getStatusCode(), actual.getStatus());
Expand Down
Expand Up @@ -47,24 +47,7 @@ public class ObjectService extends RepositoryService implements FedoraJcrTypes {
*/
public FedoraObject createObject(final Session session, final String path)
throws RepositoryException {
return createObject(session, path, NT_FOLDER);
}

/**
* @param session A JCR Session
* @param path The path to use to create the object
* @param primaryType The primary node type
* @return The created object
* @throws RepositoryException
* @author Stefano Cossu
*/
public FedoraObject createObject(final Session session, final String path, final String primaryType)
throws RepositoryException {
if (null == primaryType || primaryType.isEmpty()) {
return new FedoraObject(session, path, NT_FOLDER);
} else {
return new FedoraObject(session, path, primaryType);
}
return new FedoraObject(session, path, NT_FOLDER);
}

/**
Expand Down

0 comments on commit f636281

Please sign in to comment.