You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@clerezza.apache.org by re...@apache.org on 2010/01/11 16:02:19 UTC

svn commit: r897890 - in /incubator/clerezza: issues/CLEREZZA-39/ trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.xhtml2html/ trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.xhtml2html/src/main/java/org/apache/clerezza/platf...

Author: reto
Date: Mon Jan 11 15:02:18 2010
New Revision: 897890

URL: http://svn.apache.org/viewvc?rev=897890&view=rev
Log:
CLEREZZA-39: closing

Added:
    incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.xhtml2html/src/main/java/org/apache/clerezza/platform/xhtml2html/DocTypeSettingBody.java
      - copied unchanged from r897874, incubator/clerezza/issues/CLEREZZA-39/org.apache.clerezza.platform.xhtml2html/src/main/java/org/apache/clerezza/platform/xhtml2html/DocTypeSettingBody.java
    incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.xhtml2html/src/main/java/org/apache/clerezza/platform/xhtml2html/DocTypeSettingByteChannel.java
      - copied unchanged from r897874, incubator/clerezza/issues/CLEREZZA-39/org.apache.clerezza.platform.xhtml2html/src/main/java/org/apache/clerezza/platform/xhtml2html/DocTypeSettingByteChannel.java
    incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.xhtml2html/src/main/java/org/apache/clerezza/platform/xhtml2html/ResponseStatusInfo.java
      - copied unchanged from r897874, incubator/clerezza/issues/CLEREZZA-39/org.apache.clerezza.platform.xhtml2html/src/main/java/org/apache/clerezza/platform/xhtml2html/ResponseStatusInfo.java
    incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.xhtml2html/src/test/
      - copied from r897874, incubator/clerezza/issues/CLEREZZA-39/org.apache.clerezza.platform.xhtml2html/src/test/
    incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.xhtml2html/src/test/java/
      - copied from r897874, incubator/clerezza/issues/CLEREZZA-39/org.apache.clerezza.platform.xhtml2html/src/test/java/
    incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.xhtml2html/src/test/java/org/
      - copied from r897874, incubator/clerezza/issues/CLEREZZA-39/org.apache.clerezza.platform.xhtml2html/src/test/java/org/
    incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.xhtml2html/src/test/java/org/apache/
      - copied from r897874, incubator/clerezza/issues/CLEREZZA-39/org.apache.clerezza.platform.xhtml2html/src/test/java/org/apache/
    incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.xhtml2html/src/test/java/org/apache/clerezza/
      - copied from r897874, incubator/clerezza/issues/CLEREZZA-39/org.apache.clerezza.platform.xhtml2html/src/test/java/org/apache/clerezza/
    incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.xhtml2html/src/test/java/org/apache/clerezza/platform/
      - copied from r897874, incubator/clerezza/issues/CLEREZZA-39/org.apache.clerezza.platform.xhtml2html/src/test/java/org/apache/clerezza/platform/
    incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.xhtml2html/src/test/java/org/apache/clerezza/platform/xhtml2html/
      - copied from r897874, incubator/clerezza/issues/CLEREZZA-39/org.apache.clerezza.platform.xhtml2html/src/test/java/org/apache/clerezza/platform/xhtml2html/
    incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.xhtml2html/src/test/java/org/apache/clerezza/platform/xhtml2html/DocTypeSettingByteChannelTest.java
      - copied unchanged from r897874, incubator/clerezza/issues/CLEREZZA-39/org.apache.clerezza.platform.xhtml2html/src/test/java/org/apache/clerezza/platform/xhtml2html/DocTypeSettingByteChannelTest.java
Removed:
    incubator/clerezza/issues/CLEREZZA-39/
Modified:
    incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.xhtml2html/   (props changed)
    incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.xhtml2html/pom.xml
    incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.xhtml2html/src/main/java/org/apache/clerezza/platform/xhtml2html/WrappedResponse.java

Propchange: incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.xhtml2html/
------------------------------------------------------------------------------
--- svn:mergeinfo (added)
+++ svn:mergeinfo Mon Jan 11 15:02:18 2010
@@ -0,0 +1 @@
+/incubator/clerezza/issues/CLEREZZA-39/org.apache.clerezza.platform.xhtml2html:895979-897874

Modified: incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.xhtml2html/pom.xml
URL: http://svn.apache.org/viewvc/incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.xhtml2html/pom.xml?rev=897890&r1=897889&r2=897890&view=diff
==============================================================================
--- incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.xhtml2html/pom.xml (original)
+++ incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.xhtml2html/pom.xml Mon Jan 11 15:02:18 2010
@@ -1,4 +1,5 @@
-<?xml version="1.0" encoding="UTF-8" standalone="no"?><project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
 	<modelVersion>4.0.0</modelVersion>
 	<parent>
 		<artifactId>org.apache.clerezza.parent</artifactId>
@@ -11,7 +12,8 @@
 	<version>0.5-incubating-SNAPSHOT</version>
 	<name>Clerezza - Filter for browsers that do not support XHTML</name>
 	<description>Provides a wrhapi filter that changes the content-type of the
-	response from application/xhtml+xml to text/html</description>
+	response from application/xhtml+xml to text/html
+	</description>
 	<dependencies>
 		<dependency>
 			<groupId>org.wymiwyg</groupId>
@@ -25,5 +27,10 @@
 			<groupId>org.osgi</groupId>
 			<artifactId>org.osgi.compendium</artifactId>
 		</dependency>
+		<dependency>
+			<groupId>junit</groupId>
+			<artifactId>junit</artifactId>
+			<scope>test</scope>
+		</dependency>
 	</dependencies>
 </project>
\ No newline at end of file

Modified: incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.xhtml2html/src/main/java/org/apache/clerezza/platform/xhtml2html/WrappedResponse.java
URL: http://svn.apache.org/viewvc/incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.xhtml2html/src/main/java/org/apache/clerezza/platform/xhtml2html/WrappedResponse.java?rev=897890&r1=897889&r2=897890&view=diff
==============================================================================
--- incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.xhtml2html/src/main/java/org/apache/clerezza/platform/xhtml2html/WrappedResponse.java (original)
+++ incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.xhtml2html/src/main/java/org/apache/clerezza/platform/xhtml2html/WrappedResponse.java Mon Jan 11 15:02:18 2010
@@ -1,4 +1,4 @@
-/*
+ /*
  * 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
@@ -20,6 +20,7 @@
 
 import org.wymiwyg.wrhapi.HandlerException;
 import org.wymiwyg.wrhapi.HeaderName;
+import org.wymiwyg.wrhapi.MessageBody;
 import org.wymiwyg.wrhapi.Response;
 import org.wymiwyg.wrhapi.util.ResponseWrapper;
 
@@ -27,18 +28,26 @@
  *
  * @author rbn
  */
-class WrappedResponse extends ResponseWrapper {
+class WrappedResponse extends ResponseWrapper implements ResponseStatusInfo {
 	private String XHTML_TYPE = "application/xhtml+xml";
 	private String HTML_TYPE = "text/html";
+	private boolean isHtml = false;
 
 	public WrappedResponse(Response response) {
 		super(response);
 	}
 
+
+
 	@Override
 	public void addHeader(HeaderName headerName, Object value) throws HandlerException {
+		if (headerName.equals(HeaderName.CONTENT_LENGTH) && isHtml) {
+			return;
+		}
 		if (headerName.equals(HeaderName.CONTENT_TYPE) && XHTML_TYPE.equals(value)) {
 			super.addHeader(headerName, HTML_TYPE);
+			isHtml = true;
+			super.setHeader(HeaderName.CONTENT_LENGTH, null);
 		} else {
 			super.addHeader(headerName, value);
 		}
@@ -46,10 +55,25 @@
 
 	@Override
 	public void setHeader(HeaderName headerName, Object value) throws HandlerException {
+		if (headerName.equals(HeaderName.CONTENT_LENGTH) && isHtml) {
+			return;
+		}
 		if (headerName.equals(HeaderName.CONTENT_TYPE) && XHTML_TYPE.equals(value)) {
 			super.setHeader(headerName, HTML_TYPE);
+			isHtml = true;
+			super.setHeader(HeaderName.CONTENT_LENGTH, null);
 		} else {
 			super.setHeader(headerName, value);
 		}
 	}
+
+	@Override
+	public void setBody(MessageBody body) throws HandlerException {
+		super.setBody(new DocTypeSettingBody(body, this));
+	}
+
+	@Override
+	public boolean isHtml() {
+		return isHtml;
+	}
 }