Source Code Cross Referenced for PortletApplicationDefinitionImpl.java in  » Portal » jetspeed-2.1.3 » org » apache » jetspeed » om » portlet » impl » 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 » jetspeed 2.1.3 » org.apache.jetspeed.om.portlet.impl 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Licensed to the Apache Software Foundation (ASF) under one or more
003:         * contributor license agreements.  See the NOTICE file distributed with
004:         * this work for additional information regarding copyright ownership.
005:         * The ASF licenses this file to You under the Apache License, Version 2.0
006:         * (the "License"); you may not use this file except in compliance with
007:         * the License.  You may obtain a copy of the License at
008:         * 
009:         *      http://www.apache.org/licenses/LICENSE-2.0
010:         * 
011:         * Unless required by applicable law or agreed to in writing, software
012:         * distributed under the License is distributed on an "AS IS" BASIS,
013:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014:         * See the License for the specific language governing permissions and
015:         * limitations under the License.
016:         */
017:
018:        package org.apache.jetspeed.om.portlet.impl;
019:
020:        import java.io.Serializable;
021:        import java.util.ArrayList;
022:        import java.util.Collection;
023:        import java.util.Collections;
024:        import java.util.HashMap;
025:        import java.util.Iterator;
026:        import java.util.List;
027:        import java.util.Map;
028:
029:        import javax.portlet.PortletMode;
030:        import javax.portlet.WindowState;
031:
032:        import org.apache.jetspeed.JetspeedActions;
033:        import org.apache.jetspeed.om.common.GenericMetadata;
034:        import org.apache.jetspeed.om.common.JetspeedServiceReference;
035:        import org.apache.jetspeed.om.common.Support;
036:        import org.apache.jetspeed.om.common.UserAttribute;
037:        import org.apache.jetspeed.om.common.UserAttributeRef;
038:        import org.apache.jetspeed.om.common.portlet.CustomPortletMode;
039:        import org.apache.jetspeed.om.common.portlet.CustomWindowState;
040:        import org.apache.jetspeed.om.common.portlet.MutablePortletApplication;
041:        import org.apache.jetspeed.om.common.portlet.PortletDefinitionComposite;
042:        import org.apache.jetspeed.om.impl.UserAttributeImpl;
043:        import org.apache.jetspeed.util.JetspeedLongObjectID;
044:        import org.apache.pluto.om.common.ObjectID;
045:        import org.apache.pluto.om.portlet.PortletDefinition;
046:        import org.apache.pluto.om.portlet.PortletDefinitionList;
047:        import org.apache.pluto.om.servlet.WebApplicationDefinition;
048:
049:        /**
050:         *
051:         * @author <a href="mailto:paulsp@apache.org">Paul Spencer</a>
052:         * @author <a href="mailto:weaver@apache.org">Scott T. Weaver</a>
053:         * @version $Id: PortletApplicationDefinitionImpl.java 553014 2007-07-03 23:10:53Z ate $
054:         * @since 1.0
055:         */
056:        public class PortletApplicationDefinitionImpl implements 
057:                MutablePortletApplication, Serializable, Support {
058:            /**
059:             * Unique id of the application.  This serves as the primary key in database
060:             * and in any caching of this object.
061:             */
062:            private Long id;
063:
064:            private JetspeedLongObjectID oid;
065:
066:            /** Holds value of property name. */
067:            private String name;
068:
069:            /** Holds value of property version. */
070:            private String version;
071:
072:            /** Holds the optional application identifier from the portlet.xml */
073:            private String applicationIdentifier;
074:
075:            /** WebApplication property */
076:            private transient WebApplicationDefinition webApplication;
077:            /** PK of this Portlet Application's Web Application */
078:            protected long webApplicationId;
079:
080:            /** Metadata property */
081:            private Collection metadataFields = null;
082:
083:            /** Metadata property */
084:            private Collection services = new ArrayList();
085:
086:            /** Description */
087:            private String description;
088:
089:            private Collection portlets;
090:
091:            /** User attribute refs collection. */
092:            private Collection userAttributeRefs;
093:
094:            /** User attributes collection. */
095:            private Collection userAttributes;
096:
097:            private PortletDefinitionListImpl listWrapper = new PortletDefinitionListImpl();
098:
099:            private int applicationType = MutablePortletApplication.WEBAPP;
100:
101:            private String checksum = "0";
102:            private long checksumLong = -1;
103:
104:            private List customPortletModes;
105:            private List customWindowStates;
106:
107:            private String jetspeedSecurityConstraint = null;
108:
109:            private transient Map supportedCustomModes;
110:            private transient Map supportedCustomStates;
111:            private transient Map mappedCustomModes;
112:            private transient Map mappedCustomStates;
113:            private transient Collection supportedPortletModes;
114:            private transient Collection supportedWindowStates;
115:
116:            /** Creates a new instance of BaseApplication */
117:            public PortletApplicationDefinitionImpl() {
118:                portlets = new ArrayList();
119:                userAttributes = new ArrayList();
120:                userAttributeRefs = new ArrayList();
121:                customPortletModes = new ArrayList();
122:                customWindowStates = new ArrayList();
123:            }
124:
125:            /**
126:             * @see org.apache.pluto.om.portlet.PortletApplicationDefinition#getId()
127:             */
128:            public ObjectID getId() {
129:                if (oid == null && id != null) {
130:                    oid = new JetspeedLongObjectID(id);
131:                }
132:                return oid;
133:            }
134:
135:            /**
136:             * @see org.apache.jetspeed.om.common.Application#getName()
137:             */
138:            public String getName() {
139:                return this .name;
140:            }
141:
142:            /**
143:             * @see org.apache.jetspeed.om.common.Application#setName(String)
144:             */
145:            public void setName(String name) {
146:                this .name = name;
147:            }
148:
149:            /**
150:             * @see org.apache.jetspeed.om.common.Application#getVersion()
151:             */
152:            public String getVersion() {
153:                return this .version;
154:            }
155:
156:            /**
157:             * @see org.apache.jetspeed.om.common.Application#setVersion(String)
158:             */
159:            public void setVersion(String version) {
160:                this .version = version;
161:            }
162:
163:            /**
164:             * @return
165:             */
166:            public WebApplicationDefinition getWebApplicationDefinition() {
167:                return webApplication;
168:            }
169:
170:            /**
171:             * @see org.apache.pluto.om.portlet.PortletApplicationDefinition#getPortletDefinitionList()
172:             */
173:            public PortletDefinitionList getPortletDefinitionList() {
174:                return new PortletDefinitionListImpl(portlets);
175:            }
176:
177:            /**
178:             * @return
179:             */
180:            public String getDescription() {
181:                return description;
182:            }
183:
184:            /**
185:             * @param string
186:             */
187:            public void setDescription(String string) {
188:                description = string;
189:            }
190:
191:            /**
192:             * @see org.apache.jetspeed.om.common.portlet.MutablePortletApplication#setWebApplicationDefinition(org.apache.pluto.om.servlet.WebApplicationDefinition)
193:             */
194:            public void setWebApplicationDefinition(WebApplicationDefinition wad) {
195:                this .webApplication = wad;
196:
197:            }
198:
199:            /**
200:             * @see org.apache.jetspeed.om.common.portlet.MutablePortletApplication#addPortletDefinition(org.apache.pluto.om.portlet.PortletDefinition)
201:             */
202:            public void addPortletDefinition(PortletDefinition pd) {
203:                ((PortletDefinitionComposite) pd)
204:                        .setPortletApplicationDefinition(this );
205:                portlets.add(pd);
206:            }
207:
208:            /**
209:             * @see org.apache.jetspeed.om.common.portlet.MutablePortletApplication#getPortletDefinitions()
210:             */
211:            public Collection getPortletDefinitions() {
212:                return portlets;
213:            }
214:
215:            /**
216:             * @see org.apache.jetspeed.om.common.portlet.MutablePortletApplication#getPortletDefinitionByName(java.lang.String)
217:             */
218:            public PortletDefinition getPortletDefinitionByName(String name) {
219:                listWrapper.setInnerCollection(portlets);
220:                return listWrapper.get(name);
221:            }
222:
223:            /**
224:             * @see org.apache.jetspeed.om.common.portlet.MutablePortletApplication#setPortletDefinitionList(org.apache.pluto.om.portlet.PortletDefinitionList)
225:             */
226:            public void setPortletDefinitionList(PortletDefinitionList portlets) {
227:                this .portlets = ((PortletDefinitionListImpl) portlets)
228:                        .getInnerCollection();
229:            }
230:
231:            /** 
232:             * @see org.apache.jetspeed.om.common.portlet.MutablePortletApplication#setUserAttributeRefs(java.util.Collection)
233:             */
234:            public void setUserAttributeRefs(Collection userAttributeRefs) {
235:                this .userAttributeRefs = userAttributeRefs;
236:            }
237:
238:            /** 
239:             * @see org.apache.jetspeed.om.common.portlet.MutablePortletApplication#getUserAttributeRefs()
240:             */
241:            public Collection getUserAttributeRefs() {
242:                return this .userAttributeRefs;
243:            }
244:
245:            /** 
246:             * @see org.apache.jetspeed.om.common.portlet.MutablePortletApplication#addUserAttributeRef(org.apache.jetspeed.om.common.UserAttributeRef)
247:             */
248:            public void addUserAttributeRef(UserAttributeRef userAttributeRef) {
249:                userAttributeRefs.add(userAttributeRef);
250:            }
251:
252:            /** 
253:             * @see org.apache.jetspeed.om.common.portlet.MutablePortletApplication#addUserAttribute(org.apache.jetspeed.om.common.UserAttribute)
254:             */
255:            public void addUserAttribute(UserAttribute userAttribute) {
256:                userAttributes.add(userAttribute);
257:            }
258:
259:            /** 
260:             * @see org.apache.jetspeed.om.common.portlet.MutablePortletApplication#addUserAttribute(java.lang.String, java.lang.String)
261:             */
262:            public void addUserAttribute(String userName, String description) {
263:                UserAttributeImpl userAttribute = new UserAttributeImpl();
264:                userAttribute.setName(userName);
265:                userAttribute.setDescription(description);
266:                userAttributes.add(userAttribute);
267:            }
268:
269:            /** 
270:             * @see org.apache.jetspeed.om.common.portlet.MutablePortletApplication#setUserAttributes(java.util.Collection)
271:             */
272:            public void setUserAttributes(Collection userAttributes) {
273:                this .userAttributes = userAttributes;
274:            }
275:
276:            /** 
277:             * @see org.apache.jetspeed.om.common.portlet.MutablePortletApplication#getUserAttributes()
278:             */
279:            public Collection getUserAttributes() {
280:                return this .userAttributes;
281:            }
282:
283:            /**
284:             * @see org.apache.jetspeed.om.common.portlet.MutablePortletApplication#setApplicationIdentifier(java.lang.String)
285:             */
286:            public void setApplicationIdentifier(String applicationIdentifier) {
287:                this .applicationIdentifier = applicationIdentifier;
288:            }
289:
290:            /**
291:             * @see org.apache.jetspeed.om.common.portlet.MutablePortletApplication#getApplicationIdentifier()
292:             */
293:            public String getApplicationIdentifier() {
294:                return this .applicationIdentifier;
295:            }
296:
297:            /**
298:             * @see org.apache.jetspeed.om.common.portlet.MutablePortletApplication#setApplicationType(int)
299:             */
300:            public void setApplicationType(int type) {
301:                this .applicationType = type;
302:            }
303:
304:            /**
305:             * @see org.apache.jetspeed.om.common.portlet.MutablePortletApplication#getApplicationType()
306:             */
307:            public int getApplicationType() {
308:                return applicationType;
309:            }
310:
311:            /**
312:             * @see org.apache.jetspeed.om.common.portlet.MutablePortletApplication#getMetadata()
313:             */
314:            public GenericMetadata getMetadata() {
315:                if (metadataFields == null) {
316:                    metadataFields = new ArrayList();
317:                }
318:
319:                GenericMetadata metadata = new PortletApplicationMetadataImpl();
320:                metadata.setFields(metadataFields);
321:
322:                return metadata;
323:            }
324:
325:            /**
326:             * @see org.apache.jetspeed.om.common.portlet.MutablePortletApplication#setMetadata(org.apache.jetspeed.om.common.GenericMetadata)
327:             */
328:            public void setMetadata(GenericMetadata metadata) {
329:                this .metadataFields = metadata.getFields();
330:            }
331:
332:            /**
333:             * @return
334:             */
335:            protected Collection getMetadataFields() {
336:                return metadataFields;
337:            }
338:
339:            /**
340:             * @param collection
341:             */
342:            protected void setMetadataFields(Collection metadataFields) {
343:                this .metadataFields = metadataFields;
344:            }
345:
346:            /* (non-Javadoc)
347:             * @see org.apache.jetspeed.om.common.portlet.PortletApplication#getJetspeedServices()
348:             */
349:            public Collection getJetspeedServices() {
350:                return services;
351:            }
352:
353:            /* (non-Javadoc)
354:             * @see org.apache.jetspeed.om.common.portlet.MutablePortletApplication#addJetspeedService(org.apache.jetspeed.om.common.JetspeedServiceReference)
355:             */
356:            public void addJetspeedService(JetspeedServiceReference service) {
357:                services.add(service);
358:            }
359:
360:            public long getChecksum() {
361:                if (checksumLong == -1) {
362:                    checksumLong = Long.parseLong(checksum);
363:                }
364:                return checksumLong;
365:            }
366:
367:            public void setChecksum(long checksum) {
368:                this .checksumLong = checksum;
369:                this .checksum = Long.toString(checksum);
370:            }
371:
372:            /* (non-Javadoc)
373:             * @see org.apache.jetspeed.om.common.Support#postLoad(java.lang.Object)
374:             */
375:            public void postLoad(Object parameter) throws Exception {
376:                Iterator portletDefinitions = getPortletDefinitions()
377:                        .iterator();
378:                while (portletDefinitions.hasNext()) {
379:                    ((Support) portletDefinitions.next()).postLoad(this );
380:                }
381:            }
382:
383:            public Collection getCustomPortletModes() {
384:                return customPortletModes;
385:            }
386:
387:            public void addCustomPortletMode(CustomPortletMode customPortletMode) {
388:                // clear transient cache
389:                supportedPortletModes = null;
390:                supportedCustomModes = null;
391:                mappedCustomModes = null;
392:
393:                if (!customPortletModes.contains(customPortletMode)) {
394:                    customPortletModes.add(customPortletMode);
395:                }
396:            }
397:
398:            public void setCustomPortletModes(Collection customPortletModes) {
399:                // clear transient cache
400:                supportedPortletModes = null;
401:                supportedCustomModes = null;
402:                mappedCustomModes = null;
403:
404:                this .customPortletModes.clear();
405:
406:                if (customPortletModes != null) {
407:                    this .customPortletModes.addAll(customPortletModes);
408:                }
409:            }
410:
411:            public PortletMode getMappedPortletMode(PortletMode mode) {
412:                if (JetspeedActions.getStandardPortletModes().contains(mode)) {
413:                    return mode;
414:                } else if (getSupportedPortletModes().contains(mode)) {
415:                    return (PortletMode) mappedCustomModes.get(mode);
416:                }
417:                return null;
418:            }
419:
420:            public PortletMode getCustomPortletMode(PortletMode mode) {
421:                if (JetspeedActions.getStandardPortletModes().contains(mode)) {
422:                    return mode;
423:                } else if (JetspeedActions.getExtendedPortletModes().contains(
424:                        mode)) {
425:                    // make sure transient cache is setup
426:                    getSupportedPortletModes();
427:                    return (PortletMode) supportedCustomModes.get(mode);
428:                }
429:                return null;
430:            }
431:
432:            public Collection getSupportedPortletModes() {
433:                if (supportedPortletModes == null) {
434:                    ArrayList list = new ArrayList(JetspeedActions
435:                            .getStandardPortletModes());
436:                    supportedCustomModes = new HashMap();
437:                    mappedCustomModes = new HashMap();
438:
439:                    if (customPortletModes.size() > 0) {
440:                        Iterator iter = customPortletModes.iterator();
441:                        while (iter.hasNext()) {
442:                            CustomPortletMode customMode = (CustomPortletMode) iter
443:                                    .next();
444:                            if (!list.contains(customMode.getCustomMode())
445:                                    && JetspeedActions
446:                                            .getExtendedPortletModes()
447:                                            .contains(
448:                                                    customMode.getMappedMode())) {
449:                                list.add(customMode.getCustomMode());
450:                                supportedCustomModes.put(customMode
451:                                        .getMappedMode(), customMode
452:                                        .getCustomMode());
453:                                mappedCustomModes.put(customMode
454:                                        .getCustomMode(), customMode
455:                                        .getMappedMode());
456:                            }
457:                        }
458:                    }
459:                    supportedPortletModes = Collections
460:                            .unmodifiableCollection(list);
461:                }
462:                return supportedPortletModes;
463:            }
464:
465:            public Collection getCustomWindowStates() {
466:                return customWindowStates;
467:            }
468:
469:            public void addCustomWindowState(CustomWindowState customWindowState) {
470:                // clear transient cache
471:                supportedWindowStates = null;
472:                supportedCustomStates = null;
473:                mappedCustomStates = null;
474:
475:                if (!customWindowStates.contains(customWindowState)) {
476:                    customWindowStates.add(customWindowState);
477:                }
478:            }
479:
480:            public void setCustomWindowStates(Collection customWindowStates) {
481:                // clear transient cache
482:                supportedWindowStates = null;
483:                supportedCustomStates = null;
484:                mappedCustomStates = null;
485:
486:                this .customWindowStates.clear();
487:
488:                if (customWindowStates != null) {
489:                    this .customWindowStates.addAll(customWindowStates);
490:                }
491:            }
492:
493:            public WindowState getMappedWindowState(WindowState state) {
494:                if (JetspeedActions.getStandardWindowStates().contains(state)) {
495:                    return state;
496:                } else if (getSupportedWindowStates().contains(state)) {
497:                    return (WindowState) mappedCustomStates.get(state);
498:                }
499:                return null;
500:            }
501:
502:            public WindowState getCustomWindowState(WindowState state) {
503:                if (JetspeedActions.getStandardWindowStates().contains(state)) {
504:                    return state;
505:                } else if (JetspeedActions.getExtendedWindowStates().contains(
506:                        state)) {
507:                    // make sure transient cache is setup
508:                    getSupportedWindowStates();
509:                    return (WindowState) supportedCustomStates.get(state);
510:                }
511:                return null;
512:            }
513:
514:            public Collection getSupportedWindowStates() {
515:                if (supportedWindowStates == null) {
516:                    ArrayList list = new ArrayList(JetspeedActions
517:                            .getStandardWindowStates());
518:                    supportedCustomStates = new HashMap();
519:                    mappedCustomStates = new HashMap();
520:
521:                    if (customWindowStates.size() > 0) {
522:                        Iterator iter = customWindowStates.iterator();
523:                        while (iter.hasNext()) {
524:                            CustomWindowState customState = (CustomWindowState) iter
525:                                    .next();
526:                            if (!list.contains(customState.getCustomState())
527:                                    && JetspeedActions
528:                                            .getExtendedWindowStates()
529:                                            .contains(
530:                                                    customState
531:                                                            .getMappedState())) {
532:                                list.add(customState.getCustomState());
533:                                supportedCustomStates.put(customState
534:                                        .getMappedState(), customState
535:                                        .getCustomState());
536:                                mappedCustomStates.put(customState
537:                                        .getCustomState(), customState
538:                                        .getMappedState());
539:                            }
540:                        }
541:                    }
542:                    supportedWindowStates = Collections
543:                            .unmodifiableCollection(list);
544:                }
545:                return supportedWindowStates;
546:            }
547:
548:            /* (non-Javadoc)
549:             * @see org.apache.jetspeed.om.common.portlet.PortletDefinitionComposite#getJetspeedSecurityConstraint()
550:             */
551:            public String getJetspeedSecurityConstraint() {
552:                return this .jetspeedSecurityConstraint;
553:            }
554:
555:            /* (non-Javadoc)
556:             * @see org.apache.jetspeed.om.common.portlet.PortletDefinitionComposite#setJetspeedSecurityConstraint(java.lang.String)
557:             */
558:            public void setJetspeedSecurityConstraint(String constraint) {
559:                this .jetspeedSecurityConstraint = constraint;
560:            }
561:
562:            public boolean isLayoutApplication() {
563:                if (this .getMetadata() != null) {
564:                    Collection c = this .getMetadata().getFields("layout-app");
565:                    if (c != null) {
566:                        if (!c.isEmpty()) {
567:                            return true;
568:                        }
569:                    }
570:                }
571:                return false;
572:            }
573:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.