KickJava   Java API By Example, From Geeks To Geeks.

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


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 /**
18  *
19  */

20 package org.alfresco.repo.action.executer;
21
22 import java.util.List JavaDoc;
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 /**
34  * Copy action executor.
35  * <p>
36  * Copies the actioned upon node to a specified location.
37  *
38  * @author Roy Wetherall
39  */

40 public class CopyActionExecuter extends ActionExecuterAbstractBase
41 {
42     public static final String JavaDoc NAME = "copy";
43     public static final String JavaDoc PARAM_DESTINATION_FOLDER = "destination-folder";
44     public static final String JavaDoc PARAM_ASSOC_TYPE_QNAME = "assoc-type";
45     public static final String JavaDoc PARAM_ASSOC_QNAME = "assoc-name";
46     public static final String JavaDoc PARAM_DEEP_COPY = "deep-copy";
47     
48     /**
49      * Node operations service
50      */

51     private CopyService copyService;
52     
53     /**
54      * The node service
55      */

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 JavaDoc
70     protected void addParameterDefintions(List JavaDoc<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     /**
79      * @see org.alfresco.repo.action.executer.ActionExecuter#execute(org.alfresco.repo.ref.NodeRef, org.alfresco.repo.ref.NodeRef)
80      */

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             // TODO get this from a parameter value
90
boolean deepCopy = false;
91             
92             this.copyService.copy(
93                     actionedUponNodeRef,
94                     destinationParent,
95                     destinationAssocTypeQName,
96                     destinationAssocQName,
97                     deepCopy);
98         }
99     }
100 }
101
Popular Tags