KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > alfresco > repo > action > evaluator > HasVersionHistoryEvaluator


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.evaluator;
18
19 import java.util.List JavaDoc;
20
21 import org.alfresco.model.ContentModel;
22 import org.alfresco.service.cmr.action.ActionCondition;
23 import org.alfresco.service.cmr.action.ParameterDefinition;
24 import org.alfresco.service.cmr.repository.NodeRef;
25 import org.alfresco.service.cmr.repository.NodeService;
26 import org.alfresco.service.cmr.version.VersionHistory;
27 import org.alfresco.service.cmr.version.VersionService;
28
29 /**
30  * Has version history evaluator
31  *
32  * @author Roy Wetherall
33  */

34 public class HasVersionHistoryEvaluator extends ActionConditionEvaluatorAbstractBase
35 {
36     /**
37      * Evaluator constants
38      */

39     public static final String JavaDoc NAME = "has-version-history";
40     
41     /**
42      * The node service
43      */

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

53     public void setNodeService(NodeService nodeService)
54     {
55         this.nodeService = nodeService;
56     }
57     
58     public void setVersionService(VersionService versionService)
59     {
60         this.versionService = versionService;
61     }
62     
63     /**
64      * @see org.alfresco.repo.action.evaluator.ActionConditionEvaluatorAbstractBase#evaluateImpl(org.alfresco.service.cmr.action.ActionCondition, org.alfresco.service.cmr.repository.NodeRef)
65      */

66     public boolean evaluateImpl(ActionCondition ruleCondition, NodeRef actionedUponNodeRef)
67     {
68         boolean result = false;
69         
70         if (this.nodeService.exists(actionedUponNodeRef) == true &&
71             this.nodeService.hasAspect(actionedUponNodeRef, ContentModel.ASPECT_VERSIONABLE) == true)
72         {
73             VersionHistory versionHistory = this.versionService.getVersionHistory(actionedUponNodeRef);
74             if (versionHistory != null && versionHistory.getAllVersions().size() != 0)
75             {
76                 result = true;
77             }
78         }
79         
80         return result;
81     }
82
83     /**
84      * @see org.alfresco.repo.action.ParameterizedItemAbstractBase#addParameterDefintions(java.util.List)
85      */

86     @Override JavaDoc
87     protected void addParameterDefintions(List JavaDoc<ParameterDefinition> paramList)
88     {
89     }
90
91 }
92
Popular Tags