KickJava   Java API By Example, From Geeks To Geeks.

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


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.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 /**
32  * Check out action executor
33  *
34  * @author Roy Wetherall
35  */

36 public class CheckOutActionExecuter extends ActionExecuterAbstractBase
37 {
38     public static final String JavaDoc NAME = "check-out";
39     public static final String JavaDoc PARAM_DESTINATION_FOLDER = "destination-folder";
40     public static final String JavaDoc PARAM_ASSOC_TYPE_QNAME = "assoc-type";
41     public static final String JavaDoc PARAM_ASSOC_QNAME = "assoc-name";
42
43     /**
44      * The version operations service
45      */

46     private CheckOutCheckInService cociService;
47     
48     /**
49      * The node service
50      */

51     private NodeService nodeService;
52     
53     /**
54      * Set the node service
55      *
56      * @param nodeService the node service
57      */

58     public void setNodeService(NodeService nodeService)
59     {
60         this.nodeService = nodeService;
61     }
62     
63     /**
64      * Set the coci service
65      *
66      * @param cociService the coci service
67      */

68     public void setCociService(CheckOutCheckInService cociService)
69     {
70         this.cociService = cociService;
71     }
72     
73     /**
74      * Add the parameter defintions
75      */

76     @Override JavaDoc
77     protected void addParameterDefintions(List JavaDoc<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     /**
85      * @see org.alfresco.repo.action.executer.ActionExecuter#execute(org.alfresco.repo.ref.NodeRef, org.alfresco.repo.ref.NodeRef)
86      */

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             // Get the destination details
93
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                 // Check the node out to the current location
100
this.cociService.checkout(actionedUponNodeRef);
101             }
102             else
103             {
104                 // Check the node out to the specified location
105
this.cociService.checkout(
106                         actionedUponNodeRef,
107                         destinationParent,
108                         destinationAssocTypeQName,
109                         destinationAssocQName);
110             }
111         }
112     }
113 }
114
Popular Tags