On DD4T Java version2, following error occured when getting DCP by getComponentPresentation method(org.dd4t.core.factories.ComponentPresentationFactory). It is related to BaseBrokerProvider class.
2015-07-13 06:16:51,843 ERROR CompressionUtils - Decompression failed.
java.util.zip.ZipException: Not in GZIP format
So on dispatcher-servlet.xml, I changed property "contentIsCompressed" to false, then another error occured.
2015-07-13 06:31:54,594 ERROR JsonDataBinder - com.fasterxml.jackson.core.JsonParseException: Illegal character ((CTRL-CHAR, code 31)): only regular white space (\r, \n, \t) is allowed between tokens
at [Source: �\x00\x00\x00\x00\x00\x00�S�j�0��F�K�ؽ��M�$&-�>h�ɮRYZlm�!~��
According to the message, JSON seems to be corrupted.So I modify source code of BaseBrokerProvider class, not to do Base 64 decoding.
protected boolean contentIsBase64Encoded = true;
public void setContentIsBase64Encoded(final String contentIsBase64Encoded) {
this.contentIsBase64Encoded = Boolean.parseBoolean(contentIsBase64Encoded);
}
And I modified dispatcher-servlet.xml like following.
<bean id="componentPresentationProvider" scope="singleton" class="org.dd4t.providers.impl.BrokerComponentPresentationProvider">
<property name="contentIsCompressed" value="false" />
<property name="contentIsBase64Encoded" value="false" />
<property name="concreteComponentPresentation" value="org.dd4t.contentmodel.impl.ComponentPresentationImpl" />
<property name="concreteComponentTemplateImpl" value="org.dd4t.contentmodel.impl.ComponentTemplateImpl" />
</bean>
Finally, error disappered.
My questions are following.
- What kind of case should I decomporess GZip(set "contentIsCompressed" true).
- Is there any problem caused by disabling Base 64 decoding?
Regards,
UPDATE
Following configuration and modification of DD4T's source code are required.
- Add TBB "Compress Output" to PT and set "true" to bean pageProvider's contentIsCompressed property in dispatcher-servlet.xml(it's on Java Web application)
- Add TBB "Compress Output" to dynamic CT and set "true" to bean componentPresentationProvider's contentIsCompressed property in dispatcher-servlet.xml.
- Modify source code of org.dd4t.core.util.CompressionUtils, decompressGZip method like following. Otherwise, multibyte characters are corrupted.
Original:
result = (String) IOUtils.toString(gis);
Modified:
result = (String) IOUtils.toString(gis,"UTF-8");