001    /**
002     * Copyright (c) 2000-2012 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 {@link com.liferay.taglib.ui.InputPermissionsTag}
031     */
032    public class InputPermissionsTagUtil {
033    
034            public static void doEndTag(
035                            String page, String formName, String modelName,
036                            PageContext pageContext)
037                    throws JspException {
038    
039                    try {
040                            HttpServletRequest request =
041                                    (HttpServletRequest)pageContext.getRequest();
042    
043                            request.setAttribute(
044                                    "liferay-ui:input-permissions:formName", formName);
045    
046                            if (modelName != null) {
047                                    List<String> supportedActions =
048                                            ResourceActionsUtil.getModelResourceActions(modelName);
049                                    List<String> groupDefaultActions =
050                                            ResourceActionsUtil.getModelResourceGroupDefaultActions(
051                                                    modelName);
052                                    List<String> guestDefaultActions =
053                                            ResourceActionsUtil.getModelResourceGuestDefaultActions(
054                                                    modelName);
055                                    List<String> guestUnsupportedActions =
056                                            ResourceActionsUtil.getModelResourceGuestUnsupportedActions(
057                                                    modelName);
058    
059                                    request.setAttribute(
060                                            "liferay-ui:input-permissions:modelName", modelName);
061                                    request.setAttribute(
062                                            "liferay-ui:input-permissions:supportedActions",
063                                            supportedActions);
064                                    request.setAttribute(
065                                            "liferay-ui:input-permissions:groupDefaultActions",
066                                            groupDefaultActions);
067                                    request.setAttribute(
068                                            "liferay-ui:input-permissions:guestDefaultActions",
069                                            guestDefaultActions);
070                                    request.setAttribute(
071                                            "liferay-ui:input-permissions:guestUnsupportedActions",
072                                            guestUnsupportedActions);
073                            }
074    
075                            PortalIncludeUtil.include(pageContext, page);
076                    }
077                    catch (Exception e) {
078                            _log.error(e, e);
079    
080                            throw new JspException(e);
081                    }
082            }
083    
084            private static Log _log = LogFactoryUtil.getLog(
085                    InputPermissionsTagUtil.class);
086    
087    }