You can subscribe to this list here.
| 2010 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(3) |
Nov
(4) |
Dec
(2) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2011 |
Jan
(2) |
Feb
(19) |
Mar
(20) |
Apr
(20) |
May
|
Jun
(3) |
Jul
|
Aug
(23) |
Sep
(2) |
Oct
(5) |
Nov
(58) |
Dec
(49) |
| 2012 |
Jan
(11) |
Feb
(20) |
Mar
(9) |
Apr
(19) |
May
(14) |
Jun
(42) |
Jul
(13) |
Aug
|
Sep
(6) |
Oct
(6) |
Nov
(22) |
Dec
(66) |
| 2013 |
Jan
(12) |
Feb
(28) |
Mar
(54) |
Apr
(21) |
May
(7) |
Jun
(69) |
Jul
(80) |
Aug
(7) |
Sep
(12) |
Oct
(145) |
Nov
(44) |
Dec
(25) |
| 2014 |
Jan
(33) |
Feb
(21) |
Mar
(19) |
Apr
(2) |
May
|
Jun
(3) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
|
From: <sbe...@us...> - 2011-02-23 08:35:21
|
Revision: 579
http://webassembletool.svn.sourceforge.net/webassembletool/?rev=579&view=rev
Author: sbernatsky
Date: 2011-02-23 08:35:15 +0000 (Wed, 23 Feb 2011)
Log Message:
-----------
https://sourceforge.net/apps/mantisbt/webassembletool/view.php?id=16 : update configuration description
Modified Paths:
--------------
trunk/src/site/xdoc/configuration.xml
Modified: trunk/src/site/xdoc/configuration.xml
===================================================================
--- trunk/src/site/xdoc/configuration.xml 2011-02-22 16:47:18 UTC (rev 578)
+++ trunk/src/site/xdoc/configuration.xml 2011-02-23 08:35:15 UTC (rev 579)
@@ -62,6 +62,15 @@
<td>No</td>
<td>text/html,application/xhtml+xml</td>
</tr>
+ <tr>
+ <td>blackListedHeaders</td>
+ <td>List of comma separated headers which will be removed from server's response before returning to the client. By default, ignored headers are Content-Length, Content-Encoding and Transfer-Encoding.
+ Use this syntax to set ignored headers :
+ <code>blackListedHeaders=Content-Length,Content-Encoding,Transfer-Encoding</code>
+ </td>
+ <td>No</td>
+ <td>Content-Length,Content-Encoding,Transfer-Encoding</td>
+ </tr>
<tr>
<td>timeout</td>
<td>Timeout while establishing a connection with the server
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <sbe...@us...> - 2011-02-22 16:47:27
|
Revision: 578
http://webassembletool.svn.sourceforge.net/webassembletool/?rev=578&view=rev
Author: sbernatsky
Date: 2011-02-22 16:47:18 +0000 (Tue, 22 Feb 2011)
Log Message:
-----------
https://sourceforge.net/apps/mantisbt/webassembletool/view.php?id=16 : copy all http headers except blacklisted
Modified Paths:
--------------
trunk/webassembletool-core/src/main/java/net/webassembletool/Driver.java
trunk/webassembletool-core/src/main/java/net/webassembletool/DriverConfiguration.java
trunk/webassembletool-core/src/main/java/net/webassembletool/cache/CachedResponse.java
trunk/webassembletool-core/src/main/java/net/webassembletool/cache/CachedResponseSummary.java
trunk/webassembletool-core/src/main/java/net/webassembletool/file/FileOutput.java
trunk/webassembletool-core/src/main/java/net/webassembletool/file/FileResource.java
trunk/webassembletool-core/src/main/java/net/webassembletool/http/HttpClientResponse.java
trunk/webassembletool-core/src/main/java/net/webassembletool/http/HttpResource.java
trunk/webassembletool-core/src/main/java/net/webassembletool/http/ResponseOutput.java
trunk/webassembletool-core/src/main/java/net/webassembletool/output/Output.java
trunk/webassembletool-core/src/main/java/net/webassembletool/output/TextOnlyStringOutput.java
trunk/webassembletool-core/src/main/java/net/webassembletool/resource/NullResource.java
trunk/webassembletool-core/src/main/java/net/webassembletool/resource/Resource.java
trunk/webassembletool-core/src/main/java/net/webassembletool/resource/ResourceUtils.java
trunk/webassembletool-core/src/main/java/net/webassembletool/util/Rfc2616.java
trunk/webassembletool-core/src/test/java/net/webassembletool/DriverConfigurationTest.java
trunk/webassembletool-core/src/test/java/net/webassembletool/http/HttpResourceTest.java
trunk/webassembletool-core/src/test/java/net/webassembletool/util/Rfc2616Test.java
Added Paths:
-----------
trunk/webassembletool-core/src/main/java/net/webassembletool/file/FileUtils.java
trunk/webassembletool-core/src/main/java/net/webassembletool/file/HeadersFile.java
trunk/webassembletool-core/src/test/java/net/webassembletool/http/HttpClientResponseTest.java
Modified: trunk/webassembletool-core/src/main/java/net/webassembletool/Driver.java
===================================================================
--- trunk/webassembletool-core/src/main/java/net/webassembletool/Driver.java 2011-02-22 09:04:36 UTC (rev 577)
+++ trunk/webassembletool-core/src/main/java/net/webassembletool/Driver.java 2011-02-22 16:47:18 UTC (rev 578)
@@ -53,8 +53,6 @@
import net.webassembletool.xml.XpathRenderer;
import net.webassembletool.xml.XsltRenderer;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import org.apache.http.HttpHost;
import org.apache.http.client.HttpClient;
import org.apache.http.client.params.ClientPNames;
@@ -70,6 +68,8 @@
import org.apache.http.params.BasicHttpParams;
import org.apache.http.params.CoreConnectionPNames;
import org.apache.http.params.HttpParams;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* Main class used to retrieve data from a provider application using HTTP
@@ -554,7 +554,7 @@
// Resource in cache, does not need validation, just render
// it
LOG.debug("Reusing cache entry for: " + httpUrl);
- Rfc2616.renderResource(cachedResource, multipleOutput);
+ Rfc2616.renderResource(config, cachedResource, multipleOutput);
return;
}
}
@@ -563,8 +563,7 @@
// Prepare a FileOutput to store the result on the file system
if (config.isPutInCache()
&& Rfc2616.isCacheable(resourceContext)) {
- fileOutput = new FileOutput(ResourceUtils.getFileUrl(
- config.getLocalBase(), resourceContext));
+ fileOutput = ResourceUtils.createFileOutput(config.getLocalBase(), resourceContext);
multipleOutput.addOutput(fileOutput);
}
if (cache != null) {
@@ -580,22 +579,21 @@
}
// If there is an error, we will try to reuse an old cache entry
if (!httpResource.isError()) {
- Rfc2616.renderResource(httpResource, multipleOutput);
+ Rfc2616.renderResource(config, httpResource, multipleOutput);
return;
}
}
// Resource could not be loaded from HTTP, let's use the expired
// cache entry if not empty and not error.
if (cachedResource != null && !cachedResource.isError()) {
- Rfc2616.renderResource(cachedResource, multipleOutput);
+ Rfc2616.renderResource(config, cachedResource, multipleOutput);
return;
}
// Resource could not be loaded neither from HTTP, nor from the
// cache, let's try from the file system
if (config.getLocalBase() != null
&& Rfc2616.isCacheable(resourceContext)) {
- fileResource = new FileResource(config.getLocalBase(),
- resourceContext);
+ fileResource = ResourceUtils.createFileResource(config.getLocalBase(), resourceContext);
if (!fileResource.isError()) {
// on réinitialise l'output pour ne pas écraser le fichier
// stocké sur le disque
@@ -603,24 +601,24 @@
multipleOutput.addOutput(output);
memoryOutput = new CacheOutput(config.getCacheMaxFileSize());
multipleOutput.addOutput(memoryOutput);
- Rfc2616.renderResource(fileResource, multipleOutput);
+ Rfc2616.renderResource(config, fileResource, multipleOutput);
return;
}
}
// No valid response could be found, let's render the response even
// if it is an error
if (httpResource != null) {
- Rfc2616.renderResource(httpResource, multipleOutput);
+ Rfc2616.renderResource(config, httpResource, multipleOutput);
return;
} else if (cachedResource != null) {
- Rfc2616.renderResource(cachedResource, multipleOutput);
+ Rfc2616.renderResource(config, cachedResource, multipleOutput);
return;
} else if (fileResource != null) {
- Rfc2616.renderResource(fileResource, multipleOutput);
+ Rfc2616.renderResource(config, fileResource, multipleOutput);
return;
} else {
// Resource could not be loaded at all
- Rfc2616.renderResource(new NullResource(), multipleOutput);
+ Rfc2616.renderResource(config, new NullResource(), multipleOutput);
}
} catch (Throwable t) {
// In case there was a problem during rendering (client abort for
Modified: trunk/webassembletool-core/src/main/java/net/webassembletool/DriverConfiguration.java
===================================================================
--- trunk/webassembletool-core/src/main/java/net/webassembletool/DriverConfiguration.java 2011-02-22 09:04:36 UTC (rev 577)
+++ trunk/webassembletool-core/src/main/java/net/webassembletool/DriverConfiguration.java 2011-02-22 16:47:18 UTC (rev 578)
@@ -15,8 +15,10 @@
package net.webassembletool;
import java.util.ArrayList;
+import java.util.HashSet;
import java.util.List;
import java.util.Properties;
+import java.util.Set;
import java.util.StringTokenizer;
import net.webassembletool.authentication.RemoteUserAuthenticationHandler;
@@ -46,15 +48,16 @@
private String proxyHost;
private int proxyPort = 0;
private boolean filterJsessionid = true;
- private String authenticationHandler = RemoteUserAuthenticationHandler.class
- .getName();
+ private String authenticationHandler = RemoteUserAuthenticationHandler.class.getName();
private final Properties properties;
private boolean preserveHost = false;
private String cookieStore = SerializableBasicCookieStore.class.getName();
private String filter = null;
private final List<String> parsableContentTypes;
+ private final Set<String> blackListedHeaders;
- private static String DEFAULT_PARSABLE_CONTENT_TYPES = "text/html, application/xhtml+xml";
+ private static final String DEFAULT_PARSABLE_CONTENT_TYPES = "text/html, application/xhtml+xml";
+ private static final String DEFAULT_BLACK_LISTED_HEADERS = "Content-Length,Content-Encoding,Transfer-Encoding";
public DriverConfiguration(String instanceName, Properties props) {
this.instanceName = instanceName;
@@ -136,8 +139,7 @@
}
}
// Parsable content types
- String strContentTypes = props.getProperty("parsableContentTypes",
- DEFAULT_PARSABLE_CONTENT_TYPES);
+ String strContentTypes = props.getProperty("parsableContentTypes", DEFAULT_PARSABLE_CONTENT_TYPES);
StringTokenizer tokenizer = new StringTokenizer(strContentTypes, ",");
String contentType;
parsableContentTypes = new ArrayList<String>();
@@ -147,9 +149,24 @@
parsableContentTypes.add(contentType);
}
+ // populate headers black list
+ blackListedHeaders = new HashSet<String>();
+ String headers = props.getProperty("blackListedHeaders", DEFAULT_BLACK_LISTED_HEADERS);
+ String[] split = headers.split(",");
+ for (String header : split) {
+ blackListedHeaders.add(header.toLowerCase());
+ }
+
properties = props;
}
+ public boolean isBlackListed(String headerName) {
+ if (headerName == null || headerName.length() == 0) {
+ return true;
+ }
+ return blackListedHeaders.contains(headerName.toLowerCase());
+ }
+
public String getFilter() {
return filter;
}
Modified: trunk/webassembletool-core/src/main/java/net/webassembletool/cache/CachedResponse.java
===================================================================
--- trunk/webassembletool-core/src/main/java/net/webassembletool/cache/CachedResponse.java 2011-02-22 09:04:36 UTC (rev 577)
+++ trunk/webassembletool-core/src/main/java/net/webassembletool/cache/CachedResponse.java 2011-02-22 16:47:18 UTC (rev 578)
@@ -1,13 +1,12 @@
package net.webassembletool.cache;
import java.io.IOException;
+import java.util.Collection;
import java.util.Date;
import java.util.Enumeration;
import java.util.HashMap;
-import java.util.Iterator;
import java.util.Map;
import java.util.Map.Entry;
-import java.util.Properties;
import javax.servlet.http.HttpServletRequest;
@@ -24,14 +23,14 @@
*/
public class CachedResponse extends Resource {
private final byte[] byteArray;
- private final Properties headers;
+ private final Map<String, Object> headers;
private final String charset;
private final int statusCode;
private final String statusMessage;
private final Date localDate = new Date();
private Map<String, String> requestHeaders;
- public CachedResponse(byte[] byteArray, String charset, Properties headers,
+ public CachedResponse(byte[] byteArray, String charset, Map<String, Object> headers,
int statusCode, String statusMessage) {
this.byteArray = byteArray;
this.headers = headers;
@@ -69,8 +68,8 @@
output.setStatus(statusCode, statusMessage);
try {
output.setCharsetName(charset);
- for (Entry<Object, Object> entry : headers.entrySet()) {
- String key = entry.getKey().toString();
+ for (Entry<String, Object> entry : headers.entrySet()) {
+ String key = entry.getKey();
String value = entry.getValue().toString();
output.addHeader(key, value);
}
@@ -91,11 +90,14 @@
}
@Override
+ public Collection<String> getHeaderNames() {
+ return headers.keySet();
+ }
+
+ @Override
public final String getHeader(String key) {
- for (Iterator<Map.Entry<Object, Object>> headersIterator = headers
- .entrySet().iterator(); headersIterator.hasNext();) {
- Map.Entry<Object, Object> entry = headersIterator.next();
- if (key.equalsIgnoreCase(entry.getKey().toString())) {
+ for (Entry<String, Object> entry : headers.entrySet()) {
+ if (key.equalsIgnoreCase(entry.getKey())) {
return entry.getValue().toString();
}
}
@@ -182,8 +184,7 @@
s.setLocalDate(localDate);
// Copy Response headers
- Properties headers2 = new Properties();
- headers2.putAll(headers);
+ Map<String, Object> headers2 = new HashMap<String, Object>(headers);
s.setHeaders(headers2);
// Copy Request headers
Modified: trunk/webassembletool-core/src/main/java/net/webassembletool/cache/CachedResponseSummary.java
===================================================================
--- trunk/webassembletool-core/src/main/java/net/webassembletool/cache/CachedResponseSummary.java 2011-02-22 09:04:36 UTC (rev 577)
+++ trunk/webassembletool-core/src/main/java/net/webassembletool/cache/CachedResponseSummary.java 2011-02-22 16:47:18 UTC (rev 578)
@@ -1,10 +1,10 @@
package net.webassembletool.cache;
import java.io.IOException;
+import java.util.Collection;
import java.util.Date;
-import java.util.Iterator;
import java.util.Map;
-import java.util.Properties;
+import java.util.Map.Entry;
import net.webassembletool.output.Output;
import net.webassembletool.resource.Resource;
@@ -17,7 +17,7 @@
*
*/
public class CachedResponseSummary extends Resource {
- private Properties headers;
+ private Map<String, Object> headers;
private int statusCode;
private Map<String, String> requestHeaders;
private boolean responseBody;
@@ -58,7 +58,7 @@
return responseBody;
}
- public void setHeaders(Properties headers) {
+ public void setHeaders(Map<String, Object> headers) {
this.headers = headers;
}
@@ -90,10 +90,13 @@
}
@Override
+ public Collection<String> getHeaderNames() {
+ return headers.keySet();
+ }
+
+ @Override
public final String getHeader(String key) {
- for (Iterator<Map.Entry<Object, Object>> headersIterator = headers
- .entrySet().iterator(); headersIterator.hasNext();) {
- Map.Entry<Object, Object> entry = headersIterator.next();
+ for (Entry<String, Object> entry : headers.entrySet()) {
if (key.equalsIgnoreCase(entry.getKey().toString())) {
return entry.getValue().toString();
}
@@ -108,10 +111,7 @@
*/
@Override
public String getRequestHeader(String key) {
-
- for (Iterator<Map.Entry<String, String>> headersIterator = requestHeaders
- .entrySet().iterator(); headersIterator.hasNext();) {
- Map.Entry<String, String> entry = headersIterator.next();
+ for (Entry<String, String> entry : requestHeaders.entrySet()) {
if (key.equalsIgnoreCase(entry.getKey().toString())) {
return entry.getValue().toString();
}
Modified: trunk/webassembletool-core/src/main/java/net/webassembletool/file/FileOutput.java
===================================================================
--- trunk/webassembletool-core/src/main/java/net/webassembletool/file/FileOutput.java 2011-02-22 09:04:36 UTC (rev 577)
+++ trunk/webassembletool-core/src/main/java/net/webassembletool/file/FileOutput.java 2011-02-22 16:47:18 UTC (rev 578)
@@ -20,9 +20,9 @@
private final File headerFile;
private FileOutputStream fileOutputStream;
- public FileOutput(String url) {
- file = new File(url);
- headerFile = new File(url + ".headers");
+ public FileOutput(File dataFile, File headersFile) {
+ this.file = dataFile;
+ this.headerFile = headersFile;
}
/** {@inheritDoc} */
@@ -35,8 +35,7 @@
}
fileOutputStream = new FileOutputStream(file);
} catch (IOException e) {
- throw new OutputException("Could not create file: " + file.toURI(),
- e);
+ throw new OutputException("Could not create file: " + file.toURI(), e);
}
}
@@ -50,24 +49,19 @@
@Override
public void close() {
try {
- // In case the file could not be written, fileOutputStream might be
- // null
+ // In case the file could not be written, fileOutputStream might be null
if (fileOutputStream != null) {
fileOutputStream.close();
}
- fileOutputStream = null;
} catch (IOException e) {
- throw new OutputException("Could not close file: " + file.toURI(),
- e);
+ throw new OutputException("Could not close file: " + file.toURI(), e);
+ } finally {
+ fileOutputStream = null;
}
try {
- FileOutputStream headers = new FileOutputStream(headerFile);
- addHeader(Integer.toString(getStatusCode()), getStatusMessage());
- getHeaders().store(headers, "Headers");
- headers.close();
+ FileUtils.storeHeaders(headerFile, new HeadersFile(getHeaders(), getStatusCode(), getStatusMessage()));
} catch (IOException e) {
- throw new OutputException("Could not write to file: "
- + headerFile.toURI(), e);
+ throw new OutputException("Could not write to file: " + headerFile.toURI(), e);
}
}
Modified: trunk/webassembletool-core/src/main/java/net/webassembletool/file/FileResource.java
===================================================================
--- trunk/webassembletool-core/src/main/java/net/webassembletool/file/FileResource.java 2011-02-22 09:04:36 UTC (rev 577)
+++ trunk/webassembletool-core/src/main/java/net/webassembletool/file/FileResource.java 2011-02-22 16:47:18 UTC (rev 578)
@@ -5,16 +5,11 @@
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
+import java.util.Collection;
import java.util.Map.Entry;
-import java.util.Properties;
-import net.webassembletool.ResourceContext;
import net.webassembletool.output.Output;
import net.webassembletool.resource.Resource;
-import net.webassembletool.resource.ResourceUtils;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang.StringUtils;
@@ -27,38 +22,14 @@
*/
public class FileResource extends Resource {
private File file;
- private Map<String, String> headersMap;
- private int statusCode;
- private String statusMessage;
+ private final HeadersFile headersFile;
- public FileResource(String localBase, ResourceContext target)
- throws IOException {
- String url = ResourceUtils.getFileUrl(localBase, target);
- file = new File(url);
- File headersFile = new File(url + ".headers");
+ public FileResource(File dataFile, File headersFile) throws IOException {
+ this.file = dataFile;
if (file.exists() && headersFile.exists()) {
- headersMap = new HashMap<String, String>();
- InputStream headersInputStream = new FileInputStream(headersFile);
- Properties headers = new Properties();
- headers.load(headersInputStream);
- headersInputStream.close();
-
- Iterator<Entry<Object, Object>> iterator = headers.entrySet()
- .iterator();
-
- while (iterator.hasNext()) {
- Entry<Object, Object> header = iterator.next();
- if (StringUtils.isNumeric(header.getKey().toString())) {
- statusCode = Integer.parseInt(header.getKey().toString());
- statusMessage = header.getValue().toString();
- } else {
- headersMap.put(header.getKey().toString().toLowerCase(),
- header.getValue().toString());
- }
- }
+ this.headersFile = FileUtils.loadHeaders(headersFile);
} else {
- statusCode = 404;
- statusMessage = "Not found";
+ this.headersFile = new HeadersFile(404, "Not found");
}
}
@@ -69,14 +40,9 @@
@Override
public void render(Output output) throws IOException {
- output.setStatus(statusCode, statusMessage);
- if (headersMap != null) {
- Iterator<Entry<String, String>> iterator = headersMap.entrySet()
- .iterator();
- while (iterator.hasNext()) {
- Entry<String, String> header = iterator.next();
- output.addHeader(header.getKey(), header.getValue());
- }
+ output.setStatus(headersFile.getStatusCode(), headersFile.getStatusMessage());
+ for (Entry<String, Object> header : headersFile.getHeadersMap().entrySet()) {
+ output.addHeader(header.getKey(), header.getValue().toString());
}
if (file != null) {
@@ -97,14 +63,20 @@
*/
@Override
public int getStatusCode() {
- return statusCode;
+ return headersFile.getStatusCode();
}
@Override
+ public Collection<String> getHeaderNames() {
+ return headersFile.getHeadersMap().keySet();
+ }
+
+ @Override
public String getHeader(String name) {
- if (headersMap == null) {
+ if (StringUtils.isEmpty(name)) {
return null;
}
- return headersMap.get(name);
+ Object value = headersFile.getHeader(name);
+ return value != null ? value.toString() : null;
}
}
Added: trunk/webassembletool-core/src/main/java/net/webassembletool/file/FileUtils.java
===================================================================
--- trunk/webassembletool-core/src/main/java/net/webassembletool/file/FileUtils.java (rev 0)
+++ trunk/webassembletool-core/src/main/java/net/webassembletool/file/FileUtils.java 2011-02-22 16:47:18 UTC (rev 578)
@@ -0,0 +1,61 @@
+package net.webassembletool.file;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.Map.Entry;
+import java.util.Properties;
+
+import org.apache.commons.lang.StringUtils;
+
+/**
+ * Internal utility class to store/retrieve data from disk.
+ *
+ * @author <a href="sta...@sm...">Stanislav Bernatskyi</a>
+ */
+class FileUtils {
+ private FileUtils() {
+ }
+
+ public static HeadersFile loadHeaders(File src) throws IOException {
+ InputStream in = new FileInputStream(src);
+ try {
+ Properties prop = new Properties();
+ prop.load(in);
+
+ HeadersFile result = new HeadersFile();
+ for (Entry<Object, Object> header : prop.entrySet()) {
+ String key = header.getKey().toString();
+ String value = header.getValue().toString();
+ if (StringUtils.isNumeric(key)) {
+ result.setStatusCode(Integer.parseInt(key));
+ result.setStatusMessage(value);
+ } else {
+ result.addHeader(key, value);
+ }
+ }
+
+ return result;
+ } finally {
+ in.close();
+ }
+ }
+
+ public static void storeHeaders(File dest, HeadersFile headers)
+ throws IOException {
+ OutputStream out = new FileOutputStream(dest);
+ try {
+ Properties prop = new Properties();
+ for (Entry<String, Object> entry : headers.getHeadersMap().entrySet()) {
+ prop.setProperty(entry.getKey(), entry.getValue().toString());
+ }
+ prop.setProperty(Integer.toString(headers.getStatusCode()), headers.getStatusMessage());
+ prop.store(out, "Headers");
+ } finally {
+ out.close();
+ }
+ }
+}
Property changes on: trunk/webassembletool-core/src/main/java/net/webassembletool/file/FileUtils.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: trunk/webassembletool-core/src/main/java/net/webassembletool/file/HeadersFile.java
===================================================================
--- trunk/webassembletool-core/src/main/java/net/webassembletool/file/HeadersFile.java (rev 0)
+++ trunk/webassembletool-core/src/main/java/net/webassembletool/file/HeadersFile.java 2011-02-22 16:47:18 UTC (rev 578)
@@ -0,0 +1,52 @@
+package net.webassembletool.file;
+
+import java.util.HashMap;
+import java.util.Map;
+
+class HeadersFile {
+ private final Map<String, Object> headersMap;
+ private int statusCode;
+ private String statusMessage;
+
+ public HeadersFile() {
+ this(0, null);
+ }
+ public HeadersFile(int statusCode, String statusMessage) {
+ this(new HashMap<String, Object>(), statusCode, statusMessage);
+ }
+
+ public HeadersFile(Map<String, Object> headersMap, int statusCode, String statusMessage) {
+ this.headersMap = headersMap;
+ this.statusCode = statusCode;
+ this.statusMessage = statusMessage;
+ }
+
+ public void addHeader(String key, Object value) {
+ headersMap.put(key.toLowerCase(), value);
+ }
+
+ public Object getHeader(String key) {
+ return headersMap.get(key.toLowerCase());
+ }
+
+ public Map<String, Object> getHeadersMap() {
+ return headersMap;
+ }
+
+ public int getStatusCode() {
+ return statusCode;
+ }
+
+ public String getStatusMessage() {
+ return statusMessage;
+ }
+
+ public void setStatusCode(int statusCode) {
+ this.statusCode = statusCode;
+ }
+
+ public void setStatusMessage(String statusMessage) {
+ this.statusMessage = statusMessage;
+ }
+
+}
Property changes on: trunk/webassembletool-core/src/main/java/net/webassembletool/file/HeadersFile.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified: trunk/webassembletool-core/src/main/java/net/webassembletool/http/HttpClientResponse.java
===================================================================
--- trunk/webassembletool-core/src/main/java/net/webassembletool/http/HttpClientResponse.java 2011-02-22 09:04:36 UTC (rev 577)
+++ trunk/webassembletool-core/src/main/java/net/webassembletool/http/HttpClientResponse.java 2011-02-22 16:47:18 UTC (rev 578)
@@ -17,11 +17,12 @@
import java.io.IOException;
import java.io.InputStream;
import java.net.SocketTimeoutException;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Set;
import javax.servlet.http.HttpServletResponse;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import org.apache.http.Header;
import org.apache.http.HttpEntity;
import org.apache.http.HttpHost;
@@ -34,6 +35,8 @@
import org.apache.http.protocol.ExecutionContext;
import org.apache.http.protocol.HttpContext;
import org.apache.http.util.EntityUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* @author François-Xavier Bonnet
@@ -48,13 +51,11 @@
private String statusText;
private String currentLocation;
private Exception exception;
- private InputStream inputStream;
public HttpClientResponse(HttpHost httpHost, HttpRequest basicHttpRequest,
HttpClient httpClient, HttpContext httpContext) {
try {
- httpResponse = httpClient.execute(httpHost, basicHttpRequest,
- httpContext);
+ httpResponse = httpClient.execute(httpHost, basicHttpRequest, httpContext);
statusCode = httpResponse.getStatusLine().getStatusCode();
statusText = httpResponse.getStatusLine().getReasonPhrase();
httpEntity = httpResponse.getEntity();
@@ -134,8 +135,7 @@
}
public InputStream openStream() throws IllegalStateException, IOException {
- inputStream = httpEntity.getContent();
- return inputStream;
+ return httpEntity.getContent();
}
public String getHeader(String name) {
@@ -150,6 +150,18 @@
}
}
+ public Collection<String> getHeaderNames() {
+ Set<String> result = new HashSet<String>();
+ if (httpResponse != null) {
+ Header[] headers = httpResponse.getAllHeaders();
+ if (headers != null) {
+ for (Header header : headers) {
+ result.add(header.getName());
+ }
+ }
+ }
+ return result;
+ }
public String[] getHeaders(String name) {
String[] result = null;
if (httpResponse != null) {
Modified: trunk/webassembletool-core/src/main/java/net/webassembletool/http/HttpResource.java
===================================================================
--- trunk/webassembletool-core/src/main/java/net/webassembletool/http/HttpResource.java 2011-02-22 09:04:36 UTC (rev 577)
+++ trunk/webassembletool-core/src/main/java/net/webassembletool/http/HttpResource.java 2011-02-22 16:47:18 UTC (rev 578)
@@ -17,6 +17,7 @@
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
+import java.util.Collection;
import java.util.Map;
import java.util.Map.Entry;
import java.util.zip.GZIPInputStream;
@@ -36,10 +37,10 @@
import net.webassembletool.util.Rfc2616;
import org.apache.commons.io.IOUtils;
+import org.apache.http.client.HttpClient;
+import org.apache.http.protocol.HttpContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.apache.http.client.HttpClient;
-import org.apache.http.protocol.HttpContext;
/**
* Resource implementation pointing to a resource on an external application.
@@ -146,9 +147,8 @@
@Override
public void render(Output output) throws IOException {
- output.setStatus(httpClientResponse.getStatusCode(),
- httpClientResponse.getStatusText());
- Rfc2616.copyHeaders(this, output);
+ output.setStatus(httpClientResponse.getStatusCode(), httpClientResponse.getStatusText());
+ Rfc2616.copyHeaders(target.getDriver().getConfiguration(), this, output);
Filter filter = target.getDriver().getFilter();
if (filter != null) {
filter.postRequest(httpClientResponse, output, target);
@@ -286,4 +286,8 @@
return httpClientResponse.getHeader(name);
}
+ @Override
+ public Collection<String> getHeaderNames() {
+ return httpClientResponse.getHeaderNames();
+ }
}
Modified: trunk/webassembletool-core/src/main/java/net/webassembletool/http/ResponseOutput.java
===================================================================
--- trunk/webassembletool-core/src/main/java/net/webassembletool/http/ResponseOutput.java 2011-02-22 09:04:36 UTC (rev 577)
+++ trunk/webassembletool-core/src/main/java/net/webassembletool/http/ResponseOutput.java 2011-02-22 16:47:18 UTC (rev 578)
@@ -2,8 +2,7 @@
import java.io.IOException;
import java.io.OutputStream;
-import java.util.Iterator;
-import java.util.Map;
+import java.util.Map.Entry;
import javax.servlet.http.HttpServletResponse;
@@ -46,11 +45,8 @@
* Copy all the headers to the response
*/
private void copyHeaders() {
- for (Iterator<Map.Entry<Object, Object>> headersIterator = getHeaders()
- .entrySet().iterator(); headersIterator.hasNext();) {
- Map.Entry<Object, Object> entry = headersIterator.next();
- response.setHeader(entry.getKey().toString(), entry.getValue()
- .toString());
+ for (Entry<String, Object> entry : getHeaders().entrySet()) {
+ response.setHeader(entry.getKey(), entry.getValue().toString());
}
}
Modified: trunk/webassembletool-core/src/main/java/net/webassembletool/output/Output.java
===================================================================
--- trunk/webassembletool-core/src/main/java/net/webassembletool/output/Output.java 2011-02-22 09:04:36 UTC (rev 577)
+++ trunk/webassembletool-core/src/main/java/net/webassembletool/output/Output.java 2011-02-22 16:47:18 UTC (rev 578)
@@ -3,9 +3,9 @@
import java.io.IOException;
import java.io.OutputStream;
import java.io.UnsupportedEncodingException;
-import java.util.Iterator;
+import java.util.HashMap;
import java.util.Map;
-import java.util.Properties;
+import java.util.Map.Entry;
/**
* An Output is designed to collect the response to a successfull HTTP request,
@@ -26,7 +26,7 @@
private String charsetName;
private int statusCode;
private String statusMessage;
- private final Properties headers = new Properties();
+ private final Map<String, Object> headers = new HashMap<String, Object>();
/**
* Sets the HTTP status code of the response
@@ -57,27 +57,30 @@
this.statusMessage = statusMessage;
}
- protected final Properties getHeaders() {
+ protected final Map<String, Object> getHeaders() {
return headers;
}
public final String getHeader(String key) {
- for (Iterator<Map.Entry<Object, Object>> headersIterator = getHeaders()
- .entrySet().iterator(); headersIterator.hasNext();) {
- Map.Entry<Object, Object> entry = headersIterator.next();
- if (key.equalsIgnoreCase(entry.getKey().toString()))
+ for (Entry<String, Object> entry : headers.entrySet()) {
+ if (key.equalsIgnoreCase(entry.getKey())) {
return entry.getValue().toString();
+ }
}
return null;
}
public final void setHeader(String key, String value) {
- for (Iterator<Map.Entry<Object, Object>> headersIterator = getHeaders()
- .entrySet().iterator(); headersIterator.hasNext();) {
- Map.Entry<Object, Object> entry = headersIterator.next();
- if (key.equalsIgnoreCase(entry.getKey().toString()))
- headers.remove(entry.getKey());
+ String keyToRemove = null;
+ for (Entry<String, Object> entry : headers.entrySet()) {
+ if (key.equalsIgnoreCase(entry.getKey())) {
+ keyToRemove = entry.getKey();
+ break;
+ }
}
+ if (keyToRemove != null) {
+ headers.remove(keyToRemove);
+ }
headers.put(key, value);
}
Modified: trunk/webassembletool-core/src/main/java/net/webassembletool/output/TextOnlyStringOutput.java
===================================================================
--- trunk/webassembletool-core/src/main/java/net/webassembletool/output/TextOnlyStringOutput.java 2011-02-22 09:04:36 UTC (rev 577)
+++ trunk/webassembletool-core/src/main/java/net/webassembletool/output/TextOnlyStringOutput.java 2011-02-22 16:47:18 UTC (rev 578)
@@ -4,9 +4,8 @@
import java.io.IOException;
import java.io.OutputStream;
import java.io.UnsupportedEncodingException;
-import java.util.Iterator;
import java.util.List;
-import java.util.Map;
+import java.util.Map.Entry;
import javax.servlet.http.HttpServletResponse;
@@ -79,17 +78,12 @@
* Copy all the headers to the response
*/
private void copyHeaders() {
- for (Iterator<Map.Entry<Object, Object>> headersIterator = getHeaders()
- .entrySet().iterator(); headersIterator.hasNext();) {
- Map.Entry<Object, Object> entry = headersIterator.next();
+ for (Entry<String, Object> entry : getHeaders().entrySet()) {
// Swallow content-encoding and content-length headers for html
// pages as content-length may change and gzip-encoded pages will be
// decoded
- if (!text
- || (!"content-length".equalsIgnoreCase((String) (entry
- .getKey())))) {
- response.setHeader(entry.getKey().toString(), entry.getValue()
- .toString());
+ if (!text || (!"content-length".equalsIgnoreCase(entry.getKey()))) {
+ response.setHeader(entry.getKey(), entry.getValue().toString());
}
}
}
Modified: trunk/webassembletool-core/src/main/java/net/webassembletool/resource/NullResource.java
===================================================================
--- trunk/webassembletool-core/src/main/java/net/webassembletool/resource/NullResource.java 2011-02-22 09:04:36 UTC (rev 577)
+++ trunk/webassembletool-core/src/main/java/net/webassembletool/resource/NullResource.java 2011-02-22 16:47:18 UTC (rev 578)
@@ -1,6 +1,8 @@
package net.webassembletool.resource;
import java.io.IOException;
+import java.util.Collection;
+import java.util.Collections;
import net.webassembletool.output.Output;
@@ -28,6 +30,11 @@
}
@Override
+ public Collection<String> getHeaderNames() {
+ return Collections.emptySet();
+ }
+
+ @Override
public String getHeader(String name) {
return null;
}
Modified: trunk/webassembletool-core/src/main/java/net/webassembletool/resource/Resource.java
===================================================================
--- trunk/webassembletool-core/src/main/java/net/webassembletool/resource/Resource.java 2011-02-22 09:04:36 UTC (rev 577)
+++ trunk/webassembletool-core/src/main/java/net/webassembletool/resource/Resource.java 2011-02-22 16:47:18 UTC (rev 578)
@@ -1,6 +1,7 @@
package net.webassembletool.resource;
import java.io.IOException;
+import java.util.Collection;
import java.util.Date;
import javax.servlet.http.HttpServletResponse;
@@ -51,6 +52,8 @@
/**
* Get resource header.
+ * <p>
+ * However it would be better to allow multiple values for single name retrieval.
*
* @param name
* Header name (not null)
@@ -58,6 +61,9 @@
*/
public abstract String getHeader(String name);
+ /** Returns all available header names found in resource. */
+ public abstract Collection<String> getHeaderNames();
+
/**
* Get header of the request which was used to get this resource. This can
* be used to check cache matching especially when the "Vary" header is
Modified: trunk/webassembletool-core/src/main/java/net/webassembletool/resource/ResourceUtils.java
===================================================================
--- trunk/webassembletool-core/src/main/java/net/webassembletool/resource/ResourceUtils.java 2011-02-22 09:04:36 UTC (rev 577)
+++ trunk/webassembletool-core/src/main/java/net/webassembletool/resource/ResourceUtils.java 2011-02-22 16:47:18 UTC (rev 578)
@@ -1,6 +1,7 @@
package net.webassembletool.resource;
import java.io.File;
+import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.util.List;
@@ -11,6 +12,8 @@
import net.webassembletool.DriverConfiguration;
import net.webassembletool.ResourceContext;
+import net.webassembletool.file.FileOutput;
+import net.webassembletool.file.FileResource;
import net.webassembletool.http.RewriteUtils;
import org.apache.commons.lang.StringUtils;
@@ -223,18 +226,29 @@
}
}
- public final static String getFileUrl(String localBase,
- ResourceContext target) {
+ public static FileOutput createFileOutput(String localBase, ResourceContext target) {
+ String baseFileName = getFileUrl(localBase, target);
+ String headersFileName = baseFileName + ".headers";
+ return new FileOutput(new File(baseFileName), new File(headersFileName));
+ }
+
+ public static FileResource createFileResource(String localBase, ResourceContext target) throws IOException {
+ String baseFileName = getFileUrl(localBase, target);
+ String headersFileName = baseFileName + ".headers";
+ return new FileResource(new File(baseFileName), new File(headersFileName));
+ }
+
+ private final static String getFileUrl(String localBase, ResourceContext target) {
String answer = "";
String url = target.getRelUrl();
// Remove ":" and "//" for absolute urls
url = url.replaceAll(":", "_");
url = url.replaceAll("//", "__");
- url = ResourceUtils.concatUrlForFile(localBase, target.getRelUrl());
+ url = ResourceUtils.concatUrlForFile(localBase, url);
// Append queryString hashcode to supply different cache
// filenames
String queryString = ResourceUtils.buildQueryString(target);
- if ("".equals(queryString)) {
+ if (queryString.length() == 0) {
answer = url;
} else {
answer = url + "_" + queryString.hashCode();
Modified: trunk/webassembletool-core/src/main/java/net/webassembletool/util/Rfc2616.java
===================================================================
--- trunk/webassembletool-core/src/main/java/net/webassembletool/util/Rfc2616.java 2011-02-22 09:04:36 UTC (rev 577)
+++ trunk/webassembletool-core/src/main/java/net/webassembletool/util/Rfc2616.java 2011-02-22 16:47:18 UTC (rev 578)
@@ -11,6 +11,7 @@
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
+import net.webassembletool.DriverConfiguration;
import net.webassembletool.ResourceContext;
import net.webassembletool.output.Output;
import net.webassembletool.resource.Resource;
@@ -392,11 +393,10 @@
return false;
}
- public final static void renderResource(Resource resource, Output output)
- throws IOException {
+ public final static void renderResource(DriverConfiguration config, Resource resource, Output output) throws IOException {
if (HttpServletResponse.SC_NOT_MODIFIED == resource.getStatusCode()) {
output.setStatusCode(resource.getStatusCode());
- copyHeaders(resource, output);
+ copyHeaders(config, resource, output);
output.open();
output.getOutputStream();
// No response body
@@ -406,50 +406,16 @@
}
}
- /**
- * Copies end-to-end headers from a resource to an output
- */
- public final static void copyHeaders(Resource resource, Output output) {
- copyHeader(resource, output, "Date");
- copyHeader(resource, output, "Content-Type");
- // Do not copy Content-encoding
- // Do not copy Content-length header for gzipped streams as it will
- // change ! OK this is not compliant with RFC 2616 but we need to do
- // that as we often have to modify the content of the response
- if (resource.getHeader("Content-encoding") == null) {
- copyHeader(resource, output, "Content-Length");
+ /** Copies end-to-end headers from a resource to an output. */
+ public final static void copyHeaders(DriverConfiguration config, Resource resource, Output output) {
+ for (String headerName : resource.getHeaderNames()) {
+ if (!config.isBlackListed(headerName)) {
+ String headerValue = resource.getHeader(headerName);
+ if (headerValue != null) {
+ output.setHeader(headerName, headerValue);
+ }
+ }
}
- copyHeader(resource, output, "Last-Modified");
- copyHeader(resource, output, "ETag");
- copyHeader(resource, output, "Expires");
- copyHeader(resource, output, "Cache-control");
- // FIXME: We have to copy all headers except those that the RFC says not
- // to. For now, we just add a missing (and important) header
- // See :
- // https://sourceforge.net/apps/mantisbt/webassembletool/view.php?id=15
- copyHeader(resource, output, "Content-Disposition");
-
- // See
- // https://sourceforge.net/apps/mantisbt/webassembletool/view.php?id=18
- copyHeader(resource, output, "Vary");
}
- /**
- * Copy header "name" from "resource" to "output".
- *
- * @param resource
- * source Resource
- * @param output
- * target Output
- * @param name
- * name of the header
- */
- private final static void copyHeader(Resource resource, Output output,
- String name) {
- String value = resource.getHeader(name);
- if (value != null) {
- output.setHeader(name, value);
- }
- }
-
}
Modified: trunk/webassembletool-core/src/test/java/net/webassembletool/DriverConfigurationTest.java
===================================================================
--- trunk/webassembletool-core/src/test/java/net/webassembletool/DriverConfigurationTest.java 2011-02-22 09:04:36 UTC (rev 577)
+++ trunk/webassembletool-core/src/test/java/net/webassembletool/DriverConfigurationTest.java 2011-02-22 16:47:18 UTC (rev 578)
@@ -72,4 +72,32 @@
"application/x", config.getParsableContentTypes().get(2));
}
+
+ public void testIsBlackListed() {
+ // by default only 'Content-Length,Content-Encoding,Transfer-Encoding' is blacklisted
+ Properties properties = new Properties();
+ DriverConfiguration config = new DriverConfiguration("test-parsable", properties);
+
+ assertTrue("null header should be blacklisted", config.isBlackListed(null));
+ assertTrue("empty header should be blacklisted", config.isBlackListed(""));
+
+ assertTrue("'Content-Length' header should be blacklisted", config.isBlackListed("Content-Length"));
+ assertTrue("'Content-Length' header should be blacklisted ignoring case",
+ config.isBlackListed("Content-Length".toUpperCase()));
+ assertTrue("'Content-Length' header should be blacklisted ignoring case",
+ config.isBlackListed("Content-Length".toLowerCase()));
+ assertTrue("'Content-Encoding' header should be blacklisted", config.isBlackListed("Content-Encoding"));
+ assertTrue("'Transfer-Encoding' header should be blacklisted", config.isBlackListed("Transfer-Encoding"));
+
+ // blacklisted headers are specified via 'blackListedHeaders' property
+ properties = new Properties();
+ properties.setProperty("blackListedHeaders", "header");
+ config = new DriverConfiguration("test-parsable", properties);
+
+ assertTrue("null header should be blacklisted", config.isBlackListed(null));
+ assertTrue("empty header should be blacklisted", config.isBlackListed(""));
+ assertFalse("'Content-Length' header should not be blacklisted", config.isBlackListed("Content-Length"));
+ assertTrue("'header' header should be blacklisted", config.isBlackListed("header"));
+ assertTrue("'header' header should be blacklisted ignoring cas", config.isBlackListed("header".toUpperCase()));
+ }
}
Added: trunk/webassembletool-core/src/test/java/net/webassembletool/http/HttpClientResponseTest.java
===================================================================
--- trunk/webassembletool-core/src/test/java/net/webassembletool/http/HttpClientResponseTest.java (rev 0)
+++ trunk/webassembletool-core/src/test/java/net/webassembletool/http/HttpClientResponseTest.java 2011-02-22 16:47:18 UTC (rev 578)
@@ -0,0 +1,94 @@
+package net.webassembletool.http;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+
+import javax.servlet.http.HttpServletResponse;
+
+import junit.framework.TestCase;
+
+import org.apache.http.Header;
+import org.apache.http.HttpHost;
+import org.apache.http.HttpRequest;
+import org.apache.http.HttpResponse;
+import org.apache.http.ProtocolVersion;
+import org.apache.http.StatusLine;
+import org.apache.http.client.HttpClient;
+import org.apache.http.message.BasicHeader;
+import org.apache.http.message.BasicStatusLine;
+import org.apache.http.protocol.HttpContext;
+import org.easymock.EasyMock;
+import org.easymock.IMocksControl;
+
+public class HttpClientResponseTest extends TestCase {
+ private HttpClientResponse tested;
+
+ private IMocksControl control;
+ private HttpHost httpHost;
+ private HttpRequest httpRequest;
+ private HttpClient httpClient;
+ private HttpContext httpContext;
+ private HttpResponse httpResponse;
+
+ @Override
+ protected void setUp() {
+ control = EasyMock.createControl();
+ httpRequest = control.createMock(HttpRequest.class);
+ httpClient = control.createMock(HttpClient.class);
+ httpContext = control.createMock(HttpContext.class);
+ httpResponse = control.createMock(HttpResponse.class);
+
+ httpHost = new HttpHost("httpHost", 1234);
+ }
+
+ @Override
+ protected void tearDown() {
+ control = null;
+ httpRequest = null;
+ httpClient = null;
+ httpContext = null;
+ httpResponse = null;
+ httpHost = null;
+
+ tested = null;
+ }
+
+ public void testGetHeaderNames() throws IOException {
+ // initial set up
+ StatusLine statusLine = new BasicStatusLine(new ProtocolVersion("p", 1, 2), HttpServletResponse.SC_MOVED_PERMANENTLY,
+ "reason");
+ EasyMock.expect(httpClient.execute(httpHost, httpRequest, httpContext)).andReturn(httpResponse);
+ EasyMock.expect(httpResponse.getStatusLine()).andReturn(statusLine);
+ EasyMock.expect(httpResponse.getStatusLine()).andReturn(statusLine);
+ EasyMock.expect(httpResponse.getEntity()).andReturn(null);
+ EasyMock.expect(httpResponse.getFirstHeader(HttpHeaders.LOCATION)).andReturn(new BasicHeader("h", "value"));
+ // getHeaderNames behaviour
+ Header[] headers = new Header[] { new BasicHeader("h1", "value 1"), new BasicHeader("h1", "value 2"),
+ new BasicHeader("h2", "value 3") };
+ EasyMock.expect(httpResponse.getAllHeaders()).andReturn(headers);
+ control.replay();
+
+ tested = new HttpClientResponse(httpHost, httpRequest, httpClient, httpContext);
+ Collection<String> actual = tested.getHeaderNames();
+
+ assertNotNull(actual);
+ String names[] = toArray(actual);
+ assertEquals(2, names.length);
+ assertEquals("h1", names[0]);
+ assertEquals("h2", names[1]);
+ control.verify();
+ }
+
+ private String[] toArray(Collection<String> src) {
+ List<String> result = new ArrayList<String>();
+ for (String s : src) {
+ result.add(s);
+ }
+ Collections.sort(result);
+ return result.toArray(new String[result.size()]);
+ }
+
+}
Property changes on: trunk/webassembletool-core/src/test/java/net/webassembletool/http/HttpClientResponseTest.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified: trunk/webassembletool-core/src/test/java/net/webassembletool/http/HttpResourceTest.java
===================================================================
--- trunk/webassembletool-core/src/test/java/net/webassembletool/http/HttpResourceTest.java 2011-02-22 09:04:36 UTC (rev 577)
+++ trunk/webassembletool-core/src/test/java/net/webassembletool/http/HttpResourceTest.java 2011-02-22 16:47:18 UTC (rev 578)
@@ -83,7 +83,8 @@
EasyMock.expect(statusLine.getStatusCode()).andReturn(HttpServletResponse.SC_MOVED_TEMPORARILY).anyTimes();
EasyMock.expect(statusLine.getReasonPhrase()).andReturn("Moved Permanently").anyTimes();
EasyMock.expect(httpResponse.getFirstHeader("Location")).andReturn(header).anyTimes();
- EasyMock.expect(httpResponse.getFirstHeader((String)EasyMock.anyObject())).andReturn(null).anyTimes();
+ EasyMock.expect(httpResponse.getAllHeaders()).andReturn(new Header[0]).anyTimes();
+ EasyMock.expect(httpResponse.getFirstHeader((String) EasyMock.anyObject())).andReturn(null).anyTimes();
EasyMock.expect(header.getValue()).andReturn("http://localhost:8080/webassembletool-app-aggregated1/redirected.jsp");
EasyMock.expect(header.getValue()).andReturn("http://localhost:8080/webassembletool-app-aggregated1/redirected.jsp");
Modified: trunk/webassembletool-core/src/test/java/net/webassembletool/util/Rfc2616Test.java
===================================================================
--- trunk/webassembletool-core/src/test/java/net/webassembletool/util/Rfc2616Test.java 2011-02-22 09:04:36 UTC (rev 577)
+++ trunk/webassembletool-core/src/test/java/net/webassembletool/util/Rfc2616Test.java 2011-02-22 16:47:18 UTC (rev 578)
@@ -1,6 +1,7 @@
package net.webassembletool.util;
import java.io.IOException;
+import java.util.Collection;
import java.util.Date;
import junit.framework.TestCase;
@@ -54,6 +55,10 @@
return null;
}
+ @Override
+ public Collection<String> getHeaderNames() {
+ return null;
+ }
};
Date d = Rfc2616.getExpiration(r);
@@ -89,7 +94,11 @@
@Override
public String getHeader(String name) {
+ return null;
+ }
+ @Override
+ public Collection<String> getHeaderNames() {
return null;
}
};
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <sbe...@us...> - 2011-02-22 09:04:42
|
Revision: 577
http://webassembletool.svn.sourceforge.net/webassembletool/?rev=577&view=rev
Author: sbernatsky
Date: 2011-02-22 09:04:36 +0000 (Tue, 22 Feb 2011)
Log Message:
-----------
https://sourceforge.net/apps/mantisbt/webassembletool/view.php?id=14 : [on anleb behalf] WAT should not follow redirect to external pages.
Modified Paths:
--------------
trunk/webassembletool-core/src/main/java/net/webassembletool/http/HttpResource.java
Added Paths:
-----------
trunk/webassembletool-core/src/test/java/net/webassembletool/http/HttpResourceTest.java
Modified: trunk/webassembletool-core/src/main/java/net/webassembletool/http/HttpResource.java
===================================================================
--- trunk/webassembletool-core/src/main/java/net/webassembletool/http/HttpResource.java 2011-02-18 11:50:10 UTC (rev 576)
+++ trunk/webassembletool-core/src/main/java/net/webassembletool/http/HttpResource.java 2011-02-22 09:04:36 UTC (rev 577)
@@ -22,6 +22,7 @@
import java.util.zip.GZIPInputStream;
import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
import net.webassembletool.Driver;
import net.webassembletool.ResourceContext;
@@ -95,6 +96,18 @@
filter.preRequest(httpClientRequest, resourceContext);
}
httpClientResponse = httpClientRequest.execute(httpClient, httpContext);
+ if (httpClientResponse != null
+ && (httpClientResponse.getStatusCode() == HttpServletResponse.SC_MOVED_PERMANENTLY || httpClientResponse
+ .getStatusCode() == HttpServletResponse.SC_MOVED_TEMPORARILY)) {
+ if (!httpClientResponse.getCurrentLocation().startsWith(
+ resourceContext.getDriver().getBaseURL())) {
+ LOG.debug("Current location should be started with: "
+ + resourceContext.getDriver().getBaseURL());
+ throw new IOException(
+ "Current location should be started with: "
+ + resourceContext.getDriver().getBaseURL());
+ }
+ }
// Store context in session if cookies where created
if (newUserContext && !userContext.getCookieStore().getCookies().isEmpty()) {
Added: trunk/webassembletool-core/src/test/java/net/webassembletool/http/HttpResourceTest.java
===================================================================
--- trunk/webassembletool-core/src/test/java/net/webassembletool/http/HttpResourceTest.java (rev 0)
+++ trunk/webassembletool-core/src/test/java/net/webassembletool/http/HttpResourceTest.java 2011-02-22 09:04:36 UTC (rev 577)
@@ -0,0 +1,119 @@
+package net.webassembletool.http;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.util.Properties;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import junit.framework.TestCase;
+import net.webassembletool.Driver;
+import net.webassembletool.ResourceContext;
+import net.webassembletool.output.Output;
+import net.webassembletool.test.MockOutput;
+
+import org.apache.http.Header;
+import org.apache.http.HeaderElement;
+import org.apache.http.HttpEntity;
+import org.apache.http.HttpHost;
+import org.apache.http.HttpRequest;
+import org.apache.http.HttpResponse;
+import org.apache.http.ParseException;
+import org.apache.http.StatusLine;
+import org.apache.http.client.HttpClient;
+import org.apache.http.protocol.HttpContext;
+import org.easymock.EasyMock;
+
+public class HttpResourceTest extends TestCase {
+
+ public void testRedirect() throws Exception{
+ HttpClient httpClient = EasyMock.createMock(HttpClient.class);
+ HttpServletRequest originalRequest = EasyMock.createMock(HttpServletRequest.class);
+ HttpServletResponse originalResponse = EasyMock.createMock(HttpServletResponse.class);
+ HttpResponse httpResponse = EasyMock.createMock(HttpResponse.class);
+ HttpEntity entity = EasyMock.createMock(HttpEntity.class);
+ StatusLine statusLine = EasyMock.createMock(StatusLine.class);
+ Header header = EasyMock.createMock(Header.class);
+
+ Properties props = new Properties();
+ props.setProperty("remoteUrlBase", "http://localhost:8080/webassembletool-app-aggregated1/");
+ props.setProperty("uriEncoding", "UTF-8");
+ props.setProperty("timeout", "5000");
+ props.setProperty("useCache", "false");
+
+
+ Driver driver = new Driver("test", props);
+ ResourceContext resourceContext = new ResourceContext(driver, "/redirect.jsp", null , originalRequest, originalResponse);
+
+ EasyMock.expect(originalRequest.getCharacterEncoding()).andReturn("UTF-8").anyTimes();
+ EasyMock.expect(originalRequest.getQueryString()).andReturn("http://localhost:8080/webassembletool-app-aggregator/redirect.jsp").anyTimes();
+ EasyMock.expect(originalRequest.getRequestURL()).andReturn(new StringBuffer("http://localhost:8080/webassembletool-app-aggregator/redirect.jsp")).anyTimes();
+ EasyMock.expect(originalRequest.getSession(false)).andReturn(null).anyTimes();
+ EasyMock.expect(originalRequest.getRemoteUser()).andReturn(null).anyTimes();
+ EasyMock.expect(originalRequest.getHeader("User-Agent")).andReturn("Mozilla/5.0 (Windows; U; Windows NT 6.1; ru; rv:1.9.2.13) Gecko/20101203 Firefox/3.6.13").anyTimes();
+ EasyMock.expect(originalRequest.getHeader("Accept")).andReturn("text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8").anyTimes();
+ EasyMock.expect(originalRequest.getHeader("Accept-Encoding")).andReturn("gzip,deflate").anyTimes();
+ EasyMock.expect(originalRequest.getHeader("Accept-Language")).andReturn("ru-ru,ru;q=0.8,en-us;q=0.5,en;q=0.3").anyTimes();
+ EasyMock.expect(originalRequest.getHeader("Accept-Charset")).andReturn("windows-1251,utf-8;q=0.7,*;q=0.7").anyTimes();
+ EasyMock.expect(originalRequest.getHeader("Cache-Control")).andReturn(null).anyTimes();
+ EasyMock.expect(originalRequest.getHeader("Pragma")).andReturn(null).anyTimes();
+
+ EasyMock.expect(httpClient.execute((HttpHost)EasyMock.anyObject(), (HttpRequest)EasyMock.anyObject(), (HttpContext)EasyMock.anyObject())).andReturn(httpResponse).anyTimes();
+
+ EasyMock.expect(httpResponse.getStatusLine()).andReturn(statusLine).anyTimes();
+ EasyMock.expect(httpResponse.getEntity()).andReturn(entity).anyTimes();
+ EasyMock.expect(entity.getContentType()).andReturn(new Header() {
+
+ public String getValue() {
+ return "text/html";
+ }
+
+ public String getName() {
+ return "Content-Type";
+ }
+
+ public HeaderElement[] getElements() throws ParseException {
+ return new HeaderElement[]{};
+ }
+ }).anyTimes();
+ EasyMock.expect(entity.getContent()).andReturn(new ByteArrayInputStream(new byte[1024]));
+
+ EasyMock.expect(statusLine.getStatusCode()).andReturn(HttpServletResponse.SC_MOVED_TEMPORARILY).anyTimes();
+ EasyMock.expect(statusLine.getReasonPhrase()).andReturn("Moved Permanently").anyTimes();
+ EasyMock.expect(httpResponse.getFirstHeader("Location")).andReturn(header).anyTimes();
+ EasyMock.expect(httpResponse.getFirstHeader((String)EasyMock.anyObject())).andReturn(null).anyTimes();
+
+ EasyMock.expect(header.getValue()).andReturn("http://localhost:8080/webassembletool-app-aggregated1/redirected.jsp");
+ EasyMock.expect(header.getValue()).andReturn("http://localhost:8080/webassembletool-app-aggregated1/redirected.jsp");
+
+ EasyMock.expect(header.getValue()).andReturn("http://google.com");
+
+ EasyMock.replay(httpClient, originalRequest, originalResponse, httpResponse, statusLine, header, entity);
+
+
+ HttpResource httpResource = new HttpResource(httpClient, resourceContext, null);
+ assertEquals(HttpServletResponse.SC_MOVED_TEMPORARILY, httpResource.getStatusCode());
+ assertEquals(false, httpResource.hasResponseBody());
+
+ ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
+ Output output = new MockOutput(outputStream);
+ httpResource.render(output);
+
+ assertEquals(HttpServletResponse.SC_MOVED_TEMPORARILY, output.getStatusCode());
+ assertEquals("http://localhost:8080/webassembletool-app-aggregator/redirected.jsp", output.getHeader("Location"));
+
+
+ try{
+ httpResource = new HttpResource(httpClient, resourceContext, null);
+ fail();
+ }catch (IOException e) {
+ assertNotNull(e);
+ assertTrue(e.getMessage().contains(driver.getBaseURL()));
+ }
+
+
+ }
+
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <sbe...@us...> - 2011-02-18 11:50:16
|
Revision: 576
http://webassembletool.svn.sourceforge.net/webassembletool/?rev=576&view=rev
Author: sbernatsky
Date: 2011-02-18 11:50:10 +0000 (Fri, 18 Feb 2011)
Log Message:
-----------
https://sourceforge.net/apps/mantisbt/webassembletool/view.php?id=33: add slf4j -> log4j logging library into end-user runtime
Modified Paths:
--------------
trunk/webassembletool-app-aggregator/pom.xml
trunk/webassembletool-app-casified-aggregator/pom.xml
Added Paths:
-----------
trunk/webassembletool-app-aggregator/src/main/resources/log4j.properties
trunk/webassembletool-app-casified-aggregator/src/main/resources/log4j.properties
Removed Paths:
-------------
trunk/webassembletool-app-aggregator/src/main/resources/commons-logging.properties
trunk/webassembletool-app-aggregator/src/main/resources/simplelog.properties
trunk/webassembletool-app-casified-aggregator/src/main/resources/commons-logging.properties
trunk/webassembletool-app-casified-aggregator/src/main/resources/simplelog.properties
Modified: trunk/webassembletool-app-aggregator/pom.xml
===================================================================
--- trunk/webassembletool-app-aggregator/pom.xml 2011-02-17 16:26:35 UTC (rev 575)
+++ trunk/webassembletool-app-aggregator/pom.xml 2011-02-18 11:50:10 UTC (rev 576)
@@ -34,10 +34,16 @@
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
- <artifactId>slf4j-nop</artifactId>
+ <artifactId>slf4j-log4j12</artifactId>
<version>1.6.1</version>
- <scope>test</scope>
+ <scope>runtime</scope>
</dependency>
+ <dependency>
+ <groupId>log4j</groupId>
+ <artifactId>log4j</artifactId>
+ <version>1.2.16</version>
+ <scope>runtime</scope>
+ </dependency>
<dependency>
<groupId>net.sourceforge.webassembletool</groupId>
<artifactId>webassembletool-core</artifactId>
Deleted: trunk/webassembletool-app-aggregator/src/main/resources/commons-logging.properties
===================================================================
--- trunk/webassembletool-app-aggregator/src/main/resources/commons-logging.properties 2011-02-17 16:26:35 UTC (rev 575)
+++ trunk/webassembletool-app-aggregator/src/main/resources/commons-logging.properties 2011-02-18 11:50:10 UTC (rev 576)
@@ -1 +0,0 @@
-org.apache.commons.logging.Log=org.apache.commons.logging.impl.SimpleLog
\ No newline at end of file
Added: trunk/webassembletool-app-aggregator/src/main/resources/log4j.properties
===================================================================
--- trunk/webassembletool-app-aggregator/src/main/resources/log4j.properties (rev 0)
+++ trunk/webassembletool-app-aggregator/src/main/resources/log4j.properties 2011-02-18 11:50:10 UTC (rev 576)
@@ -0,0 +1,51 @@
+log4j.rootLogger=WARN, A
+
+log4j.appender.A.threshold=TRACE
+log4j.appender.A=org.apache.log4j.ConsoleAppender
+log4j.appender.A.layout=org.apache.log4j.PatternLayout
+log4j.appender.A.layout.ConversionPattern=%d{dd-MM HH:mm:ss} %-8r [%t] %-5p %c %x - %m%n
+
+### file appender A1
+#log4j.appender.A1=org.apache.log4j.DailyRollingFileAppender
+#log4j.appender.A1.DatePattern=.dd-MM-yy
+#log4j.appender.A1.File=/var/log/multitrac/multitrac.log
+#log4j.appender.A1.Append=true
+#log4j.appender.A1.BufferedIO=false
+#log4j.appender.A1.layout=org.apache.log4j.PatternLayout
+#log4j.appender.A1.layout.ConversionPattern=%d{HH:mm:ss} %5p %c{1}: - %m%n
+
+### file appender
+#log4j.category.FixTotalHoursInAllProjectsJob = Debug, FileLoger
+#log4j.appender.FileLoger=org.apache.log4j.FileAppender
+#log4j.appender.FileLoger.maxFileSize=9MB
+#log4j.appender.FileLoger.maxBackupIndex=5
+#log4j.appender.FileLoger.File=/var/log/multitrac/SQLLogger_FixTotalHoursInAllProjectsJob.log
+#log4j.appender.FileLoger.Append=true
+#log4j.appender.FileLoger.BufferedIO=false
+#log4j.appender.FileLoger.threshold=DEBUG
+#log4j.appender.FileLoger.layout=org.apache.log4j.PatternLayout
+#log4j.appender.FileLoger.layout.ConversionPattern=%d{dd-MM HH:mm:ss} : - %m%n
+
+
+log4j.category.com.secondarynet=INFO
+
+log4j.category.httpclient=INFO
+log4j.category.freemarker=INFO
+log4j.category.org.hibernate=WARN
+#log4j.category.org.hibernate=DEBUG
+log4j.category.org.hibernate.SQL=DEBUG
+#log4j.category.org.hibernate.jdbc.AbstractBatcher=DEBUG
+#log4j.category.org.springframework.security=DEBUG
+log4j.category.org.apache.wicket=WARN
+#log4j.category.fr.smile.multitrac.tracing=TRACE
+log4j.category.test.spring=TRACE
+log4j.category.org.apache.solr=WARN
+#log4j.category.org.unitils=TRACE
+#log4j.category.org.hsqldb=TRACE
+#log4j.category.org.dbunit=TRACE
+log4j.category.com.opensymphony=WARN
+log4j.category.org.apache=WARN
+log4j.category.catalia=WARN
+
+#custom categories
+log4j.category.net.webassembletool=ERROR
Property changes on: trunk/webassembletool-app-aggregator/src/main/resources/log4j.properties
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Deleted: trunk/webassembletool-app-aggregator/src/main/resources/simplelog.properties
===================================================================
--- trunk/webassembletool-app-aggregator/src/main/resources/simplelog.properties 2011-02-17 16:26:35 UTC (rev 575)
+++ trunk/webassembletool-app-aggregator/src/main/resources/simplelog.properties 2011-02-18 11:50:10 UTC (rev 576)
@@ -1,2 +0,0 @@
-org.apache.commons.logging.simplelog.defaultlog=error
-org.apache.commons.logging.simplelog.log.net.webassembletool=error
Modified: trunk/webassembletool-app-casified-aggregator/pom.xml
===================================================================
--- trunk/webassembletool-app-casified-aggregator/pom.xml 2011-02-17 16:26:35 UTC (rev 575)
+++ trunk/webassembletool-app-casified-aggregator/pom.xml 2011-02-18 11:50:10 UTC (rev 576)
@@ -64,6 +64,18 @@
<type>war</type>
<scope>provided</scope>
</dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-log4j12</artifactId>
+ <version>1.6.1</version>
+ <scope>runtime</scope>
+ </dependency>
+ <dependency>
+ <groupId>log4j</groupId>
+ <artifactId>log4j</artifactId>
+ <version>1.2.16</version>
+ <scope>runtime</scope>
+ </dependency>
</dependencies>
<build>
<finalName>webassembletool-app-casified-aggregator</finalName>
Deleted: trunk/webassembletool-app-casified-aggregator/src/main/resources/commons-logging.properties
===================================================================
--- trunk/webassembletool-app-casified-aggregator/src/main/resources/commons-logging.properties 2011-02-17 16:26:35 UTC (rev 575)
+++ trunk/webassembletool-app-casified-aggregator/src/main/resources/commons-logging.properties 2011-02-18 11:50:10 UTC (rev 576)
@@ -1 +0,0 @@
-org.apache.commons.logging.Log=org.apache.commons.logging.impl.SimpleLog
\ No newline at end of file
Added: trunk/webassembletool-app-casified-aggregator/src/main/resources/log4j.properties
===================================================================
--- trunk/webassembletool-app-casified-aggregator/src/main/resources/log4j.properties (rev 0)
+++ trunk/webassembletool-app-casified-aggregator/src/main/resources/log4j.properties 2011-02-18 11:50:10 UTC (rev 576)
@@ -0,0 +1,51 @@
+log4j.rootLogger=WARN, A
+
+log4j.appender.A.threshold=TRACE
+log4j.appender.A=org.apache.log4j.ConsoleAppender
+log4j.appender.A.layout=org.apache.log4j.PatternLayout
+log4j.appender.A.layout.ConversionPattern=%d{dd-MM HH:mm:ss} %-8r [%t] %-5p %c %x - %m%n
+
+### file appender A1
+#log4j.appender.A1=org.apache.log4j.DailyRollingFileAppender
+#log4j.appender.A1.DatePattern=.dd-MM-yy
+#log4j.appender.A1.File=/var/log/multitrac/multitrac.log
+#log4j.appender.A1.Append=true
+#log4j.appender.A1.BufferedIO=false
+#log4j.appender.A1.layout=org.apache.log4j.PatternLayout
+#log4j.appender.A1.layout.ConversionPattern=%d{HH:mm:ss} %5p %c{1}: - %m%n
+
+### file appender
+#log4j.category.FixTotalHoursInAllProjectsJob = Debug, FileLoger
+#log4j.appender.FileLoger=org.apache.log4j.FileAppender
+#log4j.appender.FileLoger.maxFileSize=9MB
+#log4j.appender.FileLoger.maxBackupIndex=5
+#log4j.appender.FileLoger.File=/var/log/multitrac/SQLLogger_FixTotalHoursInAllProjectsJob.log
+#log4j.appender.FileLoger.Append=true
+#log4j.appender.FileLoger.BufferedIO=false
+#log4j.appender.FileLoger.threshold=DEBUG
+#log4j.appender.FileLoger.layout=org.apache.log4j.PatternLayout
+#log4j.appender.FileLoger.layout.ConversionPattern=%d{dd-MM HH:mm:ss} : - %m%n
+
+
+log4j.category.com.secondarynet=INFO
+
+log4j.category.httpclient=INFO
+log4j.category.freemarker=INFO
+log4j.category.org.hibernate=WARN
+#log4j.category.org.hibernate=DEBUG
+log4j.category.org.hibernate.SQL=DEBUG
+#log4j.category.org.hibernate.jdbc.AbstractBatcher=DEBUG
+#log4j.category.org.springframework.security=DEBUG
+log4j.category.org.apache.wicket=WARN
+#log4j.category.fr.smile.multitrac.tracing=TRACE
+log4j.category.test.spring=TRACE
+log4j.category.org.apache.solr=WARN
+#log4j.category.org.unitils=TRACE
+#log4j.category.org.hsqldb=TRACE
+#log4j.category.org.dbunit=TRACE
+log4j.category.com.opensymphony=WARN
+log4j.category.org.apache=WARN
+log4j.category.catalia=WARN
+
+#custom categories
+log4j.category.net.webassembletool=ERROR
Property changes on: trunk/webassembletool-app-casified-aggregator/src/main/resources/log4j.properties
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Deleted: trunk/webassembletool-app-casified-aggregator/src/main/resources/simplelog.properties
===================================================================
--- trunk/webassembletool-app-casified-aggregator/src/main/resources/simplelog.properties 2011-02-17 16:26:35 UTC (rev 575)
+++ trunk/webassembletool-app-casified-aggregator/src/main/resources/simplelog.properties 2011-02-18 11:50:10 UTC (rev 576)
@@ -1,2 +0,0 @@
-org.apache.commons.logging.simplelog.defaultlog=error
-org.apache.commons.logging.simplelog.log.net.webassembletool=debug
\ No newline at end of file
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <spa...@us...> - 2011-02-17 16:26:42
|
Revision: 575
http://webassembletool.svn.sourceforge.net/webassembletool/?rev=575&view=rev
Author: spacetoha
Date: 2011-02-17 16:26:35 +0000 (Thu, 17 Feb 2011)
Log Message:
-----------
http://sourceforge.net/apps/mantisbt/webassembletool/view.php?id=21 fixed.
Modified Paths:
--------------
trunk/webassembletool-core/src/main/java/net/webassembletool/util/Rfc2616.java
trunk/webassembletool-core/src/test/java/net/webassembletool/util/Rfc2616Test.java
Modified: trunk/webassembletool-core/src/main/java/net/webassembletool/util/Rfc2616.java
===================================================================
--- trunk/webassembletool-core/src/main/java/net/webassembletool/util/Rfc2616.java 2011-02-17 15:36:39 UTC (rev 574)
+++ trunk/webassembletool-core/src/main/java/net/webassembletool/util/Rfc2616.java 2011-02-17 16:26:35 UTC (rev 575)
@@ -1,6 +1,7 @@
package net.webassembletool.util;
import java.io.IOException;
+import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
@@ -15,10 +16,10 @@
import net.webassembletool.resource.Resource;
import org.apache.commons.lang.StringUtils;
+import org.apache.http.impl.cookie.DateParseException;
+import org.apache.http.impl.cookie.DateUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.apache.http.impl.cookie.DateParseException;
-import org.apache.http.impl.cookie.DateUtils;
/**
* Rfc2616 caching implementation.
@@ -28,400 +29,427 @@
*
*/
public class Rfc2616 {
- private Rfc2616() {
+ private Rfc2616() {
- }
+ }
- private static final int SECONDS = 1000;
- private static final Logger LOG = LoggerFactory.getLogger(Rfc2616.class);
+ private static final int SECONDS = 1000;
+ private static final Logger LOG = LoggerFactory.getLogger(Rfc2616.class);
- private final static class CacheControlResponseHeader {
- private boolean _public = false;
- private boolean _private = false;
- private boolean noCache = false;
- private boolean noStore = false;
- private boolean mustRevalidate = false;
- private boolean proxyRevalidate = false;
- private Long maxAge = null;
- private Long sMaxAge = null;
+ private final static class CacheControlResponseHeader {
+ private boolean _public = false;
+ private boolean _private = false;
+ private boolean noCache = false;
+ private boolean noStore = false;
+ private boolean mustRevalidate = false;
+ private boolean proxyRevalidate = false;
+ private Long maxAge = null;
+ private Long sMaxAge = null;
- private CacheControlResponseHeader() {
- // Nothing to do
- }
+ private CacheControlResponseHeader() {
+ // Nothing to do
+ }
- public final static CacheControlResponseHeader parse(Resource resource) {
- String cacheControlString = resource.getHeader("Cache-control");
- if (cacheControlString == null) {
- return null;
- }
- CacheControlResponseHeader result = new CacheControlResponseHeader();
- String[] split = cacheControlString.split(",");
- for (int i = 0; i < split.length; i++) {
- String[] token = split[i].trim().split("=");
- if (token[0].equalsIgnoreCase("public")) {
- result._public = true;
- } else if (token[0].equalsIgnoreCase("private")) {
- result._private = true;
- } else if (token[0].equalsIgnoreCase("no-cache")) {
- result.noCache = true;
- } else if (token[0].equalsIgnoreCase("no-store")) {
- result.noStore = true;
- } else if (token[0].equalsIgnoreCase("must-revalidate")) {
- result.mustRevalidate = true;
- } else if (token[0].equalsIgnoreCase("proxy-revalidate")) {
- result.proxyRevalidate = true;
- } else if (token[0].equalsIgnoreCase("max-age")) {
- result.maxAge = Long.valueOf(-1);
- if (token.length == 2) {
- try {
- result.maxAge = Long.parseLong(token[1]);
- } catch (NumberFormatException e) {
- // Invalid max-age, assume -1 no cache
- }
- }
- } else if (token[0].equalsIgnoreCase("s-max-age")) {
- result.sMaxAge = Long.valueOf(-1);
- if (token.length == 2) {
- try {
- result.maxAge = Long.parseLong(token[1]);
- } catch (NumberFormatException e) {
- // Invalid max-age, assume -1 no cache
- }
- }
- }
- }
- return result;
- }
+ public final static CacheControlResponseHeader parse(Resource resource) {
+ String cacheControlString = resource.getHeader("Cache-control");
+ if (cacheControlString == null) {
+ return null;
+ }
+ CacheControlResponseHeader result = new CacheControlResponseHeader();
+ String[] split = cacheControlString.split(",");
+ for (int i = 0; i < split.length; i++) {
+ String[] token = split[i].trim().split("=");
+ if (token[0].equalsIgnoreCase("public")) {
+ result._public = true;
+ } else if (token[0].equalsIgnoreCase("private")) {
+ result._private = true;
+ } else if (token[0].equalsIgnoreCase("no-cache")) {
+ result.noCache = true;
+ } else if (token[0].equalsIgnoreCase("no-store")) {
+ result.noStore = true;
+ } else if (token[0].equalsIgnoreCase("must-revalidate")) {
+ result.mustRevalidate = true;
+ } else if (token[0].equalsIgnoreCase("proxy-revalidate")) {
+ result.proxyRevalidate = true;
+ } else if (token[0].equalsIgnoreCase("max-age")) {
+ result.maxAge = Long.valueOf(-1);
+ if (token.length == 2) {
+ try {
+ result.maxAge = Long.parseLong(token[1]);
+ } catch (NumberFormatException e) {
+ // Invalid max-age, assume -1 no cache
+ }
+ }
+ } else if (token[0].equalsIgnoreCase("s-max-age")) {
+ result.sMaxAge = Long.valueOf(-1);
+ if (token.length == 2) {
+ try {
+ result.maxAge = Long.parseLong(token[1]);
+ } catch (NumberFormatException e) {
+ // Invalid max-age, assume -1 no cache
+ }
+ }
+ }
+ }
+ return result;
+ }
- }
+ }
- /**
- * Create a map of all headers and their values which are mentioned in the Vary header of "resource".
- *
- * <p>
- * This method is used to get the headers from an existing cached resource. (Cache side)
- *
- * <p>
- * When doing a new request on this resource, the cached resource can be used if all headers values contained in the
- * returned map are exactly the same than the ones in the new request.
- *
- * @param resource
- * @return
- */
- public final static Map<String, String> getVary(Resource resource) {
- String varyString = resource.getHeader("Vary");
- if (varyString != null) {
- Map<String, String> result = new HashMap<String, String>();
- String[] varyStringSplit = varyString.split(",");
+ /**
+ * Create a map of all headers and their values which are mentioned in the
+ * Vary header of "resource".
+ *
+ * <p>
+ * This method is used to get the headers from an existing cached resource.
+ * (Cache side)
+ *
+ * <p>
+ * When doing a new request on this resource, the cached resource can be
+ * used if all headers values contained in the returned map are exactly the
+ * same than the ones in the new request.
+ *
+ * @param resource
+ * @return
+ */
+ public final static Map<String, String> getVary(Resource resource) {
+ String varyString = resource.getHeader("Vary");
+ if (varyString != null) {
+ Map<String, String> result = new HashMap<String, String>();
+ String[] varyStringSplit = varyString.split(",");
for (String key : varyStringSplit) {
- String value = resource.getRequestHeader(key);
- result.put(key, value);
- }
- return result;
- }
- return null;
- }
+ String value = resource.getRequestHeader(key);
+ result.put(key, value);
+ }
+ return result;
+ }
+ return null;
+ }
- /**
- * Create a map of all headers and their values in resourceContext#getOriginalRequest() which are mentioned in the
- * Vary header of "resource".
- *
- * <p>
- * This method is used to get the headers from a new, upcoming request. (Client side)
- *
- * @param resource
- * @return
- */
- public final static Map<String, String> getVary(ResourceContext resourceContext, Resource resource) {
- HttpServletRequest request = resourceContext.getOriginalRequest();
- String varyString = resource.getHeader("Vary");
- if (varyString != null) {
- Map<String, String> result = new HashMap<String, String>();
- String[] varyStringSplit = varyString.split(",");
- for (int i = 0; i < varyStringSplit.length; i++) {
- String key = varyStringSplit[i];
- String value = request.getHeader(key);
- if (value != null) {
- result.put(key, value);
- }
- }
- return result;
- }
- return null;
- }
+ /**
+ * Create a map of all headers and their values in
+ * resourceContext#getOriginalRequest() which are mentioned in the Vary
+ * header of "resource".
+ *
+ * <p>
+ * This method is used to get the headers from a new, upcoming request.
+ * (Client side)
+ *
+ * @param resource
+ * @return
+ */
+ public final static Map<String, String> getVary(
+ ResourceContext resourceContext, Resource resource) {
+ HttpServletRequest request = resourceContext.getOriginalRequest();
+ String varyString = resource.getHeader("Vary");
+ if (varyString != null) {
+ Map<String, String> result = new HashMap<String, String>();
+ String[] varyStringSplit = varyString.split(",");
+ for (int i = 0; i < varyStringSplit.length; i++) {
+ String key = varyStringSplit[i];
+ String value = request.getHeader(key);
+ if (value != null) {
+ result.put(key, value);
+ }
+ }
+ return result;
+ }
+ return null;
+ }
- /**
- * Ensure that "resourceContext" matches "resource" according to the Vary header of "resource". "resource" is
- * usually a cached resource.
- *
- * @param resourceContext
- * @param resource
- * @return true if resource matches according to "Vary"
- */
- public final static boolean varyMatches(ResourceContext resourceContext, Resource resource) {
- Map<String, String> vary = getVary(resource);
- if (vary == null) {
- return true;
- } else {
- HttpServletRequest request = resourceContext.getOriginalRequest();
- for (Iterator<Entry<String, String>> iterator = vary.entrySet().iterator(); iterator.hasNext();) {
- Entry<String, String> header = iterator.next();
- String key = header.getKey();
- String value = header.getValue();
+ /**
+ * Ensure that "resourceContext" matches "resource" according to the Vary
+ * header of "resource". "resource" is usually a cached resource.
+ *
+ * @param resourceContext
+ * @param resource
+ * @return true if resource matches according to "Vary"
+ */
+ public final static boolean varyMatches(ResourceContext resourceContext,
+ Resource resource) {
+ Map<String, String> vary = getVary(resource);
+ if (vary == null) {
+ return true;
+ } else {
+ HttpServletRequest request = resourceContext.getOriginalRequest();
+ for (Iterator<Entry<String, String>> iterator = vary.entrySet()
+ .iterator(); iterator.hasNext();) {
+ Entry<String, String> header = iterator.next();
+ String key = header.getKey();
+ String value = header.getValue();
- if (!StringUtils.equals(value, request.getHeader(key))) {
- return false;
- }
- }
- return true;
- }
- }
+ if (!StringUtils.equals(value, request.getHeader(key))) {
+ return false;
+ }
+ }
+ return true;
+ }
+ }
- public final static boolean needsValidation(ResourceContext resourceContext, Resource resource) {
- if (resource == null) {
- return true;
- }
- return requiresRefresh(resourceContext) || isStale(resource);
- }
+ public final static boolean needsValidation(
+ ResourceContext resourceContext, Resource resource) {
+ if (resource == null) {
+ return true;
+ }
+ return requiresRefresh(resourceContext) || isStale(resource);
+ }
- public final static boolean isStale(Resource resource) {
- Date date = getDate(resource);
- Date expiration = getHeuristicExpiration(resource);
- if (date == null || expiration == null) {
- return true;
- }
- Date nowOnOriginServer = new Date(getAge(resource) + date.getTime());
- return (nowOnOriginServer.after(expiration));
- }
+ public final static boolean isStale(Resource resource) {
+ Date date = getDate(resource);
+ Date expiration = getHeuristicExpiration(resource);
+ if (date == null || expiration == null) {
+ return true;
+ }
+ Date nowOnOriginServer = new Date(getAge(resource) + date.getTime());
+ return (nowOnOriginServer.after(expiration));
+ }
- /**
- * Get ETag from a resource.
- *
- * @param resource
- * Resource (not null)
- * @return etag or null
- */
- public final static String getEtag(Resource resource) {
- return resource.getHeader("Etag");
- }
+ /**
+ * Get ETag from a resource.
+ *
+ * @param resource
+ * Resource (not null)
+ * @return etag or null
+ */
+ public final static String getEtag(Resource resource) {
+ return resource.getHeader("Etag");
+ }
- public final static boolean etagMatches(ResourceContext resourceContext, Resource resource) {
- String etag = getEtag(resource);
- if (etag == null) {
- return true;
- }
- HttpServletRequest request = resourceContext.getOriginalRequest();
- String ifNoneMatch = request.getHeader("If-none-match");
- if (ifNoneMatch == null) {
- return true;
- }
- String[] ifNoneMatchSplit = ifNoneMatch.split(",");
- for (int i = 0; i < ifNoneMatchSplit.length; i++) {
- if (ifNoneMatchSplit[i].equals(etag)) {
- return true;
- }
- }
- return false;
- }
+ public final static boolean etagMatches(ResourceContext resourceContext,
+ Resource resource) {
+ String etag = getEtag(resource);
+ if (etag == null) {
+ return true;
+ }
+ HttpServletRequest request = resourceContext.getOriginalRequest();
+ String ifNoneMatch = request.getHeader("If-none-match");
+ if (ifNoneMatch == null) {
+ return true;
+ }
+ String[] ifNoneMatchSplit = ifNoneMatch.split(",");
+ for (int i = 0; i < ifNoneMatchSplit.length; i++) {
+ if (ifNoneMatchSplit[i].equals(etag)) {
+ return true;
+ }
+ }
+ return false;
+ }
- public final static Date getExpiration(Resource resource) {
- Date date = getDate(resource);
- if (date == null) {
- LOG.warn("No Date header, cannot calculate expiration.");
- return null;
- }
- Long maxAge = null;
- CacheControlResponseHeader cacheControl = CacheControlResponseHeader.parse(resource);
- if (cacheControl != null) {
- if (cacheControl.maxAge != null) {
- maxAge = cacheControl.maxAge;
- }
- if (cacheControl.sMaxAge != null) {
- maxAge = cacheControl.sMaxAge;
- }
- }
- if (maxAge != null) {
- // maxAge directive found according to HTTP/1.1
- // Age is in seconds. See
- // https://sourceforge.net/apps/mantisbt/webassembletool/view.php?id=17
- return new Date(date.getTime() + maxAge.longValue() * SECONDS);
+ public final static Date getExpiration(Resource resource) {
+ Date date = getDate(resource);
+ Long maxAge = null;
+ CacheControlResponseHeader cacheControl = CacheControlResponseHeader
+ .parse(resource);
+ if (cacheControl != null) {
+ if (cacheControl.maxAge != null) {
+ maxAge = cacheControl.maxAge;
+ }
+ if (cacheControl.sMaxAge != null) {
+ maxAge = cacheControl.sMaxAge;
+ }
+ }
+ if (maxAge != null) {
+ // maxAge directive found according to HTTP/1.1
+ // Age is in seconds. See
+ // https://sourceforge.net/apps/mantisbt/webassembletool/view.php?id=17
+ return new Date(date.getTime() + maxAge.longValue() * SECONDS);
- }
- Date expires = getDateHeader(resource, "Expires");
- if (expires != null) {
- return expires;
- }
- return null;
- }
+ }
+ Date expires = getDateHeader(resource, "Expires");
+ if (expires != null) {
+ return expires;
+ }
+ return null;
+ }
- public final static Date getDate(Resource resource) {
- return getDateHeader(resource, "Date");
- }
+ public final static Date getDate(Resource resource) {
+ // Fixed according to
+ // http://sourceforge.net/apps/mantisbt/webassembletool/view.php?id=21
+ Date date = getDateHeader(resource, "Date");
+ if (date == null) {
+ date = Calendar.getInstance().getTime();
+ }
+ return date;
+ }
- public final static Date getHeuristicExpiration(Resource resource) {
- Date expiration = getExpiration(resource);
- if (expiration != null) {
- return expiration;
- }
- Date date = getDate(resource);
- if (date == null) {
- return null;
- }
- Date lastModified = getDateHeader(resource, "Last-modified");
- // If the response does have a Last-Modified time, the heuristic
- // expiration value SHOULD be no more than some fraction of the interval
- // since that time. A typical setting of this fraction might be 10%.
- if (lastModified != null) {
- return new Date(date.getTime() + (date.getTime() - lastModified.getTime()) / 10);
- }
- return null;
- }
+ public final static Date getHeuristicExpiration(Resource resource) {
+ Date expiration = getExpiration(resource);
+ if (expiration != null) {
+ return expiration;
+ }
+ Date date = getDate(resource);
+ if (date == null) {
+ return null;
+ }
+ Date lastModified = getDateHeader(resource, "Last-modified");
+ // If the response does have a Last-Modified time, the heuristic
+ // expiration value SHOULD be no more than some fraction of the interval
+ // since that time. A typical setting of this fraction might be 10%.
+ if (lastModified != null) {
+ return new Date(date.getTime()
+ + (date.getTime() - lastModified.getTime()) / 10);
+ }
+ return null;
+ }
- public final static long getAge(Resource resource) {
+ public final static long getAge(Resource resource) {
return System.currentTimeMillis() - resource.getLocalDate().getTime();
- }
+ }
- public final static boolean isCacheable(Resource resource) {
- CacheControlResponseHeader cacheControl = CacheControlResponseHeader.parse(resource);
- if (cacheControl == null) {
- // Check expire header, if not a valid date, assume no cache
- if (resource.getHeader("Expires") != null && getDateHeader(resource, "Expires") == null) {
- return false;
- }
- }
- if (cacheControl._public) {
- return true;
- }
- if (cacheControl._private || cacheControl.noCache || cacheControl.noStore || cacheControl.mustRevalidate
- || cacheControl.proxyRevalidate || cacheControl.maxAge <= 0) {
- return false;
- }
- return true;
- }
+ public final static boolean isCacheable(Resource resource) {
+ CacheControlResponseHeader cacheControl = CacheControlResponseHeader
+ .parse(resource);
+ if (cacheControl == null) {
+ // Check expire header, if not a valid date, assume no cache
+ if (resource.getHeader("Expires") != null
+ && getDateHeader(resource, "Expires") == null) {
+ return false;
+ }
+ }
+ if (cacheControl._public) {
+ return true;
+ }
+ if (cacheControl._private || cacheControl.noCache
+ || cacheControl.noStore || cacheControl.mustRevalidate
+ || cacheControl.proxyRevalidate || cacheControl.maxAge <= 0) {
+ return false;
+ }
+ return true;
+ }
- /**
- * A Resource is cacheable if the HTTP method is GET or HEAD according to HTTP specification. Additionnaly, if we
- * are not in proxy mode, the driver will send a GET method as we are not proxying the original request but only
- * including an element. In that case, the response is cacheable.
- *
- * @param context
- * @return true if the resource is cacheable
- */
- public final static boolean isCacheable(ResourceContext context) {
- String method = context.getOriginalRequest().getMethod();
- return !context.isProxy() || "GET".equalsIgnoreCase(method) || "HEAD".equalsIgnoreCase(method);
- }
+ /**
+ * A Resource is cacheable if the HTTP method is GET or HEAD according to
+ * HTTP specification. Additionnaly, if we are not in proxy mode, the driver
+ * will send a GET method as we are not proxying the original request but
+ * only including an element. In that case, the response is cacheable.
+ *
+ * @param context
+ * @return true if the resource is cacheable
+ */
+ public final static boolean isCacheable(ResourceContext context) {
+ String method = context.getOriginalRequest().getMethod();
+ return !context.isProxy() || "GET".equalsIgnoreCase(method)
+ || "HEAD".equalsIgnoreCase(method);
+ }
- public final static boolean matches(ResourceContext resourceContext, Resource cachedResponse) {
- String method = resourceContext.getOriginalRequest().getMethod();
+ public final static boolean matches(ResourceContext resourceContext,
+ Resource cachedResponse) {
+ String method = resourceContext.getOriginalRequest().getMethod();
- if (!"HEAD".equalsIgnoreCase(method) && !cachedResponse.hasResponseBody()) {
- return false;
- }
- if (!etagMatches(resourceContext, cachedResponse)) {
- return false;
- }
- if (!varyMatches(resourceContext, cachedResponse)) {
- return false;
- }
- return true;
- }
+ if (!"HEAD".equalsIgnoreCase(method)
+ && !cachedResponse.hasResponseBody()) {
+ return false;
+ }
+ if (!etagMatches(resourceContext, cachedResponse)) {
+ return false;
+ }
+ if (!varyMatches(resourceContext, cachedResponse)) {
+ return false;
+ }
+ return true;
+ }
- public final static Date getDateHeader(Resource resource, String name) {
- String dateString = resource.getHeader(name);
- return convertDate(dateString);
- }
+ public final static Date getDateHeader(Resource resource, String name) {
+ String dateString = resource.getHeader(name);
+ return convertDate(dateString);
+ }
- public final static Date getDateHeader(ResourceContext resourceContext, String name) {
- String dateString = resourceContext.getOriginalRequest().getHeader(name);
- return convertDate(dateString);
- }
+ public final static Date getDateHeader(ResourceContext resourceContext,
+ String name) {
+ String dateString = resourceContext.getOriginalRequest()
+ .getHeader(name);
+ return convertDate(dateString);
+ }
- private final static Date convertDate(String dateString) {
- if (dateString != null) {
- try {
- return DateUtils.parseDate(dateString);
- } catch (DateParseException e) {
- // Ignore invalid date
- LOG.warn("Invalid date format: " + dateString);
- }
- }
- return null;
- }
+ private final static Date convertDate(String dateString) {
+ if (dateString != null) {
+ try {
+ return DateUtils.parseDate(dateString);
+ } catch (DateParseException e) {
+ // Ignore invalid date
+ LOG.warn("Invalid date format: " + dateString);
+ }
+ }
+ return null;
+ }
- public final static boolean requiresRefresh(ResourceContext context) {
- HttpServletRequest originalRequest = context.getOriginalRequest();
- String pragma = originalRequest.getHeader("Pragma");
- if ("no-cache".equalsIgnoreCase(pragma)) {
- return true;
- }
- String cacheControl = originalRequest.getHeader("Cache-control");
- if (cacheControl != null) {
- cacheControl = cacheControl.toLowerCase();
- if (cacheControl.contains("no-cache") || cacheControl.contains("no-store")
- || cacheControl.contains("must-revalidate") || cacheControl.contains("max-age=0")) {
- return true;
- }
- }
- return false;
- }
+ public final static boolean requiresRefresh(ResourceContext context) {
+ HttpServletRequest originalRequest = context.getOriginalRequest();
+ String pragma = originalRequest.getHeader("Pragma");
+ if ("no-cache".equalsIgnoreCase(pragma)) {
+ return true;
+ }
+ String cacheControl = originalRequest.getHeader("Cache-control");
+ if (cacheControl != null) {
+ cacheControl = cacheControl.toLowerCase();
+ if (cacheControl.contains("no-cache")
+ || cacheControl.contains("no-store")
+ || cacheControl.contains("must-revalidate")
+ || cacheControl.contains("max-age=0")) {
+ return true;
+ }
+ }
+ return false;
+ }
- public final static void renderResource(Resource resource, Output output) throws IOException {
- if (HttpServletResponse.SC_NOT_MODIFIED == resource.getStatusCode()) {
- output.setStatusCode(resource.getStatusCode());
- copyHeaders(resource, output);
- output.open();
- output.getOutputStream();
- // No response body
- output.close();
- } else {
- resource.render(output);
- }
- }
+ public final static void renderResource(Resource resource, Output output)
+ throws IOException {
+ if (HttpServletResponse.SC_NOT_MODIFIED == resource.getStatusCode()) {
+ output.setStatusCode(resource.getStatusCode());
+ copyHeaders(resource, output);
+ output.open();
+ output.getOutputStream();
+ // No response body
+ output.close();
+ } else {
+ resource.render(output);
+ }
+ }
- /**
- * Copies end-to-end headers from a resource to an output
- */
- public final static void copyHeaders(Resource resource, Output output) {
- copyHeader(resource, output, "Date");
- copyHeader(resource, output, "Content-Type");
- // Do not copy Content-encoding
- // Do not copy Content-length header for gzipped streams as it will
- // change ! OK this is not compliant with RFC 2616 but we need to do
- // that as we often have to modify the content of the response
- if (resource.getHeader("Content-encoding") == null) {
- copyHeader(resource, output, "Content-Length");
- }
- copyHeader(resource, output, "Last-Modified");
- copyHeader(resource, output, "ETag");
- copyHeader(resource, output, "Expires");
- copyHeader(resource, output, "Cache-control");
- // FIXME: We have to copy all headers except those that the RFC says not
- // to. For now, we just add a missing (and important) header
- // See :
- // https://sourceforge.net/apps/mantisbt/webassembletool/view.php?id=15
- copyHeader(resource, output, "Content-Disposition");
+ /**
+ * Copies end-to-end headers from a resource to an output
+ */
+ public final static void copyHeaders(Resource resource, Output output) {
+ copyHeader(resource, output, "Date");
+ copyHeader(resource, output, "Content-Type");
+ // Do not copy Content-encoding
+ // Do not copy Content-length header for gzipped streams as it will
+ // change ! OK this is not compliant with RFC 2616 but we need to do
+ // that as we often have to modify the content of the response
+ if (resource.getHeader("Content-encoding") == null) {
+ copyHeader(resource, output, "Content-Length");
+ }
+ copyHeader(resource, output, "Last-Modified");
+ copyHeader(resource, output, "ETag");
+ copyHeader(resource, output, "Expires");
+ copyHeader(resource, output, "Cache-control");
+ // FIXME: We have to copy all headers except those that the RFC says not
+ // to. For now, we just add a missing (and important) header
+ // See :
+ // https://sourceforge.net/apps/mantisbt/webassembletool/view.php?id=15
+ copyHeader(resource, output, "Content-Disposition");
- // See
- // https://sourceforge.net/apps/mantisbt/webassembletool/view.php?id=18
- copyHeader(resource, output, "Vary");
- }
+ // See
+ // https://sourceforge.net/apps/mantisbt/webassembletool/view.php?id=18
+ copyHeader(resource, output, "Vary");
+ }
- /**
- * Copy header "name" from "resource" to "output".
- *
- * @param resource
- * source Resource
- * @param output
- * target Output
- * @param name
- * name of the header
- */
- private final static void copyHeader(Resource resource, Output output, String name) {
- String value = resource.getHeader(name);
- if (value != null) {
- output.setHeader(name, value);
- }
- }
+ /**
+ * Copy header "name" from "resource" to "output".
+ *
+ * @param resource
+ * source Resource
+ * @param output
+ * target Output
+ * @param name
+ * name of the header
+ */
+ private final static void copyHeader(Resource resource, Output output,
+ String name) {
+ String value = resource.getHeader(name);
+ if (value != null) {
+ output.setHeader(name, value);
+ }
+ }
}
Modified: trunk/webassembletool-core/src/test/java/net/webassembletool/util/Rfc2616Test.java
===================================================================
--- trunk/webassembletool-core/src/test/java/net/webassembletool/util/Rfc2616Test.java 2011-02-17 15:36:39 UTC (rev 574)
+++ trunk/webassembletool-core/src/test/java/net/webassembletool/util/Rfc2616Test.java 2011-02-17 16:26:35 UTC (rev 575)
@@ -8,6 +8,7 @@
import net.webassembletool.resource.Resource;
import org.apache.http.impl.cookie.DateUtils;
+import org.junit.Assert;
/**
* Tests for RFC2616 handling.
@@ -17,51 +18,84 @@
*/
public class Rfc2616Test extends TestCase {
- /**
- * Ensure max-date is correctly used (in seconds). See
- * https://sourceforge.net/apps/mantisbt/webassembletool/view.php?id=17
- */
- public void test_getExpiration() {
+ /**
+ * Ensure max-date is correctly used (in seconds). See
+ * https://sourceforge.net/apps/mantisbt/webassembletool/view.php?id=17
+ */
+ public void test_getExpiration() {
- final Date now = new Date();
+ final Date now = new Date();
- Resource r = new Resource() {
+ Resource r = new Resource() {
- @Override
- public void render(Output output) throws IOException {
- }
+ @Override
+ public void render(Output output) throws IOException {
+ }
- @Override
- public void release() {
- }
+ @Override
+ public void release() {
+ }
- @Override
- public int getStatusCode() {
- return 200;
- }
+ @Override
+ public int getStatusCode() {
+ return 200;
+ }
- @Override
- public String getHeader(String name) {
- if (name.equals("Cache-control")) {
- return "max-age=60";
- }
+ @Override
+ public String getHeader(String name) {
+ if (name.equals("Cache-control")) {
+ return "max-age=60";
+ }
- if (name.equals("Date")) {
- return DateUtils.formatDate(now);
- }
+ if (name.equals("Date")) {
+ return DateUtils.formatDate(now);
+ }
- return null;
- }
+ return null;
+ }
- };
+ };
- Date d = Rfc2616.getExpiration(r);
- assertTrue(d.after(now));
+ Date d = Rfc2616.getExpiration(r);
+ assertTrue(d.after(now));
- // Distance will not be exactly 60000.
- long distance = (d.getTime() - now.getTime());
- assertTrue(distance > 59000 && distance < 61000);
+ // Distance will not be exactly 60000.
+ long distance = (d.getTime() - now.getTime());
+ assertTrue(distance > 59000 && distance < 61000);
- }
+ }
+ public void test_getDate() {
+
+ Resource resourceWithoutDate = new Resource() {
+
+ @Override
+ public void render(Output output) throws IOException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void release() {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public int getStatusCode() {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ @Override
+ public String getHeader(String name) {
+
+ return null;
+ }
+ };
+
+ Date date = Rfc2616.getDate(resourceWithoutDate);
+ Assert.assertNotNull(date);
+ }
+
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <sbe...@us...> - 2011-02-17 15:36:46
|
Revision: 574
http://webassembletool.svn.sourceforge.net/webassembletool/?rev=574&view=rev
Author: sbernatsky
Date: 2011-02-17 15:36:39 +0000 (Thu, 17 Feb 2011)
Log Message:
-----------
#33: move to slf4j from commons-logging
Modified Paths:
--------------
trunk/webassembletool-app-aggregator/pom.xml
trunk/webassembletool-app-aggregator/src/test/java/net/webassembletool/test/cases/PerformanceTestCase.java
trunk/webassembletool-cas/src/main/java/net/webassembletool/cas/CasAuthenticationHandler.java
trunk/webassembletool-core/pom.xml
trunk/webassembletool-core/src/main/java/net/webassembletool/Driver.java
trunk/webassembletool-core/src/main/java/net/webassembletool/DriverFactory.java
trunk/webassembletool-core/src/main/java/net/webassembletool/ProxyServlet.java
trunk/webassembletool-core/src/main/java/net/webassembletool/RewriteProxyServlet.java
trunk/webassembletool-core/src/main/java/net/webassembletool/aggregator/AggregatorServlet.java
trunk/webassembletool-core/src/main/java/net/webassembletool/authentication/RequestAuthenticationHandler.java
trunk/webassembletool-core/src/main/java/net/webassembletool/cache/Cache.java
trunk/webassembletool-core/src/main/java/net/webassembletool/cache/CacheEntry.java
trunk/webassembletool-core/src/main/java/net/webassembletool/cookie/FilteringCookieStore.java
trunk/webassembletool-core/src/main/java/net/webassembletool/extension/ExtensionFactory.java
trunk/webassembletool-core/src/main/java/net/webassembletool/filter/CookieForwardingFilter.java
trunk/webassembletool-core/src/main/java/net/webassembletool/http/HttpClientRequest.java
trunk/webassembletool-core/src/main/java/net/webassembletool/http/HttpClientResponse.java
trunk/webassembletool-core/src/main/java/net/webassembletool/http/HttpResource.java
trunk/webassembletool-core/src/main/java/net/webassembletool/resource/ResourceUtils.java
trunk/webassembletool-core/src/main/java/net/webassembletool/tags/BlockRenderer.java
trunk/webassembletool-core/src/main/java/net/webassembletool/tags/TemplateRenderer.java
trunk/webassembletool-core/src/main/java/net/webassembletool/util/Rfc2616.java
trunk/webassembletool-core/src/main/java/net/webassembletool/vars/VariablesResolver.java
trunk/webassembletool-taglib/src/main/java/net/webassembletool/taglib/DefaultErrorTag.java
trunk/webassembletool-taglib/src/main/java/net/webassembletool/taglib/ErrorDefinitionTag.java
trunk/webassembletool-taglib/src/main/java/net/webassembletool/taglib/ParameterTag.java
trunk/webassembletool-taglib/src/main/java/net/webassembletool/taglib/ReplaceTag.java
trunk/webassembletool-wicket/pom.xml
trunk/webassembletool-wicket/src/main/java/net/webassembletool/wicket/container/AbstractWatDriverContainer.java
trunk/webassembletool-wicket/src/main/java/net/webassembletool/wicket/container/WATBlock.java
trunk/webassembletool-wicket/src/main/java/net/webassembletool/wicket/container/WATTemplate.java
trunk/webassembletool-wicket/src/main/java/net/webassembletool/wicket/utils/WATBufferedResponse.java
Modified: trunk/webassembletool-app-aggregator/pom.xml
===================================================================
--- trunk/webassembletool-app-aggregator/pom.xml 2011-02-16 13:44:55 UTC (rev 573)
+++ trunk/webassembletool-app-aggregator/pom.xml 2011-02-17 15:36:39 UTC (rev 574)
@@ -32,6 +32,12 @@
<type>jar</type>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-nop</artifactId>
+ <version>1.6.1</version>
+ <scope>test</scope>
+ </dependency>
<dependency>
<groupId>net.sourceforge.webassembletool</groupId>
<artifactId>webassembletool-core</artifactId>
Modified: trunk/webassembletool-app-aggregator/src/test/java/net/webassembletool/test/cases/PerformanceTestCase.java
===================================================================
--- trunk/webassembletool-app-aggregator/src/test/java/net/webassembletool/test/cases/PerformanceTestCase.java 2011-02-16 13:44:55 UTC (rev 573)
+++ trunk/webassembletool-app-aggregator/src/test/java/net/webassembletool/test/cases/PerformanceTestCase.java 2011-02-17 15:36:39 UTC (rev 574)
@@ -9,8 +9,8 @@
import junit.framework.TestCase;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import com.meterware.httpunit.GetMethodWebRequest;
import com.meterware.httpunit.WebConversation;
@@ -52,7 +52,7 @@
private final static String AGGREGATOR = "http://localhost:8080/webassembletool-app-aggregator/";
private final static String AGGREGATOR_NO_CACHE = "http://localhost:8080/webassembletool-app-aggregator/nocache/ag1/";
- private static final Log LOG = LogFactory.getLog(PerformanceTestCase.class);
+ private static final Logger LOG = LoggerFactory.getLogger(PerformanceTestCase.class);
/**
* Execute a get request
Modified: trunk/webassembletool-cas/src/main/java/net/webassembletool/cas/CasAuthenticationHandler.java
===================================================================
--- trunk/webassembletool-cas/src/main/java/net/webassembletool/cas/CasAuthenticationHandler.java 2011-02-16 13:44:55 UTC (rev 573)
+++ trunk/webassembletool-cas/src/main/java/net/webassembletool/cas/CasAuthenticationHandler.java 2011-02-17 15:36:39 UTC (rev 574)
@@ -13,26 +13,22 @@
import net.webassembletool.http.HttpClientRequest;
import net.webassembletool.http.HttpClientResponse;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
import org.jasig.cas.client.authentication.AttributePrincipal;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
public class CasAuthenticationHandler implements AuthenticationHandler {
- private final static Log LOG = LogFactory
- .getLog(AuthenticationHandler.class);
+ private final static Logger LOG = LoggerFactory.getLogger(AuthenticationHandler.class);
private final static String SECOND_REQUEST = "SECOND_REQUEST";
private String loginUrl = "/login";
- private String addCasAuthentication(String location,
- ResourceContext requestContext) {
- Principal principal = requestContext.getOriginalRequest()
- .getUserPrincipal();
+ private String addCasAuthentication(String location, ResourceContext requestContext) {
+ Principal principal = requestContext.getOriginalRequest().getUserPrincipal();
if (principal != null && principal instanceof AttributePrincipal) {
AttributePrincipal casPrincipal = (AttributePrincipal) principal;
LOG.debug("User logged in CAS as: " + casPrincipal.getName());
String casProxyTicket = casPrincipal.getProxyTicketFor(location);
- LOG.debug("Proxy ticket retrieved: " + casPrincipal.getName()
- + " for service: " + location + " : " + casProxyTicket);
+ LOG.debug("Proxy ticket retrieved: " + casPrincipal.getName() + " for service: " + location + " : " + casProxyTicket);
if (casProxyTicket != null) {
if (location.indexOf("?") > 0) {
return location + "&ticket=" + casProxyTicket;
@@ -55,10 +51,8 @@
}
}
- public boolean needsNewRequest(HttpClientResponse httpClientResponse,
- ResourceContext requestContext) {
- HttpServletRequest httpServletRequest = requestContext
- .getOriginalRequest();
+ public boolean needsNewRequest(HttpClientResponse httpClientResponse, ResourceContext requestContext) {
+ HttpServletRequest httpServletRequest = requestContext.getOriginalRequest();
if (httpServletRequest.getAttribute(SECOND_REQUEST) != null) {
// Calculating the URL we may have been redirected to, as
// automatic redirect following is activated
@@ -66,10 +60,8 @@
if (currentLocation != null && currentLocation.contains(loginUrl)) {
// If the user is authenticated we need a second request with
// the proxy ticket
- Principal principal = requestContext.getOriginalRequest()
- .getUserPrincipal();
- if (principal != null
- && principal instanceof AttributePrincipal) {
+ Principal principal = requestContext.getOriginalRequest().getUserPrincipal();
+ if (principal != null && principal instanceof AttributePrincipal) {
return true;
}
}
@@ -77,19 +69,15 @@
return false;
}
- public void preRequest(HttpClientRequest request,
- ResourceContext requestContext) {
- HttpServletRequest httpServletRequest = requestContext
- .getOriginalRequest();
+ public void preRequest(HttpClientRequest request, ResourceContext requestContext) {
+ HttpServletRequest httpServletRequest = requestContext.getOriginalRequest();
if (httpServletRequest.getAttribute(SECOND_REQUEST) != null) {
- request.setUri(addCasAuthentication(request.getUri(),
- requestContext));
+ request.setUri(addCasAuthentication(request.getUri(), requestContext));
}
httpServletRequest.setAttribute(SECOND_REQUEST, true);
}
- public void render(ResourceContext requestContext, String src, Writer out)
- throws IOException, HttpErrorPage {
+ public void render(ResourceContext requestContext, String src, Writer out) throws IOException, HttpErrorPage {
// Just copy src to out
out.write(src);
}
Modified: trunk/webassembletool-core/pom.xml
===================================================================
--- trunk/webassembletool-core/pom.xml 2011-02-16 13:44:55 UTC (rev 573)
+++ trunk/webassembletool-core/pom.xml 2011-02-17 15:36:39 UTC (rev 574)
@@ -19,16 +19,17 @@
<scope>provided</scope>
</dependency>
<dependency>
- <groupId>commons-logging</groupId>
- <artifactId>commons-logging</artifactId>
- <version>1.1.1</version>
- </dependency>
- <dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.0.1</version>
<type>jar</type>
<scope>compile</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ </exclusion>
+ </exclusions>
</dependency>
<dependency>
<groupId>opensymphony</groupId>
@@ -43,6 +44,10 @@
<artifactId>servlet-api</artifactId>
<groupId>javax.servlet</groupId>
</exclusion>
+ <exclusion>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ </exclusion>
</exclusions>
</dependency>
<dependency>
@@ -90,5 +95,21 @@
<type>jar</type>
<scope>compile</scope>
</dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ <version>1.6.1</version>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>jcl-over-slf4j</artifactId>
+ <version>1.6.1</version>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-nop</artifactId>
+ <version>1.6.1</version>
+ <scope>test</scope>
+ </dependency>
</dependencies>
</project>
\ No newline at end of file
Modified: trunk/webassembletool-core/src/main/java/net/webassembletool/Driver.java
===================================================================
--- trunk/webassembletool-core/src/main/java/net/webassembletool/Driver.java 2011-02-16 13:44:55 UTC (rev 573)
+++ trunk/webassembletool-core/src/main/java/net/webassembletool/Driver.java 2011-02-17 15:36:39 UTC (rev 574)
@@ -53,8 +53,8 @@
import net.webassembletool.xml.XpathRenderer;
import net.webassembletool.xml.XsltRenderer;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.apache.http.HttpHost;
import org.apache.http.client.HttpClient;
import org.apache.http.client.params.ClientPNames;
@@ -81,7 +81,7 @@
* @contributor Nicolas Richeton
*/
public class Driver {
- private static final Log LOG = LogFactory.getLog(Driver.class);
+ private static final Logger LOG = LoggerFactory.getLogger(Driver.class);
private final DriverConfiguration config;
private final Cache cache;
private final HttpClient httpClient;
Modified: trunk/webassembletool-core/src/main/java/net/webassembletool/DriverFactory.java
===================================================================
--- trunk/webassembletool-core/src/main/java/net/webassembletool/DriverFactory.java 2011-02-16 13:44:55 UTC (rev 573)
+++ trunk/webassembletool-core/src/main/java/net/webassembletool/DriverFactory.java 2011-02-17 15:36:39 UTC (rev 574)
@@ -8,8 +8,8 @@
import java.util.Map.Entry;
import java.util.Properties;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* Factory class used to configure and retrieve {@linkplain Driver} INSTANCIES.
@@ -17,7 +17,7 @@
* @author Stanislav Bernatskyi
*/
public class DriverFactory {
- private static final Log LOG = LogFactory.getLog(DriverFactory.class);
+ private static final Logger LOG = LoggerFactory.getLogger(DriverFactory.class);
private static final String DEFAULT_INSTANCE = "default";
private static final Map<String, Driver> INSTANCIES = new HashMap<String, Driver>();
Modified: trunk/webassembletool-core/src/main/java/net/webassembletool/ProxyServlet.java
===================================================================
--- trunk/webassembletool-core/src/main/java/net/webassembletool/ProxyServlet.java 2011-02-16 13:44:55 UTC (rev 573)
+++ trunk/webassembletool-core/src/main/java/net/webassembletool/ProxyServlet.java 2011-02-17 15:36:39 UTC (rev 574)
@@ -8,8 +8,8 @@
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* Servlet used to proxy requests from a remote application.
@@ -18,7 +18,7 @@
*/
public class ProxyServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
- private static final Log LOG = LogFactory.getLog(ProxyServlet.class);
+ private static final Logger LOG = LoggerFactory.getLogger(ProxyServlet.class);
private String provider;
@Override
Modified: trunk/webassembletool-core/src/main/java/net/webassembletool/RewriteProxyServlet.java
===================================================================
--- trunk/webassembletool-core/src/main/java/net/webassembletool/RewriteProxyServlet.java 2011-02-16 13:44:55 UTC (rev 573)
+++ trunk/webassembletool-core/src/main/java/net/webassembletool/RewriteProxyServlet.java 2011-02-17 15:36:39 UTC (rev 574)
@@ -16,8 +16,8 @@
import javax.servlet.http.HttpServletRequestWrapper;
import javax.servlet.http.HttpServletResponse;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* Reverse Proxy servlet with rewrite abilities. It will usually be mapped on *
@@ -197,7 +197,7 @@
}
- private static Log logger = LogFactory.getLog(RewriteProxyServlet.class);
+ private static Logger logger = LoggerFactory.getLogger(RewriteProxyServlet.class);
private static final long serialVersionUID = 8479657871058986339L;
Modified: trunk/webassembletool-core/src/main/java/net/webassembletool/aggregator/AggregatorServlet.java
===================================================================
--- trunk/webassembletool-core/src/main/java/net/webassembletool/aggregator/AggregatorServlet.java 2011-02-16 13:44:55 UTC (rev 573)
+++ trunk/webassembletool-core/src/main/java/net/webassembletool/aggregator/AggregatorServlet.java 2011-02-17 15:36:39 UTC (rev 574)
@@ -12,8 +12,8 @@
import net.webassembletool.HttpErrorPage;
import net.webassembletool.esi.EsiRenderer;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* Servlet used to proxy requests from a remote application.
@@ -22,7 +22,7 @@
*/
public class AggregatorServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
- private static final Log LOG = LogFactory.getLog(AggregatorServlet.class);
+ private static final Logger LOG = LoggerFactory.getLogger(AggregatorServlet.class);
private String provider;
@Override
Modified: trunk/webassembletool-core/src/main/java/net/webassembletool/authentication/RequestAuthenticationHandler.java
===================================================================
--- trunk/webassembletool-core/src/main/java/net/webassembletool/authentication/RequestAuthenticationHandler.java 2011-02-16 13:44:55 UTC (rev 573)
+++ trunk/webassembletool-core/src/main/java/net/webassembletool/authentication/RequestAuthenticationHandler.java 2011-02-17 15:36:39 UTC (rev 574)
@@ -26,8 +26,8 @@
import net.webassembletool.http.HttpClientRequest;
import net.webassembletool.http.HttpClientResponse;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* Forward session and/or request attributes as request headers.
@@ -36,8 +36,7 @@
*/
public class RequestAuthenticationHandler implements AuthenticationHandler {
private String headerPrefix = "X-ATTR-";
- private static Log logger = LogFactory
- .getLog(RequestAuthenticationHandler.class);
+ private static Logger logger = LoggerFactory.getLogger(RequestAuthenticationHandler.class);
private final ArrayList<String> sessionAttributes = new ArrayList<String>();
private final ArrayList<String> requestAttributes = new ArrayList<String>();
Modified: trunk/webassembletool-core/src/main/java/net/webassembletool/cache/Cache.java
===================================================================
--- trunk/webassembletool-core/src/main/java/net/webassembletool/cache/Cache.java 2011-02-16 13:44:55 UTC (rev 573)
+++ trunk/webassembletool-core/src/main/java/net/webassembletool/cache/Cache.java 2011-02-17 15:36:39 UTC (rev 574)
@@ -8,8 +8,8 @@
import net.webassembletool.resource.Resource;
import net.webassembletool.resource.ResourceUtils;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* Represents a local interface to caching system.
@@ -19,7 +19,7 @@
* @author Francois-Xavier Bonnet
*/
public class Cache {
- private static Log LOG = LogFactory.getLog(Cache.class);
+ private static Logger LOG = LoggerFactory.getLogger(Cache.class);
private final Storage storage;
public Cache() {
Modified: trunk/webassembletool-core/src/main/java/net/webassembletool/cache/CacheEntry.java
===================================================================
--- trunk/webassembletool-core/src/main/java/net/webassembletool/cache/CacheEntry.java 2011-02-16 13:44:55 UTC (rev 573)
+++ trunk/webassembletool-core/src/main/java/net/webassembletool/cache/CacheEntry.java 2011-02-17 15:36:39 UTC (rev 574)
@@ -20,15 +20,15 @@
import net.webassembletool.resource.Resource;
import net.webassembletool.util.Rfc2616;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* @author Francois-Xavier Bonnet
* @author Nicolas Richeton
*/
class CacheEntry {
- private static final Log LOG = LogFactory.getLog(CacheEntry.class);
+ private static final Logger LOG = LoggerFactory.getLogger(CacheEntry.class);
private static final long CLEAN_DELAY = 15 * 60 * 1000; // 15 minutes;
private static final Pattern ETAG_PATTERN = Pattern.compile(",?\\s*((W/)?\"[^\"]*\")");
Modified: trunk/webassembletool-core/src/main/java/net/webassembletool/cookie/FilteringCookieStore.java
===================================================================
--- trunk/webassembletool-core/src/main/java/net/webassembletool/cookie/FilteringCookieStore.java 2011-02-16 13:44:55 UTC (rev 573)
+++ trunk/webassembletool-core/src/main/java/net/webassembletool/cookie/FilteringCookieStore.java 2011-02-17 15:36:39 UTC (rev 574)
@@ -17,8 +17,8 @@
import java.util.ArrayList;
import java.util.Properties;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.apache.http.cookie.Cookie;
/**
@@ -28,7 +28,7 @@
*
*/
public class FilteringCookieStore extends SerializableBasicCookieStore {
- private static Log logger = LogFactory.getLog(FilteringCookieStore.class);
+ private static Logger logger = LoggerFactory.getLogger(FilteringCookieStore.class);
/**
* Serialization ID.
*/
Modified: trunk/webassembletool-core/src/main/java/net/webassembletool/extension/ExtensionFactory.java
===================================================================
--- trunk/webassembletool-core/src/main/java/net/webassembletool/extension/ExtensionFactory.java 2011-02-16 13:44:55 UTC (rev 573)
+++ trunk/webassembletool-core/src/main/java/net/webassembletool/extension/ExtensionFactory.java 2011-02-17 15:36:39 UTC (rev 574)
@@ -22,8 +22,8 @@
import net.webassembletool.cookie.CustomCookieStore;
import net.webassembletool.filter.Filter;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* Factory for all Wat extension classes (authenticator, filters, cookie store).
@@ -32,7 +32,7 @@
*
*/
public class ExtensionFactory {
- private static final Log LOG = LogFactory.getLog(ExtensionFactory.class);
+ private static final Logger LOG = LoggerFactory.getLogger(ExtensionFactory.class);
private static final String EXTENSION_WAT_FILTER = Filter.class.getName();
private static final String EXTENSION_COOKIE_STORE = CustomCookieStore.class
Modified: trunk/webassembletool-core/src/main/java/net/webassembletool/filter/CookieForwardingFilter.java
===================================================================
--- trunk/webassembletool-core/src/main/java/net/webassembletool/filter/CookieForwardingFilter.java 2011-02-16 13:44:55 UTC (rev 573)
+++ trunk/webassembletool-core/src/main/java/net/webassembletool/filter/CookieForwardingFilter.java 2011-02-17 15:36:39 UTC (rev 574)
@@ -28,8 +28,8 @@
import net.webassembletool.http.HttpHeaders;
import net.webassembletool.output.Output;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* Cookie forwarding Filter.
@@ -38,7 +38,7 @@
*
*/
public class CookieForwardingFilter implements Filter {
- private static Log logger = LogFactory.getLog(ExtensionFactory.class);
+ private static Logger logger = LoggerFactory.getLogger(ExtensionFactory.class);
public static final String PROP_ATTRIBUTE = "forwardCookies";
private final ArrayList<String> forwardCookies = new ArrayList<String>();
Modified: trunk/webassembletool-core/src/main/java/net/webassembletool/http/HttpClientRequest.java
===================================================================
--- trunk/webassembletool-core/src/main/java/net/webassembletool/http/HttpClientRequest.java 2011-02-16 13:44:55 UTC (rev 573)
+++ trunk/webassembletool-core/src/main/java/net/webassembletool/http/HttpClientRequest.java 2011-02-17 15:36:39 UTC (rev 574)
@@ -23,8 +23,8 @@
import javax.servlet.http.HttpServletRequest;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.apache.http.HttpEntityEnclosingRequest;
import org.apache.http.HttpHost;
import org.apache.http.client.HttpClient;
@@ -46,7 +46,7 @@
*
*/
public class HttpClientRequest {
- private final static Log LOG = LogFactory.getLog(HttpClientRequest.class);
+ private final static Logger LOG = LoggerFactory.getLogger(HttpClientRequest.class);
private String uri;
private final HttpServletRequest originalRequest;
private boolean proxy;
Modified: trunk/webassembletool-core/src/main/java/net/webassembletool/http/HttpClientResponse.java
===================================================================
--- trunk/webassembletool-core/src/main/java/net/webassembletool/http/HttpClientResponse.java 2011-02-16 13:44:55 UTC (rev 573)
+++ trunk/webassembletool-core/src/main/java/net/webassembletool/http/HttpClientResponse.java 2011-02-17 15:36:39 UTC (rev 574)
@@ -20,8 +20,8 @@
import javax.servlet.http.HttpServletResponse;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.apache.http.Header;
import org.apache.http.HttpEntity;
import org.apache.http.HttpHost;
@@ -41,7 +41,7 @@
*
*/
public class HttpClientResponse {
- private final static Log LOG = LogFactory.getLog(HttpClientResponse.class);
+ private final static Logger LOG = LoggerFactory.getLogger(HttpClientResponse.class);
private HttpResponse httpResponse;
private HttpEntity httpEntity;
private int statusCode;
Modified: trunk/webassembletool-core/src/main/java/net/webassembletool/http/HttpResource.java
===================================================================
--- trunk/webassembletool-core/src/main/java/net/webassembletool/http/HttpResource.java 2011-02-16 13:44:55 UTC (rev 573)
+++ trunk/webassembletool-core/src/main/java/net/webassembletool/http/HttpResource.java 2011-02-17 15:36:39 UTC (rev 574)
@@ -35,8 +35,8 @@
import net.webassembletool.util.Rfc2616;
import org.apache.commons.io.IOUtils;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.apache.http.client.HttpClient;
import org.apache.http.protocol.HttpContext;
@@ -47,7 +47,7 @@
* @author Nicolas Richeton
*/
public class HttpResource extends Resource {
- private final static Log LOG = LogFactory.getLog(HttpResource.class);
+ private final static Logger LOG = LoggerFactory.getLogger(HttpResource.class);
private HttpClientResponse httpClientResponse;
private final ResourceContext target;
private final String url;
Modified: trunk/webassembletool-core/src/main/java/net/webassembletool/resource/ResourceUtils.java
===================================================================
--- trunk/webassembletool-core/src/main/java/net/webassembletool/resource/ResourceUtils.java 2011-02-16 13:44:55 UTC (rev 573)
+++ trunk/webassembletool-core/src/main/java/net/webassembletool/resource/ResourceUtils.java 2011-02-17 15:36:39 UTC (rev 574)
@@ -14,8 +14,8 @@
import net.webassembletool.http.RewriteUtils;
import org.apache.commons.lang.StringUtils;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* Utility class to generate URL and path for Resources
@@ -24,7 +24,7 @@
*/
public class ResourceUtils {
- private static final Log LOG = LogFactory.getLog(ResourceUtils.class);
+ private static final Logger LOG = LoggerFactory.getLogger(ResourceUtils.class);
/**
* Private constructor
Modified: trunk/webassembletool-core/src/main/java/net/webassembletool/tags/BlockRenderer.java
===================================================================
--- trunk/webassembletool-core/src/main/java/net/webassembletool/tags/BlockRenderer.java 2011-02-16 13:44:55 UTC (rev 573)
+++ trunk/webassembletool-core/src/main/java/net/webassembletool/tags/BlockRenderer.java 2011-02-17 15:36:39 UTC (rev 574)
@@ -9,8 +9,8 @@
import net.webassembletool.ResourceContext;
import net.webassembletool.parser.Parser;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* Block renderer.
@@ -22,7 +22,7 @@
* @author Francois-Xavier Bonnet
*/
public class BlockRenderer implements Renderer, Appendable {
- private final static Log LOG = LogFactory.getLog(BlockRenderer.class);
+ private final static Logger LOG = LoggerFactory.getLogger(BlockRenderer.class);
private final static Parser PARSER = new Parser(Pattern
.compile("<!--\\$[^>]*\\$-->"), BlockElement.TYPE);
private final String page;
Modified: trunk/webassembletool-core/src/main/java/net/webassembletool/tags/TemplateRenderer.java
===================================================================
--- trunk/webassembletool-core/src/main/java/net/webassembletool/tags/TemplateRenderer.java 2011-02-16 13:44:55 UTC (rev 573)
+++ trunk/webassembletool-core/src/main/java/net/webassembletool/tags/TemplateRenderer.java 2011-02-17 15:36:39 UTC (rev 574)
@@ -10,8 +10,8 @@
import net.webassembletool.ResourceContext;
import net.webassembletool.parser.Parser;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* Template renderer.
@@ -31,7 +31,7 @@
* @author Francois-Xavier Bonnet
*/
public class TemplateRenderer implements Renderer, Appendable {
- private final static Log LOG = LogFactory.getLog(TemplateRenderer.class);
+ private final static Logger LOG = LoggerFactory.getLogger(TemplateRenderer.class);
private final static Parser PARSER = new Parser(Pattern
.compile("<!--\\$[^>]*\\$-->"), TemplateElement.TYPE,
ParamElement.TYPE);
Modified: trunk/webassembletool-core/src/main/java/net/webassembletool/util/Rfc2616.java
===================================================================
--- trunk/webassembletool-core/src/main/java/net/webassembletool/util/Rfc2616.java 2011-02-16 13:44:55 UTC (rev 573)
+++ trunk/webassembletool-core/src/main/java/net/webassembletool/util/Rfc2616.java 2011-02-17 15:36:39 UTC (rev 574)
@@ -15,8 +15,8 @@
import net.webassembletool.resource.Resource;
import org.apache.commons.lang.StringUtils;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.apache.http.impl.cookie.DateParseException;
import org.apache.http.impl.cookie.DateUtils;
@@ -33,7 +33,7 @@
}
private static final int SECONDS = 1000;
- private static final Log LOG = LogFactory.getLog(Rfc2616.class);
+ private static final Logger LOG = LoggerFactory.getLogger(Rfc2616.class);
private final static class CacheControlResponseHeader {
private boolean _public = false;
Modified: trunk/webassembletool-core/src/main/java/net/webassembletool/vars/VariablesResolver.java
===================================================================
--- trunk/webassembletool-core/src/main/java/net/webassembletool/vars/VariablesResolver.java 2011-02-16 13:44:55 UTC (rev 573)
+++ trunk/webassembletool-core/src/main/java/net/webassembletool/vars/VariablesResolver.java 2011-02-17 15:36:39 UTC (rev 574)
@@ -26,8 +26,8 @@
import net.webassembletool.ConfigurationException;
import net.webassembletool.Driver;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* Manage variables replacement
@@ -36,7 +36,7 @@
*/
public class VariablesResolver {
- private static final Log LOG = LogFactory.getLog(VariablesResolver.class);
+ private static final Logger LOG = LoggerFactory.getLogger(VariablesResolver.class);
static {
// Load default settings
Modified: trunk/webassembletool-taglib/src/main/java/net/webassembletool/taglib/DefaultErrorTag.java
===================================================================
--- trunk/webassembletool-taglib/src/main/java/net/webassembletool/taglib/DefaultErrorTag.java 2011-02-16 13:44:55 UTC (rev 573)
+++ trunk/webassembletool-taglib/src/main/java/net/webassembletool/taglib/DefaultErrorTag.java 2011-02-17 15:36:39 UTC (rev 574)
@@ -3,7 +3,7 @@
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.tagext.BodyTagSupport;
import javax.servlet.jsp.tagext.Tag;
-import org.apache.commons.logging.LogFactory;
+import org.slf4j.LoggerFactory;
/**
* 'defaultError' JSP tag.
@@ -19,7 +19,7 @@
public int doAfterBody() throws JspException {
ErrorManageableTag parent = getFirstAvailableParent();
if (parent == null) {
- LogFactory.getLog(ErrorDefinitionTag.class).warn("No parent found, skipping tag");
+ LoggerFactory.getLogger(ErrorDefinitionTag.class).warn("No parent found, skipping tag");
return Tag.SKIP_BODY;
}
String value = getBodyContent().getString();
@@ -32,7 +32,7 @@
if (getBodyContent() == null) {
ErrorManageableTag parent = getFirstAvailableParent();
if (parent == null) {
- LogFactory.getLog(ErrorDefinitionTag.class).warn("No parent found, skipping tag");
+ LoggerFactory.getLogger(ErrorDefinitionTag.class).warn("No parent found, skipping tag");
return Tag.SKIP_BODY;
}
parent.setDefaultMessage("");
Modified: trunk/webassembletool-taglib/src/main/java/net/webassembletool/taglib/ErrorDefinitionTag.java
===================================================================
--- trunk/webassembletool-taglib/src/main/java/net/webassembletool/taglib/ErrorDefinitionTag.java 2011-02-16 13:44:55 UTC (rev 573)
+++ trunk/webassembletool-taglib/src/main/java/net/webassembletool/taglib/ErrorDefinitionTag.java 2011-02-17 15:36:39 UTC (rev 574)
@@ -3,7 +3,7 @@
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.tagext.BodyTagSupport;
import javax.servlet.jsp.tagext.Tag;
-import org.apache.commons.logging.LogFactory;
+import org.slf4j.LoggerFactory;
/**
* 'errorDefinition' JSP tag.
@@ -35,7 +35,7 @@
public int doAfterBody() throws JspException {
ErrorManageableTag parent = getFirstAvailableParent();
if (parent == null) {
- LogFactory.getLog(ErrorDefinitionTag.class).warn("No parent found, skipping tag");
+ LoggerFactory.getLogger(ErrorDefinitionTag.class).warn("No parent found, skipping tag");
return Tag.SKIP_BODY;
}
String value = getBodyContent().getString();
Modified: trunk/webassembletool-taglib/src/main/java/net/webassembletool/taglib/ParameterTag.java
===================================================================
--- trunk/webassembletool-taglib/src/main/java/net/webassembletool/taglib/ParameterTag.java 2011-02-16 13:44:55 UTC (rev 573)
+++ trunk/webassembletool-taglib/src/main/java/net/webassembletool/taglib/ParameterTag.java 2011-02-17 15:36:39 UTC (rev 574)
@@ -3,7 +3,7 @@
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.tagext.BodyTagSupport;
import javax.servlet.jsp.tagext.Tag;
-import org.apache.commons.logging.LogFactory;
+import org.slf4j.LoggerFactory;
/**
* Only used inside a tag that implements IParameterTag. This tag add a request parameter to the parent tag, which will be applied on render.
@@ -38,7 +38,7 @@
public int doAfterBody() throws JspException {
ParametrizableTag parent = getFirstAvailableParent();
if (parent == null) {
- LogFactory.getLog(ParameterTag.class).warn("No parent found, skipping tag");
+ LoggerFactory.getLogger(ParameterTag.class).warn("No parent found, skipping tag");
return Tag.SKIP_BODY;
}
String value = getBodyContent().getString();
Modified: trunk/webassembletool-taglib/src/main/java/net/webassembletool/taglib/ReplaceTag.java
===================================================================
--- trunk/webassembletool-taglib/src/main/java/net/webassembletool/taglib/ReplaceTag.java 2011-02-16 13:44:55 UTC (rev 573)
+++ trunk/webassembletool-taglib/src/main/java/net/webassembletool/taglib/ReplaceTag.java 2011-02-17 15:36:39 UTC (rev 574)
@@ -3,7 +3,7 @@
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.tagext.BodyTagSupport;
import javax.servlet.jsp.tagext.Tag;
-import org.apache.commons.logging.LogFactory;
+import org.slf4j.LoggerFactory;
/**
* Only used inside a tag that implements IReplaceableTag. This tag add a replace rule to the parent tag, which will be applied on render.
@@ -38,7 +38,7 @@
public int doAfterBody() throws JspException {
ReplaceableTag parent = getFirstAvailableParent();
if (parent == null) {
- LogFactory.getLog(ReplaceTag.class).warn("No parent found, skipping tag");
+ LoggerFactory.getLogger(ReplaceTag.class).warn("No parent found, skipping tag");
return Tag.SKIP_BODY;
}
if (expression == null)
@@ -53,7 +53,7 @@
if (getBodyContent() == null) {
ReplaceableTag parent = getFirstAvailableParent();
if (parent == null) {
- LogFactory.getLog(ReplaceTag.class).warn("No parent found, skipping tag");
+ LoggerFactory.getLogger(ReplaceTag.class).warn("No parent found, skipping tag");
return Tag.SKIP_BODY;
}
parent.getReplaceRules().put(expression, "");
Modified: trunk/webassembletool-wicket/pom.xml
===================================================================
--- trunk/webassembletool-wicket/pom.xml 2011-02-16 13:44:55 UTC (rev 573)
+++ trunk/webassembletool-wicket/pom.xml 2011-02-17 15:36:39 UTC (rev 574)
@@ -45,5 +45,11 @@
<type>jar</type>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-nop</artifactId>
+ <version>1.6.1</version>
+ <scope>test</scope>
+ </dependency>
</dependencies>
</project>
\ No newline at end of file
Modified: trunk/webassembletool-wicket/src/main/java/net/webassembletool/wicket/container/AbstractWatDriverContainer.java
===================================================================
--- trunk/webassembletool-wicket/src/main/java/net/webassembletool/wicket/container/AbstractWatDriverContainer.java 2011-02-16 13:44:55 UTC (rev 573)
+++ trunk/webassembletool-wicket/src/main/java/net/webassembletool/wicket/container/AbstractWatDriverContainer.java 2011-02-17 15:36:39 UTC (rev 574)
@@ -22,16 +22,13 @@
import net.webassembletool.wicket.utils.WATNullResponse;
import net.webassembletool.wicket.utils.WATWicketConfiguration;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
import org.apache.wicket.Response;
import org.apache.wicket.markup.ComponentTag;
import org.apache.wicket.markup.MarkupStream;
import org.apache.wicket.markup.html.WebMarkupContainer;
/**
- * A container for a template parameter. It encloses a block which will be
- * inserted into the template.
+ * A container for a template parameter. It encloses a block which will be inserted into the template.
*
* <p>
* Usage :
@@ -62,8 +59,6 @@
*
*/
public abstract class AbstractWatDriverContainer extends WebMarkupContainer {
- private static Log logger = LogFactory
- .getLog(AbstractWatDriverContainer.class);
private static final long serialVersionUID = 1L;
public static final String WAT_ERROR_PREFIX = "net.webassembletool.error";
@@ -115,13 +110,11 @@
/*
* (non-Javadoc)
*
- * @see
- * org.apache.wicket.MarkupContainer#onComponentTagBody(org.apache.wicket
- * .markup.MarkupStream, org.apache.wicket.markup.ComponentTag)
+ * @see org.apache.wicket.MarkupContainer#onComponentTagBody(org.apache.wicket .markup.MarkupStream,
+ * org.apache.wicket.markup.ComponentTag)
*/
@Override
- protected void onComponentTagBody(MarkupStream markupStream,
- ComponentTag openTag) {
+ protected void onComponentTagBody(MarkupStream markupStream, ComponentTag openTag) {
// For unit tests, WAT can be disabled. This component will then behave
// like a standard MarkupContainer.
@@ -141,15 +134,14 @@
}
/**
- * This method is called when the component is rendered. This is the place
- * to do the specific processing and call Driver.
+ * This method is called when the component is rendered. This is the place to do the specific processing and call
+ * Driver.
*
* @param blocks
* @param params
* @param replaceRules
*/
- public abstract void process(Map<String, String> blocks,
- Map<String, String> params, Map<String, String> replaceRules);
+ public abstract void process(Map<String, String> blocks, Map<String, String> params, Map<String, String> replaceRules);
/**
* Write error content according to the error.
@@ -158,8 +150,7 @@
* @param response
* @param httpStatusCode
*/
- protected void sendErrorContent(Map<String, String> blocks,
- Response response, Integer httpStatusCode) {
+ protected void sendErrorContent(Map<String, String> blocks, Response response, Integer httpStatusCode) {
String errorContent = blocks.get(WAT_ERROR_PREFIX + httpStatusCode);
if (errorContent == null) {
Modified: trunk/webassembletool-wicket/src/main/java/net/webassembletool/wicket/container/WATBlock.java
===================================================================
--- trunk/webassembletool-wicket/src/main/java/net/webassembletool/wicket/container/WATBlock.java 2011-02-16 13:44:55 UTC (rev 573)
+++ trunk/webassembletool-wicket/src/main/java/net/webassembletool/wicket/container/WATBlock.java 2011-02-17 15:36:39 UTC (rev 574)
@@ -25,8 +25,8 @@
import net.webassembletool.HttpErrorPage;
import net.webassembletool.wicket.utils.ResponseWriter;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.apache.wicket.protocol.http.WebResponse;
import org.apache.wicket.protocol.http.servlet.ServletWebRequest;
@@ -58,7 +58,7 @@
*
*/
public class WATBlock extends AbstractWatDriverContainer {
- private static final Log LOG = LogFactory.getLog(WATBlock.class);
+ private static final Logger LOG = LoggerFactory.getLogger(WATBlock.class);
private static final long serialVersionUID = 1L;
private String blockName = null;
Modified: trunk/webassembletool-wicket/src/main/java/net/webassembletool/wicket/container/WATTemplate.java
===================================================================
--- trunk/webassembletool-wicket/src/main/java/net/webassembletool/wicket/container/WATTemplate.java 2011-02-16 13:44:55 UTC (rev 573)
+++ trunk/webassembletool-wicket/src/main/java/net/webassembletool/wicket/container/WATTemplate.java 2011-02-17 15:36:39 UTC (rev 574)
@@ -24,14 +24,13 @@
import net.webassembletool.HttpErrorPage;
import net.webassembletool.wicket.utils.ResponseWriter;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
import org.apache.wicket.protocol.http.WebResponse;
import org.apache.wicket.protocol.http.servlet.ServletWebRequest;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
- * A container for a template parameter. It encloses a block which will be
- * inserted into the template.
+ * A container for a template parameter. It encloses a block which will be inserted into the template.
*
* <p>
* Usage :
@@ -62,7 +61,7 @@
*
*/
public class WATTemplate extends AbstractWatDriverContainer {
- private static Log logger = LogFactory.getLog(WATTemplate.class);
+ private static Logger logger = LoggerFactory.getLogger(WATTemplate.class);
private static final long serialVersionUID = 1L;
private String name = null;
private String page = null;
@@ -83,8 +82,7 @@
}
@Override
- public void process(Map<String, String> blocks, Map<String, String> params,
- Map<String, String> replaceRules) {
+ public void process(Map<String, String> blocks, Map<String, String> params, Map<String, String> replaceRules) {
ServletWebRequest servletWebRequest = (ServletWebRequest) getRequest();
HttpServletRequest request = servletWebRequest.getHttpServletRequest();
@@ -93,12 +91,12 @@
Driver driver = getDriver();
try {
- driver.renderTemplate(page, name, new ResponseWriter(webResponse),
- request, response, blocks, replaceRules, params, false);
+ driver.renderTemplate(page, name, new ResponseWriter(webResponse), request, response, blocks, replaceRules, params,
+ false);
} catch (IOException e) {
- logger.error(e);
+ logger.error("io error", e);
} catch (HttpErrorPage e) {
- logger.error(e);
+ logger.error("http error", e);
}
}
Modified: trunk/webassembletool-wicket/src/main/java/net/webassembletool/wicket/utils/WATBufferedResponse.java
===================================================================
--- trunk/webassembletool-wicket/src/main/java/net/webassembletool/wicket/utils/WATBufferedResponse.java 2011-02-16 13:44:55 UTC (rev 573)
+++ trunk/webassembletool-wicket/src/main/java/net/webassembletool/wicket/utils/WATBufferedResponse.java 2011-02-17 15:36:39 UTC (rev 574)
@@ -20,8 +20,8 @@
import net.webassembletool.wicket.container.WATParam;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.apache.wicket.Response;
import org.apache.wicket.protocol.http.WebResponse;
@@ -36,7 +36,7 @@
* @see Response
*/
public class WATBufferedResponse extends WebResponse {
- private static final Log LOG = LogFactory.getLog(WATBufferedResponse.class);
+ private static final Logger LOG = LoggerFactory.getLogger(WATBufferedResponse.class);
private final ByteArrayOutputStream baos = new ByteArrayOutputStream();
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rg...@us...> - 2011-02-16 13:45:02
|
Revision: 573
http://webassembletool.svn.sourceforge.net/webassembletool/?rev=573&view=rev
Author: rgonord
Date: 2011-02-16 13:44:55 +0000 (Wed, 16 Feb 2011)
Log Message:
-----------
clean static-assembly
Modified Paths:
--------------
trunk/webassembletool-maven/webassembletool-staticassembly-archetype/src/main/resources/META-INF/maven/archetype-metadata.xml
trunk/webassembletool-maven/webassembletool-staticassembly-archetype/src/main/resources/META-INF/maven/archetype.xml
trunk/webassembletool-maven/webassembletool-staticassembly-archetype/src/main/resources/archetype-resources/pom.xml
Added Paths:
-----------
trunk/webassembletool-maven/webassembletool-staticassembly-archetype/src/main/resources/archetype-resources/src/main/assembly/export.xml
Removed Paths:
-------------
trunk/webassembletool-maven/webassembletool-staticassembly-archetype/src/main/resources/archetype-resources/src/main/assembly/exportMaquette.xml
Modified: trunk/webassembletool-maven/webassembletool-staticassembly-archetype/src/main/resources/META-INF/maven/archetype-metadata.xml
===================================================================
--- trunk/webassembletool-maven/webassembletool-staticassembly-archetype/src/main/resources/META-INF/maven/archetype-metadata.xml 2011-02-15 14:38:34 UTC (rev 572)
+++ trunk/webassembletool-maven/webassembletool-staticassembly-archetype/src/main/resources/META-INF/maven/archetype-metadata.xml 2011-02-16 13:44:55 UTC (rev 573)
@@ -1,17 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<archetype-descriptor name="webassembletool-staticassembly-archetype">
- <fileSets>
- <fileSet filtered="false" encoding="UTF-8">
- <directory>src/main/resources</directory>
- <includes>
- <include>**/*</include>
- </includes>
- </fileSet>
- <fileSet filtered="false" encoding="UTF-8">
- <directory>src/main/filters</directory>
- <includes>
- <include>**/*</include>
- </includes>
- </fileSet>
- </fileSets>
+ <fileSets>
+ <fileSet filtered="false" encoding="UTF-8">
+ <directory>src/main/resources</directory>
+ <includes>
+ <include>**/*</include>
+ </includes>
+ </fileSet>
+ <fileSet filtered="false" encoding="UTF-8">
+ <directory>src/main/filters</directory>
+ <includes>
+ <include>**/*</include>
+ </includes>
+ </fileSet>
+ <fileSet filtered="false" encoding="UTF-8">
+ <directory>src/main/assembly</directory>
+ <includes>
+ <include>**/*</include>
+ </includes>
+ </fileSet>
+ </fileSets>
</archetype-descriptor>
\ No newline at end of file
Modified: trunk/webassembletool-maven/webassembletool-staticassembly-archetype/src/main/resources/META-INF/maven/archetype.xml
===================================================================
--- trunk/webassembletool-maven/webassembletool-staticassembly-archetype/src/main/resources/META-INF/maven/archetype.xml 2011-02-15 14:38:34 UTC (rev 572)
+++ trunk/webassembletool-maven/webassembletool-staticassembly-archetype/src/main/resources/META-INF/maven/archetype.xml 2011-02-16 13:44:55 UTC (rev 573)
@@ -1,6 +1,9 @@
-<?xml version="1.0" encoding="UTF-8"?><archetype>
- <id>webassembletool-staticassembly-archetype</id>
- <resources>
- <resource>src/main/resources</resource>
- </resources>
+<?xml version="1.0" encoding="UTF-8"?>
+<archetype>
+ <id>webassembletool-staticassembly-archetype</id>
+ <resources>
+ <resource>src/main/resources</resource>
+ <resource>src/main/filters</resource>
+ <resource>src/main/assembly</resource>
+ </resources>
</archetype>
\ No newline at end of file
Modified: trunk/webassembletool-maven/webassembletool-staticassembly-archetype/src/main/resources/archetype-resources/pom.xml
===================================================================
--- trunk/webassembletool-maven/webassembletool-staticassembly-archetype/src/main/resources/archetype-resources/pom.xml 2011-02-15 14:38:34 UTC (rev 572)
+++ trunk/webassembletool-maven/webassembletool-staticassembly-archetype/src/main/resources/archetype-resources/pom.xml 2011-02-16 13:44:55 UTC (rev 573)
@@ -5,12 +5,12 @@
<artifactId>\${artifactId}</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
- <name>\${artifactId}</name>
+ <name>\${project.artifactId}</name>
<properties>
<maven.build.timestamp.format>yyyyMMdd_HHmm__</maven.build.timestamp.format>
</properties>
<build>
- <finalName>\${artifactId}</finalName>
+ <finalName>\${project.artifactId}</finalName>
<filters>
<filter>src/main/filters/filter.properties</filter>
</filters>
@@ -36,6 +36,9 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
+ <configuration>
+ <encoding>ISO-8859-1</encoding>
+ </configuration>
</plugin>
<plugin>
<groupId>net.sourceforge.webassembletool.maven</groupId>
@@ -64,9 +67,9 @@
</goals>
<configuration>
<descriptors>
- <descriptor>src/main/assembly/exportMaquette.xml</descriptor>
+ <descriptor>src/main/assembly/export.xml</descriptor>
</descriptors>
- <finalName>${maven.build.timestamp}${project.name}</finalName>
+ <finalName>${maven.build.timestamp}_${project.name}</finalName>
</configuration>
</execution>
</executions>
Added: trunk/webassembletool-maven/webassembletool-staticassembly-archetype/src/main/resources/archetype-resources/src/main/assembly/export.xml
===================================================================
--- trunk/webassembletool-maven/webassembletool-staticassembly-archetype/src/main/resources/archetype-resources/src/main/assembly/export.xml (rev 0)
+++ trunk/webassembletool-maven/webassembletool-staticassembly-archetype/src/main/resources/archetype-resources/src/main/assembly/export.xml 2011-02-16 13:44:55 UTC (rev 573)
@@ -0,0 +1,12 @@
+<assembly>
+ <id>export</id>
+ <formats>
+ <format>zip</format>
+ </formats>
+ <fileSets>
+ <fileSet>
+ <directory>target/generated-html</directory>
+ <outputDirectory></outputDirectory>
+ </fileSet>
+ </fileSets>
+</assembly>
\ No newline at end of file
Deleted: trunk/webassembletool-maven/webassembletool-staticassembly-archetype/src/main/resources/archetype-resources/src/main/assembly/exportMaquette.xml
===================================================================
--- trunk/webassembletool-maven/webassembletool-staticassembly-archetype/src/main/resources/archetype-resources/src/main/assembly/exportMaquette.xml 2011-02-15 14:38:34 UTC (rev 572)
+++ trunk/webassembletool-maven/webassembletool-staticassembly-archetype/src/main/resources/archetype-resources/src/main/assembly/exportMaquette.xml 2011-02-16 13:44:55 UTC (rev 573)
@@ -1,12 +0,0 @@
-<assembly>
- <id>exportMaquette</id>
- <formats>
- <format>zip</format>
- </formats>
- <fileSets>
- <fileSet>
- <directory>target/generated-html</directory>
- <outputDirectory></outputDirectory>
- </fileSet>
- </fileSets>
-</assembly>
\ No newline at end of file
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <sbe...@us...> - 2011-02-15 14:38:41
|
Revision: 572
http://webassembletool.svn.sourceforge.net/webassembletool/?rev=572&view=rev
Author: sbernatsky
Date: 2011-02-15 14:38:34 +0000 (Tue, 15 Feb 2011)
Log Message:
-----------
cleanup
Modified Paths:
--------------
trunk/webassembletool-core/src/main/java/net/webassembletool/cache/CacheEntry.java
trunk/webassembletool-core/src/main/java/net/webassembletool/http/HttpClientRequest.java
trunk/webassembletool-core/src/main/java/net/webassembletool/http/HttpResource.java
trunk/webassembletool-core/src/main/java/net/webassembletool/util/Rfc2616.java
Modified: trunk/webassembletool-core/src/main/java/net/webassembletool/cache/CacheEntry.java
===================================================================
--- trunk/webassembletool-core/src/main/java/net/webassembletool/cache/CacheEntry.java 2011-02-14 13:30:26 UTC (rev 571)
+++ trunk/webassembletool-core/src/main/java/net/webassembletool/cache/CacheEntry.java 2011-02-15 14:38:34 UTC (rev 572)
@@ -28,12 +28,14 @@
* @author Nicolas Richeton
*/
class CacheEntry {
- private static Log LOG = LogFactory.getLog(CacheEntry.class);
+ private static final Log LOG = LogFactory.getLog(CacheEntry.class);
+ private static final long CLEAN_DELAY = 15 * 60 * 1000; // 15 minutes;
+ private static final Pattern ETAG_PATTERN = Pattern.compile(",?\\s*((W/)?\"[^\"]*\")");
+
private final String url;
private transient Storage storage;
private transient boolean dirty;
private long lastClean = -1;
- private static long CLEAN_DELAY = 15 * 60 * 1000; // 15 minutes;
/**
* A list a all responses for this ResourceContext. Only includes
@@ -53,9 +55,6 @@
return url;
}
- private static Pattern ETAG_PATTERN = Pattern
- .compile(",?\\s*((W/)?\"[^\"]*\")");
-
public CacheEntry(String url, Storage storage) {
this.url = url;
this.storage = storage;
@@ -162,8 +161,7 @@
* @return The headers "If-Modified-Since" and "If-None-Match" to add to the
* request
*/
- public Map<String, String> getValidators(ResourceContext resourceContext,
- CachedResponse cachedResponse) {
+ public Map<String, String> getValidators(ResourceContext resourceContext, Resource cachedResponse) {
HashMap<String, String> result = new HashMap<String, String>();
String ifNoneMatch = getIfNoneMatch(resourceContext);
if (ifNoneMatch != null) {
@@ -213,8 +211,7 @@
return null;
}
- private String getIfModifiedSince(ResourceContext resourceContext,
- CachedResponse cachedResponse) {
+ private String getIfModifiedSince(ResourceContext resourceContext, Resource cachedResponse) {
String requestedIfModifiedSinceString = resourceContext
.getOriginalRequest().getHeader(HttpHeaders.IF_MODIFIED_SINCE);
Date requestedIfModifiedSinceDate = Rfc2616.getDateHeader(
@@ -251,8 +248,7 @@
* @return The response to send to the client
* @throws HttpErrorPage
*/
- public Resource select(ResourceContext resourceContext,
- CachedResponse cachedResponse, Resource newResource)
+ public Resource select(ResourceContext resourceContext, CachedResponse cachedResponse, Resource newResource)
throws HttpErrorPage {
if (LOG.isDebugEnabled()) {
LOG.debug("select(" + resourceContext.getRelUrl() + ")");
@@ -340,8 +336,7 @@
}
}
- private void updateHeaders(CachedResponse cachedResponse,
- Resource newResource) {
+ private void updateHeaders(CachedResponse cachedResponse, Resource newResource) {
copyHeader(newResource, cachedResponse, HttpHeaders.DATE);
copyHeader(newResource, cachedResponse, HttpHeaders.CONTENT_TYPE);
copyHeader(newResource, cachedResponse, HttpHeaders.CONTENT_LENGTH);
@@ -370,8 +365,7 @@
&& resource.getStatusCode() != HttpServletResponse.SC_NOT_MODIFIED) {
// Inject headers from the original request.
- resource.setRequestHeadersFromRequest(resourceContext
- .getOriginalRequest());
+ resource.setRequestHeadersFromRequest(resourceContext.getOriginalRequest());
String key = getCacheKey(resourceContext, resource);
@@ -419,8 +413,7 @@
* @param resource
* @return
*/
- private String getCacheKey(ResourceContext resourceContext,
- CachedResponse resource) {
+ private String getCacheKey(ResourceContext resourceContext, Resource resource) {
StringBuilder cacheKey = new StringBuilder();
cacheKey.append(url).append(" ");
String etag = Rfc2616.getEtag(resource);
Modified: trunk/webassembletool-core/src/main/java/net/webassembletool/http/HttpClientRequest.java
===================================================================
--- trunk/webassembletool-core/src/main/java/net/webassembletool/http/HttpClientRequest.java 2011-02-14 13:30:26 UTC (rev 571)
+++ trunk/webassembletool-core/src/main/java/net/webassembletool/http/HttpClientRequest.java 2011-02-15 14:38:34 UTC (rev 572)
@@ -66,10 +66,10 @@
this.preserveHost = preserveHost;
}
+ private static final String[] UNSAFE = { "{", "}", "|", "\\", "^", "~", "[", "]", "`" };
+ private static final String[] ESCAPED = { "%7B", "%7D", "%7C", "%5C", "%5E", "%7E", "%5B", "%5D", "%60" };
+
private String escapeUnsafeCharacters(String url) {
- final String[] UNSAFE = { "{", "}", "|", "\\", "^", "~", "[", "]", "`" };
- final String[] ESCAPED = { "%7B", "%7D", "%7C", "%5C", "%5E", "%7E",
- "%5B", "%5D", "%60" };
String result = url;
for (int i = 0; i < UNSAFE.length; i++) {
result = result.replaceAll(Pattern.quote(UNSAFE[i]), ESCAPED[i]);
@@ -77,13 +77,10 @@
return result;
}
- public HttpClientResponse execute(HttpClient httpClient,
- HttpContext httpContext) throws IOException {
+ public HttpClientResponse execute(HttpClient httpClient, HttpContext httpContext) throws IOException {
buildHttpMethod();
- HttpClientResponse result;
URL url = new URL(uri);
- HttpHost httpHost = new HttpHost(url.getHost(), url.getPort(),
- url.getProtocol());
+ HttpHost httpHost = new HttpHost(url.getHost(), url.getPort(), url.getProtocol());
// Preserve host if required
if (preserveHost) {
// original port is -1 for default ports(80, 443),
@@ -103,8 +100,7 @@
long start = System.currentTimeMillis();
// Do the request
- result = new HttpClientResponse(httpHost, httpRequest, httpClient,
- httpContext);
+ HttpClientResponse result = new HttpClientResponse(httpHost, httpRequest, httpClient, httpContext);
long end = System.currentTimeMillis();
if (LOG.isDebugEnabled()) {
LOG.debug(toString() + " -> " + result.toString() + " ("
Modified: trunk/webassembletool-core/src/main/java/net/webassembletool/http/HttpResource.java
===================================================================
--- trunk/webassembletool-core/src/main/java/net/webassembletool/http/HttpResource.java 2011-02-14 13:30:26 UTC (rev 571)
+++ trunk/webassembletool-core/src/main/java/net/webassembletool/http/HttpResource.java 2011-02-15 14:38:34 UTC (rev 572)
@@ -58,8 +58,7 @@
this.url = ResourceUtils.getHttpUrlWithQueryString(resourceContext);
Driver driver = resourceContext.getDriver();
- HttpServletRequest originalRequest = resourceContext
- .getOriginalRequest();
+ HttpServletRequest originalRequest = resourceContext.getOriginalRequest();
// Retrieve session and other cookies
UserContext userContext = null;
@@ -75,8 +74,7 @@
httpContext = userContext.getHttpContext();
// Proceed with request
- AuthenticationHandler authenticationHandler = resourceContext
- .getDriver().getAuthenticationHandler();
+ AuthenticationHandler authenticationHandler = driver.getAuthenticationHandler();
boolean proxy = resourceContext.isProxy();
boolean preserveHost = resourceContext.isPreserveHost();
HttpClientRequest httpClientRequest = new HttpClientRequest(url,
@@ -92,21 +90,18 @@
authenticationHandler.preRequest(httpClientRequest, resourceContext);
// Filter
- Filter filter = resourceContext.getDriver().getFilter();
+ Filter filter = driver.getFilter();
if (filter != null) {
filter.preRequest(httpClientRequest, resourceContext);
}
httpClientResponse = httpClientRequest.execute(httpClient, httpContext);
// Store context in session if cookies where created
- if (newUserContext
- && userContext.getCookieStore().getCookies().size() > 0) {
- resourceContext.getDriver().setUserContext(userContext,
- originalRequest);
+ if (newUserContext && !userContext.getCookieStore().getCookies().isEmpty()) {
+ resourceContext.getDriver().setUserContext(userContext, originalRequest);
}
- while (authenticationHandler.needsNewRequest(httpClientResponse,
- resourceContext)) {
+ while (authenticationHandler.needsNewRequest(httpClientResponse, resourceContext)) {
// We must first ensure that the connection is always released, if
// not the connection manager's pool may be exhausted soon !
httpClientResponse.finish();
@@ -123,10 +118,8 @@
httpContext);
// Store context if cookies where created
- if (newUserContext
- && userContext.getCookieStore().getCookies().size() > 0) {
- resourceContext.getDriver().setUserContext(userContext,
- originalRequest);
+ if (newUserContext && !userContext.getCookieStore().getCookies().isEmpty()) {
+ resourceContext.getDriver().setUserContext(userContext, originalRequest);
}
}
Modified: trunk/webassembletool-core/src/main/java/net/webassembletool/util/Rfc2616.java
===================================================================
--- trunk/webassembletool-core/src/main/java/net/webassembletool/util/Rfc2616.java 2011-02-14 13:30:26 UTC (rev 571)
+++ trunk/webassembletool-core/src/main/java/net/webassembletool/util/Rfc2616.java 2011-02-15 14:38:34 UTC (rev 572)
@@ -113,12 +113,9 @@
if (varyString != null) {
Map<String, String> result = new HashMap<String, String>();
String[] varyStringSplit = varyString.split(",");
- for (int i = 0; i < varyStringSplit.length; i++) {
- String key = varyStringSplit[i];
+ for (String key : varyStringSplit) {
String value = resource.getRequestHeader(key);
-
result.put(key, value);
-
}
return result;
}
@@ -281,7 +278,7 @@
}
public final static long getAge(Resource resource) {
- return new Date().getTime() - resource.getLocalDate().getTime();
+ return System.currentTimeMillis() - resource.getLocalDate().getTime();
}
public final static boolean isCacheable(Resource resource) {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <sbe...@us...> - 2011-02-14 13:30:33
|
Revision: 571
http://webassembletool.svn.sourceforge.net/webassembletool/?rev=571&view=rev
Author: sbernatsky
Date: 2011-02-14 13:30:26 +0000 (Mon, 14 Feb 2011)
Log Message:
-----------
move Rfc2616 helper class into util package
Modified Paths:
--------------
trunk/webassembletool-core/src/main/java/net/webassembletool/Driver.java
trunk/webassembletool-core/src/main/java/net/webassembletool/cache/CacheEntry.java
trunk/webassembletool-core/src/main/java/net/webassembletool/cache/CachedResponse.java
trunk/webassembletool-core/src/main/java/net/webassembletool/http/HttpResource.java
Added Paths:
-----------
trunk/webassembletool-core/src/main/java/net/webassembletool/util/
trunk/webassembletool-core/src/main/java/net/webassembletool/util/Rfc2616.java
trunk/webassembletool-core/src/test/java/net/webassembletool/util/
trunk/webassembletool-core/src/test/java/net/webassembletool/util/Rfc2616Test.java
Removed Paths:
-------------
trunk/webassembletool-core/src/main/java/net/webassembletool/cache/Rfc2616.java
trunk/webassembletool-core/src/test/java/net/webassembletool/cache/Rfc2616Test.java
Modified: trunk/webassembletool-core/src/main/java/net/webassembletool/Driver.java
===================================================================
--- trunk/webassembletool-core/src/main/java/net/webassembletool/Driver.java 2011-01-21 08:54:38 UTC (rev 570)
+++ trunk/webassembletool-core/src/main/java/net/webassembletool/Driver.java 2011-02-14 13:30:26 UTC (rev 571)
@@ -30,7 +30,6 @@
import net.webassembletool.cache.Cache;
import net.webassembletool.cache.CacheOutput;
import net.webassembletool.cache.CachedResponse;
-import net.webassembletool.cache.Rfc2616;
import net.webassembletool.cookie.CustomCookieStore;
import net.webassembletool.extension.ExtensionFactory;
import net.webassembletool.file.FileOutput;
@@ -49,6 +48,7 @@
import net.webassembletool.resource.ResourceUtils;
import net.webassembletool.tags.BlockRenderer;
import net.webassembletool.tags.TemplateRenderer;
+import net.webassembletool.util.Rfc2616;
import net.webassembletool.vars.VariablesResolver;
import net.webassembletool.xml.XpathRenderer;
import net.webassembletool.xml.XsltRenderer;
Modified: trunk/webassembletool-core/src/main/java/net/webassembletool/cache/CacheEntry.java
===================================================================
--- trunk/webassembletool-core/src/main/java/net/webassembletool/cache/CacheEntry.java 2011-01-21 08:54:38 UTC (rev 570)
+++ trunk/webassembletool-core/src/main/java/net/webassembletool/cache/CacheEntry.java 2011-02-14 13:30:26 UTC (rev 571)
@@ -18,6 +18,7 @@
import net.webassembletool.ResourceContext;
import net.webassembletool.http.HttpHeaders;
import net.webassembletool.resource.Resource;
+import net.webassembletool.util.Rfc2616;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
Modified: trunk/webassembletool-core/src/main/java/net/webassembletool/cache/CachedResponse.java
===================================================================
--- trunk/webassembletool-core/src/main/java/net/webassembletool/cache/CachedResponse.java 2011-01-21 08:54:38 UTC (rev 570)
+++ trunk/webassembletool-core/src/main/java/net/webassembletool/cache/CachedResponse.java 2011-02-14 13:30:26 UTC (rev 571)
@@ -13,6 +13,7 @@
import net.webassembletool.output.Output;
import net.webassembletool.resource.Resource;
+import net.webassembletool.util.Rfc2616;
/**
* Resource implementation that keeps the contents inside a byte array. A
Deleted: trunk/webassembletool-core/src/main/java/net/webassembletool/cache/Rfc2616.java
===================================================================
--- trunk/webassembletool-core/src/main/java/net/webassembletool/cache/Rfc2616.java 2011-01-21 08:54:38 UTC (rev 570)
+++ trunk/webassembletool-core/src/main/java/net/webassembletool/cache/Rfc2616.java 2011-02-14 13:30:26 UTC (rev 571)
@@ -1,455 +0,0 @@
-package net.webassembletool.cache;
-
-import java.io.IOException;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Map.Entry;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-import net.webassembletool.ResourceContext;
-import net.webassembletool.output.Output;
-import net.webassembletool.resource.Resource;
-
-import org.apache.commons.lang.StringUtils;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.http.impl.cookie.DateParseException;
-import org.apache.http.impl.cookie.DateUtils;
-
-/**
- * Rfc2616 caching implementation.
- *
- * @author Francois-Xavier Bonnet
- * @author Nicolas Richeton
- *
- */
-public class Rfc2616 {
- private Rfc2616() {
-
- }
-
- private static final int SECONDS = 1000;
- private static final Log LOG = LogFactory.getLog(Rfc2616.class);
-
- private final static class CacheControlResponseHeader {
- private boolean _public = false;
- private boolean _private = false;
- private boolean noCache = false;
- private boolean noStore = false;
- private boolean mustRevalidate = false;
- private boolean proxyRevalidate = false;
- private Long maxAge = null;
- private Long sMaxAge = null;
-
- private CacheControlResponseHeader() {
- // Nothing to do
- }
-
- public final static CacheControlResponseHeader parse(Resource resource) {
- String cacheControlString = resource.getHeader("Cache-control");
- if (cacheControlString == null) {
- return null;
- }
- CacheControlResponseHeader result = new CacheControlResponseHeader();
- String[] split = cacheControlString.split(",");
- for (int i = 0; i < split.length; i++) {
- String[] token = split[i].trim().split("=");
- if (token[0].equalsIgnoreCase("public")) {
- result._public = true;
- } else if (token[0].equalsIgnoreCase("private")) {
- result._private = true;
- } else if (token[0].equalsIgnoreCase("no-cache")) {
- result.noCache = true;
- } else if (token[0].equalsIgnoreCase("no-store")) {
- result.noStore = true;
- } else if (token[0].equalsIgnoreCase("must-revalidate")) {
- result.mustRevalidate = true;
- } else if (token[0].equalsIgnoreCase("proxy-revalidate")) {
- result.proxyRevalidate = true;
- } else if (token[0].equalsIgnoreCase("max-age")) {
- result.maxAge = Long.valueOf(-1);
- if (token.length == 2) {
- try {
- result.maxAge = Long.parseLong(token[1]);
- } catch (NumberFormatException e) {
- // Invalid max-age, assume -1 no cache
- }
- }
- } else if (token[0].equalsIgnoreCase("s-max-age")) {
- result.sMaxAge = Long.valueOf(-1);
- if (token.length == 2) {
- try {
- result.maxAge = Long.parseLong(token[1]);
- } catch (NumberFormatException e) {
- // Invalid max-age, assume -1 no cache
- }
- }
- }
- }
- return result;
- }
-
- }
-
- /**
- * Create a map of all headers and their values which are mentioned in the
- * Vary header of "resource".
- *
- * <p>
- * This method is used to get the headers from an existing cached resource.
- * (Cache side)
- *
- * <p>
- * When doing a new request on this resource, the cached resource can be
- * used if all headers values contained in the returned map are exactly the
- * same than the ones in the new request.
- *
- * @param resource
- * @return
- */
- public final static Map<String, String> getVary(Resource resource) {
- String varyString = resource.getHeader("Vary");
- if (varyString != null) {
- Map<String, String> result = new HashMap<String, String>();
- String[] varyStringSplit = varyString.split(",");
- for (int i = 0; i < varyStringSplit.length; i++) {
- String key = varyStringSplit[i];
- String value = resource.getRequestHeader(key);
-
- result.put(key, value);
-
- }
- return result;
- }
- return null;
- }
-
- /**
- * Create a map of all headers and their values in
- * resourceContext#getOriginalRequest() which are mentioned in the Vary
- * header of "resource".
- *
- * <p>
- * This method is used to get the headers from a new, upcoming request.
- * (Client side)
- *
- * @param resource
- * @return
- */
- public final static Map<String, String> getVary(
- ResourceContext resourceContext, Resource resource) {
- HttpServletRequest request = resourceContext.getOriginalRequest();
- String varyString = resource.getHeader("Vary");
- if (varyString != null) {
- Map<String, String> result = new HashMap<String, String>();
- String[] varyStringSplit = varyString.split(",");
- for (int i = 0; i < varyStringSplit.length; i++) {
- String key = varyStringSplit[i];
- String value = request.getHeader(key);
- if (value != null) {
- result.put(key, value);
- }
- }
- return result;
- }
- return null;
- }
-
- /**
- * Ensure that "resourceContext" matches "resource" according to the Vary
- * header of "resource". "resource" is usually a cached resource.
- *
- * @param resourceContext
- * @param resource
- * @return true if resource matches according to "Vary"
- */
- public final static boolean varyMatches(ResourceContext resourceContext,
- Resource resource) {
- Map<String, String> vary = getVary(resource);
- if (vary == null) {
- return true;
- } else {
- HttpServletRequest request = resourceContext.getOriginalRequest();
- for (Iterator<Entry<String, String>> iterator = vary.entrySet()
- .iterator(); iterator.hasNext();) {
- Entry<String, String> header = iterator.next();
- String key = header.getKey();
- String value = header.getValue();
-
- if (!StringUtils.equals(value, request.getHeader(key))) {
- return false;
- }
- }
- return true;
- }
- }
-
- public final static boolean needsValidation(
- ResourceContext resourceContext, CachedResponse resource) {
- if (resource == null) {
- return true;
- }
- return requiresRefresh(resourceContext) || isStale(resource);
- }
-
- public final static boolean isStale(Resource resource) {
- Date date = getDate(resource);
- Date expiration = getHeuristicExpiration(resource);
- if (date == null || expiration == null) {
- return true;
- }
- Date nowOnOriginServer = new Date(getAge(resource) + date.getTime());
- return (nowOnOriginServer.after(expiration));
- }
-
- /**
- * Get ETag from a resource.
- *
- * @param resource
- * Resource (not null)
- * @return etag or null
- */
- public final static String getEtag(Resource resource) {
- return resource.getHeader("Etag");
- }
-
- public final static boolean etagMatches(ResourceContext resourceContext,
- Resource resource) {
- String etag = getEtag(resource);
- if (etag == null) {
- return true;
- }
- HttpServletRequest request = resourceContext.getOriginalRequest();
- String ifNoneMatch = request.getHeader("If-none-match");
- if (ifNoneMatch == null) {
- return true;
- }
- String[] ifNoneMatchSplit = ifNoneMatch.split(",");
- for (int i = 0; i < ifNoneMatchSplit.length; i++) {
- if (ifNoneMatchSplit[i].equals(etag)) {
- return true;
- }
- }
- return false;
- }
-
- public final static Date getExpiration(Resource resource) {
- Date date = getDate(resource);
- if (date == null) {
- LOG.warn("No Date header, cannot calculate expiration.");
- return null;
- }
- Long maxAge = null;
- CacheControlResponseHeader cacheControl = CacheControlResponseHeader
- .parse(resource);
- if (cacheControl != null) {
- if (cacheControl.maxAge != null) {
- maxAge = cacheControl.maxAge;
- }
- if (cacheControl.sMaxAge != null) {
- maxAge = cacheControl.sMaxAge;
- }
- }
- if (maxAge != null) {
- // maxAge directive found according to HTTP/1.1
- // Age is in seconds. See
- // https://sourceforge.net/apps/mantisbt/webassembletool/view.php?id=17
- return new Date(date.getTime() + maxAge.longValue() * SECONDS);
-
- }
- Date expires = getDateHeader(resource, "Expires");
- if (expires != null) {
- return expires;
- }
- return null;
- }
-
- public final static Date getDate(Resource resource) {
- return getDateHeader(resource, "Date");
- }
-
- public final static Date getHeuristicExpiration(Resource resource) {
- Date expiration = getExpiration(resource);
- if (expiration != null) {
- return expiration;
- }
- Date date = getDate(resource);
- if (date == null) {
- return null;
- }
- Date lastModified = getDateHeader(resource, "Last-modified");
- // If the response does have a Last-Modified time, the heuristic
- // expiration value SHOULD be no more than some fraction of the interval
- // since that time. A typical setting of this fraction might be 10%.
- if (lastModified != null) {
- return new Date(date.getTime()
- + (date.getTime() - lastModified.getTime()) / 10);
- }
- return null;
- }
-
- public final static long getAge(Resource resource) {
- return new Date().getTime() - resource.getLocalDate().getTime();
- }
-
- public final static boolean isCacheable(Resource resource) {
- CacheControlResponseHeader cacheControl = CacheControlResponseHeader
- .parse(resource);
- if (cacheControl == null) {
- // Check expire header, if not a valid date, assume no cache
- if (resource.getHeader("Expires") != null
- && getDateHeader(resource, "Expires") == null) {
- return false;
- }
- }
- if (cacheControl._public) {
- return true;
- }
- if (cacheControl._private || cacheControl.noCache
- || cacheControl.noStore || cacheControl.mustRevalidate
- || cacheControl.proxyRevalidate || cacheControl.maxAge <= 0) {
- return false;
- }
- return true;
- }
-
- /**
- * A Resource is cacheable if the HTTP method is GET or HEAD according to
- * HTTP specification. Additionnaly, if we are not in proxy mode, the driver
- * will send a GET method as we are not proxying the original request but
- * only including an element. In that case, the response is cacheable.
- *
- * @param context
- * @return true if the resource is cacheable
- */
- public final static boolean isCacheable(ResourceContext context) {
- String method = context.getOriginalRequest().getMethod();
- return !context.isProxy() || "GET".equalsIgnoreCase(method)
- || "HEAD".equalsIgnoreCase(method);
- }
-
- public final static boolean matches(ResourceContext resourceContext,
- Resource cachedResponse) {
- String method = resourceContext.getOriginalRequest().getMethod();
-
- if (!"HEAD".equalsIgnoreCase(method)
- && !cachedResponse.hasResponseBody()) {
- return false;
- }
- if (!etagMatches(resourceContext, cachedResponse)) {
- return false;
- }
- if (!varyMatches(resourceContext, cachedResponse)) {
- return false;
- }
- return true;
- }
-
- public final static Date getDateHeader(Resource resource, String name) {
- String dateString = resource.getHeader(name);
- return convertDate(dateString);
- }
-
- public final static Date getDateHeader(ResourceContext resourceContext,
- String name) {
- String dateString = resourceContext.getOriginalRequest()
- .getHeader(name);
- return convertDate(dateString);
- }
-
- private final static Date convertDate(String dateString) {
- if (dateString != null) {
- try {
- return DateUtils.parseDate(dateString);
- } catch (DateParseException e) {
- // Ignore invalid date
- LOG.warn("Invalid date format: " + dateString);
- }
- }
- return null;
- }
-
- public final static boolean requiresRefresh(ResourceContext context) {
- HttpServletRequest originalRequest = context.getOriginalRequest();
- String pragma = originalRequest.getHeader("Pragma");
- if ("no-cache".equalsIgnoreCase(pragma)) {
- return true;
- }
- String cacheControl = originalRequest.getHeader("Cache-control");
- if (cacheControl != null) {
- cacheControl = cacheControl.toLowerCase();
- if (cacheControl.contains("no-cache")
- || cacheControl.contains("no-store")
- || cacheControl.contains("must-revalidate")
- || cacheControl.contains("max-age=0")) {
- return true;
- }
- }
- return false;
- }
-
- public final static void renderResource(Resource resource, Output output)
- throws IOException {
- if (HttpServletResponse.SC_NOT_MODIFIED == resource.getStatusCode()) {
- output.setStatusCode(resource.getStatusCode());
- copyHeaders(resource, output);
- output.open();
- output.getOutputStream();
- // No response body
- output.close();
- } else {
- resource.render(output);
- }
- }
-
- /**
- * Copies end-to-end headers from a resource to an output
- */
- public final static void copyHeaders(Resource resource, Output output) {
- copyHeader(resource, output, "Date");
- copyHeader(resource, output, "Content-Type");
- // Do not copy Content-encoding
- // Do not copy Content-length header for gzipped streams as it will
- // change ! OK this is not compliant with RFC 2616 but we need to do
- // that as we often have to modify the content of the response
- if (resource.getHeader("Content-encoding") == null) {
- copyHeader(resource, output, "Content-Length");
- }
- copyHeader(resource, output, "Last-Modified");
- copyHeader(resource, output, "ETag");
- copyHeader(resource, output, "Expires");
- copyHeader(resource, output, "Cache-control");
- // FIXME: We have to copy all headers except those that the RFC says not
- // to. For now, we just add a missing (and important) header
- // See :
- // https://sourceforge.net/apps/mantisbt/webassembletool/view.php?id=15
- copyHeader(resource, output, "Content-Disposition");
-
- // See
- // https://sourceforge.net/apps/mantisbt/webassembletool/view.php?id=18
- copyHeader(resource, output, "Vary");
- }
-
- /**
- * Copy header "name" from "resource" to "output".
- *
- * @param resource
- * source Resource
- * @param output
- * target Output
- * @param name
- * name of the header
- */
- private final static void copyHeader(Resource resource, Output output,
- String name) {
- String value = resource.getHeader(name);
- if (value != null) {
- output.setHeader(name, value);
- }
- }
-
-}
Modified: trunk/webassembletool-core/src/main/java/net/webassembletool/http/HttpResource.java
===================================================================
--- trunk/webassembletool-core/src/main/java/net/webassembletool/http/HttpResource.java 2011-01-21 08:54:38 UTC (rev 570)
+++ trunk/webassembletool-core/src/main/java/net/webassembletool/http/HttpResource.java 2011-02-14 13:30:26 UTC (rev 571)
@@ -27,12 +27,12 @@
import net.webassembletool.ResourceContext;
import net.webassembletool.UserContext;
import net.webassembletool.authentication.AuthenticationHandler;
-import net.webassembletool.cache.Rfc2616;
import net.webassembletool.filter.Filter;
import net.webassembletool.output.Output;
import net.webassembletool.output.UnsupportedContentEncodingException;
import net.webassembletool.resource.Resource;
import net.webassembletool.resource.ResourceUtils;
+import net.webassembletool.util.Rfc2616;
import org.apache.commons.io.IOUtils;
import org.apache.commons.logging.Log;
Copied: trunk/webassembletool-core/src/main/java/net/webassembletool/util/Rfc2616.java (from rev 570, trunk/webassembletool-core/src/main/java/net/webassembletool/cache/Rfc2616.java)
===================================================================
--- trunk/webassembletool-core/src/main/java/net/webassembletool/util/Rfc2616.java (rev 0)
+++ trunk/webassembletool-core/src/main/java/net/webassembletool/util/Rfc2616.java 2011-02-14 13:30:26 UTC (rev 571)
@@ -0,0 +1,430 @@
+package net.webassembletool.util;
+
+import java.io.IOException;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Map.Entry;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import net.webassembletool.ResourceContext;
+import net.webassembletool.output.Output;
+import net.webassembletool.resource.Resource;
+
+import org.apache.commons.lang.StringUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.http.impl.cookie.DateParseException;
+import org.apache.http.impl.cookie.DateUtils;
+
+/**
+ * Rfc2616 caching implementation.
+ *
+ * @author Francois-Xavier Bonnet
+ * @author Nicolas Richeton
+ *
+ */
+public class Rfc2616 {
+ private Rfc2616() {
+
+ }
+
+ private static final int SECONDS = 1000;
+ private static final Log LOG = LogFactory.getLog(Rfc2616.class);
+
+ private final static class CacheControlResponseHeader {
+ private boolean _public = false;
+ private boolean _private = false;
+ private boolean noCache = false;
+ private boolean noStore = false;
+ private boolean mustRevalidate = false;
+ private boolean proxyRevalidate = false;
+ private Long maxAge = null;
+ private Long sMaxAge = null;
+
+ private CacheControlResponseHeader() {
+ // Nothing to do
+ }
+
+ public final static CacheControlResponseHeader parse(Resource resource) {
+ String cacheControlString = resource.getHeader("Cache-control");
+ if (cacheControlString == null) {
+ return null;
+ }
+ CacheControlResponseHeader result = new CacheControlResponseHeader();
+ String[] split = cacheControlString.split(",");
+ for (int i = 0; i < split.length; i++) {
+ String[] token = split[i].trim().split("=");
+ if (token[0].equalsIgnoreCase("public")) {
+ result._public = true;
+ } else if (token[0].equalsIgnoreCase("private")) {
+ result._private = true;
+ } else if (token[0].equalsIgnoreCase("no-cache")) {
+ result.noCache = true;
+ } else if (token[0].equalsIgnoreCase("no-store")) {
+ result.noStore = true;
+ } else if (token[0].equalsIgnoreCase("must-revalidate")) {
+ result.mustRevalidate = true;
+ } else if (token[0].equalsIgnoreCase("proxy-revalidate")) {
+ result.proxyRevalidate = true;
+ } else if (token[0].equalsIgnoreCase("max-age")) {
+ result.maxAge = Long.valueOf(-1);
+ if (token.length == 2) {
+ try {
+ result.maxAge = Long.parseLong(token[1]);
+ } catch (NumberFormatException e) {
+ // Invalid max-age, assume -1 no cache
+ }
+ }
+ } else if (token[0].equalsIgnoreCase("s-max-age")) {
+ result.sMaxAge = Long.valueOf(-1);
+ if (token.length == 2) {
+ try {
+ result.maxAge = Long.parseLong(token[1]);
+ } catch (NumberFormatException e) {
+ // Invalid max-age, assume -1 no cache
+ }
+ }
+ }
+ }
+ return result;
+ }
+
+ }
+
+ /**
+ * Create a map of all headers and their values which are mentioned in the Vary header of "resource".
+ *
+ * <p>
+ * This method is used to get the headers from an existing cached resource. (Cache side)
+ *
+ * <p>
+ * When doing a new request on this resource, the cached resource can be used if all headers values contained in the
+ * returned map are exactly the same than the ones in the new request.
+ *
+ * @param resource
+ * @return
+ */
+ public final static Map<String, String> getVary(Resource resource) {
+ String varyString = resource.getHeader("Vary");
+ if (varyString != null) {
+ Map<String, String> result = new HashMap<String, String>();
+ String[] varyStringSplit = varyString.split(",");
+ for (int i = 0; i < varyStringSplit.length; i++) {
+ String key = varyStringSplit[i];
+ String value = resource.getRequestHeader(key);
+
+ result.put(key, value);
+
+ }
+ return result;
+ }
+ return null;
+ }
+
+ /**
+ * Create a map of all headers and their values in resourceContext#getOriginalRequest() which are mentioned in the
+ * Vary header of "resource".
+ *
+ * <p>
+ * This method is used to get the headers from a new, upcoming request. (Client side)
+ *
+ * @param resource
+ * @return
+ */
+ public final static Map<String, String> getVary(ResourceContext resourceContext, Resource resource) {
+ HttpServletRequest request = resourceContext.getOriginalRequest();
+ String varyString = resource.getHeader("Vary");
+ if (varyString != null) {
+ Map<String, String> result = new HashMap<String, String>();
+ String[] varyStringSplit = varyString.split(",");
+ for (int i = 0; i < varyStringSplit.length; i++) {
+ String key = varyStringSplit[i];
+ String value = request.getHeader(key);
+ if (value != null) {
+ result.put(key, value);
+ }
+ }
+ return result;
+ }
+ return null;
+ }
+
+ /**
+ * Ensure that "resourceContext" matches "resource" according to the Vary header of "resource". "resource" is
+ * usually a cached resource.
+ *
+ * @param resourceContext
+ * @param resource
+ * @return true if resource matches according to "Vary"
+ */
+ public final static boolean varyMatches(ResourceContext resourceContext, Resource resource) {
+ Map<String, String> vary = getVary(resource);
+ if (vary == null) {
+ return true;
+ } else {
+ HttpServletRequest request = resourceContext.getOriginalRequest();
+ for (Iterator<Entry<String, String>> iterator = vary.entrySet().iterator(); iterator.hasNext();) {
+ Entry<String, String> header = iterator.next();
+ String key = header.getKey();
+ String value = header.getValue();
+
+ if (!StringUtils.equals(value, request.getHeader(key))) {
+ return false;
+ }
+ }
+ return true;
+ }
+ }
+
+ public final static boolean needsValidation(ResourceContext resourceContext, Resource resource) {
+ if (resource == null) {
+ return true;
+ }
+ return requiresRefresh(resourceContext) || isStale(resource);
+ }
+
+ public final static boolean isStale(Resource resource) {
+ Date date = getDate(resource);
+ Date expiration = getHeuristicExpiration(resource);
+ if (date == null || expiration == null) {
+ return true;
+ }
+ Date nowOnOriginServer = new Date(getAge(resource) + date.getTime());
+ return (nowOnOriginServer.after(expiration));
+ }
+
+ /**
+ * Get ETag from a resource.
+ *
+ * @param resource
+ * Resource (not null)
+ * @return etag or null
+ */
+ public final static String getEtag(Resource resource) {
+ return resource.getHeader("Etag");
+ }
+
+ public final static boolean etagMatches(ResourceContext resourceContext, Resource resource) {
+ String etag = getEtag(resource);
+ if (etag == null) {
+ return true;
+ }
+ HttpServletRequest request = resourceContext.getOriginalRequest();
+ String ifNoneMatch = request.getHeader("If-none-match");
+ if (ifNoneMatch == null) {
+ return true;
+ }
+ String[] ifNoneMatchSplit = ifNoneMatch.split(",");
+ for (int i = 0; i < ifNoneMatchSplit.length; i++) {
+ if (ifNoneMatchSplit[i].equals(etag)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public final static Date getExpiration(Resource resource) {
+ Date date = getDate(resource);
+ if (date == null) {
+ LOG.warn("No Date header, cannot calculate expiration.");
+ return null;
+ }
+ Long maxAge = null;
+ CacheControlResponseHeader cacheControl = CacheControlResponseHeader.parse(resource);
+ if (cacheControl != null) {
+ if (cacheControl.maxAge != null) {
+ maxAge = cacheControl.maxAge;
+ }
+ if (cacheControl.sMaxAge != null) {
+ maxAge = cacheControl.sMaxAge;
+ }
+ }
+ if (maxAge != null) {
+ // maxAge directive found according to HTTP/1.1
+ // Age is in seconds. See
+ // https://sourceforge.net/apps/mantisbt/webassembletool/view.php?id=17
+ return new Date(date.getTime() + maxAge.longValue() * SECONDS);
+
+ }
+ Date expires = getDateHeader(resource, "Expires");
+ if (expires != null) {
+ return expires;
+ }
+ return null;
+ }
+
+ public final static Date getDate(Resource resource) {
+ return getDateHeader(resource, "Date");
+ }
+
+ public final static Date getHeuristicExpiration(Resource resource) {
+ Date expiration = getExpiration(resource);
+ if (expiration != null) {
+ return expiration;
+ }
+ Date date = getDate(resource);
+ if (date == null) {
+ return null;
+ }
+ Date lastModified = getDateHeader(resource, "Last-modified");
+ // If the response does have a Last-Modified time, the heuristic
+ // expiration value SHOULD be no more than some fraction of the interval
+ // since that time. A typical setting of this fraction might be 10%.
+ if (lastModified != null) {
+ return new Date(date.getTime() + (date.getTime() - lastModified.getTime()) / 10);
+ }
+ return null;
+ }
+
+ public final static long getAge(Resource resource) {
+ return new Date().getTime() - resource.getLocalDate().getTime();
+ }
+
+ public final static boolean isCacheable(Resource resource) {
+ CacheControlResponseHeader cacheControl = CacheControlResponseHeader.parse(resource);
+ if (cacheControl == null) {
+ // Check expire header, if not a valid date, assume no cache
+ if (resource.getHeader("Expires") != null && getDateHeader(resource, "Expires") == null) {
+ return false;
+ }
+ }
+ if (cacheControl._public) {
+ return true;
+ }
+ if (cacheControl._private || cacheControl.noCache || cacheControl.noStore || cacheControl.mustRevalidate
+ || cacheControl.proxyRevalidate || cacheControl.maxAge <= 0) {
+ return false;
+ }
+ return true;
+ }
+
+ /**
+ * A Resource is cacheable if the HTTP method is GET or HEAD according to HTTP specification. Additionnaly, if we
+ * are not in proxy mode, the driver will send a GET method as we are not proxying the original request but only
+ * including an element. In that case, the response is cacheable.
+ *
+ * @param context
+ * @return true if the resource is cacheable
+ */
+ public final static boolean isCacheable(ResourceContext context) {
+ String method = context.getOriginalRequest().getMethod();
+ return !context.isProxy() || "GET".equalsIgnoreCase(method) || "HEAD".equalsIgnoreCase(method);
+ }
+
+ public final static boolean matches(ResourceContext resourceContext, Resource cachedResponse) {
+ String method = resourceContext.getOriginalRequest().getMethod();
+
+ if (!"HEAD".equalsIgnoreCase(method) && !cachedResponse.hasResponseBody()) {
+ return false;
+ }
+ if (!etagMatches(resourceContext, cachedResponse)) {
+ return false;
+ }
+ if (!varyMatches(resourceContext, cachedResponse)) {
+ return false;
+ }
+ return true;
+ }
+
+ public final static Date getDateHeader(Resource resource, String name) {
+ String dateString = resource.getHeader(name);
+ return convertDate(dateString);
+ }
+
+ public final static Date getDateHeader(ResourceContext resourceContext, String name) {
+ String dateString = resourceContext.getOriginalRequest().getHeader(name);
+ return convertDate(dateString);
+ }
+
+ private final static Date convertDate(String dateString) {
+ if (dateString != null) {
+ try {
+ return DateUtils.parseDate(dateString);
+ } catch (DateParseException e) {
+ // Ignore invalid date
+ LOG.warn("Invalid date format: " + dateString);
+ }
+ }
+ return null;
+ }
+
+ public final static boolean requiresRefresh(ResourceContext context) {
+ HttpServletRequest originalRequest = context.getOriginalRequest();
+ String pragma = originalRequest.getHeader("Pragma");
+ if ("no-cache".equalsIgnoreCase(pragma)) {
+ return true;
+ }
+ String cacheControl = originalRequest.getHeader("Cache-control");
+ if (cacheControl != null) {
+ cacheControl = cacheControl.toLowerCase();
+ if (cacheControl.contains("no-cache") || cacheControl.contains("no-store")
+ || cacheControl.contains("must-revalidate") || cacheControl.contains("max-age=0")) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public final static void renderResource(Resource resource, Output output) throws IOException {
+ if (HttpServletResponse.SC_NOT_MODIFIED == resource.getStatusCode()) {
+ output.setStatusCode(resource.getStatusCode());
+ copyHeaders(resource, output);
+ output.open();
+ output.getOutputStream();
+ // No response body
+ output.close();
+ } else {
+ resource.render(output);
+ }
+ }
+
+ /**
+ * Copies end-to-end headers from a resource to an output
+ */
+ public final static void copyHeaders(Resource resource, Output output) {
+ copyHeader(resource, output, "Date");
+ copyHeader(resource, output, "Content-Type");
+ // Do not copy Content-encoding
+ // Do not copy Content-length header for gzipped streams as it will
+ // change ! OK this is not compliant with RFC 2616 but we need to do
+ // that as we often have to modify the content of the response
+ if (resource.getHeader("Content-encoding") == null) {
+ copyHeader(resource, output, "Content-Length");
+ }
+ copyHeader(resource, output, "Last-Modified");
+ copyHeader(resource, output, "ETag");
+ copyHeader(resource, output, "Expires");
+ copyHeader(resource, output, "Cache-control");
+ // FIXME: We have to copy all headers except those that the RFC says not
+ // to. For now, we just add a missing (and important) header
+ // See :
+ // https://sourceforge.net/apps/mantisbt/webassembletool/view.php?id=15
+ copyHeader(resource, output, "Content-Disposition");
+
+ // See
+ // https://sourceforge.net/apps/mantisbt/webassembletool/view.php?id=18
+ copyHeader(resource, output, "Vary");
+ }
+
+ /**
+ * Copy header "name" from "resource" to "output".
+ *
+ * @param resource
+ * source Resource
+ * @param output
+ * target Output
+ * @param name
+ * name of the header
+ */
+ private final static void copyHeader(Resource resource, Output output, String name) {
+ String value = resource.getHeader(name);
+ if (value != null) {
+ output.setHeader(name, value);
+ }
+ }
+
+}
Deleted: trunk/webassembletool-core/src/test/java/net/webassembletool/cache/Rfc2616Test.java
===================================================================
--- trunk/webassembletool-core/src/test/java/net/webassembletool/cache/Rfc2616Test.java 2011-01-21 08:54:38 UTC (rev 570)
+++ trunk/webassembletool-core/src/test/java/net/webassembletool/cache/Rfc2616Test.java 2011-02-14 13:30:26 UTC (rev 571)
@@ -1,67 +0,0 @@
-package net.webassembletool.cache;
-
-import java.io.IOException;
-import java.util.Date;
-
-import junit.framework.TestCase;
-import net.webassembletool.output.Output;
-import net.webassembletool.resource.Resource;
-
-import org.apache.http.impl.cookie.DateUtils;
-
-/**
- * Tests for RFC2616 handling.
- *
- * @author Nicolas Richeton
- *
- */
-public class Rfc2616Test extends TestCase {
-
- /**
- * Ensure max-date is correctly used (in seconds). See
- * https://sourceforge.net/apps/mantisbt/webassembletool/view.php?id=17
- */
- public void test_getExpiration() {
-
- final Date now = new Date();
-
- Resource r = new Resource() {
-
- @Override
- public void render(Output output) throws IOException {
- }
-
- @Override
- public void release() {
- }
-
- @Override
- public int getStatusCode() {
- return 200;
- }
-
- @Override
- public String getHeader(String name) {
- if (name.equals("Cache-control")) {
- return "max-age=60";
- }
-
- if (name.equals("Date")) {
- return DateUtils.formatDate(now);
- }
-
- return null;
- }
-
- };
-
- Date d = Rfc2616.getExpiration(r);
- assertTrue(d.after(now));
-
- // Distance will not be exactly 60000.
- long distance = (d.getTime() - now.getTime());
- assertTrue(distance > 59000 && distance < 61000);
-
- }
-
-}
Copied: trunk/webassembletool-core/src/test/java/net/webassembletool/util/Rfc2616Test.java (from rev 570, trunk/webassembletool-core/src/test/java/net/webassembletool/cache/Rfc2616Test.java)
===================================================================
--- trunk/webassembletool-core/src/test/java/net/webassembletool/util/Rfc2616Test.java (rev 0)
+++ trunk/webassembletool-core/src/test/java/net/webassembletool/util/Rfc2616Test.java 2011-02-14 13:30:26 UTC (rev 571)
@@ -0,0 +1,67 @@
+package net.webassembletool.util;
+
+import java.io.IOException;
+import java.util.Date;
+
+import junit.framework.TestCase;
+import net.webassembletool.output.Output;
+import net.webassembletool.resource.Resource;
+
+import org.apache.http.impl.cookie.DateUtils;
+
+/**
+ * Tests for RFC2616 handling.
+ *
+ * @author Nicolas Richeton
+ *
+ */
+public class Rfc2616Test extends TestCase {
+
+ /**
+ * Ensure max-date is correctly used (in seconds). See
+ * https://sourceforge.net/apps/mantisbt/webassembletool/view.php?id=17
+ */
+ public void test_getExpiration() {
+
+ final Date now = new Date();
+
+ Resource r = new Resource() {
+
+ @Override
+ public void render(Output output) throws IOException {
+ }
+
+ @Override
+ public void release() {
+ }
+
+ @Override
+ public int getStatusCode() {
+ return 200;
+ }
+
+ @Override
+ public String getHeader(String name) {
+ if (name.equals("Cache-control")) {
+ return "max-age=60";
+ }
+
+ if (name.equals("Date")) {
+ return DateUtils.formatDate(now);
+ }
+
+ return null;
+ }
+
+ };
+
+ Date d = Rfc2616.getExpiration(r);
+ assertTrue(d.after(now));
+
+ // Distance will not be exactly 60000.
+ long distance = (d.getTime() - now.getTime());
+ assertTrue(distance > 59000 && distance < 61000);
+
+ }
+
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ath...@us...> - 2011-01-21 08:54:44
|
Revision: 570
http://webassembletool.svn.sourceforge.net/webassembletool/?rev=570&view=rev
Author: athaveau
Date: 2011-01-21 08:54:38 +0000 (Fri, 21 Jan 2011)
Log Message:
-----------
revert to previous site url (sftp)
Modified Paths:
--------------
trunk/pom.xml
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2011-01-20 16:01:47 UTC (rev 569)
+++ trunk/pom.xml 2011-01-21 08:54:38 UTC (rev 570)
@@ -379,7 +379,8 @@
<site>
<id>webassembletool-site</id>
<name>ESIGate</name>
- <url>scp://shell.sourceforge.net/home/groups/w/we/webassembletool/htdocs</url>
+ <url>sftp://web.sourceforge.net/home/groups/w/we/webassembletool/htdocs</url>
+ <!--<url>scp://shell.sourceforge.net/home/groups/w/we/webassembletool/htdocs</url>-->
</site>
</distributionManagement>
<properties>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ath...@us...> - 2011-01-20 16:01:54
|
Revision: 569
http://webassembletool.svn.sourceforge.net/webassembletool/?rev=569&view=rev
Author: athaveau
Date: 2011-01-20 16:01:47 +0000 (Thu, 20 Jan 2011)
Log Message:
-----------
Fix Url to http://www.esigate.org
Modified Paths:
--------------
trunk/pom.xml
trunk/src/main/resources/README.txt
trunk/src/site/resources/examples/templates/sparkle/index.html
trunk/src/site/resources/sitemap.xml
trunk/src/site/site.xml
trunk/src/site/xdoc/maven.xml
trunk/webassembletool-core/src/test/java/net/webassembletool/cache/MemoryOutputTest.java
trunk/webassembletool-maven/webassembletool-staticassembly-plugin/src/site/xdoc/usage.xml
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2010-12-15 10:41:22 UTC (rev 568)
+++ trunk/pom.xml 2011-01-20 16:01:47 UTC (rev 569)
@@ -49,7 +49,7 @@
<unsubscribe>https://lists.sourceforge.net/lists/listinfo/webassembletool-commits</unsubscribe>
</mailingList>
</mailingLists>
- <url>http://webassembletool.sourceforge.net/</url>
+ <url>http://www.esigate.org/</url>
<licenses>
<license>
<name>Apache Software License</name>
@@ -379,7 +379,7 @@
<site>
<id>webassembletool-site</id>
<name>ESIGate</name>
- <url>sftp://web.sourceforge.net/home/groups/w/we/webassembletool/htdocs</url>
+ <url>scp://shell.sourceforge.net/home/groups/w/we/webassembletool/htdocs</url>
</site>
</distributionManagement>
<properties>
Modified: trunk/src/main/resources/README.txt
===================================================================
--- trunk/src/main/resources/README.txt 2010-12-15 10:41:22 UTC (rev 568)
+++ trunk/src/main/resources/README.txt 2011-01-20 16:01:47 UTC (rev 569)
@@ -4,4 +4,4 @@
- src: the source files for the project
See the documentation for further information:
-http://webassembletool.sourceforge.net
\ No newline at end of file
+http://www.esigate.org
\ No newline at end of file
Modified: trunk/src/site/resources/examples/templates/sparkle/index.html
===================================================================
--- trunk/src/site/resources/examples/templates/sparkle/index.html 2010-12-15 10:41:22 UTC (rev 568)
+++ trunk/src/site/resources/examples/templates/sparkle/index.html 2011-01-20 16:01:47 UTC (rev 569)
@@ -23,7 +23,7 @@
</head>
<body>
<div id="header">
- <h1><a href="http://webassembletool.sourceforge.net/">Web Assemble Tool</a></h1>
+ <h1><a href="http://www.esigate.org/">Web Assemble Tool</a></h1>
<h2><a href="http://freecsstemplates.org/">Template is : Sparkle by Free Css Templates </a></h2>
</div>
<div id="menu">
Modified: trunk/src/site/resources/sitemap.xml
===================================================================
--- trunk/src/site/resources/sitemap.xml 2010-12-15 10:41:22 UTC (rev 568)
+++ trunk/src/site/resources/sitemap.xml 2011-01-20 16:01:47 UTC (rev 569)
@@ -1,12 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.google.com/schemas/sitemap/0.84">
<url>
- <loc>http://webassembletool.sourceforge.net/</loc>
+ <loc>http://www.esigate.org/</loc>
<changefreq>weekly</changefreq>
<priority>0.8</priority>
</url>
<url>
- <loc>http://webassembletool.sourceforge.net/index.html</loc>
+ <loc>http://www.esigate.org/index.html</loc>
<changefreq>weekly</changefreq>
<priority>0.0</priority>
</url>
Modified: trunk/src/site/site.xml
===================================================================
--- trunk/src/site/site.xml 2010-12-15 10:41:22 UTC (rev 568)
+++ trunk/src/site/site.xml 2011-01-20 16:01:47 UTC (rev 569)
@@ -34,7 +34,7 @@
<links>
<item name="Maven repo"
- href="http://webassembletool.sourceforge.net/maven/repository/" />
+ href="http://www.esigate.org/maven/repository/" />
<item name="Change log"
href="https://sourceforge.net/apps/mantisbt/webassembletool/changelog_page.php" />
<item name="Roadmap"
Modified: trunk/src/site/xdoc/maven.xml
===================================================================
--- trunk/src/site/xdoc/maven.xml 2010-12-15 10:41:22 UTC (rev 568)
+++ trunk/src/site/xdoc/maven.xml 2011-01-20 16:01:47 UTC (rev 569)
@@ -20,7 +20,7 @@
<repository>
<id>webassembletool-repository</id>
<name>Website Assembling Toolkit repository</name>
- <url>http://webassembletool.sourceforge.net/maven/repository</url>
+ <url>http://www.esigate.org/maven/repository</url>
</repository>
]]></source>
</section>
Modified: trunk/webassembletool-core/src/test/java/net/webassembletool/cache/MemoryOutputTest.java
===================================================================
--- trunk/webassembletool-core/src/test/java/net/webassembletool/cache/MemoryOutputTest.java 2010-12-15 10:41:22 UTC (rev 568)
+++ trunk/webassembletool-core/src/test/java/net/webassembletool/cache/MemoryOutputTest.java 2011-01-20 16:01:47 UTC (rev 569)
@@ -36,7 +36,7 @@
assertNull(memoryOutput.toResource());
// Size =0 (means no limit) : content is written
- // see http://webassembletool.sourceforge.net/configuration.html
+ // see http://www.esigate.org/configuration.html
memoryOutput = new CacheOutput(0);
memoryOutput.setCharsetName(CHARSET);
memoryOutput.open();
Modified: trunk/webassembletool-maven/webassembletool-staticassembly-plugin/src/site/xdoc/usage.xml
===================================================================
--- trunk/webassembletool-maven/webassembletool-staticassembly-plugin/src/site/xdoc/usage.xml 2010-12-15 10:41:22 UTC (rev 568)
+++ trunk/webassembletool-maven/webassembletool-staticassembly-plugin/src/site/xdoc/usage.xml 2011-01-20 16:01:47 UTC (rev 569)
@@ -26,7 +26,7 @@
The simplest way is to generate your project with the archetype :
<source><![CDATA[
mvn archetype:generate
- -DarchetypeRepository=http://webassembletool.sourceforge.net/maven/repository
+ -DarchetypeRepository=http://www.esigate.org/maven/repository
-DarchetypeArtifactId=webassembletool-staticassembly-archetype
-DarchetypeGroupId=net.sourceforge.webassembletool.maven -DarchetypeVersion=RELEASE
]]></source>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ath...@us...> - 2010-12-15 10:41:28
|
Revision: 568
http://webassembletool.svn.sourceforge.net/webassembletool/?rev=568&view=rev
Author: athaveau
Date: 2010-12-15 10:41:22 +0000 (Wed, 15 Dec 2010)
Log Message:
-----------
update parsableContentTypes comments
Modified Paths:
--------------
trunk/src/site/xdoc/configuration.xml
Modified: trunk/src/site/xdoc/configuration.xml
===================================================================
--- trunk/src/site/xdoc/configuration.xml 2010-12-15 09:23:42 UTC (rev 567)
+++ trunk/src/site/xdoc/configuration.xml 2010-12-15 10:41:22 UTC (rev 568)
@@ -55,7 +55,8 @@
</tr>
<tr>
<td>parsableContentTypes</td>
- <td>List of parsable content types. By default, parsable content types are text/html and application/xhtml+xml.
+ <td>List of parsable content types. By default, parsable content types are text/html and application/xhtml+xml.
+ Use this syntax to set content types :
<code>parsableContentTypes=text/html,application/xhtml+xml,text/plain</code>
</td>
<td>No</td>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ath...@us...> - 2010-12-15 09:23:49
|
Revision: 567
http://webassembletool.svn.sourceforge.net/webassembletool/?rev=567&view=rev
Author: athaveau
Date: 2010-12-15 09:23:42 +0000 (Wed, 15 Dec 2010)
Log Message:
-----------
Add parsableContentTypes configuration (https://sourceforge.net/apps/mantisbt/webassembletool/view.php?id=38)
Modified Paths:
--------------
trunk/src/site/xdoc/configuration.xml
trunk/webassembletool-core/src/main/java/net/webassembletool/Driver.java
trunk/webassembletool-core/src/main/java/net/webassembletool/DriverConfiguration.java
trunk/webassembletool-core/src/main/java/net/webassembletool/http/HttpResource.java
trunk/webassembletool-core/src/main/java/net/webassembletool/output/TextOnlyStringOutput.java
trunk/webassembletool-core/src/main/java/net/webassembletool/resource/ResourceUtils.java
trunk/webassembletool-core/src/test/java/net/webassembletool/resource/ResourceUtilsTest.java
Added Paths:
-----------
trunk/webassembletool-core/src/test/java/net/webassembletool/DriverConfigurationTest.java
Modified: trunk/src/site/xdoc/configuration.xml
===================================================================
--- trunk/src/site/xdoc/configuration.xml 2010-11-30 12:05:46 UTC (rev 566)
+++ trunk/src/site/xdoc/configuration.xml 2010-12-15 09:23:42 UTC (rev 567)
@@ -53,6 +53,14 @@
<td>No</td>
<td>20</td>
</tr>
+ <tr>
+ <td>parsableContentTypes</td>
+ <td>List of parsable content types. By default, parsable content types are text/html and application/xhtml+xml.
+ <code>parsableContentTypes=text/html,application/xhtml+xml,text/plain</code>
+ </td>
+ <td>No</td>
+ <td>text/html,application/xhtml+xml</td>
+ </tr>
<tr>
<td>timeout</td>
<td>Timeout while establishing a connection with the server
Modified: trunk/webassembletool-core/src/main/java/net/webassembletool/Driver.java
===================================================================
--- trunk/webassembletool-core/src/main/java/net/webassembletool/Driver.java 2010-11-30 12:05:46 UTC (rev 566)
+++ trunk/webassembletool-core/src/main/java/net/webassembletool/Driver.java 2010-12-15 09:23:42 UTC (rev 567)
@@ -451,7 +451,8 @@
renderResource(resourceContext, new ResponseOutput(response));
} else {
// Directly stream out non text data
- TextOnlyStringOutput textOutput = new TextOnlyStringOutput(response);
+ TextOnlyStringOutput textOutput = new TextOnlyStringOutput(
+ response, this.config.getParsableContentTypes());
renderResource(resourceContext, textOutput);
// If data was binary, no text buffer is available and no rendering
// is needed.
Modified: trunk/webassembletool-core/src/main/java/net/webassembletool/DriverConfiguration.java
===================================================================
--- trunk/webassembletool-core/src/main/java/net/webassembletool/DriverConfiguration.java 2010-11-30 12:05:46 UTC (rev 566)
+++ trunk/webassembletool-core/src/main/java/net/webassembletool/DriverConfiguration.java 2010-12-15 09:23:42 UTC (rev 567)
@@ -14,7 +14,10 @@
*/
package net.webassembletool;
+import java.util.ArrayList;
+import java.util.List;
import java.util.Properties;
+import java.util.StringTokenizer;
import net.webassembletool.authentication.RemoteUserAuthenticationHandler;
import net.webassembletool.cookie.SerializableBasicCookieStore;
@@ -43,15 +46,15 @@
private String proxyHost;
private int proxyPort = 0;
private boolean filterJsessionid = true;
- private String authenticationHandler = RemoteUserAuthenticationHandler.class.getName();
+ private String authenticationHandler = RemoteUserAuthenticationHandler.class
+ .getName();
private final Properties properties;
private boolean preserveHost = false;
private String cookieStore = SerializableBasicCookieStore.class.getName();
private String filter = null;
+ private final List<String> parsableContentTypes;
- public String getFilter() {
- return filter;
- }
+ private static String DEFAULT_PARSABLE_CONTENT_TYPES = "text/html, application/xhtml+xml";
public DriverConfiguration(String instanceName, Properties props) {
this.instanceName = instanceName;
@@ -132,10 +135,25 @@
visibleBaseURL = baseURL;
}
}
+ // Parsable content types
+ String strContentTypes = props.getProperty("parsableContentTypes",
+ DEFAULT_PARSABLE_CONTENT_TYPES);
+ StringTokenizer tokenizer = new StringTokenizer(strContentTypes, ",");
+ String contentType;
+ parsableContentTypes = new ArrayList<String>();
+ while (tokenizer.hasMoreElements()) {
+ contentType = tokenizer.nextToken();
+ contentType = contentType.trim();
+ parsableContentTypes.add(contentType);
+ }
properties = props;
}
+ public String getFilter() {
+ return filter;
+ }
+
public int getFixMode() {
return fixMode;
}
@@ -220,4 +238,14 @@
return cookieStore;
}
+ /**
+ * List of parsable content types. Default is text/html,
+ * application/xhtml+xml
+ *
+ * @return
+ */
+ public List<String> getParsableContentTypes() {
+ return parsableContentTypes;
+ }
+
}
Modified: trunk/webassembletool-core/src/main/java/net/webassembletool/http/HttpResource.java
===================================================================
--- trunk/webassembletool-core/src/main/java/net/webassembletool/http/HttpResource.java 2010-11-30 12:05:46 UTC (rev 566)
+++ trunk/webassembletool-core/src/main/java/net/webassembletool/http/HttpResource.java 2010-12-15 09:23:42 UTC (rev 567)
@@ -214,9 +214,9 @@
private void removeSessionId(InputStream inputStream, Output output)
throws IOException {
String jsessionid = RewriteUtils.getSessionId(target);
- boolean textContentType = ResourceUtils
- .isTextContentType(httpClientResponse
- .getHeader(HttpHeaders.CONTENT_TYPE));
+ boolean textContentType = ResourceUtils.isTextContentType(
+ httpClientResponse.getHeader(HttpHeaders.CONTENT_TYPE), target
+ .getDriver().getConfiguration().getParsableContentTypes());
if (jsessionid == null || !textContentType) {
IOUtils.copy(inputStream, output.getOutputStream());
} else {
Modified: trunk/webassembletool-core/src/main/java/net/webassembletool/output/TextOnlyStringOutput.java
===================================================================
--- trunk/webassembletool-core/src/main/java/net/webassembletool/output/TextOnlyStringOutput.java 2010-11-30 12:05:46 UTC (rev 566)
+++ trunk/webassembletool-core/src/main/java/net/webassembletool/output/TextOnlyStringOutput.java 2010-12-15 09:23:42 UTC (rev 567)
@@ -5,6 +5,7 @@
import java.io.OutputStream;
import java.io.UnsupportedEncodingException;
import java.util.Iterator;
+import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletResponse;
@@ -32,9 +33,12 @@
private ByteArrayOutputStream byteArrayOutputStream;
private OutputStream outputStream;
private boolean text = false;
+ private final List<String> contentTypes;
- public TextOnlyStringOutput(HttpServletResponse response) {
+ public TextOnlyStringOutput(HttpServletResponse response,
+ List<String> contentTypes) {
this.response = response;
+ this.contentTypes = contentTypes;
}
/**
@@ -55,7 +59,8 @@
@Override
public void open() {
response.setStatus(getStatusCode());
- if (ResourceUtils.isTextContentType(getHeader("Content-Type"))) {
+ if (ResourceUtils.isTextContentType(getHeader("Content-Type"),
+ this.contentTypes)) {
text = true;
}
copyHeaders();
Modified: trunk/webassembletool-core/src/main/java/net/webassembletool/resource/ResourceUtils.java
===================================================================
--- trunk/webassembletool-core/src/main/java/net/webassembletool/resource/ResourceUtils.java 2010-11-30 12:05:46 UTC (rev 566)
+++ trunk/webassembletool-core/src/main/java/net/webassembletool/resource/ResourceUtils.java 2010-12-15 09:23:42 UTC (rev 567)
@@ -3,11 +3,13 @@
import java.io.File;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
+import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import javax.servlet.http.HttpSession;
+import net.webassembletool.DriverConfiguration;
import net.webassembletool.ResourceContext;
import net.webassembletool.http.RewriteUtils;
@@ -58,8 +60,8 @@
queryString.append(originalQuerystring);
}
if (target.getParameters() != null) {
- ResourceUtils.appendParameters(queryString, charset, target
- .getParameters());
+ ResourceUtils.appendParameters(queryString, charset,
+ target.getParameters());
}
return queryString.toString();
} catch (UnsupportedEncodingException e) {
@@ -69,19 +71,27 @@
/**
* Check whether the given content-type value corresponds to "parsable"
- * text. "Parsable" text is actually html/xhtml
+ * text. Content types parsable are
+ * {@link DriverConfiguration#getParsableContentTypes()}
*
* @param contentType
* the value of http header Content-Type
* @return true if this represents text or false if not
*/
- public static boolean isTextContentType(String contentType) {
- if (contentType == null) {
- return false;
+ public static boolean isTextContentType(String contentType,
+ List<String> textContentTypes) {
+ boolean isText = false;
+
+ if (contentType != null) {
+ String lowerContentType = contentType.toLowerCase();
+ for (String textContentType : textContentTypes) {
+ if (lowerContentType.startsWith(textContentType)) {
+ isText = true;
+ break;
+ }
+ }
}
- String lowerContentType = contentType.toLowerCase();
- return (lowerContentType.startsWith("text/html") || lowerContentType
- .startsWith("application/xhtml+xml"));
+ return isText;
}
private static void appendParameters(StringBuilder buf, String charset,
Added: trunk/webassembletool-core/src/test/java/net/webassembletool/DriverConfigurationTest.java
===================================================================
--- trunk/webassembletool-core/src/test/java/net/webassembletool/DriverConfigurationTest.java (rev 0)
+++ trunk/webassembletool-core/src/test/java/net/webassembletool/DriverConfigurationTest.java 2010-12-15 09:23:42 UTC (rev 567)
@@ -0,0 +1,75 @@
+package net.webassembletool;
+
+import java.util.Properties;
+
+import junit.framework.TestCase;
+
+/**
+ * DriverConfiguration test case.
+ *
+ * @author Alexis Thaveau
+ *
+ */
+public class DriverConfigurationTest extends TestCase {
+
+ DriverConfiguration defaultConfig;
+
+ @Override
+ protected void setUp() throws Exception {
+ defaultConfig = new DriverConfiguration("test", new Properties());
+
+ }
+
+ /**
+ * Test default configuration
+ */
+ public void testDefaultConfig() {
+ // Parsable contentTypes
+ assertTrue("text/html is not in default parsable cotent-types",
+ defaultConfig.getParsableContentTypes().contains("text/html"));
+ assertTrue(
+ "application/xhtml+xml is not in default parsable cotent-types",
+ defaultConfig.getParsableContentTypes().contains(
+ "application/xhtml+xml"));
+
+ }
+
+ /**
+ * Test property parsableContentTypes
+ */
+ public void testParsableContentTypes() {
+ Properties properties = new Properties();
+ properties.put("parsableContentTypes", "text/plain");
+ DriverConfiguration config = new DriverConfiguration("test-parsable",
+ properties);
+ assertEquals("parsableContentTypes should contains only 1 element", 1,
+ config.getParsableContentTypes().size());
+ assertEquals("parsableContentTypes should contains text/plain",
+ "text/plain", config.getParsableContentTypes().get(0));
+
+ properties = new Properties();
+ properties.put("parsableContentTypes", "text/plain, text/html");
+ config = new DriverConfiguration("test-parsable", properties);
+ assertEquals("parsableContentTypes should contains only 2 elements", 2,
+ config.getParsableContentTypes().size());
+ assertEquals("parsableContentTypes should contains text/plain",
+ "text/plain", config.getParsableContentTypes().get(0));
+
+ assertEquals("parsableContentTypes should contains text/html",
+ "text/html", config.getParsableContentTypes().get(1));
+
+ properties = new Properties();
+ properties.put("parsableContentTypes",
+ "text/plain, text/html,application/x");
+ config = new DriverConfiguration("test-parsable", properties);
+ assertEquals("parsableContentTypes should contains only 3 elements", 3,
+ config.getParsableContentTypes().size());
+ assertEquals("parsableContentTypes should contains text/plain",
+ "text/plain", config.getParsableContentTypes().get(0));
+ assertEquals("parsableContentTypes should contains text/html",
+ "text/html", config.getParsableContentTypes().get(1));
+ assertEquals("parsableContentTypes should contains application/x",
+ "application/x", config.getParsableContentTypes().get(2));
+
+ }
+}
Modified: trunk/webassembletool-core/src/test/java/net/webassembletool/resource/ResourceUtilsTest.java
===================================================================
--- trunk/webassembletool-core/src/test/java/net/webassembletool/resource/ResourceUtilsTest.java 2010-11-30 12:05:46 UTC (rev 566)
+++ trunk/webassembletool-core/src/test/java/net/webassembletool/resource/ResourceUtilsTest.java 2010-12-15 09:23:42 UTC (rev 567)
@@ -6,6 +6,7 @@
import junit.framework.TestCase;
import net.webassembletool.Driver;
+import net.webassembletool.DriverConfiguration;
import net.webassembletool.ResourceContext;
import org.easymock.EasyMock;
@@ -27,9 +28,10 @@
null, request, null);
resourceContext.setProxy(true);
EasyMock.replay(request);
- assertEquals("http://www.foo.com/test", ResourceUtils
- .getHttpUrlWithQueryString(resourceContext));
+ assertEquals("http://www.foo.com/test",
+ ResourceUtils.getHttpUrlWithQueryString(resourceContext));
}
+
public void testGetHttpUrlWithQueryStringAbsoluteurl() {
Properties props = new Properties();
props.put("remoteUrlBase", "http://www.foo.com/");
@@ -41,12 +43,34 @@
"ISO-8859-1");
EasyMock.expect(request.getQueryString()).andReturn(null);
EasyMock.expect(request.getSession(false)).andReturn(null);
- ResourceContext resourceContext = new ResourceContext(driver, "http://www.bar.com/test",
- null, request, null);
+ ResourceContext resourceContext = new ResourceContext(driver,
+ "http://www.bar.com/test", null, request, null);
resourceContext.setProxy(true);
EasyMock.replay(request);
- assertEquals("http://www.bar.com/test", ResourceUtils
- .getHttpUrlWithQueryString(resourceContext));
+ assertEquals("http://www.bar.com/test",
+ ResourceUtils.getHttpUrlWithQueryString(resourceContext));
}
+ public void testIsTextContentType() {
+ DriverConfiguration config = new DriverConfiguration("test",
+ new Properties());
+ assertTrue(ResourceUtils.isTextContentType("text/html",
+ config.getParsableContentTypes()));
+
+ assertTrue(ResourceUtils.isTextContentType("application/xhtml+xml",
+ config.getParsableContentTypes()));
+
+ assertFalse(ResourceUtils.isTextContentType("text/plain",
+ config.getParsableContentTypes()));
+
+ Properties properties = new Properties();
+ properties.setProperty("parsableContentTypes", "text/plain");
+
+ config = new DriverConfiguration("test", properties);
+ assertTrue(ResourceUtils.isTextContentType("text/plain",
+ config.getParsableContentTypes()));
+ assertFalse(ResourceUtils.isTextContentType("text/html",
+ config.getParsableContentTypes()));
+
+ }
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <nri...@us...> - 2010-11-30 12:05:52
|
Revision: 566
http://webassembletool.svn.sourceforge.net/webassembletool/?rev=566&view=rev
Author: nricheton
Date: 2010-11-30 12:05:46 +0000 (Tue, 30 Nov 2010)
Log Message:
-----------
Improved site. Added web-analytics.
Modified Paths:
--------------
trunk/pom.xml
trunk/src/site/site.xml
trunk/src/site/xdoc/index.xml
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2010-11-29 09:10:17 UTC (rev 565)
+++ trunk/pom.xml 2010-11-30 12:05:46 UTC (rev 566)
@@ -56,7 +56,7 @@
<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
</license>
</licenses>
- <description>ESIGate</description>
+ <description>ESIGate - ESI reverse proxy, CMS integration, Remove templating</description>
<issueManagement>
<system>MantisBT</system>
<url>https://sourceforge.net/apps/mantisbt/webassembletool/view_all_bug_page.php</url>
Modified: trunk/src/site/site.xml
===================================================================
--- trunk/src/site/site.xml 2010-11-29 09:10:17 UTC (rev 565)
+++ trunk/src/site/site.xml 2010-11-30 12:05:46 UTC (rev 566)
@@ -1,25 +1,47 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
-<project name="ESIGate">
- <skin>
- <groupId>net.sourceforge.webassembletool.maven</groupId>
- <artifactId>webassembletool-maven-skin</artifactId>
- <version>${project.version}</version>
- </skin>
- <version position="left"/>
+<project name="ESIGate - ESI reverse proxy, CMS integration, Remove templating">
+ <skin>
+ <groupId>net.sourceforge.webassembletool.maven</groupId>
+ <artifactId>webassembletool-maven-skin</artifactId>
+ <version>${project.version}</version>
+ </skin>
+ <version position="left" />
+
<bannerLeft>
<name>ESIGate</name>
<src>images/logo.jpg</src>
<href>http://sourceforge.net/projects/webassembletool</href>
- <alt>Get ESIGate at SourceForge.net. Fast, secure and Free Open Source software downloads</alt>
+ <alt>Get ESIGate at SourceForge.net. Fast, secure and Free Open Source
+ software downloads</alt>
</bannerLeft>
<body>
- <links>
- <item name="Maven repo" href="http://webassembletool.sourceforge.net/maven/repository/" />
- <item name="Change log" href="https://sourceforge.net/apps/mantisbt/webassembletool/changelog_page.php"/>
- <item name="Roadmap" href="https://sourceforge.net/apps/mantisbt/webassembletool/roadmap_page.php"/>
- <item name="Stats (ohloh)" href="http://www.ohloh.net/p/webassembletool"/>
- </links>
-
+ <head>
+ <script type="text/javascript">
+
+ var _gaq = _gaq || [];
+ _gaq.push(['_setAccount', 'UA-8756343-2']);
+ _gaq.push(['_trackPageview']);
+
+ (function() {
+ var ga = document.createElement('script'); ga.type = 'text/javascript';
+ ga.async = true;
+ ga.src = ('https:' == document.location.protocol ? 'https://ssl' :
+ 'http://www') + '.google-analytics.com/ga.js';
+ var s = document.getElementsByTagName('script')[0];
+ s.parentNode.insertBefore(ga, s);
+ })();</script>
+ </head>
+
+ <links>
+ <item name="Maven repo"
+ href="http://webassembletool.sourceforge.net/maven/repository/" />
+ <item name="Change log"
+ href="https://sourceforge.net/apps/mantisbt/webassembletool/changelog_page.php" />
+ <item name="Roadmap"
+ href="https://sourceforge.net/apps/mantisbt/webassembletool/roadmap_page.php" />
+ <item name="Stats (ohloh)" href="http://www.ohloh.net/p/webassembletool" />
+ </links>
+
<menu name="About">
<item href="index.html" name="Overview" />
<item href="features.html" name="Features" />
@@ -46,13 +68,14 @@
<item href="maven.html" name="Maven" />
<item href="external-resources.html" name="External resources" />
</menu>
-
+
<menu name="Community">
- <item href="http://sourceforge.net/apps/mediawiki/webassembletool/" name="FAQ (Wiki)" />
+ <item href="http://sourceforge.net/apps/mediawiki/webassembletool/"
+ name="FAQ (Wiki)" />
<item href="http://sourceforge.net/projects/webassembletool/"
name="SourceForge" />
</menu>
-
+
<menu ref="reports" />
<menu ref="modules" />
Modified: trunk/src/site/xdoc/index.xml
===================================================================
--- trunk/src/site/xdoc/index.xml 2010-11-29 09:10:17 UTC (rev 565)
+++ trunk/src/site/xdoc/index.xml 2010-11-30 12:05:46 UTC (rev 566)
@@ -3,15 +3,23 @@
<properties>
<title>Overview</title>
<author email="fxb...@us...">Francois-Xavier Bonnet</author>
+ <author email="nic...@gm...">Nicolas Richeton</author>
</properties>
<body>
<h1>Overview</h1>
<section name="ESIGate (Website Assembling Toolkit)">
<p>
- ESIGate (formerly known as "Website Assembling Toolkit")is a toolkit developped to help developpers to integrate
+ ESIGate (formerly known as "Website Assembling Toolkit") is a toolkit developed to help developers to integrate
existing web applications and aggregate them as
a single website.
</p>
+ <ul>
+ <li><b>ESI reverse proxy</b> : speed up your website using standard or custom (enhanced) ESI syntax.</li>
+ <li><b>CMS integration</b> : include dynamic content from any CMS or website in your application easily.</li>
+ <li><b>Remote templating</b> : use a remote template instead of embedded files and be able to completely change design (not only CSS) on the fly.</li>
+ <li><b>All together</b> : combine and assemble multiple applications into a single, fast, modular and standard-compliant one.</li>
+ <li>Can be used stand-alone with any application or embedded in Java applications (JSP, JSF, Wicket and API support))</li>
+ </ul>
</section>
<section name="Reverse proxy and ESI processor">
<p>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <nri...@us...> - 2010-11-29 09:10:23
|
Revision: 565
http://webassembletool.svn.sourceforge.net/webassembletool/?rev=565&view=rev
Author: nricheton
Date: 2010-11-29 09:10:17 +0000 (Mon, 29 Nov 2010)
Log Message:
-----------
Fixed blog name
Modified Paths:
--------------
trunk/src/site/xdoc/external-resources.xml
Modified: trunk/src/site/xdoc/external-resources.xml
===================================================================
--- trunk/src/site/xdoc/external-resources.xml 2010-11-28 18:50:40 UTC (rev 564)
+++ trunk/src/site/xdoc/external-resources.xml 2010-11-29 09:10:17 UTC (rev 565)
@@ -11,7 +11,7 @@
<subsection name="Tutorials">
<ul>
<li>
- Le blog de Nicolas Richeton
+ Nicolas Richeton
<ul>
<li>
<a
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <nri...@us...> - 2010-11-28 18:50:46
|
Revision: 564
http://webassembletool.svn.sourceforge.net/webassembletool/?rev=564&view=rev
Author: nricheton
Date: 2010-11-28 18:50:40 +0000 (Sun, 28 Nov 2010)
Log Message:
-----------
Removed unnecessary image
Removed Paths:
-------------
trunk/webassembletool-maven/webassembletool-maven-skin/src/main/resources/overview.jpg
Deleted: trunk/webassembletool-maven/webassembletool-maven-skin/src/main/resources/overview.jpg
===================================================================
(Binary files differ)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <nri...@us...> - 2010-11-28 18:47:52
|
Revision: 563
http://webassembletool.svn.sourceforge.net/webassembletool/?rev=563&view=rev
Author: nricheton
Date: 2010-11-28 18:47:45 +0000 (Sun, 28 Nov 2010)
Log Message:
-----------
Updated website and skin : improved readability
Modified Paths:
--------------
trunk/src/site/site.xml
trunk/src/site/xdoc/aggregator.xml
trunk/src/site/xdoc/api.xml
trunk/src/site/xdoc/authentication.xml
trunk/src/site/xdoc/cache.xml
trunk/src/site/xdoc/cas.xml
trunk/src/site/xdoc/configuration.xml
trunk/src/site/xdoc/esi.xml
trunk/src/site/xdoc/features.xml
trunk/src/site/xdoc/httpheaders.xml
trunk/src/site/xdoc/index.xml
trunk/src/site/xdoc/maven.xml
trunk/src/site/xdoc/proxy.xml
trunk/src/site/xdoc/quickstart.xml
trunk/src/site/xdoc/sample.xml
trunk/src/site/xdoc/taglib.xml
trunk/src/site/xdoc/xpathxslt.xml
trunk/webassembletool-maven/webassembletool-maven-skin/src/main/resources/css/maven-theme.css
trunk/webassembletool-maven/webassembletool-maven-skin/src/main/resources/css/site.css
Added Paths:
-----------
trunk/src/site/xdoc/external-resources.xml
Modified: trunk/src/site/site.xml
===================================================================
--- trunk/src/site/site.xml 2010-10-06 14:44:51 UTC (rev 562)
+++ trunk/src/site/site.xml 2010-11-28 18:47:45 UTC (rev 563)
@@ -27,6 +27,7 @@
<menu name="Download">
<item href="http://sourceforge.net/project/showfiles.php?group_id=209844"
name="Download" />
+ <item href="maven.html" name="Maven repositories" />
</menu>
<menu name="Documentation">
<item href="quickstart.html" name="Quick start" />
@@ -43,13 +44,17 @@
<item href="cas.html" name="Single Sign On with CAS" />
<item href="sample.html" name="Sample applications" />
<item href="maven.html" name="Maven" />
+ <item href="external-resources.html" name="External resources" />
</menu>
- <menu ref="modules" />
+
<menu name="Community">
<item href="http://sourceforge.net/apps/mediawiki/webassembletool/" name="FAQ (Wiki)" />
<item href="http://sourceforge.net/projects/webassembletool/"
name="SourceForge" />
</menu>
+
<menu ref="reports" />
+
+ <menu ref="modules" />
</body>
</project>
\ No newline at end of file
Modified: trunk/src/site/xdoc/aggregator.xml
===================================================================
--- trunk/src/site/xdoc/aggregator.xml 2010-10-06 14:44:51 UTC (rev 562)
+++ trunk/src/site/xdoc/aggregator.xml 2010-11-28 18:47:45 UTC (rev 563)
@@ -5,6 +5,7 @@
<author email="fxb...@us...">Francois-Xavier Bonnet</author>
</properties>
<body>
+ <h1>Aggregator</h1>
<section name="Goals">
<p>
Like the reverse proxy servlet, the aggregator is implemented as a
Modified: trunk/src/site/xdoc/api.xml
===================================================================
--- trunk/src/site/xdoc/api.xml 2010-10-06 14:44:51 UTC (rev 562)
+++ trunk/src/site/xdoc/api.xml 2010-11-28 18:47:45 UTC (rev 563)
@@ -5,6 +5,7 @@
<author email="fxb...@us...">Francois-Xavier Bonnet</author>
</properties>
<body>
+ <h1>API</h1>
<p>
Any functionality used in the taglib, reverse proxy or aggregator can
be used through
Modified: trunk/src/site/xdoc/authentication.xml
===================================================================
--- trunk/src/site/xdoc/authentication.xml 2010-10-06 14:44:51 UTC (rev 562)
+++ trunk/src/site/xdoc/authentication.xml 2010-11-28 18:47:45 UTC (rev 563)
@@ -5,6 +5,7 @@
<author email="fxb...@us...">Francois-Xavier Bonnet</author>
</properties>
<body>
+ <h1>Authentication</h1>
<section name="Authentication">
<p>
User authentication consists in two different things :
Modified: trunk/src/site/xdoc/cache.xml
===================================================================
--- trunk/src/site/xdoc/cache.xml 2010-10-06 14:44:51 UTC (rev 562)
+++ trunk/src/site/xdoc/cache.xml 2010-11-28 18:47:45 UTC (rev 563)
@@ -5,6 +5,7 @@
<author email="fxb...@us...">Francois-Xavier Bonnet</author>
</properties>
<body>
+ <h1>Cache</h1>
<section name="Configuration">
<p>
ESIGate includes a full
Modified: trunk/src/site/xdoc/cas.xml
===================================================================
--- trunk/src/site/xdoc/cas.xml 2010-10-06 14:44:51 UTC (rev 562)
+++ trunk/src/site/xdoc/cas.xml 2010-11-28 18:47:45 UTC (rev 563)
@@ -5,6 +5,7 @@
<author email="fxb...@us...">Francois-Xavier Bonnet</author>
</properties>
<body>
+ <h1>Implementing SSO using JASIG CAS</h1>
<section name="Principles">
<p>
The toolkit can do CAS authentication using the JASIG CAS client.
Modified: trunk/src/site/xdoc/configuration.xml
===================================================================
--- trunk/src/site/xdoc/configuration.xml 2010-10-06 14:44:51 UTC (rev 562)
+++ trunk/src/site/xdoc/configuration.xml 2010-11-28 18:47:45 UTC (rev 563)
@@ -5,6 +5,7 @@
<author email="fxb...@us...">Francois-Xavier Bonnet</author>
</properties>
<body>
+ <h1>Configuration</h1>
<section name="Configuration file">
<p>
The tools default behavior is to load a configuration file from
Modified: trunk/src/site/xdoc/esi.xml
===================================================================
--- trunk/src/site/xdoc/esi.xml 2010-10-06 14:44:51 UTC (rev 562)
+++ trunk/src/site/xdoc/esi.xml 2010-11-28 18:47:45 UTC (rev 563)
@@ -5,6 +5,7 @@
<author email="fxb...@us...">Francois-Xavier Bonnet</author>
</properties>
<body>
+ <h1>Edge Side Include</h1>
<section name="Edge Side Include (ESI)">
<p>
Currently aggregator servlet supports ESI include and comment
Added: trunk/src/site/xdoc/external-resources.xml
===================================================================
--- trunk/src/site/xdoc/external-resources.xml (rev 0)
+++ trunk/src/site/xdoc/external-resources.xml 2010-11-28 18:47:45 UTC (rev 563)
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<document>
+ <properties>
+ <title>ESIGate external resources</title>
+ <author email="nic...@gm...">Nicolas Richeton</author>
+ </properties>
+ <body>
+ <h1>ESIGate external resources</h1>
+ <section name="External resources">
+ <p>Tutorials and examples can also be found on other sites. Feel free to contact us to add your website in that list.</p>
+ <subsection name="Tutorials">
+ <ul>
+ <li>
+ Le blog de Nicolas Richeton
+ <ul>
+ <li>
+ <a
+ href="http://blog.richeton.com/2010/11/28/esigate-tutorial-part-1/">Part 1</a> - Using taglib and templating.
+ </li>
+ </ul>
+ </li>
+ </ul>
+ </subsection>
+
+
+
+ </section>
+ </body>
+</document>
\ No newline at end of file
Modified: trunk/src/site/xdoc/features.xml
===================================================================
--- trunk/src/site/xdoc/features.xml 2010-10-06 14:44:51 UTC (rev 562)
+++ trunk/src/site/xdoc/features.xml 2010-11-28 18:47:45 UTC (rev 563)
@@ -5,23 +5,24 @@
<author email="fxb...@us...">Francois-Xavier Bonnet</author>
</properties>
<body>
- <section name="Features">
- <subsection name="Blocks and templates">
+ <h1>Features</h1>
+
+ <section name="Blocks and templates">
<p>
Any web application can be used as a provider. The master
application will be
able to use blocks and templates delimited with special HTML comments.
</p>
- </subsection>
- <subsection name="Cross technologies">
+ </section>
+ <section name="Cross technologies">
<p>
As we only use HTML comments inside provider applications, a
provider application
may have been developed with any technology,
including Java, PHP on .NET.
</p>
- </subsection>
- <subsection name="Reverse proxy">
+ </section>
+ <section name="Reverse proxy">
<p>
The kit contains a reverse-proxy servlet that can be used to
retrieve static contents
@@ -32,29 +33,29 @@
well be used in a
production environment with good performance.
</p>
- </subsection>
- <subsection name="Aggregator">
+ </section>
+ <section name="Aggregator">
<p>
The aggregator is a reverse-proxy servlet that can parse the pages
on the fly and process
inclusion instructions inserted in the pages by
the applications as tags.
</p>
- </subsection>
- <subsection name="ESI 1.0 specification support">
+ </section>
+ <section name="ESI 1.0 specification support">
<p>
In addition to its native syntax using HTML comments, the Website Assembling
Toolkit partially supports ESI specification (for now, only esi:include and
esi comments are supported).
</p>
- </subsection>
- <subsection name="Xpath expressions and XSLT">
+ </section>
+ <section name="Xpath expressions and XSLT">
<p>
One of the latest features is the possibility to retrieve elements using xpath
expressions and to apply on-the-fly XSLT transformations to retrieved elements.
</p>
- </subsection>
- <subsection name="Cache">
+ </section>
+ <section name="Cache">
<p>
In order to improve performance, the tool can be configured to use a
cache (the underlying cache
@@ -64,8 +65,8 @@
depending on your needs and depending on the provider
application.
</p>
- </subsection>
- <subsection name="User context">
+ </section>
+ <section name="User context">
<p>
While calling the provider application, you may want to send
informations about
@@ -76,15 +77,15 @@
appended as request
parameters to the http request.
</p>
- </subsection>
- <subsection name="Single Sign On with CAS">
+ </section>
+ <section name="Single Sign On with CAS">
<p>
The kit supports CAS protocol using the
<a
href="http://www.jasig.org/cas/proxy-authentication">proxy authentication mode</a>
and the JASIG CAS client.
</p>
- </subsection>
- </section>
+ </section>
+
</body>
</document>
\ No newline at end of file
Modified: trunk/src/site/xdoc/httpheaders.xml
===================================================================
--- trunk/src/site/xdoc/httpheaders.xml 2010-10-06 14:44:51 UTC (rev 562)
+++ trunk/src/site/xdoc/httpheaders.xml 2010-11-28 18:47:45 UTC (rev 563)
@@ -1,10 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<document>
<properties>
- <title>HTTP headers suppot</title>
+ <title>HTTP headers support</title>
<author email="fxb...@us...">Francois-Xavier Bonnet</author>
</properties>
<body>
+ <h1>HTTP headers support</h1>
<section name="Request headers">
<p>
Some request headers are forwarded to the target server, some are
Modified: trunk/src/site/xdoc/index.xml
===================================================================
--- trunk/src/site/xdoc/index.xml 2010-10-06 14:44:51 UTC (rev 562)
+++ trunk/src/site/xdoc/index.xml 2010-11-28 18:47:45 UTC (rev 563)
@@ -5,6 +5,7 @@
<author email="fxb...@us...">Francois-Xavier Bonnet</author>
</properties>
<body>
+ <h1>Overview</h1>
<section name="ESIGate (Website Assembling Toolkit)">
<p>
ESIGate (formerly known as "Website Assembling Toolkit")is a toolkit developped to help developpers to integrate
Modified: trunk/src/site/xdoc/maven.xml
===================================================================
--- trunk/src/site/xdoc/maven.xml 2010-10-06 14:44:51 UTC (rev 562)
+++ trunk/src/site/xdoc/maven.xml 2010-11-28 18:47:45 UTC (rev 563)
@@ -3,14 +3,19 @@
<properties>
<title>Maven</title>
<author email="fxb...@us...">Francois-Xavier Bonnet</author>
+ <author email="nic...@gm...">Nicolas Richeton</author>
</properties>
<body>
+ <h1>Maven</h1>
<section name="Using the Website Assembling Toolkit in a Maven project">
<p>
- The Website Assembling Toolkit has not been deployed yet on Maven central
+ The Website Assembling Toolkit has not been deployed yet on Maven
+ central
repository. You have to add the Website Assembling Toolkit repository to
- your pom.xml
+ your
+ pom.xml
</p>
+
<source><![CDATA[
<repository>
<id>webassembletool-repository</id>
@@ -18,6 +23,33 @@
<url>http://webassembletool.sourceforge.net/maven/repository</url>
</repository>
]]></source>
+ </section>
+
+ <section name="Repositories">
+ <table>
+ <tr>
+ <th>Type</th>
+ <th>URL</th>
+ <th>Description</th>
+ </tr>
+ <tr>
+ <td>Release</td>
+ <td>
+ <a href="http://www.esigate.org/maven/repository/">http://www.esigate.org/maven/repository/</a>
+ </td>
+ <td>Official releases of ESIGate, usable on production.</td>
+ </tr>
+ <tr>
+ <td>Snapshots</td>
+ <td>
+ <a href="http://www.esigate.org/maven/snapshots/">http://www.esigate.org/maven/snapshots/</a>
+ </td>
+ <td>Development builds of ESIGate, usable for compatibility tests and beta testing.</td>
+ </tr>
+ </table>
+ </section>
+
+ <section name="Adding dependency on ESI Gate">
<p>
Then you can add the dependency. For the core API:
</p>
@@ -28,10 +60,11 @@
<version>RELEASE</version>
</dependency>
]]></source>
-<p>
-Note: don't forget to change RELEASE with the latest version.
-</p><br/>
<p>
+ Note: don't forget to change RELEASE with the latest version.
+</p>
+ <br />
+ <p>
For the taglib (in master application):
</p>
<source><![CDATA[
Modified: trunk/src/site/xdoc/proxy.xml
===================================================================
--- trunk/src/site/xdoc/proxy.xml 2010-10-06 14:44:51 UTC (rev 562)
+++ trunk/src/site/xdoc/proxy.xml 2010-11-28 18:47:45 UTC (rev 563)
@@ -6,6 +6,7 @@
<author email="nri...@us...">Nicolas Richeton</author>
</properties>
<body>
+ <h1>Reverse proxy servlets</h1>
<section name="Reverse proxy servlets">
<p>
The toolkit includes two reverse proxy servlets which can be used
Modified: trunk/src/site/xdoc/quickstart.xml
===================================================================
--- trunk/src/site/xdoc/quickstart.xml 2010-10-06 14:44:51 UTC (rev 562)
+++ trunk/src/site/xdoc/quickstart.xml 2010-11-28 18:47:45 UTC (rev 563)
@@ -5,6 +5,7 @@
<author email="fxb...@us...">Francois-Xavier Bonnet</author>
</properties>
<body>
+ <h1>Quickstart</h1>
Imagine you have to write a java application (master) that must
include
a block coming from
Modified: trunk/src/site/xdoc/sample.xml
===================================================================
--- trunk/src/site/xdoc/sample.xml 2010-10-06 14:44:51 UTC (rev 562)
+++ trunk/src/site/xdoc/sample.xml 2010-11-28 18:47:45 UTC (rev 563)
@@ -5,6 +5,7 @@
<author email="fxb...@us...">Francois-Xavier Bonnet</author>
</properties>
<body>
+ <h1>Sample applications</h1>
<section name="Applications">
<p>The source distribution includes to demonstrate most of the
functionalities of the toolkit:
Modified: trunk/src/site/xdoc/taglib.xml
===================================================================
--- trunk/src/site/xdoc/taglib.xml 2010-10-06 14:44:51 UTC (rev 562)
+++ trunk/src/site/xdoc/taglib.xml 2010-11-28 18:47:45 UTC (rev 563)
@@ -5,6 +5,7 @@
<author email="fxb...@us...">Francois-Xavier Bonnet</author>
</properties>
<body>
+ <h1>Taglib</h1>
<section name="Tag the block on the provider application">
<p>The block has to be tagged using special HTML comments.</p>
<source>
Modified: trunk/src/site/xdoc/xpathxslt.xml
===================================================================
--- trunk/src/site/xdoc/xpathxslt.xml 2010-10-06 14:44:51 UTC (rev 562)
+++ trunk/src/site/xdoc/xpathxslt.xml 2010-11-28 18:47:45 UTC (rev 563)
@@ -5,6 +5,7 @@
<author email="fxb...@us...">Francois-Xavier Bonnet</author>
</properties>
<body>
+ <h1>Xpath and XSLT</h1>
<section name="Xpath and XSLT">
<p>
It is possible to extract an Xpath expression from a page or to
Modified: trunk/webassembletool-maven/webassembletool-maven-skin/src/main/resources/css/maven-theme.css
===================================================================
--- trunk/webassembletool-maven/webassembletool-maven-skin/src/main/resources/css/maven-theme.css 2010-10-06 14:44:51 UTC (rev 562)
+++ trunk/webassembletool-maven/webassembletool-maven-skin/src/main/resources/css/maven-theme.css 2010-11-28 18:47:45 UTC (rev 563)
@@ -56,35 +56,42 @@
background: url(../images/newwindow.png) right center no-repeat;
padding-right: 18px;
}
+
+
+
+h1 {
+ color: #708691;
+}
+
+
h2 {
- padding: 4px 4px 4px 6px;
- border: 1px solid #999;
- color: #900;
- background-color: #ddd;
- font-weight:900;
- font-size: x-large;
+ font-family:"Trebuchet MS", Arial, Helvetica, sans-serif;
+ color: #708691;
+ font-weight:bold;
+ font-size: 1.4em;
+ background-image:url(../images/bg_h2.jpg);
+ background-repeat:no-repeat;
+ padding:0px 10px 20px 25px;
+ border:none;
+ background-color: white;
}
+
h3 {
- padding: 4px 4px 4px 6px;
- border: 1px solid #aaa;
- color: #900;
- background-color: #eee;
- font-weight: normal;
- font-size: large;
+ color: #708691;
+ background:url(../images/bg_nav.gif) no-repeat scroll left bottom;
+
+ font-size: 1.3em;
+ margin-left: 17px;
}
-h4 {
- padding: 4px 4px 4px 6px;
- border: 1px solid #bbb;
- color: #900;
- background-color: #fff;
- font-weight: normal;
- font-size: large;
-}
+
h5 {
- padding: 4px 4px 4px 6px;
- color: #900;
- font-size: medium;
+ font-family:"Trebuchet MS", Arial, Helvetica, sans-serif;
+ padding: 4px 4px 4px 6px;
+ color: #708691;
+ font-weight:bold;
+ font-size: 1.4em;
}
+
p {
line-height: 1.3em;
font-size: small;
@@ -111,10 +118,11 @@
background-color: #bbb;
text-align: left;
font-weight: bold;
+ font-size:1.1em;
}
table.bodyTable th, table.bodyTable td {
- font-size: 1em;
+ font-size:1.1em;
}
table.bodyTable tr.a {
@@ -127,6 +135,7 @@
.source {
border: 1px solid #999;
+ font-size: 1.4em;
}
dl {
padding: 4px 4px 4px 6px;
Modified: trunk/webassembletool-maven/webassembletool-maven-skin/src/main/resources/css/site.css
===================================================================
--- trunk/webassembletool-maven/webassembletool-maven-skin/src/main/resources/css/site.css 2010-10-06 14:44:51 UTC (rev 562)
+++ trunk/webassembletool-maven/webassembletool-maven-skin/src/main/resources/css/site.css 2010-11-28 18:47:45 UTC (rev 563)
@@ -11,7 +11,6 @@
position:absolute;
top:20px;
left:0px;
- width:250px;
height:200px;
border:none;
}
@@ -48,13 +47,14 @@
}
li {
list-style-type: none;
- background:url(../images/puce.gif) center left no-repeat;
+ background:url(../images/puce.gif) no-repeat scroll 0 3px transparent;
padding-left: 15px;
color:#5b5b5b;
- font-size:1em;
+
}
#navcolumn li {
background:url(../images/puce.gif) center left no-repeat;
+ font-size:0.9em;
}
.none {
color:#5b5b5b;
@@ -69,24 +69,8 @@
a:active, a:hover {
color:#c35235;
}
-h2 {
- font-family:"Trebuchet MS", Arial, Helvetica, sans-serif;
- color: #708691;
- font-weight:bold;
- font-size: 1.4em;
- background-image:url(../images/bg_h2.jpg);
- background-repeat:no-repeat;
- padding:0px 10px 20px 25px;
- border:none;
- background-color: white;
-}
-h5 {
- font-family:"Trebuchet MS", Arial, Helvetica, sans-serif;
- padding: 4px 4px 4px 6px;
- color: #708691;
- font-weight:bold;
- font-size: 1.4em;
-}
+
+
p {
font-family:"Trebuchet MS", Arial, Helvetica, sans-serif;
font-size:1.2em;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <wa...@us...> - 2010-10-06 14:44:57
|
Revision: 562
http://webassembletool.svn.sourceforge.net/webassembletool/?rev=562&view=rev
Author: waddle
Date: 2010-10-06 14:44:51 +0000 (Wed, 06 Oct 2010)
Log Message:
-----------
add gpg maven plugin to sign artifacts when releasing (use of a profile)
Modified Paths:
--------------
trunk/pom.xml
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2010-10-05 14:52:59 UTC (rev 561)
+++ trunk/pom.xml 2010-10-06 14:44:51 UTC (rev 562)
@@ -262,9 +262,43 @@
<artifactId>sonar-maven-plugin</artifactId>
<version>1.0-beta-1</version>
</plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-gpg-plugin</artifactId>
+ <version>1.1</version>
+ </plugin>
</plugins>
</pluginManagement>
</build>
+ <profiles>
+ <profile>
+ <id>release-sign-artifacts</id>
+ <activation>
+ <property>
+ <name>performRelease</name>
+ <value>true</value>
+ </property>
+ </activation>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-gpg-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>sign-artifacts</id>
+ <phase>verify</phase>
+ <goals>
+ <goal>sign</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ </profiles>
+
<modules>
<module>webassembletool-core</module>
<module>webassembletool-taglib</module>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <wa...@us...> - 2010-10-05 14:53:05
|
Revision: 561
http://webassembletool.svn.sourceforge.net/webassembletool/?rev=561&view=rev
Author: waddle
Date: 2010-10-05 14:52:59 +0000 (Tue, 05 Oct 2010)
Log Message:
-----------
death code removed
Modified Paths:
--------------
trunk/webassembletool-core/src/main/java/net/webassembletool/file/FileResource.java
Modified: trunk/webassembletool-core/src/main/java/net/webassembletool/file/FileResource.java
===================================================================
--- trunk/webassembletool-core/src/main/java/net/webassembletool/file/FileResource.java 2010-10-05 13:33:52 UTC (rev 560)
+++ trunk/webassembletool-core/src/main/java/net/webassembletool/file/FileResource.java 2010-10-05 14:52:59 UTC (rev 561)
@@ -8,8 +8,8 @@
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
-import java.util.Properties;
import java.util.Map.Entry;
+import java.util.Properties;
import net.webassembletool.ResourceContext;
import net.webassembletool.output.Output;
@@ -78,10 +78,7 @@
output.addHeader(header.getKey(), header.getValue());
}
}
- // String charset = output.getHeader("content-encoding");
- // if (charset != null) {
- // output.setCharsetName(charset);
- // }
+
if (file != null) {
InputStream inputStream = new FileInputStream(file);
try {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <nri...@us...> - 2010-10-05 13:33:58
|
Revision: 560
http://webassembletool.svn.sourceforge.net/webassembletool/?rev=560&view=rev
Author: nricheton
Date: 2010-10-05 13:33:52 +0000 (Tue, 05 Oct 2010)
Log Message:
-----------
Added new mailing lists
Modified Paths:
--------------
trunk/pom.xml
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2010-10-05 12:59:57 UTC (rev 559)
+++ trunk/pom.xml 2010-10-05 13:33:52 UTC (rev 560)
@@ -28,10 +28,26 @@
<inceptionYear>2008</inceptionYear>
<mailingLists>
<mailingList>
- <post>https://sourceforge.net/mail/?group_id=209844</post>
+ <post>web...@li...</post>
<archive>https://sourceforge.net/mailarchive/forum.php?forum_name=webassembletool-users</archive>
<name>webassembletool-users</name>
+ <subscribe>https://lists.sourceforge.net/lists/listinfo/webassembletool-users</subscribe>
+ <unsubscribe>https://lists.sourceforge.net/lists/listinfo/webassembletool-users</unsubscribe>
</mailingList>
+ <mailingList>
+ <post>web...@li...</post>
+ <archive>https://sourceforge.net/mailarchive/forum.php?forum_name=webassembletool-devel</archive>
+ <name>webassembletool-devel</name>
+ <subscribe>https://lists.sourceforge.net/lists/listinfo/webassembletool-devel</subscribe>
+ <unsubscribe>https://lists.sourceforge.net/lists/listinfo/webassembletool-devel</unsubscribe>
+ </mailingList>
+ <mailingList>
+ <post>web...@li...</post>
+ <archive>https://sourceforge.net/mailarchive/forum.php?forum_name=webassembletool-commits</archive>
+ <name>webassembletool-commits</name>
+ <subscribe>https://lists.sourceforge.net/lists/listinfo/webassembletool-commits</subscribe>
+ <unsubscribe>https://lists.sourceforge.net/lists/listinfo/webassembletool-commits</unsubscribe>
+ </mailingList>
</mailingLists>
<url>http://webassembletool.sourceforge.net/</url>
<licenses>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|