|
|
|
@ -1,5 +1,5 @@ |
|
|
|
/* |
|
|
|
/* |
|
|
|
* Copyright 2002-2014 the original author or authors. |
|
|
|
* Copyright 2002-2015 the original author or authors. |
|
|
|
* |
|
|
|
* |
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
|
|
* you may not use this file except in compliance with the License. |
|
|
|
* you may not use this file except in compliance with the License. |
|
|
|
@ -20,7 +20,7 @@ import java.io.ByteArrayOutputStream; |
|
|
|
import java.io.IOException; |
|
|
|
import java.io.IOException; |
|
|
|
import java.io.StringWriter; |
|
|
|
import java.io.StringWriter; |
|
|
|
import java.nio.charset.Charset; |
|
|
|
import java.nio.charset.Charset; |
|
|
|
import java.util.Arrays; |
|
|
|
import java.util.Collections; |
|
|
|
import java.util.HashMap; |
|
|
|
import java.util.HashMap; |
|
|
|
import java.util.Map; |
|
|
|
import java.util.Map; |
|
|
|
import java.util.Scanner; |
|
|
|
import java.util.Scanner; |
|
|
|
@ -97,9 +97,7 @@ public class AppCacheManifestTransformer extends ResourceTransformerSupport { |
|
|
|
throws IOException { |
|
|
|
throws IOException { |
|
|
|
|
|
|
|
|
|
|
|
resource = transformerChain.transform(request, resource); |
|
|
|
resource = transformerChain.transform(request, resource); |
|
|
|
|
|
|
|
if (!this.fileExtension.equals(StringUtils.getFilenameExtension(resource.getFilename()))) { |
|
|
|
String filename = resource.getFilename(); |
|
|
|
|
|
|
|
if (!this.fileExtension.equals(StringUtils.getFilenameExtension(filename))) { |
|
|
|
|
|
|
|
return resource; |
|
|
|
return resource; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -138,7 +136,7 @@ public class AppCacheManifestTransformer extends ResourceTransformerSupport { |
|
|
|
String hash = hashBuilder.build(); |
|
|
|
String hash = hashBuilder.build(); |
|
|
|
contentWriter.write("\n" + "# Hash: " + hash); |
|
|
|
contentWriter.write("\n" + "# Hash: " + hash); |
|
|
|
if (logger.isTraceEnabled()) { |
|
|
|
if (logger.isTraceEnabled()) { |
|
|
|
logger.trace("AppCache file: [" + resource.getFilename()+ "] Hash: [" + hash + "]"); |
|
|
|
logger.trace("AppCache file: [" + resource.getFilename()+ "] hash: [" + hash + "]"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return new TransformedResource(resource, contentWriter.toString().getBytes(DEFAULT_CHARSET)); |
|
|
|
return new TransformedResource(resource, contentWriter.toString().getBytes(DEFAULT_CHARSET)); |
|
|
|
@ -170,7 +168,7 @@ public class AppCacheManifestTransformer extends ResourceTransformerSupport { |
|
|
|
|
|
|
|
|
|
|
|
private class CacheSection implements SectionTransformer { |
|
|
|
private class CacheSection implements SectionTransformer { |
|
|
|
|
|
|
|
|
|
|
|
private final String COMMENT_DIRECTIVE = "#"; |
|
|
|
private static final String COMMENT_DIRECTIVE = "#"; |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public String transform(String line, HashBuilder builder, Resource resource, |
|
|
|
public String transform(String line, HashBuilder builder, Resource resource, |
|
|
|
@ -178,7 +176,8 @@ public class AppCacheManifestTransformer extends ResourceTransformerSupport { |
|
|
|
|
|
|
|
|
|
|
|
if (isLink(line) && !hasScheme(line)) { |
|
|
|
if (isLink(line) && !hasScheme(line)) { |
|
|
|
ResourceResolverChain resolverChain = transformerChain.getResolverChain(); |
|
|
|
ResourceResolverChain resolverChain = transformerChain.getResolverChain(); |
|
|
|
Resource appCacheResource = resolverChain.resolveResource(null, line, Arrays.asList(resource)); |
|
|
|
Resource appCacheResource = |
|
|
|
|
|
|
|
resolverChain.resolveResource(null, line, Collections.singletonList(resource)); |
|
|
|
String path = resolveUrlPath(line, request, resource, transformerChain); |
|
|
|
String path = resolveUrlPath(line, request, resource, transformerChain); |
|
|
|
builder.appendResource(appCacheResource); |
|
|
|
builder.appendResource(appCacheResource); |
|
|
|
if (logger.isTraceEnabled()) { |
|
|
|
if (logger.isTraceEnabled()) { |
|
|
|
|