1 17 package org.alfresco.repo.action.executer; 18 19 import java.util.List ; 20 21 import org.alfresco.model.ContentModel; 22 import org.alfresco.repo.action.ParameterDefinitionImpl; 23 import org.alfresco.service.cmr.action.Action; 24 import org.alfresco.service.cmr.action.ParameterDefinition; 25 import org.alfresco.service.cmr.coci.CheckOutCheckInService; 26 import org.alfresco.service.cmr.dictionary.DataTypeDefinition; 27 import org.alfresco.service.cmr.repository.NodeRef; 28 import org.alfresco.service.cmr.repository.NodeService; 29 import org.alfresco.service.namespace.QName; 30 31 36 public class CheckOutActionExecuter extends ActionExecuterAbstractBase 37 { 38 public static final String NAME = "check-out"; 39 public static final String PARAM_DESTINATION_FOLDER = "destination-folder"; 40 public static final String PARAM_ASSOC_TYPE_QNAME = "assoc-type"; 41 public static final String PARAM_ASSOC_QNAME = "assoc-name"; 42 43 46 private CheckOutCheckInService cociService; 47 48 51 private NodeService nodeService; 52 53 58 public void setNodeService(NodeService nodeService) 59 { 60 this.nodeService = nodeService; 61 } 62 63 68 public void setCociService(CheckOutCheckInService cociService) 69 { 70 this.cociService = cociService; 71 } 72 73 76 @Override 77 protected void addParameterDefintions(List <ParameterDefinition> paramList) 78 { 79 paramList.add(new ParameterDefinitionImpl(PARAM_DESTINATION_FOLDER, DataTypeDefinition.NODE_REF, false, getParamDisplayLabel(PARAM_DESTINATION_FOLDER))); 80 paramList.add(new ParameterDefinitionImpl(PARAM_ASSOC_TYPE_QNAME, DataTypeDefinition.QNAME, false, getParamDisplayLabel(PARAM_ASSOC_TYPE_QNAME))); 81 paramList.add(new ParameterDefinitionImpl(PARAM_ASSOC_QNAME, DataTypeDefinition.QNAME, false, getParamDisplayLabel(PARAM_ASSOC_QNAME))); 82 } 83 84 87 public void executeImpl(Action ruleAction, NodeRef actionedUponNodeRef) 88 { 89 if (this.nodeService.exists(actionedUponNodeRef) == true && 90 this.nodeService.hasAspect(actionedUponNodeRef, ContentModel.ASPECT_WORKING_COPY) == false) 91 { 92 NodeRef destinationParent = (NodeRef)ruleAction.getParameterValue(PARAM_DESTINATION_FOLDER); 94 QName destinationAssocTypeQName = (QName)ruleAction.getParameterValue(PARAM_ASSOC_TYPE_QNAME); 95 QName destinationAssocQName = (QName)ruleAction.getParameterValue(PARAM_ASSOC_QNAME); 96 97 if (destinationParent == null || destinationAssocTypeQName == null || destinationAssocQName == null) 98 { 99 this.cociService.checkout(actionedUponNodeRef); 101 } 102 else 103 { 104 this.cociService.checkout( 106 actionedUponNodeRef, 107 destinationParent, 108 destinationAssocTypeQName, 109 destinationAssocQName); 110 } 111 } 112 } 113 } 114 | Popular Tags |