1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
package org.apache.jetspeed.om.portlet.impl; |
19 |
|
|
20 |
|
import java.io.Serializable; |
21 |
|
import java.util.ArrayList; |
22 |
|
import java.util.Collection; |
23 |
|
import java.util.Collections; |
24 |
|
import java.util.HashMap; |
25 |
|
import java.util.Iterator; |
26 |
|
import java.util.List; |
27 |
|
import java.util.Map; |
28 |
|
|
29 |
|
import javax.portlet.PortletMode; |
30 |
|
import javax.portlet.WindowState; |
31 |
|
|
32 |
|
import org.apache.jetspeed.JetspeedActions; |
33 |
|
import org.apache.jetspeed.om.common.GenericMetadata; |
34 |
|
import org.apache.jetspeed.om.common.JetspeedServiceReference; |
35 |
|
import org.apache.jetspeed.om.common.Support; |
36 |
|
import org.apache.jetspeed.om.common.UserAttribute; |
37 |
|
import org.apache.jetspeed.om.common.UserAttributeRef; |
38 |
|
import org.apache.jetspeed.om.common.portlet.CustomPortletMode; |
39 |
|
import org.apache.jetspeed.om.common.portlet.CustomWindowState; |
40 |
|
import org.apache.jetspeed.om.common.portlet.MutablePortletApplication; |
41 |
|
import org.apache.jetspeed.om.common.portlet.PortletDefinitionComposite; |
42 |
|
import org.apache.jetspeed.om.impl.UserAttributeImpl; |
43 |
|
import org.apache.jetspeed.util.JetspeedLongObjectID; |
44 |
|
import org.apache.pluto.om.common.ObjectID; |
45 |
|
import org.apache.pluto.om.portlet.PortletDefinition; |
46 |
|
import org.apache.pluto.om.portlet.PortletDefinitionList; |
47 |
|
import org.apache.pluto.om.servlet.WebApplicationDefinition; |
48 |
|
|
49 |
|
|
50 |
|
|
51 |
|
|
52 |
|
|
53 |
|
|
54 |
|
|
55 |
|
|
56 |
|
public class PortletApplicationDefinitionImpl implements MutablePortletApplication, Serializable, Support |
57 |
|
{ |
58 |
|
|
59 |
|
|
60 |
|
|
61 |
|
|
62 |
|
private Long id; |
63 |
|
|
64 |
|
private JetspeedLongObjectID oid; |
65 |
|
|
66 |
|
|
67 |
|
private String name; |
68 |
|
|
69 |
|
|
70 |
|
private String version; |
71 |
|
|
72 |
|
|
73 |
|
private String applicationIdentifier; |
74 |
|
|
75 |
|
|
76 |
|
private transient WebApplicationDefinition webApplication; |
77 |
|
|
78 |
|
protected long webApplicationId; |
79 |
|
|
80 |
|
|
81 |
0 |
private Collection metadataFields = null; |
82 |
|
|
83 |
|
|
84 |
0 |
private Collection services = new ArrayList(); |
85 |
|
|
86 |
|
|
87 |
|
private String description; |
88 |
|
|
89 |
|
private Collection portlets; |
90 |
|
|
91 |
|
|
92 |
|
private Collection userAttributeRefs; |
93 |
|
|
94 |
|
|
95 |
|
private Collection userAttributes; |
96 |
|
|
97 |
0 |
private PortletDefinitionListImpl listWrapper = new PortletDefinitionListImpl(); |
98 |
|
|
99 |
0 |
private int applicationType = MutablePortletApplication.WEBAPP; |
100 |
|
|
101 |
0 |
private String checksum = "0"; |
102 |
0 |
private long checksumLong = -1; |
103 |
|
|
104 |
|
private List customPortletModes; |
105 |
|
private List customWindowStates; |
106 |
|
|
107 |
0 |
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 |
|
|
117 |
|
public PortletApplicationDefinitionImpl() |
118 |
0 |
{ |
119 |
0 |
portlets = new ArrayList(); |
120 |
0 |
userAttributes = new ArrayList(); |
121 |
0 |
userAttributeRefs = new ArrayList(); |
122 |
0 |
customPortletModes = new ArrayList(); |
123 |
0 |
customWindowStates = new ArrayList(); |
124 |
0 |
} |
125 |
|
|
126 |
|
|
127 |
|
|
128 |
|
|
129 |
|
public ObjectID getId() |
130 |
|
{ |
131 |
0 |
if ( oid == null && id != class="keyword">null ) |
132 |
|
{ |
133 |
0 |
oid = new JetspeedLongObjectID(id); |
134 |
|
} |
135 |
0 |
return oid; |
136 |
|
} |
137 |
|
|
138 |
|
|
139 |
|
|
140 |
|
|
141 |
|
public String getName() |
142 |
|
{ |
143 |
0 |
return this.name; |
144 |
|
} |
145 |
|
|
146 |
|
|
147 |
|
|
148 |
|
|
149 |
|
public void setName(String name) |
150 |
|
{ |
151 |
0 |
this.name = name; |
152 |
0 |
} |
153 |
|
|
154 |
|
|
155 |
|
|
156 |
|
|
157 |
|
public String getVersion() |
158 |
|
{ |
159 |
0 |
return this.version; |
160 |
|
} |
161 |
|
|
162 |
|
|
163 |
|
|
164 |
|
|
165 |
|
public void setVersion(String version) |
166 |
|
{ |
167 |
0 |
this.version = version; |
168 |
0 |
} |
169 |
|
|
170 |
|
|
171 |
|
|
172 |
|
|
173 |
|
public WebApplicationDefinition getWebApplicationDefinition() |
174 |
|
{ |
175 |
0 |
return webApplication; |
176 |
|
} |
177 |
|
|
178 |
|
|
179 |
|
|
180 |
|
|
181 |
|
public PortletDefinitionList getPortletDefinitionList() |
182 |
|
{ |
183 |
0 |
return new PortletDefinitionListImpl(portlets); |
184 |
|
} |
185 |
|
|
186 |
|
|
187 |
|
|
188 |
|
|
189 |
|
public String getDescription() |
190 |
|
{ |
191 |
0 |
return description; |
192 |
|
} |
193 |
|
|
194 |
|
|
195 |
|
|
196 |
|
|
197 |
|
public void setDescription(String string) |
198 |
|
{ |
199 |
0 |
description = string; |
200 |
0 |
} |
201 |
|
|
202 |
|
|
203 |
|
|
204 |
|
|
205 |
|
public void setWebApplicationDefinition(WebApplicationDefinition wad) |
206 |
|
{ |
207 |
0 |
this.webApplication = wad; |
208 |
|
|
209 |
0 |
} |
210 |
|
|
211 |
|
|
212 |
|
|
213 |
|
|
214 |
|
public void addPortletDefinition(PortletDefinition pd) |
215 |
|
{ |
216 |
0 |
((PortletDefinitionComposite) pd).setPortletApplicationDefinition(this); |
217 |
0 |
portlets.add(pd); |
218 |
0 |
} |
219 |
|
|
220 |
|
|
221 |
|
|
222 |
|
|
223 |
|
public Collection getPortletDefinitions() |
224 |
|
{ |
225 |
0 |
return portlets; |
226 |
|
} |
227 |
|
|
228 |
|
|
229 |
|
|
230 |
|
|
231 |
|
public PortletDefinition getPortletDefinitionByName(String name) |
232 |
|
{ |
233 |
0 |
listWrapper.setInnerCollection(portlets); |
234 |
0 |
return listWrapper.get(name); |
235 |
|
} |
236 |
|
|
237 |
|
|
238 |
|
|
239 |
|
|
240 |
|
public void setPortletDefinitionList(PortletDefinitionList portlets) |
241 |
|
{ |
242 |
0 |
this.portlets = ((PortletDefinitionListImpl) portlets).getInnerCollection(); |
243 |
0 |
} |
244 |
|
|
245 |
|
|
246 |
|
|
247 |
|
|
248 |
|
public void setUserAttributeRefs(Collection userAttributeRefs) |
249 |
|
{ |
250 |
0 |
this.userAttributeRefs = userAttributeRefs; |
251 |
0 |
} |
252 |
|
|
253 |
|
|
254 |
|
|
255 |
|
|
256 |
|
public Collection getUserAttributeRefs() |
257 |
|
{ |
258 |
0 |
return this.userAttributeRefs; |
259 |
|
} |
260 |
|
|
261 |
|
|
262 |
|
|
263 |
|
|
264 |
|
public void addUserAttributeRef(UserAttributeRef userAttributeRef) |
265 |
|
{ |
266 |
0 |
userAttributeRefs.add(userAttributeRef); |
267 |
0 |
} |
268 |
|
|
269 |
|
|
270 |
|
|
271 |
|
|
272 |
|
public void addUserAttribute(UserAttribute userAttribute) |
273 |
|
{ |
274 |
0 |
userAttributes.add(userAttribute); |
275 |
0 |
} |
276 |
|
|
277 |
|
|
278 |
|
|
279 |
|
|
280 |
|
public void addUserAttribute(String userName, String description) |
281 |
|
{ |
282 |
0 |
UserAttributeImpl userAttribute = new UserAttributeImpl(); |
283 |
0 |
userAttribute.setName(userName); |
284 |
0 |
userAttribute.setDescription(description); |
285 |
0 |
userAttributes.add(userAttribute); |
286 |
0 |
} |
287 |
|
|
288 |
|
|
289 |
|
|
290 |
|
|
291 |
|
public void setUserAttributes(Collection userAttributes) |
292 |
|
{ |
293 |
0 |
this.userAttributes = userAttributes; |
294 |
0 |
} |
295 |
|
|
296 |
|
|
297 |
|
|
298 |
|
|
299 |
|
public Collection getUserAttributes() |
300 |
|
{ |
301 |
0 |
return this.userAttributes; |
302 |
|
} |
303 |
|
|
304 |
|
|
305 |
|
|
306 |
|
|
307 |
|
public void setApplicationIdentifier(String applicationIdentifier) |
308 |
|
{ |
309 |
0 |
this.applicationIdentifier = applicationIdentifier; |
310 |
0 |
} |
311 |
|
|
312 |
|
|
313 |
|
|
314 |
|
|
315 |
|
public String getApplicationIdentifier() |
316 |
|
{ |
317 |
0 |
return this.applicationIdentifier; |
318 |
|
} |
319 |
|
|
320 |
|
|
321 |
|
|
322 |
|
|
323 |
|
public void setApplicationType(int type) |
324 |
|
{ |
325 |
0 |
this.applicationType = type; |
326 |
0 |
} |
327 |
|
|
328 |
|
|
329 |
|
|
330 |
|
|
331 |
|
public int getApplicationType() |
332 |
|
{ |
333 |
0 |
return applicationType; |
334 |
|
} |
335 |
|
|
336 |
|
|
337 |
|
|
338 |
|
|
339 |
|
public GenericMetadata getMetadata() |
340 |
|
{ |
341 |
0 |
if(metadataFields == null) |
342 |
|
{ |
343 |
0 |
metadataFields = new ArrayList(); |
344 |
|
} |
345 |
|
|
346 |
0 |
GenericMetadata metadata = new PortletApplicationMetadataImpl(); |
347 |
0 |
metadata.setFields(metadataFields); |
348 |
|
|
349 |
0 |
return metadata; |
350 |
|
} |
351 |
|
|
352 |
|
|
353 |
|
|
354 |
|
|
355 |
|
public void setMetadata(GenericMetadata metadata) |
356 |
|
{ |
357 |
0 |
this.metadataFields = metadata.getFields(); |
358 |
0 |
} |
359 |
|
|
360 |
|
|
361 |
|
|
362 |
|
|
363 |
|
protected Collection getMetadataFields() |
364 |
|
{ |
365 |
0 |
return metadataFields; |
366 |
|
} |
367 |
|
|
368 |
|
|
369 |
|
|
370 |
|
|
371 |
|
protected void setMetadataFields(Collection metadataFields) |
372 |
|
{ |
373 |
0 |
this.metadataFields = metadataFields; |
374 |
0 |
} |
375 |
|
|
376 |
|
|
377 |
|
|
378 |
|
|
379 |
|
public Collection getJetspeedServices() |
380 |
|
{ |
381 |
0 |
return services; |
382 |
|
} |
383 |
|
|
384 |
|
|
385 |
|
|
386 |
|
|
387 |
|
public void addJetspeedService(JetspeedServiceReference service) |
388 |
|
{ |
389 |
0 |
services.add(service); |
390 |
0 |
} |
391 |
|
|
392 |
|
public long getChecksum() |
393 |
|
{ |
394 |
0 |
if(checksumLong == -1) |
395 |
|
{ |
396 |
0 |
checksumLong = Long.parseLong(checksum); |
397 |
|
} |
398 |
0 |
return checksumLong; |
399 |
|
} |
400 |
|
|
401 |
|
public void setChecksum(long checksum) |
402 |
|
{ |
403 |
0 |
this.checksumLong = checksum; |
404 |
0 |
this.checksum = Long.toString(checksum); |
405 |
0 |
} |
406 |
|
|
407 |
|
|
408 |
|
|
409 |
|
|
410 |
|
public void postLoad(Object parameter) throws Exception |
411 |
|
{ |
412 |
0 |
Iterator portletDefinitions = getPortletDefinitions().iterator(); |
413 |
0 |
while (portletDefinitions.hasNext()) |
414 |
|
{ |
415 |
0 |
((Support) portletDefinitions.next()).postLoad(this); |
416 |
|
} |
417 |
0 |
} |
418 |
|
|
419 |
|
public Collection getCustomPortletModes() |
420 |
|
{ |
421 |
0 |
return customPortletModes; |
422 |
|
} |
423 |
|
|
424 |
|
public void addCustomPortletMode(CustomPortletMode customPortletMode) |
425 |
|
{ |
426 |
|
|
427 |
0 |
supportedPortletModes = null; |
428 |
0 |
supportedCustomModes = null; |
429 |
0 |
mappedCustomModes = null; |
430 |
|
|
431 |
0 |
if ( !customPortletModes.contains(customPortletMode) ) |
432 |
|
{ |
433 |
0 |
customPortletModes.add(customPortletMode); |
434 |
|
} |
435 |
0 |
} |
436 |
|
|
437 |
|
public void setCustomPortletModes(Collection customPortletModes) |
438 |
|
{ |
439 |
|
|
440 |
0 |
supportedPortletModes = null; |
441 |
0 |
supportedCustomModes = null; |
442 |
0 |
mappedCustomModes = null; |
443 |
|
|
444 |
0 |
this.customPortletModes.clear(); |
445 |
|
|
446 |
0 |
if ( customPortletModes != null ) |
447 |
|
{ |
448 |
0 |
this.customPortletModes.addAll(customPortletModes); |
449 |
|
} |
450 |
0 |
} |
451 |
|
|
452 |
|
public PortletMode getMappedPortletMode(PortletMode mode) |
453 |
|
{ |
454 |
0 |
if ( JetspeedActions.getStandardPortletModes().contains(mode) ) |
455 |
|
{ |
456 |
0 |
return mode; |
457 |
|
} |
458 |
0 |
else if ( getSupportedPortletModes().contains(mode) ) |
459 |
|
{ |
460 |
0 |
return (PortletMode)mappedCustomModes.get(mode); |
461 |
|
} |
462 |
0 |
return null; |
463 |
|
} |
464 |
|
|
465 |
|
public PortletMode getCustomPortletMode(PortletMode mode) |
466 |
|
{ |
467 |
0 |
if (JetspeedActions.getStandardPortletModes().contains(mode)) |
468 |
|
{ |
469 |
0 |
return mode; |
470 |
|
} |
471 |
0 |
else if (JetspeedActions.getExtendedPortletModes().contains(mode)) |
472 |
|
{ |
473 |
|
|
474 |
0 |
getSupportedPortletModes(); |
475 |
0 |
return (PortletMode)supportedCustomModes.get(mode); |
476 |
|
} |
477 |
0 |
return null; |
478 |
|
} |
479 |
|
|
480 |
|
public Collection getSupportedPortletModes() |
481 |
|
{ |
482 |
0 |
if ( supportedPortletModes == null ) |
483 |
|
{ |
484 |
0 |
ArrayList list = new ArrayList(JetspeedActions.getStandardPortletModes()); |
485 |
0 |
supportedCustomModes = new HashMap(); |
486 |
0 |
mappedCustomModes = new HashMap(); |
487 |
|
|
488 |
0 |
if ( customPortletModes.size() > 0 ) |
489 |
|
{ |
490 |
0 |
Iterator iter = customPortletModes.iterator(); |
491 |
0 |
while ( iter.hasNext() ) |
492 |
|
{ |
493 |
0 |
CustomPortletMode customMode = (CustomPortletMode)iter.next(); |
494 |
0 |
if ( !list.contains(customMode.getCustomMode()) && JetspeedActions.getExtendedPortletModes().contains(customMode.getMappedMode()) ) |
495 |
|
{ |
496 |
0 |
list.add(customMode.getCustomMode()); |
497 |
0 |
supportedCustomModes.put(customMode.getMappedMode(), customMode.getCustomMode()); |
498 |
0 |
mappedCustomModes.put(customMode.getCustomMode(), customMode.getMappedMode()); |
499 |
|
} |
500 |
0 |
} |
501 |
|
} |
502 |
0 |
supportedPortletModes = Collections.unmodifiableCollection(list); |
503 |
|
} |
504 |
0 |
return supportedPortletModes; |
505 |
|
} |
506 |
|
|
507 |
|
public Collection getCustomWindowStates() |
508 |
|
{ |
509 |
0 |
return customWindowStates; |
510 |
|
} |
511 |
|
|
512 |
|
public void addCustomWindowState(CustomWindowState customWindowState) |
513 |
|
{ |
514 |
|
|
515 |
0 |
supportedWindowStates = null; |
516 |
0 |
supportedCustomStates = null; |
517 |
0 |
mappedCustomStates = null; |
518 |
|
|
519 |
0 |
if ( !customWindowStates.contains(customWindowState) ) |
520 |
|
{ |
521 |
0 |
customWindowStates.add(customWindowState); |
522 |
|
} |
523 |
0 |
} |
524 |
|
|
525 |
|
public void setCustomWindowStates(Collection customWindowStates) |
526 |
|
{ |
527 |
|
|
528 |
0 |
supportedWindowStates = null; |
529 |
0 |
supportedCustomStates = null; |
530 |
0 |
mappedCustomStates = null; |
531 |
|
|
532 |
0 |
this.customWindowStates.clear(); |
533 |
|
|
534 |
0 |
if ( customWindowStates != null ) |
535 |
|
{ |
536 |
0 |
this.customWindowStates.addAll(customWindowStates); |
537 |
|
} |
538 |
0 |
} |
539 |
|
|
540 |
|
public WindowState getMappedWindowState(WindowState state) |
541 |
|
{ |
542 |
0 |
if (JetspeedActions.getStandardWindowStates().contains(state) ) |
543 |
|
{ |
544 |
0 |
return state; |
545 |
|
} |
546 |
0 |
else if ( getSupportedWindowStates().contains(state) ) |
547 |
|
{ |
548 |
0 |
return (WindowState)mappedCustomStates.get(state); |
549 |
|
} |
550 |
0 |
return null; |
551 |
|
} |
552 |
|
|
553 |
|
public WindowState getCustomWindowState(WindowState state) |
554 |
|
{ |
555 |
0 |
if (JetspeedActions.getStandardWindowStates().contains(state)) |
556 |
|
{ |
557 |
0 |
return state; |
558 |
|
} |
559 |
0 |
else if (JetspeedActions.getExtendedWindowStates().contains(state)) |
560 |
|
{ |
561 |
|
|
562 |
0 |
getSupportedWindowStates(); |
563 |
0 |
return (WindowState)supportedCustomStates.get(state); |
564 |
|
} |
565 |
0 |
return null; |
566 |
|
} |
567 |
|
|
568 |
|
public Collection getSupportedWindowStates() |
569 |
|
{ |
570 |
0 |
if ( supportedWindowStates == null ) |
571 |
|
{ |
572 |
0 |
ArrayList list = new ArrayList(JetspeedActions.getStandardWindowStates()); |
573 |
0 |
supportedCustomStates = new HashMap(); |
574 |
0 |
mappedCustomStates = new HashMap(); |
575 |
|
|
576 |
0 |
if ( customWindowStates.size() > 0 ) |
577 |
|
{ |
578 |
0 |
Iterator iter = customWindowStates.iterator(); |
579 |
0 |
while ( iter.hasNext() ) |
580 |
|
{ |
581 |
0 |
CustomWindowState customState = (CustomWindowState)iter.next(); |
582 |
0 |
if ( !list.contains(customState.getCustomState()) && JetspeedActions.getExtendedWindowStates().contains(customState.getMappedState()) ) |
583 |
|
{ |
584 |
0 |
list.add(customState.getCustomState()); |
585 |
0 |
supportedCustomStates.put(customState.getMappedState(),customState.getCustomState()); |
586 |
0 |
mappedCustomStates.put(customState.getCustomState(),customState.getMappedState()); |
587 |
|
} |
588 |
0 |
} |
589 |
|
} |
590 |
0 |
supportedWindowStates = Collections.unmodifiableCollection(list); |
591 |
|
} |
592 |
0 |
return supportedWindowStates; |
593 |
|
} |
594 |
|
|
595 |
|
|
596 |
|
|
597 |
|
|
598 |
|
public String getJetspeedSecurityConstraint() |
599 |
|
{ |
600 |
0 |
return this.jetspeedSecurityConstraint; |
601 |
|
} |
602 |
|
|
603 |
|
|
604 |
|
|
605 |
|
|
606 |
|
public void setJetspeedSecurityConstraint(String constraint) |
607 |
|
{ |
608 |
0 |
this.jetspeedSecurityConstraint = constraint; |
609 |
0 |
} |
610 |
|
|
611 |
|
public boolean isLayoutApplication() |
612 |
|
{ |
613 |
0 |
if (this.getMetadata() != null) |
614 |
|
{ |
615 |
0 |
Collection c = this.getMetadata().getFields("layout-app"); |
616 |
0 |
if (c != null) |
617 |
|
{ |
618 |
0 |
if (!c.isEmpty()) |
619 |
|
{ |
620 |
0 |
return true; |
621 |
|
} |
622 |
|
} |
623 |
|
} |
624 |
0 |
return false; |
625 |
|
} |
626 |
|
} |