You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by mg...@apache.org on 2019/05/23 11:56:05 UTC

[wicket] branch wicket-8.x updated: WICKET-6669 Use the scope and name of the first provided resource for IScopeAwareTextResourceProcessor#process()

This is an automated email from the ASF dual-hosted git repository.

mgrigorov pushed a commit to branch wicket-8.x
in repository https://gitbox.apache.org/repos/asf/wicket.git


The following commit(s) were added to refs/heads/wicket-8.x by this push:
     new e2a1115  WICKET-6669 Use the scope and name of the first provided resource for IScopeAwareTextResourceProcessor#process()
e2a1115 is described below

commit e2a11151e2bc55ae3a637efd88b1202582461780
Author: Martin Tzvetanov Grigorov <mg...@apache.org>
AuthorDate: Thu May 23 09:03:18 2019 +0300

    WICKET-6669 Use the scope and name of the first provided resource for IScopeAwareTextResourceProcessor#process()
    
    The same is already done in ConcatBundleResource#getCacheKey()
    
    (cherry picked from commit 8566ed24031641c060871cb0732b7171fd2deac8)
---
 .../wicket/resource/bundles/ConcatBundleResource.java | 19 +++++++++++++++++--
 1 file changed, 17 insertions(+), 2 deletions(-)

diff --git a/wicket-core/src/main/java/org/apache/wicket/resource/bundles/ConcatBundleResource.java b/wicket-core/src/main/java/org/apache/wicket/resource/bundles/ConcatBundleResource.java
index 95087c4..62f57a2 100644
--- a/wicket-core/src/main/java/org/apache/wicket/resource/bundles/ConcatBundleResource.java
+++ b/wicket-core/src/main/java/org/apache/wicket/resource/bundles/ConcatBundleResource.java
@@ -32,6 +32,7 @@ import org.apache.wicket.request.resource.AbstractResource;
 import org.apache.wicket.request.resource.IResource;
 import org.apache.wicket.request.resource.ResourceReference;
 import org.apache.wicket.request.resource.caching.IStaticCacheableResource;
+import org.apache.wicket.resource.IScopeAwareTextResourceProcessor;
 import org.apache.wicket.resource.ITextResourceCompressor;
 import org.apache.wicket.util.io.ByteArrayOutputStream;
 import org.apache.wicket.util.io.IOUtils;
@@ -174,14 +175,28 @@ public class ConcatBundleResource extends AbstractResource implements IStaticCac
 	{
 		ByteArrayOutputStream output = new ByteArrayOutputStream();
 		for (IResourceStream curStream : resources)
+		{
 			IOUtils.copy(curStream.getInputStream(), output);
+		}
 
 		byte[] bytes = output.toByteArray();
 
-		if (getCompressor() != null)
+		final ITextResourceCompressor textResourceCompressor = getCompressor();
+		if (textResourceCompressor != null)
 		{
 			String nonCompressed = new String(bytes, "UTF-8");
-			bytes = getCompressor().compress(nonCompressed).getBytes("UTF-8");
+
+			if (textResourceCompressor instanceof IScopeAwareTextResourceProcessor)
+			{
+				final ResourceReference reference = providedResources.get(0).getReference();
+				final Class<?> scope = reference.getScope();
+				final String name = reference.getName();
+				bytes = ((IScopeAwareTextResourceProcessor) textResourceCompressor).process(nonCompressed, scope, name).getBytes("UTF-8");
+			}
+			else
+			{
+				bytes = textResourceCompressor.compress(nonCompressed).getBytes("UTF-8");
+			}
 		}
 
 		return bytes;