knguyen 2005/02/23 18:13:26 CET
Added files:
core/src/java/org/jahia/params SerializableParamBean.java
Log:
- partial adv search refactoring
Revision Changes Path
1.1 +199 -0
jahia/core/src/java/org/jahia/params/SerializableParamBean.java (new)
http://jahia.mine.nu:8080/cgi-bin/cvsweb.cgi/jahia/core/src/java/org/jahia/params/SerializableParamBean.java?rev=1.1&content-type=text/plain
Index: SerializableParamBean.java
====================================================================
//
// ____.
// __/\ ______| |__/\. _______
// __ .____| | \ | +----+ \
// _______| /--| | | - \ _ | : - \_________
// \\______: :---| : : | : | \________>
// |__\---\_____________:______: :____|____:_____\
// /_____|
//
// . . . i n j a h i a w e t r u s t . . .
//
//
// ParamBean
// EV 03.11.2000
// EV 23.12.2000 SettingsBean now in ParamBean
// SH 24.01.2001 added getSession accessor
// SH 24.01.2001 added some debugging code and some comments about
comportement under Orion
// DJ 30.01.2001 added an internal wrapper for
FileUpload/HttpServletRequest getParameter.
// SH 04.02.2001 added some comments on InputStream, Parameters,
WebApps problems + javadoc
// MJ 21.03.2001 replaced basic URL parameters with PathInfo elements
// NK 17.04.2001 added Multisite features
// NK 14.05.2001 Jump to requested site's home page when the
actual requested page is not of this site
// instead of page not found
Exception.
// NK 11.07.2001 Added last requested page parameter
// JB 25.10.2001 Added setOperationMode methode
// SH 01.02.2002 Added defaultParameterValues hashtable to reduce URL
length
// when using default values for engine names, operation
// modes, etc...
// FH 15.08.2003 - javadoc fixes
// - removed redundant class casting
// - removed unused private attribute
//
// Development notes : for the moment this class does not handle the
problematic
// of reading an input stream multiple times. This can cause problems if for
// example Jahia needs to read the InputStream object from the request before
// forwarding it to a web application. Also, under some server
implementations,
// such as the Orion server, retrieving an InputStream object before reading
the
// parameters will cause an error when trying to call a getParameter method.
// The main issue of all this is that we are very dependant on the
implementation
// of these methods right now. A solution that was studied involved writing
// parsers for the content of the request and managing the body internally
inside
// Jahia. This is probably the most solid way to do it, but it involves a lot
of
// development, especially since there should be a significant performance hit
// if not done fully.
// Basically the solution would be something like this :
// 1. Jahia retrieves the InputStream (or Reader) object
// 2. Jahia retrieves the full content and stores it either in memory or on
disk
// depending on some criteria to be defined (size, type of request ?)
// 3. Jahia parses the parameters included in the request body, making sure it
// then uses only the result of that parsing internally
// 4. Jahia's dispatching service can then emulate a full web container
behaviour
// without much problems, since it can intercept everything, include the
request
// body (which is the part of the emulation currently missing). So the
application
// could indeed retrieve an InputStream or a Reader that is passed the body
only
// of that application and that comes from memory or disk storage instead of
the
// socket.
//
// Advantages :
// - Allows for a FULL implementation of a request object
// - Allows Jahia and web applications to process the request multiple times
// - Improved security because we could only pass the body that concerns the
// web application.
//
// Disadvantages :
// - Serious performance hit because the worst case is : Jahia processes the
// request body, parses it, forwards it to the app, that reprocesses it again
!
// The current case is : Jahia forwards it directly to the webapp, not reading
// it most of the time.
// - Loss of security because in some cases an application can receive a GET
// request that actually has the body of a POST request (this is because the
// emulation replaces the URL but not the body currently, mostly for
performance
// reasons).
// - More usage of resources, since request bodies should have to be stored
// in memory and/or on disk, probably multiple times.
// The current decision was not to go forward with this implementation since
it
// will involve a lot of work and that the benefits are dependant on the
applications
// that must run under it. If the applications do not undergo problems in the
// meantime the current solution should be sufficient.
//
/**
* @todo Implement a system to store parameters either in the session or in
* the URL, transparently, in order to generate short URLs
*
* @todo Implement static (or search engine) friendly URLs, such as .html
ending
* URLs
*/
package org.jahia.params;
import java.io.File;
import java.util.ArrayList;
import java.util.Date;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.HashSet;
import java.util.ListIterator;
import java.util.Locale;
import java.util.Map;
import java.util.NoSuchElementException;
import java.util.Properties;
import java.util.Set;
import java.util.StringTokenizer;
import java.util.Vector;
import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import org.jahia.bin.Jahia;
import org.jahia.content.ContentPageKey;
import org.jahia.data.events.JahiaEvent;
import org.jahia.exceptions.JahiaException;
import org.jahia.exceptions.JahiaPageNotFoundException;
import org.jahia.exceptions.JahiaSessionExpirationException;
import org.jahia.exceptions.JahiaSiteNotFoundException;
import org.jahia.registries.ServicesRegistry;
import org.jahia.services.applications.DispatchingService;
import org.jahia.services.applications.ServletIncludeRequestWrapper;
import org.jahia.services.applications.ServletIncludeResponseWrapper;
import org.jahia.services.fields.ContentField;
import org.jahia.services.lock.LockKey;
import org.jahia.services.lock.LockService;
import org.jahia.services.pages.ContentPage;
import org.jahia.services.pages.JahiaPage;
import org.jahia.services.sites.JahiaSite;
import org.jahia.services.sites.SiteLanguageMapping;
import org.jahia.services.sites.SiteLanguageSettings;
import org.jahia.services.usermanager.JahiaUser;
import org.jahia.services.usermanager.JahiaUserManagerService;
import org.jahia.services.version.EntryLoadRequest;
import org.jahia.services.version.StateModificationContext;
import org.jahia.services.cache.HtmlCache;
import org.jahia.services.cache.CacheFactory;
import org.jahia.settings.SettingsBean;
import org.jahia.utils.LanguageCodeConverters;
import org.jahia.utils.properties.PropertiesManager;
import java.io.IOException;
import java.io.BufferedReader;
import org.jahia.exceptions.*;
import org.jahia.services.applications.ServletDispatchingProvider;
import org.jahia.services.pages.PageProperty;
import java.util.LinkedList;
import java.util.Iterator;
import javax.servlet.http.Cookie;
import org.jahia.utils.JahiaString;
import org.jahia.pipelines.Pipeline;
import org.jahia.pipelines.PipelineException;
import org.apache.struts.Globals;
import org.apache.log4j.Logger;
import javax.servlet.jsp.jstl.core.Config;
import org.jahia.engines.login.Login_Engine;
/**
* A ParamBean with null request and null response
*
*/
public class SerializableParamBean extends ParamBean {
private static org.apache.log4j.Logger logger =
org.apache.log4j.Logger.getLogger(SerializableParamBean.class);
/**
* jParams should not be null !
*
* @param jParams
* @throws JahiaPageNotFoundException
* @throws JahiaSessionExpirationException
* @throws JahiaSiteNotFoundException
* @throws JahiaException
*/
public SerializableParamBean(ParamBean jParams)
throws JahiaPageNotFoundException, JahiaSessionExpirationException,
JahiaSiteNotFoundException, JahiaException
{
super(null, null, Jahia.getStaticServletConfig().getServletContext(),
Jahia.getSettings(), System.currentTimeMillis(),
ParamBean.POST_METHOD, jParams.getSite(), jParams.getUser(),
jParams.getContentPage());
}
/**
* jParams should not be null !
*
* @param jParams
* @return
* @throws JahiaPageNotFoundException
* @throws JahiaSessionExpirationException
* @throws JahiaSiteNotFoundException
* @throws JahiaException
*/
public static SerializableParamBean getInstance(ParamBean jParams)
throws JahiaPageNotFoundException, JahiaSessionExpirationException,
JahiaSiteNotFoundException, JahiaException {
return new SerializableParamBean(jParams);
}
}