%line | %branch | |||||||||
---|---|---|---|---|---|---|---|---|---|---|
org.apache.jetspeed.layout.impl.GetFolderAction |
|
|
1 | /* |
|
2 | * Licensed to the Apache Software Foundation (ASF) under one or more |
|
3 | * contributor license agreements. See the NOTICE file distributed with |
|
4 | * this work for additional information regarding copyright ownership. |
|
5 | * The ASF licenses this file to You under the Apache License, Version 2.0 |
|
6 | * (the "License"); you may not use this file except in compliance with |
|
7 | * the License. You may obtain a copy of the License at |
|
8 | * |
|
9 | * 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 |
|
41 | extends BaseGetResourceAction |
|
42 | implements AjaxAction, AjaxBuilder, Constants |
|
43 | { |
|
44 | 0 | protected Log log = LogFactory.getLog(GetFolderAction.class); |
45 | ||
46 | public GetFolderAction(String template, |
|
47 | String errorTemplate, |
|
48 | PageManager pageManager, |
|
49 | PortletActionSecurityBehavior securityBehavior) |
|
50 | { |
|
51 | 0 | super(template, errorTemplate, pageManager, securityBehavior); |
52 | 0 | } |
53 | ||
54 | public boolean run(RequestContext requestContext, Map resultMap) |
|
55 | { |
|
56 | 0 | boolean success = true; |
57 | 0 | String status = "success"; |
58 | try |
|
59 | { |
|
60 | 0 | resultMap.put(ACTION, "getfolder"); |
61 | 0 | if (false == checkAccess(requestContext, JetspeedActions.VIEW)) |
62 | { |
|
63 | 0 | success = false; |
64 | 0 | resultMap.put(REASON, "Insufficient access to get portlets"); |
65 | 0 | return success; |
66 | } |
|
67 | 0 | Folder folder = retrieveFolder(requestContext); |
68 | 0 | resultMap.put(STATUS, status); |
69 | 0 | resultMap.put(FOLDER, folder); |
70 | 0 | putSecurityInformation(resultMap, folder); |
71 | } |
|
72 | 0 | catch (Exception e) |
73 | { |
|
74 | // Log the exception |
|
75 | 0 | log.error("exception while getting folder info", e); |
76 | ||
77 | // Return a failure indicator |
|
78 | 0 | success = false; |
79 | 0 | } |
80 | ||
81 | 0 | return success; |
82 | } |
|
83 | ||
84 | protected Folder retrieveFolder(RequestContext requestContext) |
|
85 | throws Exception |
|
86 | { |
|
87 | 0 | String folderName = getActionParameter(requestContext, FOLDER); |
88 | 0 | if (folderName == null) |
89 | { |
|
90 | 0 | folderName = "/"; |
91 | } |
|
92 | 0 | Folder folder = pageManager.getFolder(folderName); |
93 | 0 | return folder; |
94 | } |
|
95 | ||
96 | ||
97 | } |
This report is generated by jcoverage, Maven and Maven JCoverage Plugin. |