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.layout.PortletActionSecurityBehavior;
27 import org.apache.jetspeed.om.folder.Folder;
28 import org.apache.jetspeed.page.PageManager;
29 import org.apache.jetspeed.request.RequestContext;
30
31 /***
32 * Retrieve a single page
33 *
34 * AJAX Parameters:
35 * folder = the path of the folder to retrieve information on
36 *
37 * @author <a href="mailto:taylor@apache.org">David Sean Taylor</a>
38 * @version $Id: $
39 */
40 public class GetFolderAction
41 extends BaseGetResourceAction
42 implements AjaxAction, AjaxBuilder, Constants
43 {
44 protected Log log = LogFactory.getLog(GetFolderAction.class);
45
46 public GetFolderAction(String template,
47 String errorTemplate,
48 PageManager pageManager,
49 PortletActionSecurityBehavior securityBehavior)
50 {
51 super(template, errorTemplate, pageManager, securityBehavior);
52 }
53
54 public boolean run(RequestContext requestContext, Map resultMap)
55 {
56 boolean success = true;
57 String status = "success";
58 try
59 {
60 resultMap.put(ACTION, "getfolder");
61 if (false == checkAccess(requestContext, JetspeedActions.VIEW))
62 {
63 success = false;
64 resultMap.put(REASON, "Insufficient access to get portlets");
65 return success;
66 }
67 Folder folder = retrieveFolder(requestContext);
68 resultMap.put(STATUS, status);
69 resultMap.put(FOLDER, folder);
70 putSecurityInformation(resultMap, folder);
71 }
72 catch (Exception e)
73 {
74
75 log.error("exception while getting folder info", e);
76
77
78 success = false;
79 }
80
81 return success;
82 }
83
84 protected Folder retrieveFolder(RequestContext requestContext)
85 throws Exception
86 {
87 String folderName = getActionParameter(requestContext, FOLDER);
88 if (folderName == null)
89 {
90 folderName = "/";
91 }
92 Folder folder = pageManager.getFolder(folderName);
93 return folder;
94 }
95
96
97 }