use of org.onehippo.cms7.crisp.core.resource.jackson.JacksonResource in project hippo by NHS-digital-website.
the class SvgSimpleJacksonRestTemplateResourceResolver method isCacheable.
@Override
public boolean isCacheable(final Resource resource) {
if (this.isCacheEnabled() && resource instanceof JacksonResource) {
String data = resource.getValue("data", String.class);
if (Objects.nonNull(data)) {
byte[] decodedBytes = Base64.getDecoder().decode(data);
String decodedString = new String(decodedBytes);
Matcher regexMatcher = svgPattern.matcher(decodedString);
if (regexMatcher.find()) {
return true;
} else {
log.warn("Could not cache SVG resource. Its body contained: " + decodedString);
}
}
}
return false;
}
Aggregations