use of org.apache.wicket.resource.IScopeAwareTextResourceProcessor in project wicket by apache.
the class CssPackageResource method processResponse.
@Override
protected byte[] processResponse(final Attributes attributes, final byte[] bytes) {
final byte[] processedResponse = super.processResponse(attributes, bytes);
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;
}
} else {
// don't strip the comments
return processedResponse;
}
}
use of org.apache.wicket.resource.IScopeAwareTextResourceProcessor in project wicket by apache.
the class JavaScriptPackageResource method processResponse.
@Override
protected byte[] processResponse(final Attributes attributes, byte[] bytes) {
final byte[] processedResponse = super.processResponse(attributes, bytes);
IJavaScriptCompressor 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;
}
} else {
// don't strip the comments
return processedResponse;
}
}
Aggregations