- Added onContentRead policy to help support planned samples

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@2284 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Roy Wetherall
2006-02-02 12:23:43 +00:00
parent 5d8d0e136c
commit a38de2aa2d
3 changed files with 58 additions and 1 deletions

View File

@@ -22,6 +22,7 @@ import java.util.Map;
import java.util.Set;
import org.alfresco.error.AlfrescoRuntimeException;
import org.alfresco.repo.content.ContentServicePolicies.OnContentReadPolicy;
import org.alfresco.repo.content.ContentServicePolicies.OnContentUpdatePolicy;
import org.alfresco.repo.content.filestore.FileContentStore;
import org.alfresco.repo.content.transform.ContentTransformer;
@@ -77,9 +78,10 @@ public class RoutingContentService implements ContentService
private PolicyComponent policyComponent;
/**
* The onContentService policy delegate
* Policies delegate
*/
ClassPolicyDelegate<ContentServicePolicies.OnContentUpdatePolicy> onContentUpdateDelegate;
ClassPolicyDelegate<ContentServicePolicies.OnContentReadPolicy> onContentReadDelegate;
/**
* Default constructor sets up a temporary store
@@ -132,6 +134,7 @@ public class RoutingContentService implements ContentService
// Register on content update policy
this.onContentUpdateDelegate = this.policyComponent.registerClassPolicy(OnContentUpdatePolicy.class);
this.onContentReadDelegate = this.policyComponent.registerClassPolicy(OnContentReadPolicy.class);
}
/**
@@ -259,6 +262,16 @@ public class RoutingContentService implements ContentService
reader.setMimetype(contentData.getMimetype());
reader.setEncoding(contentData.getEncoding());
// Fire the content read policy
if (reader != null)
{
// Fire the content update policy
Set<QName> types = new HashSet<QName>(this.nodeService.getAspects(nodeRef));
types.add(this.nodeService.getType(nodeRef));
OnContentReadPolicy policy = this.onContentReadDelegate.get(types);
policy.onContentRead(nodeRef);
}
// we don't listen for anything
// result may be null - but interface contract says we may return null
return reader;