1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
package org.apache.jetspeed.page; |
18 |
|
|
19 |
|
import java.util.ArrayList; |
20 |
|
import java.util.Iterator; |
21 |
|
import java.util.LinkedList; |
22 |
|
import java.util.List; |
23 |
|
import java.util.Map; |
24 |
|
|
25 |
|
import javax.security.auth.Subject; |
26 |
|
|
27 |
|
import org.apache.commons.logging.Log; |
28 |
|
import org.apache.commons.logging.LogFactory; |
29 |
|
import org.apache.jetspeed.om.common.SecurityConstraint; |
30 |
|
import org.apache.jetspeed.om.common.SecurityConstraints; |
31 |
|
import org.apache.jetspeed.om.folder.Folder; |
32 |
|
import org.apache.jetspeed.om.folder.FolderNotFoundException; |
33 |
|
import org.apache.jetspeed.om.folder.InvalidFolderException; |
34 |
|
import org.apache.jetspeed.om.folder.MenuDefinition; |
35 |
|
import org.apache.jetspeed.om.folder.MenuExcludeDefinition; |
36 |
|
import org.apache.jetspeed.om.folder.MenuIncludeDefinition; |
37 |
|
import org.apache.jetspeed.om.folder.MenuOptionsDefinition; |
38 |
|
import org.apache.jetspeed.om.folder.MenuSeparatorDefinition; |
39 |
|
import org.apache.jetspeed.om.page.Fragment; |
40 |
|
import org.apache.jetspeed.om.page.Link; |
41 |
|
import org.apache.jetspeed.om.page.Page; |
42 |
|
import org.apache.jetspeed.om.page.PageSecurity; |
43 |
|
import org.apache.jetspeed.om.page.SecurityConstraintsDef; |
44 |
|
import org.apache.jetspeed.om.preference.FragmentPreference; |
45 |
|
import org.apache.jetspeed.page.document.Node; |
46 |
|
import org.apache.jetspeed.page.document.NodeException; |
47 |
|
import org.apache.jetspeed.page.impl.DatabasePageManagerUtils; |
48 |
|
|
49 |
|
|
50 |
|
|
51 |
|
|
52 |
|
|
53 |
|
|
54 |
|
|
55 |
|
public abstract class AbstractPageManager |
56 |
|
implements PageManager |
57 |
|
{ |
58 |
0 |
private final static Log log = LogFactory.getLog(AbstractPageManager.class); |
59 |
|
|
60 |
|
private final static String FOLDER_NODE_TYPE = "folder"; |
61 |
|
private final static String PAGE_NODE_TYPE = "page"; |
62 |
|
private final static String FRAGMENT_NODE_TYPE = "fragment"; |
63 |
|
private final static String LINK_NODE_TYPE = "link"; |
64 |
|
protected Class fragmentClass; |
65 |
|
protected Class pageClass; |
66 |
|
protected Class folderClass; |
67 |
|
protected Class linkClass; |
68 |
|
protected Class pageSecurityClass; |
69 |
|
protected Class propertyClass; |
70 |
|
protected Class folderMenuDefinitionClass; |
71 |
|
protected Class folderMenuExcludeDefinitionClass; |
72 |
|
protected Class folderMenuIncludeDefinitionClass; |
73 |
|
protected Class folderMenuOptionsDefinitionClass; |
74 |
|
protected Class folderMenuSeparatorDefinitionClass; |
75 |
|
protected Class pageMenuDefinitionClass; |
76 |
|
protected Class pageMenuExcludeDefinitionClass; |
77 |
|
protected Class pageMenuIncludeDefinitionClass; |
78 |
|
protected Class pageMenuOptionsDefinitionClass; |
79 |
|
protected Class pageMenuSeparatorDefinitionClass; |
80 |
|
protected Class securityConstraintsClass; |
81 |
|
protected Class folderSecurityConstraintClass; |
82 |
|
protected Class pageSecurityConstraintClass; |
83 |
|
protected Class fragmentSecurityConstraintClass; |
84 |
|
protected Class linkSecurityConstraintClass; |
85 |
|
protected Class pageSecuritySecurityConstraintClass; |
86 |
|
protected Class securityConstraintsDefClass; |
87 |
|
protected Class fragmentPreferenceClass; |
88 |
|
|
89 |
|
private boolean permissionsEnabled; |
90 |
|
|
91 |
|
private boolean constraintsEnabled; |
92 |
|
|
93 |
0 |
private List listeners = new LinkedList(); |
94 |
|
|
95 |
|
public AbstractPageManager(boolean permissionsEnabled, class="keyword">boolean constraintsEnabled) |
96 |
0 |
{ |
97 |
0 |
this.permissionsEnabled = permissionsEnabled; |
98 |
0 |
this.constraintsEnabled = constraintsEnabled; |
99 |
0 |
} |
100 |
|
|
101 |
|
public AbstractPageManager(boolean permissionsEnabled, class="keyword">boolean constraintsEnabled, Map modelClasses) |
102 |
|
{ |
103 |
0 |
this(permissionsEnabled, constraintsEnabled); |
104 |
|
|
105 |
0 |
this.fragmentClass = (Class)modelClasses.get("FragmentImpl"); |
106 |
0 |
this.pageClass = (Class)modelClasses.get("PageImpl"); |
107 |
0 |
this.folderClass = (Class)modelClasses.get("FolderImpl"); |
108 |
0 |
this.linkClass = (Class)modelClasses.get("LinkImpl"); |
109 |
0 |
this.pageSecurityClass = (Class)modelClasses.get("PageSecurityImpl"); |
110 |
0 |
this.folderMenuDefinitionClass = (Class)modelClasses.get("FolderMenuDefinitionImpl"); |
111 |
0 |
this.folderMenuExcludeDefinitionClass = (Class)modelClasses.get("FolderMenuExcludeDefinitionImpl"); |
112 |
0 |
this.folderMenuIncludeDefinitionClass = (Class)modelClasses.get("FolderMenuIncludeDefinitionImpl"); |
113 |
0 |
this.folderMenuOptionsDefinitionClass = (Class)modelClasses.get("FolderMenuOptionsDefinitionImpl"); |
114 |
0 |
this.folderMenuSeparatorDefinitionClass = (Class)modelClasses.get("FolderMenuSeparatorDefinitionImpl"); |
115 |
0 |
this.pageMenuDefinitionClass = (Class)modelClasses.get("PageMenuDefinitionImpl"); |
116 |
0 |
this.pageMenuExcludeDefinitionClass = (Class)modelClasses.get("PageMenuExcludeDefinitionImpl"); |
117 |
0 |
this.pageMenuIncludeDefinitionClass = (Class)modelClasses.get("PageMenuIncludeDefinitionImpl"); |
118 |
0 |
this.pageMenuOptionsDefinitionClass = (Class)modelClasses.get("PageMenuOptionsDefinitionImpl"); |
119 |
0 |
this.pageMenuSeparatorDefinitionClass = (Class)modelClasses.get("PageMenuSeparatorDefinitionImpl"); |
120 |
0 |
this.securityConstraintsClass = (Class)modelClasses.get("SecurityConstraintsImpl"); |
121 |
0 |
this.folderSecurityConstraintClass = (Class)modelClasses.get("FolderSecurityConstraintImpl"); |
122 |
0 |
this.pageSecurityConstraintClass = (Class)modelClasses.get("PageSecurityConstraintImpl"); |
123 |
0 |
this.fragmentSecurityConstraintClass = (Class)modelClasses.get("FragmentSecurityConstraintImpl"); |
124 |
0 |
this.linkSecurityConstraintClass = (Class)modelClasses.get("LinkSecurityConstraintImpl"); |
125 |
0 |
this.pageSecuritySecurityConstraintClass = (Class)modelClasses.get("PageSecuritySecurityConstraintImpl"); |
126 |
0 |
this.securityConstraintsDefClass = (Class)modelClasses.get("SecurityConstraintsDefImpl"); |
127 |
0 |
this.fragmentPreferenceClass = (Class)modelClasses.get("FragmentPreferenceImpl"); |
128 |
0 |
} |
129 |
|
|
130 |
|
|
131 |
|
|
132 |
|
|
133 |
|
|
134 |
|
|
135 |
|
|
136 |
|
|
137 |
|
|
138 |
|
public boolean getPermissionsEnabled() |
139 |
|
{ |
140 |
0 |
return permissionsEnabled; |
141 |
|
} |
142 |
|
|
143 |
|
|
144 |
|
|
145 |
|
|
146 |
|
|
147 |
|
|
148 |
|
|
149 |
|
|
150 |
|
|
151 |
|
public boolean getConstraintsEnabled() |
152 |
|
{ |
153 |
0 |
return constraintsEnabled; |
154 |
|
} |
155 |
|
|
156 |
|
|
157 |
|
|
158 |
|
|
159 |
|
public Page newPage(String path) |
160 |
|
{ |
161 |
0 |
Page page = null; |
162 |
|
try |
163 |
|
{ |
164 |
|
|
165 |
0 |
page = (Page)createObject(this.pageClass); |
166 |
0 |
if (!path.startsWith(Folder.PATH_SEPARATOR)) |
167 |
|
{ |
168 |
0 |
path = Folder.PATH_SEPARATOR + path; |
169 |
|
} |
170 |
0 |
if (!path.endsWith(Page.DOCUMENT_TYPE)) |
171 |
|
{ |
172 |
0 |
path += Page.DOCUMENT_TYPE; |
173 |
|
} |
174 |
0 |
page.setPath(path); |
175 |
|
|
176 |
|
|
177 |
0 |
page.setRootFragment(newFragment()); |
178 |
|
} |
179 |
0 |
catch (ClassCastException e) |
180 |
|
{ |
181 |
0 |
String message = "Failed to create page object for " + this.pageClass; |
182 |
0 |
log.error(message, e); |
183 |
0 |
} |
184 |
0 |
return page; |
185 |
|
} |
186 |
|
|
187 |
|
|
188 |
|
|
189 |
|
|
190 |
|
public Folder newFolder(String path) |
191 |
|
{ |
192 |
0 |
Folder folder = null; |
193 |
|
try |
194 |
|
{ |
195 |
|
|
196 |
0 |
folder = (Folder)createObject(this.folderClass); |
197 |
0 |
if (!path.startsWith(Folder.PATH_SEPARATOR)) |
198 |
|
{ |
199 |
0 |
path = Folder.PATH_SEPARATOR + path; |
200 |
|
} |
201 |
0 |
folder.setPath(path); |
202 |
|
} |
203 |
0 |
catch (ClassCastException e) |
204 |
|
{ |
205 |
0 |
String message = "Failed to create link object for " + this.linkClass; |
206 |
0 |
log.error(message, e); |
207 |
0 |
} |
208 |
0 |
return folder; |
209 |
|
} |
210 |
|
|
211 |
|
|
212 |
|
|
213 |
|
|
214 |
|
public Link newLink(String path) |
215 |
|
{ |
216 |
0 |
Link link = null; |
217 |
|
try |
218 |
|
{ |
219 |
|
|
220 |
0 |
link = (Link)createObject(this.linkClass); |
221 |
0 |
if (!path.startsWith(Folder.PATH_SEPARATOR)) |
222 |
|
{ |
223 |
0 |
path = Folder.PATH_SEPARATOR + path; |
224 |
|
} |
225 |
0 |
if (!path.endsWith(Link.DOCUMENT_TYPE)) |
226 |
|
{ |
227 |
0 |
path += Link.DOCUMENT_TYPE; |
228 |
|
} |
229 |
0 |
link.setPath(path); |
230 |
|
} |
231 |
0 |
catch (ClassCastException e) |
232 |
|
{ |
233 |
0 |
String message = "Failed to create link object for " + this.linkClass; |
234 |
0 |
log.error(message, e); |
235 |
0 |
} |
236 |
0 |
return link; |
237 |
|
} |
238 |
|
|
239 |
|
|
240 |
|
|
241 |
|
|
242 |
|
public PageSecurity newPageSecurity() |
243 |
|
{ |
244 |
0 |
PageSecurity pageSecurity = null; |
245 |
|
try |
246 |
|
{ |
247 |
|
|
248 |
0 |
pageSecurity = (PageSecurity)createObject(this.pageSecurityClass); |
249 |
0 |
pageSecurity.setPath(Folder.PATH_SEPARATOR + PageSecurity.DOCUMENT_TYPE); |
250 |
|
} |
251 |
0 |
catch (ClassCastException e) |
252 |
|
{ |
253 |
0 |
String message = "Failed to create page security object for " + this.pageClass; |
254 |
0 |
log.error(message, e); |
255 |
0 |
} |
256 |
0 |
return pageSecurity; |
257 |
|
} |
258 |
|
|
259 |
|
|
260 |
|
|
261 |
|
|
262 |
|
public Fragment newFragment() |
263 |
|
{ |
264 |
0 |
Fragment fragment = null; |
265 |
|
try |
266 |
|
{ |
267 |
0 |
fragment = (Fragment)createObject(this.fragmentClass); |
268 |
0 |
fragment.setType(Fragment.LAYOUT); |
269 |
|
} |
270 |
0 |
catch (ClassCastException e) |
271 |
|
{ |
272 |
0 |
String message = "Failed to create page object for " + this.pageClass; |
273 |
0 |
log.error(message, e); |
274 |
|
|
275 |
0 |
} |
276 |
0 |
return fragment; |
277 |
|
} |
278 |
|
|
279 |
|
|
280 |
|
|
281 |
|
|
282 |
|
public Fragment newPortletFragment() |
283 |
|
{ |
284 |
0 |
Fragment fragment = null; |
285 |
|
try |
286 |
|
{ |
287 |
0 |
fragment = (Fragment)createObject(this.fragmentClass); |
288 |
0 |
fragment.setType(Fragment.PORTLET); |
289 |
|
} |
290 |
0 |
catch (ClassCastException e) |
291 |
|
{ |
292 |
0 |
String message = "Failed to create page object for " + this.pageClass; |
293 |
0 |
log.error(message, e); |
294 |
|
|
295 |
0 |
} |
296 |
0 |
return fragment; |
297 |
|
} |
298 |
|
|
299 |
|
|
300 |
|
|
301 |
|
|
302 |
|
|
303 |
|
|
304 |
|
public MenuDefinition newFolderMenuDefinition() |
305 |
|
{ |
306 |
|
try |
307 |
|
{ |
308 |
0 |
return (MenuDefinition)createObject(this.folderMenuDefinitionClass); |
309 |
|
} |
310 |
0 |
catch (ClassCastException e) |
311 |
|
{ |
312 |
0 |
String message = "Failed to create menu definition object for " + this.folderMenuDefinitionClass; |
313 |
0 |
log.error(message, e); |
314 |
|
} |
315 |
0 |
return null; |
316 |
|
} |
317 |
|
|
318 |
|
|
319 |
|
|
320 |
|
|
321 |
|
|
322 |
|
|
323 |
|
public MenuExcludeDefinition newFolderMenuExcludeDefinition() |
324 |
|
{ |
325 |
|
try |
326 |
|
{ |
327 |
0 |
return (MenuExcludeDefinition)createObject(this.folderMenuExcludeDefinitionClass); |
328 |
|
} |
329 |
0 |
catch (ClassCastException e) |
330 |
|
{ |
331 |
0 |
String message = "Failed to create menu exclude definition object for " + this.folderMenuExcludeDefinitionClass; |
332 |
0 |
log.error(message, e); |
333 |
|
} |
334 |
0 |
return null; |
335 |
|
} |
336 |
|
|
337 |
|
|
338 |
|
|
339 |
|
|
340 |
|
|
341 |
|
|
342 |
|
public MenuIncludeDefinition newFolderMenuIncludeDefinition() |
343 |
|
{ |
344 |
|
try |
345 |
|
{ |
346 |
0 |
return (MenuIncludeDefinition)createObject(this.folderMenuIncludeDefinitionClass); |
347 |
|
} |
348 |
0 |
catch (ClassCastException e) |
349 |
|
{ |
350 |
0 |
String message = "Failed to create menu include definition object for " + this.folderMenuIncludeDefinitionClass; |
351 |
0 |
log.error(message, e); |
352 |
|
} |
353 |
0 |
return null; |
354 |
|
} |
355 |
|
|
356 |
|
|
357 |
|
|
358 |
|
|
359 |
|
|
360 |
|
|
361 |
|
public MenuOptionsDefinition newFolderMenuOptionsDefinition() |
362 |
|
{ |
363 |
|
try |
364 |
|
{ |
365 |
0 |
return (MenuOptionsDefinition)createObject(this.folderMenuOptionsDefinitionClass); |
366 |
|
} |
367 |
0 |
catch (ClassCastException e) |
368 |
|
{ |
369 |
0 |
String message = "Failed to create menu options definition object for " + this.folderMenuOptionsDefinitionClass; |
370 |
0 |
log.error(message, e); |
371 |
|
} |
372 |
0 |
return null; |
373 |
|
} |
374 |
|
|
375 |
|
|
376 |
|
|
377 |
|
|
378 |
|
|
379 |
|
|
380 |
|
public MenuSeparatorDefinition newFolderMenuSeparatorDefinition() |
381 |
|
{ |
382 |
|
try |
383 |
|
{ |
384 |
0 |
return (MenuSeparatorDefinition)createObject(this.folderMenuSeparatorDefinitionClass); |
385 |
|
} |
386 |
0 |
catch (ClassCastException e) |
387 |
|
{ |
388 |
0 |
String message = "Failed to create menu separator definition object for " + this.folderMenuSeparatorDefinitionClass; |
389 |
0 |
log.error(message, e); |
390 |
|
} |
391 |
0 |
return null; |
392 |
|
} |
393 |
|
|
394 |
|
|
395 |
|
|
396 |
|
|
397 |
|
|
398 |
|
|
399 |
|
public MenuDefinition newPageMenuDefinition() |
400 |
|
{ |
401 |
|
try |
402 |
|
{ |
403 |
0 |
return (MenuDefinition)createObject(this.pageMenuDefinitionClass); |
404 |
|
} |
405 |
0 |
catch (ClassCastException e) |
406 |
|
{ |
407 |
0 |
String message = "Failed to create menu definition object for " + this.pageMenuDefinitionClass; |
408 |
0 |
log.error(message, e); |
409 |
|
} |
410 |
0 |
return null; |
411 |
|
} |
412 |
|
|
413 |
|
|
414 |
|
|
415 |
|
|
416 |
|
|
417 |
|
|
418 |
|
public MenuExcludeDefinition newPageMenuExcludeDefinition() |
419 |
|
{ |
420 |
|
try |
421 |
|
{ |
422 |
0 |
return (MenuExcludeDefinition)createObject(this.pageMenuExcludeDefinitionClass); |
423 |
|
} |
424 |
0 |
catch (ClassCastException e) |
425 |
|
{ |
426 |
0 |
String message = "Failed to create menu exclude definition object for " + this.pageMenuExcludeDefinitionClass; |
427 |
0 |
log.error(message, e); |
428 |
|
} |
429 |
0 |
return null; |
430 |
|
} |
431 |
|
|
432 |
|
|
433 |
|
|
434 |
|
|
435 |
|
|
436 |
|
|
437 |
|
public MenuIncludeDefinition newPageMenuIncludeDefinition() |
438 |
|
{ |
439 |
|
try |
440 |
|
{ |
441 |
0 |
return (MenuIncludeDefinition)createObject(this.pageMenuIncludeDefinitionClass); |
442 |
|
} |
443 |
0 |
catch (ClassCastException e) |
444 |
|
{ |
445 |
0 |
String message = "Failed to create menu include definition object for " + this.pageMenuIncludeDefinitionClass; |
446 |
0 |
log.error(message, e); |
447 |
|
} |
448 |
0 |
return null; |
449 |
|
} |
450 |
|
|
451 |
|
|
452 |
|
|
453 |
|
|
454 |
|
|
455 |
|
|
456 |
|
public MenuOptionsDefinition newPageMenuOptionsDefinition() |
457 |
|
{ |
458 |
|
try |
459 |
|
{ |
460 |
0 |
return (MenuOptionsDefinition)createObject(this.pageMenuOptionsDefinitionClass); |
461 |
|
} |
462 |
0 |
catch (ClassCastException e) |
463 |
|
{ |
464 |
0 |
String message = "Failed to create menu options definition object for " + this.pageMenuOptionsDefinitionClass; |
465 |
0 |
log.error(message, e); |
466 |
|
} |
467 |
0 |
return null; |
468 |
|
} |
469 |
|
|
470 |
|
|
471 |
|
|
472 |
|
|
473 |
|
|
474 |
|
|
475 |
|
public MenuSeparatorDefinition newPageMenuSeparatorDefinition() |
476 |
|
{ |
477 |
|
try |
478 |
|
{ |
479 |
0 |
return (MenuSeparatorDefinition)createObject(this.pageMenuSeparatorDefinitionClass); |
480 |
|
} |
481 |
0 |
catch (ClassCastException e) |
482 |
|
{ |
483 |
0 |
String message = "Failed to create menu separator definition object for " + this.pageMenuSeparatorDefinitionClass; |
484 |
0 |
log.error(message, e); |
485 |
|
} |
486 |
0 |
return null; |
487 |
|
} |
488 |
|
|
489 |
|
|
490 |
|
|
491 |
|
|
492 |
|
|
493 |
|
|
494 |
|
public SecurityConstraints newSecurityConstraints() |
495 |
|
{ |
496 |
|
try |
497 |
|
{ |
498 |
0 |
return (SecurityConstraints)createObject(this.securityConstraintsClass); |
499 |
|
} |
500 |
0 |
catch (ClassCastException e) |
501 |
|
{ |
502 |
0 |
String message = "Failed to create security constraints definition object for " + this.securityConstraintsClass; |
503 |
0 |
log.error(message, e); |
504 |
|
} |
505 |
0 |
return null; |
506 |
|
} |
507 |
|
|
508 |
|
|
509 |
|
|
510 |
|
|
511 |
|
|
512 |
|
|
513 |
|
public SecurityConstraint newFolderSecurityConstraint() |
514 |
|
{ |
515 |
|
try |
516 |
|
{ |
517 |
0 |
return (SecurityConstraint)createObject(this.folderSecurityConstraintClass); |
518 |
|
} |
519 |
0 |
catch (ClassCastException e) |
520 |
|
{ |
521 |
0 |
String message = "Failed to create security constraint definition object for " + this.folderSecurityConstraintClass; |
522 |
0 |
log.error(message, e); |
523 |
|
} |
524 |
0 |
return null; |
525 |
|
} |
526 |
|
|
527 |
|
|
528 |
|
|
529 |
|
|
530 |
|
|
531 |
|
|
532 |
|
public SecurityConstraint newPageSecurityConstraint() |
533 |
|
{ |
534 |
|
try |
535 |
|
{ |
536 |
0 |
return (SecurityConstraint)createObject(this.pageSecurityConstraintClass); |
537 |
|
} |
538 |
0 |
catch (ClassCastException e) |
539 |
|
{ |
540 |
0 |
String message = "Failed to create security constraint definition object for " + this.pageSecurityConstraintClass; |
541 |
0 |
log.error(message, e); |
542 |
|
} |
543 |
0 |
return null; |
544 |
|
} |
545 |
|
|
546 |
|
|
547 |
|
|
548 |
|
|
549 |
|
|
550 |
|
|
551 |
|
public SecurityConstraint newFragmentSecurityConstraint() |
552 |
|
{ |
553 |
|
try |
554 |
|
{ |
555 |
0 |
return (SecurityConstraint)createObject(this.fragmentSecurityConstraintClass); |
556 |
|
} |
557 |
0 |
catch (ClassCastException e) |
558 |
|
{ |
559 |
0 |
String message = "Failed to create security constraint definition object for " + this.fragmentSecurityConstraintClass; |
560 |
0 |
log.error(message, e); |
561 |
|
} |
562 |
0 |
return null; |
563 |
|
} |
564 |
|
|
565 |
|
|
566 |
|
|
567 |
|
|
568 |
|
|
569 |
|
|
570 |
|
public SecurityConstraint newLinkSecurityConstraint() |
571 |
|
{ |
572 |
|
try |
573 |
|
{ |
574 |
0 |
return (SecurityConstraint)createObject(this.linkSecurityConstraintClass); |
575 |
|
} |
576 |
0 |
catch (ClassCastException e) |
577 |
|
{ |
578 |
0 |
String message = "Failed to create security constraint definition object for " + this.linkSecurityConstraintClass; |
579 |
0 |
log.error(message, e); |
580 |
|
} |
581 |
0 |
return null; |
582 |
|
} |
583 |
|
|
584 |
|
|
585 |
|
|
586 |
|
|
587 |
|
|
588 |
|
|
589 |
|
public SecurityConstraint newPageSecuritySecurityConstraint() |
590 |
|
{ |
591 |
|
try |
592 |
|
{ |
593 |
0 |
return (SecurityConstraint)createObject(this.pageSecuritySecurityConstraintClass); |
594 |
|
} |
595 |
0 |
catch (ClassCastException e) |
596 |
|
{ |
597 |
0 |
String message = "Failed to create security constraint definition object for " + this.pageSecuritySecurityConstraintClass; |
598 |
0 |
log.error(message, e); |
599 |
|
} |
600 |
0 |
return null; |
601 |
|
} |
602 |
|
|
603 |
|
|
604 |
|
|
605 |
|
|
606 |
|
|
607 |
|
|
608 |
|
public SecurityConstraintsDef newSecurityConstraintsDef() |
609 |
|
{ |
610 |
|
try |
611 |
|
{ |
612 |
0 |
return (SecurityConstraintsDef)createObject(this.securityConstraintsDefClass); |
613 |
|
} |
614 |
0 |
catch (ClassCastException e) |
615 |
|
{ |
616 |
0 |
String message = "Failed to create security constraints definition object for " + this.securityConstraintsDefClass; |
617 |
0 |
log.error(message, e); |
618 |
|
} |
619 |
0 |
return null; |
620 |
|
} |
621 |
|
|
622 |
|
|
623 |
|
|
624 |
|
|
625 |
|
|
626 |
|
|
627 |
|
public FragmentPreference newFragmentPreference() |
628 |
|
{ |
629 |
|
try |
630 |
|
{ |
631 |
0 |
return (FragmentPreference)createObject(this.fragmentPreferenceClass); |
632 |
|
} |
633 |
0 |
catch (ClassCastException e) |
634 |
|
{ |
635 |
0 |
String message = "Failed to create security constraints definition object for " + this.fragmentPreferenceClass; |
636 |
0 |
log.error(message, e); |
637 |
|
} |
638 |
0 |
return null; |
639 |
|
} |
640 |
|
|
641 |
|
|
642 |
|
|
643 |
|
|
644 |
|
|
645 |
|
|
646 |
|
|
647 |
|
private Object createObject(Class classe) |
648 |
|
{ |
649 |
0 |
Object object = null; |
650 |
|
try |
651 |
|
{ |
652 |
0 |
object = classe.newInstance(); |
653 |
|
} |
654 |
0 |
catch (Exception e) |
655 |
|
{ |
656 |
0 |
log.error("Factory failed to create object: " + classe.getName(), e); |
657 |
0 |
} |
658 |
0 |
return object; |
659 |
|
} |
660 |
|
|
661 |
|
|
662 |
|
|
663 |
|
|
664 |
|
|
665 |
|
|
666 |
|
public void addListener(PageManagerEventListener listener) |
667 |
|
{ |
668 |
|
|
669 |
0 |
synchronized (listeners) |
670 |
|
{ |
671 |
0 |
listeners.add(listener); |
672 |
0 |
} |
673 |
0 |
} |
674 |
|
|
675 |
|
|
676 |
|
|
677 |
|
|
678 |
|
|
679 |
|
|
680 |
|
public void removeListener(PageManagerEventListener listener) |
681 |
|
{ |
682 |
|
|
683 |
0 |
synchronized (listeners) |
684 |
|
{ |
685 |
0 |
listeners.remove(listener); |
686 |
0 |
} |
687 |
0 |
} |
688 |
|
|
689 |
|
|
690 |
|
|
691 |
|
|
692 |
|
public void reset() |
693 |
|
{ |
694 |
|
|
695 |
0 |
} |
696 |
|
|
697 |
|
|
698 |
|
|
699 |
|
|
700 |
|
|
701 |
|
|
702 |
|
|
703 |
|
public void notifyNewNode(Node node) |
704 |
|
{ |
705 |
|
|
706 |
0 |
List listenersList = null; |
707 |
0 |
synchronized (listeners) |
708 |
|
{ |
709 |
0 |
listenersList = new ArrayList(listeners); |
710 |
0 |
} |
711 |
|
|
712 |
0 |
Iterator listenersIter = listenersList.iterator(); |
713 |
0 |
while (listenersIter.hasNext()) |
714 |
|
{ |
715 |
0 |
PageManagerEventListener listener = (PageManagerEventListener)listenersIter.next(); |
716 |
|
try |
717 |
|
{ |
718 |
0 |
listener.newNode(node); |
719 |
|
} |
720 |
0 |
catch (Exception e) |
721 |
|
{ |
722 |
0 |
log.error("Failed to notify page manager event listener", e); |
723 |
0 |
} |
724 |
0 |
} |
725 |
0 |
} |
726 |
|
|
727 |
|
|
728 |
|
|
729 |
|
|
730 |
|
|
731 |
|
|
732 |
|
|
733 |
|
public void notifyUpdatedNode(Node node) |
734 |
|
{ |
735 |
|
|
736 |
0 |
List listenersList = null; |
737 |
0 |
synchronized (listeners) |
738 |
|
{ |
739 |
0 |
listenersList = new ArrayList(listeners); |
740 |
0 |
} |
741 |
|
|
742 |
0 |
Iterator listenersIter = listenersList.iterator(); |
743 |
0 |
while (listenersIter.hasNext()) |
744 |
|
{ |
745 |
0 |
PageManagerEventListener listener = (PageManagerEventListener)listenersIter.next(); |
746 |
|
try |
747 |
|
{ |
748 |
0 |
listener.updatedNode(node); |
749 |
|
} |
750 |
0 |
catch (Exception e) |
751 |
|
{ |
752 |
0 |
log.error("Failed to notify page manager event listener", e); |
753 |
0 |
} |
754 |
0 |
} |
755 |
0 |
} |
756 |
|
|
757 |
|
|
758 |
|
|
759 |
|
|
760 |
|
|
761 |
|
|
762 |
|
|
763 |
|
public void notifyRemovedNode(Node node) |
764 |
|
{ |
765 |
|
|
766 |
0 |
List listenersList = null; |
767 |
0 |
synchronized (listeners) |
768 |
|
{ |
769 |
0 |
listenersList = new ArrayList(listeners); |
770 |
0 |
} |
771 |
|
|
772 |
0 |
Iterator listenersIter = listenersList.iterator(); |
773 |
0 |
while (listenersIter.hasNext()) |
774 |
|
{ |
775 |
0 |
PageManagerEventListener listener = (PageManagerEventListener)listenersIter.next(); |
776 |
|
try |
777 |
|
{ |
778 |
0 |
listener.removedNode(node); |
779 |
|
} |
780 |
0 |
catch (Exception e) |
781 |
|
{ |
782 |
0 |
log.error("Failed to notify page manager event listener", e); |
783 |
0 |
} |
784 |
0 |
} |
785 |
0 |
} |
786 |
|
|
787 |
|
public Folder copyFolder(Folder source, String path) |
788 |
|
throws NodeException |
789 |
|
{ |
790 |
|
|
791 |
0 |
Folder folder = newFolder(path); |
792 |
0 |
folder.setDefaultPage(source.getDefaultPage()); |
793 |
0 |
folder.setShortTitle(source.getShortTitle()); |
794 |
0 |
folder.setTitle(source.getTitle()); |
795 |
0 |
folder.setHidden(source.isHidden()); |
796 |
0 |
folder.setDefaultDecorator(source.getDefaultDecorator(Fragment.LAYOUT), Fragment.LAYOUT); |
797 |
0 |
folder.setDefaultDecorator(source.getDefaultDecorator(Fragment.PORTLET), Fragment.PORTLET); |
798 |
0 |
folder.setSkin(source.getSkin()); |
799 |
|
|
800 |
|
|
801 |
0 |
folder.getMetadata().copyFields(source.getMetadata().getFields()); |
802 |
|
|
803 |
|
|
804 |
0 |
SecurityConstraints srcSecurity = source.getSecurityConstraints(); |
805 |
0 |
if ((srcSecurity != null) && !srcSecurity.isEmpty()) |
806 |
|
{ |
807 |
0 |
SecurityConstraints copiedSecurity = copySecurityConstraints(FOLDER_NODE_TYPE, srcSecurity); |
808 |
0 |
folder.setSecurityConstraints(copiedSecurity); |
809 |
|
} |
810 |
|
|
811 |
|
|
812 |
0 |
folder.setDocumentOrder(DatabasePageManagerUtils.createList()); |
813 |
0 |
Iterator documentOrders = source.getDocumentOrder().iterator(); |
814 |
0 |
while (documentOrders.hasNext()) |
815 |
|
{ |
816 |
0 |
String name = (String)documentOrders.next(); |
817 |
0 |
folder.getDocumentOrder().add(name); |
818 |
0 |
} |
819 |
|
|
820 |
|
|
821 |
0 |
List menus = source.getMenuDefinitions(); |
822 |
0 |
if (menus != null) |
823 |
|
{ |
824 |
0 |
List copiedMenus = copyMenuDefinitions(FOLDER_NODE_TYPE, menus); |
825 |
0 |
folder.setMenuDefinitions(copiedMenus); |
826 |
|
} |
827 |
|
|
828 |
0 |
return folder; |
829 |
|
} |
830 |
|
|
831 |
|
public Page copyPage(Page source, String path) |
832 |
|
throws NodeException |
833 |
|
{ |
834 |
|
|
835 |
0 |
Page page = newPage(path); |
836 |
0 |
page.setTitle(source.getTitle()); |
837 |
0 |
page.setShortTitle(source.getShortTitle()); |
838 |
0 |
page.setVersion(source.getVersion()); |
839 |
0 |
page.setDefaultDecorator(source.getDefaultDecorator(Fragment.LAYOUT), Fragment.LAYOUT); |
840 |
0 |
page.setDefaultDecorator(source.getDefaultDecorator(Fragment.PORTLET), Fragment.PORTLET); |
841 |
0 |
page.setSkin(source.getSkin()); |
842 |
0 |
page.setHidden(source.isHidden()); |
843 |
|
|
844 |
|
|
845 |
0 |
page.getMetadata().copyFields(source.getMetadata().getFields()); |
846 |
|
|
847 |
|
|
848 |
0 |
SecurityConstraints srcSecurity = source.getSecurityConstraints(); |
849 |
0 |
if ((srcSecurity != null) && !srcSecurity.isEmpty()) |
850 |
|
{ |
851 |
0 |
SecurityConstraints copiedSecurity = copySecurityConstraints(PAGE_NODE_TYPE, srcSecurity); |
852 |
0 |
page.setSecurityConstraints(copiedSecurity); |
853 |
|
} |
854 |
|
|
855 |
|
|
856 |
0 |
List menus = source.getMenuDefinitions(); |
857 |
0 |
if (menus != null) |
858 |
|
{ |
859 |
0 |
List copiedMenus = copyMenuDefinitions(PAGE_NODE_TYPE, menus); |
860 |
0 |
page.setMenuDefinitions(copiedMenus); |
861 |
|
} |
862 |
|
|
863 |
|
|
864 |
0 |
Fragment root = copyFragment(source.getRootFragment(), source.getRootFragment().getName()); |
865 |
0 |
page.setRootFragment(root); |
866 |
|
|
867 |
0 |
return page; |
868 |
|
} |
869 |
|
|
870 |
|
public Fragment copyFragment(Fragment source, String name) |
871 |
|
throws NodeException |
872 |
|
{ |
873 |
|
|
874 |
0 |
Fragment copy = newFragment(); |
875 |
0 |
copy.setDecorator(source.getDecorator()); |
876 |
0 |
copy.setName(name); |
877 |
0 |
copy.setShortTitle(source.getShortTitle()); |
878 |
0 |
copy.setSkin(source.getSkin()); |
879 |
0 |
copy.setTitle(source.getTitle()); |
880 |
0 |
copy.setType(source.getType()); |
881 |
0 |
copy.setState(source.getState()); |
882 |
|
|
883 |
|
|
884 |
0 |
SecurityConstraints srcSecurity = source.getSecurityConstraints(); |
885 |
0 |
if ((srcSecurity != null) && !srcSecurity.isEmpty()) |
886 |
|
{ |
887 |
0 |
SecurityConstraints copiedSecurity = copySecurityConstraints(FRAGMENT_NODE_TYPE, srcSecurity); |
888 |
0 |
copy.setSecurityConstraints(copiedSecurity); |
889 |
|
} |
890 |
|
|
891 |
|
|
892 |
0 |
Iterator props = source.getProperties().entrySet().iterator(); |
893 |
0 |
while (props.hasNext()) |
894 |
|
{ |
895 |
0 |
Map.Entry prop = (Map.Entry)props.next(); |
896 |
0 |
copy.getProperties().put(prop.getKey(), prop.getValue()); |
897 |
0 |
} |
898 |
|
|
899 |
|
|
900 |
0 |
copy.setPreferences(DatabasePageManagerUtils.createList()); |
901 |
0 |
Iterator prefs = source.getPreferences().iterator(); |
902 |
0 |
while (prefs.hasNext()) |
903 |
|
{ |
904 |
0 |
FragmentPreference pref = (FragmentPreference)prefs.next(); |
905 |
0 |
FragmentPreference newPref = this.newFragmentPreference(); |
906 |
0 |
newPref.setName(pref.getName()); |
907 |
0 |
newPref.setReadOnly(pref.isReadOnly()); |
908 |
0 |
newPref.setValueList(DatabasePageManagerUtils.createList()); |
909 |
0 |
Iterator values = pref.getValueList().iterator(); |
910 |
0 |
while (values.hasNext()) |
911 |
|
{ |
912 |
0 |
String value = (String)values.next(); |
913 |
0 |
newPref.getValueList().add(value); |
914 |
0 |
} |
915 |
0 |
copy.getPreferences().add(newPref); |
916 |
0 |
} |
917 |
|
|
918 |
|
|
919 |
0 |
Iterator fragments = source.getFragments().iterator(); |
920 |
0 |
while (fragments.hasNext()) |
921 |
|
{ |
922 |
0 |
Fragment fragment = (Fragment)fragments.next(); |
923 |
0 |
Fragment copiedFragment = copyFragment(fragment, fragment.getName()); |
924 |
0 |
copy.getFragments().add(copiedFragment); |
925 |
0 |
} |
926 |
0 |
return copy; |
927 |
|
} |
928 |
|
|
929 |
|
public Link copyLink(Link source, String path) |
930 |
|
throws NodeException |
931 |
|
{ |
932 |
|
|
933 |
0 |
Link link = newLink(path); |
934 |
0 |
link.setTitle(source.getTitle()); |
935 |
0 |
link.setShortTitle(source.getShortTitle()); |
936 |
0 |
link.setSkin(source.getSkin()); |
937 |
0 |
link.setVersion(source.getVersion()); |
938 |
0 |
link.setTarget(source.getTarget()); |
939 |
0 |
link.setUrl(source.getUrl()); |
940 |
0 |
link.setHidden(source.isHidden()); |
941 |
|
|
942 |
|
|
943 |
0 |
link.getMetadata().copyFields(source.getMetadata().getFields()); |
944 |
|
|
945 |
|
|
946 |
0 |
SecurityConstraints srcSecurity = source.getSecurityConstraints(); |
947 |
0 |
if ((srcSecurity != null) && !srcSecurity.isEmpty()) |
948 |
|
{ |
949 |
0 |
SecurityConstraints copiedSecurity = copySecurityConstraints(LINK_NODE_TYPE, srcSecurity); |
950 |
0 |
link.setSecurityConstraints(copiedSecurity); |
951 |
|
} |
952 |
|
|
953 |
0 |
return link; |
954 |
|
} |
955 |
|
|
956 |
|
public PageSecurity copyPageSecurity(PageSecurity source) |
957 |
|
throws NodeException |
958 |
|
{ |
959 |
|
|
960 |
0 |
PageSecurity copy = this.newPageSecurity(); |
961 |
0 |
copy.setPath(source.getPath()); |
962 |
0 |
copy.setVersion(source.getVersion()); |
963 |
|
|
964 |
|
|
965 |
0 |
copy.setSecurityConstraintsDefs(DatabasePageManagerUtils.createList()); |
966 |
0 |
Iterator defs = source.getSecurityConstraintsDefs().iterator(); |
967 |
0 |
while (defs.hasNext()) |
968 |
|
{ |
969 |
0 |
SecurityConstraintsDef def = (SecurityConstraintsDef)defs.next(); |
970 |
0 |
SecurityConstraintsDef defCopy = this.newSecurityConstraintsDef(); |
971 |
0 |
defCopy.setName(def.getName()); |
972 |
0 |
List copiedConstraints = DatabasePageManagerUtils.createList(); |
973 |
0 |
Iterator constraints = def.getSecurityConstraints().iterator(); |
974 |
0 |
while (constraints.hasNext()) |
975 |
|
{ |
976 |
0 |
SecurityConstraint srcConstraint = (SecurityConstraint)constraints.next(); |
977 |
0 |
SecurityConstraint dstConstraint = newPageSecuritySecurityConstraint(); |
978 |
0 |
copyConstraint(srcConstraint, dstConstraint); |
979 |
0 |
copiedConstraints.add(dstConstraint); |
980 |
0 |
} |
981 |
0 |
defCopy.setSecurityConstraints(copiedConstraints); |
982 |
0 |
copy.getSecurityConstraintsDefs().add(defCopy); |
983 |
0 |
} |
984 |
|
|
985 |
|
|
986 |
0 |
copy.setGlobalSecurityConstraintsRefs(DatabasePageManagerUtils.createList()); |
987 |
0 |
Iterator globals = source.getGlobalSecurityConstraintsRefs().iterator(); |
988 |
0 |
while (globals.hasNext()) |
989 |
|
{ |
990 |
0 |
String global = (String)globals.next(); |
991 |
0 |
copy.getGlobalSecurityConstraintsRefs().add(global); |
992 |
0 |
} |
993 |
|
|
994 |
0 |
return copy; |
995 |
|
} |
996 |
|
|
997 |
|
protected List copyMenuDefinitions(String type, List srcMenus) |
998 |
|
{ |
999 |
0 |
List copiedMenus = DatabasePageManagerUtils.createList(); |
1000 |
0 |
Iterator menus = srcMenus.iterator(); |
1001 |
0 |
while (menus.hasNext()) |
1002 |
|
{ |
1003 |
0 |
MenuDefinition srcMenu = (MenuDefinition)menus.next(); |
1004 |
0 |
MenuDefinition copiedMenu = (MenuDefinition)copyMenuElement(type, srcMenu); |
1005 |
0 |
if (copiedMenu != null) |
1006 |
|
{ |
1007 |
0 |
copiedMenus.add(copiedMenu); |
1008 |
|
} |
1009 |
0 |
} |
1010 |
0 |
return copiedMenus; |
1011 |
|
} |
1012 |
|
|
1013 |
|
protected Object copyMenuElement(String type, Object srcElement) |
1014 |
|
{ |
1015 |
0 |
if (srcElement instanceof MenuDefinition) |
1016 |
|
{ |
1017 |
|
|
1018 |
0 |
MenuDefinition source = (MenuDefinition)srcElement; |
1019 |
0 |
MenuDefinition menu = null; |
1020 |
0 |
if (type.equals(PAGE_NODE_TYPE)) |
1021 |
|
{ |
1022 |
0 |
menu = newPageMenuDefinition(); |
1023 |
|
} |
1024 |
0 |
else if (type.equals(FOLDER_NODE_TYPE)) |
1025 |
|
{ |
1026 |
0 |
menu = newFolderMenuDefinition(); |
1027 |
|
} |
1028 |
0 |
menu.setDepth(source.getDepth()); |
1029 |
0 |
menu.setName(source.getName()); |
1030 |
0 |
menu.setOptions(source.getOptions()); |
1031 |
0 |
menu.setOrder(source.getOrder()); |
1032 |
0 |
menu.setPaths(source.isPaths()); |
1033 |
0 |
menu.setProfile(source.getProfile()); |
1034 |
0 |
menu.setRegexp(source.isRegexp()); |
1035 |
0 |
menu.setShortTitle(source.getShortTitle()); |
1036 |
0 |
menu.setSkin(source.getSkin()); |
1037 |
0 |
menu.setTitle(source.getTitle()); |
1038 |
|
|
1039 |
|
|
1040 |
0 |
menu.getMetadata().copyFields(source.getMetadata().getFields()); |
1041 |
|
|
1042 |
|
|
1043 |
0 |
List elements = source.getMenuElements(); |
1044 |
0 |
if (elements != null) |
1045 |
|
{ |
1046 |
0 |
List copiedElements = DatabasePageManagerUtils.createList(); |
1047 |
0 |
Iterator elementsIter = elements.iterator(); |
1048 |
0 |
while (elementsIter.hasNext()) |
1049 |
|
{ |
1050 |
0 |
Object element = elementsIter.next(); |
1051 |
0 |
Object copiedElement = copyMenuElement(type, element); |
1052 |
0 |
if (copiedElement != null) |
1053 |
|
{ |
1054 |
0 |
copiedElements.add(copiedElement); |
1055 |
|
} |
1056 |
0 |
} |
1057 |
0 |
menu.setMenuElements(copiedElements); |
1058 |
|
} |
1059 |
|
|
1060 |
0 |
return menu; |
1061 |
|
} |
1062 |
0 |
else if (srcElement instanceof MenuExcludeDefinition) |
1063 |
|
{ |
1064 |
|
|
1065 |
0 |
MenuExcludeDefinition source = (MenuExcludeDefinition)srcElement; |
1066 |
0 |
MenuExcludeDefinition menuExclude = null; |
1067 |
0 |
if (type.equals(PAGE_NODE_TYPE)) |
1068 |
|
{ |
1069 |
0 |
menuExclude = newPageMenuExcludeDefinition(); |
1070 |
|
} |
1071 |
0 |
else if (type.equals(FOLDER_NODE_TYPE)) |
1072 |
|
{ |
1073 |
0 |
menuExclude = newFolderMenuExcludeDefinition(); |
1074 |
|
} |
1075 |
0 |
menuExclude.setName(source.getName()); |
1076 |
0 |
return menuExclude; |
1077 |
|
} |
1078 |
0 |
else if (srcElement instanceof MenuIncludeDefinition) |
1079 |
|
{ |
1080 |
|
|
1081 |
0 |
MenuIncludeDefinition source = (MenuIncludeDefinition)srcElement; |
1082 |
0 |
MenuIncludeDefinition menuInclude = null; |
1083 |
0 |
if (type.equals(PAGE_NODE_TYPE)) |
1084 |
|
{ |
1085 |
0 |
menuInclude = newPageMenuIncludeDefinition(); |
1086 |
|
} |
1087 |
0 |
else if (type.equals(FOLDER_NODE_TYPE)) |
1088 |
|
{ |
1089 |
0 |
menuInclude = newFolderMenuIncludeDefinition(); |
1090 |
|
} |
1091 |
0 |
menuInclude.setName(source.getName()); |
1092 |
0 |
menuInclude.setNest(source.isNest()); |
1093 |
0 |
return menuInclude; |
1094 |
|
} |
1095 |
0 |
else if (srcElement instanceof MenuOptionsDefinition) |
1096 |
|
{ |
1097 |
|
|
1098 |
0 |
MenuOptionsDefinition source = (MenuOptionsDefinition)srcElement; |
1099 |
0 |
MenuOptionsDefinition menuOptions = null; |
1100 |
0 |
if (type.equals(PAGE_NODE_TYPE)) |
1101 |
|
{ |
1102 |
0 |
menuOptions = newPageMenuOptionsDefinition(); |
1103 |
|
} |
1104 |
0 |
else if (type.equals(FOLDER_NODE_TYPE)) |
1105 |
|
{ |
1106 |
0 |
menuOptions = newFolderMenuOptionsDefinition(); |
1107 |
|
} |
1108 |
0 |
menuOptions.setDepth(source.getDepth()); |
1109 |
0 |
menuOptions.setOptions(source.getOptions()); |
1110 |
0 |
menuOptions.setOrder(source.getOrder()); |
1111 |
0 |
menuOptions.setPaths(source.isPaths()); |
1112 |
0 |
menuOptions.setProfile(source.getProfile()); |
1113 |
0 |
menuOptions.setRegexp(source.isRegexp()); |
1114 |
0 |
menuOptions.setSkin(source.getSkin()); |
1115 |
0 |
return menuOptions; |
1116 |
|
} |
1117 |
0 |
else if (srcElement instanceof MenuSeparatorDefinition) |
1118 |
|
{ |
1119 |
|
|
1120 |
0 |
MenuSeparatorDefinition source = (MenuSeparatorDefinition)srcElement; |
1121 |
0 |
MenuSeparatorDefinition menuSeparator = null; |
1122 |
0 |
if (type.equals(PAGE_NODE_TYPE)) |
1123 |
|
{ |
1124 |
0 |
menuSeparator = newPageMenuSeparatorDefinition(); |
1125 |
|
} |
1126 |
0 |
else if (type.equals(FOLDER_NODE_TYPE)) |
1127 |
|
{ |
1128 |
0 |
menuSeparator = newFolderMenuSeparatorDefinition(); |
1129 |
|
} |
1130 |
0 |
menuSeparator.setSkin(source.getSkin()); |
1131 |
0 |
menuSeparator.setTitle(source.getTitle()); |
1132 |
0 |
menuSeparator.setText(source.getText()); |
1133 |
|
|
1134 |
|
|
1135 |
0 |
menuSeparator.getMetadata().copyFields(source.getMetadata().getFields()); |
1136 |
|
|
1137 |
0 |
return menuSeparator; |
1138 |
|
} |
1139 |
0 |
return null; |
1140 |
|
} |
1141 |
|
|
1142 |
|
protected void copyConstraint(SecurityConstraint srcConstraint, SecurityConstraint dstConstraint) |
1143 |
|
{ |
1144 |
0 |
dstConstraint.setUsers(srcConstraint.getUsers()); |
1145 |
0 |
dstConstraint.setRoles(srcConstraint.getRoles()); |
1146 |
0 |
dstConstraint.setGroups(srcConstraint.getGroups()); |
1147 |
0 |
dstConstraint.setPermissions(srcConstraint.getPermissions()); |
1148 |
0 |
} |
1149 |
|
|
1150 |
|
protected SecurityConstraints copySecurityConstraints(String type, SecurityConstraints source) |
1151 |
|
{ |
1152 |
0 |
SecurityConstraints security = newSecurityConstraints(); |
1153 |
0 |
if (source.getOwner() != null) |
1154 |
|
{ |
1155 |
0 |
security.setOwner(source.getOwner()); |
1156 |
|
} |
1157 |
0 |
if (source.getSecurityConstraints() != null) |
1158 |
|
{ |
1159 |
0 |
List copiedConstraints = DatabasePageManagerUtils.createList(); |
1160 |
0 |
Iterator constraints = source.getSecurityConstraints().iterator(); |
1161 |
0 |
while (constraints.hasNext()) |
1162 |
|
{ |
1163 |
0 |
SecurityConstraint srcConstraint = (SecurityConstraint)constraints.next(); |
1164 |
0 |
SecurityConstraint dstConstraint = null; |
1165 |
0 |
if (type.equals(PAGE_NODE_TYPE)) |
1166 |
|
{ |
1167 |
0 |
dstConstraint = newPageSecurityConstraint(); |
1168 |
|
} |
1169 |
0 |
else if (type.equals(FOLDER_NODE_TYPE)) |
1170 |
|
{ |
1171 |
0 |
dstConstraint = newFolderSecurityConstraint(); |
1172 |
|
} |
1173 |
0 |
else if (type.equals(LINK_NODE_TYPE)) |
1174 |
|
{ |
1175 |
0 |
dstConstraint = newLinkSecurityConstraint(); |
1176 |
|
} |
1177 |
0 |
else if (type.equals(FRAGMENT_NODE_TYPE)) |
1178 |
|
{ |
1179 |
0 |
dstConstraint = newFragmentSecurityConstraint(); |
1180 |
|
} |
1181 |
0 |
copyConstraint(srcConstraint, dstConstraint); |
1182 |
0 |
copiedConstraints.add(dstConstraint); |
1183 |
0 |
} |
1184 |
0 |
security.setSecurityConstraints(copiedConstraints); |
1185 |
|
} |
1186 |
0 |
if (source.getSecurityConstraintsRefs() != null) |
1187 |
|
{ |
1188 |
0 |
List copiedRefs = DatabasePageManagerUtils.createList(); |
1189 |
0 |
Iterator refs = source.getSecurityConstraintsRefs().iterator(); |
1190 |
0 |
while (refs.hasNext()) |
1191 |
|
{ |
1192 |
0 |
String constraintsRef = (String)refs.next(); |
1193 |
0 |
copiedRefs.add(constraintsRef); |
1194 |
0 |
} |
1195 |
0 |
security.setSecurityConstraintsRefs(copiedRefs); |
1196 |
|
} |
1197 |
0 |
return security; |
1198 |
|
} |
1199 |
|
|
1200 |
|
|
1201 |
|
|
1202 |
|
|
1203 |
|
|
1204 |
|
|
1205 |
|
|
1206 |
|
public void deepCopyFolder(Folder srcFolder, String destinationPath, String owner) |
1207 |
|
throws NodeException |
1208 |
|
{ |
1209 |
0 |
PageManagerUtils.deepCopyFolder(this, srcFolder, destinationPath, owner); |
1210 |
0 |
} |
1211 |
|
|
1212 |
|
public Page getUserPage(String userName, String pageName) |
1213 |
|
throws PageNotFoundException, NodeException |
1214 |
|
{ |
1215 |
0 |
return this.getPage(Folder.USER_FOLDER + userName + Folder.PATH_SEPARATOR + pageName); |
1216 |
|
} |
1217 |
|
|
1218 |
|
public Folder getUserFolder(String userName) |
1219 |
|
throws FolderNotFoundException, InvalidFolderException, NodeException |
1220 |
|
{ |
1221 |
0 |
return this.getFolder(Folder.USER_FOLDER + userName); |
1222 |
|
} |
1223 |
|
|
1224 |
|
public boolean folderExists(String folderName) |
1225 |
|
{ |
1226 |
|
try |
1227 |
|
{ |
1228 |
0 |
getFolder(folderName); |
1229 |
|
} |
1230 |
0 |
catch (Exception e) |
1231 |
|
{ |
1232 |
0 |
return false; |
1233 |
0 |
} |
1234 |
0 |
return true; |
1235 |
|
} |
1236 |
|
public boolean pageExists(String pageName) |
1237 |
|
{ |
1238 |
|
try |
1239 |
|
{ |
1240 |
0 |
getPage(pageName); |
1241 |
|
} |
1242 |
0 |
catch (Exception e) |
1243 |
|
{ |
1244 |
0 |
return false; |
1245 |
0 |
} |
1246 |
0 |
return true; |
1247 |
|
} |
1248 |
|
|
1249 |
|
public boolean linkExists(String linkName) |
1250 |
|
{ |
1251 |
|
try |
1252 |
|
{ |
1253 |
0 |
getLink(linkName); |
1254 |
|
} |
1255 |
0 |
catch (Exception e) |
1256 |
|
{ |
1257 |
0 |
return false; |
1258 |
0 |
} |
1259 |
0 |
return true; |
1260 |
|
} |
1261 |
|
|
1262 |
|
public boolean userFolderExists(String userName) |
1263 |
|
{ |
1264 |
|
try |
1265 |
|
{ |
1266 |
0 |
getFolder(Folder.USER_FOLDER + userName); |
1267 |
|
} |
1268 |
0 |
catch (Exception e) |
1269 |
|
{ |
1270 |
0 |
return false; |
1271 |
0 |
} |
1272 |
0 |
return true; |
1273 |
|
} |
1274 |
|
|
1275 |
|
public boolean userPageExists(String userName, String pageName) |
1276 |
|
{ |
1277 |
|
try |
1278 |
|
{ |
1279 |
0 |
getPage(Folder.USER_FOLDER + userName + Folder.PATH_SEPARATOR + pageName); |
1280 |
|
} |
1281 |
0 |
catch (Exception e) |
1282 |
|
{ |
1283 |
0 |
return false; |
1284 |
0 |
} |
1285 |
0 |
return true; |
1286 |
|
} |
1287 |
|
|
1288 |
|
|
1289 |
|
|
1290 |
|
|
1291 |
|
|
1292 |
|
|
1293 |
|
|
1294 |
|
|
1295 |
|
public void createUserHomePagesFromRoles(Subject subject) |
1296 |
|
throws NodeException |
1297 |
|
{ |
1298 |
0 |
PageManagerUtils.createUserHomePagesFromRoles(this, subject); |
1299 |
0 |
} |
1300 |
|
|
1301 |
|
} |