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 * Get Portal-wide themes lists
32 * (page decorators, portlet decorators, layouts, desktop-page-decorators, desktop-portlet-decorators)
33 *
34 * AJAX Parameters:
35 * none
36 *
37 * @author <a href="mailto:taylor@apache.org">David Sean Taylor</a>
38 * @version $Id: $
39 */
40 public class GetThemesAction
41 extends BasePortletAction
42 implements AjaxAction, AjaxBuilder, Constants
43 {
44 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 super(template, errorTemplate, securityBehavior);
53 this.decorationFactory = decorationFactory;
54 }
55
56 public boolean run( RequestContext requestContext, Map resultMap )
57 {
58 boolean success = true;
59 String status = "success";
60 try
61 {
62 resultMap.put( ACTION, "getthemes" );
63 if (false == checkAccess( requestContext, JetspeedActions.VIEW ) )
64 {
65 success = false;
66 resultMap.put( REASON, "Insufficient access to get themes" );
67 return success;
68 }
69 String type = getActionParameter(requestContext, TYPE );
70 String format = getActionParameter(requestContext, FORMAT );
71 if (format == null)
72 format = "xml";
73 if (type == null || type.equals( PAGE_DECORATIONS ) )
74 resultMap.put( PAGE_DECORATIONS, decorationFactory.getPageDecorations( requestContext ) );
75 if (type == null || type.equals( PORTLET_DECORATIONS ) )
76 resultMap.put( PORTLET_DECORATIONS, decorationFactory.getPortletDecorations( requestContext ) );
77 if (type == null || type.equals( LAYOUTS ) )
78 resultMap.put( LAYOUTS, decorationFactory.getLayouts( requestContext ) );
79 if (type == null || type.equals( DESKTOP_PAGE_DECORATIONS) )
80 resultMap.put( DESKTOP_PAGE_DECORATIONS, decorationFactory.getDesktopPageDecorations( requestContext ) );
81 if (type == null || type.equals( DESKTOP_PORTLET_DECORATIONS ) )
82 resultMap.put( DESKTOP_PORTLET_DECORATIONS, decorationFactory.getDesktopPortletDecorations( requestContext ) );
83 resultMap.put( TYPE, type );
84 resultMap.put( FORMAT, format );
85 resultMap.put( STATUS, status );
86 }
87 catch (Exception e)
88 {
89
90 log.error( "exception while getting theme info", e );
91
92 success = false;
93 }
94
95 return success;
96 }
97
98
99 }