Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
remove HTML responses where better RDF responses exist
  • Loading branch information
cbeer committed May 15, 2013
1 parent 0dbb83a commit 4f4321a
Show file tree
Hide file tree
Showing 8 changed files with 0 additions and 432 deletions.
101 changes: 0 additions & 101 deletions fcrepo-http-api/src/main/java/org/fcrepo/api/FedoraChildren.java

This file was deleted.

Expand Up @@ -60,40 +60,6 @@ public class FedoraDatastreams extends AbstractResource {

private final Logger logger = getLogger(FedoraDatastreams.class);

/**
* Returns a list of datastreams for the object
*
* @param pid
* persistent identifier of the digital object
* @return the list of datastreams
* @throws RepositoryException
* @throws IOException
*/

@GET
@Timed
@Produces({TEXT_XML, APPLICATION_JSON})
public ObjectDatastreams getDatastreams(@PathParam("path")
final List<PathSegment> pathList) throws RepositoryException, IOException {

final Session session = getAuthenticatedSession();

try {
final String path = toPath(pathList);
logger.info("getting datastreams of {}", path);
final ObjectDatastreams objectDatastreams = new ObjectDatastreams();

objectDatastreams.datastreams =
copyOf(transform(datastreamService
.getDatastreamsForPath(session, path), ds2dsElement));

return objectDatastreams;
} finally {
session.logout();
}

}

@POST
@Timed
public Response modifyDatastreams(@PathParam("path") final List<PathSegment> pathList,
Expand Down
131 changes: 0 additions & 131 deletions fcrepo-http-api/src/main/java/org/fcrepo/api/FedoraNodes.java
Expand Up @@ -65,67 +65,6 @@ public class FedoraNodes extends AbstractResource {

@Autowired
private LowLevelStorageService llStoreService;

/**
* Jersey seems to demote methods that @Produces(WILDCARD), even when
* no methods match the Accept header (eg, when it's null). This is
* appears to be an interpretation of
* http://jsr311.java.net/nonav/releases/1.1/spec/spec3.html#x3-360003.7.2
* So this is just a hack to dispatch to the "real" default.
* @param pathList
* @return
* @throws RepositoryException
* @throws IOException
*/
@GET
@Produces(WILDCARD)
public Response defaultDescribe(@PathParam("path") final List<PathSegment> pathList,
@Context final Request request) throws RepositoryException, IOException {
return describe(pathList, request);
}

@GET
@Produces({TEXT_XML, APPLICATION_JSON, APPLICATION_XML})
public Response describe(@PathParam("path") final List<PathSegment> pathList,
@Context final Request request) throws RepositoryException, IOException {

final String path = toPath(pathList);
logger.trace("getting profile for {}", path);

if ("/".equals(path)) {
return Response.ok(getRepositoryProfile()).build();
}


final Session session = getAuthenticatedSession();

try {
final FedoraResource resource = nodeService.getObject(session, path);

final Date date = resource.getLastModifiedDate();
final Date roundedDate = new Date();
roundedDate.setTime(date.getTime() - date.getTime() % 1000);

Response.ResponseBuilder builder = request.evaluatePreconditions(roundedDate);

if (builder == null) {
if (resource.hasContent()) {
builder = Response.ok(getDatastreamProfile(resource.getNode()));
} else {
builder = Response.ok(getObjectProfile(resource.getNode()));
}
}

final CacheControl cc = new CacheControl();
cc.setMaxAge(0);
cc.setMustRevalidate(true);

return builder.cacheControl(cc).lastModified(date).build();

} finally {
session.logout();
}
}

@GET
@Produces({N3, N3_ALT1, N3_ALT2, TURTLE, RDF_XML, RDF_JSON, NTRIPLES})
Expand Down Expand Up @@ -165,76 +104,6 @@ public Response describeRdf(@PathParam("path") final List<PathSegment> pathList,

}

/**
* Returns an object profile.
*
* @param node
* @return 200
* @throws RepositoryException
* @throws IOException
*/
public ObjectProfile getObjectProfile(Node node)
throws RepositoryException, IOException {

final String path = node.getPath();
logger.trace("getting object profile {}", path);
final ObjectProfile objectProfile = new ObjectProfile();
final FedoraObject obj = objectService.getObject(node.getSession(), path);
objectProfile.pid = obj.getName();
objectProfile.objCreateDate = obj.getCreatedDate();
objectProfile.objLastModDate = obj.getLastModifiedDate();
objectProfile.objSize = obj.getSize();
objectProfile.objItemIndexViewURL =
uriInfo.getAbsolutePathBuilder().path("datastreams").build();
objectProfile.objState = ObjectProfile.ObjectStates.A;
objectProfile.objModels = obj.getModels();

return objectProfile;

}

public DatastreamProfile getDatastreamProfile(Node node) throws RepositoryException, IOException {
final String path = node.getPath();
logger.trace("Executing getDatastream() with path: {}", path);
return getDatastreamProfile(datastreamService.getDatastream(node.getSession(), path));

}

private DatastreamProfile getDatastreamProfile(final Datastream ds)
throws RepositoryException, IOException {
logger.trace("Executing getDSProfile() with node: " + ds.getDsId());
final DatastreamProfile dsProfile = new DatastreamProfile();
dsProfile.dsID = ds.getDsId();
dsProfile.pid = ds.getObject().getName();
logger.trace("Retrieved datastream " + ds.getDsId() + "'s parent: " +
dsProfile.pid);
dsProfile.dsChecksumType = ds.getContentDigestType();
dsProfile.dsChecksum = ds.getContentDigest();
dsProfile.dsState = DatastreamProfile.DatastreamStates.A;
dsProfile.dsMIME = ds.getMimeType();
dsProfile.dsSize = ds.getSize();
dsProfile.dsCreateDate = ds.getCreatedDate();
dsProfile.dsLastModifiedDate = ds.getLastModifiedDate();
dsProfile.dsStores = new DatastreamProfile.DSStores(ds,
llStoreService.getLowLevelCacheEntries(ds.getNode()));
return dsProfile;
}

public DescribeRepository getRepositoryProfile() throws RepositoryException {

final Session session = getAuthenticatedSession();
final DescribeRepository description = new DescribeRepository();
description.repositoryBaseURL = uriInfo.getBaseUri();
description.sampleOAIURL =
uriInfo.getBaseUriBuilder().path("/123/oai_dc")
.build();
description.repositorySize = objectService.getRepositorySize();
description.numberOfObjects =
objectService.getRepositoryObjectCount(session);
session.logout();
return description;
}

/**
* Does nothing (good) yet -- just runs SPARQL-UPDATE statements
* @param pathList
Expand Down

This file was deleted.

Expand Up @@ -108,21 +108,6 @@ public void tearDown() {

}

@Test
public void testGetDatastreams() throws RepositoryException, IOException {
final String pid = "FedoraDatastreamsTest1";
final String path = "/objects/" + pid;
final String dsid = "testDS";
final DatastreamIterator mockIter =
TestHelpers.mockDatastreamIterator(pid, dsid, "asdf");
when(mockDatastreams.getDatastreamsForPath(mockSession, path)).thenReturn(mockIter);
final ObjectDatastreams actual = testObj.getDatastreams(createPathList("objects",pid));
verify(mockDatastreams).getDatastreamsForPath(mockSession, path);
verify(mockSession, never()).save();
assertEquals(1, actual.datastreams.size());
assertEquals(dsid, actual.datastreams.iterator().next().dsid);
}

@Test
public void testModifyDatastreams() throws RepositoryException,
IOException, InvalidChecksumException {
Expand Down

0 comments on commit 4f4321a

Please sign in to comment.