Source Code Cross Referenced for ChannelStaticData.java in  » Portal » uPortal_rel-2-6-1-GA » org » jasig » portal » 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 » uPortal_rel 2 6 1 GA » org.jasig.portal 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /* Copyright 2000 The JA-SIG Collaborative.  All rights reserved.
002:         *  See license distributed with this file and
003:         *  available online at http://www.uportal.org/license.html
004:         */
005:
006:        package org.jasig.portal;
007:
008:        import java.util.Hashtable;
009:        import java.util.Iterator;
010:        import java.util.Map;
011:        import java.util.Map.Entry;
012:
013:        import javax.naming.Context;
014:
015:        import org.jasig.portal.layout.IUserLayoutManager;
016:        import org.jasig.portal.layout.node.IUserLayoutChannelDescription;
017:        import org.jasig.portal.security.IAuthorizationPrincipal;
018:        import org.jasig.portal.security.IPerson;
019:        import org.jasig.portal.services.AuthorizationService;
020:        import org.apache.commons.logging.Log;
021:        import org.apache.commons.logging.LogFactory;
022:
023:        /**
024:         * Used to store channel configuration items and parameters.
025:         * @author Ken Weiner, Peter Kharchenko
026:         * @version $Revision: 36781 $
027:         * @author Peter Kharchenko  {@link <a href="mailto:pkharchenko@interactivebusiness.com"">pkharchenko@interactivebusiness.com"</a>}
028:         */
029:        public class ChannelStaticData extends Hashtable {
030:
031:            private static final Log log = LogFactory
032:                    .getLog(ChannelStaticData.class);
033:
034:            private long m_timeout = java.lang.Long.MAX_VALUE;
035:            // Cache a reference to the portal's JNDI context
036:            private Context m_portalContext = null;
037:            // This is the ID that globally identifies the channel as
038:            // it's defined during the publish time.
039:            private String m_channelPublishId = null;
040:            // This is the ID that locally identifies the channel in the user's layout
041:            // The id is determined at the subscribe time.
042:            private String m_channelSubscribeId = null;
043:            // Cache the IPerson
044:            private IPerson m_person = null;
045:            private ICCRegistry iccr = null;
046:            // reference to layout manager for persisting parameter changes
047:            private IUserLayoutManager ulm;
048:
049:            private String serializerName;
050:
051:            private IUserLayoutChannelDescription layoutChannelDescription = null;
052:
053:            // Cache the PermissionManager for this channel
054:            //  private PermissionManager m_permissionManager = null;
055:
056:            public ChannelStaticData() {
057:                this (null, null);
058:            }
059:
060:            /**
061:             * If support is being provided to update channel parameters then a Layout
062:             * Manager instance is required and the initial values of parameters must be
063:             * set here to forgo override checks. If a LayoutManager is had for
064:             * ChannelStaticData then setParameter() and setParameters() restrict
065:             * changing parameters that are not overrideable and hence can not be used to
066:             * inject the initial parameter values.
067:             *
068:             * @param parameters
069:             * @param ulm
070:             */
071:            public ChannelStaticData(Map parameters, IUserLayoutManager ulm) {
072:                if (parameters != null)
073:                    this .putAll(parameters);
074:                this .ulm = ulm;
075:            }
076:
077:            /**
078:             * Returns an instance of the IAuthorizationPrincipal for the IPerson
079:             * @return instance of the IAuthorizationPrincipal for the IPerson
080:             */
081:            public IAuthorizationPrincipal getAuthorizationPrincipal() {
082:                return getAuthorizationPrincipal(getPerson());
083:            }
084:
085:            /**
086:             * Returns an instance of the IAuthorizationPrincipal for the IPerson
087:             * @param person a IPerson instance
088:             * @return instance of the IAuthorizationPrincipal for the IPerson
089:             */
090:            public static IAuthorizationPrincipal getAuthorizationPrincipal(
091:                    IPerson person) {
092:                EntityIdentifier pid = person.getEntityIdentifier();
093:                IAuthorizationPrincipal ap = null;
094:                try {
095:                    ap = AuthorizationService.instance().newPrincipal(
096:                            pid.getKey(), pid.getType());
097:                } catch (AuthorizationException ae) {
098:                    log.error("Could not get authorization service: " + ae);
099:                }
100:                return ap;
101:            }
102:
103:            /**
104:             * Determine channel publish Id.
105:             *
106:             * @return channel's publish Id (defined at publish-time)
107:             */
108:            public String getChannelPublishId() {
109:                return (m_channelPublishId);
110:            }
111:
112:            /**
113:             * Gets the channel subscribe Id
114:             * @return the channel's Id (defined at subscribe-time)
115:             */
116:            public String getChannelSubscribeId() {
117:                return (m_channelSubscribeId);
118:            }
119:
120:            /**
121:             * Obtain a channel JNDI context
122:             * @return JNDI context
123:             */
124:            public Context getJNDIContext() {
125:                return m_portalContext;
126:            }
127:
128:            /**
129:             * Get information contained in a particular <param> element
130:             * @param key param name
131:             * @return param value
132:             */
133:            public synchronized String getParameter(String key) {
134:                return (String) super .get(key);
135:            }
136:
137:            /**
138:             * Provide information on the user the channel is serving
139:             * @return <code>IPerons</code> object.
140:             */
141:            public IPerson getPerson() {
142:                return (m_person);
143:            }
144:
145:            /**
146:             * Maximum time the channel will be allowed to spend in the rendering cycle.
147:             * @return timeout (in milliseconds) after which the channel thread will be killed.
148:             * Ideally, channels should monitor for this timeout and abort internal execution
149:             * if the rendering cycle takes too long.
150:             */
151:            public long getTimeout() {
152:                return (m_timeout);
153:            }
154:
155:            /**
156:             * Setter method for channel publish Id
157:             * @param channelPublishId channel publish Id (defined at a publish-time)
158:             */
159:            public void setChannelPublishId(String channelPublishId) {
160:                m_channelPublishId = channelPublishId;
161:            }
162:
163:            /**
164:             * Sets the channel subscribe Id
165:             * @param channelSubscribeId the channel subscribe Id
166:             */
167:            public void setChannelSubscribeId(String channelSubscribeId) {
168:                m_channelSubscribeId = channelSubscribeId;
169:            }
170:
171:            /**
172:             * Set channel JNDI context.
173:             *
174:             * @param c a <code>Context</code> value
175:             */
176:            public void setJNDIContext(Context c) {
177:                m_portalContext = c;
178:            }
179:
180:            /**
181:             * Set information contained in a channel <param>element Parameters are
182:             * strings!
183:             *
184:             * @param key
185:             *            param name
186:             * @param value
187:             *            param value
188:             * @throws IllegalChannelParameterOverrideException
189:             *             if key is not configured to be overrideable.
190:             */
191:            public String setParameter(String key, String value) {
192:                if (ulm == null) // nothing can be persisted so drop back to old way
193:                    return (String) super .put(key, value);
194:
195:                try {
196:                    if (getChannelDescription().canOverrideParameter(key))
197:                        return (String) super .put(key, value);
198:                    throw new IllegalChannelParameterOverrideException(key,
199:                            value);
200:                } catch (PortalException pe) {
201:                    // can't get channel description so fall back to old way
202:                }
203:                return (String) super .put(key, value);
204:            }
205:
206:            /**
207:             * Returns true if the indicated parameter can be altered. Ad-hoc added
208:             * parameters will always be allowed to change. Parameters locked during
209:             * publishing or via the plugged-in layout manager will return false. If no
210:             * layout manager is available then this method always returns true.
211:             *
212:             * @param key
213:             * @return boolean
214:             */
215:            public boolean canSetParameter(String key) throws PortalException {
216:                if (ulm == null) // can't tell so everything is modifiable
217:                    return true;
218:
219:                if (getChannelDescription().canOverrideParameter(key))
220:                    return true;
221:                return false;
222:            }
223:
224:            private IUserLayoutChannelDescription getChannelDescription()
225:                    throws PortalException {
226:                if (layoutChannelDescription == null) {
227:                    layoutChannelDescription = (IUserLayoutChannelDescription) ulm
228:                            .getNode(getChannelSubscribeId());
229:                }
230:                return layoutChannelDescription;
231:            }
232:
233:            /**
234:             * Resets the value of this parameter. If this is an overrideable parameter
235:             * then a user's override will be removed and the original value restored.
236:             * If this is a non-overrideable parameter this call will have no effect. If
237:             * this is an ad-hoc parameter then the parameter will be removed. Ad-hoc
238:             * parameters are ones added by a channel instance beyond the set of
239:             * parameters specified during channel publishing.
240:             *
241:             * @param key
242:             *            param name
243:             */
244:            public void resetParameter(String key) {
245:                if (ulm == null) // nothing can be persisted so follow old approach
246:                {
247:                    super .remove(key);
248:                    return;
249:                }
250:
251:                try {
252:                    getChannelDescription().resetParameter(key);
253:                    String value = getChannelDescription().getParameterValue(
254:                            key);
255:                    if (value == null) // ad-hoc parm so delete
256:                        super .remove(key);
257:                    else
258:                        // not ad-hoc so value was replaced with channel def value
259:                        super .put(key, value);
260:                } catch (PortalException pe) {
261:                    // can't get channel description so fall back to old way of just
262:                    // changing parameters as needed.
263:                    super .remove(key);
264:                }
265:            }
266:
267:            /**
268:             * Writes all string valued parameters to the database as part of the user's
269:             * layout.
270:             */
271:            public void store() throws PortalException {
272:                if (ulm == null)
273:                    return;
274:
275:                IUserLayoutChannelDescription cd = getChannelDescription();
276:
277:                for (Iterator itr = this .entrySet().iterator(); itr.hasNext();) {
278:                    Map.Entry parm = (Entry) itr.next();
279:                    cd.setParameterValue((String) parm.getKey(), (String) parm
280:                            .getValue());
281:                }
282:                ulm.updateNode(cd);
283:                ulm.saveUserLayout();
284:                layoutChannelDescription = null; // force a reload next time
285:            }
286:
287:            /**
288:             * Copy parameter list from a Map
289:             *
290:             * @param params
291:             *            a map of params
292:             * @throws IllegalChannelParameterOverrideException
293:             *             if key is not configured to be overrideable.
294:             */
295:            public void setParameters(Map params) {
296:                if (ulm == null) // nothing can be persisted so drop back to old way
297:                    putAll(params);
298:
299:                try {
300:                    IUserLayoutChannelDescription cd = getChannelDescription();
301:                    for (Iterator itr = params.entrySet().iterator(); itr
302:                            .hasNext();) {
303:                        Map.Entry e = (Entry) itr.next();
304:                        if (!cd.canOverrideParameter((String) e.getKey()))
305:                            throw new IllegalChannelParameterOverrideException(
306:                                    (String) e.getKey(), (String) e.getValue());
307:                    }
308:                } catch (PortalException pe) {
309:                    // if an exception occurs and we can't get channel description
310:                    // or all parameters are overrideable then accept all params
311:                }
312:                // Copy the map
313:                putAll(params);
314:            }
315:
316:            /**
317:             * Setter method for the user being served by the channel
318:             * @param person an <code>IPerson<code> value.
319:             */
320:            public void setPerson(IPerson person) {
321:                m_person = person;
322:            }
323:
324:            /**
325:             * Setter method for channel timeout.
326:             * @param value
327:             */
328:            public void setTimeout(long value) {
329:                m_timeout = value;
330:            }
331:
332:            /**
333:             * Obtain inter-channel communication registry object
334:             *
335:             * @return an <code>ICCRegistry</code> value
336:             */
337:            public ICCRegistry getICCRegistry() {
338:                return this .iccr;
339:            }
340:
341:            /**
342:             * Set inter-channel communication registry object
343:             *
344:             * @param registry an <code>ICCRegistry</code> value
345:             */
346:            public void setICCRegistry(ICCRegistry registry) {
347:                this .iccr = registry;
348:            }
349:
350:            public String toString() {
351:                StringBuffer sb = new StringBuffer();
352:
353:                sb.append("ChannelStaticData: ");
354:                sb.append("Channel Publish ID = [").append(
355:                        this .m_channelPublishId).append("] ");
356:                sb.append("Channel Subscribe ID = [").append(
357:                        this .m_channelSubscribeId).append("] ");
358:                sb.append("person= [").append(this .m_person).append("] ");
359:                return sb.toString();
360:            }
361:
362:            /**
363:             * Sets the serializer name.
364:             * @return serializerName
365:             */
366:            public String getSerializerName() {
367:                return serializerName;
368:            }
369:
370:            /**
371:             * Setter method for the serializer name.
372:             * @param serializerName
373:             */
374:            public void setSerializerName(String serializerName) {
375:                this.serializerName = serializerName;
376:            }
377:
378:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.