001    /**
002     * Copyright (c) 2000-2013 Liferay, Inc. All rights reserved.
003     *
004     * The contents of this file are subject to the terms of the Liferay Enterprise
005     * Subscription License ("License"). You may not use this file except in
006     * compliance with the License. You can obtain a copy of the License by
007     * contacting Liferay, Inc. See the License for the specific language governing
008     * permissions and limitations under the License, including but not limited to
009     * distribution rights of the Software.
010     *
011     *
012     *
013     */
014    
015    package com.liferay.portal.servlet.taglib.ui;
016    
017    import com.liferay.portal.kernel.log.Log;
018    import com.liferay.portal.kernel.log.LogFactoryUtil;
019    import com.liferay.portal.kernel.servlet.PortalIncludeUtil;
020    import com.liferay.portal.security.permission.ResourceActionsUtil;
021    
022    import java.util.List;
023    
024    import javax.servlet.http.HttpServletRequest;
025    import javax.servlet.jsp.JspException;
026    import javax.servlet.jsp.PageContext;
027    
028    /**
029     * @author     Brian Chan
030     * @deprecated As of 6.2.0, replaced by {@link
031     *             com.liferay.taglib.ui.InputPermissionsTag}
032     */
033    public class InputPermissionsTagUtil {
034    
035            public static void doEndTag(
036                            String page, String formName, String modelName,
037                            PageContext pageContext)
038                    throws JspException {
039    
040                    try {
041                            HttpServletRequest request =
042                                    (HttpServletRequest)pageContext.getRequest();
043    
044                            request.setAttribute(
045                                    "liferay-ui:input-permissions:formName", formName);
046    
047                            if (modelName != null) {
048                                    List<String> supportedActions =
049                                            ResourceActionsUtil.getModelResourceActions(modelName);
050                                    List<String> groupDefaultActions =
051                                            ResourceActionsUtil.getModelResourceGroupDefaultActions(
052                                                    modelName);
053                                    List<String> guestDefaultActions =
054                                            ResourceActionsUtil.getModelResourceGuestDefaultActions(
055                                                    modelName);
056                                    List<String> guestUnsupportedActions =
057                                            ResourceActionsUtil.getModelResourceGuestUnsupportedActions(
058                                                    modelName);
059    
060                                    request.setAttribute(
061                                            "liferay-ui:input-permissions:modelName", modelName);
062                                    request.setAttribute(
063                                            "liferay-ui:input-permissions:supportedActions",
064                                            supportedActions);
065                                    request.setAttribute(
066                                            "liferay-ui:input-permissions:groupDefaultActions",
067                                            groupDefaultActions);
068                                    request.setAttribute(
069                                            "liferay-ui:input-permissions:guestDefaultActions",
070                                            guestDefaultActions);
071                                    request.setAttribute(
072                                            "liferay-ui:input-permissions:guestUnsupportedActions",
073                                            guestUnsupportedActions);
074                            }
075    
076                            PortalIncludeUtil.include(pageContext, page);
077                    }
078                    catch (Exception e) {
079                            _log.error(e, e);
080    
081                            throw new JspException(e);
082                    }
083            }
084    
085            private static Log _log = LogFactoryUtil.getLog(
086                    InputPermissionsTagUtil.class);
087    
088    }