Skip to content

Commit

Permalink
Added datastreamHistory XML stub
Browse files Browse the repository at this point in the history
  • Loading branch information
ajs6f committed Jan 18, 2013
1 parent f9e2aab commit e277b3c
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 9 deletions.
Expand Up @@ -2,6 +2,7 @@

import java.io.IOException;
import java.io.InputStream;
import java.util.Calendar;
import java.util.Map;

import javax.jcr.ItemExistsException;
Expand All @@ -24,7 +25,6 @@
import com.google.common.collect.ImmutableSet.Builder;

import freemarker.template.TemplateException;
import java.util.Calendar;

@Path("/objects/{pid}/datastreams")
public class FedoraDatastreams extends AbstractResource {
Expand All @@ -41,7 +41,7 @@ public Response getDatastreams(@PathParam("pid") final String pid)
throws RepositoryException, IOException, TemplateException {

final Node root = ws.getSession().getRootNode();

if (root.hasNode(pid)) {

@SuppressWarnings("unchecked")
Expand Down Expand Up @@ -162,10 +162,10 @@ public Response getDatastream(@PathParam("pid") final String pid,
if (root.hasNode(pid + "/" + dsid)) {
return Response
.ok()
.entity(renderTemplate(
"datastreamProfile.ftl",
.entity(renderTemplate("datastreamProfile.ftl",
ImmutableMap.of("ds",
(Object) root.getNode(pid + "/" + dsid), "obj", (Object) root.getNode(pid))))
(Object) root.getNode(pid + "/" + dsid),
"obj", (Object) root.getNode(pid))))
.build();
} else {
return four04;
Expand All @@ -192,6 +192,25 @@ public Response getDatastreamContent(@PathParam("pid") final String pid,
}
}

@GET
@Path("/{dsid}/versions")
@Produces("text/xml")
public Response getDatastreamHistory(@PathParam("pid") final String pid,
@PathParam("dsid") final String dsid) throws RepositoryException,
IOException, TemplateException {
final Node root = ws.getSession().getRootNode();
if (root.hasNode(pid + "/" + dsid)) {
final Node ds = root.getNode(pid + "/" + dsid);
return Response
.ok()
.entity(renderTemplate("datastreamHistory.ftl",
ImmutableMap.of("ds", (Object) ds))).build();
} else {
return four04;
}

}

@DELETE
@Path("/{dsid}")
public Response deleteDatastream(@PathParam("pid") String pid,
Expand Down
9 changes: 5 additions & 4 deletions src/main/resources/fedora-node-types.cnd
Expand Up @@ -16,16 +16,17 @@
*/
<fedora = 'info:fedora'>


/*
* Any Fedora resource.
*/
[fedora:resource] > mix:versionable, nt:hierarchyNode abstract
[fedora:resource] > mix:lastModified, mix:versionable, nt:hierarchyNode abstract


/*
* A Fedora object.
*/
[fedora:object] > fedora:resource
[fedora:object] > fedora:resource
+ * (fedora:datastream) = fedora:datastream COPY


Expand Down Expand Up @@ -64,8 +65,8 @@
/*
* Indicates that this resource is owned.
*/
[fedora:created] > mix:created,mix:lastModified
mixin
[fedora:created] > mix:created, mix:lastModified mixin


/*
* Some entity that owns a Fedora resource.
Expand Down
18 changes: 18 additions & 0 deletions src/main/resources/freemarker/datastreamHistory.ftl
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<datastreamProfile xmlns="http://www.fedora.info/definitions/1/0/management/"
pid="${ds.getParent().getName()}" dsID="${ds.getName()}">
<dsLabel>${ds.getName()}</dsLabel>
<dsVersionID></dsVersionID>
<dsCreateDate></dsCreateDate>
<dsState>A</dsState>
<dsMIME>${ds.getProperty("fedora:contentType").getString()}</dsMIME>
<dsFormatURI>http://www.oxygenxml.com/</dsFormatURI>
<dsControlGroup>M</dsControlGroup>
<dsSize>0</dsSize>
<dsVersionable>true</dsVersionable>
<dsInfoType></dsInfoType>
<dsLocation>${ds.getPath()}</dsLocation>
<dsLocationType></dsLocationType>
<dsChecksumType></dsChecksumType>
<dsChecksum></dsChecksum>
</datastreamProfile>

0 comments on commit e277b3c

Please sign in to comment.