KickJava   Java API By Example, From Geeks To Geeks.

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


1 package org.jahia.services.version;
2
3 import java.util.HashSet JavaDoc;
4 import java.util.Set JavaDoc;
5 import java.util.Stack JavaDoc;
6
7 import org.jahia.content.ObjectKey;
8
9 /**
10  *
11  * <p>Title: Extended StateModificationContext, hold the entryState of the version to restore </p>
12  * <p>Description: </p>
13  * <p>Copyright: Copyright (c) 2004</p>
14  * <p>Company: </p>
15  * @author not attributable
16  * @version 1.0
17  */

18 public class RestoreVersionStateModificationContext extends StateModificationContext {
19
20     private static org.apache.log4j.Logger logger =
21             org.apache.log4j.Logger.getLogger(RestoreVersionStateModificationContext.class);
22
23     private ContentObjectEntryState entryState;
24
25     /**
26      * if true, the restore version is an undelete indeed. So this is the last version that is restored
27      */

28     private boolean undelete = false;
29
30     private int containerPageChildId = -1;
31
32     /**
33      * Activation context constructor
34      * @param startObject specifies the object at which the state modification
35      * was triggered, giving us a "start point" that we can insert in the
36      * tree path.
37      * @param languageCodes contains a Set of String object that contain the
38      * language codes for which we want to perform an activation of the content
39      * objects.
40      * @param entryState, the entrystate to restore.
41      */

42     public RestoreVersionStateModificationContext(ObjectKey startObject,
43                                                   Set JavaDoc languageCodes,
44                                                   ContentObjectEntryState entryState) {
45         this(startObject,languageCodes,entryState,false);
46     }
47
48     /**
49      * Utility constructor to construct a context that has the descendingInSubPages
50      * boolean directly initialized to a value.
51      * @param startObject specifies the object at which the state modification
52      * was triggered, giving us a "start point" that we can insert in the
53      * tree path.
54      * @param languageCodes contains a Set of String object that contain the
55      * language codes for which we want to perform an activation of the content
56      * objects.
57      * @param descendingInSubPages true specifies that we want the activation
58      * to be recursive and descend in sub pages. This is useful notably to
59      * delete whole subsets of pages.
60      * @param entryState, the entrystate to restore.
61      */

62     public RestoreVersionStateModificationContext(ObjectKey startObject,
63                                     Set JavaDoc languageCodes,
64                                     boolean descendingInSubPages,
65                                     ContentObjectEntryState entryState) {
66         this(startObject, languageCodes,descendingInSubPages,entryState,false);
67     }
68
69     /**
70      * Activation context constructor
71      * @param startObject specifies the object at which the state modification
72      * was triggered, giving us a "start point" that we can insert in the
73      * tree path.
74      * @param languageCodes contains a Set of String object that contain the
75      * language codes for which we want to perform an activation of the content
76      * objects.
77      * @param entryState, the entrystate to restore.
78      * @param undelete, if true, this is the last version that is restored
79      *
80      */

81     public RestoreVersionStateModificationContext(ObjectKey startObject,
82                                                   Set JavaDoc languageCodes,
83                                                   ContentObjectEntryState entryState,
84                                                   boolean undelete) {
85         super(startObject,languageCodes);
86         this.entryState = entryState;
87         this.undelete = undelete;
88     }
89
90     /**
91      * Utility constructor to construct a context that has the descendingInSubPages
92      * boolean directly initialized to a value.
93      * @param startObject specifies the object at which the state modification
94      * was triggered, giving us a "start point" that we can insert in the
95      * tree path.
96      * @param languageCodes contains a Set of String object that contain the
97      * language codes for which we want to perform an activation of the content
98      * objects.
99      * @param descendingInSubPages true specifies that we want the activation
100      * to be recursive and descend in sub pages. This is useful notably to
101      * delete whole subsets of pages.
102      * @param entryState, the entrystate to restore.
103      * @param undelete, if true, this is the last version that is restored
104      */

105     public RestoreVersionStateModificationContext(ObjectKey startObject,
106                                     Set JavaDoc languageCodes,
107                                     boolean descendingInSubPages,
108                                     ContentObjectEntryState entryState,
109                                     boolean undelete) {
110         super(startObject, languageCodes,descendingInSubPages);
111         this.entryState = entryState;
112         this.undelete = undelete;
113     }
114
115     public ContentObjectEntryState getEntryState(){
116         return this.entryState;
117     }
118
119     /**
120      * return -1 if null
121      * @return int
122      */

123     public int getVersionId(){
124         if ( this.getEntryState() == null ){
125             return -1;
126         }
127         return this.getEntryState().getVersionID();
128     }
129
130     public boolean isUndelete() {
131         return undelete;
132     }
133
134     public void setUndelete(boolean undelete) {
135         this.undelete = undelete;
136     }
137
138     /**
139      * if the value is different than -1, this means this context is created by the page of this id to restore it's parent container
140      * @return
141      */

142     public int getContainerPageChildId() {
143         return containerPageChildId;
144     }
145
146     public void setContainerPageChildId(int containerPageChildId) {
147         this.containerPageChildId = containerPageChildId;
148     }
149
150 }
151
152
Popular Tags