Source Code Cross Referenced for DSAMECommunityURLManagerImpl.java in  » Portal » Open-Portal » com » sun » portal » community » urlmanager » impl » 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 » Open Portal » com.sun.portal.community.urlmanager.impl 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * CommunityURLManager.java
003:         *
004:         * Created on May 17, 2005, 12:53 PM
005:         *
006:         * To change this template, choose Tools | Options and locate the template under
007:         * the Source Creation and Management node. Right-click the template and choose
008:         * Open. You can then make changes to the template in the Source Editor.
009:         */
010:
011:        package com.sun.portal.community.urlmanager.impl;
012:
013:        import javax.servlet.http.HttpServletRequest;
014:        import com.sun.portal.desktop.context.DesktopAppContext;
015:        import com.sun.portal.desktop.context.DesktopAppContextThreadLocalizer;
016:        import com.sun.portal.desktop.context.DesktopContext;
017:        import com.sun.portal.desktop.context.DesktopContextThreadLocalizer;
018:        import com.sun.portal.desktop.context.DSAMEMultiPortalConstants;
019:
020:        import com.sun.portal.desktop.DesktopParameters;
021:
022:        import com.sun.portal.community.urlmanager.CommunityURLManager;
023:        import com.sun.portal.community.CommunityContainerName;
024:        import com.sun.portal.community.CommunityFactory;
025:        import com.sun.portal.community.CommunityException;
026:        import com.sun.portal.community.CommunityId;
027:        import com.sun.portal.community.RoleId;
028:        import com.sun.portal.community.impl.TypeConverter;
029:
030:        import com.sun.portal.community.mc.ConfigTable.ConfigKey;
031:        import com.sun.portal.community.mc.CMCPrincipal;
032:        import com.sun.portal.community.mc.CMCRolePrincipal;
033:
034:        import java.util.Set;
035:        import java.util.HashSet;
036:        import java.util.Iterator;
037:        import java.util.Collections;
038:
039:        import java.net.URL;
040:        import java.net.MalformedURLException;
041:        import java.net.URLEncoder;
042:        import java.io.UnsupportedEncodingException;
043:
044:        /**
045:         * This class reads desktop service IS properties related to creating community URLs and creates those URLs.
046:         *
047:         */
048:        public class DSAMECommunityURLManagerImpl implements 
049:                CommunityURLManager {
050:
051:            /**
052:             * For a community, returns the desktop URL to that community for the user
053:             */
054:            public String getCommunityURL(HttpServletRequest request,
055:                    String userId, CommunityId cid) throws CommunityException {
056:
057:                return getCommunityURL(request, cid);
058:            }
059:
060:            /**
061:             * For a community, returns the desktop URL to that community for the current user
062:             */
063:            public String getCommunityURL(HttpServletRequest request,
064:                    CommunityId cid) throws CommunityException {
065:
066:                // get the community container        
067:                String communityContainer = new CommunityContainerName(cid)
068:                        .toString();
069:                String url = getCommunityURLInternal(request,
070:                        communityContainer);
071:
072:                url += "&" + getCurrentMembershipParameter(cid);
073:                return url;
074:
075:            }
076:
077:            /**
078:             * Returns the bookmarkable, readable, autologin, access URL to a community.
079:             */
080:            public String getCommunityAccessURL(HttpServletRequest request,
081:                    CommunityId cid) throws CommunityException {
082:                // deprecated - public api should take name only
083:                String idstring = cid.toString();
084:                String name = idstring.substring(idstring.indexOf("__") + 2); // assume ps can map name back to id (default is jdo)
085:                return getCommunityAccessURL(request, name);
086:            }
087:
088:            /**
089:             * Returns the bookmarkable, readable, autologin, access URL to a community.
090:             * Eg,  http://server/portal/dt?dt.community=blah for a named community
091:             * and, http://server/portal/dt?dt.community=     for the community home page
092:             */
093:            public String getCommunityAccessURL(HttpServletRequest request,
094:                    String communityName) throws CommunityException {
095:                boolean useold = false; // XXX config
096:                boolean namedCommunity = communityName != null
097:                        || communityName.length() > 0;
098:                if (useold) {
099:                    if (namedCommunity)
100:                        return getCommunityURL(request, new CommunityId("jdo",
101:                                communityName));
102:                    else {
103:                        return getCommunityHomeURL(request);
104:                    }
105:                }
106:                if (communityName == null)
107:                    communityName = "";
108:                DesktopContext dc = DesktopContextThreadLocalizer.get();
109:                String url = dc.getDesktopURL(request,
110:                        DesktopParameters.CURRENT_MEMBERSHIP + "="
111:                                + urlencode(communityName));
112:                return url;
113:            }
114:
115:            private String getCurrentMembershipParameter() {
116:                return getCurrentMembershipParameter(null);
117:            }
118:
119:            private String getCurrentMembershipParameter(CommunityId cid) {
120:                String membershipString = null;
121:
122:                if (cid == null) {
123:                    membershipString = DesktopParameters.CURRENT_MEMBERSHIP_VALUE_NONE;
124:                } else {
125:                    membershipString = cid.toString();
126:                }
127:                return DesktopParameters.CURRENT_MEMBERSHIP + "="
128:                        + membershipString;
129:            }
130:
131:            /**
132:             * returns the desktop URL to community home
133:             */
134:            public String getCommunityHomeURL(HttpServletRequest request) {
135:                String communityHomeContainer = getCommunityHomeContainer();
136:                return getCommunityURLInternal(request, communityHomeContainer)
137:                        + "&" + getCurrentMembershipParameter();
138:            }
139:
140:            /**
141:             * returns the desktop URL to community create
142:             */
143:            public String getCommunityCreateURL(HttpServletRequest request) {
144:
145:                String communityCreateContainer = getCommunityCreateContainer();
146:                return getCommunityURLInternal(request,
147:                        communityCreateContainer);
148:
149:            }
150:
151:            /**
152:             * Internal method to generate URLs
153:             */
154:            protected String getCommunityURLInternal(
155:                    HttpServletRequest request, String containerName) {
156:
157:                // get desktop url
158:                String desktopURL = getDesktopURL(request);
159:
160:                // get the getCommunityParentContainerURLParameter
161:                String communityParentURLParameter = getCommunityParentContainerURLParameter();
162:
163:                // calculate the separator
164:                String separator;
165:                if ((desktopURL.indexOf("&") > 0)
166:                        || (desktopURL.indexOf("?") > 0)) {
167:                    separator = "&";
168:                } else {
169:                    separator = "?";
170:                }
171:
172:                // concatenate it all
173:                // TODO: somewhere I need to encode this stuff TODO ...
174:                return desktopURL + separator + communityParentURLParameter
175:                        + "=" + containerName;
176:
177:            }
178:
179:            protected String getDesktopURL(HttpServletRequest request) {
180:                DesktopAppContext dac = DesktopAppContextThreadLocalizer.get();
181:                return dac.getDesktopURL(request);
182:            }
183:
184:            protected String getLoginURL() {
185:                DesktopContext dc = DesktopContextThreadLocalizer.get();
186:                return dc.getLoginURL();
187:            }
188:
189:            protected String getCommunityParentContainerURLParameter() {
190:                DSAMEMultiPortalConstants dmpc = DSAMEMultiPortalConstants
191:                        .getInstance();
192:                DesktopContext dc = DesktopContextThreadLocalizer.get();
193:                return dc
194:                        .getStringAttribute(dmpc.MP_ATTR_COMMUNITY_PARENT_CONTAINER_URL_PARAMETER);
195:            }
196:
197:            protected String getCommunityHomeContainer() {
198:                DSAMEMultiPortalConstants dmpc = DSAMEMultiPortalConstants
199:                        .getInstance();
200:                DesktopContext dc = DesktopContextThreadLocalizer.get();
201:                return dc
202:                        .getStringAttribute(dmpc.MP_ATTR_COMMUNITY_HOME_CONTAINER_NAME);
203:            }
204:
205:            protected String getCommunityCreateContainer() {
206:                DSAMEMultiPortalConstants dmpc = DSAMEMultiPortalConstants
207:                        .getInstance();
208:                DesktopContext dc = DesktopContextThreadLocalizer.get();
209:                return dc
210:                        .getStringAttribute(dmpc.MP_ATTR_COMMUNITY_CREATE_CONTAINER_NAME);
211:            }
212:
213:            private String urlencode(String s) {
214:                try {
215:                    return URLEncoder.encode(s, "UTF-8");
216:                } catch (Exception wonthappen) {
217:                }
218:                return s;
219:            }
220:
221:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.