1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
package org.apache.jetspeed.om.portlet.impl; |
18 |
|
|
19 |
|
import java.io.IOException; |
20 |
|
import java.io.Serializable; |
21 |
|
import java.util.ArrayList; |
22 |
|
import java.util.Arrays; |
23 |
|
import java.util.Collection; |
24 |
|
import java.util.Iterator; |
25 |
|
import java.util.List; |
26 |
|
import java.util.Locale; |
27 |
|
import java.util.StringTokenizer; |
28 |
|
import java.util.prefs.BackingStoreException; |
29 |
|
import java.util.prefs.Preferences; |
30 |
|
|
31 |
|
import javax.portlet.PreferencesValidator; |
32 |
|
|
33 |
|
import org.apache.jetspeed.components.portletregistry.PortletRegistry; |
34 |
|
import org.apache.jetspeed.components.portletregistry.RegistryException; |
35 |
|
import org.apache.jetspeed.factory.PortletFactory; |
36 |
|
import org.apache.jetspeed.om.common.GenericMetadata; |
37 |
|
import org.apache.jetspeed.om.common.MutableDescription; |
38 |
|
import org.apache.jetspeed.om.common.MutableDisplayName; |
39 |
|
import org.apache.jetspeed.om.common.ParameterComposite; |
40 |
|
import org.apache.jetspeed.om.common.Support; |
41 |
|
import org.apache.jetspeed.om.common.portlet.MutablePortletApplication; |
42 |
|
import org.apache.jetspeed.om.common.portlet.PortletDefinitionComposite; |
43 |
|
import org.apache.jetspeed.om.common.preference.PreferenceComposite; |
44 |
|
import org.apache.jetspeed.om.common.preference.PreferenceSetComposite; |
45 |
|
import org.apache.jetspeed.om.common.preference.PreferencesValidatorFactory; |
46 |
|
import org.apache.jetspeed.om.impl.DescriptionImpl; |
47 |
|
import org.apache.jetspeed.om.impl.DescriptionSetImpl; |
48 |
|
import org.apache.jetspeed.om.impl.DisplayNameSetImpl; |
49 |
|
import org.apache.jetspeed.om.impl.LanguageImpl; |
50 |
|
import org.apache.jetspeed.om.impl.LanguageSetImpl; |
51 |
|
import org.apache.jetspeed.om.impl.ParameterSetImpl; |
52 |
|
import org.apache.jetspeed.om.impl.PortletDescriptionImpl; |
53 |
|
import org.apache.jetspeed.om.impl.PortletDisplayNameImpl; |
54 |
|
import org.apache.jetspeed.om.impl.PortletParameterSetImpl; |
55 |
|
import org.apache.jetspeed.om.impl.SecurityRoleRefImpl; |
56 |
|
import org.apache.jetspeed.om.impl.SecurityRoleRefSetImpl; |
57 |
|
import org.apache.jetspeed.om.preference.impl.PrefsPreference; |
58 |
|
import org.apache.jetspeed.om.preference.impl.PrefsPreferenceSetImpl; |
59 |
|
import org.apache.jetspeed.util.HashCodeBuilder; |
60 |
|
import org.apache.jetspeed.util.JetspeedLongObjectID; |
61 |
|
import org.apache.pluto.om.common.Description; |
62 |
|
import org.apache.pluto.om.common.DescriptionSet; |
63 |
|
import org.apache.pluto.om.common.DisplayName; |
64 |
|
import org.apache.pluto.om.common.DisplayNameSet; |
65 |
|
import org.apache.pluto.om.common.Language; |
66 |
|
import org.apache.pluto.om.common.LanguageSet; |
67 |
|
import org.apache.pluto.om.common.ObjectID; |
68 |
|
import org.apache.pluto.om.common.Parameter; |
69 |
|
import org.apache.pluto.om.common.ParameterSet; |
70 |
|
import org.apache.pluto.om.common.Preference; |
71 |
|
import org.apache.pluto.om.common.PreferenceSet; |
72 |
|
import org.apache.pluto.om.common.SecurityRoleRef; |
73 |
|
import org.apache.pluto.om.common.SecurityRoleRefSet; |
74 |
|
import org.apache.pluto.om.portlet.ContentType; |
75 |
|
import org.apache.pluto.om.portlet.ContentTypeSet; |
76 |
|
import org.apache.pluto.om.portlet.PortletApplicationDefinition; |
77 |
|
import org.apache.pluto.om.servlet.ServletDefinition; |
78 |
|
|
79 |
|
|
80 |
|
|
81 |
|
|
82 |
|
|
83 |
|
|
84 |
|
|
85 |
|
|
86 |
|
|
87 |
|
public class PortletDefinitionImpl implements PortletDefinitionComposite, PreferencesValidatorFactory, Serializable, Support |
88 |
|
{ |
89 |
|
|
90 |
|
|
91 |
|
|
92 |
|
|
93 |
|
|
94 |
|
|
95 |
|
protected static PortletRegistry registry; |
96 |
|
protected static PortletFactory portletFactory; |
97 |
|
|
98 |
|
private Long id; |
99 |
|
private JetspeedLongObjectID oid; |
100 |
|
private String className; |
101 |
|
private String name; |
102 |
|
private String portletIdentifier; |
103 |
0 |
private Collection languageSet = null; |
104 |
0 |
private LanguageSetImpl langListWrapper = new LanguageSetImpl(); |
105 |
|
private Collection parameterSet; |
106 |
0 |
private ParameterSetImpl paramListWrapper = new PortletParameterSetImpl(); |
107 |
|
private Collection securityRoleRefSet; |
108 |
0 |
private SecurityRoleRefSetImpl secListWrapper = new SecurityRoleRefSetImpl(); |
109 |
|
|
110 |
|
|
111 |
|
|
112 |
|
|
113 |
|
private String preferenceValidatorClassname; |
114 |
|
private Collection displayNames; |
115 |
0 |
private DisplayNameSetImpl DNListWrapper = new DisplayNameSetImpl(); |
116 |
|
private Collection descriptions; |
117 |
0 |
private DescriptionSetImpl descListWrapper = new DescriptionSetImpl(DescriptionImpl.TYPE_PORTLET); |
118 |
|
private String resourceBundle; |
119 |
|
private ArrayList supportedLocales; |
120 |
|
|
121 |
|
private Collection contentTypes; |
122 |
0 |
private ContentTypeSetImpl ctListWrapper = new ContentTypeSetImpl(); |
123 |
|
protected List portletEntities; |
124 |
|
|
125 |
|
|
126 |
|
private MutablePortletApplication app; |
127 |
|
|
128 |
|
protected long appId; |
129 |
|
private String expirationCache; |
130 |
|
|
131 |
|
|
132 |
0 |
private Collection metadataFields = null; |
133 |
|
private PrefsPreferenceSetImpl preferenceSet; |
134 |
|
|
135 |
0 |
private String jetspeedSecurityConstraint = null; |
136 |
|
|
137 |
|
public PortletDefinitionImpl() |
138 |
|
{ |
139 |
0 |
super(); |
140 |
|
try |
141 |
|
{ |
142 |
0 |
parameterSet = new ArrayList(); |
143 |
0 |
securityRoleRefSet = new ArrayList(); |
144 |
|
|
145 |
|
|
146 |
0 |
contentTypes = new ArrayList(); |
147 |
0 |
supportedLocales= new ArrayList(); |
148 |
|
} |
149 |
0 |
catch (RuntimeException e) |
150 |
|
{ |
151 |
|
|
152 |
0 |
e.printStackTrace(); |
153 |
0 |
} |
154 |
0 |
} |
155 |
|
|
156 |
|
|
157 |
|
|
158 |
|
|
159 |
|
public ObjectID getId() |
160 |
|
{ |
161 |
0 |
if ( oid == null && id != class="keyword">null ) |
162 |
|
{ |
163 |
0 |
oid = new JetspeedLongObjectID(id); |
164 |
|
} |
165 |
0 |
return oid; |
166 |
|
} |
167 |
|
|
168 |
|
|
169 |
|
|
170 |
|
|
171 |
|
public String getClassName() |
172 |
|
{ |
173 |
0 |
return className; |
174 |
|
} |
175 |
|
|
176 |
|
|
177 |
|
|
178 |
|
|
179 |
|
public String getName() |
180 |
|
{ |
181 |
0 |
return name; |
182 |
|
} |
183 |
|
|
184 |
|
|
185 |
|
|
186 |
|
|
187 |
|
public LanguageSet getLanguageSet() |
188 |
|
{ |
189 |
0 |
if ( languageSet != null ) |
190 |
|
{ |
191 |
0 |
langListWrapper.setInnerCollection(languageSet); |
192 |
|
} |
193 |
0 |
langListWrapper.setClassLoader(getPortletClassLoader()); |
194 |
|
|
195 |
0 |
return langListWrapper; |
196 |
|
} |
197 |
|
|
198 |
|
|
199 |
|
|
200 |
|
|
201 |
|
public ParameterSet getInitParameterSet() |
202 |
|
{ |
203 |
0 |
paramListWrapper.setInnerCollection(parameterSet); |
204 |
0 |
return paramListWrapper; |
205 |
|
} |
206 |
|
|
207 |
|
|
208 |
|
|
209 |
|
|
210 |
|
public SecurityRoleRefSet getInitSecurityRoleRefSet() |
211 |
|
{ |
212 |
0 |
secListWrapper.setInnerCollection(securityRoleRefSet); |
213 |
0 |
return secListWrapper; |
214 |
|
} |
215 |
|
|
216 |
|
|
217 |
|
|
218 |
|
|
219 |
|
public PreferenceSet getPreferenceSet() |
220 |
|
{ |
221 |
|
try |
222 |
|
{ |
223 |
0 |
if (preferenceSet == null) |
224 |
|
{ |
225 |
|
|
226 |
0 |
if(app == null) |
227 |
|
{ |
228 |
0 |
throw new IllegalStateException("Portlet Application must be defined before preferences can be accessed"); |
229 |
|
} |
230 |
|
|
231 |
0 |
Preferences prefNode = PrefsPreference.createPrefenceNode(this); |
232 |
0 |
preferenceSet = new PrefsPreferenceSetImpl(prefNode, this); |
233 |
|
} |
234 |
|
} |
235 |
0 |
catch (BackingStoreException e) |
236 |
|
{ |
237 |
0 |
String msg = "Preference backing store failed: " + e.toString(); |
238 |
0 |
IllegalStateException ise = new IllegalStateException(msg); |
239 |
0 |
ise.initCause(e); |
240 |
0 |
throw ise; |
241 |
0 |
} |
242 |
|
|
243 |
0 |
return preferenceSet; |
244 |
|
} |
245 |
|
|
246 |
|
|
247 |
|
|
248 |
|
|
249 |
|
public void setPreferenceSet( PreferenceSet preferences ) |
250 |
|
{ |
251 |
0 |
this.preferenceSet = (PrefsPreferenceSetImpl) preferences; |
252 |
0 |
} |
253 |
|
|
254 |
|
|
255 |
|
|
256 |
|
|
257 |
|
public ContentTypeSet getContentTypeSet() |
258 |
|
{ |
259 |
0 |
ctListWrapper.setInnerCollection(contentTypes); |
260 |
0 |
return ctListWrapper; |
261 |
|
} |
262 |
|
|
263 |
|
|
264 |
|
|
265 |
|
|
266 |
|
public PortletApplicationDefinition getPortletApplicationDefinition() |
267 |
|
{ |
268 |
0 |
return app; |
269 |
|
} |
270 |
|
|
271 |
|
|
272 |
|
|
273 |
|
|
274 |
|
public ServletDefinition getServletDefinition() |
275 |
|
{ |
276 |
|
|
277 |
0 |
return null; |
278 |
|
} |
279 |
|
|
280 |
|
|
281 |
|
|
282 |
|
|
283 |
|
public String getExpirationCache() |
284 |
|
{ |
285 |
0 |
return expirationCache; |
286 |
|
} |
287 |
|
|
288 |
|
|
289 |
|
|
290 |
|
|
291 |
|
public ClassLoader getPortletClassLoader() |
292 |
|
{ |
293 |
0 |
if ( portletFactory != null ) |
294 |
|
{ |
295 |
0 |
return portletFactory.getPortletApplicationClassLoader(app); |
296 |
|
} |
297 |
0 |
return null; |
298 |
|
} |
299 |
|
|
300 |
|
|
301 |
|
|
302 |
|
|
303 |
|
public void setId( String oid ) |
304 |
|
{ |
305 |
0 |
throw new UnsupportedOperationException(); |
306 |
|
} |
307 |
|
|
308 |
|
|
309 |
|
|
310 |
|
|
311 |
|
public void setClassName( String className ) |
312 |
|
{ |
313 |
0 |
this.className = className; |
314 |
0 |
} |
315 |
|
|
316 |
|
|
317 |
|
|
318 |
|
|
319 |
|
public void setName( String name ) |
320 |
|
{ |
321 |
0 |
this.name = name; |
322 |
0 |
} |
323 |
|
|
324 |
|
|
325 |
|
|
326 |
|
|
327 |
|
public void setPortletClassLoader( ClassLoader loader ) |
328 |
|
{ |
329 |
|
|
330 |
|
; |
331 |
0 |
} |
332 |
|
|
333 |
|
|
334 |
|
|
335 |
|
|
336 |
|
public void addLanguage( Language lang ) |
337 |
|
{ |
338 |
0 |
if (languageSet == null) |
339 |
|
{ |
340 |
0 |
languageSet = new ArrayList(); |
341 |
|
} |
342 |
0 |
langListWrapper.setInnerCollection(languageSet); |
343 |
0 |
langListWrapper.add(lang); |
344 |
0 |
} |
345 |
|
|
346 |
|
|
347 |
|
|
348 |
|
|
349 |
|
public void addLanguage(String title, String shortTitle, String keywords, Locale locale) |
350 |
|
{ |
351 |
0 |
LanguageImpl lang = new LanguageImpl(); |
352 |
0 |
lang.setTitle(title); |
353 |
0 |
lang.setShortTitle(shortTitle); |
354 |
0 |
lang.setKeywords(keywords); |
355 |
0 |
lang.setLocale(locale); |
356 |
|
|
357 |
0 |
addLanguage(lang); |
358 |
0 |
} |
359 |
|
|
360 |
|
|
361 |
|
|
362 |
|
|
363 |
|
public void setContentTypeSet( ContentTypeSet contentTypes ) |
364 |
|
{ |
365 |
0 |
this.contentTypes = ((ContentTypeSetImpl) contentTypes).getInnerCollection(); |
366 |
0 |
} |
367 |
|
|
368 |
|
|
369 |
|
|
370 |
|
|
371 |
|
public void setInitParameterSet( ParameterSet parameters ) |
372 |
|
{ |
373 |
0 |
this.parameterSet = ((ParameterSetImpl) parameters).getInnerCollection(); |
374 |
0 |
} |
375 |
|
|
376 |
|
|
377 |
|
|
378 |
|
|
379 |
|
public void setInitSecurityRoleRefSet( SecurityRoleRefSet securityRefs ) |
380 |
|
{ |
381 |
0 |
this.securityRoleRefSet = ((SecurityRoleRefSetImpl) securityRefs).getInnerCollection(); |
382 |
0 |
} |
383 |
|
|
384 |
|
|
385 |
|
|
386 |
|
|
387 |
|
public void setLanguageSet( LanguageSet languages ) |
388 |
|
{ |
389 |
0 |
this.languageSet = ((LanguageSetImpl) languages).getInnerCollection(); |
390 |
0 |
} |
391 |
|
|
392 |
|
|
393 |
|
|
394 |
|
|
395 |
|
|
396 |
|
|
397 |
|
|
398 |
|
|
399 |
|
/** |
400 |
|
* @see org.apache.jetspeed.om.common.portlet.PortletDefinitionComposite#setUserAttributeSet(java.util.Collection) |
401 |
|
*/ |
402 |
|
|
403 |
|
|
404 |
|
|
405 |
|
|
406 |
|
/** |
407 |
|
* @see org.apache.jetspeed.om.common.portlet.PortletDefinitionComposite#getUserAttributeSet() |
408 |
|
*/ |
409 |
|
|
410 |
|
|
411 |
|
|
412 |
|
/** |
413 |
|
* @see org.apache.jetspeed.om.common.portlet.PortletDefinitionComposite#addUserAttributeRef(org.apache.jetspeed.om.common.UserAttributeRef) |
414 |
|
*/ |
415 |
|
|
416 |
|
|
417 |
|
|
418 |
|
|
419 |
|
|
420 |
|
/** |
421 |
|
* @see org.apache.jetspeed.om.common.portlet.PortletDefinitionComposite#setUserAttributeSet(java.util.Collection) |
422 |
|
*/ |
423 |
|
|
424 |
|
|
425 |
|
|
426 |
|
|
427 |
|
/** |
428 |
|
* @see org.apache.jetspeed.om.common.portlet.PortletDefinitionComposite#getUserAttributeRefSet() |
429 |
|
*/ |
430 |
|
|
431 |
|
|
432 |
|
|
433 |
|
|
434 |
|
|
435 |
|
|
436 |
|
|
437 |
|
|
438 |
|
public ParameterComposite addInitParameter( String name, String value, DescriptionSet description ) |
439 |
|
{ |
440 |
0 |
ParameterComposite pc = addInitParameter(name, value); |
441 |
0 |
pc.setDescriptionSet(description); |
442 |
0 |
return pc; |
443 |
|
} |
444 |
|
|
445 |
|
|
446 |
|
|
447 |
|
|
448 |
|
|
449 |
|
public ParameterComposite addInitParameter( String name, String value, String description, Locale locale ) |
450 |
|
{ |
451 |
0 |
ParameterComposite param = addInitParameter(name, value); |
452 |
0 |
param.addDescription(locale, description); |
453 |
0 |
return param; |
454 |
|
} |
455 |
|
|
456 |
|
public void addInitParameter( Parameter parameter ) |
457 |
|
{ |
458 |
0 |
parameterSet.add(parameter); |
459 |
0 |
} |
460 |
|
|
461 |
|
|
462 |
|
|
463 |
|
|
464 |
|
|
465 |
|
public ParameterComposite addInitParameter( String name, String value ) |
466 |
|
{ |
467 |
0 |
paramListWrapper.setInnerCollection(parameterSet); |
468 |
0 |
return (ParameterComposite) paramListWrapper.add(name, value); |
469 |
|
} |
470 |
|
|
471 |
|
|
472 |
|
|
473 |
|
|
474 |
|
public void setExpirationCache( String cache ) |
475 |
|
{ |
476 |
0 |
expirationCache = cache; |
477 |
0 |
} |
478 |
|
|
479 |
|
|
480 |
|
|
481 |
|
|
482 |
|
public void addContentType( ContentType cType ) |
483 |
|
{ |
484 |
0 |
ctListWrapper.setInnerCollection(contentTypes); |
485 |
0 |
ctListWrapper.addContentType(cType); |
486 |
0 |
} |
487 |
|
|
488 |
|
|
489 |
|
|
490 |
|
|
491 |
|
public void addContentType(String contentType, Collection modes) |
492 |
|
{ |
493 |
0 |
ContentTypeImpl ct = new ContentTypeImpl(); |
494 |
0 |
ct.setContentType(contentType); |
495 |
0 |
ct.setPortletModes(modes); |
496 |
|
|
497 |
0 |
addContentType(ct); |
498 |
0 |
} |
499 |
|
|
500 |
|
|
501 |
|
|
502 |
|
|
503 |
|
|
504 |
|
public PreferenceComposite addPreference( String name, String[] values ) |
505 |
|
{ |
506 |
0 |
return (PreferenceComposite) ((PrefsPreferenceSetImpl) getPreferenceSet()).add(name, Arrays.asList(values)); |
507 |
|
} |
508 |
|
|
509 |
|
public void setPortletIdentifier( String portletIdentifier ) |
510 |
|
{ |
511 |
0 |
this.portletIdentifier = portletIdentifier; |
512 |
0 |
} |
513 |
|
|
514 |
|
public String getPortletIdentifier() |
515 |
|
{ |
516 |
0 |
return this.portletIdentifier; |
517 |
|
} |
518 |
|
|
519 |
|
|
520 |
|
|
521 |
|
|
522 |
|
public void setPortletApplicationDefinition( PortletApplicationDefinition pad ) |
523 |
|
{ |
524 |
0 |
app = (MutablePortletApplication) pad; |
525 |
0 |
} |
526 |
|
|
527 |
|
|
528 |
|
|
529 |
|
|
530 |
|
public boolean equals( Object obj ) |
531 |
|
{ |
532 |
0 |
if (obj != null && obj.getClass().equals(getClass())) |
533 |
|
{ |
534 |
0 |
PortletDefinitionImpl pd = (PortletDefinitionImpl) obj; |
535 |
0 |
boolean sameId = (id != null && pd.id != class="keyword">null && id.equals(pd.id)); |
536 |
0 |
if (sameId) |
537 |
|
{ |
538 |
0 |
return true; |
539 |
|
} |
540 |
0 |
boolean sameAppId = (appId == pd.appId); |
541 |
0 |
boolean sameName = (pd.getName() != null && name != class="keyword">null && pd.getName().equals(name)); |
542 |
0 |
return sameName && sameAppId; |
543 |
|
} |
544 |
0 |
return false; |
545 |
|
} |
546 |
|
|
547 |
|
|
548 |
|
|
549 |
|
|
550 |
|
public int hashCode() |
551 |
|
{ |
552 |
0 |
HashCodeBuilder hasher = new HashCodeBuilder(1, 3); |
553 |
0 |
hasher.append(name); |
554 |
0 |
if (app != null) |
555 |
|
{ |
556 |
0 |
if ( getId() != null ) |
557 |
|
{ |
558 |
0 |
hasher.append(getId().toString()); |
559 |
|
} |
560 |
0 |
hasher.append(app.getName()); |
561 |
|
} |
562 |
0 |
return hasher.toHashCode(); |
563 |
|
} |
564 |
|
|
565 |
|
|
566 |
|
|
567 |
|
|
568 |
|
public String getUniqueName() |
569 |
|
{ |
570 |
0 |
if (app != null && name != class="keyword">null) |
571 |
|
{ |
572 |
0 |
return app.getName() + "::" + name; |
573 |
|
} |
574 |
|
else |
575 |
|
{ |
576 |
0 |
throw new IllegalStateException( |
577 |
|
"Cannot generate a unique portlet name until the application and portlet name have been set"); |
578 |
|
} |
579 |
|
} |
580 |
|
|
581 |
|
|
582 |
|
|
583 |
|
|
584 |
|
public Description getDescription( Locale arg0 ) |
585 |
|
{ |
586 |
0 |
if (descriptions != null) |
587 |
|
{ |
588 |
0 |
descListWrapper.setInnerCollection(descriptions); |
589 |
0 |
return descListWrapper.get(arg0); |
590 |
|
} |
591 |
0 |
return null; |
592 |
|
} |
593 |
|
|
594 |
|
|
595 |
|
|
596 |
|
|
597 |
|
public DisplayName getDisplayName( Locale arg0 ) |
598 |
|
{ |
599 |
0 |
if (displayNames != null) |
600 |
|
{ |
601 |
0 |
DNListWrapper.setInnerCollection(displayNames); |
602 |
0 |
return DNListWrapper.get(arg0); |
603 |
|
} |
604 |
0 |
return null; |
605 |
|
} |
606 |
|
|
607 |
|
|
608 |
|
|
609 |
|
|
610 |
|
public void setDescriptions( DescriptionSet arg0 ) |
611 |
|
{ |
612 |
0 |
this.descriptions = ((DescriptionSetImpl) arg0).getInnerCollection(); |
613 |
0 |
} |
614 |
|
|
615 |
|
|
616 |
|
|
617 |
|
|
618 |
|
public void setDisplayNames( DisplayNameSet arg0 ) |
619 |
|
{ |
620 |
0 |
this.displayNames = ((DisplayNameSetImpl) arg0).getInnerCollection(); |
621 |
0 |
} |
622 |
|
|
623 |
|
|
624 |
|
|
625 |
|
|
626 |
|
|
627 |
|
|
628 |
|
|
629 |
|
|
630 |
|
|
631 |
|
public String getDisplayNameText( Locale locale ) |
632 |
|
{ |
633 |
0 |
DisplayName dn = getDisplayName(locale); |
634 |
0 |
if (dn != null) |
635 |
|
{ |
636 |
0 |
return dn.getDisplayName(); |
637 |
|
} |
638 |
0 |
return null; |
639 |
|
} |
640 |
|
|
641 |
|
|
642 |
|
|
643 |
|
|
644 |
|
|
645 |
|
|
646 |
|
|
647 |
|
|
648 |
|
|
649 |
|
public String getDescriptionText( Locale locale ) |
650 |
|
{ |
651 |
0 |
Description desc = getDescription(locale); |
652 |
0 |
if (desc != null) |
653 |
|
{ |
654 |
0 |
return desc.getDescription(); |
655 |
|
} |
656 |
0 |
return null; |
657 |
|
} |
658 |
|
|
659 |
|
public DescriptionSet getDescriptionSet() |
660 |
|
{ |
661 |
0 |
return this.descListWrapper; |
662 |
|
} |
663 |
|
|
664 |
|
|
665 |
|
|
666 |
|
|
667 |
|
|
668 |
|
public void addDescription( Locale locale, String description ) |
669 |
|
{ |
670 |
0 |
if (descriptions == null) |
671 |
|
{ |
672 |
0 |
descriptions = new ArrayList(); |
673 |
|
} |
674 |
0 |
descListWrapper.setInnerCollection(descriptions); |
675 |
0 |
MutableDescription descObj = new PortletDescriptionImpl(); |
676 |
0 |
descObj.setLocale(locale); |
677 |
0 |
descObj.setDescription(description); |
678 |
0 |
descListWrapper.addDescription(descObj); |
679 |
0 |
} |
680 |
|
|
681 |
|
public void addDescription( Description description ) |
682 |
|
{ |
683 |
0 |
if (descriptions == null) |
684 |
|
{ |
685 |
0 |
descriptions = new ArrayList(); |
686 |
|
} |
687 |
0 |
descListWrapper.setInnerCollection(descriptions); |
688 |
0 |
descListWrapper.addDescription(description); |
689 |
0 |
} |
690 |
|
|
691 |
|
|
692 |
|
|
693 |
|
|
694 |
|
|
695 |
|
public void addDisplayName( Locale locale, String displayName ) |
696 |
|
{ |
697 |
0 |
if (displayNames == null) |
698 |
|
{ |
699 |
0 |
displayNames = new ArrayList(); |
700 |
|
} |
701 |
0 |
DNListWrapper.setInnerCollection(displayNames); |
702 |
0 |
MutableDisplayName dn = new PortletDisplayNameImpl(); |
703 |
0 |
dn.setLocale(locale); |
704 |
0 |
dn.setDisplayName(displayName); |
705 |
0 |
DNListWrapper.addDisplayName(dn); |
706 |
0 |
} |
707 |
|
|
708 |
|
public void addDisplayName( DisplayName displayName ) |
709 |
|
{ |
710 |
0 |
if (displayNames == null) |
711 |
|
{ |
712 |
0 |
displayNames = new ArrayList(); |
713 |
|
} |
714 |
0 |
DNListWrapper.setInnerCollection(displayNames); |
715 |
0 |
DNListWrapper.addDisplayName(displayName); |
716 |
0 |
} |
717 |
|
|
718 |
|
public DisplayNameSet getDisplayNameSet() |
719 |
|
{ |
720 |
0 |
if ( displayNames != null ) |
721 |
|
{ |
722 |
0 |
DNListWrapper.setInnerCollection(displayNames); |
723 |
|
} |
724 |
0 |
return DNListWrapper; |
725 |
|
} |
726 |
|
|
727 |
|
|
728 |
|
|
729 |
|
|
730 |
|
|
731 |
|
|
732 |
|
|
733 |
|
|
734 |
|
|
735 |
|
|
736 |
|
public void store() throws IOException |
737 |
|
{ |
738 |
0 |
if(registry != null) |
739 |
|
{ |
740 |
|
try |
741 |
|
{ |
742 |
0 |
registry.savePortletDefinition(this); |
743 |
|
} |
744 |
0 |
catch (RegistryException e) |
745 |
|
{ |
746 |
0 |
IOException ioe = new IOException("Failed to store portlet definition: "+e.getMessage()); |
747 |
0 |
ioe.initCause(e); |
748 |
0 |
} |
749 |
|
} |
750 |
|
else |
751 |
|
{ |
752 |
0 |
throw new IllegalStateException("The portlet registry for PortletDefinitionImpl has not been set. "+ |
753 |
|
"Please invoke PortletDefinitionImpl.setPortletRegistry before invoking the store() method."); |
754 |
|
} |
755 |
0 |
} |
756 |
|
|
757 |
|
|
758 |
|
|
759 |
|
|
760 |
|
|
761 |
|
|
762 |
|
|
763 |
|
|
764 |
|
public String getPreferenceValidatorClassname() |
765 |
|
{ |
766 |
0 |
return preferenceValidatorClassname; |
767 |
|
} |
768 |
|
|
769 |
|
|
770 |
|
|
771 |
|
|
772 |
|
|
773 |
|
|
774 |
|
|
775 |
|
|
776 |
|
|
777 |
|
public void setPreferenceValidatorClassname( String string ) |
778 |
|
{ |
779 |
0 |
preferenceValidatorClassname = string; |
780 |
0 |
} |
781 |
|
|
782 |
|
|
783 |
|
|
784 |
|
|
785 |
|
|
786 |
|
public void addPreference( Preference preference ) |
787 |
|
{ |
788 |
0 |
Iterator valueItr = preference.getValues(); |
789 |
0 |
ArrayList list = new ArrayList(); |
790 |
0 |
while (valueItr.hasNext()) |
791 |
|
{ |
792 |
0 |
list.add(valueItr.next()); |
793 |
|
} |
794 |
|
|
795 |
0 |
PreferenceComposite newPref = (PreferenceComposite) ((PreferenceSetComposite) getPreferenceSet()).add( |
796 |
|
preference.getName(), list); |
797 |
|
|
798 |
0 |
Iterator descItr = newPref.getDescriptions(); |
799 |
0 |
while (descItr.hasNext()) |
800 |
|
{ |
801 |
0 |
Description desc = (Description) descItr.next(); |
802 |
0 |
newPref.addDescription(desc.getLocale(), desc.getDescription()); |
803 |
0 |
} |
804 |
|
|
805 |
0 |
} |
806 |
|
|
807 |
|
|
808 |
|
|
809 |
|
|
810 |
|
public void addSecurityRoleRef( SecurityRoleRef securityRef ) |
811 |
|
{ |
812 |
0 |
secListWrapper.setInnerCollection(securityRoleRefSet); |
813 |
0 |
secListWrapper.add(securityRef); |
814 |
0 |
} |
815 |
|
|
816 |
|
|
817 |
|
|
818 |
|
|
819 |
|
public SecurityRoleRef addSecurityRoleRef(String roleName, String roleLink) |
820 |
|
{ |
821 |
0 |
SecurityRoleRefImpl ref = new SecurityRoleRefImpl(); |
822 |
0 |
ref.setRoleName(roleName); |
823 |
0 |
ref.setRoleLink(roleLink); |
824 |
|
|
825 |
0 |
addSecurityRoleRef(ref); |
826 |
|
|
827 |
0 |
return ref; |
828 |
|
} |
829 |
|
|
830 |
|
|
831 |
|
|
832 |
|
|
833 |
|
public GenericMetadata getMetadata() |
834 |
|
{ |
835 |
0 |
if (metadataFields == null) |
836 |
|
{ |
837 |
0 |
metadataFields = new ArrayList(); |
838 |
|
} |
839 |
|
|
840 |
0 |
GenericMetadata metadata = new PortletDefinitionMetadataImpl(); |
841 |
0 |
metadata.setFields(metadataFields); |
842 |
|
|
843 |
0 |
return metadata; |
844 |
|
} |
845 |
|
|
846 |
|
|
847 |
|
|
848 |
|
|
849 |
|
public void setMetadata( GenericMetadata metadata ) |
850 |
|
{ |
851 |
0 |
this.metadataFields = metadata.getFields(); |
852 |
0 |
} |
853 |
|
|
854 |
|
|
855 |
|
|
856 |
|
|
857 |
|
protected Collection getMetadataFields() |
858 |
|
{ |
859 |
0 |
return metadataFields; |
860 |
|
} |
861 |
|
|
862 |
|
|
863 |
|
|
864 |
|
|
865 |
|
protected void setMetadataFields( Collection metadataFields ) |
866 |
|
{ |
867 |
0 |
this.metadataFields = metadataFields; |
868 |
0 |
} |
869 |
|
|
870 |
|
|
871 |
|
|
872 |
|
|
873 |
|
public String getResourceBundle() |
874 |
|
{ |
875 |
0 |
return resourceBundle; |
876 |
|
} |
877 |
|
|
878 |
|
|
879 |
|
|
880 |
|
|
881 |
|
public void setResourceBundle(String string) |
882 |
|
{ |
883 |
0 |
resourceBundle = string; |
884 |
0 |
} |
885 |
|
|
886 |
|
public Collection getSupportedLocales() |
887 |
|
{ |
888 |
0 |
return supportedLocales; |
889 |
|
} |
890 |
|
|
891 |
|
public void addSupportedLocale(String locale) |
892 |
|
{ |
893 |
|
|
894 |
0 |
StringTokenizer tokenizer = new StringTokenizer(locale, "_"); |
895 |
0 |
String[] localeDef = new String[3]; |
896 |
0 |
for (int i = 0; i < 3; i++) |
897 |
|
{ |
898 |
0 |
if (tokenizer.hasMoreTokens()) |
899 |
|
{ |
900 |
0 |
localeDef[i] = tokenizer.nextToken(); |
901 |
|
} |
902 |
|
else |
903 |
|
{ |
904 |
0 |
localeDef[i] = ""; |
905 |
|
} |
906 |
|
} |
907 |
0 |
supportedLocales.add(new Locale(localeDef[0], localeDef[1], localeDef[2])); |
908 |
0 |
} |
909 |
|
|
910 |
|
|
911 |
|
|
912 |
|
|
913 |
|
public void postLoad(Object parameter) throws Exception |
914 |
|
{ |
915 |
0 |
if (resourceBundle != null) |
916 |
|
{ |
917 |
0 |
langListWrapper.setResources(resourceBundle); |
918 |
|
} |
919 |
|
|
920 |
0 |
if (parameter instanceof ClassLoader) |
921 |
|
{ |
922 |
|
|
923 |
0 |
langListWrapper.setClassLoader((ClassLoader) parameter); |
924 |
|
|
925 |
|
|
926 |
0 |
langListWrapper.postLoad(this.supportedLocales); |
927 |
|
} |
928 |
|
else |
929 |
|
{ |
930 |
|
|
931 |
0 |
langListWrapper.setClassLoader(getPortletClassLoader()); |
932 |
|
} |
933 |
0 |
} |
934 |
|
|
935 |
|
public static void setPortletRegistry(PortletRegistry registry) |
936 |
|
{ |
937 |
0 |
PortletDefinitionImpl.registry = registry; |
938 |
0 |
} |
939 |
|
|
940 |
|
public static void setPortletFactory(PortletFactory portletFactory) |
941 |
|
{ |
942 |
0 |
PortletDefinitionImpl.portletFactory = portletFactory; |
943 |
0 |
} |
944 |
|
|
945 |
|
public PreferencesValidator getPreferencesValidator() |
946 |
|
{ |
947 |
0 |
if ( portletFactory != null ) |
948 |
|
{ |
949 |
0 |
return portletFactory.getPreferencesValidator(this); |
950 |
|
} |
951 |
0 |
return null; |
952 |
|
} |
953 |
|
|
954 |
|
|
955 |
|
|
956 |
|
|
957 |
|
public String getJetspeedSecurityConstraint() |
958 |
|
{ |
959 |
0 |
return this.jetspeedSecurityConstraint; |
960 |
|
} |
961 |
|
|
962 |
|
|
963 |
|
|
964 |
|
|
965 |
|
public void setJetspeedSecurityConstraint(String constraint) |
966 |
|
{ |
967 |
0 |
this.jetspeedSecurityConstraint = constraint; |
968 |
0 |
} |
969 |
|
} |