public boolean alreadyRecordedFailureIncident(long jobId) { try { return findFailure(is.getIncidentsOfJob(jobId, true)); } catch (Exception e) { return false; } }
public void recordMigrationIncident(Job job, String error) { try { is.storeIncident(job, new Date(), SYSTEM_MIGRATED_ERROR, Severity.FAILURE, Collections.singletonMap("error", error), NO_DETAILS); } catch (IncidentServiceException e) { logException(e); } }
@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); } }
@GET @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) @Path("{id}.{type:xml|json}") @RestQuery(name = "incidentjson", description = "Returns the job incident by it's incident identifier.", returnDescription = "Returns the job incident.", pathParameters = { @RestParameter(name = "id", isRequired = true, description = "The incident identifier.", type = Type.INTEGER), @RestParameter(name = "type", isRequired = true, description = "The media type of the response [xml|json]", defaultValue = "xml", type = Type.STRING)}, reponses = { @RestResponse(responseCode = SC_OK, description = "The job incident."), @RestResponse(responseCode = SC_NOT_FOUND, description = "No job incident with this identifier was found.")}) public Response getIncident(@PathParam("id") final long incidentId, @PathParam("type") final String type) throws NotFoundException { try { Incident incident = svc.getIncident(incidentId); return ok(getResponseType(type), new JaxbIncident(incident)); } catch (IncidentServiceException e) { logger.warn("Unable to get job incident for incident id {}: {}", incidentId, e); throw new WebApplicationException(INTERNAL_SERVER_ERROR); } }
/** * Record an incident for a given job. This method is intended to record client incidents, i.e. incidents crafted by * the programmer. * * @param code * A code number. This incident factory method enforces an incident code schema of <code>job_type.code</code> * , e.g. <code>org.opencastproject.service.1511</code> . So instead of aligning * <code>job.getJobType()</code> and the incident's code prefix manually this is done automatically for you * by this method. See {@link org.opencastproject.job.api.Incident#getCode()}. * @see org.opencastproject.job.api.Incident */ public void record(Job job, Severity severity, int code, Map<String, String> params, List<Tuple<String, String>> details) { try { is.storeIncident(job, new Date(), job.getJobType() + "." + code, severity, params, details); } catch (IncidentServiceException e) { logException(e); } }
@PathParam("type") final String type) { try { final List<Incident> incidents = svc.getIncidentsOfJob(jobIds); final MediaType mt = getResponseType(type); if (eq(FMT_SYS, format)) {
Incident incident = svc.storeIncident(job, timestamp, code, severity, map, list); String uri = UrlSupport.concat(serverUrl, serviceUrl, Long.toString(incident.getId()), ".xml"); return Response.created(new URI(uri)).entity(new JaxbIncident(incident)).build();
throws NotFoundException { try { final IncidentTree tree = svc.getIncidentsOfJob(jobId, cascade); final MediaType mt = getResponseType(type); if (eq(FMT_SYS, format)) {
/** * Record an incident for a given job caused by an uncatched exception. This method is intended to record incidents by * the job system itself, e.g. the job dispatcher. */ private void unhandledException(Job job, String code, Severity severity, Throwable t) { if (!alreadyRecordedFailureIncident(job.getId())) { try { is.storeIncident( job, new Date(), code, severity, Collections.singletonMap("exception", ExceptionUtils.getMessage(t)), Arrays.asList(tuple("job-type", job.getJobType()), tuple("job-operation", job.getOperation()), tuple("stack-trace", ExceptionUtils.getStackTrace(t)))); } catch (IncidentServiceException e) { logException(e); } } }