Skip to content

Commit

Permalink
Made DublinCore JAX-RS use ObjectService
Browse files Browse the repository at this point in the history
  • Loading branch information
ajs6f committed Feb 21, 2013
1 parent 6f45553 commit e98b514
Showing 1 changed file with 13 additions and 14 deletions.
27 changes: 13 additions & 14 deletions fcrepo-dc/src/main/java/org/fcrepo/generator/DublinCore.java
Expand Up @@ -3,15 +3,16 @@

import static javax.ws.rs.core.MediaType.TEXT_XML;
import static javax.ws.rs.core.Response.ok;
import static org.fcrepo.services.ObjectService.getObjectNode;

import java.io.InputStream;
import java.util.List;

import javax.annotation.Resource;
import javax.inject.Inject;
import javax.jcr.Node;
import javax.jcr.PathNotFoundException;
import javax.jcr.RepositoryException;
import javax.jcr.Session;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
Expand All @@ -20,35 +21,33 @@

import org.fcrepo.AbstractResource;
import org.fcrepo.generator.dublincore.AbstractIndexer;
import org.fcrepo.services.ObjectService;

@Path("/objects/{pid}/oai_dc")
public class DublinCore extends AbstractResource {

@Resource
List<AbstractIndexer> indexers;

@Inject
ObjectService objectService;

@GET
@Produces(TEXT_XML)
public Response getObjectAsDublinCore(@PathParam("pid")
final String pid) throws RepositoryException {
final Session session = repo.login();

try {

final Node obj = session.getNode("/objects/" + pid);
final Node obj = getObjectNode(pid);

for (AbstractIndexer indexer : indexers) {
InputStream inputStream = indexer.getStream(obj);
for (AbstractIndexer indexer : indexers) {
InputStream inputStream = indexer.getStream(obj);

if (inputStream != null) {
return ok(inputStream).build();
}
if (inputStream != null) {
return ok(inputStream).build();
}
// no indexers = no path for DC
throw new PathNotFoundException();
} finally {
session.logout();
}
// no indexers = no path for DC
throw new PathNotFoundException();

}

Expand Down

0 comments on commit e98b514

Please sign in to comment.