| InputPermissionsTagUtil.java |
1 /**
2 * Copyright (c) 2000-2009 Liferay, Inc. All rights reserved.
3 *
4 * The contents of this file are subject to the terms of the Liferay Enterprise
5 * Subscription License ("License"). You may not use this file except in
6 * compliance with the License. You can obtain a copy of the License by
7 * contacting Liferay, Inc. See the License for the specific language governing
8 * permissions and limitations under the License, including but not limited to
9 * distribution rights of the Software.
10 *
11 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
12 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
13 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
14 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
15 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
16 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
17 * SOFTWARE.
18 */
19
20 package com.liferay.portal.servlet.taglib.ui;
21
22 import com.liferay.portal.kernel.log.Log;
23 import com.liferay.portal.kernel.log.LogFactoryUtil;
24 import com.liferay.portal.kernel.servlet.PortalIncludeUtil;
25 import com.liferay.portal.security.permission.ResourceActionsUtil;
26
27 import java.util.List;
28
29 import javax.servlet.http.HttpServletRequest;
30 import javax.servlet.jsp.JspException;
31 import javax.servlet.jsp.PageContext;
32
33 /**
34 * <a href="InputPermissionsTagUtil.java.html"><b><i>View Source</i></b></a>
35 *
36 * @author Brian Chan
37 *
38 */
39 public class InputPermissionsTagUtil {
40
41 public static void doEndTag(
42 String page, String formName, String modelName,
43 PageContext pageContext)
44 throws JspException {
45
46 try {
47 HttpServletRequest request =
48 (HttpServletRequest)pageContext.getRequest();
49
50 request.setAttribute(
51 "liferay-ui:input-permissions:formName", formName);
52
53 if (modelName != null) {
54 List<String> supportedActions =
55 ResourceActionsUtil.getModelResourceActions(modelName);
56 List<String> communityDefaultActions =
57 ResourceActionsUtil.getModelResourceCommunityDefaultActions(
58 modelName);
59 List<String> guestDefaultActions =
60 ResourceActionsUtil.getModelResourceGuestDefaultActions(
61 modelName);
62 List<String> guestUnsupportedActions =
63 ResourceActionsUtil.getModelResourceGuestUnsupportedActions(
64 modelName);
65
66 request.setAttribute(
67 "liferay-ui:input-permissions:modelName", modelName);
68 request.setAttribute(
69 "liferay-ui:input-permissions:supportedActions",
70 supportedActions);
71 request.setAttribute(
72 "liferay-ui:input-permissions:communityDefaultActions",
73 communityDefaultActions);
74 request.setAttribute(
75 "liferay-ui:input-permissions:guestDefaultActions",
76 guestDefaultActions);
77 request.setAttribute(
78 "liferay-ui:input-permissions:guestUnsupportedActions",
79 guestUnsupportedActions);
80 }
81
82 PortalIncludeUtil.include(pageContext, page);
83 }
84 catch (Exception e) {
85 _log.error(e, e);
86
87 throw new JspException(e);
88 }
89 }
90
91 private static Log _log =
92 LogFactoryUtil.getLog(InputPermissionsTagUtil.class);
93
94 }