1 17 20 package org.alfresco.repo.action.executer; 21 22 import java.util.List ; 23 24 import org.alfresco.repo.action.ParameterDefinitionImpl; 25 import org.alfresco.service.cmr.action.Action; 26 import org.alfresco.service.cmr.action.ParameterDefinition; 27 import org.alfresco.service.cmr.dictionary.DataTypeDefinition; 28 import org.alfresco.service.cmr.repository.CopyService; 29 import org.alfresco.service.cmr.repository.NodeRef; 30 import org.alfresco.service.cmr.repository.NodeService; 31 import org.alfresco.service.namespace.QName; 32 33 40 public class CopyActionExecuter extends ActionExecuterAbstractBase 41 { 42 public static final String NAME = "copy"; 43 public static final String PARAM_DESTINATION_FOLDER = "destination-folder"; 44 public static final String PARAM_ASSOC_TYPE_QNAME = "assoc-type"; 45 public static final String PARAM_ASSOC_QNAME = "assoc-name"; 46 public static final String PARAM_DEEP_COPY = "deep-copy"; 47 48 51 private CopyService copyService; 52 53 56 private NodeService nodeService; 57 58 public void setNodeService(NodeService nodeService) 59 { 60 this.nodeService = nodeService; 61 } 62 63 public void setCopyService(CopyService copyService) 64 { 65 this.copyService = copyService; 66 } 67 68 69 @Override 70 protected void addParameterDefintions(List <ParameterDefinition> paramList) 71 { 72 paramList.add(new ParameterDefinitionImpl(PARAM_DESTINATION_FOLDER, DataTypeDefinition.NODE_REF, true, getParamDisplayLabel(PARAM_DESTINATION_FOLDER))); 73 paramList.add(new ParameterDefinitionImpl(PARAM_ASSOC_TYPE_QNAME, DataTypeDefinition.QNAME, true, getParamDisplayLabel(PARAM_ASSOC_TYPE_QNAME))); 74 paramList.add(new ParameterDefinitionImpl(PARAM_ASSOC_QNAME, DataTypeDefinition.QNAME, true, getParamDisplayLabel(PARAM_ASSOC_QNAME))); 75 paramList.add(new ParameterDefinitionImpl(PARAM_DEEP_COPY, DataTypeDefinition.BOOLEAN, false, getParamDisplayLabel(PARAM_DEEP_COPY))); 76 } 77 78 81 public void executeImpl(Action ruleAction, NodeRef actionedUponNodeRef) 82 { 83 if (this.nodeService.exists(actionedUponNodeRef) == true) 84 { 85 NodeRef destinationParent = (NodeRef)ruleAction.getParameterValue(PARAM_DESTINATION_FOLDER); 86 QName destinationAssocTypeQName = (QName)ruleAction.getParameterValue(PARAM_ASSOC_TYPE_QNAME); 87 QName destinationAssocQName = (QName)ruleAction.getParameterValue(PARAM_ASSOC_QNAME); 88 89 boolean deepCopy = false; 91 92 this.copyService.copy( 93 actionedUponNodeRef, 94 destinationParent, 95 destinationAssocTypeQName, 96 destinationAssocQName, 97 deepCopy); 98 } 99 } 100 } 101 | Popular Tags |