Source Code Cross Referenced for WorksiteHandler.java in  » ERP-CRM-Financial » sakai » org » sakaiproject » portal » charon » handlers » 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 » ERP CRM Financial » sakai » org.sakaiproject.portal.charon.handlers 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**********************************************************************************
002:         * $URL: https://source.sakaiproject.org/svn/portal/tags/sakai_2-4-1/portal-impl/impl/src/java/org/sakaiproject/portal/charon/handlers/WorksiteHandler.java $
003:         * $Id: WorksiteHandler.java 29143 2007-04-19 01:10:38Z ajpoland@iupui.edu $
004:         ***********************************************************************************
005:         *
006:         * Copyright (c) 2003, 2004, 2005, 2006, 2007 The Sakai Foundation.
007:         *
008:         * Licensed under the Educational Community License, Version 1.0 (the "License");
009:         * you may not use this file except in compliance with the License.
010:         * You may obtain a copy of the License at
011:         *
012:         *      http://www.opensource.org/licenses/ecl1.php
013:         *
014:         * Unless required by applicable law or agreed to in writing, software
015:         * distributed under the License is distributed on an "AS IS" BASIS,
016:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
017:         * See the License for the specific language governing permissions and
018:         * limitations under the License.
019:         *
020:         **********************************************************************************/package org.sakaiproject.portal.charon.handlers;
021:
022:        import java.io.IOException;
023:        import java.util.ArrayList;
024:        import java.util.HashMap;
025:        import java.util.Iterator;
026:        import java.util.List;
027:        import java.util.Map;
028:
029:        import javax.servlet.http.HttpServletRequest;
030:        import javax.servlet.http.HttpServletResponse;
031:
032:        import org.sakaiproject.component.cover.ServerConfigurationService;
033:        import org.sakaiproject.exception.IdUnusedException;
034:        import org.sakaiproject.exception.PermissionException;
035:        import org.sakaiproject.portal.api.Portal;
036:        import org.sakaiproject.portal.api.PortalHandlerException;
037:        import org.sakaiproject.portal.api.PortalRenderContext;
038:        import org.sakaiproject.site.api.Site;
039:        import org.sakaiproject.site.api.SitePage;
040:        import org.sakaiproject.site.api.ToolConfiguration;
041:        import org.sakaiproject.tool.api.Session;
042:        import org.sakaiproject.tool.api.ToolException;
043:        import org.sakaiproject.util.Web;
044:
045:        /**
046:         * 
047:         * @author ieb
048:         * @since Sakai 2.4
049:         * @version $Rev: 29143 $
050:         * 
051:         */
052:        public class WorksiteHandler extends PageHandler {
053:            private static final String INCLUDE_WORKSITE = "include-worksite";
054:
055:            private static final String INCLUDE_PAGE_NAV = "include-page-nav";
056:
057:            public WorksiteHandler() {
058:                urlFragment = "worksite";
059:            }
060:
061:            @Override
062:            public int doPost(String[] parts, HttpServletRequest req,
063:                    HttpServletResponse res, Session session)
064:                    throws PortalHandlerException {
065:                return doGet(parts, req, res, session);
066:            }
067:
068:            @Override
069:            public int doGet(String[] parts, HttpServletRequest req,
070:                    HttpServletResponse res, Session session)
071:                    throws PortalHandlerException {
072:                if ((parts.length >= 3) && (parts[1].equals("worksite"))) {
073:                    try {
074:                        // recognize an optional page/pageid
075:                        String pageId = null;
076:                        if ((parts.length == 5) && (parts[3].equals("page"))) {
077:                            pageId = parts[4];
078:                        }
079:
080:                        doWorksite(req, res, session, parts[2], pageId, req
081:                                .getContextPath()
082:                                + req.getServletPath());
083:                        return END;
084:                    } catch (Exception ex) {
085:                        throw new PortalHandlerException(ex);
086:                    }
087:                } else {
088:                    return NEXT;
089:                }
090:            }
091:
092:            public void doWorksite(HttpServletRequest req,
093:                    HttpServletResponse res, Session session, String siteId,
094:                    String pageId, String toolContextPath)
095:                    throws ToolException, IOException {
096:                // if no page id, see if there was a last page visited for this site
097:                if (pageId == null) {
098:                    pageId = (String) session
099:                            .getAttribute(Portal.ATTR_SITE_PAGE + siteId);
100:                }
101:
102:                // find the site, for visiting
103:                Site site = null;
104:                try {
105:                    site = siteHelper.getSiteVisit(siteId);
106:                } catch (IdUnusedException e) {
107:                    portal.doError(req, res, session, Portal.ERROR_WORKSITE);
108:                    return;
109:                } catch (PermissionException e) {
110:                    // if not logged in, give them a chance
111:                    if (session.getUserId() == null) {
112:                        portal.doLogin(req, res, session, req.getPathInfo(),
113:                                false);
114:                    } else {
115:                        portal
116:                                .doError(req, res, session,
117:                                        Portal.ERROR_WORKSITE);
118:                    }
119:                    return;
120:                }
121:
122:                // find the page, or use the first page if pageId not found
123:                SitePage page = site.getPage(pageId);
124:                if (page == null) {
125:                    // List pages = site.getOrderedPages();
126:                    List pages = siteHelper.getPermittedPagesInOrder(site);
127:                    if (!pages.isEmpty()) {
128:                        page = (SitePage) pages.get(0);
129:                    }
130:                }
131:                if (page == null) {
132:                    portal.doError(req, res, session, Portal.ERROR_WORKSITE);
133:                    return;
134:                }
135:
136:                // store the last page visited
137:                session.setAttribute(Portal.ATTR_SITE_PAGE + siteId, page
138:                        .getId());
139:
140:                // form a context sensitive title
141:                String title = ServerConfigurationService
142:                        .getString("ui.service")
143:                        + " : " + site.getTitle() + " : " + page.getTitle();
144:
145:                // start the response
146:                String siteType = portal.calcSiteType(siteId);
147:                PortalRenderContext rcontext = portal.startPageContext(
148:                        siteType, title, site.getSkin(), req);
149:
150:                includeWorksite(rcontext, res, req, session, site, page,
151:                        toolContextPath, "worksite");
152:
153:                portal.includeBottom(rcontext);
154:
155:                // end the response
156:                portal.sendResponse(rcontext, res, "worksite", null);
157:            }
158:
159:            public void includeWorksite(PortalRenderContext rcontext,
160:                    HttpServletResponse res, HttpServletRequest req,
161:                    Session session, Site site, SitePage page,
162:                    String toolContextPath, String portalPrefix)
163:                    throws IOException {
164:                if (rcontext.uses(INCLUDE_WORKSITE)) {
165:
166:                    // add the page navigation with presence
167:                    includePageNav(rcontext, req, session, site, page,
168:                            toolContextPath, portalPrefix);
169:
170:                    // add the page
171:                    includePage(rcontext, res, req, page, toolContextPath,
172:                            "content");
173:                }
174:
175:            }
176:
177:            public void includePageNav(PortalRenderContext rcontext,
178:                    HttpServletRequest req, Session session, Site site,
179:                    SitePage page, String toolContextPath, String portalPrefix)
180:                    throws IOException {
181:                if (rcontext.uses(INCLUDE_PAGE_NAV)) {
182:
183:                    includePageList(
184:                            rcontext,
185:                            req,
186:                            session,
187:                            site,
188:                            page,
189:                            toolContextPath,
190:                            portalPrefix,
191:                            /* doPages */true,
192:                            /* resetTools */"true"
193:                                    .equals(ServerConfigurationService
194:                                            .getString(Portal.CONFIG_AUTO_RESET)),
195:                            /* includeSummary */false);
196:
197:                }
198:
199:            }
200:
201:            protected void includePageList(PortalRenderContext rcontext,
202:                    HttpServletRequest req, Session session, Site site,
203:                    SitePage page, String toolContextPath, String portalPrefix,
204:                    boolean doPages, boolean resetTools, boolean includeSummary)
205:                    throws IOException {
206:                if (rcontext.uses(INCLUDE_PAGE_NAV)) {
207:
208:                    boolean loggedIn = session.getUserId() != null;
209:
210:                    String pageUrl = Web.returnUrl(req, "/"
211:                            + portalPrefix
212:                            + "/"
213:                            + Web
214:                                    .escapeUrl(siteHelper
215:                                            .getSiteEffectiveId(site))
216:                            + "/page/");
217:                    String toolUrl = Web.returnUrl(req, "/"
218:                            + portalPrefix
219:                            + "/"
220:                            + Web
221:                                    .escapeUrl(siteHelper
222:                                            .getSiteEffectiveId(site)));
223:                    if (resetTools) {
224:                        toolUrl = toolUrl + "/tool-reset/";
225:                    } else {
226:                        toolUrl = toolUrl + "/tool/";
227:                    }
228:
229:                    String pagePopupUrl = Web.returnUrl(req, "/page/");
230:                    boolean showHelp = ServerConfigurationService.getBoolean(
231:                            "display.help.menu", true);
232:                    String iconUrl = site.getIconUrlFull();
233:                    boolean published = site.isPublished();
234:                    String type = site.getType();
235:
236:                    rcontext
237:                            .put("pageNavPublished", Boolean.valueOf(published));
238:                    rcontext.put("pageNavType", type);
239:                    rcontext.put("pageNavIconUrl", iconUrl);
240:                    // rcontext.put("pageNavSitToolsHead",
241:                    // Web.escapeHtml(rb.getString("sit_toolshead")));
242:
243:                    // order the pages based on their tools and the tool order for the
244:                    // site type
245:                    // List pages = site.getOrderedPages();
246:                    List pages = siteHelper.getPermittedPagesInOrder(site);
247:
248:                    List<Map> l = new ArrayList<Map>();
249:                    for (Iterator i = pages.iterator(); i.hasNext();) {
250:
251:                        SitePage p = (SitePage) i.next();
252:                        List pTools = p.getTools();
253:
254:                        boolean current = (page != null
255:                                && p.getId().equals(page.getId()) && !p
256:                                .isPopUp());
257:                        String pagerefUrl = pageUrl + Web.escapeUrl(p.getId());
258:                        if (resetTools) {
259:                            pagerefUrl = pagerefUrl.replaceFirst("/"
260:                                    + portalPrefix + "/", "/" + portalPrefix
261:                                    + "-reset/");
262:                        }
263:
264:                        if (doPages || p.isPopUp()) {
265:                            Map<String, Object> m = new HashMap<String, Object>();
266:                            m.put("isPage", Boolean.valueOf(true));
267:                            m.put("current", Boolean.valueOf(current));
268:                            m.put("ispopup", Boolean.valueOf(p.isPopUp()));
269:                            m.put("pagePopupUrl", pagePopupUrl);
270:                            m.put("pageTitle", Web.escapeHtml(p.getTitle()));
271:                            m.put("jsPageTitle", Web.escapeJavascript(p
272:                                    .getTitle()));
273:                            m.put("pageId", Web.escapeUrl(p.getId()));
274:                            m.put("jsPageId", Web.escapeJavascript(p.getId()));
275:                            m.put("pageRefUrl", pagerefUrl);
276:                            if (includeSummary)
277:                                siteHelper.summarizePage(m, site, p);
278:                            l.add(m);
279:                            continue;
280:                        }
281:
282:                        // Loop through the tools again and Unroll the tools
283:                        Iterator iPt = pTools.iterator();
284:
285:                        while (iPt.hasNext()) {
286:                            ToolConfiguration placement = (ToolConfiguration) iPt
287:                                    .next();
288:
289:                            String toolrefUrl = toolUrl
290:                                    + Web.escapeUrl(placement.getId());
291:
292:                            Map<String, Object> m = new HashMap<String, Object>();
293:                            m.put("isPage", Boolean.valueOf(false));
294:                            m.put("toolId", Web.escapeUrl(placement.getId()));
295:                            m.put("jsToolId", Web.escapeJavascript(placement
296:                                    .getId()));
297:                            m.put("toolRegistryId", placement.getToolId());
298:                            m.put("toolTitle", Web.escapeHtml(placement
299:                                    .getTitle()));
300:                            m.put("jsToolTitle", Web.escapeJavascript(placement
301:                                    .getTitle()));
302:                            m.put("toolrefUrl", toolrefUrl);
303:                            l.add(m);
304:                        }
305:
306:                    }
307:                    rcontext.put("pageNavTools", l);
308:
309:                    String helpUrl = ServerConfigurationService
310:                            .getHelpUrl(null);
311:                    rcontext.put("pageNavShowHelp", Boolean.valueOf(showHelp));
312:                    rcontext.put("pageNavHelpUrl", helpUrl);
313:
314:                    // rcontext.put("pageNavSitContentshead",
315:                    // Web.escapeHtml(rb.getString("sit_contentshead")));
316:
317:                    // Handle Presense
318:                    boolean showPresence = ServerConfigurationService
319:                            .getBoolean("display.users.present", true);
320:                    String presenceUrl = Web.returnUrl(req, "/presence/"
321:                            + Web.escapeUrl(site.getId()));
322:
323:                    // rcontext.put("pageNavSitPresenceTitle",
324:                    // Web.escapeHtml(rb.getString("sit_presencetitle")));
325:                    // rcontext.put("pageNavSitPresenceFrameTitle",
326:                    // Web.escapeHtml(rb.getString("sit_presenceiframetit")));
327:                    rcontext.put("pageNavShowPresenceLoggedIn", Boolean
328:                            .valueOf(showPresence && loggedIn));
329:                    rcontext.put("pageNavPresenceUrl", presenceUrl);
330:                }
331:
332:            }
333:
334:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.