Skip to content

Commit

Permalink
Merging Bens globbing with Pauls changes.
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonathan Green authored and cbeer committed Apr 26, 2013
1 parent 8f5a6dc commit 3e8f10b
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 7 deletions.
27 changes: 20 additions & 7 deletions fcrepo-http-api/src/main/java/org/fcrepo/api/FedoraDescribe.java
Expand Up @@ -27,6 +27,7 @@
import org.fcrepo.jaxb.responses.management.DatastreamProfile;
import org.fcrepo.provider.VelocityViewer;
import org.fcrepo.services.DatastreamService;
import org.fcrepo.services.LowLevelStorageService;
import org.fcrepo.services.ObjectService;
import org.slf4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
Expand All @@ -47,6 +48,9 @@ public class FedoraDescribe extends AbstractResource {
@Autowired
private DatastreamService datastreamService;

@Autowired
private LowLevelStorageService llStoreService;

@GET
@Produces({TEXT_XML, APPLICATION_JSON, TEXT_HTML})
public Response describe(@PathParam("path")
Expand All @@ -70,7 +74,7 @@ public Response describe(@PathParam("path")

/**
* Returns an object profile.
*
*
* @param path
* @return 200
* @throws RepositoryException
Expand All @@ -96,16 +100,16 @@ public ObjectProfile getObjectProfile(Node node)
return objectProfile;

}

public ObjectService getObjectService() {
return objectService;
}


public void setObjectService(ObjectService objectService) {
this.objectService = objectService;
}

public DatastreamProfile getDatastreamProfile(Node node) throws RepositoryException, IOException {
final String path = node.getPath();
logger.trace("Executing getDatastream() with path: {}", path);
Expand All @@ -131,14 +135,16 @@ private DatastreamProfile getDatastreamProfile(final Datastream ds)
dsProfile.dsMIME = ds.getMimeType();
dsProfile.dsSize = ds.getSize();
dsProfile.dsCreateDate = ds.getCreatedDate().toString();
dsProfile.dsStores = new DatastreamProfile.DSStores(ds,
llStoreService.getLowLevelCacheEntries(ds.getNode()));
return dsProfile;
}

public DatastreamService getDatastreamService() {
return datastreamService;
}


public void setDatastreamService(DatastreamService datastreamService) {
this.datastreamService = datastreamService;
}
Expand All @@ -157,12 +163,19 @@ public DescribeRepository getRepositoryProfile() throws RepositoryException {
session.logout();
return description;
}

//TODO Figure out how to call this
public String getRepositoryProfileHtml() throws RepositoryException {

final VelocityViewer view = new VelocityViewer();
return view.getRepoInfo(getRepositoryProfile());
}


public LowLevelStorageService getLlStoreService() {
return llStoreService;
}

public void setLlStoreService(final LowLevelStorageService llStoreService) {
this.llStoreService = llStoreService;
}
}
Expand Up @@ -2,10 +2,16 @@
package org.fcrepo.jaxb.responses.management;

import java.net.URI;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Set;

import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import org.fcrepo.Datastream;
import org.fcrepo.utils.LowLevelCacheEntry;

import org.joda.time.DateTime;
import org.joda.time.format.DateTimeFormatter;
Expand Down Expand Up @@ -64,6 +70,9 @@ public class DatastreamProfile {

@XmlElement
public URI dsChecksum;

@XmlElement
public DSStores dsStores;

public static enum DatastreamControlGroup {
M, E, R
Expand All @@ -83,5 +92,30 @@ public static String convertDateToXSDString(final long date) {
final DateTimeFormatter fmt = ISODateTimeFormat.dateTime();
return fmt.print(dt);
}

/**
* adds the datastream store information to the datastream profile output.
*
* datastream profile output in fcrepo4 no longer matches output from
* fcrepo3.x
*
*/
public static class DSStores {

@XmlElement(name = "dsStore")
public List<String> storeIdentifiers ;

public DSStores(){
this.storeIdentifiers = new ArrayList();
}

public DSStores(Datastream datastream, Set cacheEntries) {
this.storeIdentifiers = new ArrayList();
for (Iterator it = cacheEntries.iterator(); it.hasNext();) {
LowLevelCacheEntry cacheEntry = (LowLevelCacheEntry) it.next();
storeIdentifiers.add(cacheEntry.getExternalIdentifier());
}
}
}

}

0 comments on commit 3e8f10b

Please sign in to comment.