use of com.enonic.xp.portal.impl.mapper.PortalRequestMapper in project xp by enonic.
the class MacroContextMapper method serialize.
@Override
public void serialize(final MapGenerator gen) {
gen.value("name", macroContext.getName());
gen.value("body", macroContext.getBody());
MapperHelper.serializeMultimap("params", gen, macroContext.getParameters());
final PortalRequest request = macroContext.getRequest();
gen.map("request");
if (request != null) {
new PortalRequestMapper(request).serialize(gen);
}
gen.end();
gen.value("document", macroContext.getDocument());
}
use of com.enonic.xp.portal.impl.mapper.PortalRequestMapper in project xp by enonic.
the class FilterScriptImpl method doExecute.
private PortalResponse doExecute(final PortalRequest request, final WebResponse response, final WebHandlerChain webHandlerChain) {
if (!this.scriptExports.hasMethod(FILTER_SCRIPT_METHOD)) {
throw new WebException(HttpStatus.NOT_IMPLEMENTED, "Missing exported function '" + FILTER_SCRIPT_METHOD + "' in filter script: " + scriptExports.getScript());
}
Tracer.withCurrent(this::addTraceInfo);
final PortalRequestMapper requestMapper = new PortalRequestMapper(request);
final FilterNextFunctionWrapper nextHandler = new FilterNextFunctionWrapper(webHandlerChain, request, response, scriptExports.getScript(), scriptService);
final ScriptValue result = this.scriptExports.executeMethod(FILTER_SCRIPT_METHOD, requestMapper, nextHandler);
return new PortalResponseSerializer(result).serialize();
}
use of com.enonic.xp.portal.impl.mapper.PortalRequestMapper in project xp by enonic.
the class IdProviderControllerScriptImpl method doExecute.
private PortalResponse doExecute(final String functionName, final PortalRequest portalRequest) {
final boolean exists = this.scriptExports.hasMethod(functionName);
if (!exists) {
return new PortalResponseSerializer(null, HttpStatus.NOT_FOUND).serialize();
}
final PortalRequestMapper requestMapper = new PortalRequestMapper(portalRequest);
final ScriptValue result = this.scriptExports.executeMethod(functionName, requestMapper);
if ((result == null) || !result.isObject()) {
return null;
} else {
return new PortalResponseSerializer(result).serialize();
}
}
use of com.enonic.xp.portal.impl.mapper.PortalRequestMapper in project xp by enonic.
the class ResponseProcessorExecutor method executeFilter.
private PortalResponse executeFilter(final ScriptExports filterExports, final PortalRequest request, final PortalResponse response) {
final PortalRequestMapper requestMapper = new PortalRequestMapper(request);
final PortalResponseMapper responseMapper = new PortalResponseMapper(response);
final ScriptValue result = filterExports.executeMethod(RESPONSE_PROCESSOR_METHOD, requestMapper, responseMapper);
final PortalResponseSerializer portalResponseSerializer = new PortalResponseSerializer(result);
if (unmodifiedByteSourceBody(response, result)) {
portalResponseSerializer.body(response.getBody());
}
addTraceInfo(Tracer.current(), filterExports);
return portalResponseSerializer.serialize();
}
use of com.enonic.xp.portal.impl.mapper.PortalRequestMapper in project xp by enonic.
the class ControllerScriptImpl method doExecute.
private PortalResponse doExecute(final PortalRequest portalRequest) {
Tracer.withCurrent(this::addTraceInfo);
final HttpMethod method = portalRequest.getMethod();
final boolean isHead = method == HttpMethod.HEAD;
String runMethod = isHead ? "get" : method.toString().toLowerCase();
final boolean exists = this.scriptExports.hasMethod(runMethod);
if (!exists) {
if (this.scriptExports.hasMethod(ALL_SCRIPT_METHOD_NAME)) {
runMethod = ALL_SCRIPT_METHOD_NAME;
} else {
return new PortalResponseSerializer(null, HttpStatus.METHOD_NOT_ALLOWED).serialize();
}
}
final PortalRequestMapper requestMapper = new PortalRequestMapper(portalRequest);
final ScriptValue result = this.scriptExports.executeMethod(runMethod, requestMapper);
return new PortalResponseSerializer(result).serialize();
}
Aggregations