1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package org.apache.jetspeed.om.page;
19
20 import java.util.HashMap;
21 import java.util.List;
22 import java.util.ListIterator;
23 import java.util.Locale;
24 import java.util.Map;
25
26 import org.apache.jetspeed.om.common.GenericMetadata;
27 import org.apache.jetspeed.om.common.SecurityConstraint;
28 import org.apache.jetspeed.om.common.SecurityConstraints;
29 import org.apache.jetspeed.om.folder.MenuDefinition;
30 import org.apache.jetspeed.om.folder.MenuExcludeDefinition;
31 import org.apache.jetspeed.om.folder.MenuIncludeDefinition;
32 import org.apache.jetspeed.om.folder.MenuOptionsDefinition;
33 import org.apache.jetspeed.om.folder.MenuSeparatorDefinition;
34 import org.apache.jetspeed.page.document.Node;
35
36 public class ContentPageImpl implements ContentPage
37 {
38 private final Page page;
39 private final Map cachedFragments;
40 private ContentFragment rootContentFragment;
41 private boolean dirty=false;
42
43 public ContentPageImpl(Page page)
44 {
45 this.page = page;
46 this.cachedFragments = new HashMap();
47 }
48
49 public void setRootContentFragment(ContentFragment frag)
50 {
51 this.rootContentFragment = frag;
52 }
53
54 public String toString()
55 {
56 return page.toString();
57 }
58
59
60
61
62 public ContentFragment getContentFragmentById(String id)
63 {
64 ContentFragment contentFragment = null;
65 if(cachedFragments.containsKey(id))
66 {
67 contentFragment = (ContentFragment) cachedFragments.get(id);
68 }
69 else
70 {
71 Fragment f = page.getFragmentById(id);
72 if(f != null)
73 {
74 contentFragment = new ContentFragmentImpl(f, cachedFragments);
75 cachedFragments.put(id, contentFragment);
76 }
77 }
78 return contentFragment;
79 }
80
81
82
83
84 public Fragment getFragmentById(String id)
85 {
86 return getContentFragmentById(id);
87 }
88
89
90
91
92 public Fragment removeFragmentById(String id)
93 {
94
95 Fragment removed = page.removeFragmentById(id);
96 if (removed != null)
97 {
98
99 if ((rootContentFragment != null) && rootContentFragment.getId().equals(id))
100 {
101 rootContentFragment = null;
102 }
103 cachedFragments.clear();
104 }
105 return removed;
106 }
107
108
109
110
111 public List getContentFragmentsByName(String name)
112 {
113
114 List fragments = page.getFragmentsByName(name);
115 if (fragments == null)
116 {
117 return null;
118 }
119
120
121 ListIterator fragmentsIter = fragments.listIterator();
122 while (fragmentsIter.hasNext())
123 {
124 Fragment fragment = (Fragment)fragmentsIter.next();
125 String fragmentId = fragment.getId();
126 ContentFragment contentFragment = (ContentFragment)cachedFragments.get(fragmentId);
127 if (contentFragment == null)
128 {
129 contentFragment = new ContentFragmentImpl(fragment, cachedFragments);
130 cachedFragments.put(fragmentId, contentFragment);
131 }
132 fragmentsIter.set(contentFragment);
133 }
134 return null;
135 }
136
137
138
139
140 public List getFragmentsByName(String name)
141 {
142 return getContentFragmentsByName(name);
143 }
144
145
146
147
148 public ContentFragment getRootContentFragment()
149 {
150 if(rootContentFragment == null)
151 {
152 rootContentFragment = new ContentFragmentImpl(page.getRootFragment(), cachedFragments);
153 cachedFragments.put(rootContentFragment.getId(), rootContentFragment);
154 }
155 return rootContentFragment;
156 }
157
158
159
160
161 public Fragment getRootFragment()
162 {
163 return getRootContentFragment();
164 }
165
166
167
168
169 public String getEffectiveDefaultDecorator(String fragmentType)
170 {
171 return page.getEffectiveDefaultDecorator(fragmentType);
172 }
173
174
175
176
177 public String getDefaultDecorator(String fragmentType)
178 {
179 return page.getDefaultDecorator(fragmentType);
180 }
181
182
183
184
185 public String getSkin()
186 {
187
188 return page.getSkin();
189 }
190
191
192
193
194 public void setDefaultDecorator(String decoratorName, String fragmentType)
195 {
196
197 page.setDefaultDecorator(decoratorName, fragmentType);
198 }
199
200
201
202
203 public void setSkin(String skinName)
204 {
205
206 page.setSkin(skinName);
207 }
208
209
210
211
212 public void setRootFragment(Fragment fragment)
213 {
214
215 page.setRootFragment(fragment);
216 }
217
218
219
220
221 public List getMenuDefinitions()
222 {
223 return page.getMenuDefinitions();
224 }
225
226
227
228
229 public MenuDefinition newMenuDefinition()
230 {
231 return page.newMenuDefinition();
232 }
233
234
235
236
237 public MenuExcludeDefinition newMenuExcludeDefinition()
238 {
239 return page.newMenuExcludeDefinition();
240 }
241
242
243
244
245 public MenuIncludeDefinition newMenuIncludeDefinition()
246 {
247 return page.newMenuIncludeDefinition();
248 }
249
250
251
252
253 public MenuOptionsDefinition newMenuOptionsDefinition()
254 {
255 return page.newMenuOptionsDefinition();
256 }
257
258
259
260
261 public MenuSeparatorDefinition newMenuSeparatorDefinition()
262 {
263 return page.newMenuSeparatorDefinition();
264 }
265
266
267
268
269 public void setMenuDefinitions(List definitions)
270 {
271 page.setMenuDefinitions(definitions);
272 }
273
274
275
276
277 public GenericMetadata getMetadata()
278 {
279
280 return page.getMetadata();
281 }
282
283
284
285
286 public String getName()
287 {
288
289 return page.getName();
290 }
291
292
293
294
295 public Node getParent()
296 {
297
298 return page.getParent();
299 }
300
301
302
303
304 public String getPath()
305 {
306
307 return page.getPath();
308 }
309
310
311
312
313 public String getShortTitle(Locale locale)
314 {
315
316 return page.getShortTitle(locale);
317 }
318
319
320
321
322 public String getTitle(Locale locale)
323 {
324
325 return page.getTitle(locale);
326 }
327
328
329
330
331 public String getType()
332 {
333
334 return page.getType();
335 }
336
337
338
339
340 public String getUrl()
341 {
342
343 return page.getUrl();
344 }
345
346
347
348
349 public boolean isHidden()
350 {
351
352 return page.isHidden();
353 }
354
355
356
357
358 public void setHidden(boolean hidden)
359 {
360
361 page.setHidden(hidden);
362 }
363
364
365
366
367 public void setParent(Node parent)
368 {
369
370 page.setParent(parent);
371 }
372
373
374
375
376 public void setPath(String path)
377 {
378
379 page.setPath(path);
380 }
381
382
383
384
385 public void checkAccess(String actions) throws SecurityException
386 {
387
388 page.checkAccess(actions);
389 }
390
391
392
393
394 public void checkConstraints(String actions) throws SecurityException
395 {
396
397 page.checkConstraints(actions);
398 }
399
400
401
402
403 public void checkPermissions(int mask) throws SecurityException
404 {
405
406 page.checkPermissions(mask);
407 }
408
409
410
411
412 public boolean getConstraintsEnabled()
413 {
414
415 return page.getConstraintsEnabled();
416 }
417
418
419
420
421 public boolean getPermissionsEnabled()
422 {
423
424 return page.getPermissionsEnabled();
425 }
426
427
428
429
430 public SecurityConstraints getSecurityConstraints()
431 {
432
433 return page.getSecurityConstraints();
434 }
435
436
437
438
439 public SecurityConstraints newSecurityConstraints()
440 {
441
442 return page.newSecurityConstraints();
443 }
444
445
446
447
448 public SecurityConstraint newSecurityConstraint()
449 {
450
451 return page.newSecurityConstraint();
452 }
453
454
455
456
457 public void setSecurityConstraints(SecurityConstraints constraints)
458 {
459
460 page.setSecurityConstraints(constraints);
461 }
462
463
464
465
466 public String getId()
467 {
468
469 return page.getId();
470 }
471
472
473
474
475 public String getShortTitle()
476 {
477
478 return page.getShortTitle();
479 }
480
481
482
483
484 public String getTitle()
485 {
486
487 return page.getTitle();
488 }
489
490
491
492
493 public void setShortTitle(String title)
494 {
495 page.setShortTitle(title);
496 }
497
498
499
500
501 public void setTitle(String title)
502 {
503
504 page.setTitle(title);
505 }
506
507 /***
508 * getPage - access wrapped page
509 *
510 * @return wrapped page
511 */
512 public Page getPage()
513 {
514 return page;
515 }
516
517 public String getVersion()
518 {
519 return page.getVersion();
520 }
521
522 public void setVersion(String version)
523 {
524 page.setVersion(version);
525 }
526
527 public boolean isDirty() {
528 return dirty;
529 }
530
531 public void setDirty(boolean dirty) {
532 this.dirty = dirty;
533 }
534
535 }