All Downloads are FREE. Search and download functionalities are using the official Maven repository.

javax.portlet.filter.PortletRequestWrapper Maven / Gradle / Ivy

There is a newer version: 3.0.1
Show newest version
/*  Licensed to the Apache Software Foundation (ASF) under one
 *  or more contributor license agreements.  See the NOTICE file
 *  distributed with this work for additional information
 *  regarding copyright ownership.  The ASF licenses this file
 *  to you under the Apache License, Version 2.0 (the
 *  "License"); you may not use this file except in compliance
 *  with the License.  You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing,
 *  software distributed under the License is distributed on an
 *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 *  KIND, either express or implied.  See the License for the
 *  specific language governing permissions and limitations
 *  under the License.
 */
/*
 * NOTE: this source code is based on an early draft version of JSR 286 and not intended for product
 * implementations. This file may change or vanish in the final version of the JSR 286 specification.
 */
/*
 * This source code implements specifications defined by the Java
 * Community Process. In order to remain compliant with the specification
 * DO NOT add / change / or delete method signatures!
 */
/*
 * Copyright 2006 IBM Corporation.
 *
 */
package javax.portlet.filter;

import java.security.Principal;
import java.util.Enumeration;
import java.util.Locale;
import java.util.Map;

import javax.portlet.PortalContext;
import javax.portlet.PortletMode;
import javax.portlet.PortletPreferences;
import javax.portlet.PortletRequest;
import javax.portlet.PortletSession;
import javax.portlet.WindowState;
import javax.servlet.http.Cookie;

/**
 * The PortletRequestWrapper provides a convenient 
 * implementation of the PortletRequest interface 
 * and is extended by other request wrappers.
 * This class implements the Wrapper or Decorator pattern. 
 * Methods default to calling through to the wrapped request object.
 *
 * @since 2.0
 * @see PortletRequest
 */
public class PortletRequestWrapper implements PortletRequest {

    PortletRequest request;
    
    /** 
     * Require having a request for constructing
     * the wrapper.
     *
     */
    private PortletRequestWrapper() {
    }
    
    
    /**
     * Creates an PortletRequest adaptor 
     * wrapping the given request object.
     * 
     * @param request  the portlet request to wrap
     * @throws java.lang.IllegalArgumentException if the request is null
     */
    public PortletRequestWrapper(PortletRequest request) {
    	if ( request == null)
    		throw new java.lang.IllegalArgumentException("Request is null");

        this.request = request;
    }

    /**
     * The default behavior of this method is to call 
     * getAttribute(String name) on the wrapped request object.
     */
    public Object getAttribute(String name) {
        return request.getAttribute(name);
    }

    /**
     * The default behavior of this method is to call 
     * getAttributeNames() on the wrapped request object.
     */
    public Enumeration getAttributeNames() {
        return request.getAttributeNames();
    }

    /**
     * The default behavior of this method is to call 
     * getAuthType() on the wrapped request object.
     */
    public String getAuthType() {
        return request.getAuthType();
    }

    /**
     * The default behavior of this method is to call 
     * getContextPath() on the wrapped request object.
     */
    public String getContextPath() {
        return request.getContextPath();
    }

    /**
     * The default behavior of this method is to call 
     * getLocale() on the wrapped request object.
     */
    public Locale getLocale() {
        return request.getLocale();
    }

    /**
     * The default behavior of this method is to call 
     * getLocales() on the wrapped request object.
     */
    public Enumeration getLocales() {
        return request.getLocales();
    }

    /**
     * The default behavior of this method is to call 
     * getParameter(String name) on the wrapped request object.
     */
    public String getParameter(String name) {
        return request.getParameter(name);
    }

    /**
     * The default behavior of this method is to call 
     * getParameterMap() on the wrapped request object.
     */
    public Map getParameterMap() {
        return request.getParameterMap();
    }

    /**
     * The default behavior of this method is to call 
     * getParameterNames() on the wrapped request object.
     */
    public Enumeration getParameterNames() {
        return request.getParameterNames();
    }

    /**
     * The default behavior of this method is to call 
     * getParameterValues(name) on the wrapped request object.
     */
    public String[] getParameterValues(String name) {
        return request.getParameterValues(name);
    }

    /**
     * The default behavior of this method is to call 
     * getPortalContext() on the wrapped request object.
     */
    public PortalContext getPortalContext() {
        return request.getPortalContext();
    }

    /**
     * The default behavior of this method is to call 
     * getPortletMode() on the wrapped request object.
     */
    public PortletMode getPortletMode() {
        return request.getPortletMode();
    }

    /**
     * The default behavior of this method is to call 
     * getPortletSession() on the wrapped request object.
     */
    public PortletSession getPortletSession() {
        return request.getPortletSession();
    }

    /**
     * The default behavior of this method is to call 
     * getPortletSession(create) on the wrapped request object.
     */
    public PortletSession getPortletSession(boolean create) {
        return request.getPortletSession(create);
    }

    /**
     * The default behavior of this method is to call 
     * getPreferences() on the wrapped request object.
     */
    public PortletPreferences getPreferences() {
        return request.getPreferences();
    }

    /**
     * The default behavior of this method is to call 
     * getProperteis(name) on the wrapped request object.
     */
    public Enumeration getProperties(String name) {
        return request.getProperties(name);
    }

    /**
     * The default behavior of this method is to call 
     * getProperty(name) on the wrapped request object.
     */
    public String getProperty(String name) {
        return request.getProperty(name);
    }

    /**
     * The default behavior of this method is to call 
     * getPropertyNames() on the wrapped request object.
     */
    public Enumeration getPropertyNames() {
        return request.getPropertyNames();
    }

    /**
     * The default behavior of this method is to call 
     * getRemoteUser() on the wrapped request object.
     */
    public String getRemoteUser() {
        return request.getRemoteUser();
    }

    /**
     * The default behavior of this method is to call 
     * getRequestedSessionId() on the wrapped request object.
     */
    public String getRequestedSessionId() {
        return request.getRequestedSessionId();
    }

    /**
     * The default behavior of this method is to call 
     * getResponseContentType() on the wrapped request object.
     */
    public String getResponseContentType() {
        return request.getResponseContentType();
    }

    /**
     * The default behavior of this method is to call 
     * getResponseContentTypes() on the wrapped request object.
     */
    public Enumeration getResponseContentTypes() {
        return request.getResponseContentTypes();
    }

    /**
     * The default behavior of this method is to call 
     * getScheme() on the wrapped request object.
     */
    public String getScheme() {
        return request.getScheme();
    }

    /**
     * The default behavior of this method is to call 
     * getServerName() on the wrapped request object.
     */
    public String getServerName() {
        return request.getServerName();
    }

    /**
     * The default behavior of this method is to call 
     * getServerPort() on the wrapped request object.
     */
    public int getServerPort() {
        return request.getServerPort();
    }

    /**
     * The default behavior of this method is to call 
     * getUserPrincipal() on the wrapped request object.
     */
    public Principal getUserPrincipal() {
        return request.getUserPrincipal();
    }

    /**
     * The default behavior of this method is to call 
     * getWindowId() on the wrapped request object.
     */
    public String getWindowID() {
        return request.getWindowID();
    }

    /**
     * The default behavior of this method is to call 
     * getWindowState() on the wrapped request object.
     */
    public WindowState getWindowState() {
        return request.getWindowState();
    }

    /**
     * The default behavior of this method is to call 
     * isPortletModeAllowed(mode) on the wrapped request object.
     */
    public boolean isPortletModeAllowed(PortletMode mode) {
        return request.isPortletModeAllowed(mode);
    }

    /**
     * The default behavior of this method is to call 
     * isRequestedSessionIdValid() on the wrapped request object.
     */
    public boolean isRequestedSessionIdValid() {
        return request.isRequestedSessionIdValid();
    }

    /**
     * The default behavior of this method is to call 
     * isSecure() on the wrapped request object.
     */
    public boolean isSecure() {
        return request.isSecure();
    }

    /**
     * The default behavior of this method is to call 
     * isUserInRole(role) on the wrapped request object.
     */
    public boolean isUserInRole(String role) {
        return request.isUserInRole(role);
    }

    /**
     * The default behavior of this method is to call 
     * isWindowStateAllowed(state) on the wrapped request object.
     */
    public boolean isWindowStateAllowed(WindowState state) {
        return request.isWindowStateAllowed(state);
    }

    /**
     * The default behavior of this method is to call 
     * removeAttribute(name) on the wrapped request object.
     */
    public void removeAttribute(String name) {
        request.removeAttribute(name);
    }

    /**
     * The default behavior of this method is to call 
     * setAttribute(name, o) on the wrapped request object.
     */
    public void setAttribute(String name, Object o) {
        request.setAttribute(name, o);
    }

    /**
     * Return the wrapped request object.
     * 
     * @return the wrapped request
     */
    public PortletRequest getRequest() {
        return request;
    }

    /**
     * Sets the request object being wrapped.
     * 
     * @param request the request to set
     * @throws java.lang.IllegalArgumentException   if the request is null.
     */
    public void setRequest(PortletRequest request) {
    	if ( request == null)
    		throw new java.lang.IllegalArgumentException("Request is null");

    	this.request = request;
    }

    /**
     *  The default behavior of this method is to call 
     * getCookies() on the wrapped request object.
     */
    public Cookie[] getCookies() {
    	return request.getCookies();
    }

    /**
     *  The default behavior of this method is to call 
     * getPrivateParameterMap() on the wrapped request object.
     */
	public Map getPrivateParameterMap() {
		return request.getPrivateParameterMap();
	}

    /**
     *  The default behavior of this method is to call 
     * getPublicParameterMap() on the wrapped request object.
     */
	public Map getPublicParameterMap() {
		return request.getPublicParameterMap();
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy