Source Code Cross Referenced for PortletDefinitionImpl.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:        package org.apache.jetspeed.om.portlet.impl;
018:
019:        import java.io.IOException;
020:        import java.io.Serializable;
021:        import java.util.ArrayList;
022:        import java.util.Arrays;
023:        import java.util.Collection;
024:        import java.util.Iterator;
025:        import java.util.List;
026:        import java.util.Locale;
027:        import java.util.StringTokenizer;
028:        import java.util.prefs.BackingStoreException;
029:        import java.util.prefs.Preferences;
030:
031:        import javax.portlet.PreferencesValidator;
032:
033:        import org.apache.jetspeed.components.portletregistry.PortletRegistry;
034:        import org.apache.jetspeed.components.portletregistry.RegistryException;
035:        import org.apache.jetspeed.factory.PortletFactory;
036:        import org.apache.jetspeed.om.common.GenericMetadata;
037:        import org.apache.jetspeed.om.common.MutableDescription;
038:        import org.apache.jetspeed.om.common.MutableDisplayName;
039:        import org.apache.jetspeed.om.common.ParameterComposite;
040:        import org.apache.jetspeed.om.common.Support;
041:        import org.apache.jetspeed.om.common.portlet.MutablePortletApplication;
042:        import org.apache.jetspeed.om.common.portlet.PortletDefinitionComposite;
043:        import org.apache.jetspeed.om.common.preference.PreferenceComposite;
044:        import org.apache.jetspeed.om.common.preference.PreferenceSetComposite;
045:        import org.apache.jetspeed.om.common.preference.PreferencesValidatorFactory;
046:        import org.apache.jetspeed.om.impl.DescriptionImpl;
047:        import org.apache.jetspeed.om.impl.DescriptionSetImpl;
048:        import org.apache.jetspeed.om.impl.DisplayNameSetImpl;
049:        import org.apache.jetspeed.om.impl.LanguageImpl;
050:        import org.apache.jetspeed.om.impl.LanguageSetImpl;
051:        import org.apache.jetspeed.om.impl.ParameterSetImpl;
052:        import org.apache.jetspeed.om.impl.PortletDescriptionImpl;
053:        import org.apache.jetspeed.om.impl.PortletDisplayNameImpl;
054:        import org.apache.jetspeed.om.impl.PortletParameterSetImpl;
055:        import org.apache.jetspeed.om.impl.SecurityRoleRefImpl;
056:        import org.apache.jetspeed.om.impl.SecurityRoleRefSetImpl;
057:        import org.apache.jetspeed.om.preference.impl.PrefsPreference;
058:        import org.apache.jetspeed.om.preference.impl.PrefsPreferenceSetImpl;
059:        import org.apache.jetspeed.util.HashCodeBuilder;
060:        import org.apache.jetspeed.util.JetspeedLongObjectID;
061:        import org.apache.pluto.om.common.Description;
062:        import org.apache.pluto.om.common.DescriptionSet;
063:        import org.apache.pluto.om.common.DisplayName;
064:        import org.apache.pluto.om.common.DisplayNameSet;
065:        import org.apache.pluto.om.common.Language;
066:        import org.apache.pluto.om.common.LanguageSet;
067:        import org.apache.pluto.om.common.ObjectID;
068:        import org.apache.pluto.om.common.Parameter;
069:        import org.apache.pluto.om.common.ParameterSet;
070:        import org.apache.pluto.om.common.Preference;
071:        import org.apache.pluto.om.common.PreferenceSet;
072:        import org.apache.pluto.om.common.SecurityRoleRef;
073:        import org.apache.pluto.om.common.SecurityRoleRefSet;
074:        import org.apache.pluto.om.portlet.ContentType;
075:        import org.apache.pluto.om.portlet.ContentTypeSet;
076:        import org.apache.pluto.om.portlet.PortletApplicationDefinition;
077:        import org.apache.pluto.om.servlet.ServletDefinition;
078:
079:        /**
080:         * 
081:         * PortletDefinitionImpl
082:         * 
083:         * @author <a href="mailto:weaver@apache.org">Scott T. Weaver </a>
084:         * @version $Id: PortletDefinitionImpl.java 517124 2007-03-12 08:10:25Z ate $
085:         *  
086:         */
087:        public class PortletDefinitionImpl implements 
088:                PortletDefinitionComposite, PreferencesValidatorFactory,
089:                Serializable, Support {
090:            /**
091:             * This is a static instance of the PortletREgistry that can be used by
092:             * all instances of the PortletDefinitionImpl to support the 
093:             * PortletDefintionCtrl.store() method.
094:             * 
095:             */
096:            protected static PortletRegistry registry;
097:            protected static PortletFactory portletFactory;
098:
099:            private Long id;
100:            private JetspeedLongObjectID oid;
101:            private String className;
102:            private String name;
103:            private String portletIdentifier;
104:            private Collection languageSet = null;
105:            private LanguageSetImpl langListWrapper = new LanguageSetImpl();
106:            private Collection parameterSet;
107:            private ParameterSetImpl paramListWrapper = new PortletParameterSetImpl();
108:            private Collection securityRoleRefSet;
109:            private SecurityRoleRefSetImpl secListWrapper = new SecurityRoleRefSetImpl();
110:            /** User attribute set. * */
111:            //private Collection userAttributeSet;
112:            /** User attribute ref set. * */
113:            //private Collection userAttributeRefSet;
114:            private String preferenceValidatorClassname;
115:            private Collection displayNames;
116:            private DisplayNameSetImpl DNListWrapper = new DisplayNameSetImpl();
117:            private Collection descriptions;
118:            private DescriptionSetImpl descListWrapper = new DescriptionSetImpl(
119:                    DescriptionImpl.TYPE_PORTLET);
120:            private String resourceBundle;
121:            private ArrayList supportedLocales;
122:
123:            private Collection contentTypes;
124:            private ContentTypeSetImpl ctListWrapper = new ContentTypeSetImpl();
125:            protected List portletEntities;
126:
127:            /** PortletApplicationDefinition this PortletDefinition belongs to */
128:            private MutablePortletApplication app;
129:
130:            protected long appId;
131:            private String expirationCache;
132:
133:            /** Metadata property */
134:            private Collection metadataFields = null;
135:            private PrefsPreferenceSetImpl preferenceSet;
136:
137:            private String jetspeedSecurityConstraint = null;
138:
139:            public PortletDefinitionImpl() {
140:                super ();
141:                try {
142:                    parameterSet = new ArrayList();
143:                    securityRoleRefSet = new ArrayList();
144:                    //userAttributeSet = new ArrayList();
145:                    //userAttributeRefSet = new ArrayList();
146:                    contentTypes = new ArrayList();
147:                    supportedLocales = new ArrayList();
148:                } catch (RuntimeException e) {
149:                    //            System.out.println("Failed to fully construct Portlet Definition");
150:                    e.printStackTrace();
151:                }
152:            }
153:
154:            /**
155:             * @see org.apache.pluto.om.portlet.PortletDefinition#getId()
156:             */
157:            public ObjectID getId() {
158:                if (oid == null && id != null) {
159:                    oid = new JetspeedLongObjectID(id);
160:                }
161:                return oid;
162:            }
163:
164:            /**
165:             * @see org.apache.pluto.om.portlet.PortletDefinition#getClassName()
166:             */
167:            public String getClassName() {
168:                return className;
169:            }
170:
171:            /**
172:             * @see org.apache.pluto.om.portlet.PortletDefinition#getName()
173:             */
174:            public String getName() {
175:                return name;
176:            }
177:
178:            /**
179:             * @see org.apache.pluto.om.portlet.PortletDefinition#getLanguageSet()
180:             */
181:            public LanguageSet getLanguageSet() {
182:                if (languageSet != null) {
183:                    langListWrapper.setInnerCollection(languageSet);
184:                }
185:                langListWrapper.setClassLoader(getPortletClassLoader());
186:
187:                return langListWrapper;
188:            }
189:
190:            /**
191:             * @see org.apache.pluto.om.portlet.PortletDefinition#getInitParameterSet()
192:             */
193:            public ParameterSet getInitParameterSet() {
194:                paramListWrapper.setInnerCollection(parameterSet);
195:                return paramListWrapper;
196:            }
197:
198:            /**
199:             * @see org.apache.pluto.om.portlet.PortletDefinition#getInitSecurityRoleRefSet()
200:             */
201:            public SecurityRoleRefSet getInitSecurityRoleRefSet() {
202:                secListWrapper.setInnerCollection(securityRoleRefSet);
203:                return secListWrapper;
204:            }
205:
206:            /**
207:             * @see org.apache.pluto.om.portlet.PortletDefinition#getPreferenceSet()
208:             */
209:            public PreferenceSet getPreferenceSet() {
210:                try {
211:                    if (preferenceSet == null) {
212:
213:                        if (app == null) {
214:                            throw new IllegalStateException(
215:                                    "Portlet Application must be defined before preferences can be accessed");
216:                        }
217:
218:                        Preferences prefNode = PrefsPreference
219:                                .createPrefenceNode(this );
220:                        preferenceSet = new PrefsPreferenceSetImpl(prefNode,
221:                                this );
222:                    }
223:                } catch (BackingStoreException e) {
224:                    String msg = "Preference backing store failed: "
225:                            + e.toString();
226:                    IllegalStateException ise = new IllegalStateException(msg);
227:                    ise.initCause(e);
228:                    throw ise;
229:                }
230:
231:                return preferenceSet;
232:            }
233:
234:            /**
235:             * @see org.apache.jetspeed.om.common.portlet.PortletDefinitionComposite#setPreferenceSet(org.apache.pluto.om.common.PreferenceSet)
236:             */
237:            public void setPreferenceSet(PreferenceSet preferences) {
238:                this .preferenceSet = (PrefsPreferenceSetImpl) preferences;
239:            }
240:
241:            /**
242:             * @see org.apache.pluto.om.portlet.PortletDefinition#getContentTypeSet()
243:             */
244:            public ContentTypeSet getContentTypeSet() {
245:                ctListWrapper.setInnerCollection(contentTypes);
246:                return ctListWrapper;
247:            }
248:
249:            /**
250:             * @see org.apache.pluto.om.portlet.PortletDefinition#getPortletApplicationDefinition()
251:             */
252:            public PortletApplicationDefinition getPortletApplicationDefinition() {
253:                return app;
254:            }
255:
256:            /**
257:             * @see org.apache.pluto.om.portlet.PortletDefinition#getServletDefinition()
258:             */
259:            public ServletDefinition getServletDefinition() {
260:                // TODO Auto-generated method stub
261:                return null;
262:            }
263:
264:            /**
265:             * @see org.apache.pluto.om.portlet.PortletDefinition#getExpirationCache()
266:             */
267:            public String getExpirationCache() {
268:                return expirationCache;
269:            }
270:
271:            /**
272:             * @see org.apache.pluto.om.portlet.PortletDefinition#getPortletClassLoader()
273:             */
274:            public ClassLoader getPortletClassLoader() {
275:                if (portletFactory != null) {
276:                    return portletFactory.getPortletApplicationClassLoader(app);
277:                }
278:                return null;
279:            }
280:
281:            /**
282:             * @see org.apache.pluto.om.portlet.PortletDefinitionCtrl#setId(java.lang.String)
283:             */
284:            public void setId(String oid) {
285:                throw new UnsupportedOperationException();
286:            }
287:
288:            /**
289:             * @see org.apache.pluto.om.portlet.PortletDefinitionCtrl#setClassName(java.lang.String)
290:             */
291:            public void setClassName(String className) {
292:                this .className = className;
293:            }
294:
295:            /**
296:             * @see org.apache.pluto.om.portlet.PortletDefinitionCtrl#setName(java.lang.String)
297:             */
298:            public void setName(String name) {
299:                this .name = name;
300:            }
301:
302:            /**
303:             * @see org.apache.pluto.om.portlet.PortletDefinitionCtrl#setPortletClassLoader(java.lang.ClassLoader)
304:             */
305:            public void setPortletClassLoader(ClassLoader loader) {
306:                // no-op: ClassLoader is only stored in the PortletFactory
307:                ;
308:            }
309:
310:            /**
311:             * @see org.apache.jetspeed.om.common.portlet.PortletDefinitionComposite#addLanguage(org.apache.pluto.om.common.Language)
312:             */
313:            public void addLanguage(Language lang) {
314:                if (languageSet == null) {
315:                    languageSet = new ArrayList();
316:                }
317:                langListWrapper.setInnerCollection(languageSet);
318:                langListWrapper.add(lang);
319:            }
320:
321:            /**
322:             * @see org.apache.jetspeed.om.common.portlet.PortletDefinitionComposite#addLanguage(java.lang.String, java.lang.String, java.lang.String, java.util.Locale)
323:             */
324:            public void addLanguage(String title, String shortTitle,
325:                    String keywords, Locale locale) {
326:                LanguageImpl lang = new LanguageImpl();
327:                lang.setTitle(title);
328:                lang.setShortTitle(shortTitle);
329:                lang.setKeywords(keywords);
330:                lang.setLocale(locale);
331:
332:                addLanguage(lang);
333:            }
334:
335:            /**
336:             * @see org.apache.jetspeed.om.common.portlet.PortletDefinitionComposite#setContentTypeSet(org.apache.pluto.om.portlet.ContentTypeSet)
337:             */
338:            public void setContentTypeSet(ContentTypeSet contentTypes) {
339:                this .contentTypes = ((ContentTypeSetImpl) contentTypes)
340:                        .getInnerCollection();
341:            }
342:
343:            /**
344:             * @see org.apache.jetspeed.om.common.portlet.PortletDefinitionComposite#setInitParameterSet(org.apache.pluto.om.common.ParameterSet)
345:             */
346:            public void setInitParameterSet(ParameterSet parameters) {
347:                this .parameterSet = ((ParameterSetImpl) parameters)
348:                        .getInnerCollection();
349:            }
350:
351:            /**
352:             * @see org.apache.jetspeed.om.common.portlet.PortletDefinitionComposite#setInitSecurityRoleRefSet(org.apache.pluto.om.common.SecurityRoleRefSet)
353:             */
354:            public void setInitSecurityRoleRefSet(
355:                    SecurityRoleRefSet securityRefs) {
356:                this .securityRoleRefSet = ((SecurityRoleRefSetImpl) securityRefs)
357:                        .getInnerCollection();
358:            }
359:
360:            /**
361:             * @see org.apache.jetspeed.om.common.portlet.PortletDefinitionComposite#setLanguageSet(org.apache.pluto.om.common.LanguageSet)
362:             */
363:            public void setLanguageSet(LanguageSet languages) {
364:                this .languageSet = ((LanguageSetImpl) languages)
365:                        .getInnerCollection();
366:            }
367:
368:            /**
369:             * @see org.apache.jetspeed.om.common.portlet.PortletDefinitionComposite#addUserAttribute(org.apache.jetspeed.om.common.UserAttribute)
370:             */
371:            /*
372:             * public void addUserAttribute(UserAttribute userAttribute) {
373:             * this.userAttributeSet.add(userAttribute); }
374:             *  
375:             *//**
376:             * @see org.apache.jetspeed.om.common.portlet.PortletDefinitionComposite#setUserAttributeSet(java.util.Collection)
377:             */
378:            /*
379:             * public void setUserAttributeSet(Collection userAttributeSet) {
380:             * this.userAttributeSet = userAttributeSet; }
381:             *  
382:             *//**
383:             * @see org.apache.jetspeed.om.common.portlet.PortletDefinitionComposite#getUserAttributeSet()
384:             */
385:            /*
386:             * public Collection getUserAttributeSet() { return this.userAttributeSet; }
387:             *  
388:             *//**
389:             * @see org.apache.jetspeed.om.common.portlet.PortletDefinitionComposite#addUserAttributeRef(org.apache.jetspeed.om.common.UserAttributeRef)
390:             */
391:            /*
392:             * public void addUserAttributeRef(UserAttributeRef userAttributeRef) {
393:             * System.out.println("_______IN addUserAttributeRef");
394:             * this.userAttributeRefSet.add(userAttributeRef); }
395:             *  
396:             *//**
397:             * @see org.apache.jetspeed.om.common.portlet.PortletDefinitionComposite#setUserAttributeSet(java.util.Collection)
398:             */
399:            /*
400:             * public void setUserAttributeRefSet(Collection userAttributeRefSet) {
401:             * this.userAttributeRefSet = userAttributeRefSet; }
402:             *  
403:             *//**
404:             * @see org.apache.jetspeed.om.common.portlet.PortletDefinitionComposite#getUserAttributeRefSet()
405:             */
406:            /*
407:             * public Collection getUserAttributeRefSet() { return
408:             * this.userAttributeRefSet; }
409:             */
410:            /**
411:             * @see org.apache.jetspeed.om.common.portlet.PortletDefinitionComposite#setInitParameter(java.lang.String,
412:             *      java.lang.String, java.lang.String)
413:             */
414:            public ParameterComposite addInitParameter(String name,
415:                    String value, DescriptionSet description) {
416:                ParameterComposite pc = addInitParameter(name, value);
417:                pc.setDescriptionSet(description);
418:                return pc;
419:            }
420:
421:            /**
422:             * @see org.apache.jetspeed.om.common.portlet.PortletDefinitionComposite#addInitParameter(java.lang.String,
423:             *      java.lang.String, java.lang.String, java.util.Locale)
424:             */
425:            public ParameterComposite addInitParameter(String name,
426:                    String value, String description, Locale locale) {
427:                ParameterComposite param = addInitParameter(name, value);
428:                param.addDescription(locale, description);
429:                return param;
430:            }
431:
432:            public void addInitParameter(Parameter parameter) {
433:                parameterSet.add(parameter);
434:            }
435:
436:            /**
437:             * @see org.apache.jetspeed.om.common.portlet.PortletDefinitionComposite#setInitParameter(java.lang.String,
438:             *      java.lang.String)
439:             */
440:            public ParameterComposite addInitParameter(String name, String value) {
441:                paramListWrapper.setInnerCollection(parameterSet);
442:                return (ParameterComposite) paramListWrapper.add(name, value);
443:            }
444:
445:            /**
446:             * @see org.apache.jetspeed.om.common.portlet.PortletDefinitionComposite#setExpirationCache(java.lang.String)
447:             */
448:            public void setExpirationCache(String cache) {
449:                expirationCache = cache;
450:            }
451:
452:            /**
453:             * @see org.apache.jetspeed.om.common.portlet.PortletDefinitionComposite#addContentType(org.apache.pluto.om.portlet.ContentType)
454:             */
455:            public void addContentType(ContentType cType) {
456:                ctListWrapper.setInnerCollection(contentTypes);
457:                ctListWrapper.addContentType(cType);
458:            }
459:
460:            /**
461:             * @see org.apache.jetspeed.om.common.portlet.PortletDefinitionComposite#addContentType(java.lang.String, java.lang.String[])
462:             */
463:            public void addContentType(String contentType, Collection modes) {
464:                ContentTypeImpl ct = new ContentTypeImpl();
465:                ct.setContentType(contentType);
466:                ct.setPortletModes(modes);
467:
468:                addContentType(ct);
469:            }
470:
471:            /**
472:             * @see org.apache.jetspeed.om.common.portlet.PortletDefinitionComposite#addPreference(java.lang.String,
473:             *      java.util.Collection)
474:             */
475:            public PreferenceComposite addPreference(String name,
476:                    String[] values) {
477:                return (PreferenceComposite) ((PrefsPreferenceSetImpl) getPreferenceSet())
478:                        .add(name, Arrays.asList(values));
479:            }
480:
481:            public void setPortletIdentifier(String portletIdentifier) {
482:                this .portletIdentifier = portletIdentifier;
483:            }
484:
485:            public String getPortletIdentifier() {
486:                return this .portletIdentifier;
487:            }
488:
489:            /**
490:             * @see org.apache.jetspeed.om.common.portlet.PortletDefinitionComposite#setPortletApplicationDefinition(org.apache.pluto.om.portlet.PortletApplicationDefinition)
491:             */
492:            public void setPortletApplicationDefinition(
493:                    PortletApplicationDefinition pad) {
494:                app = (MutablePortletApplication) pad;
495:            }
496:
497:            /**
498:             * @see java.lang.Object#equals(java.lang.Object)
499:             */
500:            public boolean equals(Object obj) {
501:                if (obj != null && obj.getClass().equals(getClass())) {
502:                    PortletDefinitionImpl pd = (PortletDefinitionImpl) obj;
503:                    boolean sameId = (id != null && pd.id != null && id
504:                            .equals(pd.id));
505:                    if (sameId) {
506:                        return true;
507:                    }
508:                    boolean sameAppId = (appId == pd.appId);
509:                    boolean sameName = (pd.getName() != null && name != null && pd
510:                            .getName().equals(name));
511:                    return sameName && sameAppId;
512:                }
513:                return false;
514:            }
515:
516:            /**
517:             * @see java.lang.Object#hashCode()
518:             */
519:            public int hashCode() {
520:                HashCodeBuilder hasher = new HashCodeBuilder(1, 3);
521:                hasher.append(name);
522:                if (app != null) {
523:                    if (getId() != null) {
524:                        hasher.append(getId().toString());
525:                    }
526:                    hasher.append(app.getName());
527:                }
528:                return hasher.toHashCode();
529:            }
530:
531:            /**
532:             * @see org.apache.jetspeed.om.common.portlet.PortletDefinitionComposite#getUniqueName()
533:             */
534:            public String getUniqueName() {
535:                if (app != null && name != null) {
536:                    return app.getName() + "::" + name;
537:                } else {
538:                    throw new IllegalStateException(
539:                            "Cannot generate a unique portlet name until the application and portlet name have been set");
540:                }
541:            }
542:
543:            /**
544:             * @see org.apache.pluto.om.portlet.PortletDefinition#getDescription(java.util.Locale)
545:             */
546:            public Description getDescription(Locale arg0) {
547:                if (descriptions != null) {
548:                    descListWrapper.setInnerCollection(descriptions);
549:                    return descListWrapper.get(arg0);
550:                }
551:                return null;
552:            }
553:
554:            /**
555:             * @see org.apache.pluto.om.portlet.PortletDefinition#getDisplayName(java.util.Locale)
556:             */
557:            public DisplayName getDisplayName(Locale arg0) {
558:                if (displayNames != null) {
559:                    DNListWrapper.setInnerCollection(displayNames);
560:                    return DNListWrapper.get(arg0);
561:                }
562:                return null;
563:            }
564:
565:            /**
566:             * @see org.apache.pluto.om.portlet.PortletDefinitionCtrl#setDescriptions(org.apache.pluto.om.common.DescriptionSet)
567:             */
568:            public void setDescriptions(DescriptionSet arg0) {
569:                this .descriptions = ((DescriptionSetImpl) arg0)
570:                        .getInnerCollection();
571:            }
572:
573:            /**
574:             * @see org.apache.pluto.om.portlet.PortletDefinitionCtrl#setDisplayNames(org.apache.pluto.om.common.DisplayNameSet)
575:             */
576:            public void setDisplayNames(DisplayNameSet arg0) {
577:                this .displayNames = ((DisplayNameSetImpl) arg0)
578:                        .getInnerCollection();
579:            }
580:
581:            /**
582:             * Returns localized text of this PortletDefinitions display name.
583:             * 
584:             * @param locale
585:             *            Locale to get the display name for
586:             * @return Localized text string of the display name or <code>null</code>
587:             *         if no DisplayName exists for this locale
588:             */
589:            public String getDisplayNameText(Locale locale) {
590:                DisplayName dn = getDisplayName(locale);
591:                if (dn != null) {
592:                    return dn.getDisplayName();
593:                }
594:                return null;
595:            }
596:
597:            /**
598:             * Returns localized text of this PortletDefinitions description.
599:             * 
600:             * @param locale
601:             *            Locale to get the description for
602:             * @return Localized text string of the display name or <code>null</code>
603:             *         if no Description exists for this locale
604:             */
605:            public String getDescriptionText(Locale locale) {
606:                Description desc = getDescription(locale);
607:                if (desc != null) {
608:                    return desc.getDescription();
609:                }
610:                return null;
611:            }
612:
613:            public DescriptionSet getDescriptionSet() {
614:                return this .descListWrapper;
615:            }
616:
617:            /**
618:             * @see org.apache.jetspeed.om.common.portlet.PortletDefinitionComposite#addDescription(java.util.Locale,
619:             *      java.lang.String)
620:             */
621:            public void addDescription(Locale locale, String description) {
622:                if (descriptions == null) {
623:                    descriptions = new ArrayList();
624:                }
625:                descListWrapper.setInnerCollection(descriptions);
626:                MutableDescription descObj = new PortletDescriptionImpl();
627:                descObj.setLocale(locale);
628:                descObj.setDescription(description);
629:                descListWrapper.addDescription(descObj);
630:            }
631:
632:            public void addDescription(Description description) {
633:                if (descriptions == null) {
634:                    descriptions = new ArrayList();
635:                }
636:                descListWrapper.setInnerCollection(descriptions);
637:                descListWrapper.addDescription(description);
638:            }
639:
640:            /**
641:             * @see org.apache.jetspeed.om.common.portlet.PortletDefinitionComposite#addDisplayName(java.util.Locale,
642:             *      java.lang.String)
643:             */
644:            public void addDisplayName(Locale locale, String displayName) {
645:                if (displayNames == null) {
646:                    displayNames = new ArrayList();
647:                }
648:                DNListWrapper.setInnerCollection(displayNames);
649:                MutableDisplayName dn = new PortletDisplayNameImpl();
650:                dn.setLocale(locale);
651:                dn.setDisplayName(displayName);
652:                DNListWrapper.addDisplayName(dn);
653:            }
654:
655:            public void addDisplayName(DisplayName displayName) {
656:                if (displayNames == null) {
657:                    displayNames = new ArrayList();
658:                }
659:                DNListWrapper.setInnerCollection(displayNames);
660:                DNListWrapper.addDisplayName(displayName);
661:            }
662:
663:            public DisplayNameSet getDisplayNameSet() {
664:                if (displayNames != null) {
665:                    DNListWrapper.setInnerCollection(displayNames);
666:                }
667:                return DNListWrapper;
668:            }
669:
670:            /**
671:             * <p>
672:             * store will attempt to perform an atomic persistence call against this
673:             * portletDefinition.
674:             * </p>
675:             * 
676:             * @see org.apache.pluto.om.portlet.PortletDefinitionCtrl#store()
677:             * @throws java.io.IOException
678:             */
679:            public void store() throws IOException {
680:                if (registry != null) {
681:                    try {
682:                        registry.savePortletDefinition(this );
683:                    } catch (RegistryException e) {
684:                        IOException ioe = new IOException(
685:                                "Failed to store portlet definition: "
686:                                        + e.getMessage());
687:                        ioe.initCause(e);
688:                    }
689:                } else {
690:                    throw new IllegalStateException(
691:                            "The portlet registry for PortletDefinitionImpl has not been set.  "
692:                                    + "Please invoke PortletDefinitionImpl.setPortletRegistry before invoking the store() method.");
693:                }
694:            }
695:
696:            /**
697:             * <p>
698:             * getPreferenceValidatorClassname
699:             * </p>
700:             * 
701:             * @return
702:             */
703:            public String getPreferenceValidatorClassname() {
704:                return preferenceValidatorClassname;
705:            }
706:
707:            /**
708:             * <p>
709:             * setPreferenceValidatorClassname
710:             * </p>
711:             * 
712:             * @param string
713:             *  
714:             */
715:            public void setPreferenceValidatorClassname(String string) {
716:                preferenceValidatorClassname = string;
717:            }
718:
719:            /**
720:             * @see org.apache.jetspeed.om.common.portlet.PortletDefinitionComposite#addPreference(org.apache.pluto.om.common.Preference)
721:             * @param preference
722:             */
723:            public void addPreference(Preference preference) {
724:                Iterator valueItr = preference.getValues();
725:                ArrayList list = new ArrayList();
726:                while (valueItr.hasNext()) {
727:                    list.add(valueItr.next());
728:                }
729:
730:                PreferenceComposite newPref = (PreferenceComposite) ((PreferenceSetComposite) getPreferenceSet())
731:                        .add(preference.getName(), list);
732:
733:                Iterator descItr = newPref.getDescriptions();
734:                while (descItr.hasNext()) {
735:                    Description desc = (Description) descItr.next();
736:                    newPref.addDescription(desc.getLocale(), desc
737:                            .getDescription());
738:                }
739:
740:            }
741:
742:            /**
743:             * @see org.apache.jetspeed.om.common.portlet.PortletDefinitionComposite#addSecurityRoleRef(org.apache.pluto.om.common.SecurityRoleRef)
744:             */
745:            public void addSecurityRoleRef(SecurityRoleRef securityRef) {
746:                secListWrapper.setInnerCollection(securityRoleRefSet);
747:                secListWrapper.add(securityRef);
748:            }
749:
750:            /**
751:             * @see org.apache.jetspeed.om.common.portlet.PortletDefinitionComposite#addSecurityRoleRef(java.lang.String, java.lang.String)
752:             */
753:            public SecurityRoleRef addSecurityRoleRef(String roleName,
754:                    String roleLink) {
755:                SecurityRoleRefImpl ref = new SecurityRoleRefImpl();
756:                ref.setRoleName(roleName);
757:                ref.setRoleLink(roleLink);
758:
759:                addSecurityRoleRef(ref);
760:
761:                return ref;
762:            }
763:
764:            /**
765:             * @see org.apache.jetspeed.om.common.portlet.MutablePortletApplication#getMetadata()
766:             */
767:            public GenericMetadata getMetadata() {
768:                if (metadataFields == null) {
769:                    metadataFields = new ArrayList();
770:                }
771:
772:                GenericMetadata metadata = new PortletDefinitionMetadataImpl();
773:                metadata.setFields(metadataFields);
774:
775:                return metadata;
776:            }
777:
778:            /**
779:             * @see org.apache.jetspeed.om.common.portlet.MutablePortletApplication#setMetadata(org.apache.jetspeed.om.common.GenericMetadata)
780:             */
781:            public void setMetadata(GenericMetadata metadata) {
782:                this .metadataFields = metadata.getFields();
783:            }
784:
785:            /**
786:             * @return
787:             */
788:            protected Collection getMetadataFields() {
789:                return metadataFields;
790:            }
791:
792:            /**
793:             * @param collection
794:             */
795:            protected void setMetadataFields(Collection metadataFields) {
796:                this .metadataFields = metadataFields;
797:            }
798:
799:            /**
800:             * @return
801:             */
802:            public String getResourceBundle() {
803:                return resourceBundle;
804:            }
805:
806:            /**
807:             * @param string
808:             */
809:            public void setResourceBundle(String string) {
810:                resourceBundle = string;
811:            }
812:
813:            public Collection getSupportedLocales() {
814:                return supportedLocales;
815:            }
816:
817:            public void addSupportedLocale(String locale) {
818:                // parse locale String
819:                StringTokenizer tokenizer = new StringTokenizer(locale, "_");
820:                String[] localeDef = new String[3];
821:                for (int i = 0; i < 3; i++) {
822:                    if (tokenizer.hasMoreTokens()) {
823:                        localeDef[i] = tokenizer.nextToken();
824:                    } else {
825:                        localeDef[i] = "";
826:                    }
827:                }
828:                supportedLocales.add(new Locale(localeDef[0], localeDef[1],
829:                        localeDef[2]));
830:            }
831:
832:            /* (non-Javadoc)
833:             * @see org.apache.jetspeed.om.Support#postLoad(java.lang.Object)
834:             */
835:            public void postLoad(Object parameter) throws Exception {
836:                if (resourceBundle != null) {
837:                    langListWrapper.setResources(resourceBundle);
838:                }
839:
840:                if (parameter instanceof  ClassLoader) {
841:                    // newly created PD from portlet.xml
842:                    langListWrapper.setClassLoader((ClassLoader) parameter);
843:                    // create supported locale languages and
844:                    // retrieve title, shortTitle and keywords from resourceBundle if defined
845:                    langListWrapper.postLoad(this .supportedLocales);
846:                } else {
847:                    // loaded from persistent store
848:                    langListWrapper.setClassLoader(getPortletClassLoader());
849:                }
850:            }
851:
852:            public static void setPortletRegistry(PortletRegistry registry) {
853:                PortletDefinitionImpl.registry = registry;
854:            }
855:
856:            public static void setPortletFactory(PortletFactory portletFactory) {
857:                PortletDefinitionImpl.portletFactory = portletFactory;
858:            }
859:
860:            public PreferencesValidator getPreferencesValidator() {
861:                if (portletFactory != null) {
862:                    return portletFactory.getPreferencesValidator(this );
863:                }
864:                return null;
865:            }
866:
867:            /* (non-Javadoc)
868:             * @see org.apache.jetspeed.om.common.portlet.PortletDefinitionComposite#getJetspeedSecurityConstraint()
869:             */
870:            public String getJetspeedSecurityConstraint() {
871:                return this .jetspeedSecurityConstraint;
872:            }
873:
874:            /* (non-Javadoc)
875:             * @see org.apache.jetspeed.om.common.portlet.PortletDefinitionComposite#setJetspeedSecurityConstraint(java.lang.String)
876:             */
877:            public void setJetspeedSecurityConstraint(String constraint) {
878:                this.jetspeedSecurityConstraint = constraint;
879:            }
880:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.