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