01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
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 extends BaseGetResourceAction implements
41: AjaxAction, AjaxBuilder, Constants {
42: protected Log log = LogFactory.getLog(GetFolderAction.class);
43:
44: public GetFolderAction(String template, String errorTemplate,
45: PageManager pageManager,
46: PortletActionSecurityBehavior securityBehavior) {
47: super (template, errorTemplate, pageManager, securityBehavior);
48: }
49:
50: public boolean run(RequestContext requestContext, Map resultMap) {
51: boolean success = true;
52: String status = "success";
53: try {
54: resultMap.put(ACTION, "getfolder");
55: if (false == checkAccess(requestContext,
56: JetspeedActions.VIEW)) {
57: success = false;
58: resultMap.put(REASON,
59: "Insufficient access to get portlets");
60: return success;
61: }
62: Folder folder = retrieveFolder(requestContext);
63: resultMap.put(STATUS, status);
64: resultMap.put(FOLDER, folder);
65: putSecurityInformation(resultMap, folder);
66: } catch (Exception e) {
67: // Log the exception
68: log.error("exception while getting folder info", e);
69:
70: // Return a failure indicator
71: success = false;
72: }
73:
74: return success;
75: }
76:
77: protected Folder retrieveFolder(RequestContext requestContext)
78: throws Exception {
79: String folderName = getActionParameter(requestContext, FOLDER);
80: if (folderName == null) {
81: folderName = "/";
82: }
83: Folder folder = pageManager.getFolder(folderName);
84: return folder;
85: }
86:
87: }
|