private void createEvent(AIP aip, ModelService model, IndexService index, PluginState state, boolean notify) throws PluginException { try { PluginHelper.createPluginEvent(this, aip.getId(), model, index, state, "", notify); } catch (RODAException e) { throw new PluginException(e.getMessage(), e); } }
public static String runSiegfriedOnPath(Path sourceDirectory) throws PluginException { try { String siegfriedMode = RodaCoreFactory.getRodaConfigurationAsString("core", "tools", "siegfried", "mode"); if ("server".equalsIgnoreCase(siegfriedMode)) { LOGGER.debug("Running Siegfried on server mode"); String endpoint = getSiegfriedServerEndpoint(sourceDirectory); return HTTPUtility.doGet(endpoint); } else { LOGGER.debug("Running Siegfried on standalone mode"); List<String> command = getBatchCommand(sourceDirectory); return CommandUtility.execute(command, false); } } catch (CommandException | GenericException e) { throw new PluginException("Error while executing Siegfried: " + e.getMessage()); } }
} catch (RequestNotValidException | NotFoundException | GenericException | AuthorizationDeniedException | ValidationException | AlreadyExistsException e) { throw new PluginException(e.getMessage(), e);
protected void createUnpackingEventSuccess(ModelService model, IndexService index, TransferredResource transferredResource, AIP aip, String unpackDescription) { setPreservationEventType(UNPACK_EVENT_TYPE); setPreservationSuccessMessage(UNPACK_SUCCESS_MESSAGE); setPreservationFailureMessage(UNPACK_FAILURE_MESSAGE); setPreservationEventDescription(unpackDescription); try { boolean notify = true; PluginHelper.createPluginEvent(this, aip.getId(), model, index, transferredResource, PluginState.SUCCESS, "", notify); } catch (NotFoundException | RequestNotValidException | GenericException | AuthorizationDeniedException | ValidationException | AlreadyExistsException e) { LOGGER.warn("Error creating unpacking event: " + e.getMessage(), e); } }
protected void createWellformedEventSuccess(ModelService model, IndexService index, TransferredResource transferredResource, AIP aip) { setPreservationEventType(WELLFORMED_EVENT_TYPE); setPreservationSuccessMessage(WELLFORMED_SUCCESS_MESSAGE); setPreservationFailureMessage(WELLFORMED_FAILURE_MESSAGE); setPreservationEventDescription(WELLFORMED_DESCRIPTION); try { boolean notify = true; PluginHelper.createPluginEvent(this, aip.getId(), model, index, transferredResource, PluginState.SUCCESS, "", notify); } catch (NotFoundException | RequestNotValidException | GenericException | AuthorizationDeniedException | ValidationException | AlreadyExistsException e) { LOGGER.warn("Error creating unpacking event: " + e.getMessage(), e); } } }
throw new GenericException("Error setting user password - " + e.getMessage(), e);
private void updateAIPsToBeAppraised(ModelService model, List<AIP> aips, IngestJobPluginInfo jobPluginInfo) { for (AIP aip : aips) { aip.setState(AIPState.UNDER_APPRAISAL); try { aip = model.updateAIPState(aip, PluginHelper.getJobUsername(this, model)); getParameterValues().put(RodaConstants.PLUGIN_PARAMS_OUTCOMEOBJECTID_TO_SOURCEOBJECTID_MAP, JsonUtils.getJsonFromObject(jobPluginInfo.getAipIdToTransferredResourceIds())); // update main report outcomeObjectState PluginHelper.updateJobReportState(this, model, aip.getIngestSIPUUID(), aip.getId(), AIPState.UNDER_APPRAISAL); // update counters of manual intervention jobPluginInfo.incrementOutcomeObjectsWithManualIntervention(); } catch (GenericException | NotFoundException | RequestNotValidException | AuthorizationDeniedException e) { LOGGER.error("Error while updating AIP state to '{}'. Reason: {}", AIPState.UNDER_APPRAISAL, e.getMessage()); } } }
private void processAIP(IndexService index, ModelService model, Report report, Job job, AIP aip) { Report reportItem = PluginHelper.initPluginReportItem(this, aip.getId(), AIP.class, AIPState.INGEST_PROCESSING); PluginHelper.updatePartialJobReport(this, model, reportItem, false, job); String outcomeDetail = ""; try { LOGGER.debug("Auto accepting AIP {}", aip.getId()); if (aip.getState() != AIPState.ACTIVE) { aip.setState(AIPState.ACTIVE); model.updateAIPState(aip, job.getUsername()); } reportItem.setPluginState(PluginState.SUCCESS).setOutcomeObjectState(AIPState.ACTIVE); LOGGER.debug("Done with auto accepting AIP {}", aip.getId()); } catch (RODAException e) { LOGGER.error("Error updating AIP (metadata attribute state=ACTIVE)", e); outcomeDetail = "Error updating AIP (metadata attribute state=ACTIVE): " + e.getMessage(); reportItem.setPluginState(PluginState.FAILURE).setPluginDetails(outcomeDetail) .setOutcomeObjectState(AIPState.UNDER_APPRAISAL); } try { boolean notify = true; PluginHelper.createPluginEvent(this, aip.getId(), model, index, reportItem.getPluginState(), outcomeDetail, notify); } catch (ValidationException | RequestNotValidException | NotFoundException | GenericException | AuthorizationDeniedException | AlreadyExistsException e) { LOGGER.error("Error creating event: {}", e.getMessage(), e); } report.addReport(reportItem); PluginHelper.updatePartialJobReport(this, model, reportItem, true, job); }
reportItem.setPluginState(PluginState.FAILURE).setPluginDetails(e.getMessage());
private void fixAncestors(IndexService index, ModelService model, Report report, JobPluginInfo jobPluginInfo, int counter) { try { Optional<String> computedSearchScope = PluginHelper.getSearchScopeFromParameters(this, model); Job originalJob = PluginHelper.getJob(originalJobId, model); PluginHelper.fixParents(index, model, Optional.ofNullable(originalJob.getId()), computedSearchScope, originalJob.getUsername()); jobPluginInfo.incrementObjectsProcessedWithSuccess(counter); report.setPluginState(PluginState.SUCCESS); } catch (NotFoundException | GenericException | RequestNotValidException | AuthorizationDeniedException e) { LOGGER.error("Error when fixing ancestors", e); jobPluginInfo.incrementObjectsProcessedWithFailure(counter); report.setPluginState(PluginState.FAILURE); Report reportItem = PluginHelper.initPluginReportItem(this, "", AIP.class); reportItem.setPluginDetails("Ancestors fix failed: " + e.getMessage()); reportItem.setPluginState(PluginState.FAILURE); report.addReport(reportItem); try { PluginHelper.updatePartialJobReport(this, model, reportItem, true, PluginHelper.getJob(this, index)); } catch (NotFoundException | GenericException | RequestNotValidException e1) { LOGGER.error("Error when updating job when ancestors fix failed", e1); } } }
private void processDIP(ModelService model, Report report, JobPluginInfo jobPluginInfo, Job job, DIP dip) { PluginState state = PluginState.SUCCESS; Report reportItem = PluginHelper.initPluginReportItem(this, dip.getId(), DIP.class); try { model.deleteDIP(dip.getId()); } catch (NotFoundException | GenericException | AuthorizationDeniedException e) { state = PluginState.FAILURE; reportItem.addPluginDetails("Could not delete DIP: " + e.getMessage()); } report.addReport(reportItem.setPluginState(state)); PluginHelper.updatePartialJobReport(this, model, reportItem, true, job); jobPluginInfo.incrementObjectsProcessed(state); }
private void handleJobStateUpdated(Messages.JobStateUpdated message) { markMessageProcessingAsStarted(message); Plugin<?> p = message.getPlugin() == null ? this.plugin : message.getPlugin(); try { Job job = PluginHelper.getJob(p, getIndex()); LOGGER.info("Setting job '{}' ({}) state to {}. Details: {}", job.getName(), job.getId(), message.getState(), message.getStateDatails().orElse("NO DETAILS")); } catch (NotFoundException | GenericException | RequestNotValidException e) { LOGGER.warn("Unable to get Job from index to log its state change. Reason: {}", e.getMessage()); } JobsHelper.updateJobState(p, getModel(), message.getState(), message.getStateDatails()); if (Job.isFinalState(message.getState())) { // 20160817 hsilva: the following instruction is needed for the "sync" // execution of a job (i.e. for testing purposes) jobCreator.tell("Done", getSelf()); jobsManager.tell(Messages.newJobsManagerJobEnded(jobId, plugin.getClass().getName()), getSelf()); JobsHelper.deleteJobWorkingDirectory(jobId); getContext().stop(getSelf()); } markMessageProcessingAsEnded(message); }
private void processDIP(ModelService model, Report report, JobPluginInfo jobPluginInfo, Job job, DIP dip) { PluginState state = PluginState.SUCCESS; Report reportItem = PluginHelper.initPluginReportItem(this, dip.getId(), DIP.class); try { dip.setPermissions(permissions); model.updateDIPPermissions(dip); } catch (GenericException | NotFoundException | RequestNotValidException | AuthorizationDeniedException e) { state = PluginState.FAILURE; reportItem.addPluginDetails("Could not update DIP permissions: " + e.getMessage()); } finally { // TODO 20170222 nvieira it should create an event associated with DIP reportItem.setPluginState(state); report.addReport(reportItem); jobPluginInfo.incrementObjectsProcessed(state); PluginHelper.updatePartialJobReport(this, model, reportItem, true, job); } }
private void processDIPFile(ModelService model, Report report, JobPluginInfo jobPluginInfo, Job job, DIPFile dipFile) { PluginState state = PluginState.SUCCESS; Report reportItem = PluginHelper.initPluginReportItem(this, dipFile.getId(), DIPFile.class); try { model.deleteDIPFile(dipFile.getDipId(), dipFile.getPath(), dipFile.getId(), false); } catch (NotFoundException | GenericException | AuthorizationDeniedException | RequestNotValidException e) { state = PluginState.FAILURE; reportItem.addPluginDetails("Could not delete DIP file: " + e.getMessage()); } report.addReport(reportItem.setPluginState(state)); PluginHelper.updatePartialJobReport(this, model, reportItem, true, job); jobPluginInfo.incrementObjectsProcessed(state); }
} catch (ValidationException | RequestNotValidException | NotFoundException | GenericException | AuthorizationDeniedException | AlreadyExistsException e) { LOGGER.error("Error creating event: {}", e.getMessage(), e);
private void processAIPs(ModelService model, JobPluginInfo jobPluginInfo, Job cachedJob, List<AIP> list) { for (AIP aip : list) { try { LOGGER.debug("Processing AIP {}", aip.getId()); String parentId = aip.getParentId(); if (parentId != null) { try { model.retrieveAIP(parentId); } catch (RODAException e) { // orphan was found aip.setParentId(newParentId); model.updateAIP(aip, cachedJob.getUsername()); // reporting Report reportItem = PluginHelper.initPluginReportItem(this, aip.getId(), AIP.class, AIPState.ACTIVE) .setPluginState(PluginState.SUCCESS) .setPluginDetails(String.format(MOVED_ORPHAN_AIP_FROM_TO, parentId, newParentId)); PluginHelper.updatePartialJobReport(this, model, reportItem, true, cachedJob); } } jobPluginInfo.incrementObjectsProcessedWithSuccess(); } catch (RODAException e) { LOGGER.error("Error processing AIP {} (RemoveOrphansAction)", aip.getId(), e); Report reportItem = PluginHelper.initPluginReportItem(this, aip.getId(), AIP.class, AIPState.ACTIVE) .setPluginState(PluginState.FAILURE).addPluginDetails(e.getMessage()); PluginHelper.updatePartialJobReport(this, model, reportItem, true, cachedJob); jobPluginInfo.incrementObjectsProcessedWithFailure(); } } }
} catch (ValidationException | RequestNotValidException | NotFoundException | GenericException | AuthorizationDeniedException | AlreadyExistsException e) { LOGGER.error("Error creating event: {}", e.getMessage(), e);
} catch (GenericException | NotFoundException | RequestNotValidException | AuthorizationDeniedException e) { state = PluginState.FAILURE; reportItem.addPluginDetails("Could not update AIP permissions: " + e.getMessage()); outcome = "AIP " + aip.getId() + " or some of its child permissions were not successfully updated: " + e.getMessage(); } finally { reportItem.setPluginState(state);
LOGGER.error("Error processing AIP {}: {}", aip.getId(), mse.getMessage(), mse);
private void processRisk(IndexService index, ModelService model, Report report, JobPluginInfo jobPluginInfo, Job job, Risk risk) { Report reportItem = PluginHelper.initPluginReportItem(this, risk.getId(), Risk.class); PluginState state = PluginState.SUCCESS; try { Filter incidenceFilter = new Filter( new SimpleFilterParameter(RodaConstants.RISK_INCIDENCE_RISK_ID, risk.getId())); deleteRelatedIncidences(model, index, incidenceFilter); } catch (GenericException | RequestNotValidException | NotFoundException | AuthorizationDeniedException e) { reportItem.addPluginDetails("Could not delete representation related incidences: " + e.getMessage()); state = PluginState.FAILURE; } try { model.deleteRisk(risk.getId(), true); } catch (GenericException | NotFoundException | AuthorizationDeniedException | RequestNotValidException e) { state = PluginState.FAILURE; } report.addReport(reportItem.setPluginState(state)); PluginHelper.updatePartialJobReport(this, model, reportItem, true, job); jobPluginInfo.incrementObjectsProcessed(state); }