1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
package org.apache.jetspeed.layout.impl; |
18 |
|
|
19 |
|
import java.util.Map; |
20 |
|
|
21 |
|
import org.apache.commons.logging.Log; |
22 |
|
import org.apache.commons.logging.LogFactory; |
23 |
|
import org.apache.jetspeed.JetspeedActions; |
24 |
|
import org.apache.jetspeed.ajax.AjaxAction; |
25 |
|
import org.apache.jetspeed.ajax.AjaxBuilder; |
26 |
|
import org.apache.jetspeed.decoration.DecorationFactory; |
27 |
|
import org.apache.jetspeed.layout.PortletActionSecurityBehavior; |
28 |
|
import org.apache.jetspeed.request.RequestContext; |
29 |
|
|
30 |
|
|
31 |
|
|
32 |
|
|
33 |
|
|
34 |
|
|
35 |
|
|
36 |
|
|
37 |
|
|
38 |
|
|
39 |
|
|
40 |
|
public class GetThemesAction |
41 |
|
extends BasePortletAction |
42 |
|
implements AjaxAction, AjaxBuilder, Constants |
43 |
|
{ |
44 |
0 |
protected static final Log log = LogFactory.getLog(GetThemesAction.class); |
45 |
|
protected DecorationFactory decorationFactory; |
46 |
|
|
47 |
|
public GetThemesAction(String template, |
48 |
|
String errorTemplate, |
49 |
|
DecorationFactory decorationFactory, |
50 |
|
PortletActionSecurityBehavior securityBehavior) |
51 |
|
{ |
52 |
0 |
super(template, errorTemplate, securityBehavior); |
53 |
0 |
this.decorationFactory = decorationFactory; |
54 |
0 |
} |
55 |
|
|
56 |
|
public boolean run( RequestContext requestContext, Map resultMap ) |
57 |
|
{ |
58 |
0 |
boolean success = true; |
59 |
0 |
String status = "success"; |
60 |
|
try |
61 |
|
{ |
62 |
0 |
resultMap.put( ACTION, "getthemes" ); |
63 |
0 |
if (false == checkAccess( requestContext, JetspeedActions.VIEW ) ) |
64 |
|
{ |
65 |
0 |
success = false; |
66 |
0 |
resultMap.put( REASON, "Insufficient access to get themes" ); |
67 |
0 |
return success; |
68 |
|
} |
69 |
0 |
String type = getActionParameter(requestContext, TYPE ); |
70 |
0 |
String format = getActionParameter(requestContext, FORMAT ); |
71 |
0 |
if (format == null) |
72 |
0 |
format = "xml"; |
73 |
0 |
if (type == null || type.equals( PAGE_DECORATIONS ) ) |
74 |
0 |
resultMap.put( PAGE_DECORATIONS, decorationFactory.getPageDecorations( requestContext ) ); |
75 |
0 |
if (type == null || type.equals( PORTLET_DECORATIONS ) ) |
76 |
0 |
resultMap.put( PORTLET_DECORATIONS, decorationFactory.getPortletDecorations( requestContext ) ); |
77 |
0 |
if (type == null || type.equals( LAYOUTS ) ) |
78 |
0 |
resultMap.put( LAYOUTS, decorationFactory.getLayouts( requestContext ) ); |
79 |
0 |
if (type == null || type.equals( DESKTOP_PAGE_DECORATIONS) ) |
80 |
0 |
resultMap.put( DESKTOP_PAGE_DECORATIONS, decorationFactory.getDesktopPageDecorations( requestContext ) ); |
81 |
0 |
if (type == null || type.equals( DESKTOP_PORTLET_DECORATIONS ) ) |
82 |
0 |
resultMap.put( DESKTOP_PORTLET_DECORATIONS, decorationFactory.getDesktopPortletDecorations( requestContext ) ); |
83 |
0 |
resultMap.put( TYPE, type ); |
84 |
0 |
resultMap.put( FORMAT, format ); |
85 |
0 |
resultMap.put( STATUS, status ); |
86 |
|
} |
87 |
0 |
catch (Exception e) |
88 |
|
{ |
89 |
|
|
90 |
0 |
log.error( "exception while getting theme info", e ); |
91 |
|
|
92 |
0 |
success = false; |
93 |
0 |
} |
94 |
|
|
95 |
0 |
return success; |
96 |
|
} |
97 |
|
|
98 |
|
|
99 |
|
} |