*/
@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException,
IOException {
String queryString = request.getQueryString();
CallbackService callbackService = Services.get().get(CallbackService.class);
if (!callbackService.isValid(queryString)) {
throw new XServletException(HttpServletResponse.SC_BAD_REQUEST, ErrorCode.E0402, queryString);
}
String actionId = callbackService.getActionId(queryString);
if (actionId == null) {
throw new XServletException(HttpServletResponse.SC_BAD_REQUEST, ErrorCode.E0402, queryString);
}
int idx = actionId.lastIndexOf('@', actionId.length());
String jobId;
if (idx == -1) {
jobId = actionId;
}
else {
jobId = actionId.substring(0, idx);
}
setLogInfo(jobId, actionId);
log = XLog.getLog(getClass());
log.debug("Received a CallbackServlet.doPost() with query string " + queryString);
validateContentType(request, RestConstants.TEXT_CONTENT_TYPE);
try {
log.info(XLog.STD, "callback for action [{0}]", actionId);
String data = IOUtils.getReaderAsString(request.getReader(), maxDataLen);
Properties props = PropertiesUtils.stringToProperties(data);
DagEngine dagEngine = Services.get().get(DagEngineService.class).getSystemDagEngine();
dagEngine.processCallback(actionId, callbackService.getExternalStatus(queryString), props);
}
catch (IOException ex) {
if (ex.getMessage().startsWith("stream exceeds limit")) {
// TODO, WE MUST SET THE ACTION TO ERROR
throw new XServletException(HttpServletResponse.SC_BAD_REQUEST, ErrorCode.E0403, "data too long");