Permalink
Browse files

Added datastreamHistory XML stub

  • Loading branch information...
ajs6f committed Jan 18, 2013
1 parent f9e2aab commit e277b3cca966f4abb61b41135c714fd0e44c39fe
@@ -2,6 +2,7 @@
import java.io.IOException;
import java.io.InputStream;
+import java.util.Calendar;
import java.util.Map;
import javax.jcr.ItemExistsException;
@@ -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 {
@@ -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")
@@ -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;
@@ -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,
@@ -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
@@ -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.
@@ -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.