Source Code Cross Referenced for SharedServicesUtilsImpl.java in  » Portal » Open-Portal » com » sun » portal » app » calendarcommon » common » 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.app.calendarcommon.common 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**
002:         * Copyright 2002 Sun Microsystems, Inc. All
003:         * rights reserved. Use of this product is subject
004:         * to license terms. Federal Acquisitions:
005:         * Commercial Software -- Government Users
006:         * Subject to Standard License Terms and
007:         * Conditions.
008:         *
009:         * Sun, Sun Microsystems, the Sun logo, and iPlanet
010:         * are trademarks or registered trademarks of Sun Microsystems,
011:         * Inc. in the United States and other countries.
012:         */package com.sun.portal.app.calendarcommon.common;
013:
014:        import com.iplanet.sso.SSOToken;
015:        import com.sun.portal.app.calendarcommon.calendar.provisioning.SharedCalendarPortletProvisionListener;
016:        import com.sun.portal.community.CommunityFactory;
017:        import com.sun.portal.community.Community;
018:        import com.sun.portal.log.common.PortalLogger;
019:        import java.util.Set;
020:        import java.util.logging.Level;
021:        import java.util.logging.Logger;
022:        import javax.faces.context.FacesContext;
023:        import javax.portlet.PortletPreferences;
024:        import javax.portlet.PortletRequest;
025:        import javax.servlet.ServletContext;
026:
027:        /**
028:         * Dummy implementation of SharedServicesUtils for testing.
029:         *
030:         * @author    Nigel Jacobs
031:         * @created   May 19, 2005
032:         * 
033:         */
034:        public class SharedServicesUtilsImpl implements  SharedServicesUtils {
035:
036:            ServletContext _context;
037:
038:            private static Logger logger = PortalLogger
039:                    .getLogger(SharedCalendarPortletProvisionListener.class);
040:
041:            protected SharedServicesUtilsImpl(ServletContext context) {
042:                _context = context;
043:            }
044:
045:            /**
046:             * Get the community id.
047:             *
048:             * @param request
049:             * @throws com.sun.portal.app.SharedServices.common.SharedServicesException
050:             * @return community id.
051:             */
052:            public String getCommunityID(PortletRequest request)
053:                    throws SharedServicesException {
054:                //TESTING: REPLACE
055:                //return getStringPreference(request, "bookmarkHelpPage");
056:                return getStringPreference(request,
057:                        CommunityFactory.COMMUNITY_ID_PREF);
058:
059:            }
060:
061:            /**
062:             * Get the community id.
063:             *
064:             * @param context
065:             * @throws com.sun.portal.app.SharedServices.common.SharedServicesException
066:             * @return community id.
067:             */
068:            public String getCommunityID(FacesContext context)
069:                    throws SharedServicesException {
070:                Object request = context.getExternalContext().getRequest();
071:                if (request instanceof  PortletRequest) {
072:                    return getCommunityID((PortletRequest) request);
073:                } else {
074:                    throw new SharedServicesException(
075:                            "Can't getCommunityID: only supporting Portlet environment.");
076:                }
077:            }
078:
079:            /**
080:             * Get the ids of all the members of the community, as a set of Strings.
081:             *
082:             * @param request
083:             * @return member id Strings.
084:             */
085:            public synchronized Set getMemberIDs(PortletRequest request)
086:                    throws SharedServicesException {
087:
088:                try {
089:                    CommunityFactory cf = CommunityFactory.getInstance();
090:                    Community c = cf.getCommunity(request);
091:                    // TODO: restrict to only member role here?
092:                    Set members = c.getUsers();
093:
094:                    if (logger.isLoggable(Level.FINER)) {
095:                        logger.finer("members = " + members);
096:                    }
097:
098:                    return members;
099:                } catch (Exception ex) {
100:                    logger.log(Level.WARNING,
101:                            "Cant get member IDs for community: ", ex);
102:                    throw new SharedServicesException(
103:                            "Cant get member IDs for community: ", ex);
104:                }
105:
106:            }
107:
108:            /**
109:             * Get the ids of all the members of the community, as a set of Strings.
110:             *
111:             * @param context
112:             * @return member id Strings.
113:             */
114:            public synchronized Set getMemberIDs(FacesContext context)
115:                    throws SharedServicesException {
116:                Object request = context.getExternalContext().getRequest();
117:                if (request instanceof  PortletRequest) {
118:                    return getMemberIDs((PortletRequest) request);
119:                } else {
120:                    throw new SharedServicesException(
121:                            "Can't getMemberIDs: only supporting Portlet environment.");
122:                }
123:            }
124:
125:            /**
126:             * Get the current users community member id.
127:             *
128:             * @param request
129:             * @throws com.sun.portal.app.SharedServices.common.SharedServicesException
130:             * @return member id.
131:             */
132:            public String getCurrentMemberID(PortletRequest request)
133:                    throws SharedServicesException {
134:
135:                try {
136:                    SSOToken token = (SSOToken) request
137:                            .getAttribute(SSO_TOKEN_CONTEXT_ATTR);
138:                    if (token == null)
139:                        return null;
140:                    return token.getPrincipal().getName();
141:                } catch (Exception e) {
142:                    throw new SharedServicesException(
143:                            "Can't get SSOToken from portlet request", e);
144:                }
145:
146:            }
147:
148:            /**
149:             * Get the current users community member id.
150:             *
151:             * @param request
152:             * @throws com.sun.portal.app.SharedServices.common.SharedServicesException
153:             * @return member id.
154:             */
155:            public String getCurrentMemberID(FacesContext context)
156:                    throws SharedServicesException {
157:                Object request = context.getExternalContext().getRequest();
158:                if (request instanceof  PortletRequest) {
159:                    return getCurrentMemberID((PortletRequest) request);
160:                } else {
161:                    throw new SharedServicesException(
162:                            "Can't getCurrentMemberID: only supporting Portlet environment.");
163:                }
164:            }
165:
166:            /**
167:             * Clean up the resources.
168:             */
169:            public void destroy() {
170:
171:            }
172:
173:            private String getStringPreference(PortletRequest request,
174:                    String preference) {
175:                if (request == null) {
176:                    logger.warning("Request is null");
177:                    return null;
178:                }
179:                if (preference == null) {
180:                    logger.warning("Preference is null");
181:                    return null;
182:                }
183:                PortletPreferences prefs = request.getPreferences();
184:                if (prefs == null) {
185:                    logger.warning("Preferences is null");
186:                    return null;
187:                }
188:                return prefs.getValue(preference, null);
189:            }
190:
191:            /**
192:             * Get the URL of the community search server.
193:             * 
194:             * @param request 
195:             * @return url String
196:             * @throws com.sun.portal.app.SharedServices.common.SharedServicesException 
197:             */
198:            public String getSearchServerURL(PortletRequest request)
199:                    throws SharedServicesException {
200:                return getStringPreference(request, SEARCH_SERVER_URL_ATTR);
201:            }
202:
203:            /**
204:             * Get the URL of the community search server.
205:             * 
206:             * @param context 
207:             * @return url String
208:             * @throws com.sun.portal.app.SharedServices.common.SharedServicesException 
209:             */
210:            public String getSearchServerURL(FacesContext context)
211:                    throws SharedServicesException {
212:                Object request = context.getExternalContext().getRequest();
213:                if (request instanceof  PortletRequest) {
214:                    return getSearchServerURL((PortletRequest) request);
215:                } else {
216:                    throw new SharedServicesException(
217:                            "Can't getCommunityID: only supporting Portlet environment.");
218:                }
219:            }
220:
221:            /**
222:             * Get the community search database.
223:             * 
224:             * @param request 
225:             * @return database name
226:             * @throws com.sun.portal.app.SharedServices.common.SharedServicesException 
227:             */
228:            public String getSearchDatabase(PortletRequest request)
229:                    throws SharedServicesException {
230:                return getStringPreference(request, SEARCH_DB_ATTR);
231:            }
232:
233:            /**
234:             * Get the community search database.
235:             * 
236:             * @param context 
237:             * @return database name
238:             * @throws com.sun.portal.app.SharedServices.common.SharedServicesException 
239:             */
240:            public String getSearchDatabase(FacesContext context)
241:                    throws SharedServicesException {
242:                Object request = context.getExternalContext().getRequest();
243:                if (request instanceof  PortletRequest) {
244:                    return getSearchDatabase((PortletRequest) request);
245:                } else {
246:                    throw new SharedServicesException(
247:                            "Can't getCommunityID: only supporting Portlet environment.");
248:                }
249:            }
250:
251:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.