You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@turbine.apache.org by he...@apache.org on 2003/07/31 18:29:52 UTC
cvs commit: jakarta-turbine-2/src/java/org/apache/turbine/util/uri DataURI.java
henning 2003/07/31 09:29:52
Modified: src/java/org/apache/turbine/services/pull/tools
ContentTool.java
src/java/org/apache/turbine/util/uri DataURI.java
Log:
- Make it possible to turn URI encoding off for the Content ($content) tool
by setting a property in TR.props
- Make it possible to switch between relative and absolute links with a
property in TR.props.
- DataURI must expose a clearResponse() method (like TurbineURI) to make it
possible to turn the encoding off.
Revision Changes Path
1.2 +46 -3 jakarta-turbine-2/src/java/org/apache/turbine/services/pull/tools/ContentTool.java
Index: ContentTool.java
===================================================================
RCS file: /home/cvs/jakarta-turbine-2/src/java/org/apache/turbine/services/pull/tools/ContentTool.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ContentTool.java 7 May 2003 13:58:21 -0000 1.1
+++ ContentTool.java 31 Jul 2003 16:29:52 -0000 1.2
@@ -54,8 +54,10 @@
* <http://www.apache.org/>.
*/
-import org.apache.turbine.services.pull.ApplicationTool;
+import org.apache.commons.configuration.Configuration;
+import org.apache.turbine.Turbine;
+import org.apache.turbine.services.pull.ApplicationTool;
import org.apache.turbine.util.RunData;
import org.apache.turbine.util.uri.DataURI;
@@ -79,6 +81,32 @@
public class ContentTool
implements ApplicationTool
{
+ /** Prefix for Parameters for this tool */
+ public static final String CONTENT_TOOL_PREFIX = "tool.content";
+
+ /**
+ * Should this tool add Container Encoding to the URIs returned?
+ * True might cause trouble e.g. if you run with Apache HTTP Daemon / Tomcat Combo.
+ *
+ * Default is false (like Turbine 2.2)
+ */
+ public static final String CONTENT_TOOL_ENCODING_KEY = "want.encoding";
+
+ /** Default Value for CONTENT_TOOL_ENCODING_KEY */
+ public static final boolean CONTENT_TOOL_ENCODING_DEFAULT = false;
+
+ /** Should this tool return relative URIs or absolute? Default: Absolute. */
+ public static final String CONTENT_TOOL_RELATIVE_KEY = "want.relative";
+
+ /** Default Value for CONTENT_TOOL_RELATIVE_KEY */
+ public static final boolean CONTENT_TOOL_RELATIVE_DEFAULT = false;
+
+ /** Do we want the container to encode the response? */
+ boolean wantEncoding = false;
+
+ /** Do we want a relative link? */
+ boolean wantRelative = false;
+
/** Caches a DataURI object which provides the translation routines */
private DataURI dataURI = null;
@@ -111,6 +139,20 @@
// or null is passed in we'll throw an appropriate runtime
// exception.
dataURI = new DataURI((RunData) data);
+
+ Configuration conf =
+ Turbine.getConfiguration().subset(CONTENT_TOOL_PREFIX);
+
+ wantRelative = conf.getBoolean(CONTENT_TOOL_RELATIVE_KEY,
+ CONTENT_TOOL_RELATIVE_DEFAULT);
+
+ wantEncoding = conf.getBoolean(CONTENT_TOOL_ENCODING_KEY,
+ CONTENT_TOOL_ENCODING_DEFAULT);
+
+ if (!wantEncoding)
+ {
+ dataURI.clearResponse();
+ }
}
/**
@@ -132,6 +174,7 @@
{
dataURI.setScriptName(path);
- return dataURI.getAbsoluteLink();
+ return wantRelative ?
+ dataURI.getRelativeLink() : dataURI.getAbsoluteLink();
}
}
1.4 +11 -1 jakarta-turbine-2/src/java/org/apache/turbine/util/uri/DataURI.java
Index: DataURI.java
===================================================================
RCS file: /home/cvs/jakarta-turbine-2/src/java/org/apache/turbine/util/uri/DataURI.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- DataURI.java 3 Jun 2003 13:41:29 -0000 1.3
+++ DataURI.java 31 Jul 2003 16:29:52 -0000 1.4
@@ -127,6 +127,16 @@
/**
+ * Content Tool wants to be able to turn the encoding
+ * of the servlet container off. After calling this method,
+ * the encoding will not happen any longer.
+ */
+ public void clearResponse()
+ {
+ setResponse(null);
+ }
+
+ /**
* Builds the URL with all of the data URL-encoded as well as
* encoded using HttpServletResponse.encodeUrl(). The resulting
* URL is absolute; it starts with http/https...
---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-dev-help@jakarta.apache.org