Search in sources :

Example 1 with UnboundReasoningServiceException

use of org.apache.stanbol.reasoners.servicesapi.UnboundReasoningServiceException in project stanbol by apache.

the class ReasoningServicesResource method getServiceDocumentation.

@GET
@Produces(TEXT_HTML)
@Path("{service}")
public Response getServiceDocumentation(@PathParam(value = "service") String serviceID, @Context HttpHeaders headers) {
    try {
        this.service = this.getServicesManager().get(serviceID);
    } catch (UnboundReasoningServiceException e) {
        log.info("Service {} is not bound", serviceID);
        ResponseBuilder rb = Response.status(Status.NOT_FOUND);
        rb.header(HttpHeaders.CONTENT_TYPE, TEXT_HTML + "; charset=utf-8");
        return rb.build();
    }
    ResponseBuilder rb = Response.ok(new Viewable("service", this));
    rb.header(HttpHeaders.CONTENT_TYPE, TEXT_HTML + "; charset=utf-8");
    return rb.build();
}
Also used : UnboundReasoningServiceException(org.apache.stanbol.reasoners.servicesapi.UnboundReasoningServiceException) Viewable(org.apache.stanbol.commons.web.viewable.Viewable) ResponseBuilder(javax.ws.rs.core.Response.ResponseBuilder) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Example 2 with UnboundReasoningServiceException

use of org.apache.stanbol.reasoners.servicesapi.UnboundReasoningServiceException in project stanbol by apache.

the class ReasoningServiceTaskResource method prepare.

public void prepare(String serviceID, String taskIDstr, String jobFlag) {
    this.taskID = taskIDstr;
    log.debug("Called service {} to perform task {}", serviceID, taskID);
    // Parameters for customized reasoning services
    this.parameters = prepareParameters();
    // Retrieve the service
    try {
        service = getService(serviceID);
    } catch (UnboundReasoningServiceException e) {
        log.error("Service not found: {}", serviceID);
        throw new WebApplicationException(e, Response.Status.NOT_FOUND);
    }
    log.debug("Service retrieved");
    // Check if the task is allowed
    if (this.service.supportsTask(taskID) || taskID.equals(ReasoningServiceExecutor.TASK_CHECK)) {
    // Ok
    } else {
        log.error("Unsupported task (not found): {}", taskID);
        throw new WebApplicationException(new Exception("Unsupported task (not found): " + taskID), Response.Status.NOT_FOUND);
    }
    // Check for the job parameter
    if (!jobFlag.equals("")) {
        log.debug("Job param is {}", job);
        if (jobFlag.equals("/job")) {
            log.debug("Ask for background job");
            this.job = true;
        } else {
            log.error("Malformed request");
            throw new WebApplicationException(Response.Status.BAD_REQUEST);
        }
    }
    // Now we check if the service implementation is supported
    if (getCurrentService() instanceof JenaReasoningService) {
    } else if (getCurrentService() instanceof OWLApiReasoningService) {
    } else {
        log.error("This implementation of ReasoningService is not supported: {}", getCurrentService().getClass());
        throw new WebApplicationException(new Exception("This implementation of ReasoningService is not supported: " + getCurrentService().getClass()), Response.Status.INTERNAL_SERVER_ERROR);
    }
    log.debug("Implementation is supported");
}
Also used : UnboundReasoningServiceException(org.apache.stanbol.reasoners.servicesapi.UnboundReasoningServiceException) JenaReasoningService(org.apache.stanbol.reasoners.jena.JenaReasoningService) WebApplicationException(javax.ws.rs.WebApplicationException) OWLApiReasoningService(org.apache.stanbol.reasoners.owlapi.OWLApiReasoningService) WebApplicationException(javax.ws.rs.WebApplicationException) UnboundReasoningServiceException(org.apache.stanbol.reasoners.servicesapi.UnboundReasoningServiceException) UnsupportedEncodingException(java.io.UnsupportedEncodingException)

Aggregations

UnboundReasoningServiceException (org.apache.stanbol.reasoners.servicesapi.UnboundReasoningServiceException)2 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 GET (javax.ws.rs.GET)1 Path (javax.ws.rs.Path)1 Produces (javax.ws.rs.Produces)1 WebApplicationException (javax.ws.rs.WebApplicationException)1 ResponseBuilder (javax.ws.rs.core.Response.ResponseBuilder)1 Viewable (org.apache.stanbol.commons.web.viewable.Viewable)1 JenaReasoningService (org.apache.stanbol.reasoners.jena.JenaReasoningService)1 OWLApiReasoningService (org.apache.stanbol.reasoners.owlapi.OWLApiReasoningService)1