Skip to content

Commit

Permalink
Altered HTTP API endpoints to use Datastream.getCreatedDate()
Browse files Browse the repository at this point in the history
  • Loading branch information
ajs6f committed Feb 28, 2013
1 parent 0c46d84 commit b114512
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 16 deletions.
Expand Up @@ -135,13 +135,15 @@ public Response addDatastreams(@PathParam("pid")
@GET
@Path("/__content__")
@Produces("multipart/mixed")
public MultipartBody getDatastreamsContents(@PathParam("pid") final String pid, @QueryParam("dsid") List<String> dsids) throws RepositoryException, IOException {
public MultipartBody getDatastreamsContents(@PathParam("pid")
final String pid, @QueryParam("dsid")
List<String> dsids) throws RepositoryException, IOException {

final Session session = repo.login();

if(dsids.isEmpty()) {
if (dsids.isEmpty()) {
NodeIterator ni = getObjectNode(pid).getNodes();
while(ni.hasNext()) {
while (ni.hasNext()) {
dsids.add(ni.nextNode().getName());
}
}
Expand All @@ -153,9 +155,11 @@ public MultipartBody getDatastreamsContents(@PathParam("pid") final String pid,
final String dsid = i.next();

try {
final Datastream ds = DatastreamService.getDatastream(pid, dsid);
atts.add(new Attachment(ds.getNode().getName(), ds.getMimeType(), ds.getContent()));
} catch(PathNotFoundException e) {
final Datastream ds =
DatastreamService.getDatastream(pid, dsid);
atts.add(new Attachment(ds.getNode().getName(), ds
.getMimeType(), ds.getContent()));
} catch (PathNotFoundException e) {

}
}
Expand Down Expand Up @@ -410,8 +414,7 @@ private DatastreamProfile getDSProfile(Datastream ds)
dsProfile.dsMIME = ds.getMimeType();
dsProfile.dsSize =
getNodePropertySize(ds.getNode()) + ds.getContentSize();
dsProfile.dsCreateDate =
ds.getNode().getProperty("jcr:created").getString();
dsProfile.dsCreateDate = ds.getCreatedDate().toString();
return dsProfile;
}

Expand Down
Expand Up @@ -135,13 +135,15 @@ public Response addDatastreams(@PathParam("pid")
@GET
@Path("/__content__")
@Produces("multipart/mixed")
public MultipartBody getDatastreamsContents(@PathParam("pid") final String pid, @QueryParam("dsid") List<String> dsids) throws RepositoryException, IOException {
public MultipartBody getDatastreamsContents(@PathParam("pid")
final String pid, @QueryParam("dsid")
List<String> dsids) throws RepositoryException, IOException {

final Session session = repo.login();

if(dsids.isEmpty()) {
if (dsids.isEmpty()) {
NodeIterator ni = getObjectNode(pid).getNodes();
while(ni.hasNext()) {
while (ni.hasNext()) {
dsids.add(ni.nextNode().getName());
}
}
Expand All @@ -153,9 +155,11 @@ public MultipartBody getDatastreamsContents(@PathParam("pid") final String pid,
final String dsid = i.next();

try {
final Datastream ds = DatastreamService.getDatastream(pid, dsid);
atts.add(new Attachment(ds.getNode().getName(), ds.getMimeType(), ds.getContent()));
} catch(PathNotFoundException e) {
final Datastream ds =
DatastreamService.getDatastream(pid, dsid);
atts.add(new Attachment(ds.getNode().getName(), ds
.getMimeType(), ds.getContent()));
} catch (PathNotFoundException e) {

}
}
Expand Down Expand Up @@ -410,8 +414,7 @@ private DatastreamProfile getDSProfile(Datastream ds)
dsProfile.dsMIME = ds.getMimeType();
dsProfile.dsSize =
getNodePropertySize(ds.getNode()) + ds.getContentSize();
dsProfile.dsCreateDate =
ds.getNode().getProperty("jcr:created").getString();
dsProfile.dsCreateDate = ds.getCreatedDate().toString();
return dsProfile;
}

Expand Down

0 comments on commit b114512

Please sign in to comment.