[ 
https://issues.apache.org/jira/browse/WICKET-6611?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16678119#comment-16678119
 ] 

Tobias Soloschenko commented on WICKET-6611:
--------------------------------------------

Hello [~thomas.heigl],

[~mgrigorov] and me did some refactoring to process scoped resources, so that 
you have the scope and the name of the original resource available in addition 
to the original content. With this variables it is possible to provide a 
PackageResourceReference the app can access by url. (With the replaced URLs)

Without knowing of the stack trace you are facing I assume that a resource is 
present which invokes the old compress method and your application fails with a 
message that ends with: ".process() should be used instead!"

Because ConcatBundleResource is using ITextResourceCompressor which only 
provides the compress method the CssUrlReplacer can't create 
PackageResourceReference in a meaningful way.

Without digging deep into it my suggestion would be to create your own 
ConcatBundleResource which uses the IScopeAwareTextResourceProcessor and 
provide a name / scope that fits to map the URLs of the CSS to a concrete 
location so that the PackageResourceReferences are resolving the resources 
correctly.

The reason why ConcatBundleResource is exclude is that the resources provided 
by URLs are mapped based on each Resource.

If there is any good suggestion how to handle the resource mapping for bundled 
resources in general, PRs are always welcome.

kind regards

Tobias

> Missing check for IScopeAwareTextResourceProcessor when concatenating 
> resources
> -------------------------------------------------------------------------------
>
>                 Key: WICKET-6611
>                 URL: https://issues.apache.org/jira/browse/WICKET-6611
>             Project: Wicket
>          Issue Type: Bug
>          Components: wicket-core
>    Affects Versions: 8.1.0
>            Reporter: Thomas Heigl
>            Priority: Major
>
> Resource concatenation cannot be used with text compressors relying on scope 
> information.
> I tried to use {{CssUrlReplacer}} in my application and it failed on startup 
> with an {{UnsupportedOperationException}} in the {{compress}} method.
> In {{CssPackageResource}} we have the following code:  
> {code:java}
> ICssCompressor compressor = getCompressor();
> if (compressor != null && getCompress())
> {
>    try
>    {
>       String charsetName = "UTF-8";
>       String nonCompressed = new String(processedResponse, charsetName);
>       String output;
>       if (compressor instanceof IScopeAwareTextResourceProcessor)
>       {
>          IScopeAwareTextResourceProcessor scopeAwareProcessor = 
> (IScopeAwareTextResourceProcessor) compressor;
>          output = scopeAwareProcessor.process(nonCompressed, getScope(), 
> name);
>       }
>       else
>       {
>          output = compressor.compress(nonCompressed);
>       }
>       return output.getBytes(charsetName);
>    }
>    catch (Exception e)
>    {
>       log.error("Error while filtering content", e);
>       return processedResponse;
>    }
> }{code}
> In {{ConcatBundleResource}} this {{instanceof}} is missing and {{compress}} 
> is called directly.
> {code:java}
> if (getCompressor() != null)
> {
>    String nonCompressed = new String(bytes, "UTF-8");
>    bytes = getCompressor().compress(nonCompressed).getBytes("UTF-8");
> }{code}
>  



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to