public static <T extends Serializable> T sendPostRequest(T element, Class<T> elementClass, String url, String resource, String username, String password) throws RODAException { CloseableHttpClient httpClient = HttpClientBuilder.create().build(); String basicAuthToken = new String(Base64.encode((username + ":" + password).getBytes())); HttpPost httpPost = new HttpPost(url + resource); httpPost.setHeader("Authorization", "Basic " + basicAuthToken); httpPost.addHeader("content-type", "application/json"); httpPost.addHeader("Accept", "application/json"); try { httpPost.setEntity(new StringEntity(JsonUtils.getJsonFromObject(element))); HttpResponse response; response = httpClient.execute(httpPost); HttpEntity responseEntity = response.getEntity(); int responseStatusCode = response.getStatusLine().getStatusCode(); if (responseStatusCode == 201) { return JsonUtils.getObjectFromJson(responseEntity.getContent(), elementClass); } else { throw new RODAException("POST request response status code: " + responseStatusCode); } } catch (IOException e) { throw new RODAException("Error sending POST request", e); } }
id = IdUtils.createUUID(); RODAException cause = logEntry.getCause(); message.append("[" + cause.getClass().getSimpleName() + "] " + cause.getMessage()); if (cause.getCause() != null) { message.append( "\n cause: [" + cause.getCause().getClass().getSimpleName() + "] " + cause.getCause().getMessage());
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); } }
throw new NoSuchElementException("Error getting next item in list: " + e.getMessage());
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()); } }
ReturnWithExceptions<Void, ModelObserver> exceptions = new ReturnWithExceptions<>(); exceptions .add(new RODAException("Error trying to reindex an unconfigured object class: " + objectClass.getName())); return exceptions;
} catch (RequestNotValidException | NotFoundException | GenericException | AuthorizationDeniedException | ValidationException | AlreadyExistsException e) { throw new PluginException(e.getMessage(), e);
@Override public void migrate(StorageService storage) throws RODAException { try (CloseableIterable<Resource> risks = storage.listResourcesUnderDirectory(ModelUtils.getRiskContainerPath(), false)) { for (Resource resource : risks) { if (!resource.isDirectory() && resource instanceof Binary) { Binary binary = (Binary) resource; migrate(storage, binary); } } } catch (IOException e) { throw new RODAException(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); } }
state = PluginState.FAILURE; Report reportItem = PluginHelper.initPluginReportItem(this, file.getId(), File.class); reportItem.addPluginDetails("Could not move file: " + e.getMessage()).setPluginState(state); report.addReport(reportItem); PluginHelper.updatePartialJobReport(this, model, reportItem, true, job); .append(e.getClass().getSimpleName()).append("] ").append(e.getMessage());
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); } } }
if (exception != null) { failureMessage = "RODA object conversion from lite throwed an error: [" + exception.getClass().getName() + "] " + exception.getMessage(); } else { failureMessage = "RODA object conversion from lite throwed an error."; if (exception != null) { failureMessage = "RODA object conversion from lite throwed an error: [" + exception.getClass().getName() + "] " + exception.getMessage(); } else { failureMessage = "RODA object conversion from lite throwed an error.";
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()); } } }
throw new GenericException("Error setting user password - " + e.getMessage(), e);
} catch (PluginException | NotFoundException | GenericException | RequestNotValidException | AuthorizationDeniedException e) { LOGGER.error("Error running Siegfried {}: {}", representation.getAipId(), e.getMessage(), e); .setPluginDetails("Error running Siegfried " + representation.getAipId() + ": " + e.getMessage()); } catch (ValidationException | RequestNotValidException | NotFoundException | GenericException | AuthorizationDeniedException | AlreadyExistsException e) { LOGGER.error("Error creating event: {}", e.getMessage(), e);
} catch (PluginException | NotFoundException | GenericException | RequestNotValidException | AuthorizationDeniedException e) { LOGGER.error("Error running Siegfried {}: {}", aip.getId(), e.getMessage(), e); .setPluginDetails("Error running Siegfried " + aip.getId() + ": " + e.getMessage()); } catch (ValidationException | RequestNotValidException | NotFoundException | GenericException | AuthorizationDeniedException | AlreadyExistsException e) { LOGGER.error("Error creating event: {}", e.getMessage(), e);
} catch (PluginException | NotFoundException | GenericException | RequestNotValidException | AuthorizationDeniedException e) { LOGGER.error("Error running Siegfried on file {}: {}", file.getId(), e.getMessage(), e); .setPluginDetails("Error running Siegfried on file " + file.getId() + ": " + e.getMessage()); } catch (ValidationException | RequestNotValidException | NotFoundException | GenericException | AuthorizationDeniedException | AlreadyExistsException e) { LOGGER.error("Error creating event: {}", e.getMessage(), e);
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); }
} catch (ValidationException | RequestNotValidException | NotFoundException | GenericException | AuthorizationDeniedException | AlreadyExistsException e) { LOGGER.error("Error creating event: {}", e.getMessage(), e);
reportItem.setPluginState(PluginState.FAILURE).setPluginDetails(e.getMessage());