public static String getRepresentationId(Representation representation) { return getRepresentationId(representation.getAipId(), representation.getId()); }
private void processRepresentation(ModelService model, Report report, JobPluginInfo jobPluginInfo, Job job, List<Representation> representations) { for (Representation representation : representations) { Report reportItem = PluginHelper.initPluginReportItem(this, representation.getId(), Representation.class); PluginHelper.updatePartialJobReport(this, model, reportItem, false, job); PluginState state = PluginState.SUCCESS; try { model.changeRepresentationType(representation.getAipId(), representation.getId(), newType, job.getUsername()); } catch (RequestNotValidException | NotFoundException | GenericException | AuthorizationDeniedException e) { state = PluginState.FAILURE; } finally { jobPluginInfo.incrementObjectsProcessed(state); reportItem.setPluginState(state); StringBuilder outcomeText = new StringBuilder().append("The representation '").append(representation.getId()) .append(" of AIP ").append(representation.getAipId()).append("' changed its type from '") .append(representation.getType()).append("' to '").append(newType).append("'."); model.createUpdateAIPEvent(representation.getAipId(), representation.getId(), null, null, PreservationEventType.UPDATE, EVENT_DESCRIPTION, state, outcomeText.toString(), details, job.getUsername(), true); report.addReport(reportItem); PluginHelper.updatePartialJobReport(this, model, reportItem, true, job); } } }
@Override public ReturnWithExceptions<Void, ModelObserver> representationUpdated(Representation representation) { ReturnWithExceptions<Void, ModelObserver> ret = representationDeleted(representation.getAipId(), representation.getId(), false); representationCreated(representation).addTo(ret); return ret; }
public static <T extends IsRODAObject> List<LinkingIdentifier> runSiegfriedOnRepresentation(ModelService model, Representation representation) throws GenericException, RequestNotValidException, NotFoundException, AuthorizationDeniedException, PluginException { StoragePath representationDataPath = ModelUtils.getRepresentationDataStoragePath(representation.getAipId(), representation.getId()); try (DirectResourceAccess directAccess = model.getStorage().getDirectAccess(representationDataPath)) { Path representationFsPath = directAccess.getPath(); List<LinkingIdentifier> sources = runSiegfriedOnRepresentationOrFile(model, representation.getAipId(), representation.getId(), new ArrayList<>(), null, representationFsPath); return sources; } catch (IOException e) { throw new GenericException(e); } }
Representation.class); PluginHelper.updatePartialJobReport(this, model, reportItem, false, job); LOGGER.debug("Processing representation {} of AIP {}", representation.getId(), representation.getAipId()); try { sources.addAll(SiegfriedPluginUtils.runSiegfriedOnRepresentation(model, representation)); } 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()); PluginHelper.createPluginEvent(this, representation.getAipId(), representation.getId(), model, index, sources, null, reportItem.getPluginState(), "", true); } catch (ValidationException | RequestNotValidException | NotFoundException | GenericException
} else if (object instanceof Representation) { Representation o = (Representation) object; ret = get(Representation.class, Arrays.asList(o.getAipId(), o.getId()), false); } else if (object instanceof User) { User o = (User) object;
LOGGER.debug("Processing representation {} from AIP {}", representation.getId(), representation.getAipId()); Report reportItem = PluginHelper.initPluginReportItem(this, IdUtils.getRepresentationId(representation), Representation.class, AIPState.ACTIVE); PremisSkeletonPluginUtils.createPremisSkeletonOnRepresentation(model, representation.getAipId(), representation.getId(), algorithms); model.notifyRepresentationUpdated(representation); PluginHelper.createPluginEvent(this, representation.getAipId(), representation.getId(), model, index, null, null, reportItem.getPluginState(), "", notify); } catch (ValidationException | RequestNotValidException | NotFoundException | GenericException
private CloseableIterable<OptionalWithCause<File>> listFiles() throws RequestNotValidException, GenericException, NotFoundException, AuthorizationDeniedException { CloseableIterable<OptionalWithCause<Representation>> representations = listRepresentations(); return CloseableIterables.concat(representations, rep -> { if (rep.isPresent()) { Representation representation = rep.get(); try { return listFilesUnder(representation.getAipId(), representation.getId(), true); } catch (RODAException e) { LOGGER.error("Error listing files under representation: {}", representation.getId(), e); return CloseableIterables.empty(); } } else { return CloseableIterables.empty(); } }); }
@Override public ReturnWithExceptions<Void, ModelObserver> representationCreated(Representation representation) { ReturnWithExceptions<Void, ModelObserver> ret = new ReturnWithExceptions<>(this); try { AIP aip = model.retrieveAIP(representation.getAipId()); List<String> ancestors = SolrUtils.getAncestors(aip.getParentId(), model); indexRepresentation(aip, representation, ancestors).addTo(ret); if (ret.isEmpty()) { indexPreservationsEvents(aip.getId(), representation.getId()).addTo(ret); if (aip.getRepresentations().size() == 1) { SolrUtils.update(index, IndexedAIP.class, aip.getId(), Collections.singletonMap(RodaConstants.AIP_HAS_REPRESENTATIONS, true), (ModelObserver) this).addTo(ret); } } } catch (RequestNotValidException | NotFoundException | GenericException | AuthorizationDeniedException e) { LOGGER.error("Cannot index representation: {}", representation, e); ret.add(e); } return ret; }
state = PluginState.FAILURE; LOGGER.error("Failed to execute premis skeleton plugin on representation {} from AIP {}", representation.getId(), representation.getAipId(), e);
private ReturnWithExceptions<Void, ModelObserver> representationStateUpdated(final AIP aip, final Representation representation) { ReturnWithExceptions<Void, ModelObserver> ret = new ReturnWithExceptions<>(this); try (CloseableIterable<OptionalWithCause<File>> allFiles = model.listFilesUnder(representation.getAipId(), representation.getId(), true)) { SolrUtils.update(index, IndexedRepresentation.class, IdUtils.getRepresentationId(representation), Collections.singletonMap(RodaConstants.INDEX_STATE, SolrUtils.formatEnum(aip.getState())), (ModelObserver) this) .addTo(ret); if (ret.isEmpty()) { for (OptionalWithCause<File> file : allFiles) { if (file.isPresent()) { fileStateUpdated(aip, file.get(), false).addTo(ret); } else { LOGGER.error("Cannot do a partial update on File", file.getCause()); ret.add(file.getCause()); } } } else { LOGGER.error("Cannot index representation: {}", representation); } } catch (AuthorizationDeniedException | IOException | NotFoundException | GenericException | RequestNotValidException e) { LOGGER.error("Cannot do a partial update", e); ret.add(e); } return ret; }
model.deleteRepresentation(representation.getAipId(), representation.getId()); } catch (NotFoundException | GenericException | RequestNotValidException | AuthorizationDeniedException e) { state = PluginState.FAILURE; new SimpleFilterParameter(RodaConstants.RISK_INCIDENCE_AIP_ID, representation.getAipId()), new SimpleFilterParameter(RodaConstants.RISK_INCIDENCE_REPRESENTATION_ID, representation.getId())); deleteRelatedIncidences(model, index, incidenceFilter); model.deletePreservationMetadata(PreservationMetadataType.REPRESENTATION, representation.getAipId(), representation.getId(), pmId, false); } catch (RequestNotValidException | NotFoundException | GenericException | AuthorizationDeniedException e) { sources.add(PluginHelper.getLinkingIdentifier(representation.getAipId(), representation.getId(), RodaConstants.PRESERVATION_LINKING_OBJECT_SOURCE)); model.createEvent(representation.getAipId(), representation.getId(), null, null, PreservationEventType.DELETION, EVENT_DESCRIPTION, sources, null, state, outcomeText, details, job.getUsername(), true);
incidence.setDetectedBy(job.getUsername()); incidence.setRiskId(riskId); incidence.setAipId(representation.getAipId()); incidence.setRepresentationId(representation.getId()); incidence.setObjectClass(Representation.class.getSimpleName()); PluginHelper.createPluginEvent(this, representation.getAipId(), representation.getId(), model, index, null, null, state, "", true); } catch (RequestNotValidException | NotFoundException | GenericException | AuthorizationDeniedException
List<File> newFiles = new ArrayList<>(); List<DIPFile> newDIPFiles = new ArrayList<>(); aipId = representation.getAipId(); PluginState reportState = PluginState.SUCCESS; boolean notify = true; boolean hasNonPdfFiles = false; try (CloseableIterable<OptionalWithCause<File>> allFiles = model.listFilesUnder(representation.getAipId(), representation.getId(), true)) { LOGGER.debug("Processing representation {}", representation); job.getUsername()); reportItem.setSourceAndOutcomeObjectId(reportItem.getSourceObjectId(), IdUtils.getRepresentationId(representation.getAipId(), newRepresentationID)); outputFormat, file.getId(), representation.getId(), representation.getAipId()); Representation rep = model.retrieveRepresentation(representation.getAipId(), newRepresentationID); createPremisSkeletonOnRepresentation(model, representation.getAipId(), rep); } catch (RequestNotValidException | GenericException | NotFoundException | AuthorizationDeniedException | ValidationException | IOException | XmlException e) {
doc.addField(RodaConstants.REPRESENTATION_AIP_ID, rep.getAipId()); doc.addField(RodaConstants.REPRESENTATION_ORIGINAL, rep.isOriginal()); doc.addField(RodaConstants.REPRESENTATION_TYPE, rep.getType()); SolrUtils.indexDescriptiveMetadataFields(RodaCoreFactory.getModelService(), rep.getAipId(), rep.getId(), rep.getDescriptiveMetadata(), doc); Long numberOfDocumentationFiles; try { Directory documentationDirectory = model.getDocumentationDirectory(rep.getAipId(), rep.getId()); numberOfDocumentationFiles = storage.countResourcesUnderDirectory(documentationDirectory.getStoragePath(), true); } catch (NotFoundException e) { Directory schemasDirectory = model.getSchemasDirectory(rep.getAipId(), rep.getId()); numberOfSchemaFiles = storage.countResourcesUnderDirectory(schemasDirectory.getStoragePath(), true); } catch (NotFoundException e) {
Long numberOfDataFolders = 0L; try (CloseableIterable<OptionalWithCause<File>> allFiles = model.listFilesUnder(representation.getAipId(), representation.getId(), true)) { for (OptionalWithCause<File> file : allFiles) {
notify, job.getUsername()); reportItem.setSourceAndOutcomeObjectId(reportItem.getSourceObjectId(), IdUtils.getRepresentationId(representation.getAipId(), newRepresentationID));
private ReturnWithExceptions<Void, ModelObserver> representationPermissionsUpdated(final AIP aip, final Representation representation) { ReturnWithExceptions<Void, ModelObserver> ret = new ReturnWithExceptions<>(this); SolrUtils.update(index, IndexedRepresentation.class, IdUtils.getRepresentationId(representation), SolrUtils.getPermissionsAsPreCalculatedFields(aip.getPermissions()), (ModelObserver) this).addTo(ret); if (ret.isEmpty()) { try (CloseableIterable<OptionalWithCause<File>> allFiles = model.listFilesUnder(representation.getAipId(), representation.getId(), true)) { for (OptionalWithCause<File> file : allFiles) { if (file.isPresent()) { SolrUtils.update(index, IndexedFile.class, IdUtils.getFileId(file.get()), SolrUtils.getPermissionsAsPreCalculatedFields(aip.getPermissions()), (ModelObserver) this).addTo(ret); } else { LOGGER.error("Cannot do a partial update on file", file.getCause()); ret.add(file.getCause()); } } } catch (AuthorizationDeniedException | IOException | NotFoundException | GenericException | RequestNotValidException e) { LOGGER.error("Cannot do a partial update", e); ret.add(e); } } return ret; }