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.portlet.documentlibrary.display.context.util;
016    
017    import com.liferay.portal.kernel.display.context.util.BaseRequestHelper;
018    import com.liferay.portal.kernel.exception.PortalException;
019    import com.liferay.portal.kernel.exception.SystemException;
020    import com.liferay.portal.util.PortletKeys;
021    import com.liferay.portlet.documentlibrary.DLGroupServiceSettings;
022    import com.liferay.portlet.documentlibrary.DLPortletInstanceSettings;
023    
024    import javax.servlet.http.HttpServletRequest;
025    
026    /**
027     * @author Iv??n Zaera
028     */
029    public class DLRequestHelper extends BaseRequestHelper {
030    
031            public DLRequestHelper(HttpServletRequest request) {
032                    super(request);
033            }
034    
035            public DLGroupServiceSettings getDLGroupServiceSettings() {
036                    try {
037                            if (_dlGroupServiceSettings == null) {
038                                    String portletId = getPortletId();
039    
040                                    if (portletId.equals(PortletKeys.PORTLET_CONFIGURATION)) {
041                                            HttpServletRequest request = getRequest();
042    
043                                            _dlGroupServiceSettings =
044                                                    DLGroupServiceSettings.getInstance(
045                                                            getScopeGroupId(), request.getParameterMap());
046                                    }
047                                    else {
048                                            _dlGroupServiceSettings =
049                                                    DLGroupServiceSettings.getInstance(getScopeGroupId());
050                                    }
051                            }
052    
053                            return _dlGroupServiceSettings;
054                    }
055                    catch (PortalException pe) {
056                            throw new SystemException(pe);
057                    }
058            }
059    
060            public DLPortletInstanceSettings getDLPortletInstanceSettings() {
061                    try {
062                            if (_dlPortletInstanceSettings == null) {
063                                    String portletId = getPortletId();
064    
065                                    if (portletId.equals(PortletKeys.PORTLET_CONFIGURATION)) {
066                                            HttpServletRequest request = getRequest();
067    
068                                            _dlPortletInstanceSettings =
069                                                    DLPortletInstanceSettings.getInstance(
070                                                            getLayout(), getResourcePortletId(),
071                                                            request.getParameterMap());
072                                    }
073                                    else {
074                                            _dlPortletInstanceSettings =
075                                                    DLPortletInstanceSettings.getInstance(
076                                                            getLayout(), getPortletId());
077                                    }
078                            }
079    
080                            return _dlPortletInstanceSettings;
081                    }
082                    catch (PortalException pe) {
083                            throw new SystemException(pe);
084                    }
085            }
086    
087            private DLGroupServiceSettings _dlGroupServiceSettings;
088            private DLPortletInstanceSettings _dlPortletInstanceSettings;
089    
090    }