Skip to content
Permalink
Browse files

Update policy-driven-storage for runtime configuration

Move configuration from Spring to the repository
Add REST endpoint for runtime configuration
Resolves:
  https://www.pivotaltracker.com/story/show/49059799
  https://www.pivotaltracker.com/story/show/54197412
  • Loading branch information...
osmandin authored and awoods committed Aug 13, 2013
1 parent b2ebc22 commit 2972371cfc2b613d1f9497973be0f9e0fd3efb41
Showing with 1,712 additions and 196 deletions.
  1. +0 −1 fcrepo-auth-oauth/src/test/resources/spring-test/repo.xml
  2. +0 −1 fcrepo-generator-dc/src/test/resources/spring-test/repo.xml
  3. +0 −1 fcrepo-http-api/src/test/resources/spring-test/repo.xml
  4. +0 −1 fcrepo-jms/src/test/resources/spring-test/repo.xml
  5. +1 −9 fcrepo-kernel/pom.xml
  6. +2 −2 fcrepo-kernel/src/main/java/org/fcrepo/kernel/Datastream.java
  7. +5 −5 fcrepo-kernel/src/main/java/org/fcrepo/kernel/services/DatastreamService.java
  8. +1 −1 ...a/org/fcrepo/storage → fcrepo-kernel/src/main/java/org/fcrepo/kernel/services}/policy/Policy.java
  9. +75 −0 fcrepo-kernel/src/main/java/org/fcrepo/kernel/services/policy/StoragePolicyDecisionPoint.java
  10. +0 −62 fcrepo-kernel/src/test/java/org/fcrepo/integration/kernel/PolicyDecisionPointDemoIT.java
  11. +6 −2 fcrepo-kernel/src/test/java/org/fcrepo/integration/kernel/utils/SelfHealingIT.java
  12. +2 −2 fcrepo-kernel/src/test/java/org/fcrepo/kernel/services/DatastreamServiceTest.java
  13. +1 −2 fcrepo-kernel/src/test/resources/spring-test/repo.xml
  14. +0 −1 fcrepo-rss/src/test/resources/spring-test/repo.xml
  15. +76 −13 fcrepo-storage-policy/pom.xml
  16. +65 −12 fcrepo-storage-policy/src/main/java/org/fcrepo/storage/policy/MimeTypePolicy.java
  17. +64 −19 fcrepo-storage-policy/src/main/java/org/fcrepo/storage/policy/PolicyDecisionPoint.java
  18. +279 −0 fcrepo-storage-policy/src/main/java/org/fcrepo/storage/policy/PolicyGenerator.java
  19. +32 −0 fcrepo-storage-policy/src/main/java/org/fcrepo/storage/policy/PolicyTypeException.java
  20. +104 −0 fcrepo-storage-policy/src/test/java/org/fcrepo/storage/policy/AbstractResourceIT.java
  21. +120 −0 fcrepo-storage-policy/src/test/java/org/fcrepo/storage/policy/ContainerWrapper.java
  22. +12 −2 fcrepo-storage-policy/src/test/java/org/fcrepo/storage/policy/MimeTypePolicyTest.java
  23. +3 −4 fcrepo-storage-policy/src/test/java/org/fcrepo/storage/policy/PolicyDecisionPointTest.java
  24. +70 −0 fcrepo-storage-policy/src/test/java/org/fcrepo/storage/policy/PolicyGeneratorIT.java
  25. +110 −0 fcrepo-storage-policy/src/test/java/org/fcrepo/storage/policy/PolicyGeneratorTest.java
  26. +3 −4 ...l/utils → fcrepo-storage-policy/src/test/java/org/fcrepo/storage/policy}/TiffPolicyStorageIT.java
  27. +114 −0 fcrepo-storage-policy/src/test/java/org/fcrepo/storage/policy/WebAppConfig.java
  28. +32 −0 fcrepo-storage-policy/src/test/java/org/fcrepo/storage/policy/bind/ContextParam.java
  29. +30 −0 fcrepo-storage-policy/src/test/java/org/fcrepo/storage/policy/bind/Describable.java
  30. +29 −0 fcrepo-storage-policy/src/test/java/org/fcrepo/storage/policy/bind/Displayable.java
  31. +54 −0 fcrepo-storage-policy/src/test/java/org/fcrepo/storage/policy/bind/Filter.java
  32. +49 −0 fcrepo-storage-policy/src/test/java/org/fcrepo/storage/policy/bind/FilterMapping.java
  33. +32 −0 fcrepo-storage-policy/src/test/java/org/fcrepo/storage/policy/bind/InitParam.java
  34. +56 −0 fcrepo-storage-policy/src/test/java/org/fcrepo/storage/policy/bind/Listener.java
  35. +63 −0 fcrepo-storage-policy/src/test/java/org/fcrepo/storage/policy/bind/Param.java
  36. +61 −0 fcrepo-storage-policy/src/test/java/org/fcrepo/storage/policy/bind/Servlet.java
  37. +30 −0 fcrepo-storage-policy/src/test/java/org/fcrepo/storage/policy/bind/ServletMapping.java
  38. +30 −0 fcrepo-storage-policy/src/test/java/org/fcrepo/storage/policy/bind/UrlMappable.java
  39. +0 −43 fcrepo-storage-policy/src/test/resources/my_repository.json
  40. +35 −0 fcrepo-storage-policy/src/test/resources/repository.json
  41. +2 −2 fcrepo-storage-policy/src/test/resources/spring-test/repo.xml
  42. +16 −0 fcrepo-storage-policy/src/test/resources/spring-test/rest.xml
  43. +3 −4 fcrepo-storage-policy/src/test/resources/spring-test/test-container.xml
  44. +37 −0 fcrepo-storage-policy/src/test/resources/web.xml
  45. +0 −1 fcrepo-transform/src/test/resources/spring-test/repo.xml
  46. +5 −0 fcrepo-webapp/pom.xml
  47. +3 −1 fcrepo-webapp/src/main/resources/spring/rest.xml
  48. +0 −1 fcrepo-webhooks/src/test/resources/spring-test/repo.xml
@@ -17,6 +17,5 @@

<bean class="org.modeshape.jcr.JcrRepositoryFactory"/>

<bean class="org.fcrepo.storage.policy.PolicyDecisionPoint" />

</beans>
@@ -19,6 +19,5 @@


<bean class="org.modeshape.jcr.JcrRepositoryFactory"/>
<bean class="org.fcrepo.storage.policy.PolicyDecisionPoint" />

</beans>
@@ -16,6 +16,5 @@
</bean>

<bean class="org.modeshape.jcr.JcrRepositoryFactory"/>
<bean class="org.fcrepo.storage.policy.PolicyDecisionPoint" />

</beans>
@@ -17,7 +17,6 @@
</bean>

<bean class="org.modeshape.jcr.JcrRepositoryFactory"/>
<bean class="org.fcrepo.storage.policy.PolicyDecisionPoint" />


</beans>
@@ -42,20 +42,12 @@
<groupId>org.fcrepo</groupId>
<artifactId>fcrepo-metrics</artifactId>
<version>${project.version}</version>
</dependency>

<dependency>
<groupId>org.fcrepo</groupId>
<artifactId>fcrepo-storage-policy</artifactId>
<version>${project.version}</version>
</dependency>

</dependency>
<dependency>
<groupId>org.apache.jena</groupId>
<artifactId>apache-jena-libs</artifactId>
<type>pom</type>
</dependency>

<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
@@ -35,7 +35,7 @@
import javax.jcr.RepositoryException;
import javax.jcr.Session;

import org.fcrepo.storage.policy.PolicyDecisionPoint;
import org.fcrepo.kernel.services.policy.StoragePolicyDecisionPoint;
import org.fcrepo.kernel.exception.InvalidChecksumException;
import org.fcrepo.kernel.utils.ContentDigest;
import org.fcrepo.jcr.FedoraJcrTypes;
@@ -125,7 +125,7 @@ public InputStream getContent() throws RepositoryException {
*/
public void setContent(final InputStream content, final String contentType,
final URI checksum,
PolicyDecisionPoint storagePolicyDecisionPoint)
StoragePolicyDecisionPoint storagePolicyDecisionPoint)
throws RepositoryException, InvalidChecksumException {

final Node contentNode =
@@ -36,10 +36,10 @@
import javax.jcr.Session;

import org.fcrepo.kernel.Datastream;
import org.fcrepo.storage.policy.PolicyDecisionPoint;
import org.fcrepo.kernel.exception.InvalidChecksumException;
import org.fcrepo.kernel.rdf.GraphProperties;
import org.fcrepo.kernel.rdf.GraphSubjects;
import org.fcrepo.kernel.services.policy.StoragePolicyDecisionPoint;
import org.fcrepo.kernel.utils.FixityResult;
import org.fcrepo.kernel.utils.JcrRdfTools;
import org.fcrepo.kernel.utils.LowLevelCacheEntry;
@@ -66,7 +66,7 @@
public class DatastreamService extends RepositoryService {

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

@Autowired
private LowLevelStorageService llStoreService;
@@ -311,7 +311,7 @@ public void setLlStoreService(final LowLevelStorageService llStoreService) {
*
* @param pdp
*/
public void setStoragePolicyDecisionPoint(final PolicyDecisionPoint pdp) {
public void setStoragePolicyDecisionPoint(final StoragePolicyDecisionPoint pdp) {
this.storagePolicyDecisionPoint = pdp;
}

@@ -321,9 +321,9 @@ public void setStoragePolicyDecisionPoint(final PolicyDecisionPoint pdp) {
*
* @return a PolicyDecisionPoint
*/
private PolicyDecisionPoint getStoragePolicyDecisionPoint() {
private StoragePolicyDecisionPoint getStoragePolicyDecisionPoint() {
if (storagePolicyDecisionPoint == null) {
storagePolicyDecisionPoint = new PolicyDecisionPoint();
// storagePolicyDecisionPoint = new PolicyDecisionPoint();
}

return storagePolicyDecisionPoint;
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.fcrepo.storage.policy;
package org.fcrepo.kernel.services.policy;

import javax.jcr.Node;

@@ -0,0 +1,75 @@
/**
* Copyright 2013 DuraSpace, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.fcrepo.kernel.services.policy;

import javax.jcr.Node;

import java.util.List;

/**
* Service Interface implementation for managing and using org.fcrepo.kernel.services.policy.Policy
* @author osmandin
* @date Aug 14, 2013
*
*/
public interface StoragePolicyDecisionPoint {

/**
* Add a new storage policy
*
* @param p org.fcrepo.kernel.services.policy object
*/
public abstract void addPolicy(Policy p);

/**
* Given a JCR node (likely a jcr:content node), determine which storage
* policy should apply
*
* @param n
* @return
*/
public abstract String evaluatePolicies(Node n);

/**
* Remove a storage policy
*
* @param p org.fcrepo.kernel.services.policy object
*/
public abstract void removePolicy(Policy p);

/**
* Explicitly set the policies this PDP should use
*
* @param policies
*/
public abstract void setPolicies(List<Policy> policies);

/**
* @param policy
*/
public abstract boolean contains(Policy policy);

/**
* clear all policies
*/
public void removeAll();

/**
* @return policies size
*/
public abstract int size();
}

This file was deleted.

Oops, something went wrong.
@@ -37,10 +37,10 @@
import org.apache.commons.codec.binary.Hex;
import org.apache.poi.util.IOUtils;
import org.fcrepo.kernel.Datastream;
import org.fcrepo.storage.policy.PolicyDecisionPoint;
import org.fcrepo.kernel.services.DatastreamService;
import org.fcrepo.kernel.services.LowLevelStorageService;
import org.fcrepo.kernel.services.ObjectService;
import org.fcrepo.kernel.services.policy.StoragePolicyDecisionPoint;
import org.fcrepo.kernel.utils.ContentDigest;
import org.fcrepo.kernel.utils.FixityResult;
import org.fcrepo.kernel.utils.LowLevelCacheEntry;
@@ -54,6 +54,7 @@
import org.modeshape.jcr.api.JcrConstants;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;


public class SelfHealingIT {
@@ -67,6 +68,9 @@
private ObjectService objectService;

private LowLevelStorageService lowLevelService;

@Autowired(required = false)
StoragePolicyDecisionPoint storagePolicyDecisionPoint;

@Before
public void setLogger() {
@@ -86,7 +90,7 @@ public void setRepository() throws RepositoryException {
datastreamService = new DatastreamService();
datastreamService.setRepository(repo);
datastreamService
.setStoragePolicyDecisionPoint(new PolicyDecisionPoint());
.setStoragePolicyDecisionPoint(storagePolicyDecisionPoint);
objectService = new ObjectService();
objectService.setRepository(repo);
lowLevelService = new LowLevelStorageService();
@@ -48,9 +48,9 @@
import org.fcrepo.kernel.services.DatastreamService;
import org.fcrepo.kernel.services.LowLevelStorageService;
import org.fcrepo.kernel.services.ServiceHelpers;
import org.fcrepo.storage.policy.PolicyDecisionPoint;
import org.fcrepo.kernel.rdf.GraphSubjects;
import org.fcrepo.kernel.services.functions.CheckCacheEntryFixity;
import org.fcrepo.kernel.services.policy.StoragePolicyDecisionPoint;
import org.fcrepo.jcr.FedoraJcrTypes;
import org.fcrepo.kernel.utils.FedoraTypesUtils;
import org.fcrepo.kernel.utils.FixityResult;
@@ -123,7 +123,7 @@ public void testCreateDatastreamNode() throws Exception {
when(mockContent.setProperty(JCR_DATA, mockBinary))
.thenReturn(mockData);
when(mockContent.getProperty(JCR_DATA)).thenReturn(mockData);
final PolicyDecisionPoint pdp = mock(PolicyDecisionPoint.class);
final StoragePolicyDecisionPoint pdp = mock(StoragePolicyDecisionPoint.class);
when(pdp.evaluatePolicies(mockNode)).thenReturn(null);
testObj.setStoragePolicyDecisionPoint(pdp);
mockStatic(FedoraTypesUtils.class);
@@ -19,10 +19,9 @@
</bean>

<context:component-scan
base-package="org.fcrepo.kernel.services"/>
base-package="org.fcrepo.kernel.services, org.fcrepo.storage.policy"/>


<bean class="org.modeshape.jcr.JcrRepositoryFactory"/>
<bean class="org.fcrepo.storage.policy.PolicyDecisionPoint" />

</beans>
@@ -22,6 +22,5 @@
<bean class="org.fcrepo.kernel.identifiers.UUIDPidMinter"/>

<bean class="org.modeshape.jcr.JcrRepositoryFactory"/>
<bean class="org.fcrepo.storage.policy.PolicyDecisionPoint" />

</beans>
Oops, something went wrong.

0 comments on commit 2972371

Please sign in to comment.
You can’t perform that action at this time.