Thumbnail Service and Upload: thumbnails now refresh when new content is uploaded, content mime is not reset to binary when new content is checked in

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@10145 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Roy Wetherall
2008-07-30 18:33:24 +00:00
parent 558a195b5b
commit d368691efc
2 changed files with 107 additions and 67 deletions

View File

@@ -248,10 +248,14 @@ public class ThumbnailServiceImpl implements ThumbnailService
{ {
throw new ThumbnailException(ERR_NO_PARENT); throw new ThumbnailException(ERR_NO_PARENT);
} }
else if (parents.size() != 1) // TODO
{ // When a node with thumbnails is checked in the assoc's get doubled up. This means we get more than one parent.
throw new ThumbnailException(ERR_TOO_PARENT); // As a work around simply take the first parent retrieved
} //
//else if (parents.size() != 1)
//{
// throw new ThumbnailException(ERR_TOO_PARENT);
//}
else else
{ {
node = parents.get(0).getParentRef(); node = parents.get(0).getParentRef();

View File

@@ -25,14 +25,10 @@
package org.alfresco.repo.thumbnail; package org.alfresco.repo.thumbnail;
import java.io.Serializable; import java.io.Serializable;
import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set;
import org.alfresco.model.ContentModel; import org.alfresco.model.ContentModel;
import org.alfresco.repo.content.ContentServicePolicies;
import org.alfresco.repo.content.ContentServicePolicies.OnContentUpdatePolicy;
import org.alfresco.repo.node.NodeServicePolicies; import org.alfresco.repo.node.NodeServicePolicies;
import org.alfresco.repo.policy.Behaviour; import org.alfresco.repo.policy.Behaviour;
import org.alfresco.repo.policy.JavaBehaviour; import org.alfresco.repo.policy.JavaBehaviour;
@@ -57,37 +53,66 @@ import org.alfresco.util.EqualsHelper;
*/ */
public class ThumbnailedAspect implements NodeServicePolicies.OnUpdatePropertiesPolicy public class ThumbnailedAspect implements NodeServicePolicies.OnUpdatePropertiesPolicy
{ {
/** Services */
private PolicyComponent policyComponent; private PolicyComponent policyComponent;
private ThumbnailService thumbnailService; private ThumbnailService thumbnailService;
private ActionService actionService; private ActionService actionService;
private NodeService nodeService; private NodeService nodeService;
private DictionaryService dictionaryService; private DictionaryService dictionaryService;
/**
* Set the policy component
*
* @param policyComponent policy component
*/
public void setPolicyComponent(PolicyComponent policyComponent) public void setPolicyComponent(PolicyComponent policyComponent)
{ {
this.policyComponent = policyComponent; this.policyComponent = policyComponent;
} }
/**
* Set the action service
*
* @param actionService action service
*/
public void setActionService(ActionService actionService) public void setActionService(ActionService actionService)
{ {
this.actionService = actionService; this.actionService = actionService;
} }
/**
* Set the node service
*
* @param nodeService node service
*/
public void setNodeService(NodeService nodeService) public void setNodeService(NodeService nodeService)
{ {
this.nodeService = nodeService; this.nodeService = nodeService;
} }
/**
* Set the thumbnail service
*
* @param thumbnailService thumbnail service
*/
public void setThumbnailService(ThumbnailService thumbnailService) public void setThumbnailService(ThumbnailService thumbnailService)
{ {
this.thumbnailService = thumbnailService; this.thumbnailService = thumbnailService;
} }
/**
* Set the dictionary service
*
* @param dictionaryService dictionary service
*/
public void setDictionaryService(DictionaryService dictionaryService) public void setDictionaryService(DictionaryService dictionaryService)
{ {
this.dictionaryService = dictionaryService; this.dictionaryService = dictionaryService;
} }
/**
* Initialise method
*/
public void init() public void init()
{ {
this.policyComponent.bindClassBehaviour( this.policyComponent.bindClassBehaviour(
@@ -96,10 +121,17 @@ public class ThumbnailedAspect implements NodeServicePolicies.OnUpdateProperties
new JavaBehaviour(this, "onUpdateProperties", Behaviour.NotificationFrequency.TRANSACTION_COMMIT)); new JavaBehaviour(this, "onUpdateProperties", Behaviour.NotificationFrequency.TRANSACTION_COMMIT));
} }
/**
* @see org.alfresco.repo.node.NodeServicePolicies.OnUpdatePropertiesPolicy#onUpdateProperties(org.alfresco.service.cmr.repository.NodeRef, java.util.Map, java.util.Map)
*/
public void onUpdateProperties( public void onUpdateProperties(
NodeRef nodeRef, NodeRef nodeRef,
Map<QName, Serializable> before, Map<QName, Serializable> before,
Map<QName, Serializable> after) Map<QName, Serializable> after)
{
// Ignore working copies
if (this.nodeService.exists(nodeRef) == true &&
this.nodeService.hasAspect(nodeRef, ContentModel.ASPECT_WORKING_COPY) == false)
{ {
// check if any of the content properties have changed // check if any of the content properties have changed
for (QName propertyQName : after.keySet()) for (QName propertyQName : after.keySet())
@@ -156,10 +188,15 @@ public class ThumbnailedAspect implements NodeServicePolicies.OnUpdateProperties
} }
} }
} }
}
/**
* Queue the update to happen asynchronously
*
* @param nodeRef node reference
* @param contentProperty content property
*/
private void queueUpdate(NodeRef nodeRef, QName contentProperty) private void queueUpdate(NodeRef nodeRef, QName contentProperty)
{
if (this.nodeService.exists(nodeRef) == true)
{ {
Boolean automaticUpdate = (Boolean)this.nodeService.getProperty(nodeRef, ContentModel.PROP_AUTOMATIC_UPDATE); Boolean automaticUpdate = (Boolean)this.nodeService.getProperty(nodeRef, ContentModel.PROP_AUTOMATIC_UPDATE);
if (automaticUpdate != null && automaticUpdate.booleanValue() == true) if (automaticUpdate != null && automaticUpdate.booleanValue() == true)
@@ -176,4 +213,3 @@ public class ThumbnailedAspect implements NodeServicePolicies.OnUpdateProperties
} }
} }
} }
}