handleException(resp, "Task service is unavailable", null);
return;
}
String taskId = path.segment(1);
boolean keep = "id".equals(path.segment(0));
TaskInfo task = taskService.getTask(TaskJobHandler.getUserId(req), taskId, keep);
if (task == null) {
JSONObject errorDescription = new JSONObject();
try {
errorDescription.put("taskNotFound", taskId);
handleException(resp, new ServerStatus(IStatus.ERROR, HttpServletResponse.SC_NOT_FOUND, "Task not found: " + taskId, errorDescription, null));
// handleException(resp, "Task not found: " + taskId, null, HttpServletResponse.SC_NOT_FOUND);
} catch (JSONException e) {
handleException(resp, e.getMessage(), e);
}
return;
}
JSONObject result = task.toJSON();
if (task.isKeep()) {
try {
if (result.optString(ProtocolConstants.KEY_LOCATION, "").equals(""))
result.put(ProtocolConstants.KEY_LOCATION, ServletResourceHandler.getURI(req));
} catch (JSONException e) {
handleException(resp, e.getMessage(), e);
}
}
IURIUnqualificationStrategy strategy = task.getUnqualificationStrategy();
writeJSONResponse(req, resp, result, strategy);
}