Source Code Cross Referenced for PortalAction.java in  » Portal » jboss-portal-2.6.4 » org » jboss » portal » core » admin » ui » actions » 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 » jboss portal 2.6.4 » org.jboss.portal.core.admin.ui.actions 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /******************************************************************************
002:         * JBoss, a division of Red Hat                                               *
003:         * Copyright 2006, Red Hat Middleware, LLC, and individual                    *
004:         * contributors as indicated by the @authors tag. See the                     *
005:         * copyright.txt in the distribution for a full listing of                    *
006:         * individual contributors.                                                   *
007:         *                                                                            *
008:         * This is free software; you can redistribute it and/or modify it            *
009:         * under the terms of the GNU Lesser General Public License as                *
010:         * published by the Free Software Foundation; either version 2.1 of           *
011:         * the License, or (at your option) any later version.                        *
012:         *                                                                            *
013:         * This software is distributed in the hope that it will be useful,           *
014:         * but WITHOUT ANY WARRANTY; without even the implied warranty of             *
015:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU           *
016:         * Lesser General Public License for more details.                            *
017:         *                                                                            *
018:         * You should have received a copy of the GNU Lesser General Public           *
019:         * License along with this software; if not, write to the Free                *
020:         * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA         *
021:         * 02110-1301 USA, or see the FSF site: http://www.fsf.org.                   *
022:         ******************************************************************************/package org.jboss.portal.core.admin.ui.actions;
023:
024:        import org.jboss.portal.Mode;
025:        import org.jboss.portal.WindowState;
026:        import org.jboss.portal.core.admin.ui.PortalObjectManagerBean;
027:        import org.jboss.portal.core.model.portal.Page;
028:        import org.jboss.portal.core.model.portal.Portal;
029:        import org.jboss.portal.core.model.portal.PortalContainer;
030:        import org.jboss.portal.core.model.portal.PortalObject;
031:        import org.jboss.portal.core.model.portal.PortalObjectPath;
032:        import org.jboss.portal.core.model.portal.PortalObjectPermission;
033:        import org.jboss.portal.security.RoleSecurityBinding;
034:        import org.jboss.portal.security.SecurityConstants;
035:        import org.jboss.portal.security.spi.provider.DomainConfigurator;
036:        import org.jboss.portal.theme.ThemeConstants;
037:
038:        import javax.faces.application.FacesMessage;
039:        import javax.faces.component.UIComponent;
040:        import javax.faces.context.FacesContext;
041:        import javax.faces.validator.ValidatorException;
042:        import java.util.Collections;
043:        import java.util.HashSet;
044:        import java.util.Set;
045:
046:        /**
047:         * @author <a href="mailto:boleslaw dot dawidowicz at jboss.org">Boleslaw Dawidowicz</a>
048:         * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
049:         * @version $Revision: 8785 $
050:         */
051:        public class PortalAction {
052:
053:            /** . */
054:            private PortalObjectManagerBean pomgr;
055:
056:            /** . */
057:            private String portalName;
058:
059:            //private String defaultPageName;
060:
061:            /** . */
062:            private static final String ERROR_DUPE_NAME = "Duplicate Portal name found on this portal!";
063:
064:            /** . */
065:            private static final String ERROR_EMPTY_NAME = "Portal name cannot be blank!";
066:
067:            public PortalObjectManagerBean getPortalObjectManager() {
068:                return pomgr;
069:            }
070:
071:            public void setPortalObjectManager(
072:                    PortalObjectManagerBean portalObjectManager) {
073:                this .pomgr = portalObjectManager;
074:            }
075:
076:            public String getPortalName() {
077:                return portalName;
078:            }
079:
080:            public void setPortalName(String portalName) {
081:                this .portalName = portalName;
082:            }
083:
084:            public String getDefaultObjectName() {
085:                return pomgr.getSelectedObject().getDeclaredProperty(
086:                        PortalObject.PORTAL_PROP_DEFAULT_OBJECT_NAME);
087:            }
088:
089:            public void setDefaultObjectName(String defaultObjectName) {
090:                if (defaultObjectName != null && !defaultObjectName.equals("")) {
091:                    pomgr.getSelectedObject().setDeclaredProperty(
092:                            PortalObject.PORTAL_PROP_DEFAULT_OBJECT_NAME,
093:                            defaultObjectName);
094:                } else if (defaultObjectName == null
095:                        || defaultObjectName.equals("")) {
096:                    pomgr.getSelectedObject().setDeclaredProperty(
097:                            PortalObject.PORTAL_PROP_DEFAULT_OBJECT_NAME, null);
098:                }
099:
100:            }
101:
102:            /**
103:             * Checks for duplicate portal names on the portal instance. Blank page names are not allowed and are controlled by
104:             * the required attribute in the presentation page.
105:             *
106:             * @param context
107:             * @param toValidate
108:             * @param value
109:             */
110:            public void validatePortalName(FacesContext context,
111:                    UIComponent toValidate, Object value) {
112:                String portalName = (String) value;
113:
114:                // check for empty string
115:                if (portalName.startsWith(" ")) {
116:                    FacesMessage message = new FacesMessage(
117:                            FacesMessage.SEVERITY_ERROR,
118:                            PortalAction.ERROR_EMPTY_NAME,
119:                            PortalAction.ERROR_EMPTY_NAME);
120:                    throw new ValidatorException(message);
121:                }
122:
123:                // Check for duplicate child name
124:                if (pomgr.getSelectedObject().getChild(portalName) != null) {
125:                    FacesMessage message = new FacesMessage(
126:                            FacesMessage.SEVERITY_ERROR,
127:                            PortalAction.ERROR_DUPE_NAME,
128:                            PortalAction.ERROR_DUPE_NAME);
129:                    throw new ValidatorException(message);
130:                }
131:            }
132:
133:            public void addPortal() {
134:                try {
135:                    PortalContainer portalContainer = (PortalContainer) pomgr
136:                            .getSelectedObject();
137:                    Portal portal = portalContainer.createPortal(portalName);
138:                    DomainConfigurator configurator = pomgr
139:                            .getDomainConfigurator();
140:
141:                    // Initial portal permissions
142:                    Set actions = new HashSet();
143:                    actions.add(PortalObjectPermission.VIEW_RECURSIVE_ACTION);
144:                    actions
145:                            .add(PortalObjectPermission.PERSONALIZE_RECURSIVE_ACTION);
146:                    RoleSecurityBinding binding = new RoleSecurityBinding(
147:                            actions, SecurityConstants.UNCHECKED_ROLE_NAME);
148:                    Set constraints = Collections.singleton(binding);
149:                    configurator.setSecurityBindings(portal.getId().toString(
150:                            PortalObjectPath.CANONICAL_FORMAT), constraints);
151:
152:                    // We need to add initial layout sets to avoid problems...
153:                    portal.setDeclaredProperty(
154:                            ThemeConstants.PORTAL_PROP_LAYOUT, "generic");
155:                    // portal.setDeclaredProperty(ThemeConstants.PORTAL_PROP_THEME, "Nphalanx");
156:                    portal
157:                            .setDeclaredProperty(
158:                                    ThemeConstants.PORTAL_PROP_RENDERSET,
159:                                    "divRenderer");
160:
161:                    //
162:                    portal.getSupportedWindowStates()
163:                            .add(WindowState.MAXIMIZED);
164:                    portal.getSupportedWindowStates()
165:                            .add(WindowState.MINIMIZED);
166:                    portal.getSupportedWindowStates().add(WindowState.NORMAL);
167:
168:                    //
169:                    portal.getSupportedModes().add(Mode.EDIT);
170:                    portal.getSupportedModes().add(Mode.HELP);
171:                    portal.getSupportedModes().add(Mode.VIEW);
172:
173:                    // Create the default page
174:                    Page page = portal.createPage("default");
175:                    constraints = Collections
176:                            .singleton(new RoleSecurityBinding(
177:                                    PortalObjectPermission.VIEW_RECURSIVE_ACTION,
178:                                    SecurityConstants.UNCHECKED_ROLE_NAME));
179:                    configurator.setSecurityBindings(page.getId().toString(
180:                            PortalObjectPath.CANONICAL_FORMAT), constraints);
181:
182:                    portal.setDeclaredProperty(
183:                            PortalObject.PORTAL_PROP_DEFAULT_OBJECT_NAME, page
184:                                    .getName());
185:
186:                } catch (Exception e) {
187:                    e.printStackTrace();
188:                }
189:            }
190:        }
w___w_w_.__j_a___va__2s_._c_o___m__ | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.