use of com.twinsoft.convertigo.engine.enums.MimeType in project convertigo by convertigo.
the class RewriteAbsoluteUrl method applyOnResponse.
@Override
public boolean applyOnResponse(Shuttle shuttle) {
try {
MimeType mimeType = MimeType.parse(shuttle.getResponseMimeType());
Pattern pattern = null;
if (rewriteHtml && htmlTypes.contains(mimeType)) {
if (rewriteCss && cssTypes.contains(mimeType)) {
Engine.logSiteClipper.trace("(RewriteAbsoluteUrl) Prepare rewriting to use Html + Css replacement pattern");
pattern = htmlCssPattern;
} else {
Engine.logSiteClipper.trace("(RewriteAbsoluteUrl) Prepare rewriting to use Html replacement pattern");
pattern = htmlPattern;
}
} else {
if (rewriteCss && cssTypes.contains(mimeType)) {
Engine.logSiteClipper.trace("(RewriteAbsoluteUrl) Prepare rewriting to use Css replacement pattern");
pattern = cssPattern;
}
}
if (pattern != null) {
replace(pattern, shuttle);
return true;
} else {
Engine.logSiteClipper.trace("(RewriteAbsoluteUrl) Do not rewrite this resource");
}
} catch (Exception e) {
Engine.logSiteClipper.warn("Unable to apply 'RewriteRule' rule : " + getName(), e);
}
return false;
}
Aggregations