KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jahia > services > version > PageRevisionEntrySet


1 //
2
// ____.
3
// __/\ ______| |__/\. _______
4
// __ .____| | \ | +----+ \
5
// _______| /--| | | - \ _ | : - \_________
6
// \\______: :---| : : | : | \________>
7
// |__\---\_____________:______: :____|____:_____\
8
// /_____|
9
//
10
// . . . i n j a h i a w e t r u s t . . .
11
//
12

13 package org.jahia.services.version;
14
15 import org.jahia.content.ContentPageKey;
16 import org.jahia.content.ObjectKey;
17
18 public class PageRevisionEntrySet extends RevisionEntrySet {
19
20     private RevisionEntry overallRevision = null;
21
22     public static final int PAGE_ATTRIBUTES_UPDATE = 1;
23     public static final int PAGE_CONTENT_UPDATE = 2;
24     public static final int PAGE_ATTRIBUTE_AND_CONTENT_UPDATE = 3;
25     public static final int PAGE_DELETED = 4;
26
27     private int updateType = 0;
28     private boolean pageDeleted = false;
29
30     public PageRevisionEntrySet(){
31         super();
32     };
33
34     /**
35      *
36      * @param versionID
37      * @param objectKey
38      */

39     public PageRevisionEntrySet(int versionID, ObjectKey objectKey){
40         super(versionID,objectKey);
41     }
42
43     public void addRevision(RevisionEntry revisionEntry){
44         // should we change the overall workflowState;
45
if ( revisionEntry == null ){
46             return;
47         }
48
49         int revWorkflowState = revisionEntry.getWorkflowState();
50         if ( revisionEntry.getObjectKey().getType()
51              .equals(ContentPageKey.PAGE_TYPE) ){
52             if ( this.overallRevision == null ){
53                 this.overallRevision = revisionEntry;
54             } else if ( revWorkflowState ==
55                  ContentObjectEntryState.WORKFLOW_STATE_VERSIONING_DELETED ){
56                 this.overallRevision = revisionEntry;
57             } else if ( revWorkflowState !=
58                         ContentObjectEntryState.WORKFLOW_STATE_ACTIVE ){
59                 this.overallRevision = revisionEntry;
60             } else if ( this.getWorkflowState() ==
61                         ContentObjectEntryState.WORKFLOW_STATE_ACTIVE ){
62                 this.overallRevision = revisionEntry;
63             }
64             if ( this.updateType == PageRevisionEntrySet.PAGE_CONTENT_UPDATE ){
65                this.updateType = PageRevisionEntrySet.PAGE_ATTRIBUTE_AND_CONTENT_UPDATE;
66             } else if ( this.updateType != PageRevisionEntrySet.PAGE_ATTRIBUTE_AND_CONTENT_UPDATE ){
67                 this.updateType = PageRevisionEntrySet.PAGE_ATTRIBUTES_UPDATE;
68             }
69             if ( revisionEntry.getWorkflowState()
70                  == ContentObjectEntryState.WORKFLOW_STATE_VERSIONING_DELETED ){
71                 this.pageDeleted = true;
72             }
73
74         } else {
75             if ( this.updateType == PageRevisionEntrySet.PAGE_ATTRIBUTES_UPDATE ){
76                this.updateType = PageRevisionEntrySet.PAGE_ATTRIBUTE_AND_CONTENT_UPDATE;
77             } else if ( this.updateType != PageRevisionEntrySet.PAGE_ATTRIBUTE_AND_CONTENT_UPDATE ){
78                 this.updateType = PageRevisionEntrySet.PAGE_CONTENT_UPDATE;
79             }
80         }
81         super.addRevision(revisionEntry);
82     }
83
84     public int getWorkflowState(){
85         if ( this.overallRevision == null ){
86             return ContentObjectEntryState.WORKFLOW_STATE_VERSIONED;
87         }
88         return this.overallRevision.getWorkflowState();
89     }
90
91     public int getRevisionType(){
92         if ( this.pageDeleted ){
93             return PageRevisionEntrySet.PAGE_DELETED;
94         }
95         return this.updateType;
96     }
97
98     /**
99      * @todo implement multilanguage with res bundle
100      *
101      * @param languageCode
102      * @return
103      */

104     public String JavaDoc getDescription(String JavaDoc languageCode){
105         if ( this.pageDeleted ){
106             return "Page Delete";
107         } else if ( this.updateType == PageRevisionEntrySet.PAGE_ATTRIBUTES_UPDATE ){
108             return "Page Attributes Update";
109         } else if ( this.updateType == PageRevisionEntrySet.PAGE_CONTENT_UPDATE ) {
110             return "Page Contents Update";
111         } else if ( this.updateType == PageRevisionEntrySet.PAGE_ATTRIBUTE_AND_CONTENT_UPDATE ) {
112             return "Page Attributes and Contents Update";
113         }
114         return "";
115     }
116 }
117
Popular Tags