use of org.apache.oozie.service.CallbackService in project oozie by apache.
the class CallbackServlet method doGet.
/**
* GET callback
*/
@Override
protected void doGet(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);
}
log = XLog.getLog(getClass());
setLogInfo(actionId);
log.debug("Received a CallbackServlet.doGet() with query string " + queryString);
DagEngine dagEngine = Services.get().get(DagEngineService.class).getSystemDagEngine();
try {
log.info(XLog.STD, "callback for action [{0}]", actionId);
dagEngine.processCallback(actionId, callbackService.getExternalStatus(queryString), null);
} catch (DagEngineException ex) {
throw new XServletException(HttpServletResponse.SC_BAD_REQUEST, ex);
}
}
use of org.apache.oozie.service.CallbackService in project oozie by apache.
the class TestCallbackService method testCallbacks.
public void testCallbacks() throws Exception {
CallbackService cs = Services.get().get(CallbackService.class);
assertNotNull(cs);
String callback = cs.createCallBackUrl("a", "@STATUS");
assertTrue(callback.contains("http://"));
assertTrue(callback.contains("id=a"));
assertTrue(callback.contains("status=@STATUS"));
callback = callback.replace("@STATUS", "OK");
assertEquals("a", cs.getActionId(callback));
assertEquals("OK", cs.getExternalStatus(callback));
}
use of org.apache.oozie.service.CallbackService in project oozie by apache.
the class CallbackServlet method doPost.
/**
* POST callback
*/
@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);
}
log = XLog.getLog(getClass());
setLogInfo(actionId);
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");
} else {
throw ex;
}
} catch (DagEngineException ex) {
throw new XServletException(HttpServletResponse.SC_BAD_REQUEST, ex);
}
}
use of org.apache.oozie.service.CallbackService in project oozie by apache.
the class TestCallbackService method testService.
public void testService() throws Exception {
CallbackService cs = Services.get().get(CallbackService.class);
assertNotNull(cs);
}
Aggregations