Source Code Cross Referenced for ContainerProviderAdapter.java in  » Portal » Open-Portal » com » sun » portal » providers » containers » 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.providers.containers 
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 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.providers.containers;
014:
015:        import java.util.List;
016:        import java.util.Iterator;
017:        import java.util.Map;
018:        import java.util.logging.Level;
019:        import java.util.logging.LogRecord;
020:        import java.util.logging.Logger;
021:
022:        import com.sun.portal.providers.ProfileProviderAdapter;
023:        import com.sun.portal.providers.context.ProviderContext;
024:        import com.sun.portal.providers.context.ContainerProviderContext;
025:        import com.sun.portal.providers.context.ProviderContextException;
026:        import com.sun.portal.providers.ProviderException;
027:        import com.sun.portal.providers.Provider;
028:
029:        import com.sun.portal.desktop.DesktopRequestThreadLocalizer;
030:        import com.sun.portal.log.common.PortalLogger;
031:
032:        // Code in this class is duplicated in JSPContainerProviderAdapter.  Changes
033:        // applied to this class should also be considered for
034:        // JSPContainerProviderAdapter.
035:
036:        /**
037:         * This class provides default implementations of methods in the
038:         * ContainerProvider
039:         * interface implemented using a containerProviderContext object as the
040:         * persistent store.
041:         *
042:         * For method details, see the descriptions in the <code>Provider</code>
043:         * interface.
044:         *
045:         * @see com.sun.portal.providers.context.ContainerProviderContext
046:         * @see com.sun.portal.providers.Provider
047:         */
048:        public class ContainerProviderAdapter extends ProfileProviderAdapter
049:                implements  ContainerProvider {
050:
051:            private static Logger logger = PortalLogger
052:                    .getLogger(ContainerProviderAdapter.class);
053:
054:            /**
055:             * Gets the <code>ContainerProviderContext</code> for the container provider.
056:             *
057:             * @return <code>ContainerProviderContext</code>.
058:             *
059:             * @see com.sun.portal.providers.context.ContainerProviderContext
060:             *
061:             */
062:            public ContainerProviderContext getContainerProviderContext()
063:                    throws ProviderException {
064:                ProviderContext pc = getProviderContext();
065:
066:                if (!(pc instanceof  ContainerProviderContext)) {
067:                    throw new ProviderException(
068:                            "ContainerProviderAdapter.getContainerProviderContext(): "
069:                                    + "not a container provider context");
070:                }
071:
072:                return (ContainerProviderContext) pc;
073:            }
074:
075:            public List getSelectedChannels() throws ProviderException {
076:                try {
077:                    return getContainerProviderContext().getSelectedChannels(
078:                            getName());
079:                } catch (ProviderContextException pce) {
080:                    throw new ProviderException(
081:                            "ContainerProviderAdapter.getSelectedChannels(): ",
082:                            pce);
083:                }
084:            }
085:
086:            public List getAvailableChannels() throws ProviderException {
087:                try {
088:                    return getContainerProviderContext().getAvailableChannels(
089:                            getName());
090:                } catch (ProviderContextException pce) {
091:                    throw new ProviderException(
092:                            "ContainerProviderAdapter.getAvailableChannels(): ",
093:                            pce);
094:                }
095:            }
096:
097:            /**
098:             * Gets the list of available and user defined channel names.
099:             *
100:             * Available Channels are channels that are available to be added to the portal page.
101:             * User Defined Channels are channels the user has created.
102:             *
103:             * @return The list of available and user defined channel names, a list of string names.
104:             *
105:             * @exception ProviderException If the list of channel names cannot be returned.
106:             */
107:            public List getAvailableAndUserDefinedChannels()
108:                    throws ProviderException {
109:                try {
110:                    List availableChannels = getAvailableChannels();
111:                    Map userDefinedChannels = getProviderContext()
112:                            .getCollectionProperty(getName(),
113:                                    "userDefinedChannels");
114:
115:                    // Remove all elements from availableChannels contained in userDefinedChannels collection.
116:                    availableChannels.removeAll(userDefinedChannels.values());
117:
118:                    // Add all elements from userDefinedChannels to availableChannels.
119:                    Iterator itr = userDefinedChannels.keySet().iterator();
120:                    while (itr.hasNext()) {
121:                        availableChannels.add((String) itr.next());
122:                    }
123:                    return availableChannels;
124:                } catch (ProviderContextException pce) {
125:                    throw new ProviderException(
126:                            "ContainerProviderAdapter.getAvailableAndUserDefinedChannels()",
127:                            pce);
128:                }
129:            }
130:
131:            public void setSelectedChannels(List sel) throws ProviderException {
132:                try {
133:                    getContainerProviderContext().setSelectedChannels(
134:                            getName(), sel);
135:                } catch (ProviderContextException pce) {
136:                    throw new ProviderException(
137:                            "ContainerProviderAdapter.setSelectedChannels(): ",
138:                            pce);
139:                }
140:            }
141:
142:            public void setAvailableChannels(List avail)
143:                    throws ProviderException {
144:                try {
145:                    getContainerProviderContext().setAvailableChannels(
146:                            getName(), avail);
147:                } catch (ProviderContextException pce) {
148:                    throw new ProviderException(
149:                            "ContainerProviderAdapter.getAvailableChannels(): ",
150:                            pce);
151:                }
152:            }
153:
154:            public long getRefreshTime() throws ProviderException {
155:
156:                String refreshTime = getStringProperty("refreshTime");
157:                long refreshTimelong = 0;
158:                if (refreshTime != null && refreshTime.length() != 0) {
159:                    return Long.parseLong(refreshTime);
160:                } else {
161:                    //calculate the refreshTime from selected channels
162:                    List selected = getSelectedChannels();
163:                    int size = selected.size();
164:                    for (int i = 0; i < size; i++) {
165:                        String channel = (String) selected.get(i);
166:                        Provider p = getContainerProviderContext().getProvider(
167:                                DesktopRequestThreadLocalizer.getRequest(),
168:                                getName(), channel);
169:                        if (p != null) {
170:                            try {
171:                                long rt = p.getRefreshTime();
172:                                if (i == 0) {
173:                                    refreshTimelong = rt;
174:                                } else {
175:                                    refreshTimelong = Math.min(refreshTimelong,
176:                                            rt);
177:                                }
178:                            } catch (ProviderException pe) {
179:                                if (logger.isLoggable(Level.SEVERE)) {
180:                                    LogRecord rec = new LogRecord(Level.SEVERE,
181:                                            "PSDT_CSPPC0001");
182:                                    rec.setLoggerName(logger.getName());
183:                                    String[] param = { channel };
184:                                    rec.setParameters(param);
185:                                    rec.setThrown(pe);
186:                                    logger.log(rec);
187:                                }
188:                            }
189:                        } else {
190:                            if (logger.isLoggable(Level.SEVERE))
191:                                logger.log(Level.SEVERE, "PSDT_CSPPC0002",
192:                                        channel);
193:                        }
194:                        if (refreshTimelong == 0) {
195:                            break;
196:                        } else {
197:                            continue;
198:                        }
199:                    }
200:
201:                    String[] param = { new Long(refreshTimelong).toString(),
202:                            getName() };
203:                    if (logger.isLoggable(Level.FINEST)) {
204:                        logger.log(Level.FINEST, "PSDT_CSPPC0003", param);
205:                    }
206:
207:                    return refreshTimelong;
208:                }
209:            }
210:
211:            /**
212:             * Gets the window state of the channel.
213:             *
214:             * This method is a default implementation of the ContainerProvider.getWindowState()
215:             * This method currently has no effect and just returns ProviderWindowStates.NOT_DEFINED.
216:             *
217:             * Subclasses that wish to allow getting a WindowState should
218:             * override this method.
219:             *
220:             * @param channelName channel for which the window state is requested.
221:             *
222:             * @return window state
223:             * @exception ProviderException
224:             * @see com.sun.portal.providers.containers.ProviderWindowStates#NOT_DEFINED
225:             */
226:            public int getWindowState(String channelName)
227:                    throws ProviderException {
228:                return ProviderWindowStates.NOT_DEFINED;
229:            }
230:
231:            /**
232:             * Sets the window state of a channel.
233:             *
234:             * This method is a default implementation of the ContainerProvider.setWindowState()
235:             * This method currently has no effect and just throws UnsupportedWindowStateException.
236:             *
237:             * Subclasses that wish to allow setting a WindowState should
238:             * override this method.
239:             * @param channelName channel for which the window state needs to be set
240:             * @param windowState The new window state
241:             *
242:             * @exception UnsupportedWindowStateException.
243:             */
244:            public void setWindowState(String channelName, int windowState)
245:                    throws UnsupportedWindowStateException {
246:                throw new UnsupportedWindowStateException(
247:                        "Setting a window state is not supported in the default impl of containerprovider");
248:            }
249:
250:            /**
251:             * Gets the supported window states.
252:             *
253:             * This method is a default implementation of the ContainerProvider.getSupportedWindowStates()
254:             * This method currently has no effect and just returns an integer array containing
255:             * ProviderWindowStates.NOT_DEFINED.
256:             *
257:             * Subclasses that wish to allow getting  supported WindowStates should
258:             * override this method.
259:             *
260:             * @return Supported Window States as an integer array.
261:             *
262:             * @exception ProviderException If the window states cannot be returned.
263:             *
264:             * @see com.sun.portal.providers.containers.ContainerProviderAdapter#getWindowState()
265:             * @see com.sun.portal.providers.containers.ContainerProviderAdapter#setWindowState()
266:             */
267:            public int[] getSupportedWindowStates() throws ProviderException {
268:                int[] winstates = new int[1];
269:                winstates[0] = ProviderWindowStates.NOT_DEFINED;
270:                return winstates;
271:            }
272:
273:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.