001/* 002 * This library is part of OpenCms - 003 * the Open Source Content Management System 004 * 005 * Copyright (c) Alkacon Software GmbH & Co. KG (http://www.alkacon.com) 006 * 007 * This library is free software; you can redistribute it and/or 008 * modify it under the terms of the GNU Lesser General Public 009 * License as published by the Free Software Foundation; either 010 * version 2.1 of the License, or (at your option) any later version. 011 * 012 * This library is distributed in the hope that it will be useful, 013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 015 * Lesser General Public License for more details. 016 * 017 * For further information about Alkacon Software GmbH & Co. KG, please see the 018 * company website: http://www.alkacon.com 019 * 020 * For further information about OpenCms, please see the 021 * project website: http://www.opencms.org 022 * 023 * You should have received a copy of the GNU Lesser General Public 024 * License along with this library; if not, write to the Free Software 025 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 026 */ 027 028package org.opencms.staticexport; 029 030import org.opencms.util.CmsRequestUtil; 031 032import java.util.Collections; 033import java.util.Enumeration; 034import java.util.Map; 035 036import javax.servlet.http.HttpServletRequest; 037import javax.servlet.http.HttpServletRequestWrapper; 038 039/** 040 * Wrapper for static export requests, required for parameter based requests.<p> 041 * 042 * @since 6.0.0 043 */ 044public class CmsStaticExportRequest extends HttpServletRequestWrapper { 045 046 /** Map of parameters from the original request. */ 047 private Map<String, String[]> m_parameters; 048 049 /** 050 * Creates a new static export request wrapper.<p> 051 * 052 * @param req the request to wrap 053 * @param data the data for the static export 054 */ 055 public CmsStaticExportRequest(HttpServletRequest req, CmsStaticExportData data) { 056 057 super(req); 058 m_parameters = CmsRequestUtil.createParameterMap(data.getParameters()); 059 } 060 061 /** 062 * @see javax.servlet.http.HttpServletRequest#getDateHeader(java.lang.String) 063 */ 064 @Override 065 public long getDateHeader(String name) { 066 067 // make sue "last modified since" optimization is NOT used for export requests 068 if (CmsRequestUtil.HEADER_IF_MODIFIED_SINCE.equals(name)) { 069 // return -1, this means "no header has been set" in servlet standard 070 return -1; 071 } 072 return super.getDateHeader(name); 073 } 074 075 /** 076 * @see javax.servlet.ServletRequest#getParameter(java.lang.String) 077 */ 078 @Override 079 public String getParameter(String name) { 080 081 String[] values = m_parameters.get(name); 082 if (values != null) { 083 return (values[0]); 084 } 085 return null; 086 } 087 088 /** 089 * @see javax.servlet.ServletRequest#getParameterMap() 090 */ 091 @Override 092 public Map<String, String[]> getParameterMap() { 093 094 return m_parameters; 095 } 096 097 /** 098 * @see javax.servlet.ServletRequest#getParameterNames() 099 */ 100 @Override 101 public Enumeration<String> getParameterNames() { 102 103 return Collections.enumeration(m_parameters.keySet()); 104 } 105 106 /** 107 * @see javax.servlet.ServletRequest#getParameterValues(java.lang.String) 108 */ 109 @Override 110 public String[] getParameterValues(String name) { 111 112 return m_parameters.get(name); 113 } 114}