1 17 package org.alfresco.repo.action.evaluator; 18 19 import java.util.List ; 20 21 import org.alfresco.model.ContentModel; 22 import org.alfresco.service.cmr.action.ActionCondition; 23 import org.alfresco.service.cmr.action.ParameterDefinition; 24 import org.alfresco.service.cmr.repository.NodeRef; 25 import org.alfresco.service.cmr.repository.NodeService; 26 import org.alfresco.service.cmr.version.VersionHistory; 27 import org.alfresco.service.cmr.version.VersionService; 28 29 34 public class HasVersionHistoryEvaluator extends ActionConditionEvaluatorAbstractBase 35 { 36 39 public static final String NAME = "has-version-history"; 40 41 44 private NodeService nodeService; 45 46 private VersionService versionService; 47 48 53 public void setNodeService(NodeService nodeService) 54 { 55 this.nodeService = nodeService; 56 } 57 58 public void setVersionService(VersionService versionService) 59 { 60 this.versionService = versionService; 61 } 62 63 66 public boolean evaluateImpl(ActionCondition ruleCondition, NodeRef actionedUponNodeRef) 67 { 68 boolean result = false; 69 70 if (this.nodeService.exists(actionedUponNodeRef) == true && 71 this.nodeService.hasAspect(actionedUponNodeRef, ContentModel.ASPECT_VERSIONABLE) == true) 72 { 73 VersionHistory versionHistory = this.versionService.getVersionHistory(actionedUponNodeRef); 74 if (versionHistory != null && versionHistory.getAllVersions().size() != 0) 75 { 76 result = true; 77 } 78 } 79 80 return result; 81 } 82 83 86 @Override 87 protected void addParameterDefintions(List <ParameterDefinition> paramList) 88 { 89 } 90 91 } 92 | Popular Tags |