Source Code Cross Referenced for ChannelDefinition.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 2001, 2002 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.Collections;
009:        import java.util.Date;
010:        import java.util.HashMap;
011:        import java.util.Hashtable;
012:        import java.util.Iterator;
013:        import java.util.Map;
014:
015:        import org.apache.commons.logging.Log;
016:        import org.apache.commons.logging.LogFactory;
017:        import org.jasig.portal.channels.portlet.IPortletAdaptor;
018:        import org.w3c.dom.Document;
019:        import org.w3c.dom.Element;
020:
021:        /**
022:         * Describes a published channel.
023:         * @author George Lindholm, ITServices, UBC
024:         * @version $Revision: 42289 $ $Date: 2007-08-06 13:44:24 -0700 (Mon, 06 Aug 2007) $
025:         */
026:        public class ChannelDefinition implements  IBasicEntity {
027:            private static final Log log = LogFactory
028:                    .getLog(ChannelDefinition.class);
029:            private int id;
030:            private String chanFName;
031:            private String chanName;
032:            private String chanDesc;
033:            private String chanTitle;
034:            private String chanClass;
035:            private int chanTimeout;
036:            private int chanTypeId;
037:            private int chanPupblUsrId;
038:            private int chanApvlId;
039:            private Date chanPublDt;
040:            private Date chanApvlDt;
041:            private boolean chanEditable;
042:            private boolean chanHasHelp;
043:            private boolean chanHasAbout;
044:            private boolean chanIsSecure;
045:            private Map parameters; // Consider implementing as a Set
046:            private String chanLocale;
047:            private Hashtable chanDescs;
048:            private Hashtable chanTitles;
049:            private Hashtable chanNames;
050:
051:            /**
052:             * Constructs a channel definition.
053:             * @param id the channel definition ID
054:             */
055:            public ChannelDefinition(int id) {
056:                this .id = id;
057:                this .chanTitle = "";
058:                this .chanDesc = "";
059:                this .chanClass = "";
060:                this .parameters = new HashMap();
061:                this .chanLocale = null;
062:                this .chanTitles = new Hashtable();
063:                this .chanNames = new Hashtable();
064:                this .chanDescs = new Hashtable();
065:            }
066:
067:            // Getter methods
068:            public int getId() {
069:                return id;
070:            }
071:
072:            public String getFName() {
073:                return chanFName;
074:            }
075:
076:            public String getName() {
077:                return chanName;
078:            }
079:
080:            public String getDescription() {
081:                return chanDesc;
082:            }
083:
084:            public String getTitle() {
085:                return chanTitle;
086:            }
087:
088:            public String getJavaClass() {
089:                return chanClass;
090:            }
091:
092:            public int getTimeout() {
093:                return chanTimeout;
094:            }
095:
096:            public int getTypeId() {
097:                return chanTypeId;
098:            }
099:
100:            public int getPublisherId() {
101:                return chanPupblUsrId;
102:            }
103:
104:            public int getApproverId() {
105:                return chanApvlId;
106:            }
107:
108:            public Date getPublishDate() {
109:                return chanPublDt;
110:            }
111:
112:            public Date getApprovalDate() {
113:                return chanApvlDt;
114:            }
115:
116:            public boolean isEditable() {
117:                return chanEditable;
118:            }
119:
120:            public boolean hasHelp() {
121:                return chanHasHelp;
122:            }
123:
124:            public boolean hasAbout() {
125:                return chanHasAbout;
126:            }
127:
128:            public boolean isSecure() {
129:                return chanIsSecure;
130:            }
131:
132:            /**
133:             * Returns true if this channel definition defines a portlet.
134:             * Returns false if this channel definition does not define a portlet or
135:             * whether this channel definition defines a portlet or not cannot be 
136:             * determined because this definition's channel class is not set or cannot
137:             * be loaded.
138:             * @return true if we know we're a portlet, false otherwise
139:             */
140:            public boolean isPortlet() {
141:
142:                /*
143:                 * We believe we are a portlet if the channel class implements 
144:                 * IPortletAdaptor.
145:                 */
146:
147:                if (this .chanClass != null) {
148:                    try {
149:                        Class channelClass = Class.forName(this .chanClass);
150:                        return IPortletAdaptor.class
151:                                .isAssignableFrom(channelClass);
152:                    } catch (ClassNotFoundException e) {
153:                        log.error("Unable to load class for name ["
154:                                + this .chanClass
155:                                + "] and so do not know whether is a portlet.");
156:                    }
157:                }
158:
159:                return false;
160:            }
161:
162:            public ChannelParameter[] getParameters() {
163:                return (ChannelParameter[]) parameters.values().toArray(
164:                        new ChannelParameter[0]);
165:            }
166:
167:            public ChannelParameter getParameter(String key) {
168:                return (ChannelParameter) parameters.get(key);
169:            }
170:
171:            public Map getParametersAsUnmodifiableMap() {
172:                return Collections.unmodifiableMap(parameters);
173:            }
174:
175:            public String getLocale() {
176:                return chanLocale;
177:            }
178:
179:            // I18n
180:            public String getName(String locale) {
181:                String chanName = (String) chanNames.get(locale);
182:                if (chanName == null) {
183:                    return this .chanName; // fallback on "en_US"
184:                } else {
185:                    return chanName;
186:                }
187:            }
188:
189:            public String getDescription(String locale) {
190:                /*
191:                return chanDesc;
192:                 */
193:                String chanDesc = (String) chanDescs.get(locale);
194:                if (chanDesc == null) {
195:                    return this .chanDesc; // fallback on "en_US"
196:                } else {
197:                    return chanDesc;
198:                }
199:            }
200:
201:            public String getTitle(String locale) {
202:                /*
203:                return chanTitle;
204:                 */
205:                String chanTitle = (String) chanTitles.get(locale);
206:                if (chanTitle == null) {
207:                    return this .chanTitle; // fallback on "en_US"
208:                } else {
209:                    return chanTitle;
210:                }
211:            }
212:
213:            // Setter methods
214:            public void setFName(String fname) {
215:                this .chanFName = fname;
216:            }
217:
218:            public void setName(String name) {
219:                this .chanName = name;
220:            }
221:
222:            public void setDescription(String descr) {
223:                this .chanDesc = descr;
224:            }
225:
226:            public void setTitle(String title) {
227:                this .chanTitle = title;
228:            }
229:
230:            public void setJavaClass(String javaClass) {
231:                this .chanClass = javaClass;
232:            }
233:
234:            public void setTimeout(int timeout) {
235:                this .chanTimeout = timeout;
236:            }
237:
238:            public void setTypeId(int typeId) {
239:                this .chanTypeId = typeId;
240:            }
241:
242:            public void setPublisherId(int publisherId) {
243:                this .chanPupblUsrId = publisherId;
244:            }
245:
246:            public void setApproverId(int approvalId) {
247:                this .chanApvlId = approvalId;
248:            }
249:
250:            public void setPublishDate(Date publishDate) {
251:                this .chanPublDt = publishDate;
252:            }
253:
254:            public void setApprovalDate(Date approvalDate) {
255:                this .chanApvlDt = approvalDate;
256:            }
257:
258:            public void setEditable(boolean editable) {
259:                this .chanEditable = editable;
260:            }
261:
262:            public void setHasHelp(boolean hasHelp) {
263:                this .chanHasHelp = hasHelp;
264:            }
265:
266:            public void setHasAbout(boolean hasAbout) {
267:                this .chanHasAbout = hasAbout;
268:            }
269:
270:            public void setIsSecure(boolean isSecure) {
271:                this .chanIsSecure = isSecure;
272:            }
273:
274:            public void setLocale(String locale) {
275:                if (locale != null)
276:                    this .chanLocale = locale;
277:            }
278:
279:            public void clearParameters() {
280:                this .parameters.clear();
281:            }
282:
283:            public void setParameters(ChannelParameter[] parameters) {
284:                for (int i = 0; i < parameters.length; i++) {
285:                    this .parameters.put(parameters[i].getName(), parameters[i]);
286:                }
287:            }
288:
289:            public void replaceParameters(ChannelParameter[] parameters) {
290:                clearParameters();
291:                setParameters(parameters);
292:            }
293:
294:            public void putChanTitles(String locale, String chanTitle) {
295:                chanTitles.put(locale, chanTitle);
296:            }
297:
298:            public void putChanNames(String locale, String chanName) {
299:                chanNames.put(locale, chanName);
300:            }
301:
302:            public void putChanDescs(String locale, String chanDesc) {
303:                chanDescs.put(locale, chanDesc);
304:            }
305:
306:            /**
307:             * Implementation required by IBasicEntity interface.
308:             * @return EntityIdentifier
309:             */
310:            public EntityIdentifier getEntityIdentifier() {
311:                return new EntityIdentifier(String.valueOf(id),
312:                        ChannelDefinition.class);
313:            }
314:
315:            /**
316:             * Adds a parameter to this channel definition
317:             * @param parameter the channel parameter to add
318:             */
319:            public void addParameter(ChannelParameter parameter) {
320:                parameters.put(parameter.getName(), parameter);
321:            }
322:
323:            /**
324:             * Adds a parameter to this channel definition
325:             * @param name the channel parameter name
326:             * @param value the channel parameter value
327:             * @param override the channel parameter override setting
328:             */
329:            public void addParameter(String name, String value, String override) {
330:                parameters.put(name, new ChannelParameter(name, value,
331:                        RDBMServices.dbFlag(override)));
332:            }
333:
334:            /**
335:             * Removes a parameter from this channel definition
336:             * @param parameter the channel parameter to remove
337:             */
338:            public void removeParameter(ChannelParameter parameter) {
339:                removeParameter(parameter.getName());
340:            }
341:
342:            /**
343:             * Removes a parameter from this channel definition
344:             * @param name the parameter name
345:             */
346:            public void removeParameter(String name) {
347:                parameters.remove(name);
348:            }
349:
350:            /**
351:             * Get an Element expressing the minimum attributes necessary to represent
352:             * a channel.
353:             * @param doc Document that will be the owner of the Element returned
354:             * @param idTag Value of the identifier for the channel
355:             * @param chanClassArg fully qualified class name of the channel
356:             * @param editable true if the channel handles the Edit event
357:             * @param hasHelp true if the channel handles the Help event
358:             * @param hasAbout true if the channel handles the About event 
359:             * @return Element representing the channel
360:             */
361:            private Element getBase(Document doc, String idTag,
362:                    String chanClassArg, boolean editable, boolean hasHelp,
363:                    boolean hasAbout) {
364:                Element channel = doc.createElement("channel");
365:
366:                // the ID attribute is the identifier for the Channel element
367:                channel.setAttribute("ID", idTag);
368:                channel.setIdAttribute("ID", true);
369:
370:                channel.setAttribute("chanID", this .id + "");
371:                channel.setAttribute("timeout", this .chanTimeout + "");
372:                if (this .chanLocale != null) {
373:                    channel.setAttribute("name", getName(this .chanLocale));
374:                    channel.setAttribute("title", getTitle(this .chanLocale));
375:                    channel.setAttribute("locale", this .chanLocale);
376:                } else {
377:                    channel.setAttribute("name", this .chanName);
378:                    channel.setAttribute("title", this .chanTitle);
379:                }
380:                channel.setAttribute("fname", this .chanFName);
381:
382:                // chanClassArg is so named to highlight that we are using the argument
383:                // to the method rather than the instance variable chanClass
384:                channel.setAttribute("class", chanClassArg);
385:                channel.setAttribute("typeID", this .chanTypeId + "");
386:                channel.setAttribute("editable", editable ? "true" : "false");
387:                channel.setAttribute("hasHelp", hasHelp ? "true" : "false");
388:                channel.setAttribute("hasAbout", hasAbout ? "true" : "false");
389:                channel.setAttribute("secure", this .chanIsSecure ? "true"
390:                        : "false");
391:                channel.setAttribute("isPortlet", Boolean.valueOf(
392:                        this .isPortlet()).toString());
393:
394:                return channel;
395:            }
396:
397:            private final Element nodeParameter(Document doc, String name,
398:                    int value) {
399:                return nodeParameter(doc, name, Integer.toString(value));
400:            }
401:
402:            private final Element nodeParameter(Document doc, String name,
403:                    String value) {
404:                Element parameter = doc.createElement("parameter");
405:                parameter.setAttribute("name", name);
406:                parameter.setAttribute("value", value);
407:                return parameter;
408:            }
409:
410:            private final void addParameters(Document doc, Element channel) {
411:                if (parameters != null) {
412:                    Iterator iter = parameters.values().iterator();
413:                    while (iter.hasNext()) {
414:                        ChannelParameter cp = (ChannelParameter) iter.next();
415:
416:                        Element parameter = nodeParameter(doc, cp.name,
417:                                cp.value);
418:                        if (cp.override) {
419:                            parameter.setAttribute("override", "yes");
420:                        } else {
421:                            parameter.setAttribute("override", "no");
422:                        }
423:                        channel.appendChild(parameter);
424:                    }
425:                }
426:            }
427:
428:            /**
429:             * Display a message where this channel should be
430:             */
431:            public Element getDocument(Document doc, String idTag,
432:                    String statusMsg, int errorId) {
433:                Element channel = getBase(doc, idTag,
434:                        "org.jasig.portal.channels.CError", false, false, false);
435:                addParameters(doc, channel);
436:                channel.appendChild(nodeParameter(doc, "CErrorMessage",
437:                        statusMsg));
438:                channel.appendChild(nodeParameter(doc, "CErrorChanId", idTag));
439:                channel
440:                        .appendChild(nodeParameter(doc, "CErrorErrorId",
441:                                errorId));
442:                return channel;
443:            }
444:
445:            /**
446:             * return an xml representation of this channel
447:             */
448:            public Element getDocument(Document doc, String idTag) {
449:                Element channel = getBase(doc, idTag, chanClass, chanEditable,
450:                        chanHasHelp, chanHasAbout);
451:                channel.setAttribute("description", chanDesc);
452:                addParameters(doc, channel);
453:                return channel;
454:            }
455:
456:            /**
457:             * Is it time to reload me from the data store
458:             */
459:            public boolean refreshMe() {
460:                return false;
461:            }
462:
463:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.