Search in sources :

Example 1 with ActionErrorException

use of org.apache.jena.fuseki.servlets.ActionErrorException in project jena by apache.

the class ValidatorBaseJson method execute.

protected void execute(HttpServletRequest request, HttpServletResponse response) {
    long id = allocRequestId(request, response);
    ValidationAction action = new ValidationAction(id, vLog, request, response, false);
    printRequest(action);
    action.setStartTime();
    response = action.response;
    initResponse(request, response);
    try {
        JsonObject obj = execute(action);
        action.statusCode = HttpSC.OK_200;
        action.message = "OK";
        response.setCharacterEncoding(charsetUTF8);
        response.setContentType(contentTypeJSON);
        //response.setContentType(WebContent.contentTypeTextPlain);
        action.response.setStatus(HttpSC.OK_200);
        OutputStream out = response.getOutputStream();
        JSON.write(out, obj);
    } catch (ActionErrorException ex) {
        if (ex.getCause() != null)
            ex.getCause().printStackTrace(System.err);
        if (ex.getMessage() != null)
            ServletOps.responseSendError(response, ex.getRC(), ex.getMessage());
        else
            ServletOps.responseSendError(response, ex.getRC());
    } catch (Throwable th) {
        ServletOps.responseSendError(response, HttpSC.INTERNAL_SERVER_ERROR_500, "Internal Error");
    }
    action.setFinishTime();
    printResponse(action);
}
Also used : ValidationAction(org.apache.jena.fuseki.validation.json.ValidationAction) OutputStream(java.io.OutputStream) JsonObject(org.apache.jena.atlas.json.JsonObject) ActionErrorException(org.apache.jena.fuseki.servlets.ActionErrorException)

Example 2 with ActionErrorException

use of org.apache.jena.fuseki.servlets.ActionErrorException in project jena by apache.

the class ValidatorBase method executeJSON.

protected void executeJSON(HttpServletRequest request, HttpServletResponse response, JsonAction jsonAction) {
    long id = allocRequestId(request, response);
    ValidationAction action = new ValidationAction(id, vLog, request, response, false);
    printRequest(action);
    action.setStartTime();
    response = action.response;
    initResponse(request, response);
    try {
        JsonObject obj = jsonAction.execute(action);
        action.statusCode = HttpSC.OK_200;
        action.message = "OK";
        response.setCharacterEncoding(charsetUTF8);
        response.setContentType(contentTypeJSON);
        //response.setContentType(WebContent.contentTypeTextPlain);
        action.response.setStatus(HttpSC.OK_200);
        OutputStream out = response.getOutputStream();
        JSON.write(out, obj);
    } catch (ActionErrorException ex) {
        if (ex.getCause() != null)
            ex.getCause().printStackTrace(System.err);
        if (ex.getMessage() != null)
            ServletOps.responseSendError(response, ex.getRC(), ex.getMessage());
        else
            ServletOps.responseSendError(response, ex.getRC());
    } catch (Throwable th) {
        ServletOps.responseSendError(response, HttpSC.INTERNAL_SERVER_ERROR_500, "Internal Error");
    }
    action.setFinishTime();
    printResponse(action);
}
Also used : ValidationAction(org.apache.jena.fuseki.validation.json.ValidationAction) OutputStream(java.io.OutputStream) JsonObject(org.apache.jena.atlas.json.JsonObject) ActionErrorException(org.apache.jena.fuseki.servlets.ActionErrorException)

Aggregations

OutputStream (java.io.OutputStream)2 JsonObject (org.apache.jena.atlas.json.JsonObject)2 ActionErrorException (org.apache.jena.fuseki.servlets.ActionErrorException)2 ValidationAction (org.apache.jena.fuseki.validation.json.ValidationAction)2