KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > alfresco > repo > action > executer > SetPropertyValueActionExecuter


1 /*
2  * Copyright (C) 2005 Alfresco, Inc.
3  *
4  * Licensed under the Mozilla Public License version 1.1
5  * with a permitted attribution clause. You may obtain a
6  * copy of the License at
7  *
8  * http://www.alfresco.org/legal/license.txt
9  *
10  * Unless required by applicable law or agreed to in writing,
11  * software distributed under the License is distributed on an
12  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
13  * either express or implied. See the License for the specific
14  * language governing permissions and limitations under the
15  * License.
16  */

17 package org.alfresco.repo.action.executer;
18
19 import java.util.List JavaDoc;
20
21 import org.alfresco.repo.action.ParameterDefinitionImpl;
22 import org.alfresco.service.cmr.action.Action;
23 import org.alfresco.service.cmr.action.ParameterDefinition;
24 import org.alfresco.service.cmr.dictionary.DataTypeDefinition;
25 import org.alfresco.service.cmr.repository.NodeRef;
26 import org.alfresco.service.cmr.repository.NodeService;
27 import org.alfresco.service.namespace.QName;
28
29 /**
30  * Add features action executor implementation.
31  *
32  * @author Roy Wetherall
33  */

34 public class SetPropertyValueActionExecuter extends ActionExecuterAbstractBase
35 {
36     /**
37      * Action constants
38      */

39     public static final String JavaDoc NAME = "set-property-value";
40     public static final String JavaDoc PARAM_PROPERTY = "property";
41     public static final String JavaDoc PARAM_VALUE = "value";
42     
43     /**
44      * The node service
45      */

46     private NodeService nodeService;
47     
48     /**
49      * Set the node service
50      *
51      * @param nodeService the node service
52      */

53     public void setNodeService(NodeService nodeService)
54     {
55         this.nodeService = nodeService;
56     }
57
58     /**
59      * @see org.alfresco.repo.action.executer.ActionExecuter#execute(org.alfresco.service.cmr.repository.NodeRef, NodeRef)
60      */

61     public void executeImpl(Action ruleAction, NodeRef actionedUponNodeRef)
62     {
63         if (this.nodeService.exists(actionedUponNodeRef) == true)
64         {
65             // Set the value of the property
66
this.nodeService.setProperty(
67                     actionedUponNodeRef,
68                     (QName)ruleAction.getParameterValue(PARAM_PROPERTY),
69                     ruleAction.getParameterValue(PARAM_VALUE));
70         }
71     }
72
73     /**
74      * Add parameter definitions
75      */

76     @Override JavaDoc
77     protected void addParameterDefintions(List JavaDoc<ParameterDefinition> paramList)
78     {
79         paramList.add(new ParameterDefinitionImpl(PARAM_PROPERTY, DataTypeDefinition.QNAME, true, getParamDisplayLabel(PARAM_PROPERTY)));
80         paramList.add(new ParameterDefinitionImpl(PARAM_VALUE, DataTypeDefinition.ANY, true, getParamDisplayLabel(PARAM_VALUE)));
81     }
82
83 }
84
Popular Tags