KickJava   Java API By Example, From Geeks To Geeks.

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


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.io.Serializable JavaDoc;
20 import java.util.HashMap JavaDoc;
21 import java.util.List JavaDoc;
22 import java.util.Map JavaDoc;
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 /**
37  * Check in action executor
38  *
39  * @author Roy Wetherall
40  */

41 public class CheckInActionExecuter extends ActionExecuterAbstractBase
42 {
43     public static final String JavaDoc NAME = "check-in";
44     public static final String JavaDoc PARAM_DESCRIPTION = "description";
45     public static final String JavaDoc PARAM_MINOR_CHANGE = "minorChange";
46     
47     /**
48      * The node service
49      */

50     private NodeService nodeService;
51     
52     /**
53      * The coci service
54      */

55     private CheckOutCheckInService cociService;
56
57     /**
58      * Set node service
59      *
60      * @param nodeService the node service
61      */

62     public void setNodeService(NodeService nodeService)
63     {
64         this.nodeService = nodeService;
65     }
66     
67     /**
68      * Set the checkIn checkOut service
69      *
70      * @param cociService the checkIn checkOut Service
71      */

72     public void setCociService(CheckOutCheckInService cociService)
73     {
74         this.cociService = cociService;
75     }
76
77     /**
78      * @see org.alfresco.repo.action.executer.ActionExecuter#execute(org.alfresco.repo.ref.NodeRef, org.alfresco.repo.ref.NodeRef)
79      */

80     public void executeImpl(Action ruleAction, NodeRef actionedUponNodeRef)
81     {
82         // First ensure that the actionedUponNodeRef is a workingCopy
83
if (this.nodeService.exists(actionedUponNodeRef) == true &&
84             this.nodeService.hasAspect(actionedUponNodeRef, ContentModel.ASPECT_WORKING_COPY) == true)
85         {
86             // Get the version description
87
String JavaDoc description = (String JavaDoc)ruleAction.getParameterValue(PARAM_DESCRIPTION);
88             Map JavaDoc<String JavaDoc, Serializable JavaDoc> versionProperties = new HashMap JavaDoc<String JavaDoc, Serializable JavaDoc>(1);
89             versionProperties.put(Version.PROP_DESCRIPTION, description);
90             
91             // determine whether the change is minor or major
92
Boolean JavaDoc minorChange = (Boolean JavaDoc)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             // TODO determine whether the document should be kept checked out
103

104             // Check the node in
105
this.cociService.checkin(actionedUponNodeRef, versionProperties);
106         }
107     }
108
109     @Override JavaDoc
110     protected void addParameterDefintions(List JavaDoc<ParameterDefinition> paramList)
111     {
112         paramList.add(new ParameterDefinitionImpl(PARAM_DESCRIPTION, DataTypeDefinition.TEXT, false, getParamDisplayLabel(PARAM_DESCRIPTION)));
113     }
114
115 }
116
Popular Tags