Source Code Cross Referenced for AbstractPageManager.java in  » Portal » jetspeed-2.1.3 » org » apache » jetspeed » page » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Portal » jetspeed 2.1.3 » org.apache.jetspeed.page 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


0001:        /*
0002:         * Licensed to the Apache Software Foundation (ASF) under one or more
0003:         * contributor license agreements.  See the NOTICE file distributed with
0004:         * this work for additional information regarding copyright ownership.
0005:         * The ASF licenses this file to You under the Apache License, Version 2.0
0006:         * (the "License"); you may not use this file except in compliance with
0007:         * the License.  You may obtain a copy of the License at
0008:         * 
0009:         *      http://www.apache.org/licenses/LICENSE-2.0
0010:         * 
0011:         * Unless required by applicable law or agreed to in writing, software
0012:         * distributed under the License is distributed on an "AS IS" BASIS,
0013:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
0014:         * See the License for the specific language governing permissions and
0015:         * limitations under the License.
0016:         */
0017:        package org.apache.jetspeed.page;
0018:
0019:        import java.util.ArrayList;
0020:        import java.util.Iterator;
0021:        import java.util.LinkedList;
0022:        import java.util.List;
0023:        import java.util.Map;
0024:
0025:        import javax.security.auth.Subject;
0026:
0027:        import org.apache.commons.logging.Log;
0028:        import org.apache.commons.logging.LogFactory;
0029:        import org.apache.jetspeed.om.common.SecurityConstraint;
0030:        import org.apache.jetspeed.om.common.SecurityConstraints;
0031:        import org.apache.jetspeed.om.folder.Folder;
0032:        import org.apache.jetspeed.om.folder.FolderNotFoundException;
0033:        import org.apache.jetspeed.om.folder.InvalidFolderException;
0034:        import org.apache.jetspeed.om.folder.MenuDefinition;
0035:        import org.apache.jetspeed.om.folder.MenuExcludeDefinition;
0036:        import org.apache.jetspeed.om.folder.MenuIncludeDefinition;
0037:        import org.apache.jetspeed.om.folder.MenuOptionsDefinition;
0038:        import org.apache.jetspeed.om.folder.MenuSeparatorDefinition;
0039:        import org.apache.jetspeed.om.page.Fragment;
0040:        import org.apache.jetspeed.om.page.Link;
0041:        import org.apache.jetspeed.om.page.Page;
0042:        import org.apache.jetspeed.om.page.PageSecurity;
0043:        import org.apache.jetspeed.om.page.SecurityConstraintsDef;
0044:        import org.apache.jetspeed.om.preference.FragmentPreference;
0045:        import org.apache.jetspeed.page.document.Node;
0046:        import org.apache.jetspeed.page.document.NodeException;
0047:        import org.apache.jetspeed.page.impl.DatabasePageManagerUtils;
0048:
0049:        /**
0050:         * AbstractPageManagerService
0051:         *
0052:         * @author <a href="mailto:taylor@apache.org">David Sean Taylor</a>
0053:         * @version $Id: AbstractPageManager.java 517124 2007-03-12 08:10:25Z ate $
0054:         */
0055:        public abstract class AbstractPageManager implements  PageManager {
0056:            private final static Log log = LogFactory
0057:                    .getLog(AbstractPageManager.class);
0058:
0059:            private final static String FOLDER_NODE_TYPE = "folder";
0060:            private final static String PAGE_NODE_TYPE = "page";
0061:            private final static String FRAGMENT_NODE_TYPE = "fragment";
0062:            private final static String LINK_NODE_TYPE = "link";
0063:            protected Class fragmentClass;
0064:            protected Class pageClass;
0065:            protected Class folderClass;
0066:            protected Class linkClass;
0067:            protected Class pageSecurityClass;
0068:            protected Class propertyClass;
0069:            protected Class folderMenuDefinitionClass;
0070:            protected Class folderMenuExcludeDefinitionClass;
0071:            protected Class folderMenuIncludeDefinitionClass;
0072:            protected Class folderMenuOptionsDefinitionClass;
0073:            protected Class folderMenuSeparatorDefinitionClass;
0074:            protected Class pageMenuDefinitionClass;
0075:            protected Class pageMenuExcludeDefinitionClass;
0076:            protected Class pageMenuIncludeDefinitionClass;
0077:            protected Class pageMenuOptionsDefinitionClass;
0078:            protected Class pageMenuSeparatorDefinitionClass;
0079:            protected Class securityConstraintsClass;
0080:            protected Class folderSecurityConstraintClass;
0081:            protected Class pageSecurityConstraintClass;
0082:            protected Class fragmentSecurityConstraintClass;
0083:            protected Class linkSecurityConstraintClass;
0084:            protected Class pageSecuritySecurityConstraintClass;
0085:            protected Class securityConstraintsDefClass;
0086:            protected Class fragmentPreferenceClass;
0087:
0088:            private boolean permissionsEnabled;
0089:
0090:            private boolean constraintsEnabled;
0091:
0092:            private List listeners = new LinkedList();
0093:
0094:            public AbstractPageManager(boolean permissionsEnabled,
0095:                    boolean constraintsEnabled) {
0096:                this .permissionsEnabled = permissionsEnabled;
0097:                this .constraintsEnabled = constraintsEnabled;
0098:            }
0099:
0100:            public AbstractPageManager(boolean permissionsEnabled,
0101:                    boolean constraintsEnabled, Map modelClasses) {
0102:                this (permissionsEnabled, constraintsEnabled);
0103:
0104:                this .fragmentClass = (Class) modelClasses.get("FragmentImpl");
0105:                this .pageClass = (Class) modelClasses.get("PageImpl");
0106:                this .folderClass = (Class) modelClasses.get("FolderImpl");
0107:                this .linkClass = (Class) modelClasses.get("LinkImpl");
0108:                this .pageSecurityClass = (Class) modelClasses
0109:                        .get("PageSecurityImpl");
0110:                this .folderMenuDefinitionClass = (Class) modelClasses
0111:                        .get("FolderMenuDefinitionImpl");
0112:                this .folderMenuExcludeDefinitionClass = (Class) modelClasses
0113:                        .get("FolderMenuExcludeDefinitionImpl");
0114:                this .folderMenuIncludeDefinitionClass = (Class) modelClasses
0115:                        .get("FolderMenuIncludeDefinitionImpl");
0116:                this .folderMenuOptionsDefinitionClass = (Class) modelClasses
0117:                        .get("FolderMenuOptionsDefinitionImpl");
0118:                this .folderMenuSeparatorDefinitionClass = (Class) modelClasses
0119:                        .get("FolderMenuSeparatorDefinitionImpl");
0120:                this .pageMenuDefinitionClass = (Class) modelClasses
0121:                        .get("PageMenuDefinitionImpl");
0122:                this .pageMenuExcludeDefinitionClass = (Class) modelClasses
0123:                        .get("PageMenuExcludeDefinitionImpl");
0124:                this .pageMenuIncludeDefinitionClass = (Class) modelClasses
0125:                        .get("PageMenuIncludeDefinitionImpl");
0126:                this .pageMenuOptionsDefinitionClass = (Class) modelClasses
0127:                        .get("PageMenuOptionsDefinitionImpl");
0128:                this .pageMenuSeparatorDefinitionClass = (Class) modelClasses
0129:                        .get("PageMenuSeparatorDefinitionImpl");
0130:                this .securityConstraintsClass = (Class) modelClasses
0131:                        .get("SecurityConstraintsImpl");
0132:                this .folderSecurityConstraintClass = (Class) modelClasses
0133:                        .get("FolderSecurityConstraintImpl");
0134:                this .pageSecurityConstraintClass = (Class) modelClasses
0135:                        .get("PageSecurityConstraintImpl");
0136:                this .fragmentSecurityConstraintClass = (Class) modelClasses
0137:                        .get("FragmentSecurityConstraintImpl");
0138:                this .linkSecurityConstraintClass = (Class) modelClasses
0139:                        .get("LinkSecurityConstraintImpl");
0140:                this .pageSecuritySecurityConstraintClass = (Class) modelClasses
0141:                        .get("PageSecuritySecurityConstraintImpl");
0142:                this .securityConstraintsDefClass = (Class) modelClasses
0143:                        .get("SecurityConstraintsDefImpl");
0144:                this .fragmentPreferenceClass = (Class) modelClasses
0145:                        .get("FragmentPreferenceImpl");
0146:            }
0147:
0148:            /**
0149:             * <p>
0150:             * getPermissionsEnabled
0151:             * </p>
0152:             *
0153:             * @see org.apache.jetspeed.page.PageManager#getPermissionsEnabled()
0154:             * @return
0155:             */
0156:            public boolean getPermissionsEnabled() {
0157:                return permissionsEnabled;
0158:            }
0159:
0160:            /**
0161:             * <p>
0162:             * getConstraintsEnabled
0163:             * </p>
0164:             *
0165:             * @see org.apache.jetspeed.page.PageManager#getConstraintsEnabled()
0166:             * @return
0167:             */
0168:            public boolean getConstraintsEnabled() {
0169:                return constraintsEnabled;
0170:            }
0171:
0172:            /* (non-Javadoc)
0173:             * @see org.apache.jetspeed.page.PageManager#newPage(java.lang.String)
0174:             */
0175:            public Page newPage(String path) {
0176:                Page page = null;
0177:                try {
0178:                    // factory create the page and set id/path
0179:                    page = (Page) createObject(this .pageClass);
0180:                    if (!path.startsWith(Folder.PATH_SEPARATOR)) {
0181:                        path = Folder.PATH_SEPARATOR + path;
0182:                    }
0183:                    if (!path.endsWith(Page.DOCUMENT_TYPE)) {
0184:                        path += Page.DOCUMENT_TYPE;
0185:                    }
0186:                    page.setPath(path);
0187:
0188:                    // create the default fragment
0189:                    page.setRootFragment(newFragment());
0190:                } catch (ClassCastException e) {
0191:                    String message = "Failed to create page object for "
0192:                            + this .pageClass;
0193:                    log.error(message, e);
0194:                }
0195:                return page;
0196:            }
0197:
0198:            /* (non-Javadoc)
0199:             * @see org.apache.jetspeed.page.PageManager#newFolder(java.lang.String)
0200:             */
0201:            public Folder newFolder(String path) {
0202:                Folder folder = null;
0203:                try {
0204:                    // factory create the folder and set id/path
0205:                    folder = (Folder) createObject(this .folderClass);
0206:                    if (!path.startsWith(Folder.PATH_SEPARATOR)) {
0207:                        path = Folder.PATH_SEPARATOR + path;
0208:                    }
0209:                    folder.setPath(path);
0210:                } catch (ClassCastException e) {
0211:                    String message = "Failed to create link object for "
0212:                            + this .linkClass;
0213:                    log.error(message, e);
0214:                }
0215:                return folder;
0216:            }
0217:
0218:            /* (non-Javadoc)
0219:             * @see org.apache.jetspeed.page.PageManager#newLink(java.lang.String)
0220:             */
0221:            public Link newLink(String path) {
0222:                Link link = null;
0223:                try {
0224:                    // factory create the page and set id/path
0225:                    link = (Link) createObject(this .linkClass);
0226:                    if (!path.startsWith(Folder.PATH_SEPARATOR)) {
0227:                        path = Folder.PATH_SEPARATOR + path;
0228:                    }
0229:                    if (!path.endsWith(Link.DOCUMENT_TYPE)) {
0230:                        path += Link.DOCUMENT_TYPE;
0231:                    }
0232:                    link.setPath(path);
0233:                } catch (ClassCastException e) {
0234:                    String message = "Failed to create link object for "
0235:                            + this .linkClass;
0236:                    log.error(message, e);
0237:                }
0238:                return link;
0239:            }
0240:
0241:            /* (non-Javadoc)
0242:             * @see org.apache.jetspeed.page.PageManager#newPageSecurity()
0243:             */
0244:            public PageSecurity newPageSecurity() {
0245:                PageSecurity pageSecurity = null;
0246:                try {
0247:                    // factory create the document and set id/path
0248:                    pageSecurity = (PageSecurity) createObject(this .pageSecurityClass);
0249:                    pageSecurity.setPath(Folder.PATH_SEPARATOR
0250:                            + PageSecurity.DOCUMENT_TYPE);
0251:                } catch (ClassCastException e) {
0252:                    String message = "Failed to create page security object for "
0253:                            + this .pageClass;
0254:                    log.error(message, e);
0255:                }
0256:                return pageSecurity;
0257:            }
0258:
0259:            /* (non-Javadoc)
0260:             * @see org.apache.jetspeed.page.PageManager#newFragment()
0261:             */
0262:            public Fragment newFragment() {
0263:                Fragment fragment = null;
0264:                try {
0265:                    fragment = (Fragment) createObject(this .fragmentClass);
0266:                    fragment.setType(Fragment.LAYOUT);
0267:                } catch (ClassCastException e) {
0268:                    String message = "Failed to create page object for "
0269:                            + this .pageClass;
0270:                    log.error(message, e);
0271:                    // throw new NodeException(message, e);
0272:                }
0273:                return fragment;
0274:            }
0275:
0276:            /* (non-Javadoc)
0277:             * @see org.apache.jetspeed.page.PageManager#newPortletFragment()
0278:             */
0279:            public Fragment newPortletFragment() {
0280:                Fragment fragment = null;
0281:                try {
0282:                    fragment = (Fragment) createObject(this .fragmentClass);
0283:                    fragment.setType(Fragment.PORTLET);
0284:                } catch (ClassCastException e) {
0285:                    String message = "Failed to create page object for "
0286:                            + this .pageClass;
0287:                    log.error(message, e);
0288:                    // throw new NodeException(message, e);
0289:                }
0290:                return fragment;
0291:            }
0292:
0293:            /**
0294:             * newFolderMenuDefinition - creates a new empty menu definition
0295:             *
0296:             * @return a newly created MenuDefinition object
0297:             */
0298:            public MenuDefinition newFolderMenuDefinition() {
0299:                try {
0300:                    return (MenuDefinition) createObject(this .folderMenuDefinitionClass);
0301:                } catch (ClassCastException e) {
0302:                    String message = "Failed to create menu definition object for "
0303:                            + this .folderMenuDefinitionClass;
0304:                    log.error(message, e);
0305:                }
0306:                return null;
0307:            }
0308:
0309:            /**
0310:             * newFolderMenuExcludeDefinition - creates a new empty menu exclude definition
0311:             *
0312:             * @return a newly created MenuExcludeDefinition object
0313:             */
0314:            public MenuExcludeDefinition newFolderMenuExcludeDefinition() {
0315:                try {
0316:                    return (MenuExcludeDefinition) createObject(this .folderMenuExcludeDefinitionClass);
0317:                } catch (ClassCastException e) {
0318:                    String message = "Failed to create menu exclude definition object for "
0319:                            + this .folderMenuExcludeDefinitionClass;
0320:                    log.error(message, e);
0321:                }
0322:                return null;
0323:            }
0324:
0325:            /**
0326:             * newFolderMenuIncludeDefinition - creates a new empty menu include definition
0327:             *
0328:             * @return a newly created MenuIncludeDefinition object
0329:             */
0330:            public MenuIncludeDefinition newFolderMenuIncludeDefinition() {
0331:                try {
0332:                    return (MenuIncludeDefinition) createObject(this .folderMenuIncludeDefinitionClass);
0333:                } catch (ClassCastException e) {
0334:                    String message = "Failed to create menu include definition object for "
0335:                            + this .folderMenuIncludeDefinitionClass;
0336:                    log.error(message, e);
0337:                }
0338:                return null;
0339:            }
0340:
0341:            /**
0342:             * newFolderMenuOptionsDefinition - creates a new empty menu options definition
0343:             *
0344:             * @return a newly created MenuOptionsDefinition object
0345:             */
0346:            public MenuOptionsDefinition newFolderMenuOptionsDefinition() {
0347:                try {
0348:                    return (MenuOptionsDefinition) createObject(this .folderMenuOptionsDefinitionClass);
0349:                } catch (ClassCastException e) {
0350:                    String message = "Failed to create menu options definition object for "
0351:                            + this .folderMenuOptionsDefinitionClass;
0352:                    log.error(message, e);
0353:                }
0354:                return null;
0355:            }
0356:
0357:            /**
0358:             * newFolderMenuSeparatorDefinition - creates a new empty menu separator definition
0359:             *
0360:             * @return a newly created MenuSeparatorDefinition object
0361:             */
0362:            public MenuSeparatorDefinition newFolderMenuSeparatorDefinition() {
0363:                try {
0364:                    return (MenuSeparatorDefinition) createObject(this .folderMenuSeparatorDefinitionClass);
0365:                } catch (ClassCastException e) {
0366:                    String message = "Failed to create menu separator definition object for "
0367:                            + this .folderMenuSeparatorDefinitionClass;
0368:                    log.error(message, e);
0369:                }
0370:                return null;
0371:            }
0372:
0373:            /**
0374:             * newPageMenuDefinition - creates a new empty menu definition
0375:             *
0376:             * @return a newly created MenuDefinition object
0377:             */
0378:            public MenuDefinition newPageMenuDefinition() {
0379:                try {
0380:                    return (MenuDefinition) createObject(this .pageMenuDefinitionClass);
0381:                } catch (ClassCastException e) {
0382:                    String message = "Failed to create menu definition object for "
0383:                            + this .pageMenuDefinitionClass;
0384:                    log.error(message, e);
0385:                }
0386:                return null;
0387:            }
0388:
0389:            /**
0390:             * newPageMenuExcludeDefinition - creates a new empty menu exclude definition
0391:             *
0392:             * @return a newly created MenuExcludeDefinition object
0393:             */
0394:            public MenuExcludeDefinition newPageMenuExcludeDefinition() {
0395:                try {
0396:                    return (MenuExcludeDefinition) createObject(this .pageMenuExcludeDefinitionClass);
0397:                } catch (ClassCastException e) {
0398:                    String message = "Failed to create menu exclude definition object for "
0399:                            + this .pageMenuExcludeDefinitionClass;
0400:                    log.error(message, e);
0401:                }
0402:                return null;
0403:            }
0404:
0405:            /**
0406:             * newPageMenuIncludeDefinition - creates a new empty menu include definition
0407:             *
0408:             * @return a newly created MenuIncludeDefinition object
0409:             */
0410:            public MenuIncludeDefinition newPageMenuIncludeDefinition() {
0411:                try {
0412:                    return (MenuIncludeDefinition) createObject(this .pageMenuIncludeDefinitionClass);
0413:                } catch (ClassCastException e) {
0414:                    String message = "Failed to create menu include definition object for "
0415:                            + this .pageMenuIncludeDefinitionClass;
0416:                    log.error(message, e);
0417:                }
0418:                return null;
0419:            }
0420:
0421:            /**
0422:             * newPageMenuOptionsDefinition - creates a new empty menu options definition
0423:             *
0424:             * @return a newly created MenuOptionsDefinition object
0425:             */
0426:            public MenuOptionsDefinition newPageMenuOptionsDefinition() {
0427:                try {
0428:                    return (MenuOptionsDefinition) createObject(this .pageMenuOptionsDefinitionClass);
0429:                } catch (ClassCastException e) {
0430:                    String message = "Failed to create menu options definition object for "
0431:                            + this .pageMenuOptionsDefinitionClass;
0432:                    log.error(message, e);
0433:                }
0434:                return null;
0435:            }
0436:
0437:            /**
0438:             * newPageMenuSeparatorDefinition - creates a new empty menu separator definition
0439:             *
0440:             * @return a newly created MenuSeparatorDefinition object
0441:             */
0442:            public MenuSeparatorDefinition newPageMenuSeparatorDefinition() {
0443:                try {
0444:                    return (MenuSeparatorDefinition) createObject(this .pageMenuSeparatorDefinitionClass);
0445:                } catch (ClassCastException e) {
0446:                    String message = "Failed to create menu separator definition object for "
0447:                            + this .pageMenuSeparatorDefinitionClass;
0448:                    log.error(message, e);
0449:                }
0450:                return null;
0451:            }
0452:
0453:            /**
0454:             * newSecurityConstraints - creates a new empty security constraints definition
0455:             *
0456:             * @return a newly created SecurityConstraints object
0457:             */
0458:            public SecurityConstraints newSecurityConstraints() {
0459:                try {
0460:                    return (SecurityConstraints) createObject(this .securityConstraintsClass);
0461:                } catch (ClassCastException e) {
0462:                    String message = "Failed to create security constraints definition object for "
0463:                            + this .securityConstraintsClass;
0464:                    log.error(message, e);
0465:                }
0466:                return null;
0467:            }
0468:
0469:            /**
0470:             * newFolderSecurityConstraint - creates a new security constraint definition
0471:             *
0472:             * @return a newly created SecurityConstraint object
0473:             */
0474:            public SecurityConstraint newFolderSecurityConstraint() {
0475:                try {
0476:                    return (SecurityConstraint) createObject(this .folderSecurityConstraintClass);
0477:                } catch (ClassCastException e) {
0478:                    String message = "Failed to create security constraint definition object for "
0479:                            + this .folderSecurityConstraintClass;
0480:                    log.error(message, e);
0481:                }
0482:                return null;
0483:            }
0484:
0485:            /**
0486:             * newPageSecurityConstraint - creates a new security constraint definition
0487:             *
0488:             * @return a newly created SecurityConstraint object
0489:             */
0490:            public SecurityConstraint newPageSecurityConstraint() {
0491:                try {
0492:                    return (SecurityConstraint) createObject(this .pageSecurityConstraintClass);
0493:                } catch (ClassCastException e) {
0494:                    String message = "Failed to create security constraint definition object for "
0495:                            + this .pageSecurityConstraintClass;
0496:                    log.error(message, e);
0497:                }
0498:                return null;
0499:            }
0500:
0501:            /**
0502:             * newFragmentSecurityConstraint - creates a new security constraint definition
0503:             *
0504:             * @return a newly created SecurityConstraint object
0505:             */
0506:            public SecurityConstraint newFragmentSecurityConstraint() {
0507:                try {
0508:                    return (SecurityConstraint) createObject(this .fragmentSecurityConstraintClass);
0509:                } catch (ClassCastException e) {
0510:                    String message = "Failed to create security constraint definition object for "
0511:                            + this .fragmentSecurityConstraintClass;
0512:                    log.error(message, e);
0513:                }
0514:                return null;
0515:            }
0516:
0517:            /**
0518:             * newLinkSecurityConstraint - creates a new security constraint definition
0519:             *
0520:             * @return a newly created SecurityConstraint object
0521:             */
0522:            public SecurityConstraint newLinkSecurityConstraint() {
0523:                try {
0524:                    return (SecurityConstraint) createObject(this .linkSecurityConstraintClass);
0525:                } catch (ClassCastException e) {
0526:                    String message = "Failed to create security constraint definition object for "
0527:                            + this .linkSecurityConstraintClass;
0528:                    log.error(message, e);
0529:                }
0530:                return null;
0531:            }
0532:
0533:            /**
0534:             * newPageSecuritySecurityConstraint - creates a new security constraint definition
0535:             *
0536:             * @return a newly created SecurityConstraint object
0537:             */
0538:            public SecurityConstraint newPageSecuritySecurityConstraint() {
0539:                try {
0540:                    return (SecurityConstraint) createObject(this .pageSecuritySecurityConstraintClass);
0541:                } catch (ClassCastException e) {
0542:                    String message = "Failed to create security constraint definition object for "
0543:                            + this .pageSecuritySecurityConstraintClass;
0544:                    log.error(message, e);
0545:                }
0546:                return null;
0547:            }
0548:
0549:            /**
0550:             * newSecurityConstraintsDef - creates a new security constraints definition
0551:             *
0552:             * @return a newly created SecurityConstraintsDef object
0553:             */
0554:            public SecurityConstraintsDef newSecurityConstraintsDef() {
0555:                try {
0556:                    return (SecurityConstraintsDef) createObject(this .securityConstraintsDefClass);
0557:                } catch (ClassCastException e) {
0558:                    String message = "Failed to create security constraints definition object for "
0559:                            + this .securityConstraintsDefClass;
0560:                    log.error(message, e);
0561:                }
0562:                return null;
0563:            }
0564:
0565:            /**
0566:             * newFragmentPreference - creates a new security constraints definition
0567:             *
0568:             * @return a newly created FragmentPreference object
0569:             */
0570:            public FragmentPreference newFragmentPreference() {
0571:                try {
0572:                    return (FragmentPreference) createObject(this .fragmentPreferenceClass);
0573:                } catch (ClassCastException e) {
0574:                    String message = "Failed to create security constraints definition object for "
0575:                            + this .fragmentPreferenceClass;
0576:                    log.error(message, e);
0577:                }
0578:                return null;
0579:            }
0580:
0581:            /**
0582:             * createObject - creates a new page manager implementation object
0583:             *
0584:             * @param classe implementation class
0585:             * @return a newly created implementation object
0586:             */
0587:            private Object createObject(Class classe) {
0588:                Object object = null;
0589:                try {
0590:                    object = classe.newInstance();
0591:                } catch (Exception e) {
0592:                    log.error("Factory failed to create object: "
0593:                            + classe.getName(), e);
0594:                }
0595:                return object;
0596:            }
0597:
0598:            /**
0599:             * addListener - add page manager event listener
0600:             *
0601:             * @param listener page manager event listener
0602:             */
0603:            public void addListener(PageManagerEventListener listener) {
0604:                // add listener to listeners list
0605:                synchronized (listeners) {
0606:                    listeners.add(listener);
0607:                }
0608:            }
0609:
0610:            /**
0611:             * removeListener - remove page manager event listener
0612:             *
0613:             * @param listener page manager event listener
0614:             */
0615:            public void removeListener(PageManagerEventListener listener) {
0616:                // remove listener from listeners list
0617:                synchronized (listeners) {
0618:                    listeners.remove(listener);
0619:                }
0620:            }
0621:
0622:            /* (non-Javadoc)
0623:             * @see org.apache.jetspeed.page.PageManager#reset()
0624:             */
0625:            public void reset() {
0626:                // nothing to reset by default
0627:            }
0628:
0629:            /**
0630:             * notifyNewNode - notify page manager event listeners of
0631:             *                 new node event
0632:             *
0633:             * @param node new managed node if known
0634:             */
0635:            public void notifyNewNode(Node node) {
0636:                // copy listeners list to reduce synchronization deadlock
0637:                List listenersList = null;
0638:                synchronized (listeners) {
0639:                    listenersList = new ArrayList(listeners);
0640:                }
0641:                // notify listeners
0642:                Iterator listenersIter = listenersList.iterator();
0643:                while (listenersIter.hasNext()) {
0644:                    PageManagerEventListener listener = (PageManagerEventListener) listenersIter
0645:                            .next();
0646:                    try {
0647:                        listener.newNode(node);
0648:                    } catch (Exception e) {
0649:                        log.error(
0650:                                "Failed to notify page manager event listener",
0651:                                e);
0652:                    }
0653:                }
0654:            }
0655:
0656:            /**
0657:             * notifyUpdatedNode - notify page manager event listeners of
0658:             *                     updated node event
0659:             *
0660:             * @param node updated managed node if known
0661:             */
0662:            public void notifyUpdatedNode(Node node) {
0663:                // copy listeners list to reduce synchronization deadlock
0664:                List listenersList = null;
0665:                synchronized (listeners) {
0666:                    listenersList = new ArrayList(listeners);
0667:                }
0668:                // notify listeners
0669:                Iterator listenersIter = listenersList.iterator();
0670:                while (listenersIter.hasNext()) {
0671:                    PageManagerEventListener listener = (PageManagerEventListener) listenersIter
0672:                            .next();
0673:                    try {
0674:                        listener.updatedNode(node);
0675:                    } catch (Exception e) {
0676:                        log.error(
0677:                                "Failed to notify page manager event listener",
0678:                                e);
0679:                    }
0680:                }
0681:            }
0682:
0683:            /**
0684:             * notifyRemovedNode - notify page manager event listeners of
0685:             *                     removed node event
0686:             *
0687:             * @param node removed managed node if known
0688:             */
0689:            public void notifyRemovedNode(Node node) {
0690:                // copy listeners list to reduce synchronization deadlock
0691:                List listenersList = null;
0692:                synchronized (listeners) {
0693:                    listenersList = new ArrayList(listeners);
0694:                }
0695:                // notify listeners
0696:                Iterator listenersIter = listenersList.iterator();
0697:                while (listenersIter.hasNext()) {
0698:                    PageManagerEventListener listener = (PageManagerEventListener) listenersIter
0699:                            .next();
0700:                    try {
0701:                        listener.removedNode(node);
0702:                    } catch (Exception e) {
0703:                        log.error(
0704:                                "Failed to notify page manager event listener",
0705:                                e);
0706:                    }
0707:                }
0708:            }
0709:
0710:            public Folder copyFolder(Folder source, String path)
0711:                    throws NodeException {
0712:                // create the new folder and copy attributes
0713:                Folder folder = newFolder(path);
0714:                folder.setDefaultPage(source.getDefaultPage());
0715:                folder.setShortTitle(source.getShortTitle());
0716:                folder.setTitle(source.getTitle());
0717:                folder.setHidden(source.isHidden());
0718:                folder.setDefaultDecorator(source
0719:                        .getDefaultDecorator(Fragment.LAYOUT), Fragment.LAYOUT);
0720:                folder.setDefaultDecorator(source
0721:                        .getDefaultDecorator(Fragment.PORTLET),
0722:                        Fragment.PORTLET);
0723:                folder.setSkin(source.getSkin());
0724:
0725:                // copy locale specific metadata
0726:                folder.getMetadata().copyFields(
0727:                        source.getMetadata().getFields());
0728:
0729:                // copy security constraints
0730:                SecurityConstraints srcSecurity = source
0731:                        .getSecurityConstraints();
0732:                if ((srcSecurity != null) && !srcSecurity.isEmpty()) {
0733:                    SecurityConstraints copiedSecurity = copySecurityConstraints(
0734:                            FOLDER_NODE_TYPE, srcSecurity);
0735:                    folder.setSecurityConstraints(copiedSecurity);
0736:                }
0737:
0738:                // copy document orders
0739:                folder.setDocumentOrder(DatabasePageManagerUtils.createList());
0740:                Iterator documentOrders = source.getDocumentOrder().iterator();
0741:                while (documentOrders.hasNext()) {
0742:                    String name = (String) documentOrders.next();
0743:                    folder.getDocumentOrder().add(name);
0744:                }
0745:
0746:                // copy menu definitions
0747:                List menus = source.getMenuDefinitions();
0748:                if (menus != null) {
0749:                    List copiedMenus = copyMenuDefinitions(FOLDER_NODE_TYPE,
0750:                            menus);
0751:                    folder.setMenuDefinitions(copiedMenus);
0752:                }
0753:
0754:                return folder;
0755:            }
0756:
0757:            public Page copyPage(Page source, String path) throws NodeException {
0758:                // create the new page and copy attributes
0759:                Page page = newPage(path);
0760:                page.setTitle(source.getTitle());
0761:                page.setShortTitle(source.getShortTitle());
0762:                page.setVersion(source.getVersion());
0763:                page.setDefaultDecorator(source
0764:                        .getDefaultDecorator(Fragment.LAYOUT), Fragment.LAYOUT);
0765:                page.setDefaultDecorator(source
0766:                        .getDefaultDecorator(Fragment.PORTLET),
0767:                        Fragment.PORTLET);
0768:                page.setSkin(source.getSkin());
0769:                page.setHidden(source.isHidden());
0770:
0771:                // copy locale specific metadata
0772:                page.getMetadata().copyFields(source.getMetadata().getFields());
0773:
0774:                // copy security constraints
0775:                SecurityConstraints srcSecurity = source
0776:                        .getSecurityConstraints();
0777:                if ((srcSecurity != null) && !srcSecurity.isEmpty()) {
0778:                    SecurityConstraints copiedSecurity = copySecurityConstraints(
0779:                            PAGE_NODE_TYPE, srcSecurity);
0780:                    page.setSecurityConstraints(copiedSecurity);
0781:                }
0782:
0783:                // copy menu definitions
0784:                List menus = source.getMenuDefinitions();
0785:                if (menus != null) {
0786:                    List copiedMenus = copyMenuDefinitions(PAGE_NODE_TYPE,
0787:                            menus);
0788:                    page.setMenuDefinitions(copiedMenus);
0789:                }
0790:
0791:                // copy fragments
0792:                Fragment root = copyFragment(source.getRootFragment(), source
0793:                        .getRootFragment().getName());
0794:                page.setRootFragment(root);
0795:
0796:                return page;
0797:            }
0798:
0799:            public Fragment copyFragment(Fragment source, String name)
0800:                    throws NodeException {
0801:                // create the new fragment and copy attributes
0802:                Fragment copy = newFragment();
0803:                copy.setDecorator(source.getDecorator());
0804:                copy.setName(name);
0805:                copy.setShortTitle(source.getShortTitle());
0806:                copy.setSkin(source.getSkin());
0807:                copy.setTitle(source.getTitle());
0808:                copy.setType(source.getType());
0809:                copy.setState(source.getState());
0810:
0811:                // copy security constraints
0812:                SecurityConstraints srcSecurity = source
0813:                        .getSecurityConstraints();
0814:                if ((srcSecurity != null) && !srcSecurity.isEmpty()) {
0815:                    SecurityConstraints copiedSecurity = copySecurityConstraints(
0816:                            FRAGMENT_NODE_TYPE, srcSecurity);
0817:                    copy.setSecurityConstraints(copiedSecurity);
0818:                }
0819:
0820:                // copy properties
0821:                Iterator props = source.getProperties().entrySet().iterator();
0822:                while (props.hasNext()) {
0823:                    Map.Entry prop = (Map.Entry) props.next();
0824:                    copy.getProperties().put(prop.getKey(), prop.getValue());
0825:                }
0826:
0827:                // copy preferences
0828:                copy.setPreferences(DatabasePageManagerUtils.createList());
0829:                Iterator prefs = source.getPreferences().iterator();
0830:                while (prefs.hasNext()) {
0831:                    FragmentPreference pref = (FragmentPreference) prefs.next();
0832:                    FragmentPreference newPref = this .newFragmentPreference();
0833:                    newPref.setName(pref.getName());
0834:                    newPref.setReadOnly(pref.isReadOnly());
0835:                    newPref.setValueList(DatabasePageManagerUtils.createList());
0836:                    Iterator values = pref.getValueList().iterator();
0837:                    while (values.hasNext()) {
0838:                        String value = (String) values.next();
0839:                        newPref.getValueList().add(value);
0840:                    }
0841:                    copy.getPreferences().add(newPref);
0842:                }
0843:
0844:                // recursively copy fragments
0845:                Iterator fragments = source.getFragments().iterator();
0846:                while (fragments.hasNext()) {
0847:                    Fragment fragment = (Fragment) fragments.next();
0848:                    Fragment copiedFragment = copyFragment(fragment, fragment
0849:                            .getName());
0850:                    copy.getFragments().add(copiedFragment);
0851:                }
0852:                return copy;
0853:            }
0854:
0855:            public Link copyLink(Link source, String path) throws NodeException {
0856:                // create the new link and copy attributes
0857:                Link link = newLink(path);
0858:                link.setTitle(source.getTitle());
0859:                link.setShortTitle(source.getShortTitle());
0860:                link.setSkin(source.getSkin());
0861:                link.setVersion(source.getVersion());
0862:                link.setTarget(source.getTarget());
0863:                link.setUrl(source.getUrl());
0864:                link.setHidden(source.isHidden());
0865:
0866:                // copy locale specific metadata
0867:                link.getMetadata().copyFields(source.getMetadata().getFields());
0868:
0869:                // copy security constraints
0870:                SecurityConstraints srcSecurity = source
0871:                        .getSecurityConstraints();
0872:                if ((srcSecurity != null) && !srcSecurity.isEmpty()) {
0873:                    SecurityConstraints copiedSecurity = copySecurityConstraints(
0874:                            LINK_NODE_TYPE, srcSecurity);
0875:                    link.setSecurityConstraints(copiedSecurity);
0876:                }
0877:
0878:                return link;
0879:            }
0880:
0881:            public PageSecurity copyPageSecurity(PageSecurity source)
0882:                    throws NodeException {
0883:                // create the new page security document and copy attributes
0884:                PageSecurity copy = this .newPageSecurity();
0885:                copy.setPath(source.getPath());
0886:                copy.setVersion(source.getVersion());
0887:
0888:                // copy security constraint defintions
0889:                copy.setSecurityConstraintsDefs(DatabasePageManagerUtils
0890:                        .createList());
0891:                Iterator defs = source.getSecurityConstraintsDefs().iterator();
0892:                while (defs.hasNext()) {
0893:                    SecurityConstraintsDef def = (SecurityConstraintsDef) defs
0894:                            .next();
0895:                    SecurityConstraintsDef defCopy = this 
0896:                            .newSecurityConstraintsDef();
0897:                    defCopy.setName(def.getName());
0898:                    List copiedConstraints = DatabasePageManagerUtils
0899:                            .createList();
0900:                    Iterator constraints = def.getSecurityConstraints()
0901:                            .iterator();
0902:                    while (constraints.hasNext()) {
0903:                        SecurityConstraint srcConstraint = (SecurityConstraint) constraints
0904:                                .next();
0905:                        SecurityConstraint dstConstraint = newPageSecuritySecurityConstraint();
0906:                        copyConstraint(srcConstraint, dstConstraint);
0907:                        copiedConstraints.add(dstConstraint);
0908:                    }
0909:                    defCopy.setSecurityConstraints(copiedConstraints);
0910:                    copy.getSecurityConstraintsDefs().add(defCopy);
0911:                }
0912:
0913:                // copy global security constraint references
0914:                copy.setGlobalSecurityConstraintsRefs(DatabasePageManagerUtils
0915:                        .createList());
0916:                Iterator globals = source.getGlobalSecurityConstraintsRefs()
0917:                        .iterator();
0918:                while (globals.hasNext()) {
0919:                    String global = (String) globals.next();
0920:                    copy.getGlobalSecurityConstraintsRefs().add(global);
0921:                }
0922:
0923:                return copy;
0924:            }
0925:
0926:            protected List copyMenuDefinitions(String type, List srcMenus) {
0927:                List copiedMenus = DatabasePageManagerUtils.createList();
0928:                Iterator menus = srcMenus.iterator();
0929:                while (menus.hasNext()) {
0930:                    MenuDefinition srcMenu = (MenuDefinition) menus.next();
0931:                    MenuDefinition copiedMenu = (MenuDefinition) copyMenuElement(
0932:                            type, srcMenu);
0933:                    if (copiedMenu != null) {
0934:                        copiedMenus.add(copiedMenu);
0935:                    }
0936:                }
0937:                return copiedMenus;
0938:            }
0939:
0940:            protected Object copyMenuElement(String type, Object srcElement) {
0941:                if (srcElement instanceof  MenuDefinition) {
0942:                    // create the new menu element and copy attributes
0943:                    MenuDefinition source = (MenuDefinition) srcElement;
0944:                    MenuDefinition menu = null;
0945:                    if (type.equals(PAGE_NODE_TYPE)) {
0946:                        menu = newPageMenuDefinition();
0947:                    } else if (type.equals(FOLDER_NODE_TYPE)) {
0948:                        menu = newFolderMenuDefinition();
0949:                    }
0950:                    menu.setDepth(source.getDepth());
0951:                    menu.setName(source.getName());
0952:                    menu.setOptions(source.getOptions());
0953:                    menu.setOrder(source.getOrder());
0954:                    menu.setPaths(source.isPaths());
0955:                    menu.setProfile(source.getProfile());
0956:                    menu.setRegexp(source.isRegexp());
0957:                    menu.setShortTitle(source.getShortTitle());
0958:                    menu.setSkin(source.getSkin());
0959:                    menu.setTitle(source.getTitle());
0960:
0961:                    // copy locale specific metadata
0962:                    menu.getMetadata().copyFields(
0963:                            source.getMetadata().getFields());
0964:
0965:                    // recursively copy menu elements
0966:                    List elements = source.getMenuElements();
0967:                    if (elements != null) {
0968:                        List copiedElements = DatabasePageManagerUtils
0969:                                .createList();
0970:                        Iterator elementsIter = elements.iterator();
0971:                        while (elementsIter.hasNext()) {
0972:                            Object element = elementsIter.next();
0973:                            Object copiedElement = copyMenuElement(type,
0974:                                    element);
0975:                            if (copiedElement != null) {
0976:                                copiedElements.add(copiedElement);
0977:                            }
0978:                        }
0979:                        menu.setMenuElements(copiedElements);
0980:                    }
0981:
0982:                    return menu;
0983:                } else if (srcElement instanceof  MenuExcludeDefinition) {
0984:                    // create the new menu exclude element and copy attributes
0985:                    MenuExcludeDefinition source = (MenuExcludeDefinition) srcElement;
0986:                    MenuExcludeDefinition menuExclude = null;
0987:                    if (type.equals(PAGE_NODE_TYPE)) {
0988:                        menuExclude = newPageMenuExcludeDefinition();
0989:                    } else if (type.equals(FOLDER_NODE_TYPE)) {
0990:                        menuExclude = newFolderMenuExcludeDefinition();
0991:                    }
0992:                    menuExclude.setName(source.getName());
0993:                    return menuExclude;
0994:                } else if (srcElement instanceof  MenuIncludeDefinition) {
0995:                    // create the new menu include element and copy attributes
0996:                    MenuIncludeDefinition source = (MenuIncludeDefinition) srcElement;
0997:                    MenuIncludeDefinition menuInclude = null;
0998:                    if (type.equals(PAGE_NODE_TYPE)) {
0999:                        menuInclude = newPageMenuIncludeDefinition();
1000:                    } else if (type.equals(FOLDER_NODE_TYPE)) {
1001:                        menuInclude = newFolderMenuIncludeDefinition();
1002:                    }
1003:                    menuInclude.setName(source.getName());
1004:                    menuInclude.setNest(source.isNest());
1005:                    return menuInclude;
1006:                } else if (srcElement instanceof  MenuOptionsDefinition) {
1007:                    // create the new menu options element and copy attributes
1008:                    MenuOptionsDefinition source = (MenuOptionsDefinition) srcElement;
1009:                    MenuOptionsDefinition menuOptions = null;
1010:                    if (type.equals(PAGE_NODE_TYPE)) {
1011:                        menuOptions = newPageMenuOptionsDefinition();
1012:                    } else if (type.equals(FOLDER_NODE_TYPE)) {
1013:                        menuOptions = newFolderMenuOptionsDefinition();
1014:                    }
1015:                    menuOptions.setDepth(source.getDepth());
1016:                    menuOptions.setOptions(source.getOptions());
1017:                    menuOptions.setOrder(source.getOrder());
1018:                    menuOptions.setPaths(source.isPaths());
1019:                    menuOptions.setProfile(source.getProfile());
1020:                    menuOptions.setRegexp(source.isRegexp());
1021:                    menuOptions.setSkin(source.getSkin());
1022:                    return menuOptions;
1023:                } else if (srcElement instanceof  MenuSeparatorDefinition) {
1024:                    // create the new menu separator element and copy attributes
1025:                    MenuSeparatorDefinition source = (MenuSeparatorDefinition) srcElement;
1026:                    MenuSeparatorDefinition menuSeparator = null;
1027:                    if (type.equals(PAGE_NODE_TYPE)) {
1028:                        menuSeparator = newPageMenuSeparatorDefinition();
1029:                    } else if (type.equals(FOLDER_NODE_TYPE)) {
1030:                        menuSeparator = newFolderMenuSeparatorDefinition();
1031:                    }
1032:                    menuSeparator.setSkin(source.getSkin());
1033:                    menuSeparator.setTitle(source.getTitle());
1034:                    menuSeparator.setText(source.getText());
1035:
1036:                    // copy locale specific metadata
1037:                    menuSeparator.getMetadata().copyFields(
1038:                            source.getMetadata().getFields());
1039:
1040:                    return menuSeparator;
1041:                }
1042:                return null;
1043:            }
1044:
1045:            protected void copyConstraint(SecurityConstraint srcConstraint,
1046:                    SecurityConstraint dstConstraint) {
1047:                dstConstraint.setUsers(srcConstraint.getUsers());
1048:                dstConstraint.setRoles(srcConstraint.getRoles());
1049:                dstConstraint.setGroups(srcConstraint.getGroups());
1050:                dstConstraint.setPermissions(srcConstraint.getPermissions());
1051:            }
1052:
1053:            protected SecurityConstraints copySecurityConstraints(String type,
1054:                    SecurityConstraints source) {
1055:                SecurityConstraints security = newSecurityConstraints();
1056:                if (source.getOwner() != null) {
1057:                    security.setOwner(source.getOwner());
1058:                }
1059:                if (source.getSecurityConstraints() != null) {
1060:                    List copiedConstraints = DatabasePageManagerUtils
1061:                            .createList();
1062:                    Iterator constraints = source.getSecurityConstraints()
1063:                            .iterator();
1064:                    while (constraints.hasNext()) {
1065:                        SecurityConstraint srcConstraint = (SecurityConstraint) constraints
1066:                                .next();
1067:                        SecurityConstraint dstConstraint = null;
1068:                        if (type.equals(PAGE_NODE_TYPE)) {
1069:                            dstConstraint = newPageSecurityConstraint();
1070:                        } else if (type.equals(FOLDER_NODE_TYPE)) {
1071:                            dstConstraint = newFolderSecurityConstraint();
1072:                        } else if (type.equals(LINK_NODE_TYPE)) {
1073:                            dstConstraint = newLinkSecurityConstraint();
1074:                        } else if (type.equals(FRAGMENT_NODE_TYPE)) {
1075:                            dstConstraint = newFragmentSecurityConstraint();
1076:                        }
1077:                        copyConstraint(srcConstraint, dstConstraint);
1078:                        copiedConstraints.add(dstConstraint);
1079:                    }
1080:                    security.setSecurityConstraints(copiedConstraints);
1081:                }
1082:                if (source.getSecurityConstraintsRefs() != null) {
1083:                    List copiedRefs = DatabasePageManagerUtils.createList();
1084:                    Iterator refs = source.getSecurityConstraintsRefs()
1085:                            .iterator();
1086:                    while (refs.hasNext()) {
1087:                        String constraintsRef = (String) refs.next();
1088:                        copiedRefs.add(constraintsRef);
1089:                    }
1090:                    security.setSecurityConstraintsRefs(copiedRefs);
1091:                }
1092:                return security;
1093:            }
1094:
1095:            /**
1096:             * Deep copy a folder
1097:             *  
1098:             * @param source source folder
1099:             * @param dest destination folder
1100:             */
1101:            public void deepCopyFolder(Folder srcFolder,
1102:                    String destinationPath, String owner) throws NodeException {
1103:                PageManagerUtils.deepCopyFolder(this , srcFolder,
1104:                        destinationPath, owner);
1105:            }
1106:
1107:            public Page getUserPage(String userName, String pageName)
1108:                    throws PageNotFoundException, NodeException {
1109:                return this .getPage(Folder.USER_FOLDER + userName
1110:                        + Folder.PATH_SEPARATOR + pageName);
1111:            }
1112:
1113:            public Folder getUserFolder(String userName)
1114:                    throws FolderNotFoundException, InvalidFolderException,
1115:                    NodeException {
1116:                return this .getFolder(Folder.USER_FOLDER + userName);
1117:            }
1118:
1119:            public boolean folderExists(String folderName) {
1120:                try {
1121:                    getFolder(folderName);
1122:                } catch (Exception e) {
1123:                    return false;
1124:                }
1125:                return true;
1126:            }
1127:
1128:            public boolean pageExists(String pageName) {
1129:                try {
1130:                    getPage(pageName);
1131:                } catch (Exception e) {
1132:                    return false;
1133:                }
1134:                return true;
1135:            }
1136:
1137:            public boolean linkExists(String linkName) {
1138:                try {
1139:                    getLink(linkName);
1140:                } catch (Exception e) {
1141:                    return false;
1142:                }
1143:                return true;
1144:            }
1145:
1146:            public boolean userFolderExists(String userName) {
1147:                try {
1148:                    getFolder(Folder.USER_FOLDER + userName);
1149:                } catch (Exception e) {
1150:                    return false;
1151:                }
1152:                return true;
1153:            }
1154:
1155:            public boolean userPageExists(String userName, String pageName) {
1156:                try {
1157:                    getPage(Folder.USER_FOLDER + userName
1158:                            + Folder.PATH_SEPARATOR + pageName);
1159:                } catch (Exception e) {
1160:                    return false;
1161:                }
1162:                return true;
1163:            }
1164:
1165:            /**
1166:             * Creates a user's home page from the roles of the current user.
1167:             * The use case: when a portal is setup to use shared pages, but then
1168:             * the user attempts to customize. At this point, we create the new page(s) for the user.
1169:             * 
1170:             * @param subject
1171:             */
1172:            public void createUserHomePagesFromRoles(Subject subject)
1173:                    throws NodeException {
1174:                PageManagerUtils.createUserHomePagesFromRoles(this, subject);
1175:            }
1176:
1177:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.