KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > infoglue > deliver > applications > databeans > DeliveryContext


1 /* ===============================================================================
2  *
3  * Part of the InfoGlue Content Management Platform (www.infoglue.org)
4  *
5  * ===============================================================================
6  *
7  * Copyright (C)
8  *
9  * This program is free software; you can redistribute it and/or modify it under
10  * the terms of the GNU General Public License version 2, as published by the
11  * Free Software Foundation. See the file LICENSE.html for more information.
12  *
13  * This program is distributed in the hope that it will be useful, but WITHOUT
14  * ANY WARRANTY, including the implied warranty of MERCHANTABILITY or FITNESS
15  * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License along with
18  * this program; if not, write to the Free Software Foundation, Inc. / 59 Temple
19  * Place, Suite 330 / Boston, MA 02111-1307 / USA.
20  *
21  * ===============================================================================
22  */

23
24 package org.infoglue.deliver.applications.databeans;
25
26 import java.util.ArrayList JavaDoc;
27 import java.util.Iterator JavaDoc;
28 import java.util.List JavaDoc;
29
30 import javax.servlet.http.HttpServletRequest JavaDoc;
31 import javax.servlet.http.HttpServletResponse JavaDoc;
32
33 import org.infoglue.cms.applications.common.Session;
34 import org.infoglue.cms.applications.common.actions.InfoGlueAbstractAction;
35
36 /**
37  * @author Mattias Bogeblad
38  *
39  * This class is used to store the context of a page and get and set information that is central to it.
40  * TODO - write more
41  */

42
43 public class DeliveryContext implements UsageListener
44 {
45     public static final String JavaDoc META_INFO_BINDING_NAME = "Meta information";
46     public static final String JavaDoc TEMPLATE_ATTRIBUTE_NAME = "Template";
47     public static final String JavaDoc TITLE_ATTRIBUTE_NAME = "Title";
48     public static final String JavaDoc NAV_TITLE_ATTRIBUTE_NAME = "NavigationTitle";
49     /*
50     protected static final String DISABLE_PAGE_CACHE_ATTRIBUTE_NAME = "DisablePageCache";
51     protected static final String PAGE_CONTENT_TYPE_ATTRIBUTE_NAME = "ContentType";
52     protected static final String ENABLE_PAGE_PROTECTION_ATTRIBUTE_NAME = "ProtectPage";
53     protected static final String DISABLE_EDIT_ON_SIGHT_ATTRIBUTE_NAME = "DisableEditOnSight";
54     */

55     
56     public static final boolean USE_LANGUAGE_FALLBACK = true;
57     public static final boolean DO_NOT_USE_LANGUAGE_FALLBACK = false;
58     public static final boolean USE_INHERITANCE = true;
59     public static final boolean DO_NOT_USE_INHERITANCE = false;
60     
61     //These are the standard parameters which uniquely defines which page to show.
62
private Integer JavaDoc siteNodeId = null;
63     private Integer JavaDoc contentId = null;
64     private Integer JavaDoc languageId = null;
65     
66     //This sets the content type
67
private String JavaDoc contentType = null;
68     
69     //Lets one disable caching of this page if needed for some requests.
70
private boolean disablePageCache = false;
71
72     //This decides if to show a minimalistic version of the page structure - not render all compoents etc.
73
private boolean showSimple = false;
74
75     //This parameter are set if you want to access a certain repository startpage
76
private String JavaDoc repositoryName = null;
77
78     private String JavaDoc pageKey = null;
79     private String JavaDoc pagePath = null;
80     
81     private HttpServletResponse JavaDoc httpServletResponse = null;
82     private HttpServletRequest JavaDoc httpServletRequest = null;
83     private Session session = null;
84     private InfoGlueAbstractAction infoglueAbstractAction = null;
85     
86     //This section has control over what contents and sitenodes are used where so the pagecache can be selectively updated.
87
private List JavaDoc usageListeners = new ArrayList JavaDoc();
88     
89     private List JavaDoc usedContents = new ArrayList JavaDoc();
90     private List JavaDoc usedContentVersions = new ArrayList JavaDoc();
91     private List JavaDoc usedSiteNodes = new ArrayList JavaDoc();
92     private List JavaDoc usedSiteNodeVersions = new ArrayList JavaDoc();
93     
94     //private InfoGluePrincipal infoGluePrincipal = null;
95

96     //This variable sets if all urls generated should contain the server name etc.
97
private boolean useFullUrl = false;
98     
99     //The variable sets if url generation should skip niceUris
100
private boolean disableNiceUri = false;
101
102     //The variable sets if the response string should be trimmed to avoid problems with xml-responses etc.
103
private boolean trimResponse = false;
104
105     //The variable sets if the full page should be rendered once more after all components have been rendered.
106
private boolean evaluateFullPage = true;
107
108     public static DeliveryContext getDeliveryContext()
109     {
110         return new DeliveryContext();
111     }
112     
113     private DeliveryContext()
114     {
115     }
116     /*
117     public static DeliveryContext getDeliveryContext(InfoGluePrincipal infoGluePrincipal)
118     {
119         return new DeliveryContext(infoGluePrincipal);
120     }
121     
122     private DeliveryContext(InfoGluePrincipal infoGluePrincipal)
123     {
124         this.infoGluePrincipal = infoGluePrincipal;
125     }
126     */

127     
128     public java.lang.Integer JavaDoc getSiteNodeId()
129     {
130         return this.siteNodeId;
131     }
132         
133     public void setSiteNodeId(Integer JavaDoc siteNodeId)
134     {
135         this.siteNodeId = siteNodeId;
136     }
137
138     public Integer JavaDoc getContentId()
139     {
140         return this.contentId;
141     }
142         
143     public void setContentId(Integer JavaDoc contentId)
144     {
145         this.contentId = contentId;
146     }
147
148     public Integer JavaDoc getLanguageId()
149     {
150         return this.languageId;
151     }
152         
153     public void setLanguageId(Integer JavaDoc languageId)
154     {
155         this.languageId = languageId;
156     }
157
158     public String JavaDoc getRepositoryName()
159     {
160         return this.repositoryName;
161     }
162         
163     public void setRepositoryName(String JavaDoc repositoryName)
164     {
165         this.repositoryName = repositoryName;
166     }
167
168     public String JavaDoc getPageKey()
169     {
170         return this.pageKey;
171     }
172
173     public String JavaDoc getPagePath()
174     {
175         return this.pagePath;
176     }
177
178     public void setPageKey(String JavaDoc pageKey)
179     {
180         this.pageKey = pageKey;
181     }
182
183     public void setPagePath(String JavaDoc pagePath)
184     {
185         this.pagePath = pagePath;
186     }
187     
188     /*
189     public InfoGluePrincipal getPrincipal()
190     {
191         return this.infoGluePrincipal;
192     }
193     */

194     
195     public String JavaDoc toString()
196     {
197         StringBuffer JavaDoc sb = new StringBuffer JavaDoc();
198         
199         sb.append("siteNodeId:" + this.siteNodeId);
200         sb.append("languageId:" + this.languageId);
201         sb.append("contentId:" + this.contentId);
202         //sb.append("InfoGluePrincipal:" + this.infoGluePrincipal);
203

204         return sb.toString();
205     }
206
207     public Session getSession()
208     {
209         return this.session;
210     }
211
212     public void setSession(Session session)
213     {
214         this.session = session;
215     }
216
217     public InfoGlueAbstractAction getInfoGlueAbstractAction()
218     {
219         return infoglueAbstractAction;
220     }
221
222     public void setInfoGlueAbstractAction(InfoGlueAbstractAction action)
223     {
224         infoglueAbstractAction = action;
225     }
226
227
228     public HttpServletRequest JavaDoc getHttpServletRequest()
229     {
230         return httpServletRequest;
231     }
232     
233     public void setHttpServletRequest(HttpServletRequest JavaDoc httpServletRequest)
234     {
235         this.httpServletRequest = httpServletRequest;
236     }
237     
238     public HttpServletResponse JavaDoc getHttpServletResponse()
239     {
240         return httpServletResponse;
241     }
242     
243     public void setHttpServletResponse(HttpServletResponse JavaDoc httpServletResponse)
244     {
245         this.httpServletResponse = httpServletResponse;
246     }
247
248     public void addUsedContent(String JavaDoc usedContent)
249     {
250         this.usedContents.add(usedContent);
251
252         Iterator JavaDoc iterator = this.getUsageListeners().iterator();
253         while(iterator.hasNext())
254         {
255             UsageListener usageListener = (UsageListener)iterator.next();
256             usageListener.addUsedContent(usedContent);
257         }
258     }
259
260     public void addUsedSiteNode(String JavaDoc usedSiteNode)
261     {
262         this.usedSiteNodes.add(usedSiteNode);
263         
264         Iterator JavaDoc iterator = this.getUsageListeners().iterator();
265         while(iterator.hasNext())
266         {
267             UsageListener usageListener = (UsageListener)iterator.next();
268             usageListener.addUsedSiteNode(usedSiteNode);
269         }
270     }
271
272     public void addUsedContentVersion(String JavaDoc usedContentVersion)
273     {
274         this.usedContentVersions.add(usedContentVersion);
275         
276         Iterator JavaDoc iterator = this.getUsageListeners().iterator();
277         while(iterator.hasNext())
278         {
279             UsageListener usageListener = (UsageListener)iterator.next();
280             usageListener.addUsedContentVersion(usedContentVersion);
281         }
282     }
283
284     public void addUsedSiteNodeVersion(String JavaDoc usedSiteNodeVersion)
285     {
286         this.usedSiteNodeVersions.add(usedSiteNodeVersion);
287         
288         Iterator JavaDoc iterator = this.getUsageListeners().iterator();
289         while(iterator.hasNext())
290         {
291             UsageListener usageListener = (UsageListener)iterator.next();
292             usageListener.addUsedSiteNodeVersion(usedSiteNodeVersion);
293         }
294     }
295
296     public String JavaDoc[] getAllUsedEntities()
297     {
298         List JavaDoc list = new ArrayList JavaDoc();
299         list.addAll(this.usedContents);
300         list.addAll(this.usedContentVersions);
301         list.addAll(this.usedSiteNodes);
302         list.addAll(this.usedSiteNodeVersions);
303         Object JavaDoc[] array = list.toArray();
304         String JavaDoc[] groups = new String JavaDoc[array.length];
305         for(int i=0; i<array.length; i++)
306             groups[i] = array[i].toString();
307         
308         return groups;
309     }
310     
311     public List JavaDoc getUsageListeners()
312     {
313         return usageListeners;
314     }
315
316     public boolean getShowSimple()
317     {
318         return showSimple;
319     }
320     
321     public void setShowSimple(boolean showSimple)
322     {
323         this.showSimple = showSimple;
324     }
325     
326     public String JavaDoc getContentType()
327     {
328         return contentType;
329     }
330     
331     public void setContentType(String JavaDoc contentType)
332     {
333         this.contentType = contentType;
334     }
335     
336     public boolean getDisablePageCache()
337     {
338         return disablePageCache;
339     }
340     
341     public void setDisablePageCache(boolean disablePageCache)
342     {
343         this.disablePageCache = disablePageCache;
344     }
345     
346     public boolean getUseFullUrl()
347     {
348         return useFullUrl;
349     }
350     
351     public void setUseFullUrl(boolean useFullUrl)
352     {
353         this.useFullUrl = useFullUrl;
354     }
355
356     public boolean getDisableNiceUri()
357     {
358         return this.disableNiceUri;
359     }
360     
361     public void setDisableNiceUri(boolean disableNiceUri)
362     {
363         this.disableNiceUri = disableNiceUri;
364     }
365
366     public boolean getTrimResponse()
367     {
368         return this.trimResponse;
369     }
370
371     public void setTrimResponse(boolean trimResponse)
372     {
373         this.trimResponse = trimResponse;
374     }
375
376     public boolean getEvaluateFullPage()
377     {
378         return evaluateFullPage;
379     }
380
381     public void setEvaluateFullPage(boolean evaluateFullPage)
382     {
383         this.evaluateFullPage = evaluateFullPage;
384     }
385 }
386
Popular Tags