1 17 package org.alfresco.repo.action.executer; 18 19 import java.io.Serializable ; 20 import java.util.HashMap ; 21 import java.util.List ; 22 import java.util.Map ; 23 24 import org.alfresco.model.ContentModel; 25 import org.alfresco.repo.action.ParameterDefinitionImpl; 26 import org.alfresco.repo.version.VersionModel; 27 import org.alfresco.service.cmr.action.Action; 28 import org.alfresco.service.cmr.action.ParameterDefinition; 29 import org.alfresco.service.cmr.coci.CheckOutCheckInService; 30 import org.alfresco.service.cmr.dictionary.DataTypeDefinition; 31 import org.alfresco.service.cmr.repository.NodeRef; 32 import org.alfresco.service.cmr.repository.NodeService; 33 import org.alfresco.service.cmr.version.Version; 34 import org.alfresco.service.cmr.version.VersionType; 35 36 41 public class CheckInActionExecuter extends ActionExecuterAbstractBase 42 { 43 public static final String NAME = "check-in"; 44 public static final String PARAM_DESCRIPTION = "description"; 45 public static final String PARAM_MINOR_CHANGE = "minorChange"; 46 47 50 private NodeService nodeService; 51 52 55 private CheckOutCheckInService cociService; 56 57 62 public void setNodeService(NodeService nodeService) 63 { 64 this.nodeService = nodeService; 65 } 66 67 72 public void setCociService(CheckOutCheckInService cociService) 73 { 74 this.cociService = cociService; 75 } 76 77 80 public void executeImpl(Action ruleAction, NodeRef actionedUponNodeRef) 81 { 82 if (this.nodeService.exists(actionedUponNodeRef) == true && 84 this.nodeService.hasAspect(actionedUponNodeRef, ContentModel.ASPECT_WORKING_COPY) == true) 85 { 86 String description = (String )ruleAction.getParameterValue(PARAM_DESCRIPTION); 88 Map <String , Serializable > versionProperties = new HashMap <String , Serializable >(1); 89 versionProperties.put(Version.PROP_DESCRIPTION, description); 90 91 Boolean minorChange = (Boolean )ruleAction.getParameterValue(PARAM_MINOR_CHANGE); 93 if (minorChange != null && minorChange.booleanValue() == false) 94 { 95 versionProperties.put(VersionModel.PROP_VERSION_TYPE, VersionType.MAJOR); 96 } 97 else 98 { 99 versionProperties.put(VersionModel.PROP_VERSION_TYPE, VersionType.MINOR); 100 } 101 102 104 this.cociService.checkin(actionedUponNodeRef, versionProperties); 106 } 107 } 108 109 @Override 110 protected void addParameterDefintions(List <ParameterDefinition> paramList) 111 { 112 paramList.add(new ParameterDefinitionImpl(PARAM_DESCRIPTION, DataTypeDefinition.TEXT, false, getParamDisplayLabel(PARAM_DESCRIPTION))); 113 } 114 115 } 116 | Popular Tags |