Skip to content

Commit

Permalink
make the storagePolicyDecisionPoint an optional bean
Browse files Browse the repository at this point in the history
  • Loading branch information
cbeer committed Apr 29, 2013
1 parent a2bc6e8 commit d2d1751
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
Expand Up @@ -19,6 +19,7 @@
import org.fcrepo.utils.DatastreamIterator;
import org.modeshape.jcr.api.Binary;
import org.slf4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;

/**
* Service for creating and retrieving Datastreams without using the JCR API.
Expand All @@ -28,7 +29,7 @@
*/
public class DatastreamService extends RepositoryService {

@Inject
@Autowired(required=false)
PolicyDecisionPoint storagePolicyDecisionPoint;

private static final Logger logger = getLogger(DatastreamService.class);
Expand Down Expand Up @@ -79,6 +80,12 @@ public Node createDatastreamNode(final Session session,
return result;
}

/**
* Pre-create a Binary value to hand off to Datastream
* @param node the JCR node to attach the Binary to
* @param content a binary payload for the Binary
* @return a JCR Binary reference
*/
private Binary createBinary(final Node node, final InputStream content) {
/*
* https://docs.jboss.org/author/display/MODE/Binary+values#Binaryvalues-
Expand All @@ -87,11 +94,23 @@ private Binary createBinary(final Node node, final InputStream content) {
* implement this public interface, so feel free to cast the values to
* gain access to the additional methods."
*/
final Binary binary = (Binary) getBinary(node, content, storagePolicyDecisionPoint.evaluatePolicies(node));
final Binary binary = (Binary) getBinary(node, content, getStoragePolicyDecisionPoint().evaluatePolicies(node));

return binary;
}

/**
* Get the Policy Decision Point for this service. Initialize it if Spring didn't wire it in for us.
* @return a PolicyDecisionPoint
*/
private PolicyDecisionPoint getStoragePolicyDecisionPoint() {
if(storagePolicyDecisionPoint == null) {
storagePolicyDecisionPoint = new PolicyDecisionPoint();
}

return storagePolicyDecisionPoint;
}

/**
* retrieve the JCR node for a Datastream by pid and dsid
* @param path
Expand Down
1 change: 0 additions & 1 deletion fcrepo-webapp/src/main/resources/spring/repo.xml
Expand Up @@ -20,6 +20,5 @@
<bean class="org.fcrepo.services.ObjectService"/>
<bean class="org.fcrepo.services.DatastreamService"/>
<bean class="org.fcrepo.services.LowLevelStorageService"/>
<bean class="org.fcrepo.binary.PolicyDecisionPoint" />

</beans>

0 comments on commit d2d1751

Please sign in to comment.