Source Code Cross Referenced for PortalApplicationView.java in  » Portal » stringbeans-3.5 » com » nabhinc » portal » model » 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 » stringbeans 3.5 » com.nabhinc.portal.model 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /* 
002:         * (C) Copyright 2000 - 2006 Nabh Information Systems, Inc. 
003:         * 
004:         * This program is free software; you can redistribute it and/or
005:         * modify it under the terms of the GNU General Public License 
006:         * as published by the Free Software Foundation; either version 2
007:         * of the License, or (at your option) any later version.
008:         * 
009:         * This program is distributed in the hope that it will be useful,
010:         * but WITHOUT ANY WARRANTY; without even the implied warranty of 
011:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
012:         * GNU General Public License for more details.
013:         * 
014:         * You should have received a copy of the GNU General Public License
015:         * along with this program; if not, write to the Free Software 
016:         * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
017:         * 
018:         */
019:        package com.nabhinc.portal.model;
020:
021:        import java.io.Serializable;
022:        import java.util.HashMap;
023:        import java.util.Properties;
024:
025:        import javax.servlet.ServletException;
026:        import javax.servlet.http.HttpServletRequest;
027:        import javax.servlet.http.HttpSession;
028:        import javax.xml.bind.annotation.XmlElement;
029:        import javax.xml.bind.annotation.XmlTransient;
030:
031:        import com.nabhinc.portal.core.ClientInfo;
032:        import com.nabhinc.portal.core.LocaleUtil;
033:        import com.nabhinc.portal.core.PortalConstants;
034:        import com.nabhinc.portal.core.PortalUtil;
035:
036:        /**
037:         * 
038:         *
039:         * @author Padmanabh Dabke
040:         * (c) 2006 Nabh Information Systems, Inc. All Rights Reserved.
041:         */
042:        public class PortalApplicationView implements  Serializable {
043:
044:            private static final long serialVersionUID = -3755633573601263513L;
045:            @XmlElement(name="page")
046:            private PortalPageState[] pavPageStates = new PortalPageState[0];
047:
048:            private transient HashMap<Object, PortalPageState> pavPageStateMap = new HashMap<Object, PortalPageState>();
049:
050:            protected transient PortalApplication pavPortalApplication = null;
051:
052:            public transient boolean isEditable = false;
053:            public transient boolean isAdminable = false;
054:            public transient boolean isPsiteCreatable = false;
055:            public transient boolean needsPasswordCheck = false;
056:            public transient boolean isDesktopMode = false;
057:
058:            public PortalApplicationView() {
059:
060:            }
061:
062:            public PortalApplicationView(PortalPage[] pages,
063:                    PortalApplication pApp, ClientInfo clInfo,
064:                    HttpServletRequest request) throws ServletException {
065:                Properties localeProps = clInfo.currentLocaleProperties;
066:                String urlPrefix = request.getContextPath() + "/portal"
067:                        + pApp.getPath() + "/";
068:
069:                if (pages != null) {
070:                    this .pavPageStates = new PortalPageState[pages.length];
071:                    int pageStateCount = 0;
072:                    if (pApp.isEditable(request))
073:                        this .isEditable = true;
074:
075:                    for (int i = 0; i < pages.length; i++) {
076:                        if (!pages[i].isViewable(request))
077:                            continue;
078:                        pavPageStates[pageStateCount] = new PortalPageState(
079:                                pages[i], LocaleUtil.getLocalizedValue(pages[i]
080:                                        .getName(), localeProps), urlPrefix,
081:                                request);
082:                        if (isEditable
083:                                && pages[i].getEditPermission() != null
084:                                && (!pages[i].getEditPermission().isSatisfied(
085:                                        request, pages[i])))
086:                            pavPageStates[pageStateCount].isEditable = false;
087:                        if (isEditable
088:                                && pages[i].getDeletePermission() != null
089:                                && (!pages[i].getDeletePermission()
090:                                        .isSatisfied(request, pages[i])))
091:                            pavPageStates[pageStateCount].isDeletable = false;
092:
093:                        pageStateCount++;
094:                    }
095:                    // First check if we are in a session failover state
096:                    this .pavPortalApplication = pApp;
097:                    HttpSession session = request.getSession();
098:                    String displayMode = (String) session
099:                            .getAttribute(PortalConstants.PORTAL_APP_DISPLAY_MODE_ATTRIB
100:                                    + pApp.getIdPrefix());
101:                    if (displayMode == null) {
102:                        if (PortalConfiguration.getInstance()
103:                                .getDefaultDisplayMode().equals(
104:                                        PortalConstants.DISPLAY_MODE_NORMAL))
105:                            setNormalDisplayMode(request.getSession());
106:                        else
107:                            setDesktopDisplayMode(request.getSession());
108:                    } else {
109:                        initPageStates(displayMode, session);
110:                    }
111:                    computePageMap();
112:                }
113:
114:                if (pApp.isAdminable(request))
115:                    this .isAdminable = true;
116:                if (pApp.isPsiteCreatable(request))
117:                    this .isPsiteCreatable = true;
118:                if (pApp.isPasswordProtected()
119:                        && (!PortalUtil.isOwnerOrAdmin(request, pApp
120:                                .getOwnerName())))
121:                    this .needsPasswordCheck = true;
122:            }
123:
124:            public void computePageMap() {
125:                pavPageStateMap.clear();
126:                for (int i = 0; i < pavPageStates.length; i++) {
127:                    pavPageStateMap.put(pavPageStates[i].portalPage.getName(),
128:                            pavPageStates[i]);
129:                    pavPageStateMap.put(pavPageStates[i].portalPage.getIndex(),
130:                            pavPageStates[i]);
131:                }
132:            }
133:
134:            public PortalPageState getPageState(Object pageNameOrIndex) {
135:                return this .pavPageStateMap.get(pageNameOrIndex);
136:            }
137:
138:            @XmlTransient
139:            public PortalApplication getPortalApplication() {
140:                return this .pavPortalApplication;
141:            }
142:
143:            public PortalPageState[] getPageStates() {
144:                return this .pavPageStates;
145:            }
146:
147:            public void reorderPage(int oldIndex, int newIndex) {
148:                if (oldIndex < 0 || oldIndex >= pavPageStates.length)
149:                    return;
150:                if (newIndex < 0 || newIndex >= pavPageStates.length)
151:                    return;
152:                if (oldIndex == newIndex)
153:                    return;
154:
155:                PortalPageState oldTab = pavPageStates[oldIndex];
156:                if (oldIndex < newIndex) {
157:                    for (int i = oldIndex; i < newIndex; i++) {
158:                        pavPageStates[i] = pavPageStates[i + 1];
159:                    }
160:                    pavPageStates[newIndex] = oldTab;
161:                } else {
162:                    for (int i = oldIndex; i > newIndex; i--) {
163:                        pavPageStates[i] = pavPageStates[i - 1];
164:                    }
165:                    pavPageStates[newIndex] = oldTab;
166:
167:                }
168:                this .pavPortalApplication.reorderPage(oldTab.portalPage,
169:                        oldIndex, newIndex);
170:            }
171:
172:            /**
173:             * Delete an existing page if the index is within the range.
174:             */
175:            public void deletePage(int index) {
176:
177:                if (index < 0 || index >= pavPageStates.length) {
178:                    return;
179:                }
180:                if (this .pavPageStates.length == 1)
181:                    return;
182:                PortalPage deletedPage = this .pavPageStates[index].portalPage;
183:                this .pavPortalApplication.deletePage(deletedPage);
184:
185:                PortalPageState[] newPages = new PortalPageState[pavPageStates.length - 1];
186:
187:                for (int i = 0; i < index; i++) {
188:                    newPages[i] = pavPageStates[i];
189:                }
190:
191:                int newLen = newPages.length;
192:
193:                for (int i = index; i < newLen; i++) {
194:                    newPages[i] = pavPageStates[i + 1];
195:                }
196:
197:                pavPageStates = newPages;
198:
199:            }
200:
201:            public void addPage(PortalPage p, HttpServletRequest request,
202:                    ClientInfo clInfo) throws ServletException {
203:                Properties localeProps = clInfo.currentLocaleProperties;
204:                String urlPrefix = request.getContextPath() + "/portal"
205:                        + this .pavPortalApplication.getPath() + "/";
206:                PortalPageState pState = new PortalPageState(p, LocaleUtil
207:                        .getLocalizedValue(p.getName(), localeProps),
208:                        urlPrefix, request);
209:                if (this .isDesktopMode) {
210:                    pState.setDesktopPageMode(request.getSession());
211:                } else {
212:                    pState.setNormalPageMode(request.getSession());
213:                }
214:                PortalPageState[] newPages = new PortalPageState[pavPageStates.length + 1];
215:
216:                for (int i = 0; i < pavPageStates.length; i++) {
217:                    newPages[i] = pavPageStates[i];
218:                }
219:                newPages[pavPageStates.length] = pState;
220:                this .pavPageStates = newPages;
221:                computePageMap();
222:            }
223:
224:            public void setNormalDisplayMode(HttpSession session) {
225:                this .isDesktopMode = false;
226:                for (int i = 0; i < pavPageStates.length; i++) {
227:                    pavPageStates[i].setNormalPageMode(session);
228:                }
229:                session.setAttribute(
230:                        PortalConstants.PORTAL_APP_DISPLAY_MODE_ATTRIB
231:                                + this .pavPortalApplication.getIdPrefix(),
232:                        PortalConstants.DISPLAY_MODE_NORMAL);
233:            }
234:
235:            public void setDesktopDisplayMode(HttpSession session) {
236:                this .isDesktopMode = true;
237:                for (int i = 0; i < pavPageStates.length; i++) {
238:                    pavPageStates[i].setDesktopPageMode(session);
239:                }
240:                session.setAttribute(
241:                        PortalConstants.PORTAL_APP_DISPLAY_MODE_ATTRIB
242:                                + this .pavPortalApplication.getIdPrefix(),
243:                        PortalConstants.DISPLAY_MODE_DESKTOP);
244:            }
245:
246:            private void initPageStates(String displayMode, HttpSession session) {
247:                this .isDesktopMode = displayMode
248:                        .equals(PortalConstants.DISPLAY_MODE_DESKTOP);
249:                for (int i = 0; i < this .pavPageStates.length; i++) {
250:                    boolean restoredFromCache = this.pavPageStates[i]
251:                            .restoreNavigationState(session);
252:                    if (!restoredFromCache) {
253:                        if (this.isDesktopMode) {
254:                            pavPageStates[i].setDesktopPageMode(session);
255:                        } else {
256:                            pavPageStates[i].setNormalPageMode(session);
257:                        }
258:                    }
259:                }
260:            }
261:
262:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.