1   /**
2    * Copyright (c) 2000-2010 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   *
12   *
13   */
14  
15  package com.liferay.portal.servlet.taglib.ui;
16  
17  import com.liferay.portal.kernel.log.Log;
18  import com.liferay.portal.kernel.log.LogFactoryUtil;
19  import com.liferay.portal.kernel.servlet.PortalIncludeUtil;
20  import com.liferay.portal.security.permission.ResourceActionsUtil;
21  
22  import java.util.List;
23  
24  import javax.servlet.http.HttpServletRequest;
25  import javax.servlet.jsp.JspException;
26  import javax.servlet.jsp.PageContext;
27  
28  /**
29   * <a href="InputPermissionsTagUtil.java.html"><b><i>View Source</i></b></a>
30   *
31   * @author Brian Chan
32   */
33  public class InputPermissionsTagUtil {
34  
35      public static void doEndTag(
36              String page, String formName, String modelName,
37              PageContext pageContext)
38          throws JspException {
39  
40          try {
41              HttpServletRequest request =
42                  (HttpServletRequest)pageContext.getRequest();
43  
44              request.setAttribute(
45                  "liferay-ui:input-permissions:formName", formName);
46  
47              if (modelName != null) {
48                  List<String> supportedActions =
49                      ResourceActionsUtil.getModelResourceActions(modelName);
50                  List<String> communityDefaultActions =
51                      ResourceActionsUtil.getModelResourceCommunityDefaultActions(
52                          modelName);
53                  List<String> guestDefaultActions =
54                      ResourceActionsUtil.getModelResourceGuestDefaultActions(
55                          modelName);
56                  List<String> guestUnsupportedActions =
57                      ResourceActionsUtil.getModelResourceGuestUnsupportedActions(
58                          modelName);
59  
60                  request.setAttribute(
61                      "liferay-ui:input-permissions:modelName", modelName);
62                  request.setAttribute(
63                      "liferay-ui:input-permissions:supportedActions",
64                      supportedActions);
65                  request.setAttribute(
66                      "liferay-ui:input-permissions:communityDefaultActions",
67                      communityDefaultActions);
68                  request.setAttribute(
69                      "liferay-ui:input-permissions:guestDefaultActions",
70                      guestDefaultActions);
71                  request.setAttribute(
72                      "liferay-ui:input-permissions:guestUnsupportedActions",
73                      guestUnsupportedActions);
74              }
75  
76              PortalIncludeUtil.include(pageContext, page);
77          }
78          catch (Exception e) {
79              _log.error(e, e);
80  
81              throw new JspException(e);
82          }
83      }
84  
85      private static Log _log = LogFactoryUtil.getLog(
86          InputPermissionsTagUtil.class);
87  
88  }