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);
}
}
Aggregations