Skip to content

Commit

Permalink
Move logging to UrlResourceHandler, use -ver-
Browse files Browse the repository at this point in the history
  • Loading branch information
gitblit committed Dec 1, 2015
1 parent 181d47c commit 4e5e925
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,6 @@ private String uriFor(PatternBinding binding, Map<String, Object> parameters) {
String pathValue = parameterPair.getValue().toString();
if (isResourceRoute && ResourceHandler.PATH_PARAMETER.equals(parameterPair.getKey())) {
String versionedResourcePath = ((UrlResourceHandler) route.getRouteHandler()).injectVersion(pathValue);
log.debug("Inject version in resource path: '{}' => '{}'", pathValue, versionedResourcePath);
pathValue = versionedResourcePath;
}
matcher.appendReplacement(sb, pathValue);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public abstract class UrlResourceHandler extends ResourceHandler {

private static final Logger log = LoggerFactory.getLogger(UrlResourceHandler.class);

private static final Pattern VERSION_PATTERN = Pattern.compile("-[0-9]+\\.");
private static final Pattern VERSION_PATTERN = Pattern.compile("-ver-[0-9]+\\.");

public UrlResourceHandler(String urlPath) {
super(urlPath);
Expand All @@ -45,7 +45,7 @@ public UrlResourceHandler(String urlPath) {
public final void handleResource(String resourcePath, RouteContext routeContext) {
String unversionedResourcePath = removeVersion(resourcePath);
if (!unversionedResourcePath.equals(resourcePath)) {
log.debug("Remove version from resource path: '{}' => '{}'", resourcePath, unversionedResourcePath);
log.trace("Remove version from resource path: '{}' => '{}'", resourcePath, unversionedResourcePath);
resourcePath = unversionedResourcePath;
}

Expand Down Expand Up @@ -74,13 +74,15 @@ public String injectVersion(String resourcePath) {

if (extensionAt == -1) {
versionedResourcePath.append(resourcePath);
versionedResourcePath.append("-").append(lastModified);
versionedResourcePath.append("-ver-").append(lastModified);
} else {
versionedResourcePath.append(resourcePath.substring(0, extensionAt));
versionedResourcePath.append("-").append(lastModified);
versionedResourcePath.append("-ver-").append(lastModified);
versionedResourcePath.append(resourcePath.substring(extensionAt, resourcePath.length()));
}

log.trace("Inject version in resource path: '{}' => '{}'", resourcePath, versionedResourcePath);

return versionedResourcePath.toString();
} catch (IOException e) {
throw new PippoRuntimeException("Failed to read lastModified property for {}", e, resourceUrl);
Expand Down

0 comments on commit 4e5e925

Please sign in to comment.