use of org.entando.entando.aps.system.services.api.server.IResponseBuilder in project entando-core by entando.
the class SelfRestCaller method executePostProcess.
@Override
public int executePostProcess(IPostProcess postProcess) throws InvalidPostProcessResultException, ApsSystemException {
if (!(postProcess instanceof SelfRestCallPostProcess)) {
return 0;
}
SelfRestCallPostProcess selfRestCall = (SelfRestCallPostProcess) postProcess;
IResponseBuilder responseBuilder = this.getResponseBuilder();
try {
Object result = null;
ApiMethod method = responseBuilder.extractApiMethod(selfRestCall.getMethod(), selfRestCall.getNamespace(), selfRestCall.getResourceName());
Properties properties = this.extractParameters(selfRestCall);
if (method.getHttpMethod().equals(ApiMethod.HttpMethod.GET) || method.getHttpMethod().equals(ApiMethod.HttpMethod.DELETE)) {
result = responseBuilder.createResponse(method, properties);
} else {
String contentBody = this.getContentBody(selfRestCall);
Object bodyObject = UnmarshalUtils.unmarshal(method, contentBody, selfRestCall.getContentType());
result = responseBuilder.createResponse(method, bodyObject, properties);
}
Response.Status responseStatus = this.extractResponseStatusCode(result);
if (selfRestCall.isPrintResponse()) {
this.printResponse(selfRestCall, result, responseStatus, method, properties);
}
} catch (InvalidPostProcessResultException t) {
_logger.error("error in executePostProcess", t);
// ApsSystemUtils.logThrowable(t, this, "executePostProcess", t.getMessage());
throw t;
} catch (Throwable t) {
_logger.error("Error invoking api method", t);
// ApsSystemUtils.logThrowable(t, this, "executePostProcess", "Error invoking api method");
throw new ApsSystemException("Error invoking api method", t);
}
return 1;
}
Aggregations