use of com.enonic.xp.portal.impl.parser.HtmlBlockParser in project xp by enonic.
the class PostProcessEvaluator method executeInstruction.
private HtmlBlocks executeInstruction(final String content) {
for (final PostProcessInstruction instruction : this.instructions) {
final PortalResponse instructionResponse = instruction.evaluate(this.portalRequest, content);
if (instructionResponse == null) {
continue;
}
final boolean hasHeaders = !instructionResponse.getHeaders().isEmpty();
final boolean hasCookies = !instructionResponse.getCookies().isEmpty();
final boolean hasContributions = instructionResponse.hasContributions();
final boolean skipFilters = !instructionResponse.applyFilters();
if (hasContributions || hasHeaders || skipFilters || hasCookies) {
final PortalResponse.Builder newPortalResponse = PortalResponse.create(this.portalResponse);
if (hasContributions) {
newPortalResponse.contributionsFrom(instructionResponse);
}
if (hasHeaders) {
newPortalResponse.headers(instructionResponse.getHeaders());
}
if (hasCookies) {
newPortalResponse.cookies(instructionResponse.getCookies());
}
if (skipFilters) {
newPortalResponse.applyFilters(false);
}
this.portalResponse = newPortalResponse.build();
}
final String resultBody = instructionResponse.getAsString();
return resultBody == null ? null : new HtmlBlockParser().parse(resultBody);
}
return null;
}
Aggregations