Search in sources :

Example 6 with IncidentServiceException

use of org.opencastproject.serviceregistry.api.IncidentServiceException in project opencast by opencast.

the class IncidentServiceEndpoint method getLocalization.

@GET
@SuppressWarnings("unchecked")
@Produces(MediaType.APPLICATION_JSON)
@Path("localization/{id}")
@RestQuery(name = "getlocalization", description = "Returns the localization of an incident by it's id as JSON", returnDescription = "The localization of the incident as JSON", pathParameters = { @RestParameter(name = "id", isRequired = true, description = "The incident identifiers.", type = Type.INTEGER) }, restParameters = { @RestParameter(name = "locale", isRequired = true, description = "The locale.", type = Type.STRING) }, reponses = { @RestResponse(responseCode = SC_OK, description = "The localization of the given job incidents."), @RestResponse(responseCode = SC_NOT_FOUND, description = "No job incident with this incident identifier was found.") })
public Response getLocalization(@PathParam("id") final long incidentId, @QueryParam("locale") String locale) throws NotFoundException {
    try {
        IncidentL10n localization = svc.getLocalization(incidentId, LocaleUtils.toLocale(locale));
        JSONObject json = new JSONObject();
        json.put("title", localization.getTitle());
        json.put("description", localization.getDescription());
        return Response.ok(json.toJSONString()).build();
    } catch (IncidentServiceException e) {
        logger.warn("Unable to get job localization of jo incident:", e);
        throw new WebApplicationException(INTERNAL_SERVER_ERROR);
    }
}
Also used : JSONObject(org.json.simple.JSONObject) WebApplicationException(javax.ws.rs.WebApplicationException) IncidentServiceException(org.opencastproject.serviceregistry.api.IncidentServiceException) IncidentL10n(org.opencastproject.serviceregistry.api.IncidentL10n) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) RestQuery(org.opencastproject.util.doc.rest.RestQuery)

Aggregations

IncidentServiceException (org.opencastproject.serviceregistry.api.IncidentServiceException)6 GET (javax.ws.rs.GET)3 Path (javax.ws.rs.Path)3 Produces (javax.ws.rs.Produces)3 WebApplicationException (javax.ws.rs.WebApplicationException)3 Incident (org.opencastproject.job.api.Incident)3 IncidentTree (org.opencastproject.job.api.IncidentTree)3 NotFoundException (org.opencastproject.util.NotFoundException)3 RestQuery (org.opencastproject.util.doc.rest.RestQuery)3 MediaType (javax.ws.rs.core.MediaType)2 ServiceRegistryException (org.opencastproject.serviceregistry.api.ServiceRegistryException)2 JValue (com.entwinemedia.fn.data.json.JValue)1 ArrayList (java.util.ArrayList)1 JSONObject (org.json.simple.JSONObject)1 JobEndpointException (org.opencastproject.adminui.exception.JobEndpointException)1 IncidentTreeImpl (org.opencastproject.job.api.IncidentTreeImpl)1 JaxbIncident (org.opencastproject.job.api.JaxbIncident)1 JaxbIncidentDigestList (org.opencastproject.job.api.JaxbIncidentDigestList)1 JaxbIncidentFullList (org.opencastproject.job.api.JaxbIncidentFullList)1 JaxbIncidentFullTree (org.opencastproject.job.api.JaxbIncidentFullTree)1