Search in sources :

Example 1 with V3UsageMessage

use of org.ovirt.engine.api.v3.types.V3UsageMessage in project ovirt-engine by oVirt.

the class V3UsageFinder method getUsageMessage.

public V3UsageMessage getUsageMessage(UriInfo uriInfo, Request request) throws ClassNotFoundException, IOException {
    V3UsageMessage usage = new V3UsageMessage();
    usage.setMessage(RESPONSE);
    usage.setDetailedLink(findUsage(uriInfo, request.getMethod()));
    return usage;
}
Also used : V3UsageMessage(org.ovirt.engine.api.v3.types.V3UsageMessage)

Example 2 with V3UsageMessage

use of org.ovirt.engine.api.v3.types.V3UsageMessage in project ovirt-engine by oVirt.

the class V3IOExceptionMapper method toResponse.

@Override
public Response toResponse(IOException exception) {
    // Check if the cause of the exception is an invalid value, and generate a specific error message:
    Throwable cause = exception.getCause();
    if (cause instanceof InvalidValueException) {
        V3Fault fault = new V3Fault();
        fault.setReason("Invalid value");
        fault.setDetail(cause.getMessage());
        return Response.status(Status.BAD_REQUEST).entity(fault).build();
    }
    // the request:
    try {
        log.error("IO exception while processing \"{}\" request for path \"{}\"", request.getMethod(), uriInfo.getPath());
        log.error("Exception", exception);
        V3UsageFinder finder = new V3UsageFinder();
        V3UsageMessage usage = finder.getUsageMessage(uriInfo, request);
        return Response.status(Status.BAD_REQUEST).entity(usage).build();
    } catch (Exception error) {
        throw new WebApplicationException(error, Response.status(Status.INTERNAL_SERVER_ERROR).build());
    }
}
Also used : InvalidValueException(org.ovirt.engine.api.utils.InvalidValueException) V3Fault(org.ovirt.engine.api.v3.types.V3Fault) WebApplicationException(javax.ws.rs.WebApplicationException) V3UsageMessage(org.ovirt.engine.api.v3.types.V3UsageMessage) IOException(java.io.IOException) InvalidValueException(org.ovirt.engine.api.utils.InvalidValueException) WebApplicationException(javax.ws.rs.WebApplicationException)

Aggregations

V3UsageMessage (org.ovirt.engine.api.v3.types.V3UsageMessage)2 IOException (java.io.IOException)1 WebApplicationException (javax.ws.rs.WebApplicationException)1 InvalidValueException (org.ovirt.engine.api.utils.InvalidValueException)1 V3Fault (org.ovirt.engine.api.v3.types.V3Fault)1