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


001:        /*
002:         * Copyright 2004 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 Sun ONE 
010:         * are trademarks or registered trademarks of Sun Microsystems, 
011:         * Inc. in the United States and other countries. 
012:         */
013:        package com.sun.portal.taskadmin;
014:
015:        import java.util.Collections;
016:        import java.util.List;
017:        import java.util.Arrays;
018:        import java.util.ArrayList;
019:        import java.util.Iterator;
020:        import java.util.Map;
021:        import java.util.HashMap;
022:        import java.util.Set;
023:        import java.util.HashSet;
024:        import java.util.TreeSet;
025:        import java.util.StringTokenizer;
026:        import java.util.regex.PatternSyntaxException;
027:        import java.util.Locale;
028:        import java.util.ResourceBundle;
029:        import java.util.logging.Logger;
030:        import java.util.logging.Level;
031:
032:        import java.net.URL;
033:        import java.net.MalformedURLException;
034:        import java.io.*;
035:
036:        import javax.servlet.http.HttpServletRequest;
037:        import javax.servlet.http.HttpServletResponse;
038:
039:        import com.sun.portal.portletcontainercommon.PortletPreferencesUtility;
040:
041:        import com.sun.portal.taskadmin.ChannelTaskAdmin;
042:        import com.sun.portal.taskadmin.TaskAdminException;
043:        import com.sun.portal.taskadmin.TaskAdminConstants;
044:        import com.sun.portal.taskadmin.context.TaskAdminContext;
045:        import com.sun.portal.taskadmin.context.TaskAdminContextFactory;
046:        import com.sun.portal.taskadmin.context.TaskAdminContextFactoryManager;
047:
048:        import com.sun.portal.desktop.context.ContextError;
049:        import com.sun.portal.desktop.context.DPContext;
050:        import com.sun.portal.desktop.dp.*;
051:        import com.sun.portal.desktop.dp.xml.XMLDPFactory;
052:        import com.sun.portal.log.common.PortalLogger;
053:
054:        import com.iplanet.am.util.SystemProperties;
055:        import com.iplanet.sso.SSOToken;
056:
057:        /**
058:         * This class implements the APIs that can be used
059:         * to achieve a set of administrative tasks associated
060:         * with portlets.
061:         */
062:        public class PortletTaskAdmin extends ChannelTaskAdmin {
063:            private static String PORTLET_CLASS = "PortletWindowProvider";
064:            private static final String PORTLET_PREFIX = "__Portlet__";
065:            private static String PORTLET_PREFERENCE_PROPS = "__Portlet__PreferenceProperties";
066:            private static String PORTLET_PREFERENCE_READONLY = "isReadOnly";
067:
068:            // Create a logger for this class
069:            private static Logger debugLogger = PortalLogger
070:                    .getLogger(PortletTaskAdmin.class);
071:
072:            public PortletTaskAdmin(HttpServletRequest req, String baseDN)
073:                    throws TaskAdminException {
074:                super (req, baseDN);
075:            }
076:
077:            public PortletTaskAdmin(HttpServletRequest req, DPRoot dpRoot)
078:                    throws TaskAdminException {
079:                super (req, dpRoot);
080:            }
081:
082:            public PortletTaskAdmin(SSOToken ssoToken, DPRoot dpRoot)
083:                    throws TaskAdminException {
084:                super (ssoToken, dpRoot);
085:            }
086:
087:            public PortletTaskAdmin(SSOToken ssoToken, String baseDN,
088:                    String portalId) throws TaskAdminException {
089:                super (ssoToken, baseDN, portalId);
090:            }
091:
092:            /**
093:             * Creates a new portlet channel.
094:             * A new channel is created based on the named provider.
095:             * To create a nested channel, supply a hierarchical channel
096:             * name. For example, to create channel A inside of container X, based on
097:             * provider P at baseDN dc=iplanet,dc=com:<br><br>
098:             * <code>createChannel("dc=iplanet,dc=com", "X" + "/" + "A", "P");</code> 
099:             */
100:            public void createPortletChannel(String channelName,
101:                    String portletName) throws TaskAdminException {
102:                String providerName = getProviderName(portletName);
103:                createChannel(channelName, providerName);
104:            }
105:
106:            /**
107:             * This method returns the list of portlets that are existing 
108:             * at the baseDN that is passed in. The portletss in this list
109:             * can be used to create channels by the user that can administer 
110:             * the baseDN that is passed in. Always takes mergers into account.
111:             * @return Set of providers that are available at this baseDN.
112:             */
113:            public Set getExistingPortlets() throws TaskAdminException {
114:                DPNode currentNode = dpRoot;
115:                Set providers = getProviderNames(currentNode);
116:                Set portlets = new TreeSet();
117:                ;
118:                Iterator iter = providers.iterator();
119:                while (iter.hasNext()) {
120:                    String providername = (String) iter.next();
121:                    DPProvider provider = null;
122:                    String className = null;
123:                    synchronized (dpLock) {
124:                        provider = dpRoot.getProvider(providername);
125:
126:                        if (provider != null) {
127:                            className = provider.getClassName();
128:                        }
129:                    }
130:
131:                    // Check if class name ends with PortletWindowProvider to
132:                    // detemine if the class is a portlet
133:                    if (className == null || !className.endsWith(PORTLET_CLASS)) {
134:                        continue;
135:                    }
136:                    portlets.add(getPortletDisplayName(providername));
137:                }
138:                return portlets;
139:            }
140:
141:            public Set getPortletPreferenceNames(String portletName)
142:                    throws TaskAdminException {
143:                Set portletPrefs = null;
144:                DPChannel channel = getDPChannel(portletName);
145:                DPProvider provider = null;
146:                synchronized (dpLock) {
147:                    provider = channel.getProvider();
148:                    if (provider == null) {
149:                        debugLogger.log(Level.INFO, "PSPL_ADCSPT0001",
150:                                portletName);
151:                        Object[] tokens = { portletName };
152:                        throw new TaskAdminException(INVALID_PROVIDER, tokens);
153:                    }
154:                    DPProperties channelProperties = channel.getProperties();
155:                    DPProperties providerProperties = provider.getProperties();
156:
157:                    DPCollection channelPrefs = channelProperties
158:                            .getCollection(PORTLET_PREFERENCE_PROPS);
159:                    DPCollection providerPrefs = providerProperties
160:                            .getCollection(PORTLET_PREFERENCE_PROPS);
161:
162:                    DPCollection readOnlyPrefs = (DPCollection) channelPrefs
163:                            .get(PORTLET_PREFERENCE_READONLY);
164:                    if (readOnlyPrefs == null && providerPrefs != null) {
165:                        readOnlyPrefs = (DPCollection) providerPrefs
166:                                .get(PORTLET_PREFERENCE_READONLY);
167:                    }
168:                    if (readOnlyPrefs != null) {
169:                        portletPrefs = readOnlyPrefs.getNames();
170:                    } else {
171:                        portletPrefs = new TreeSet();
172:                    }
173:                }
174:                return portletPrefs;
175:            }
176:
177:            public String getPortletPreferenceStringValue(String portletName,
178:                    String prefName) throws TaskAdminException {
179:                String value = null;
180:                List values = getPortletPreferenceValues(portletName, prefName);
181:                if (values != null && !values.isEmpty()) {
182:                    value = (String) values.get(0);
183:                }
184:                return value;
185:            }
186:
187:            public List getPortletPreferenceValues(String portletName,
188:                    String prefName) throws TaskAdminException {
189:                String prefValue = null;
190:                String pref = PORTLET_PREFIX + prefName;
191:                DPChannel channel = getDPChannel(portletName);
192:                synchronized (dpLock) {
193:                    DPProperties channelProperties = channel.getProperties();
194:                    DPProperty property = channelProperties.get(pref, false);
195:                    if (property == null) {
196:                        DPProperties providerProperties = channel.getProvider()
197:                                .getProperties();
198:                        property = providerProperties.get(pref);
199:                    }
200:                    if (property == null) {
201:                        //preference doesn't exist.
202:                        Object[] tokens = { portletName, prefName };
203:                        throw new TaskAdminException(INVALID_PREFERENCE, tokens);
204:                    }
205:                    prefValue = property.getValue().toString();
206:                }
207:                return PortletPreferencesUtility.getPreferenceValues(prefValue);
208:            }
209:
210:            public void setPortletPreferenceStringValue(String portletName,
211:                    String prefName, String value) throws TaskAdminException {
212:                String[] values = { value };
213:                setPortletPreferenceValues(portletName, prefName, values);
214:            }
215:
216:            public void setPortletPreferenceValues(String portletName,
217:                    String prefName, String[] values) throws TaskAdminException {
218:                String value = PortletPreferencesUtility
219:                        .getPreferenceString(values);
220:                String pref = PORTLET_PREFIX + prefName;
221:                DPChannel channel = getDPChannel(portletName);
222:                synchronized (dpLock) {
223:                    DPProperties channelProperties = channel.getProperties();
224:                    DPProperty property = channelProperties.get(pref, false);
225:                    if (property == null) {
226:                        DPProperties providerProperties = channel.getProvider()
227:                                .getProperties();
228:                        property = providerProperties.get(pref);
229:                        if (property == null) {
230:                            //preference doesn't exist.
231:                            Object[] tokens = { portletName, prefName };
232:                            throw new TaskAdminException(INVALID_PREFERENCE,
233:                                    tokens);
234:                        }
235:                        property = channelProperties.add(property);
236:                    }
237:                    property.setValue(value);
238:                }
239:            }
240:
241:            public boolean isPortletChannel(String channelName)
242:                    throws TaskAdminException {
243:                boolean isPortlet = false;
244:                String classname = getClassName(channelName);
245:                if (classname != null && classname.endsWith(PORTLET_CLASS)) {
246:                    isPortlet = true;
247:                }
248:                return isPortlet;
249:            }
250:
251:            public Map getPortletPreferenceMap(String portletName)
252:                    throws TaskAdminException {
253:                Map prefMap = new HashMap();
254:                Set prefNames = null;
255:                DPChannel channel = getDPChannel(portletName);
256:                DPProvider provider = null;
257:                DPCollection readOnlyPrefs = null;
258:                synchronized (dpLock) {
259:                    provider = channel.getProvider();
260:                    if (provider == null) {
261:                        debugLogger.log(Level.INFO, "PSPL_ADCSPT0001",
262:                                portletName);
263:                        Object[] tokens = { portletName };
264:                        throw new TaskAdminException(INVALID_PROVIDER, tokens);
265:                    }
266:                    DPProperties channelProperties = channel.getProperties();
267:                    DPProperties providerProperties = provider.getProperties();
268:                    DPCollection channelPrefs = channelProperties
269:                            .getCollection(PORTLET_PREFERENCE_PROPS);
270:                    DPCollection providerPrefs = providerProperties
271:                            .getCollection(PORTLET_PREFERENCE_PROPS);
272:
273:                    readOnlyPrefs = (DPCollection) channelPrefs
274:                            .get(PORTLET_PREFERENCE_READONLY);
275:                    if (readOnlyPrefs == null && providerPrefs != null) {
276:                        readOnlyPrefs = (DPCollection) providerPrefs
277:                                .get(PORTLET_PREFERENCE_READONLY);
278:                    }
279:                    if (readOnlyPrefs != null) {
280:                        prefNames = readOnlyPrefs.getNames();
281:                    } else {
282:                        prefNames = new TreeSet();
283:                    }
284:                }
285:                Iterator i = prefNames.iterator();
286:                while (i.hasNext()) {
287:                    String prefName = (String) i.next();
288:                    List values = getPortletPreferenceValues(portletName,
289:                            prefName);
290:                    DPProperty readOnlyProp = readOnlyPrefs.get(prefName);
291:                    Boolean readOnly = (Boolean) readOnlyProp.getValue();
292:                    Map valueMap = new HashMap();
293:                    valueMap.put("values", values);
294:                    valueMap.put("isReadOnly", readOnly);
295:                    prefMap.put(prefName, valueMap);
296:                }
297:                return prefMap;
298:            }
299:
300:            private String getPortletDisplayName(String portletName) {
301:                if (portletName.startsWith(PORTLET_PREFIX)) {
302:                    return portletName.substring(PORTLET_PREFIX.length());
303:                } else {
304:                    return portletName;
305:                }
306:            }
307:
308:            private String getProviderName(String portletName) {
309:                return PORTLET_PREFIX + portletName;
310:            }
311:
312:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.