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.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.NodeRef; 29 import org.alfresco.service.cmr.repository.NodeService; 30 import org.alfresco.service.namespace.QName; 31 32 37 public class AddFeaturesActionExecuter extends ActionExecuterAbstractBase 38 { 39 42 public static final String NAME = "add-features"; 43 public static final String PARAM_ASPECT_NAME = "aspect-name"; 44 public static final String PARAM_ASPECT_PROPERTIES = "aspect_properties"; 45 46 49 private NodeService nodeService; 50 51 56 public void setNodeService(NodeService nodeService) 57 { 58 this.nodeService = nodeService; 59 } 60 61 64 @Override 65 protected boolean getAdhocPropertiesAllowed() 66 { 67 return true; 68 } 69 70 73 public void executeImpl(Action ruleAction, NodeRef actionedUponNodeRef) 74 { 75 if (this.nodeService.exists(actionedUponNodeRef) == true) 76 { 77 Map <QName, Serializable > properties = new HashMap <QName, Serializable >(); 78 QName aspectQName = null; 79 80 Map <String , Serializable > paramValues = ruleAction.getParameterValues(); 81 for (Map.Entry <String , Serializable > entry : paramValues.entrySet()) 82 { 83 if (entry.getKey().equals(PARAM_ASPECT_NAME) == true) 84 { 85 aspectQName = (QName)entry.getValue(); 86 } 87 else 88 { 89 QName propertyQName = QName.createQName(entry.getKey()); 91 Serializable propertyValue = entry.getValue(); 92 properties.put(propertyQName, propertyValue); 93 } 94 } 95 96 this.nodeService.addAspect(actionedUponNodeRef, aspectQName, properties); 98 } 99 } 100 101 104 @Override 105 protected void addParameterDefintions(List <ParameterDefinition> paramList) 106 { 107 paramList.add(new ParameterDefinitionImpl(PARAM_ASPECT_NAME, DataTypeDefinition.QNAME, true, getParamDisplayLabel(PARAM_ASPECT_NAME))); 108 } 109 110 } 111 | Popular Tags |