You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@turbine.apache.org by jv...@apache.org on 2002/02/08 18:07:37 UTC
cvs commit: jakarta-turbine-3/src/java/org/apache/turbine/security/fulcrum DefaultTurbineRunData.java
jvanzyl 02/02/08 09:07:37
Modified: src/java/org/apache/turbine/security/fulcrum Tag:
rundata_security_changes DefaultTurbineRunData.java
Log:
- this is now a subclass of the base rundata class, trying to get
both the base class and the variant to work at the same time as
this will be very likely given that a given application may use
subapplications that use variants of rundata.
Revision Changes Path
No revision
No revision
1.1.2.2 +2 -661 jakarta-turbine-3/src/java/org/apache/turbine/security/fulcrum/Attic/DefaultTurbineRunData.java
Index: DefaultTurbineRunData.java
===================================================================
RCS file: /home/cvs/jakarta-turbine-3/src/java/org/apache/turbine/security/fulcrum/Attic/DefaultTurbineRunData.java,v
retrieving revision 1.1.2.1
retrieving revision 1.1.2.2
diff -u -r1.1.2.1 -r1.1.2.2
--- DefaultTurbineRunData.java 8 Feb 2002 02:52:03 -0000 1.1.2.1
+++ DefaultTurbineRunData.java 8 Feb 2002 17:07:37 -0000 1.1.2.2
@@ -54,28 +54,14 @@
* <http://www.apache.org/>.
*/
-import java.util.Locale;
import java.util.Vector;
import java.util.Hashtable;
-import java.io.PrintWriter;
-import java.io.IOException;
-import javax.servlet.ServletConfig;
-import javax.servlet.ServletContext;
import javax.servlet.http.HttpSession;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
import org.apache.turbine.RunData;
import org.apache.turbine.Turbine;
-import org.apache.turbine.ParameterParser;
import org.apache.fulcrum.security.util.AccessControlList;
-import org.apache.fulcrum.pool.Recyclable;
-import org.apache.fulcrum.pool.RecyclableSupport;
-import org.apache.fulcrum.localization.Localization;
-import org.apache.fulcrum.mimetype.TurbineMimeTypes;
import org.apache.fulcrum.security.entity.User;
-import org.apache.fulcrum.template.TurbineTemplate;
import org.apache.fulcrum.util.parser.CookieParser;
-import org.apache.commons.collections.FastHashMap;
import org.apache.log4j.Category;
/**
@@ -97,85 +83,22 @@
* @author <a href="mailto:jon@latchkey.com">Jon S. Stevens</a>
* @author <a href="mailto:bhoeneis@ee.ethz.ch">Bernie Hoeneisen</a>
* @author <a href="mailto:dlr@finemaltcoding.com">Daniel Rall</a>
- * @version $Id: DefaultTurbineRunData.java,v 1.1.2.1 2002/02/08 02:52:03 jvanzyl Exp $
+ * @version $Id: DefaultTurbineRunData.java,v 1.1.2.2 2002/02/08 17:07:37 jvanzyl Exp $
*/
public class DefaultTurbineRunData
- extends RecyclableSupport
- implements Recyclable
+ extends org.apache.turbine.services.rundata.DefaultTurbineRunData
{
/**
- * The default locale.
- */
- private static Locale defaultLocale;
-
- /**
- * The default locale checked flag.
- */
- private static boolean defaultLocaleChecked;
-
- /**
- * The default charset.
- */
- private static String defaultCharSet;
-
- /**
- * The default charset checked flag.
- */
- private static boolean defaultCharSetChecked;
-
- /**
- * A reference to the GET/POST data parser.
- */
- private ParameterParser parameters;
-
- /**
* A reference to a cookie parser.
*/
public CookieParser cookies;
/**
- * The servlet request interface.
- */
- private HttpServletRequest req;
-
- /**
- * The servlet response interface.
- */
- private HttpServletResponse res;
-
- /**
- * The servlet session information.
- */
- private HttpSession session;
-
- /**
- * The servlet configuration.
- */
- private ServletConfig config;
-
- /**
- * The servlet context information.
- * Note that this is from the
- * "Turbine" Servlet context.
- */
- private ServletContext servletContext;
-
- /**
* The access control list.
*/
private AccessControlList acl;
/**
- * Cached action name to execute for this request.
- */
- private String action;
-
- /**
- * The character encoding of template files.
- */
- private String templateEncoding;
-
- /**
* The user object.
*/
private User user;
@@ -186,42 +109,6 @@
private String title;
/**
- * Cache the output stream because it can be used in many
- * different places.
- */
- private PrintWriter out;
-
- /**
- * The locale.
- */
- private Locale locale;
-
- /**
- * The HTTP charset.
- */
- private String charSet;
-
- /**
- * The HTTP content type to return.
- */
- private String contentType = "text/html";
-
- /**
- * If this is set, also set the status code to 302.
- */
- private String redirectURI;
-
- /**
- * The HTTP status code to return.
- */
- private int statusCode = HttpServletResponse.SC_OK;
-
- /**
- * This is a vector to hold critical system errors.
- */
- private Vector errors = new Vector();
-
- /**
* @see #getRemoteAddr()
*/
private String remoteAddr;
@@ -236,27 +123,6 @@
*/
private String userAgent;
- /**
- * A holder for stack trace.
- */
- private String stackTrace;
-
- /**
- * A holder ofr stack trace exception.
- */
- private Throwable stackTraceException;
-
- /**
- * Put things here and they will be shown on the default Error
- * screen. This is great for debugging variable values when an
- * exception is thrown.
- */
- private Hashtable varDebug = new Hashtable();
-
- private String target;
- private String message;
- private FastHashMap temp;
-
// These were part of server data
/** Cached serverName, */
@@ -274,50 +140,12 @@
/** Cached context path. */
private String contextPath = null;
- public void setTarget(String target)
- {
- this.target = target;
- }
-
- public String getTarget()
- {
- return target;
- }
-
- public boolean hasTarget()
- {
- return (target != null);
- }
-
- public void setTemp(String key, Object value)
- {
- temp.put(key, value);
- }
-
- public Object getTemp(String key)
- {
- return temp.get(key);
- }
-
/**
* Constructs a run data object.
*/
public DefaultTurbineRunData()
{
super();
-
- // This only needs to be made once. We will
- // clear out the mappings when the RunData object
- // is recycled.
- temp = new FastHashMap();
- }
-
- /**
- * Recycles a run data object.
- */
- public void recycle()
- {
- super.recycle();
}
/**
@@ -325,44 +153,15 @@
*/
public void dispose()
{
- target = null;
- parameters = null;
cookies = null;
- req = null;
- res = null;
- session = null;
- config = null;
- servletContext = null;
acl = null;
- action = null;
- templateEncoding = null;
user = null;
title = null;
- out = null;
- locale = null;
- charSet = null;
- contentType = "text/html";
- redirectURI = null;
- statusCode = HttpServletResponse.SC_OK;
- errors.clear();
remoteAddr = null;
remoteHost = null;
userAgent = null;
- stackTrace = null;
- stackTraceException = null;
- varDebug.clear();
message = null;
- // Clear all the values from the temporary
- // storage.
- temp.clear();
-
- //serverName = null;
- //serverPort = 80;
- //serverScheme = null;
- //scriptName = null;
- //contextPath = null;
-
super.dispose();
}
@@ -371,24 +170,6 @@
// ***************************************
/**
- * Gets the parameters. if this is the first time calling
- * this method since the rundata was borrowed from the pool
- * the request will be parsed.
- *
- * @return a parameter parser.
- */
- public ParameterParser getParameters()
- {
- // Parse the parameters first, if not yet done.
- if ((this.parameters != null) &&
- (this.parameters.getRequest() == null))
- {
- this.parameters.setRequest(this.req);
- }
- return this.parameters;
- }
-
- /**
* Gets the cookies.
*
* @return a cookie parser.
@@ -399,56 +180,6 @@
}
/**
- * Gets the servlet request.
- *
- * @return the request.
- */
- public HttpServletRequest getRequest()
- {
- return this.req;
- }
-
- /**
- * Gets the servlet response.
- *
- * @return the resposne.
- */
- public HttpServletResponse getResponse()
- {
- return this.res;
- }
-
- /**
- * Gets the servlet session information.
- *
- * @return the session.
- */
- public HttpSession getSession()
- {
- return session;
- }
-
- /**
- * Gets the servlet configuration used during servlet init.
- *
- * @return the configuration.
- */
- public ServletConfig getServletConfig()
- {
- return this.config;
- }
-
- /**
- * Gets the servlet context used during servlet init.
- *
- * @return the context.
- */
- public ServletContext getServletContext()
- {
- return this.servletContext;
- }
-
- /**
* Gets the access control list.
*
* @return the access control list.
@@ -469,60 +200,6 @@
}
/**
- * Whether or not an action has been defined.
- *
- * @return true if an action has been defined.
- */
- public boolean hasAction()
- {
- return (this.action != null &&
- this.action.length() > 0 &&
- !this.action.equalsIgnoreCase("null"));
- }
-
- /**
- * Gets the action. It returns an empty string if null so
- * that it is easy to do conditionals on it based on the
- * equalsIgnoreCase() method.
- *
- * @return a string, "" if null.
- */
- public String getAction()
- {
- return (hasAction() ? this.action : "");
- }
-
- /**
- * Sets the action for the request.
- *
- * @param action a atring.
- */
- public void setAction (String action)
- {
- this.action = action;
- }
-
- /**
- * Gets the character encoding to use for reading template files.
- *
- * @return the template encoding or null if not specified.
- */
- public String getTemplateEncoding()
- {
- return templateEncoding;
- }
-
- /**
- * Sets the character encoding to use for reading template files.
- *
- * @param encoding the template encoding.
- */
- public void setTemplateEncoding(String encoding)
- {
- templateEncoding = encoding;
- }
-
- /**
* Gets the title of the page.
*
* @return a string.
@@ -727,231 +404,6 @@
}
/**
- * Gets the print writer. *
- * @return a print writer.
- * @throws IOException.
- */
- public PrintWriter getOut()
- throws IOException
- {
- return res.getWriter();
- }
-
- /**
- * Gets the default locale defined by properties named
- * "locale.default.lang" and "locale.default.country".
- * If neither property is defined, it will use the Local.getDefault()
- * method to return the appropriate Locale for the installed JVM.
- *
- * @return the default locale.
- */
- protected static Locale getDefaultLocale()
- {
- if (!defaultLocaleChecked)
- {
- /* Get the default locale and cache it in a static variable. */
- String lang = Turbine.getConfiguration()
- .getString("locale.default.language");
- String country = Turbine.getConfiguration()
- .getString("locale.default.country");
- if (lang != null)
- {
- defaultLocale = country != null ?
- new Locale(lang,country) : new Locale(lang,"");
- }
- else if (country != null)
- {
- defaultLocale = new Locale("",country);
- }
- else
- {
- defaultLocale = Locale.getDefault();
- }
- defaultLocaleChecked = true;
- }
- return defaultLocale;
- }
-
- /**
- * Gets the default charset defined by a property named
- * "locale.default.charset" or by the default Locale.
- *
- * @return the name of the default charset.
- */
- protected String getDefaultCharSet()
- {
- if (!defaultCharSetChecked)
- {
- /* Get the default charset and cache
- it in a static variable. */
- defaultCharSet = Turbine.getConfiguration().
- getString("locale.default.charset");
-
- if (defaultCharSet == null)
- {
- /* Default charset isn't specified,
- get the locale specific one. */
- Locale locale = getDefaultLocale();
- defaultCharSet = TurbineMimeTypes.getCharSet(locale);
- }
- defaultCharSetChecked = true;
- }
- return defaultCharSet;
- }
-
- /**
- * Gets the locale. If it has not already been defined with
- * setLocale(), then the Localization service is used to determine
- * the right Locale based on the HttpServletRequest. If that is
- * not possible, then the getDefaultLocale() method is used.
- *
- * @return the Locale.
- */
- public Locale getLocale()
- {
- if (locale == null)
- {
- locale = Localization.getLocale(getRequest());
- if (locale == null)
- {
- locale = getDefaultLocale();
- }
- }
- return locale;
- }
-
- /**
- * Sets the Locale.
- *
- * @param locale the new Locale.
- */
- public void setLocale(Locale locale)
- {
- this.locale = locale;
- }
-
- /**
- * Gets the charset. If it has not already been defined with
- * setCharSet(). It will then try to get the getDefaultCharSet().
- * If that isn't defined, then the Localization/Mimetype service is
- * used to determine the right charset based on the
- * HttpServletRequest. Please note that this ordering is still up
- * in the air and may change in the near future as more testing is done.
- * The issue is that sometimes, even though the Locale
- * is dynamic, the charset should always be 8859_1. So, the current
- * ordering allows us to just define things as always being 8859_1 which
- * may or may not be correct.
- *
- * @return the charset.
- */
- public String getCharSet()
- {
- if (charSet == null)
- {
- charSet = getDefaultCharSet();
- if (charSet == null)
- {
- charSet = TurbineMimeTypes.getCharSet(getLocale());
- }
- }
- return charSet;
- }
-
- /**
- * Sets the charset.
- *
- * @param charset the name of the new charset.
- */
- public void setCharSet(String charset)
- {
- this.charSet = charset;
- }
-
- /**
- * Gets the HTTP content type to return. If a charset
- * has been specified, it is included in the content type.
- * If the charset has not been specified and the main type
- * of the content type is "text", the default charset is
- * included. If the default charset is undefined, but the
- * default locale is defined and it is not the US locale,
- * a locale specific charset is included.
- *
- * @return the content type or an empty string.
- */
- public String getContentType()
- {
- String ct = this.contentType;
- if (ct != null)
- {
- if (ct.startsWith("text/"))
- {
- String charset = getCharSet();
- if (charset != null)
- {
- ct += "; charset=" + charset;
- }
- }
- }
- else
- {
- ct = "";
- }
- return ct;
- }
-
- /**
- * Sets the HTTP content type to return.
- *
- * @param ct a string.
- */
- public void setContentType(String ct)
- {
- this.contentType = ct;
- }
-
- /**
- * Gets the redirect URI. If this is set, also make sure to set
- * the status code to 302.
- *
- * @return a string, "" if null.
- */
- public String getRedirectURI()
- {
- return (this.redirectURI == null ? "" : redirectURI);
- }
-
- /**
- * Sets the redirect uri. If this is set, also make sure to set
- * the status code to 302.
- *
- * @param ruri a string.
- */
- public void setRedirectURI(String ruri)
- {
- this.redirectURI = ruri;
- }
-
- /**
- * Gets the HTTP status code to return.
- *
- * @return the status.
- */
- public int getStatusCode()
- {
- return statusCode;
- }
-
- /**
- * Sets the HTTP status code to return.
- *
- * @param sc the status.
- */
- public void setStatusCode(int sc)
- {
- this.statusCode = sc;
- }
-
- /**
* Gets the cached server scheme.
*
* @return a string.
@@ -1084,74 +536,11 @@
session.putValue(AccessControlList.SESSION_KEY, (Object) acl);
}
- /**
- * Gets the stack trace if set.
- *
- * @return the stack trace.
- */
- public String getStackTrace()
- {
- return stackTrace;
- }
-
- /**
- * Gets the stack trace exception if set.
- *
- * @return the stack exception.
- */
- public Throwable getStackTraceException()
- {
- return stackTraceException;
- }
-
- /**
- * Sets the stack trace.
- *
- * @param trace the stack trace.
- * @param exp the exception.
- */
- public void setStackTrace(String trace,
- Throwable exp)
- {
- stackTrace = trace;
- stackTraceException = exp;
- }
-
- /**
- * Gets a table of debug variables.
- *
- * @return a hashtable for debug variables.
- */
- public Hashtable getVarDebug()
- {
- return varDebug;
- }
-
// **********************************************
// Implementation of the TurbineRunData interface
// **********************************************
/**
- * Gets the parameter parser without parsing the parameters.
- *
- * @return the parameter parser.
- */
- public ParameterParser getParameterParser()
- {
- return parameters;
- }
-
- /**
- * Sets the parameter parser.
- *
- * @param parser a parameter parser.
- */
- public void setParameterParser(ParameterParser parser)
- {
- parameters = parser;
- }
-
- /**
* Gets the cookie parser without parsing the cookies.
*
* @return the cookie parser.
@@ -1169,54 +558,6 @@
public void setCookieParser(CookieParser parser)
{
cookies = parser;
- }
-
- /**
- * Sets the servlet request.
- *
- * @param req a request.
- */
- public void setRequest(HttpServletRequest req)
- {
- this.req = req;
- }
-
- /**
- * Sets the servlet response.
- *
- * @param res a response.
- */
- public void setResponse(HttpServletResponse res)
- {
- this.res = res;
- }
-
- /**
- * Sets the servlet session inforamtion.
- *
- * @param sess a session.
- */
- public void setSession(HttpSession sess)
- {
- this.session = sess;
- }
-
- /**
- * Setsthe servlet configuration used during servlet init.
- *
- * @param config a configuration.
- */
- public void setServletConfig(ServletConfig config)
- {
- this.config = config;
- if (config == null)
- {
- this.servletContext = null;
- }
- else
- {
- this.servletContext = config.getServletContext();
- }
}
// ********************
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>