1/*2 * Licensed to the Apache Software Foundation (ASF) under one or more3 * contributor license agreements. See the NOTICE file distributed with4 * this work for additional information regarding copyright ownership.5 * The ASF licenses this file to You under the Apache License, Version 2.06 * (the "License"); you may not use this file except in compliance with7 * the License. You may obtain a copy of the License at8 * 9 * http://www.apache.org/licenses/LICENSE-2.010 * 11 * Unless required by applicable law or agreed to in writing, software12 * 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 and15 * limitations under the License.16 */17packageorg.apache.jetspeed.layout.impl;
1819import java.util.Map;
2021import org.apache.commons.logging.Log;
22import org.apache.commons.logging.LogFactory;
23import org.apache.jetspeed.JetspeedActions;
24import org.apache.jetspeed.ajax.AjaxAction;
25import org.apache.jetspeed.ajax.AjaxBuilder;
26import org.apache.jetspeed.layout.PortletActionSecurityBehavior;
27import org.apache.jetspeed.om.folder.Folder;
28import org.apache.jetspeed.page.PageManager;
29import org.apache.jetspeed.request.RequestContext;
3031/***32 * Retrieve a single page33 *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 */40publicclassGetFolderAction41extendsBaseGetResourceAction42 implements AjaxAction, AjaxBuilder, Constants43 {
44protected Log log = LogFactory.getLog(GetFolderAction.class);
4546publicGetFolderAction(String template,
47 String errorTemplate,
48 PageManager pageManager,
49 PortletActionSecurityBehavior securityBehavior)
50 {
51super(template, errorTemplate, pageManager, securityBehavior);
52 }
5354publicboolean run(RequestContext requestContext, Map resultMap)
55 {
56boolean success = true;
57 String status = "success";
58try59 {
60 resultMap.put(ACTION, "getfolder");
61if (false == checkAccess(requestContext, JetspeedActions.VIEW))
62 {
63 success = false;
64 resultMap.put(REASON, "Insufficient access to get portlets");
65return success;
66 }
67 Folder folder = retrieveFolder(requestContext);
68 resultMap.put(STATUS, status);
69 resultMap.put(FOLDER, folder);
70 putSecurityInformation(resultMap, folder);
71 }
72catch (Exception e)
73 {
74// Log the exception75 log.error("exception while getting folder info", e);
7677// Return a failure indicator78 success = false;
79 }
8081return success;
82 }
8384protected Folder retrieveFolder(RequestContext requestContext)
85 throws Exception
86 {
87 String folderName = getActionParameter(requestContext, FOLDER);
88if (folderName == null)
89 {
90 folderName = "/";
91 }
92 Folder folder = pageManager.getFolder(folderName);
93return folder;
94 }
959697 }