1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
package org.apache.jetspeed.page.impl; |
18 |
|
|
19 |
|
import java.util.Collection; |
20 |
|
import java.util.HashMap; |
21 |
|
import java.util.Iterator; |
22 |
|
import java.util.List; |
23 |
|
import java.util.Map; |
24 |
|
|
25 |
|
import javax.security.auth.Subject; |
26 |
|
|
27 |
|
import org.apache.jetspeed.JetspeedActions; |
28 |
|
import org.apache.jetspeed.components.dao.InitablePersistenceBrokerDaoSupport; |
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.folder.impl.FolderImpl; |
40 |
|
import org.apache.jetspeed.om.folder.impl.FolderMenuDefinitionImpl; |
41 |
|
import org.apache.jetspeed.om.folder.impl.FolderMenuExcludeDefinitionImpl; |
42 |
|
import org.apache.jetspeed.om.folder.impl.FolderMenuIncludeDefinitionImpl; |
43 |
|
import org.apache.jetspeed.om.folder.impl.FolderMenuOptionsDefinitionImpl; |
44 |
|
import org.apache.jetspeed.om.folder.impl.FolderMenuSeparatorDefinitionImpl; |
45 |
|
import org.apache.jetspeed.om.folder.impl.FolderSecurityConstraintImpl; |
46 |
|
import org.apache.jetspeed.om.page.ContentPage; |
47 |
|
import org.apache.jetspeed.om.page.ContentPageImpl; |
48 |
|
import org.apache.jetspeed.om.page.Fragment; |
49 |
|
import org.apache.jetspeed.om.page.Link; |
50 |
|
import org.apache.jetspeed.om.page.Page; |
51 |
|
import org.apache.jetspeed.om.page.PageSecurity; |
52 |
|
import org.apache.jetspeed.om.page.SecurityConstraintsDef; |
53 |
|
import org.apache.jetspeed.om.page.impl.FragmentImpl; |
54 |
|
import org.apache.jetspeed.om.page.impl.FragmentPreferenceImpl; |
55 |
|
import org.apache.jetspeed.om.page.impl.FragmentSecurityConstraintImpl; |
56 |
|
import org.apache.jetspeed.om.page.impl.LinkImpl; |
57 |
|
import org.apache.jetspeed.om.page.impl.LinkSecurityConstraintImpl; |
58 |
|
import org.apache.jetspeed.om.page.impl.PageImpl; |
59 |
|
import org.apache.jetspeed.om.page.impl.PageMenuDefinitionImpl; |
60 |
|
import org.apache.jetspeed.om.page.impl.PageMenuExcludeDefinitionImpl; |
61 |
|
import org.apache.jetspeed.om.page.impl.PageMenuIncludeDefinitionImpl; |
62 |
|
import org.apache.jetspeed.om.page.impl.PageMenuOptionsDefinitionImpl; |
63 |
|
import org.apache.jetspeed.om.page.impl.PageMenuSeparatorDefinitionImpl; |
64 |
|
import org.apache.jetspeed.om.page.impl.PageSecurityConstraintImpl; |
65 |
|
import org.apache.jetspeed.om.page.impl.PageSecurityImpl; |
66 |
|
import org.apache.jetspeed.om.page.impl.PageSecuritySecurityConstraintImpl; |
67 |
|
import org.apache.jetspeed.om.page.impl.SecurityConstraintsDefImpl; |
68 |
|
import org.apache.jetspeed.om.page.impl.SecurityConstraintsImpl; |
69 |
|
import org.apache.jetspeed.om.preference.FragmentPreference; |
70 |
|
import org.apache.jetspeed.page.DelegatingPageManager; |
71 |
|
import org.apache.jetspeed.page.FolderNotRemovedException; |
72 |
|
import org.apache.jetspeed.page.FolderNotUpdatedException; |
73 |
|
import org.apache.jetspeed.page.LinkNotRemovedException; |
74 |
|
import org.apache.jetspeed.page.LinkNotUpdatedException; |
75 |
|
import org.apache.jetspeed.page.PageManager; |
76 |
|
import org.apache.jetspeed.page.PageManagerEventListener; |
77 |
|
import org.apache.jetspeed.page.PageManagerSecurityUtils; |
78 |
|
import org.apache.jetspeed.page.PageManagerUtils; |
79 |
|
import org.apache.jetspeed.page.PageNotFoundException; |
80 |
|
import org.apache.jetspeed.page.PageNotRemovedException; |
81 |
|
import org.apache.jetspeed.page.PageNotUpdatedException; |
82 |
|
import org.apache.jetspeed.page.document.DocumentException; |
83 |
|
import org.apache.jetspeed.page.document.DocumentNotFoundException; |
84 |
|
import org.apache.jetspeed.page.document.FailedToDeleteDocumentException; |
85 |
|
import org.apache.jetspeed.page.document.FailedToUpdateDocumentException; |
86 |
|
import org.apache.jetspeed.page.document.NodeException; |
87 |
|
import org.apache.jetspeed.page.document.NodeSet; |
88 |
|
import org.apache.jetspeed.page.document.impl.NodeImpl; |
89 |
|
import org.apache.ojb.broker.core.proxy.ProxyHelper; |
90 |
|
import org.apache.ojb.broker.query.Criteria; |
91 |
|
import org.apache.ojb.broker.query.QueryByCriteria; |
92 |
|
import org.apache.ojb.broker.query.QueryFactory; |
93 |
|
|
94 |
|
|
95 |
|
|
96 |
|
|
97 |
|
|
98 |
|
|
99 |
|
|
100 |
|
|
101 |
|
public class DatabasePageManager extends InitablePersistenceBrokerDaoSupport implements PageManager |
102 |
|
{ |
103 |
|
private static final int DEFAULT_CACHE_SIZE = 128; |
104 |
|
private static final int MIN_CACHE_EXPIRES_SECONDS = 30; |
105 |
|
private static final int DEFAULT_CACHE_EXPIRES_SECONDS = 150; |
106 |
|
|
107 |
0 |
private static Map modelClasses = new HashMap(); |
108 |
|
static |
109 |
|
{ |
110 |
0 |
modelClasses.put("FragmentImpl", FragmentImpl.class); |
111 |
0 |
modelClasses.put("PageImpl", PageImpl.class); |
112 |
0 |
modelClasses.put("FolderImpl", FolderImpl.class); |
113 |
0 |
modelClasses.put("LinkImpl", LinkImpl.class); |
114 |
0 |
modelClasses.put("PageSecurityImpl", PageSecurityImpl.class); |
115 |
0 |
modelClasses.put("FolderMenuDefinitionImpl", FolderMenuDefinitionImpl.class); |
116 |
0 |
modelClasses.put("FolderMenuExcludeDefinitionImpl", FolderMenuExcludeDefinitionImpl.class); |
117 |
0 |
modelClasses.put("FolderMenuIncludeDefinitionImpl", FolderMenuIncludeDefinitionImpl.class); |
118 |
0 |
modelClasses.put("FolderMenuOptionsDefinitionImpl", FolderMenuOptionsDefinitionImpl.class); |
119 |
0 |
modelClasses.put("FolderMenuSeparatorDefinitionImpl", FolderMenuSeparatorDefinitionImpl.class); |
120 |
0 |
modelClasses.put("PageMenuDefinitionImpl", PageMenuDefinitionImpl.class); |
121 |
0 |
modelClasses.put("PageMenuExcludeDefinitionImpl", PageMenuExcludeDefinitionImpl.class); |
122 |
0 |
modelClasses.put("PageMenuIncludeDefinitionImpl", PageMenuIncludeDefinitionImpl.class); |
123 |
0 |
modelClasses.put("PageMenuOptionsDefinitionImpl", PageMenuOptionsDefinitionImpl.class); |
124 |
0 |
modelClasses.put("PageMenuSeparatorDefinitionImpl", PageMenuSeparatorDefinitionImpl.class); |
125 |
0 |
modelClasses.put("SecurityConstraintsImpl", SecurityConstraintsImpl.class); |
126 |
0 |
modelClasses.put("FolderSecurityConstraintImpl", FolderSecurityConstraintImpl.class); |
127 |
0 |
modelClasses.put("PageSecurityConstraintImpl", PageSecurityConstraintImpl.class); |
128 |
0 |
modelClasses.put("FragmentSecurityConstraintImpl", FragmentSecurityConstraintImpl.class); |
129 |
0 |
modelClasses.put("LinkSecurityConstraintImpl", LinkSecurityConstraintImpl.class); |
130 |
0 |
modelClasses.put("PageSecuritySecurityConstraintImpl", PageSecuritySecurityConstraintImpl.class); |
131 |
0 |
modelClasses.put("SecurityConstraintsDefImpl", SecurityConstraintsDefImpl.class); |
132 |
0 |
modelClasses.put("FragmentPreferenceImpl", FragmentPreferenceImpl.class); |
133 |
0 |
} |
134 |
|
|
135 |
|
private DelegatingPageManager delegator; |
136 |
|
|
137 |
|
private int cacheSize; |
138 |
|
|
139 |
|
private int cacheExpiresSeconds; |
140 |
|
|
141 |
|
private PageManager pageManagerProxy; |
142 |
|
|
143 |
|
public DatabasePageManager(String repositoryPath, int cacheSize, class="keyword">int cacheExpiresSeconds, boolean isPermissionsSecurity, boolean isConstraclass="keyword">intsSecurity) |
144 |
|
{ |
145 |
0 |
super(repositoryPath); |
146 |
0 |
delegator = new DelegatingPageManager(isPermissionsSecurity, isConstraintsSecurity, modelClasses); |
147 |
0 |
this.cacheSize = Math.max(cacheSize, DEFAULT_CACHE_SIZE); |
148 |
0 |
if (cacheExpiresSeconds < 0) |
149 |
|
{ |
150 |
0 |
this.cacheExpiresSeconds = DEFAULT_CACHE_EXPIRES_SECONDS; |
151 |
|
} |
152 |
0 |
else if (cacheExpiresSeconds == 0) |
153 |
|
{ |
154 |
0 |
this.cacheExpiresSeconds = 0; |
155 |
|
} |
156 |
|
else |
157 |
|
{ |
158 |
0 |
this.cacheExpiresSeconds = Math.max(cacheExpiresSeconds, MIN_CACHE_EXPIRES_SECONDS); |
159 |
|
} |
160 |
0 |
DatabasePageManagerCache.cacheInit(this); |
161 |
0 |
} |
162 |
|
|
163 |
|
|
164 |
|
|
165 |
|
|
166 |
|
|
167 |
|
|
168 |
|
public int getCacheSize() |
169 |
|
{ |
170 |
0 |
return cacheSize; |
171 |
|
} |
172 |
|
|
173 |
|
|
174 |
|
|
175 |
|
|
176 |
|
|
177 |
|
|
178 |
|
public int getCacheExpiresSeconds() |
179 |
|
{ |
180 |
0 |
return cacheExpiresSeconds; |
181 |
|
} |
182 |
|
|
183 |
|
|
184 |
|
|
185 |
|
|
186 |
|
|
187 |
|
|
188 |
|
|
189 |
|
|
190 |
|
public PageManager getPageManagerProxy() |
191 |
|
{ |
192 |
0 |
return pageManagerProxy; |
193 |
|
} |
194 |
|
|
195 |
|
|
196 |
|
|
197 |
|
|
198 |
|
|
199 |
|
|
200 |
|
|
201 |
|
|
202 |
|
public void setPageManagerProxy(PageManager proxy) |
203 |
|
{ |
204 |
|
|
205 |
0 |
if (pageManagerProxy != proxy) |
206 |
|
{ |
207 |
0 |
pageManagerProxy = proxy; |
208 |
0 |
DatabasePageManagerCache.setPageManagerProxy(proxy); |
209 |
|
} |
210 |
0 |
} |
211 |
|
|
212 |
|
|
213 |
|
|
214 |
|
|
215 |
|
public boolean getConstraintsEnabled() |
216 |
|
{ |
217 |
0 |
return delegator.getConstraintsEnabled(); |
218 |
|
} |
219 |
|
|
220 |
|
|
221 |
|
|
222 |
|
|
223 |
|
public boolean getPermissionsEnabled() |
224 |
|
{ |
225 |
0 |
return delegator.getPermissionsEnabled(); |
226 |
|
} |
227 |
|
|
228 |
|
|
229 |
|
|
230 |
|
|
231 |
|
public Page newPage(String path) |
232 |
|
{ |
233 |
0 |
return delegator.newPage(path); |
234 |
|
} |
235 |
|
|
236 |
|
|
237 |
|
|
238 |
|
|
239 |
|
public Folder newFolder(String path) |
240 |
|
{ |
241 |
0 |
return delegator.newFolder(path); |
242 |
|
} |
243 |
|
|
244 |
|
|
245 |
|
|
246 |
|
|
247 |
|
public Link newLink(String path) |
248 |
|
{ |
249 |
0 |
return delegator.newLink(path); |
250 |
|
} |
251 |
|
|
252 |
|
|
253 |
|
|
254 |
|
|
255 |
|
public PageSecurity newPageSecurity() |
256 |
|
{ |
257 |
0 |
return delegator.newPageSecurity(); |
258 |
|
} |
259 |
|
|
260 |
|
|
261 |
|
|
262 |
|
|
263 |
|
public Fragment newFragment() |
264 |
|
{ |
265 |
0 |
return delegator.newFragment(); |
266 |
|
} |
267 |
|
|
268 |
|
|
269 |
|
|
270 |
|
|
271 |
|
public Fragment newPortletFragment() |
272 |
|
{ |
273 |
0 |
return delegator.newPortletFragment(); |
274 |
|
} |
275 |
|
|
276 |
|
|
277 |
|
|
278 |
|
|
279 |
|
public MenuDefinition newFolderMenuDefinition() |
280 |
|
{ |
281 |
0 |
return delegator.newFolderMenuDefinition(); |
282 |
|
} |
283 |
|
|
284 |
|
|
285 |
|
|
286 |
|
|
287 |
|
public MenuExcludeDefinition newFolderMenuExcludeDefinition() |
288 |
|
{ |
289 |
0 |
return delegator.newFolderMenuExcludeDefinition(); |
290 |
|
} |
291 |
|
|
292 |
|
|
293 |
|
|
294 |
|
|
295 |
|
public MenuIncludeDefinition newFolderMenuIncludeDefinition() |
296 |
|
{ |
297 |
0 |
return delegator.newFolderMenuIncludeDefinition(); |
298 |
|
} |
299 |
|
|
300 |
|
|
301 |
|
|
302 |
|
|
303 |
|
public MenuOptionsDefinition newFolderMenuOptionsDefinition() |
304 |
|
{ |
305 |
0 |
return delegator.newFolderMenuOptionsDefinition(); |
306 |
|
} |
307 |
|
|
308 |
|
|
309 |
|
|
310 |
|
|
311 |
|
public MenuSeparatorDefinition newFolderMenuSeparatorDefinition() |
312 |
|
{ |
313 |
0 |
return delegator.newFolderMenuSeparatorDefinition(); |
314 |
|
} |
315 |
|
|
316 |
|
|
317 |
|
|
318 |
|
|
319 |
|
public MenuDefinition newPageMenuDefinition() |
320 |
|
{ |
321 |
0 |
return delegator.newPageMenuDefinition(); |
322 |
|
} |
323 |
|
|
324 |
|
|
325 |
|
|
326 |
|
|
327 |
|
public MenuExcludeDefinition newPageMenuExcludeDefinition() |
328 |
|
{ |
329 |
0 |
return delegator.newPageMenuExcludeDefinition(); |
330 |
|
} |
331 |
|
|
332 |
|
|
333 |
|
|
334 |
|
|
335 |
|
public MenuIncludeDefinition newPageMenuIncludeDefinition() |
336 |
|
{ |
337 |
0 |
return delegator.newPageMenuIncludeDefinition(); |
338 |
|
} |
339 |
|
|
340 |
|
|
341 |
|
|
342 |
|
|
343 |
|
public MenuOptionsDefinition newPageMenuOptionsDefinition() |
344 |
|
{ |
345 |
0 |
return delegator.newPageMenuOptionsDefinition(); |
346 |
|
} |
347 |
|
|
348 |
|
|
349 |
|
|
350 |
|
|
351 |
|
public MenuSeparatorDefinition newPageMenuSeparatorDefinition() |
352 |
|
{ |
353 |
0 |
return delegator.newPageMenuSeparatorDefinition(); |
354 |
|
} |
355 |
|
|
356 |
|
|
357 |
|
|
358 |
|
|
359 |
|
public SecurityConstraints newSecurityConstraints() |
360 |
|
{ |
361 |
0 |
return delegator.newSecurityConstraints(); |
362 |
|
} |
363 |
|
|
364 |
|
|
365 |
|
|
366 |
|
|
367 |
|
public SecurityConstraint newFolderSecurityConstraint() |
368 |
|
{ |
369 |
0 |
return delegator.newFolderSecurityConstraint(); |
370 |
|
} |
371 |
|
|
372 |
|
|
373 |
|
|
374 |
|
|
375 |
|
public SecurityConstraint newPageSecurityConstraint() |
376 |
|
{ |
377 |
0 |
return delegator.newPageSecurityConstraint(); |
378 |
|
} |
379 |
|
|
380 |
|
|
381 |
|
|
382 |
|
|
383 |
|
public SecurityConstraint newFragmentSecurityConstraint() |
384 |
|
{ |
385 |
0 |
return delegator.newFragmentSecurityConstraint(); |
386 |
|
} |
387 |
|
|
388 |
|
|
389 |
|
|
390 |
|
|
391 |
|
public SecurityConstraint newLinkSecurityConstraint() |
392 |
|
{ |
393 |
0 |
return delegator.newLinkSecurityConstraint(); |
394 |
|
} |
395 |
|
|
396 |
|
|
397 |
|
|
398 |
|
|
399 |
|
public SecurityConstraint newPageSecuritySecurityConstraint() |
400 |
|
{ |
401 |
0 |
return delegator.newPageSecuritySecurityConstraint(); |
402 |
|
} |
403 |
|
|
404 |
|
|
405 |
|
|
406 |
|
|
407 |
|
public SecurityConstraintsDef newSecurityConstraintsDef() |
408 |
|
{ |
409 |
0 |
return delegator.newSecurityConstraintsDef(); |
410 |
|
} |
411 |
|
|
412 |
|
|
413 |
|
|
414 |
|
|
415 |
|
public FragmentPreference newFragmentPreference() |
416 |
|
{ |
417 |
0 |
return delegator.newFragmentPreference(); |
418 |
|
} |
419 |
|
|
420 |
|
|
421 |
|
|
422 |
|
|
423 |
|
public void addListener(PageManagerEventListener listener) |
424 |
|
{ |
425 |
0 |
delegator.addListener(listener); |
426 |
0 |
} |
427 |
|
|
428 |
|
|
429 |
|
|
430 |
|
|
431 |
|
public void removeListener(PageManagerEventListener listener) |
432 |
|
{ |
433 |
0 |
delegator.removeListener(listener); |
434 |
0 |
} |
435 |
|
|
436 |
|
|
437 |
|
|
438 |
|
|
439 |
|
public void reset() |
440 |
|
{ |
441 |
|
|
442 |
0 |
delegator.reset(); |
443 |
|
|
444 |
|
|
445 |
0 |
DatabasePageManagerCache.cacheClear(); |
446 |
0 |
} |
447 |
|
|
448 |
|
|
449 |
|
|
450 |
|
|
451 |
|
public Page getPage(String path) throws PageNotFoundException, NodeException |
452 |
|
{ |
453 |
|
|
454 |
0 |
path = NodeImpl.getCanonicalNodePath(path); |
455 |
|
|
456 |
|
|
457 |
0 |
NodeImpl cachedNode = DatabasePageManagerCache.cacheLookup(path); |
458 |
0 |
if (cachedNode instanceof Page) |
459 |
|
{ |
460 |
|
|
461 |
0 |
cachedNode.checkAccess(JetspeedActions.VIEW); |
462 |
|
|
463 |
0 |
return (Page)cachedNode; |
464 |
|
} |
465 |
|
|
466 |
|
|
467 |
|
try |
468 |
|
{ |
469 |
0 |
Criteria filter = new Criteria(); |
470 |
0 |
filter.addEqualTo("path", path); |
471 |
0 |
QueryByCriteria query = QueryFactory.newQuery(PageImpl.class, filter); |
472 |
0 |
Page page = (Page)getPersistenceBrokerTemplate().getObjectByQuery(query); |
473 |
|
|
474 |
|
|
475 |
0 |
if (page == null) |
476 |
|
{ |
477 |
0 |
throw new PageNotFoundException("Page " + path + " not found."); |
478 |
|
} |
479 |
|
|
480 |
|
|
481 |
0 |
page.checkAccess(JetspeedActions.VIEW); |
482 |
|
|
483 |
0 |
return page; |
484 |
|
} |
485 |
0 |
catch (PageNotFoundException pnfe) |
486 |
|
{ |
487 |
0 |
throw pnfe; |
488 |
|
} |
489 |
0 |
catch (SecurityException se) |
490 |
|
{ |
491 |
0 |
throw se; |
492 |
|
} |
493 |
0 |
catch (Exception e) |
494 |
|
{ |
495 |
0 |
throw new PageNotFoundException("Page " + path + " not found.", e); |
496 |
|
} |
497 |
|
} |
498 |
|
|
499 |
|
|
500 |
|
|
501 |
|
|
502 |
|
public ContentPage getContentPage(String path) throws PageNotFoundException, NodeException |
503 |
|
{ |
504 |
|
|
505 |
0 |
return new ContentPageImpl(getPage(path)); |
506 |
|
} |
507 |
|
|
508 |
|
|
509 |
|
|
510 |
|
|
511 |
|
public Link getLink(String path) throws DocumentNotFoundException, NodeException |
512 |
|
{ |
513 |
|
|
514 |
0 |
path = NodeImpl.getCanonicalNodePath(path); |
515 |
|
|
516 |
|
|
517 |
0 |
NodeImpl cachedNode = DatabasePageManagerCache.cacheLookup(path); |
518 |
0 |
if (cachedNode instanceof Link) |
519 |
|
{ |
520 |
|
|
521 |
0 |
cachedNode.checkAccess(JetspeedActions.VIEW); |
522 |
|
|
523 |
0 |
return (Link)cachedNode; |
524 |
|
} |
525 |
|
|
526 |
|
|
527 |
|
try |
528 |
|
{ |
529 |
0 |
Criteria filter = new Criteria(); |
530 |
0 |
filter.addEqualTo("path", path); |
531 |
0 |
QueryByCriteria query = QueryFactory.newQuery(LinkImpl.class, filter); |
532 |
0 |
Link link = (Link)getPersistenceBrokerTemplate().getObjectByQuery(query); |
533 |
|
|
534 |
|
|
535 |
0 |
if (link == null) |
536 |
|
{ |
537 |
0 |
throw new DocumentNotFoundException("Link " + path + " not found."); |
538 |
|
} |
539 |
|
|
540 |
|
|
541 |
0 |
link.checkAccess(JetspeedActions.VIEW); |
542 |
|
|
543 |
0 |
return link; |
544 |
|
} |
545 |
0 |
catch (DocumentNotFoundException dnfe) |
546 |
|
{ |
547 |
0 |
throw dnfe; |
548 |
|
} |
549 |
0 |
catch (SecurityException se) |
550 |
|
{ |
551 |
0 |
throw se; |
552 |
|
} |
553 |
0 |
catch (Exception e) |
554 |
|
{ |
555 |
0 |
throw new DocumentNotFoundException("Link " + path + " not found.", e); |
556 |
|
} |
557 |
|
} |
558 |
|
|
559 |
|
|
560 |
|
|
561 |
|
|
562 |
|
|
563 |
|
public boolean checkConstraint(String securityConstraintName, String actions) |
564 |
|
{ |
565 |
|
try |
566 |
|
{ |
567 |
0 |
PageSecurity security = this.getPageSecurity(); |
568 |
0 |
SecurityConstraintsDef def = security.getSecurityConstraintsDef(securityConstraintName); |
569 |
0 |
if (def != null) |
570 |
|
{ |
571 |
0 |
return PageManagerSecurityUtils.checkConstraint(def, actions); |
572 |
|
} |
573 |
|
} |
574 |
0 |
catch(Exception e) |
575 |
|
{ |
576 |
0 |
e.printStackTrace(); |
577 |
0 |
} |
578 |
0 |
return false; |
579 |
|
} |
580 |
|
|
581 |
|
|
582 |
|
|
583 |
|
|
584 |
|
public PageSecurity getPageSecurity() throws DocumentNotFoundException, NodeException |
585 |
|
{ |
586 |
|
|
587 |
0 |
String path = Folder.PATH_SEPARATOR + PageSecurity.DOCUMENT_TYPE; |
588 |
|
|
589 |
|
|
590 |
0 |
NodeImpl cachedNode = DatabasePageManagerCache.cacheLookup(path); |
591 |
0 |
if (cachedNode instanceof PageSecurity) |
592 |
|
{ |
593 |
|
|
594 |
0 |
cachedNode.checkAccess(JetspeedActions.VIEW); |
595 |
|
|
596 |
0 |
return (PageSecurity)cachedNode; |
597 |
|
} |
598 |
|
|
599 |
|
|
600 |
|
try |
601 |
|
{ |
602 |
0 |
Criteria filter = new Criteria(); |
603 |
0 |
filter.addEqualTo("path", path); |
604 |
0 |
QueryByCriteria query = QueryFactory.newQuery(PageSecurityImpl.class, filter); |
605 |
0 |
PageSecurity document = (PageSecurity)getPersistenceBrokerTemplate().getObjectByQuery(query); |
606 |
|
|
607 |
|
|
608 |
0 |
if (document == null) |
609 |
|
{ |
610 |
0 |
throw new DocumentNotFoundException("Document " + path + " not found."); |
611 |
|
} |
612 |
|
|
613 |
|
|
614 |
0 |
document.checkAccess(JetspeedActions.VIEW); |
615 |
|
|
616 |
0 |
return document; |
617 |
|
} |
618 |
0 |
catch (DocumentNotFoundException dnfe) |
619 |
|
{ |
620 |
0 |
throw dnfe; |
621 |
|
} |
622 |
0 |
catch (SecurityException se) |
623 |
|
{ |
624 |
0 |
throw se; |
625 |
|
} |
626 |
0 |
catch (Exception e) |
627 |
|
{ |
628 |
0 |
throw new DocumentNotFoundException("Document " + path + " not found.", e); |
629 |
|
} |
630 |
|
} |
631 |
|
|
632 |
|
|
633 |
|
|
634 |
|
|
635 |
|
public Folder getFolder(String folderPath) throws FolderNotFoundException, InvalidFolderException, NodeException |
636 |
|
{ |
637 |
|
|
638 |
0 |
folderPath = NodeImpl.getCanonicalNodePath(folderPath); |
639 |
|
|
640 |
|
|
641 |
0 |
NodeImpl cachedNode = DatabasePageManagerCache.cacheLookup(folderPath); |
642 |
0 |
if (cachedNode instanceof Folder) |
643 |
|
{ |
644 |
|
|
645 |
0 |
cachedNode.checkAccess(JetspeedActions.VIEW); |
646 |
|
|
647 |
0 |
return (Folder)cachedNode; |
648 |
|
} |
649 |
|
|
650 |
|
|
651 |
|
try |
652 |
|
{ |
653 |
0 |
Criteria filter = new Criteria(); |
654 |
0 |
filter.addEqualTo("path", folderPath); |
655 |
0 |
QueryByCriteria query = QueryFactory.newQuery(FolderImpl.class, filter); |
656 |
0 |
Folder folder = (Folder)getPersistenceBrokerTemplate().getObjectByQuery(query); |
657 |
|
|
658 |
|
|
659 |
0 |
if (folder == null) |
660 |
|
{ |
661 |
0 |
throw new FolderNotFoundException("Folder " + folderPath + " not found."); |
662 |
|
} |
663 |
|
|
664 |
|
|
665 |
0 |
folder.checkAccess(JetspeedActions.VIEW); |
666 |
|
|
667 |
0 |
return folder; |
668 |
|
} |
669 |
0 |
catch (FolderNotFoundException fnfe) |
670 |
|
{ |
671 |
0 |
throw fnfe; |
672 |
|
} |
673 |
0 |
catch (SecurityException se) |
674 |
|
{ |
675 |
0 |
throw se; |
676 |
|
} |
677 |
0 |
catch (Exception e) |
678 |
|
{ |
679 |
0 |
throw new FolderNotFoundException("Folder " + folderPath + " not found.", e); |
680 |
|
} |
681 |
|
} |
682 |
|
|
683 |
|
|
684 |
|
|
685 |
|
|
686 |
|
public NodeSet getFolders(Folder folder) throws DocumentException |
687 |
|
{ |
688 |
0 |
FolderImpl folderImpl = (FolderImpl)folder; |
689 |
|
|
690 |
|
|
691 |
|
try |
692 |
|
{ |
693 |
|
|
694 |
0 |
Criteria filter = new Criteria(); |
695 |
0 |
filter.addEqualTo("parent", folderImpl.getId()); |
696 |
0 |
QueryByCriteria query = QueryFactory.newQuery(FolderImpl.class, filter); |
697 |
0 |
Collection folders = getPersistenceBrokerTemplate().getCollectionByQuery(query); |
698 |
|
|
699 |
|
|
700 |
0 |
folderImpl.accessFolders().clear(); |
701 |
0 |
if (folders != null) |
702 |
|
{ |
703 |
0 |
folderImpl.accessFolders().addAll(folders); |
704 |
|
} |
705 |
0 |
folderImpl.resetFolders(true); |
706 |
|
} |
707 |
0 |
catch (Exception e) |
708 |
|
{ |
709 |
|
|
710 |
0 |
folderImpl.resetFolders(false); |
711 |
0 |
throw new DocumentException("Unable to access folders for folder " + folder.getPath() + "."); |
712 |
0 |
} |
713 |
|
|
714 |
|
|
715 |
|
|
716 |
0 |
return folder.getFolders(); |
717 |
|
} |
718 |
|
|
719 |
|
|
720 |
|
|
721 |
|
|
722 |
|
public Folder getFolder(Folder folder, String name) throws FolderNotFoundException, DocumentException |
723 |
|
{ |
724 |
|
|
725 |
0 |
String folderPath = folder.getPath() + Folder.PATH_SEPARATOR + name; |
726 |
|
try |
727 |
|
{ |
728 |
0 |
return getFolder(folderPath); |
729 |
|
} |
730 |
0 |
catch (FolderNotFoundException fnfe) |
731 |
|
{ |
732 |
0 |
throw fnfe; |
733 |
|
} |
734 |
0 |
catch (Exception e) |
735 |
|
{ |
736 |
0 |
throw new FolderNotFoundException("Folder " + folderPath + " not found.", e); |
737 |
|
} |
738 |
|
} |
739 |
|
|
740 |
|
|
741 |
|
|
742 |
|
|
743 |
|
public NodeSet getPages(Folder folder) throws NodeException |
744 |
|
{ |
745 |
0 |
FolderImpl folderImpl = (FolderImpl)folder; |
746 |
|
|
747 |
|
|
748 |
|
try |
749 |
|
{ |
750 |
|
|
751 |
0 |
Criteria filter = new Criteria(); |
752 |
0 |
filter.addEqualTo("parent", folderImpl.getId()); |
753 |
0 |
QueryByCriteria query = QueryFactory.newQuery(PageImpl.class, filter); |
754 |
0 |
Collection pages = getPersistenceBrokerTemplate().getCollectionByQuery(query); |
755 |
|
|
756 |
|
|
757 |
0 |
folderImpl.accessPages().clear(); |
758 |
0 |
if (pages != null) |
759 |
|
{ |
760 |
0 |
folderImpl.accessPages().addAll(pages); |
761 |
|
} |
762 |
0 |
folderImpl.resetPages(true); |
763 |
|
} |
764 |
0 |
catch (Exception e) |
765 |
|
{ |
766 |
|
|
767 |
0 |
folderImpl.resetPages(false); |
768 |
0 |
throw new NodeException("Unable to access pages for folder " + folder.getPath() + "."); |
769 |
0 |
} |
770 |
|
|
771 |
|
|
772 |
|
|
773 |
0 |
return folder.getPages(); |
774 |
|
} |
775 |
|
|
776 |
|
|
777 |
|
|
778 |
|
|
779 |
|
public Page getPage(Folder folder, String name) throws PageNotFoundException, NodeException |
780 |
|
{ |
781 |
|
|
782 |
0 |
String pagePath = folder.getPath() + Folder.PATH_SEPARATOR + name; |
783 |
|
try |
784 |
|
{ |
785 |
0 |
return getPage(pagePath); |
786 |
|
} |
787 |
0 |
catch (PageNotFoundException pnfe) |
788 |
|
{ |
789 |
0 |
throw pnfe; |
790 |
|
} |
791 |
0 |
catch (Exception e) |
792 |
|
{ |
793 |
0 |
throw new PageNotFoundException("Page " + pagePath + " not found.", e); |
794 |
|
} |
795 |
|
} |
796 |
|
|
797 |
|
|
798 |
|
|
799 |
|
|
800 |
|
public NodeSet getLinks(Folder folder) throws NodeException |
801 |
|
{ |
802 |
0 |
FolderImpl folderImpl = (FolderImpl)folder; |
803 |
|
|
804 |
|
|
805 |
|
try |
806 |
|
{ |
807 |
|
|
808 |
0 |
Criteria filter = new Criteria(); |
809 |
0 |
filter.addEqualTo("parent", folderImpl.getId()); |
810 |
0 |
QueryByCriteria query = QueryFactory.newQuery(LinkImpl.class, filter); |
811 |
0 |
Collection links = getPersistenceBrokerTemplate().getCollectionByQuery(query); |
812 |
|
|
813 |
|
|
814 |
0 |
folderImpl.accessLinks().clear(); |
815 |
0 |
if (links != null) |
816 |
|
{ |
817 |
0 |
folderImpl.accessLinks().addAll(links); |
818 |
|
} |
819 |
0 |
folderImpl.resetLinks(true); |
820 |
|
} |
821 |
0 |
catch (Exception e) |
822 |
|
{ |
823 |
|
|
824 |
0 |
folderImpl.resetLinks(false); |
825 |
0 |
throw new NodeException("Unable to access links for folder " + folder.getPath() + "."); |
826 |
0 |
} |
827 |
|
|
828 |
|
|
829 |
|
|
830 |
0 |
return folder.getLinks(); |
831 |
|
} |
832 |
|
|
833 |
|
|
834 |
|
|
835 |
|
|
836 |
|
public Link getLink(Folder folder, String name) throws DocumentNotFoundException, NodeException |
837 |
|
{ |
838 |
|
|
839 |
0 |
String linkPath = folder.getPath() + Folder.PATH_SEPARATOR + name; |
840 |
|
try |
841 |
|
{ |
842 |
0 |
return getLink(linkPath); |
843 |
|
} |
844 |
0 |
catch (DocumentNotFoundException dnfe) |
845 |
|
{ |
846 |
0 |
throw dnfe; |
847 |
|
} |
848 |
0 |
catch (Exception e) |
849 |
|
{ |
850 |
0 |
throw new DocumentNotFoundException("Link " + linkPath + " not found.", e); |
851 |
|
} |
852 |
|
} |
853 |
|
|
854 |
|
|
855 |
|
|
856 |
|
|
857 |
|
public PageSecurity getPageSecurity(Folder folder) throws DocumentNotFoundException, NodeException |
858 |
|
{ |
859 |
0 |
FolderImpl folderImpl = (FolderImpl)folder; |
860 |
|
|
861 |
|
|
862 |
|
|
863 |
|
|
864 |
|
|
865 |
0 |
if (folder.getPath().equals(Folder.PATH_SEPARATOR)) |
866 |
|
{ |
867 |
|
try |
868 |
|
{ |
869 |
|
|
870 |
0 |
Criteria filter = new Criteria(); |
871 |
0 |
filter.addEqualTo("parent", folderImpl.getId()); |
872 |
0 |
QueryByCriteria query = QueryFactory.newQuery(PageSecurityImpl.class, filter); |
873 |
0 |
PageSecurity document = (PageSecurity)getPersistenceBrokerTemplate().getObjectByQuery(query); |
874 |
|
|
875 |
|
|
876 |
0 |
folderImpl.resetPageSecurity((PageSecurityImpl)document, true); |
877 |
|
} |
878 |
0 |
catch (Exception e) |
879 |
|
{ |
880 |
|
|
881 |
0 |
folderImpl.resetPageSecurity(null, true); |
882 |
0 |
throw new NodeException("Unable to access page security for folder " + folder.getPath() + "."); |
883 |
0 |
} |
884 |
|
} |
885 |
|
else |
886 |
|
{ |
887 |
|
|
888 |
0 |
folderImpl.resetPageSecurity(null, true); |
889 |
|
} |
890 |
|
|
891 |
|
|
892 |
|
|
893 |
0 |
return folder.getPageSecurity(); |
894 |
|
} |
895 |
|
|
896 |
|
|
897 |
|
|
898 |
|
|
899 |
|
public NodeSet getAll(Folder folder) throws DocumentException |
900 |
|
{ |
901 |
0 |
FolderImpl folderImpl = (FolderImpl)folder; |
902 |
|
|
903 |
|
|
904 |
|
try |
905 |
|
{ |
906 |
|
|
907 |
0 |
List all = DatabasePageManagerUtils.createList(); |
908 |
0 |
Criteria filter = new Criteria(); |
909 |
0 |
filter.addEqualTo("parent", folderImpl.getId()); |
910 |
0 |
QueryByCriteria query = QueryFactory.newQuery(FolderImpl.class, filter); |
911 |
0 |
Collection folders = getPersistenceBrokerTemplate().getCollectionByQuery(query); |
912 |
0 |
if (folders != null) |
913 |
|
{ |
914 |
0 |
all.addAll(folders); |
915 |
|
} |
916 |
0 |
query = QueryFactory.newQuery(PageImpl.class, filter); |
917 |
0 |
Collection pages = getPersistenceBrokerTemplate().getCollectionByQuery(query); |
918 |
0 |
if (pages != null) |
919 |
|
{ |
920 |
0 |
all.addAll(pages); |
921 |
|
} |
922 |
0 |
query = QueryFactory.newQuery(LinkImpl.class, filter); |
923 |
0 |
Collection links = getPersistenceBrokerTemplate().getCollectionByQuery(query); |
924 |
0 |
if (links != null) |
925 |
|
{ |
926 |
0 |
all.addAll(links); |
927 |
|
} |
928 |
0 |
query = QueryFactory.newQuery(PageSecurityImpl.class, filter); |
929 |
0 |
PageSecurity document = (PageSecurity)getPersistenceBrokerTemplate().getObjectByQuery(query); |
930 |
0 |
if (document != null) |
931 |
|
{ |
932 |
0 |
all.add(document); |
933 |
|
} |
934 |
|
|
935 |
|
|
936 |
0 |
folderImpl.accessAll().clear(); |
937 |
0 |
folderImpl.accessAll().addAll(all); |
938 |
0 |
folderImpl.resetAll(true); |
939 |
|
} |
940 |
0 |
catch (Exception e) |
941 |
|
{ |
942 |
|
|
943 |
0 |
folderImpl.resetAll(false); |
944 |
0 |
throw new DocumentException("Unable to access all nodes for folder " + folder.getPath() + "."); |
945 |
0 |
} |
946 |
|
|
947 |
|
|
948 |
|
|
949 |
0 |
return folder.getAll(); |
950 |
|
} |
951 |
|
|
952 |
|
|
953 |
|
|
954 |
|
|
955 |
|
public void updatePage(Page page) throws NodeException, PageNotUpdatedException |
956 |
|
{ |
957 |
|
try |
958 |
|
{ |
959 |
|
|
960 |
0 |
if (page instanceof ContentPageImpl) |
961 |
|
{ |
962 |
0 |
page = ((ContentPageImpl)page).getPage(); |
963 |
|
} |
964 |
0 |
page = (Page)ProxyHelper.getRealObject(page); |
965 |
|
|
966 |
|
|
967 |
0 |
FolderImpl parent = (FolderImpl)page.getParent(); |
968 |
0 |
if (parent == null) |
969 |
|
{ |
970 |
|
|
971 |
0 |
String pagePath = page.getPath(); |
972 |
0 |
String parentPath = pagePath.substring(0, pagePath.lastIndexOf(Folder.PATH_SEPARATOR)); |
973 |
0 |
if (parentPath.length() == 0) |
974 |
|
{ |
975 |
0 |
parentPath = Folder.PATH_SEPARATOR; |
976 |
|
} |
977 |
|
try |
978 |
|
{ |
979 |
0 |
parent = (FolderImpl)getFolder(parentPath); |
980 |
|
} |
981 |
0 |
catch (FolderNotFoundException fnfe) |
982 |
|
{ |
983 |
0 |
throw new PageNotUpdatedException("Missing parent folder: " + parentPath); |
984 |
0 |
} |
985 |
|
|
986 |
|
|
987 |
|
|
988 |
0 |
parent.checkAccess(JetspeedActions.EDIT); |
989 |
|
|
990 |
|
|
991 |
0 |
page.setParent(parent); |
992 |
0 |
getPersistenceBrokerTemplate().store(page); |
993 |
0 |
DatabasePageManagerCache.addTransaction(new TransactionedOperation(page.getPath(), TransactionedOperation.ADD_OPERATION)); |
994 |
|
|
995 |
|
|
996 |
0 |
if (parent != null) |
997 |
|
{ |
998 |
0 |
parent.resetPages(false); |
999 |
|
} |
1000 |
|
|
1001 |
|
|
1002 |
0 |
delegator.notifyNewNode(page); |
1003 |
0 |
} |
1004 |
|
else |
1005 |
|
{ |
1006 |
|
|
1007 |
0 |
page.checkAccess(JetspeedActions.EDIT); |
1008 |
|
|
1009 |
|
|
1010 |
0 |
getPersistenceBrokerTemplate().store(page); |
1011 |
0 |
DatabasePageManagerCache.addTransaction(new TransactionedOperation(page.getPath(), TransactionedOperation.UPDATE_OPERATION)); |
1012 |
|
|
1013 |
|
|
1014 |
|
|
1015 |
|
|
1016 |
|
|
1017 |
0 |
if (parent != null) |
1018 |
|
{ |
1019 |
0 |
parent.resetPages(false); |
1020 |
|
} |
1021 |
|
|
1022 |
|
|
1023 |
0 |
delegator.notifyUpdatedNode(page); |
1024 |
|
} |
1025 |
|
} |
1026 |
0 |
catch (PageNotUpdatedException pnue) |
1027 |
|
{ |
1028 |
0 |
throw pnue; |
1029 |
|
} |
1030 |
0 |
catch (SecurityException se) |
1031 |
|
{ |
1032 |
0 |
throw se; |
1033 |
|
} |
1034 |
0 |
catch (Exception e) |
1035 |
|
{ |
1036 |
0 |
throw new PageNotUpdatedException("Page " + page.getPath() + " not updated.", e); |
1037 |
0 |
} |
1038 |
0 |
} |
1039 |
|
|
1040 |
|
|
1041 |
|
|
1042 |
|
|
1043 |
|
public void removePage(Page page) throws NodeException, PageNotRemovedException |
1044 |
|
{ |
1045 |
|
try |
1046 |
|
{ |
1047 |
|
|
1048 |
0 |
if (page instanceof ContentPageImpl) |
1049 |
|
{ |
1050 |
0 |
page = ((ContentPageImpl)page).getPage(); |
1051 |
|
} |
1052 |
0 |
page = (Page)ProxyHelper.getRealObject(page); |
1053 |
|
|
1054 |
|
|
1055 |
0 |
page.checkAccess(JetspeedActions.EDIT); |
1056 |
|
|
1057 |
|
|
1058 |
0 |
if (page.getParent() != null) |
1059 |
|
{ |
1060 |
0 |
FolderImpl parent = (FolderImpl)ProxyHelper.getRealObject(page.getParent()); |
1061 |
|
|
1062 |
|
|
1063 |
0 |
getPersistenceBrokerTemplate().delete(page); |
1064 |
|
|
1065 |
|
|
1066 |
0 |
if (parent != null) |
1067 |
|
{ |
1068 |
0 |
parent.resetPages(false); |
1069 |
|
} |
1070 |
0 |
} |
1071 |
|
else |
1072 |
|
{ |
1073 |
|
|
1074 |
0 |
getPersistenceBrokerTemplate().delete(page); |
1075 |
|
} |
1076 |
|
|
1077 |
|
|
1078 |
0 |
delegator.notifyRemovedNode(page); |
1079 |
|
} |
1080 |
0 |
catch (SecurityException se) |
1081 |
|
{ |
1082 |
0 |
throw se; |
1083 |
|
} |
1084 |
0 |
catch (Exception e) |
1085 |
|
{ |
1086 |
0 |
throw new PageNotRemovedException("Page " + page.getPath() + " not removed.", e); |
1087 |
0 |
} |
1088 |
0 |
} |
1089 |
|
|
1090 |
|
|
1091 |
|
|
1092 |
|
|
1093 |
|
public void updateFolder(Folder folder) throws NodeException, FolderNotUpdatedException |
1094 |
|
{ |
1095 |
|
|
1096 |
0 |
updateFolder(folder, false); |
1097 |
0 |
} |
1098 |
|
|
1099 |
|
|
1100 |
|
|
1101 |
|
|
1102 |
|
public void updateFolder(Folder folder, boolean deep) throws NodeException, FolderNotUpdatedException |
1103 |
|
{ |
1104 |
|
try |
1105 |
|
{ |
1106 |
|
|
1107 |
0 |
folder = (Folder)ProxyHelper.getRealObject(folder); |
1108 |
|
|
1109 |
|
|
1110 |
0 |
FolderImpl parent = (FolderImpl)folder.getParent(); |
1111 |
0 |
if ((parent == null) && !folder.getPath().equals(Folder.PATH_SEPARATOR)) |
1112 |
|
{ |
1113 |
|
|
1114 |
0 |
String folderPath = folder.getPath(); |
1115 |
0 |
String parentPath = folderPath.substring(0, folderPath.lastIndexOf(Folder.PATH_SEPARATOR)); |
1116 |
0 |
if (parentPath.length() == 0) |
1117 |
|
{ |
1118 |
0 |
parentPath = Folder.PATH_SEPARATOR; |
1119 |
|
} |
1120 |
|
try |
1121 |
|
{ |
1122 |
0 |
parent = (FolderImpl)getFolder(parentPath); |
1123 |
|
} |
1124 |
0 |
catch (FolderNotFoundException fnfe) |
1125 |
|
{ |
1126 |
0 |
throw new FolderNotUpdatedException("Missing parent folder: " + parentPath); |
1127 |
0 |
} |
1128 |
|
|
1129 |
|
|
1130 |
|
|
1131 |
0 |
parent.checkAccess(JetspeedActions.EDIT); |
1132 |
|
|
1133 |
|
|
1134 |
0 |
folder.setParent(parent); |
1135 |
0 |
getPersistenceBrokerTemplate().store(folder); |
1136 |
0 |
DatabasePageManagerCache.addTransaction(new TransactionedOperation(folder.getPath(), TransactionedOperation.ADD_OPERATION)); |
1137 |
|
|
1138 |
|
|
1139 |
0 |
if (parent != null) |
1140 |
|
{ |
1141 |
0 |
parent.resetFolders(false); |
1142 |
|
} |
1143 |
|
|
1144 |
|
|
1145 |
0 |
delegator.notifyNewNode(folder); |
1146 |
0 |
} |
1147 |
|
else |
1148 |
|
{ |
1149 |
|
|
1150 |
0 |
boolean newFolder = folder.getId().equals("0"); |
1151 |
|
|
1152 |
|
|
1153 |
|
|
1154 |
|
|
1155 |
0 |
if (!newFolder || !folder.getPath().equals(Folder.PATH_SEPARATOR)) |
1156 |
|
{ |
1157 |
0 |
folder.checkAccess(JetspeedActions.EDIT); |
1158 |
|
} |
1159 |
|
|
1160 |
|
|
1161 |
0 |
getPersistenceBrokerTemplate().store(folder); |
1162 |
0 |
if (newFolder && !folder.getId().equals("0")) |
1163 |
|
{ |
1164 |
0 |
DatabasePageManagerCache.addTransaction(new TransactionedOperation(folder.getPath(), TransactionedOperation.ADD_OPERATION)); |
1165 |
|
} |
1166 |
|
else |
1167 |
|
{ |
1168 |
0 |
DatabasePageManagerCache.addTransaction(new TransactionedOperation(folder.getPath(), TransactionedOperation.UPDATE_OPERATION)); |
1169 |
|
} |
1170 |
|
|
1171 |
|
|
1172 |
|
|
1173 |
|
|
1174 |
|
|
1175 |
0 |
if (parent != null) |
1176 |
|
{ |
1177 |
0 |
parent.resetFolders(false); |
1178 |
|
} |
1179 |
|
|
1180 |
|
|
1181 |
0 |
if (newFolder && !folder.getId().equals("0")) |
1182 |
|
{ |
1183 |
0 |
delegator.notifyNewNode(folder); |
1184 |
|
} |
1185 |
|
else |
1186 |
|
{ |
1187 |
0 |
delegator.notifyUpdatedNode(folder); |
1188 |
|
} |
1189 |
|
} |
1190 |
|
|
1191 |
|
|
1192 |
0 |
if (deep) |
1193 |
|
{ |
1194 |
|
|
1195 |
0 |
updateFolderNodes((FolderImpl)folder); |
1196 |
|
} |
1197 |
|
} |
1198 |
0 |
catch (FolderNotUpdatedException fnue) |
1199 |
|
{ |
1200 |
0 |
throw fnue; |
1201 |
|
} |
1202 |
0 |
catch (SecurityException se) |
1203 |
|
{ |
1204 |
0 |
throw se; |
1205 |
|
} |
1206 |
0 |
catch (Exception e) |
1207 |
|
{ |
1208 |
0 |
throw new FolderNotUpdatedException("Folder " + folder.getPath() + " not updated.", e); |
1209 |
0 |
} |
1210 |
0 |
} |
1211 |
|
|
1212 |
|
|
1213 |
|
|
1214 |
|
|
1215 |
|
|
1216 |
|
|
1217 |
|
|
1218 |
|
private void updateFolderNodes(FolderImpl folderImpl) throws FolderNotUpdatedException |
1219 |
|
{ |
1220 |
|
try |
1221 |
|
{ |
1222 |
|
|
1223 |
0 |
Criteria filter = new Criteria(); |
1224 |
0 |
filter.addEqualTo("parent", folderImpl.getId()); |
1225 |
|
|
1226 |
|
|
1227 |
0 |
QueryByCriteria query = QueryFactory.newQuery(PageImpl.class, filter); |
1228 |
0 |
Collection pages = getPersistenceBrokerTemplate().getCollectionByQuery(query); |
1229 |
0 |
if (pages != null) |
1230 |
|
{ |
1231 |
0 |
Iterator pagesIter = pages.iterator(); |
1232 |
0 |
while (pagesIter.hasNext()) |
1233 |
|
{ |
1234 |
0 |
updatePage((Page)pagesIter.next()); |
1235 |
|
} |
1236 |
|
} |
1237 |
|
|
1238 |
|
|
1239 |
0 |
query = QueryFactory.newQuery(LinkImpl.class, filter); |
1240 |
0 |
Collection links = getPersistenceBrokerTemplate().getCollectionByQuery(query); |
1241 |
0 |
if (links != null) |
1242 |
|
{ |
1243 |
0 |
Iterator linksIter = links.iterator(); |
1244 |
0 |
while (linksIter.hasNext()) |
1245 |
|
{ |
1246 |
0 |
updateLink((Link)linksIter.next()); |
1247 |
|
} |
1248 |
|
} |
1249 |
|
|
1250 |
|
|
1251 |
0 |
query = QueryFactory.newQuery(PageSecurityImpl.class, filter); |
1252 |
0 |
PageSecurity document = (PageSecurity)getPersistenceBrokerTemplate().getObjectByQuery(query); |
1253 |
0 |
if (document != null) |
1254 |
|
{ |
1255 |
0 |
updatePageSecurity(document); |
1256 |
|
} |
1257 |
|
|
1258 |
|
|
1259 |
0 |
query = QueryFactory.newQuery(FolderImpl.class, filter); |
1260 |
0 |
Collection folders = getPersistenceBrokerTemplate().getCollectionByQuery(query); |
1261 |
0 |
if (folders != null) |
1262 |
|
{ |
1263 |
0 |
Iterator foldersIter = folders.iterator(); |
1264 |
0 |
while (foldersIter.hasNext()) |
1265 |
|
{ |
1266 |
0 |
updateFolder((Folder)foldersIter.next(), true); |
1267 |
|
} |
1268 |
|
} |
1269 |
|
} |
1270 |
0 |
catch (FolderNotUpdatedException fnue) |
1271 |
|
{ |
1272 |
0 |
throw fnue; |
1273 |
|
} |
1274 |
0 |
catch (SecurityException se) |
1275 |
|
{ |
1276 |
0 |
throw se; |
1277 |
|
} |
1278 |
0 |
catch (Exception e) |
1279 |
|
{ |
1280 |
0 |
throw new FolderNotUpdatedException("Folder " + folderImpl.getPath() + " not updated.", e); |
1281 |
0 |
} |
1282 |
0 |
} |
1283 |
|
|
1284 |
|
|
1285 |
|
|
1286 |
|
|
1287 |
|
public void removeFolder(Folder folder) throws NodeException, FolderNotRemovedException |
1288 |
|
{ |
1289 |
|
try |
1290 |
|
{ |
1291 |
|
|
1292 |
0 |
folder = (Folder)ProxyHelper.getRealObject(folder); |
1293 |
|
|
1294 |
|
|
1295 |
0 |
folder.checkAccess(JetspeedActions.EDIT); |
1296 |
|
|
1297 |
|
|
1298 |
0 |
((FolderImpl)folder).resetAll(false); |
1299 |
|
|
1300 |
|
|
1301 |
0 |
removeFolderNodes((FolderImpl)folder); |
1302 |
|
|
1303 |
|
|
1304 |
0 |
if (folder.getParent() != null) |
1305 |
|
{ |
1306 |
0 |
FolderImpl parent = (FolderImpl)ProxyHelper.getRealObject(folder.getParent()); |
1307 |
|
|
1308 |
|
|
1309 |
0 |
getPersistenceBrokerTemplate().delete(folder); |
1310 |
|
|
1311 |
|
|
1312 |
0 |
if (parent != null) |
1313 |
|
{ |
1314 |
0 |
parent.resetFolders(false); |
1315 |
|
} |
1316 |
0 |
} |
1317 |
|
else |
1318 |
|
{ |
1319 |
|
|
1320 |
0 |
getPersistenceBrokerTemplate().delete(folder); |
1321 |
|
} |
1322 |
|
|
1323 |
|
|
1324 |
0 |
delegator.notifyRemovedNode((FolderImpl)folder); |
1325 |
|
} |
1326 |
0 |
catch (SecurityException se) |
1327 |
|
{ |
1328 |
0 |
throw se; |
1329 |
|
} |
1330 |
0 |
catch (Exception e) |
1331 |
|
{ |
1332 |
0 |
throw new FolderNotRemovedException("Folder " + folder.getPath() + " not removed.", e); |
1333 |
0 |
} |
1334 |
0 |
} |
1335 |
|
|
1336 |
|
|
1337 |
|
|
1338 |
|
|
1339 |
|
|
1340 |
|
|
1341 |
|
|
1342 |
|
private void removeFolderNodes(FolderImpl folderImpl) throws FolderNotRemovedException |
1343 |
|
{ |
1344 |
|
try |
1345 |
|
{ |
1346 |
|
|
1347 |
0 |
Criteria filter = new Criteria(); |
1348 |
0 |
filter.addEqualTo("parent", folderImpl.getId()); |
1349 |
|
|
1350 |
|
|
1351 |
0 |
QueryByCriteria query = QueryFactory.newQuery(FolderImpl.class, filter); |
1352 |
0 |
Collection folders = getPersistenceBrokerTemplate().getCollectionByQuery(query); |
1353 |
0 |
if (folders != null) |
1354 |
|
{ |
1355 |
0 |
Iterator foldersIter = folders.iterator(); |
1356 |
0 |
while (foldersIter.hasNext()) |
1357 |
|
{ |
1358 |
0 |
removeFolder((Folder)foldersIter.next()); |
1359 |
|
} |
1360 |
|
} |
1361 |
|
|
1362 |
|
|
1363 |
0 |
query = QueryFactory.newQuery(PageImpl.class, filter); |
1364 |
0 |
Collection pages = getPersistenceBrokerTemplate().getCollectionByQuery(query); |
1365 |
0 |
if (pages != null) |
1366 |
|
{ |
1367 |
0 |
Iterator pagesIter = pages.iterator(); |
1368 |
0 |
while (pagesIter.hasNext()) |
1369 |
|
{ |
1370 |
0 |
removePage((Page)pagesIter.next()); |
1371 |
|
} |
1372 |
|
} |
1373 |
|
|
1374 |
|
|
1375 |
0 |
query = QueryFactory.newQuery(LinkImpl.class, filter); |
1376 |
0 |
Collection links = getPersistenceBrokerTemplate().getCollectionByQuery(query); |
1377 |
0 |
if (links != null) |
1378 |
|
{ |
1379 |
0 |
Iterator linksIter = links.iterator(); |
1380 |
0 |
while (linksIter.hasNext()) |
1381 |
|
{ |
1382 |
0 |
removeLink((Link)linksIter.next()); |
1383 |
|
} |
1384 |
|
} |
1385 |
|
|
1386 |
|
|
1387 |
0 |
query = QueryFactory.newQuery(PageSecurityImpl.class, filter); |
1388 |
0 |
PageSecurity document = (PageSecurity)getPersistenceBrokerTemplate().getObjectByQuery(query); |
1389 |
0 |
if (document != null) |
1390 |
|
{ |
1391 |
0 |
removePageSecurity(document); |
1392 |
|
} |
1393 |
|
} |
1394 |
0 |
catch (FolderNotRemovedException fnre) |
1395 |
|
{ |
1396 |
0 |
throw fnre; |
1397 |
|
} |
1398 |
0 |
catch (SecurityException se) |
1399 |
|
{ |
1400 |
0 |
throw se; |
1401 |
|
} |
1402 |
0 |
catch (Exception e) |
1403 |
|
{ |
1404 |
0 |
throw new FolderNotRemovedException("Folder " + folderImpl.getPath() + " not removed.", e); |
1405 |
0 |
} |
1406 |
0 |
} |
1407 |
|
|
1408 |
|
|
1409 |
|
|
1410 |
|
|
1411 |
|
public void updateLink(Link link) throws NodeException, LinkNotUpdatedException |
1412 |
|
{ |
1413 |
|
try |
1414 |
|
{ |
1415 |
|
|
1416 |
0 |
link = (Link)ProxyHelper.getRealObject(link); |
1417 |
|
|
1418 |
|
|
1419 |
0 |
FolderImpl parent = (FolderImpl)link.getParent(); |
1420 |
0 |
if (parent == null) |
1421 |
|
{ |
1422 |
|
|
1423 |
0 |
String linkPath = link.getPath(); |
1424 |
0 |
String parentPath = linkPath.substring(0, linkPath.lastIndexOf(Folder.PATH_SEPARATOR)); |
1425 |
0 |
if (parentPath.length() == 0) |
1426 |
|
{ |
1427 |
0 |
parentPath = Folder.PATH_SEPARATOR; |
1428 |
|
} |
1429 |
|
try |
1430 |
|
{ |
1431 |
0 |
parent = (FolderImpl)getFolder(parentPath); |
1432 |
|
} |
1433 |
0 |
catch (FolderNotFoundException fnfe) |
1434 |
|
{ |
1435 |
0 |
throw new FailedToUpdateDocumentException("Missing parent folder: " + parentPath); |
1436 |
0 |
} |
1437 |
|
|
1438 |
|
|
1439 |
|
|
1440 |
0 |
parent.checkAccess(JetspeedActions.EDIT); |
1441 |
|
|
1442 |
|
|
1443 |
0 |
link.setParent(parent); |
1444 |
0 |
getPersistenceBrokerTemplate().store(link); |
1445 |
0 |
DatabasePageManagerCache.addTransaction(new TransactionedOperation(link.getPath(), TransactionedOperation.ADD_OPERATION)); |
1446 |
|
|
1447 |
|
|
1448 |
0 |
if (parent != null) |
1449 |
|
{ |
1450 |
0 |
parent.resetLinks(false); |
1451 |
|
} |
1452 |
|
|
1453 |
|
|
1454 |
0 |
delegator.notifyNewNode(link); |
1455 |
0 |
} |
1456 |
|
else |
1457 |
|
{ |
1458 |
|
|
1459 |
0 |
link.checkAccess(JetspeedActions.EDIT); |
1460 |
|
|
1461 |
|
|
1462 |
0 |
getPersistenceBrokerTemplate().store(link); |
1463 |
0 |
DatabasePageManagerCache.addTransaction(new TransactionedOperation(link.getPath(), TransactionedOperation.UPDATE_OPERATION)); |
1464 |
|
|
1465 |
|
|
1466 |
|
|
1467 |
|
|
1468 |
|
|
1469 |
0 |
if (parent != null) |
1470 |
|
{ |
1471 |
0 |
parent.resetLinks(false); |
1472 |
|
} |
1473 |
|
|
1474 |
|
|
1475 |
0 |
delegator.notifyUpdatedNode(link); |
1476 |
|
} |
1477 |
|
} |
1478 |
0 |
catch (FailedToUpdateDocumentException fude) |
1479 |
|
{ |
1480 |
0 |
throw fude; |
1481 |
|
} |
1482 |
0 |
catch (SecurityException se) |
1483 |
|
{ |
1484 |
0 |
throw se; |
1485 |
|
} |
1486 |
0 |
catch (Exception e) |
1487 |
|
{ |
1488 |
0 |
throw new FailedToUpdateDocumentException("Link " + link.getPath() + " not updated.", e); |
1489 |
0 |
} |
1490 |
0 |
} |
1491 |
|
|
1492 |
|
|
1493 |
|
|
1494 |
|
|
1495 |
|
public void removeLink(Link link) throws NodeException, LinkNotRemovedException |
1496 |
|
{ |
1497 |
|
try |
1498 |
|
{ |
1499 |
|
|
1500 |
0 |
link = (Link)ProxyHelper.getRealObject(link); |
1501 |
|
|
1502 |
|
|
1503 |
0 |
link.checkAccess(JetspeedActions.EDIT); |
1504 |
|
|
1505 |
|
|
1506 |
0 |
if (link.getParent() != null) |
1507 |
|
{ |
1508 |
0 |
FolderImpl parent = (FolderImpl)ProxyHelper.getRealObject(link.getParent()); |
1509 |
|
|
1510 |
|
|
1511 |
0 |
getPersistenceBrokerTemplate().delete(link); |
1512 |
|
|
1513 |
|
|
1514 |
0 |
if (parent != null) |
1515 |
|
{ |
1516 |
0 |
parent.resetLinks(false); |
1517 |
|
} |
1518 |
0 |
} |
1519 |
|
else |
1520 |
|
{ |
1521 |
|
|
1522 |
0 |
getPersistenceBrokerTemplate().delete(link); |
1523 |
|
} |
1524 |
|
|
1525 |
|
|
1526 |
0 |
delegator.notifyRemovedNode(link); |
1527 |
|
} |
1528 |
0 |
catch (SecurityException se) |
1529 |
|
{ |
1530 |
0 |
throw se; |
1531 |
|
} |
1532 |
0 |
catch (Exception e) |
1533 |
|
{ |
1534 |
0 |
throw new FailedToDeleteDocumentException("Link " + link.getPath() + " not removed.", e); |
1535 |
0 |
} |
1536 |
0 |
} |
1537 |
|
|
1538 |
|
|
1539 |
|
|
1540 |
|
|
1541 |
|
public void updatePageSecurity(PageSecurity pageSecurity) throws NodeException, FailedToUpdateDocumentException |
1542 |
|
{ |
1543 |
|
try |
1544 |
|
{ |
1545 |
|
|
1546 |
0 |
pageSecurity = (PageSecurity)ProxyHelper.getRealObject(pageSecurity); |
1547 |
|
|
1548 |
|
|
1549 |
0 |
FolderImpl parent = (FolderImpl)pageSecurity.getParent(); |
1550 |
0 |
if (parent == null) |
1551 |
|
{ |
1552 |
|
|
1553 |
0 |
String pageSecurityPath = pageSecurity.getPath(); |
1554 |
0 |
String parentPath = pageSecurityPath.substring(0, pageSecurityPath.lastIndexOf(Folder.PATH_SEPARATOR)); |
1555 |
0 |
if (parentPath.length() == 0) |
1556 |
|
{ |
1557 |
0 |
parentPath = Folder.PATH_SEPARATOR; |
1558 |
|
} |
1559 |
|
try |
1560 |
|
{ |
1561 |
0 |
parent = (FolderImpl)getFolder(parentPath); |
1562 |
|
} |
1563 |
0 |
catch (FolderNotFoundException fnfe) |
1564 |
|
{ |
1565 |
0 |
throw new FailedToUpdateDocumentException("Missing parent folder: " + parentPath); |
1566 |
0 |
} |
1567 |
|
|
1568 |
|
|
1569 |
|
try |
1570 |
|
{ |
1571 |
0 |
parent.getPageSecurity(); |
1572 |
0 |
throw new FailedToUpdateDocumentException("Parent folder page security exists: " + parentPath); |
1573 |
|
} |
1574 |
0 |
catch (DocumentNotFoundException dnfe) |
1575 |
|
{ |
1576 |
|
|
1577 |
|
|
1578 |
0 |
parent.checkAccess(JetspeedActions.EDIT); |
1579 |
|
|
1580 |
|
|
1581 |
0 |
pageSecurity.setParent(parent); |
1582 |
0 |
getPersistenceBrokerTemplate().store(pageSecurity); |
1583 |
0 |
DatabasePageManagerCache.addTransaction(new TransactionedOperation(pageSecurity.getPath(), TransactionedOperation.ADD_OPERATION)); |
1584 |
|
|
1585 |
|
|
1586 |
0 |
if (parent != null) |
1587 |
|
{ |
1588 |
0 |
parent.resetPageSecurity((PageSecurityImpl)pageSecurity, true); |
1589 |
|
} |
1590 |
|
} |
1591 |
0 |
catch (Exception e) |
1592 |
|
{ |
1593 |
0 |
throw new FailedToUpdateDocumentException("Parent folder page security exists: " + parentPath); |
1594 |
0 |
} |
1595 |
|
|
1596 |
|
|
1597 |
0 |
delegator.notifyNewNode(pageSecurity); |
1598 |
0 |
} |
1599 |
|
else |
1600 |
|
{ |
1601 |
|
|
1602 |
0 |
pageSecurity.checkAccess(JetspeedActions.EDIT); |
1603 |
|
|
1604 |
|
|
1605 |
0 |
getPersistenceBrokerTemplate().store(pageSecurity); |
1606 |
0 |
DatabasePageManagerCache.addTransaction(new TransactionedOperation(pageSecurity.getPath(), TransactionedOperation.UPDATE_OPERATION)); |
1607 |
|
|
1608 |
|
|
1609 |
|
|
1610 |
|
|
1611 |
|
|
1612 |
0 |
if (parent != null) |
1613 |
|
{ |
1614 |
0 |
parent.resetPageSecurity((PageSecurityImpl)pageSecurity, true); |
1615 |
|
} |
1616 |
|
|
1617 |
|
|
1618 |
0 |
delegator.notifyUpdatedNode(pageSecurity); |
1619 |
|
} |
1620 |
|
|
1621 |
|
|
1622 |
0 |
DatabasePageManagerCache.resetCachedSecurityConstraints(); |
1623 |
|
} |
1624 |
0 |
catch (FailedToUpdateDocumentException fude) |
1625 |
|
{ |
1626 |
0 |
throw fude; |
1627 |
|
} |
1628 |
0 |
catch (SecurityException se) |
1629 |
|
{ |
1630 |
0 |
throw se; |
1631 |
|
} |
1632 |
0 |
catch (Exception e) |
1633 |
|
{ |
1634 |
0 |
throw new FailedToUpdateDocumentException("Document " + pageSecurity.getPath() + " not updated.", e); |
1635 |
0 |
} |
1636 |
0 |
} |
1637 |
|
|
1638 |
|
|
1639 |
|
|
1640 |
|
|
1641 |
|
public void removePageSecurity(PageSecurity pageSecurity) throws NodeException, FailedToDeleteDocumentException |
1642 |
|
{ |
1643 |
|
try |
1644 |
|
{ |
1645 |
|
|
1646 |
0 |
pageSecurity = (PageSecurity)ProxyHelper.getRealObject(pageSecurity); |
1647 |
|
|
1648 |
|
|
1649 |
0 |
pageSecurity.checkAccess(JetspeedActions.EDIT); |
1650 |
|
|
1651 |
|
|
1652 |
0 |
if (pageSecurity.getParent() != null) |
1653 |
|
{ |
1654 |
0 |
FolderImpl parent = (FolderImpl)ProxyHelper.getRealObject(pageSecurity.getParent()); |
1655 |
|
|
1656 |
|
|
1657 |
0 |
getPersistenceBrokerTemplate().delete(pageSecurity); |
1658 |
|
|
1659 |
|
|
1660 |
0 |
if (parent != null) |
1661 |
|
{ |
1662 |
0 |
parent.resetPageSecurity(null, true); |
1663 |
|
} |
1664 |
0 |
} |
1665 |
|
else |
1666 |
|
{ |
1667 |
|
|
1668 |
0 |
getPersistenceBrokerTemplate().delete(pageSecurity); |
1669 |
|
} |
1670 |
|
|
1671 |
|
|
1672 |
0 |
DatabasePageManagerCache.resetCachedSecurityConstraints(); |
1673 |
|
|
1674 |
|
|
1675 |
0 |
delegator.notifyRemovedNode(pageSecurity); |
1676 |
|
} |
1677 |
0 |
catch (SecurityException se) |
1678 |
|
{ |
1679 |
0 |
throw se; |
1680 |
|
} |
1681 |
0 |
catch (Exception e) |
1682 |
|
{ |
1683 |
0 |
throw new FailedToDeleteDocumentException("Document " + pageSecurity.getPath() + " not removed.", e); |
1684 |
0 |
} |
1685 |
0 |
} |
1686 |
|
|
1687 |
|
|
1688 |
|
|
1689 |
|
|
1690 |
|
public Page copyPage(Page source, String path) |
1691 |
|
throws NodeException, PageNotUpdatedException |
1692 |
|
{ |
1693 |
0 |
return this.delegator.copyPage(source, path); |
1694 |
|
} |
1695 |
|
|
1696 |
|
|
1697 |
|
|
1698 |
|
|
1699 |
|
public Link copyLink(Link source, String path) |
1700 |
|
throws NodeException, LinkNotUpdatedException |
1701 |
|
{ |
1702 |
0 |
return this.delegator.copyLink(source, path); |
1703 |
|
} |
1704 |
|
|
1705 |
|
|
1706 |
|
|
1707 |
|
|
1708 |
|
public Folder copyFolder(Folder source, String path) |
1709 |
|
throws NodeException, PageNotUpdatedException |
1710 |
|
{ |
1711 |
0 |
return this.delegator.copyFolder(source, path); |
1712 |
|
} |
1713 |
|
|
1714 |
|
|
1715 |
|
|
1716 |
|
|
1717 |
|
public Fragment copyFragment(Fragment source, String name) |
1718 |
|
throws NodeException, PageNotUpdatedException |
1719 |
|
{ |
1720 |
0 |
return this.delegator.copyFragment(source, name); |
1721 |
|
} |
1722 |
|
|
1723 |
|
|
1724 |
|
|
1725 |
|
|
1726 |
|
public PageSecurity copyPageSecurity(PageSecurity source) |
1727 |
|
throws NodeException |
1728 |
|
{ |
1729 |
0 |
return this.delegator.copyPageSecurity(source); |
1730 |
|
} |
1731 |
|
|
1732 |
|
|
1733 |
|
|
1734 |
|
|
1735 |
|
public Page getUserPage(String userName, String pageName) |
1736 |
|
throws PageNotFoundException, NodeException |
1737 |
|
{ |
1738 |
0 |
return this.getPage(Folder.USER_FOLDER + userName + Folder.PATH_SEPARATOR + pageName); |
1739 |
|
} |
1740 |
|
|
1741 |
|
|
1742 |
|
|
1743 |
|
|
1744 |
|
public Folder getUserFolder(String userName) |
1745 |
|
throws FolderNotFoundException, InvalidFolderException, NodeException |
1746 |
|
{ |
1747 |
0 |
return this.getFolder(Folder.USER_FOLDER + userName); |
1748 |
|
} |
1749 |
|
|
1750 |
|
|
1751 |
|
|
1752 |
|
|
1753 |
|
public boolean folderExists(String folderName) |
1754 |
|
{ |
1755 |
|
try |
1756 |
|
{ |
1757 |
0 |
getFolder(folderName); |
1758 |
|
} |
1759 |
0 |
catch (Exception e) |
1760 |
|
{ |
1761 |
0 |
return false; |
1762 |
0 |
} |
1763 |
0 |
return true; |
1764 |
|
} |
1765 |
|
|
1766 |
|
|
1767 |
|
|
1768 |
|
|
1769 |
|
public boolean pageExists(String pageName) |
1770 |
|
{ |
1771 |
|
try |
1772 |
|
{ |
1773 |
0 |
getPage(pageName); |
1774 |
|
} |
1775 |
0 |
catch (Exception e) |
1776 |
|
{ |
1777 |
0 |
return false; |
1778 |
0 |
} |
1779 |
0 |
return true; |
1780 |
|
} |
1781 |
|
|
1782 |
|
|
1783 |
|
|
1784 |
|
|
1785 |
|
public boolean linkExists(String linkName) |
1786 |
|
{ |
1787 |
|
try |
1788 |
|
{ |
1789 |
0 |
getLink(linkName); |
1790 |
|
} |
1791 |
0 |
catch (Exception e) |
1792 |
|
{ |
1793 |
0 |
return false; |
1794 |
0 |
} |
1795 |
0 |
return true; |
1796 |
|
} |
1797 |
|
|
1798 |
|
|
1799 |
|
|
1800 |
|
|
1801 |
|
public boolean userFolderExists(String userName) |
1802 |
|
{ |
1803 |
|
try |
1804 |
|
{ |
1805 |
0 |
getFolder(Folder.USER_FOLDER + userName); |
1806 |
|
} |
1807 |
0 |
catch (Exception e) |
1808 |
|
{ |
1809 |
0 |
return false; |
1810 |
0 |
} |
1811 |
0 |
return true; |
1812 |
|
} |
1813 |
|
|
1814 |
|
|
1815 |
|
|
1816 |
|
|
1817 |
|
public boolean userPageExists(String userName, String pageName) |
1818 |
|
{ |
1819 |
|
try |
1820 |
|
{ |
1821 |
0 |
getPage(Folder.USER_FOLDER + userName + Folder.PATH_SEPARATOR + pageName); |
1822 |
|
} |
1823 |
0 |
catch (Exception e) |
1824 |
|
{ |
1825 |
0 |
return false; |
1826 |
0 |
} |
1827 |
0 |
return true; |
1828 |
|
} |
1829 |
|
|
1830 |
|
|
1831 |
|
|
1832 |
|
|
1833 |
|
public void createUserHomePagesFromRoles(Subject subject) |
1834 |
|
throws NodeException |
1835 |
|
{ |
1836 |
0 |
PageManagerUtils.createUserHomePagesFromRoles(this, subject); |
1837 |
0 |
} |
1838 |
|
|
1839 |
|
|
1840 |
|
|
1841 |
|
|
1842 |
|
public void deepCopyFolder(Folder srcFolder, String destinationPath, String owner) |
1843 |
|
throws NodeException, PageNotUpdatedException |
1844 |
|
{ |
1845 |
0 |
PageManagerUtils.deepCopyFolder(this, srcFolder, destinationPath, owner); |
1846 |
0 |
} |
1847 |
|
|
1848 |
|
|
1849 |
|
|
1850 |
|
|
1851 |
|
public int addPages(Page[] pages) |
1852 |
|
throws NodeException |
1853 |
|
{ |
1854 |
0 |
if (pages.length > 0 && pages[0].getPath().equals("/tx__test1.psml")) |
1855 |
|
{ |
1856 |
|
|
1857 |
0 |
System.out.println("Adding first page"); |
1858 |
0 |
this.updatePage(pages[0]); |
1859 |
0 |
System.out.println("Adding second page"); |
1860 |
0 |
this.updatePage(pages[1]); |
1861 |
0 |
System.out.println("About to throw ex"); |
1862 |
0 |
throw new NodeException("Its gonna blow captain!"); |
1863 |
|
} |
1864 |
0 |
for (int ix = 0; ix < pages.length; ix++) |
1865 |
|
{ |
1866 |
0 |
this.updatePage(pages[ix]); |
1867 |
|
} |
1868 |
0 |
return pages.length; |
1869 |
|
} |
1870 |
|
|
1871 |
|
} |