Permalink
Browse files

prepare release 1.3.2

  • Loading branch information...
alexo committed Dec 11, 2010
2 parents ff46955 + cdcf61f commit 7b9343c06102586eee0aabbcc38338c051c1e87c
Showing with 3,146 additions and 4,694 deletions.
  1. +0 −6 .gitignore
  2. 0 {support → }/eclipse-checkstyle.xml
  3. 0 {support → }/eclipse-codeTemplates.xml
  4. 0 {support → }/eclipse-formatter.xml
  5. +20 −19 pom.xml
  6. +0 −1 support/install-thirdparty.bat
  7. BIN support/lib/compiler-r531.jar
  8. +1 −1 wro4j-core/pom.xml
  9. +1 −1 wro4j-core/src/main/java/ro/isdc/wro/http/HttpHeader.java
  10. +0 −6 wro4j-core/src/main/java/ro/isdc/wro/http/WroFilter.java
  11. +16 −4 wro4j-core/src/main/java/ro/isdc/wro/manager/WroManager.java
  12. +1 −0 wro4j-core/src/main/java/ro/isdc/wro/model/resource/factory/UriLocatorFactory.java
  13. +35 −2 wro4j-core/src/main/java/ro/isdc/wro/model/resource/locator/ByteArrayStreamDispatchingStrategy.java
  14. +1 −0 wro4j-core/src/main/java/ro/isdc/wro/model/resource/locator/ServletContextUriLocator.java
  15. +2 −2 ...-core/src/main/java/ro/isdc/wro/model/resource/locator/wildcard/DefaultWildcardStreamLocator.java
  16. +4 −19 wro4j-core/src/main/java/ro/isdc/wro/model/resource/processor/impl/css/CssImportPreProcessor.java
  17. +35 −3 wro4j-core/src/main/java/ro/isdc/wro/util/WroTestUtils.java
  18. +11 −1 wro4j-core/src/main/java/ro/isdc/wro/util/WroUtil.java
  19. +27 −1 ...e/src/test/java/ro/isdc/wro/model/resource/locator/wildcard/TestDefaultWildcardStreamLocator.java
  20. +8 −82 wro4j-core/src/test/java/ro/isdc/wro/model/resource/processor/TestCssImportPreProcessor.java
  21. +1 −1 wro4j-core/src/test/java/ro/isdc/wro/model/resource/processor/TestGroupsProcessor.java
  22. +1 −0 wro4j-core/src/test/resources/ro/isdc/wro/model/resource/locator/wildcard/tools.expose-1.0.5.js
  23. +1 −0 wro4j-core/src/test/resources/ro/isdc/wro/model/resource/locator/wildcard/tools.overlay-1.1.2.js
  24. +1 −0 ...-core/src/test/resources/ro/isdc/wro/model/resource/locator/wildcard/tools.overlay.apple-1.0.1.js
  25. +1 −0 ...ore/src/test/resources/ro/isdc/wro/model/resource/locator/wildcard/tools.overlay.gallery-1.0.0.js
  26. 0 ...ces/ro/isdc/wro/{processor/cssImports → model/resource/processor/cssImport}/css/css1/import1b.css
  27. 0 ...resources/ro/isdc/wro/{processor/cssImports → model/resource/processor/cssImport}/css/import1.css
  28. 0 ...esources/ro/isdc/wro/{processor/cssImports → model/resource/processor/cssImport}/css/import1a.css
  29. 0 ...resources/ro/isdc/wro/{processor/cssImports → model/resource/processor/cssImport}/css/import2.css
  30. 0 ...resources/ro/isdc/wro/{processor/cssImports → model/resource/processor/cssImport}/css/import3.css
  31. 0 ...ources/ro/isdc/wro/{processor/cssImports → model/resource/processor/cssImport}/css/recursive1.css
  32. 0 ...ro/isdc/wro/{processor/cssImports/test1-input.css → model/resource/processor/cssImport/test1.css}
  33. 0 ...dc/wro/{processor/cssImports/test1-output.css → model/resource/processor/cssImport/test1.out.css}
  34. 0 ...ro/isdc/wro/{processor/cssImports/test2-input.css → model/resource/processor/cssImport/test2.css}
  35. 0 ...dc/wro/{processor/cssImports/test2-output.css → model/resource/processor/cssImport/test2.out.css}
  36. +15 −12 ...processor/cssImports/testPostProcessor-output.css → model/resource/processor/cssImport/test3.css}
  37. +32 −0 wro4j-core/src/test/resources/ro/isdc/wro/model/resource/processor/cssImport/test3.out.css
  38. 0 ...ssImports/testPostProcessor-input.css → model/resource/processor/cssImport/testPostProcessor.css}
  39. +32 −0 ...-core/src/test/resources/ro/isdc/wro/model/resource/processor/cssImport/testPostProcessor.out.css
  40. 0 ...hBackgrounds-input.css → model/resource/processor/cssImport/testPostProcessorWithBackgrounds.css}
  41. 0 ...grounds-output.css → model/resource/processor/cssImport/testPostProcessorWithBackgrounds.out.css}
  42. 0 ...cessor/cssImports/testRecursive-input.css → model/resource/processor/cssImport/testRecursive.css}
  43. 0 ...r/cssImports/testRecursive-output.css → model/resource/processor/cssImport/testRecursive.out.css}
  44. 0 ...ssor/cssImports/testRecursive1-input.css → model/resource/processor/cssImport/testRecursive1.css}
  45. 0 ...cssImports/testRecursive1-output.css → model/resource/processor/cssImport/testRecursive1.out.css}
  46. +0 −14 wro4j-core/src/test/resources/ro/isdc/wro/processor/cssImports/testWithBackgrounds-input.css
  47. +226 −244 wro4j-examples/pom.xml
  48. +1 −1 wro4j-examples/src/main/resources/log4j.properties
  49. +2 −2 wro4j-examples/src/main/webapp/WEB-INF/web.xml
  50. +6 −2 wro4j-examples/src/main/webapp/WEB-INF/wro.xml
  51. +7 −11 wro4j-extensions/pom.xml
  52. +6 −3 wro4j-extensions/src/main/java/ro/isdc/wro/extensions/processor/algorithm/less/LessCss.java
  53. +2,249 −2,204 ...s/src/main/java/ro/isdc/wro/extensions/processor/algorithm/less/{less-1.0.36.js → less-1.0.40.js}
  54. +0 −1,886 wro4j-extensions/src/main/java/ro/isdc/wro/extensions/processor/algorithm/less/less.js
  55. +365 −149 wro4j-extensions/src/main/java/ro/isdc/wro/extensions/processor/algorithm/uglify/process.js
  56. +0 −1 wro4j-extensions/src/main/java/ro/isdc/wro/extensions/processor/css/YUICssCompressorProcessor.java
  57. +0 −1 ...tensions/src/main/java/ro/isdc/wro/extensions/processor/js/DojoShrinksafeCompressorProcessor.java
  58. +0 −1 ...xtensions/src/main/java/ro/isdc/wro/extensions/processor/js/GoogleClosureCompressorProcessor.java
  59. +0 −1 wro4j-extensions/src/main/java/ro/isdc/wro/extensions/processor/js/YUIJsCompressorProcessor.java
  60. +10 −10 wro4j-extensions/src/test/resources/ro/isdc/wro/extensions/processor/beautify/input.beautify.js
  61. +1 −1 wro4j-extensions/src/test/resources/ro/isdc/wro/extensions/processor/beautify/packed.beautify.js
  62. +7 −0 wro4j-extensions/src/test/resources/ro/isdc/wro/extensions/processor/lesscss/css.css
  63. +7 −0 wro4j-extensions/src/test/resources/ro/isdc/wro/extensions/processor/lesscss/css.less
  64. +3 −0 wro4j-extensions/src/test/resources/ro/isdc/wro/extensions/processor/uglify/array1.js
  65. +1 −0 wro4j-extensions/src/test/resources/ro/isdc/wro/extensions/processor/uglify/array1.pack.js
  66. +6 −0 wro4j-extensions/src/test/resources/ro/isdc/wro/extensions/processor/uglify/array4.js
  67. +1 −0 wro4j-extensions/src/test/resources/ro/isdc/wro/extensions/processor/uglify/array4.pack.js
  68. +1 −1 wro4j-extensions/src/test/resources/ro/isdc/wro/extensions/processor/uglify/input.pack.js
  69. +1 −1 wro4j-maven-plugin/pom.xml
View
@@ -1,6 +0,0 @@
-*/target/*
-*/bin/*
-.settings
-.classpath
-.project
-.gitignore
File renamed without changes.
File renamed without changes.
File renamed without changes.
View
39 pom.xml
@@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>ro.isdc.wro4j</groupId>
<artifactId>wro4j-parent</artifactId>
- <version>1.3.1</version>
+ <version>1.3.2</version>
<packaging>pom</packaging>
<name>Web Resource Optimizer Parent</name>
<inceptionYear>2008</inceptionYear>
@@ -64,7 +64,7 @@
<slf4j.dependency>1.6.0</slf4j.dependency>
<maven.dependency>2.2.1</maven.dependency>
<mockito.dependency>1.8.5</mockito.dependency>
- <junit.dependency>4.8.1</junit.dependency>
+ <junit.dependency>4.8.2</junit.dependency>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<maven.compile.encoding>UTF-8</maven.compile.encoding>
@@ -189,26 +189,27 @@
<artifactId>js</artifactId>
<version>1.7R2</version>
</dependency>
- <dependency>
- <groupId>com.google.closure</groupId>
- <artifactId>compiler</artifactId>
- <version>r531</version>
- </dependency>
- <dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring</artifactId>
- <version>2.5.6</version>
- </dependency>
<dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>${junit.dependency}</version>
- <scope>test</scope>
+ <groupId>com.google.javascript</groupId>
+ <artifactId>closure-compiler</artifactId>
+ <version>r606</version>
</dependency>
+ <dependency>
+ <groupId>com.google.closure</groupId>
+ <artifactId>compiler</artifactId>
+ <version>r531</version>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>${junit.dependency}</version>
+ <scope>test</scope>
+ </dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
<version>${mockito.dependency}</version>
+ <scope>test</scope>
</dependency>
</dependencies>
</dependencyManagement>
@@ -220,7 +221,6 @@
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
- <scope>test</scope>
</dependency>
<!-- For test -->
<dependency>
@@ -232,6 +232,7 @@
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
+ <scope>test</scope>
<version>${mockito.dependency}</version>
</dependency>
</dependencies>
@@ -418,8 +419,8 @@
<!-- Repository for third party libraries -->
<repositories>
<repository>
- <id>Jasig Repo - for YUI library</id>
- <url>http://developer.jasig.org/repo/content/groups/m2-legacy</url>
+ <id>Sonatype</id>
+ <url>http://oss.sonatype.org/content/groups/public</url>
</repository>
</repositories>
@@ -1 +0,0 @@
-mvn org.apache.maven.plugins:maven-install-plugin:2.3.1:install-file -Dfile=lib/compiler-r531.jar -DgroupId=com.google.closure -DartifactId=compiler -Dversion=r531 -Dpackaging=jar
Binary file not shown.
View
@@ -10,7 +10,7 @@
<parent>
<groupId>ro.isdc.wro4j</groupId>
<artifactId>wro4j-parent</artifactId>
- <version>1.3.1</version>
+ <version>1.3.2</version>
</parent>
<dependencies>
@@ -12,7 +12,7 @@
public enum HttpHeader {
CACHE_CONTROL("Cache-Control"), LAST_MODIFIED("Last-Modified"), ETAG("ETag"), EXPIRES("Expires"), IF_MODIFIED_SINCE(
"If-Modified-Since"), IF_NONE_MATCH("If-None-Match"), CONTENT_ENCODING("Content-Encoding"), ACCEPT_ENCODING(
- "Accept-Encoding");
+ "Accept-Encoding"), PRAGMA("Pragma");
/**
* HTTP header as string.
*/
@@ -349,7 +349,6 @@ private void initHeaderValues() {
cal.roll(Calendar.YEAR, 10);
headersMap.put(HttpHeader.CACHE_CONTROL.toString(), DEFAULT_CACHE_CONTROL_VALUE);
- // headersMap.put(HttpHeader.ETAG.toString(), Long.toHexString(timestamp));
headersMap.put(HttpHeader.LAST_MODIFIED.toString(), WroUtil.toDateAsString(timestamp));
headersMap.put(HttpHeader.EXPIRES.toString(), WroUtil.toDateAsString(cal.getTimeInMillis()));
@@ -421,11 +420,6 @@ public final void doFilter(final ServletRequest req, final ServletResponse res,
*/
private void processRequest(final HttpServletRequest request, final HttpServletResponse response)
throws ServletException, IOException {
- final String ifNoneMatch = request.getHeader(HttpHeader.IF_NONE_MATCH.toString());
- final String etagValue = headersMap.get(HttpHeader.ETAG.toString());
- if (etagValue != null && etagValue.equals(ifNoneMatch)) {
- response.setStatus(HttpServletResponse.SC_NOT_MODIFIED);
- }
setResponseHeaders(response);
// process the uri using manager
wroManagerFactory.getInstance().process();
@@ -113,6 +113,7 @@ public final void process()
throws IOException {
final HttpServletRequest request = Context.get().getRequest();
final HttpServletResponse response = Context.get().getResponse();
+
LOG.debug("processing: " + request.getRequestURI());
validate();
InputStream is = null;
@@ -150,9 +151,9 @@ public final void process()
* @param response {@link HttpServletResponse} to prevent cache.
*/
private void preventCacheResponse(final HttpServletResponse response) {
- response.setHeader("Pragma", "no-cache");
- response.setHeader("Cache-Control", "no-cache");
- response.setDateHeader("Expires", 0);
+ response.setHeader(HttpHeader.PRAGMA.toString(), "no-cache");
+ response.setHeader(HttpHeader.CACHE_CONTROL.toString(), "no-cache");
+ response.setDateHeader(HttpHeader.EXPIRES.toString(), 0);
}
@@ -172,7 +173,6 @@ private boolean isProxyResourceRequest(final HttpServletRequest request) {
return request.getRequestURI().contains(CssUrlRewritingProcessor.PATH_RESOURCES);
}
-
/**
* Add gzip header to response and wrap the response {@link OutputStream} with {@link GZIPOutputStream}.
*
@@ -214,6 +214,18 @@ private InputStream buildGroupsInputStream(final HttpServletRequest request, fin
initScheduler();
final ContentHashEntry contentHashEntry = getContentHashEntry(groupName, type, minimize);
+
+ //TODO move ETag check in wroManagerFactory
+ final String ifNoneMatch = request.getHeader(HttpHeader.IF_NONE_MATCH.toString());
+ final String etagValue = contentHashEntry.getHash();
+ if (etagValue != null && etagValue.equals(ifNoneMatch)) {
+ LOG.debug("ETag hash detected: " + etagValue + ". Sending " + HttpServletResponse.SC_NOT_MODIFIED
+ + " status code");
+ response.setStatus(HttpServletResponse.SC_NOT_MODIFIED);
+ //because we cannot return null, return a stream containing nothing.
+ return new ByteArrayInputStream(new byte[] {});
+ }
+
if (contentHashEntry.getContent() != null) {
// make the input stream encoding aware.
inputStream = new ByteArrayInputStream(contentHashEntry.getContent().getBytes());
@@ -51,6 +51,7 @@ public InputStream locate(final String uri)
if (uriLocator == null) {
throw new IOException("No locator is capable of handling uri: " + uri);
}
+ LOG.debug("locating uri: " + uri + ", using locator: " + uriLocator);
return uriLocator.locate(uri);
}
@@ -7,6 +7,7 @@
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
+import java.io.OutputStream;
import java.io.PrintWriter;
import java.net.HttpURLConnection;
import java.net.URL;
@@ -122,12 +123,44 @@ private ServletResponse getWrappedServletResponse(final HttpServletResponse resp
/**
* PrintWrapper of wrapped response.
*/
- private final PrintWriter pw = new PrintWriter(os);
+ private PrintWriter pw = new PrintWriter(os);
/**
* Servlet output stream of wrapped response.
*/
- private final ServletOutputStream sos = new DelegatingServletOutputStream(os);
+ private ServletOutputStream sos = new DelegatingServletOutputStream(os);
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void sendError(final int sc)
+ throws IOException {
+ onError(sc, "");
+ super.sendError(sc);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void sendError(final int sc, final String msg)
+ throws IOException {
+ onError(sc, msg);
+ super.sendError(sc, msg);
+ }
+
+ /**
+ * Use an empty stream to avoid container writing unwanted message when a resource is missing.
+ * @param sc status code.
+ * @param msg
+ */
+ private void onError(final int sc, final String msg) {
+ LOG.debug("Error detected with code: " + sc + " and message: " + msg);
+ final OutputStream emptyStream = new ByteArrayOutputStream();
+ pw = new PrintWriter(emptyStream);
+ sos = new DelegatingServletOutputStream(emptyStream);
+ }
@Override
public ServletOutputStream getOutputStream()
@@ -83,6 +83,7 @@ public static boolean isProtectedResource(final String uri) {
*/
public InputStream locate(final String uri)
throws IOException {
+ LOG.debug("locating uri: " + uri);
if (uri == null) {
throw new IllegalArgumentException("URI cannot be NULL!");
}
@@ -11,9 +11,9 @@
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Collection;
-import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
+import java.util.TreeMap;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.FilenameUtils;
@@ -118,7 +118,7 @@ public InputStream locateStream(final String uri, final File folder)
//maps resource uri's and corresponding file
//this map have to be ordered
- final Map<String, File> uriToFileMap = new LinkedHashMap<String, File>();
+ final Map<String, File> uriToFileMap = new TreeMap<String, File>();
final String uriFolder = FilenameUtils.getFullPathNoEndSeparator(uri);
final String parentFolderPath = folder.getPath();
@@ -4,7 +4,6 @@
package ro.isdc.wro.model.resource.processor.impl.css;
import java.io.IOException;
-import java.io.InputStreamReader;
import java.io.Reader;
import java.io.Writer;
import java.util.ArrayList;
@@ -49,13 +48,10 @@
* List of processed resources, useful for detecting deep recursion.
*/
private final List<Resource> processed = new ArrayList<Resource>();
-
/** The url pattern */
- private static final Pattern PATTERN = Pattern.compile("@import\\s*url\\(\\s*?" + "[\"']?([^\"']*?)[\"']?"
- // any sequence of characters, except an unescaped ')'
- + "\\s*?\\);?", // Any number of whitespaces, then ')'
- Pattern.CASE_INSENSITIVE); // works with 'URL('
-
+ ///^(\s|\n)*
+ //@import\s*(?:url\()?["']?([^"')]+)["']?\)?;?
+ private static final Pattern PATTERN = Pattern.compile("@import\\s*(?:url\\()?[\"']?([^\"')]+)[\"')]?\\)?;?", Pattern.CASE_INSENSITIVE);
/**
* {@inheritDoc}
@@ -128,17 +124,6 @@ private String removeImportStatements(final String content) {
return sb.toString();
}
-
- /**
- * @return the content of the resource as string.
- */
- private String getResourceContent(final Resource resource)
- throws IOException {
- final Reader reader = new InputStreamReader(uriLocatorFactory.locate(resource.getUri()));
- return IOUtils.toString(reader);
- }
-
-
/**
* Find a set of imported resources inside a given resource.
*/
@@ -147,7 +132,7 @@ private String getResourceContent(final Resource resource)
// it should be sorted
final List<Resource> imports = new ArrayList<Resource>();
// Check if @Scanner#findWithinHorizon can be used instead
- final String css = getResourceContent(resource);
+ final String css = IOUtils.toString(uriLocatorFactory.locate(resource.getUri()));
final Matcher m = PATTERN.matcher(css);
while (m.find()) {
final Resource importedResource = buildImportedResource(resource, m.group(1));
Oops, something went wrong.

0 comments on commit 7b9343c

Please sign in to comment.