001    /**
002     * Copyright (c) 2000-2013 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.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    }