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.atom;
016    
017    import com.liferay.portal.kernel.atom.AtomRequestContext;
018    import com.liferay.portal.kernel.util.GetterUtil;
019    
020    import org.apache.abdera.protocol.server.RequestContext;
021    
022    /**
023     * @author Igor Spasic
024     */
025    public class AtomRequestContextImpl implements AtomRequestContext {
026    
027            public AtomRequestContextImpl(RequestContext requestContext) {
028                    _requestContext = requestContext;
029            }
030    
031            @Override
032            public Object getContainerAttribute(String name) {
033                    return _requestContext.getAttribute(
034                            RequestContext.Scope.CONTAINER, name);
035            }
036    
037            @Override
038            public String getHeader(String name) {
039                    return _requestContext.getHeader(name);
040            }
041    
042            @Override
043            public int getIntParameter(String name) {
044                    String value = _requestContext.getParameter(name);
045    
046                    return GetterUtil.getInteger(value);
047            }
048    
049            @Override
050            public int getIntParameter(String name, int defaultValue) {
051                    String value = _requestContext.getParameter(name);
052    
053                    return GetterUtil.getInteger(value, defaultValue);
054            }
055    
056            @Override
057            public long getLongParameter(String name) {
058                    String value = _requestContext.getParameter(name);
059    
060                    return GetterUtil.getLong(value);
061            }
062    
063            @Override
064            public long getLongParameter(String name, long defaultValue) {
065                    String value = _requestContext.getParameter(name);
066    
067                    return GetterUtil.getLong(value, defaultValue);
068            }
069    
070            @Override
071            public String getParameter(String name) {
072                    return _requestContext.getParameter(name);
073            }
074    
075            @Override
076            public String getParameter(String name, String defaultValue) {
077                    String value = _requestContext.getParameter(name);
078    
079                    return GetterUtil.getString(value, defaultValue);
080            }
081    
082            @Override
083            public Object getRequestAttribute(String name) {
084                    return _requestContext.getAttribute(RequestContext.Scope.REQUEST, name);
085            }
086    
087            @Override
088            public String getResolvedUri() {
089                    return _requestContext.getResolvedUri().toString();
090            }
091    
092            @Override
093            public Object getSessionAttribute(String name) {
094                    return _requestContext.getAttribute(RequestContext.Scope.SESSION, name);
095            }
096    
097            @Override
098            public String getTargetBasePath() {
099                    return _requestContext.getTargetBasePath();
100            }
101    
102            @Override
103            public void setContainerAttribute(String name, Object value) {
104                    _requestContext.setAttribute(
105                            RequestContext.Scope.CONTAINER, name, value);
106            }
107    
108            @Override
109            public void setRequestAttribute(String name, Object value) {
110                    _requestContext.setAttribute(RequestContext.Scope.REQUEST, name, value);
111            }
112    
113            @Override
114            public void setSessionAttribute(String name, Object value) {
115                    _requestContext.setAttribute(RequestContext.Scope.SESSION, name, value);
116            }
117    
118            private RequestContext _requestContext;
119    
120    }