001    /**
002     * Copyright (c) 2000-present Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
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.security.permission.ResourceActionsUtil;
020    import com.liferay.taglib.util.PortalIncludeUtil;
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    @Deprecated
034    public class InputPermissionsTagUtil {
035    
036            public static void doEndTag(
037                            String page, String formName, String modelName,
038                            PageContext pageContext)
039                    throws JspException {
040    
041                    try {
042                            HttpServletRequest request =
043                                    (HttpServletRequest)pageContext.getRequest();
044    
045                            request.setAttribute(
046                                    "liferay-ui:input-permissions:formName", formName);
047    
048                            if (modelName != null) {
049                                    List<String> supportedActions =
050                                            ResourceActionsUtil.getModelResourceActions(modelName);
051                                    List<String> groupDefaultActions =
052                                            ResourceActionsUtil.getModelResourceGroupDefaultActions(
053                                                    modelName);
054                                    List<String> guestDefaultActions =
055                                            ResourceActionsUtil.getModelResourceGuestDefaultActions(
056                                                    modelName);
057                                    List<String> guestUnsupportedActions =
058                                            ResourceActionsUtil.getModelResourceGuestUnsupportedActions(
059                                                    modelName);
060    
061                                    request.setAttribute(
062                                            "liferay-ui:input-permissions:modelName", modelName);
063                                    request.setAttribute(
064                                            "liferay-ui:input-permissions:supportedActions",
065                                            supportedActions);
066                                    request.setAttribute(
067                                            "liferay-ui:input-permissions:groupDefaultActions",
068                                            groupDefaultActions);
069                                    request.setAttribute(
070                                            "liferay-ui:input-permissions:guestDefaultActions",
071                                            guestDefaultActions);
072                                    request.setAttribute(
073                                            "liferay-ui:input-permissions:guestUnsupportedActions",
074                                            guestUnsupportedActions);
075                            }
076    
077                            PortalIncludeUtil.include(pageContext, page);
078                    }
079                    catch (Exception e) {
080                            _log.error(e, e);
081    
082                            throw new JspException(e);
083                    }
084            }
085    
086            private static final Log _log = LogFactoryUtil.getLog(
087                    InputPermissionsTagUtil.class);
088    
089    }