@Override public Map<String, Object> getPreCalculatedFields() { Map<String, Object> preCalculatedFields = new HashMap<>(); if (aip != null) { preCalculatedFields.put(RodaConstants.INDEX_STATE, SolrUtils.formatEnum(aip.getState())); preCalculatedFields.putAll(SolrUtils.getPermissionsAsPreCalculatedFields(aip.getPermissions())); } else { preCalculatedFields.put(RodaConstants.INDEX_STATE, SolrUtils.formatEnum(AIPState.ACTIVE)); } return preCalculatedFields; }
@Override public Map<String, Object> getPreCalculatedFields() { Map<String, Object> preCalculatedFields = new HashMap<>(); // indexing AIP inherited info preCalculatedFields.put(RodaConstants.INDEX_STATE, SolrUtils.formatEnum(aip.getState())); preCalculatedFields.put(RodaConstants.INGEST_SIP_IDS, aip.getIngestSIPIds()); preCalculatedFields.put(RodaConstants.INGEST_JOB_ID, aip.getIngestJobId()); preCalculatedFields.put(RodaConstants.INGEST_UPDATE_JOB_IDS, aip.getIngestUpdateJobIds()); preCalculatedFields.put(RodaConstants.FILE_ANCESTORS, ancestors); preCalculatedFields.putAll(SolrUtils.getPermissionsAsPreCalculatedFields(aip.getPermissions())); return preCalculatedFields; }
@Override public Map<String, Object> getPreCalculatedFields() { Map<String, Object> preCalculatedFields = new HashMap<>(); // indexing file size and number preCalculatedFields.put(RodaConstants.REPRESENTATION_SIZE_IN_BYTES, sizeInBytes); preCalculatedFields.put(RodaConstants.REPRESENTATION_NUMBER_OF_DATA_FILES, numberOfDataFiles); preCalculatedFields.put(RodaConstants.REPRESENTATION_NUMBER_OF_DATA_FOLDERS, numberOfDataFolders); // indexing active state and permissions preCalculatedFields.put(RodaConstants.INDEX_STATE, SolrUtils.formatEnum(aip.getState())); preCalculatedFields.put(RodaConstants.INGEST_SIP_IDS, aip.getIngestSIPIds()); preCalculatedFields.put(RodaConstants.INGEST_JOB_ID, aip.getIngestJobId()); preCalculatedFields.put(RodaConstants.INGEST_UPDATE_JOB_IDS, aip.getIngestUpdateJobIds()); preCalculatedFields.put(RodaConstants.AIP_ANCESTORS, ancestors); preCalculatedFields.putAll(SolrUtils.getPermissionsAsPreCalculatedFields(aip.getPermissions())); return preCalculatedFields; }
if (aipIds != null && !aipIds.isEmpty()) { try { AIPState aipState = model.retrieveAIP(aipIds.get(0)).getState(); if (AIPState.ACTIVE == aipState) { success.add(transferredResourceId);
@Override public ReturnWithExceptions<Void, ModelObserver> aipStateUpdated(AIP aip) { ReturnWithExceptions<Void, ModelObserver> ret = new ReturnWithExceptions<>(this); // change AIP SolrUtils .update(index, IndexedAIP.class, aip.getId(), Collections.singletonMap(RodaConstants.INDEX_STATE, SolrUtils.formatEnum(aip.getState())), (ModelObserver) this) .addTo(ret); if (ret.isEmpty()) { // change Representations, Files & Preservation events representationsStateUpdated(aip).addTo(ret); preservationEventsStateUpdated(aip).addTo(ret); } return ret; }
private ReturnWithExceptions<Void, ModelObserver> fileStateUpdated(AIP aip, File file, boolean recursive) { ReturnWithExceptions<Void, ModelObserver> ret = new ReturnWithExceptions<>(this); SolrUtils .update(index, IndexedFile.class, IdUtils.getFileId(file), Collections.singletonMap(RodaConstants.INDEX_STATE, SolrUtils.formatEnum(aip.getState())), (ModelObserver) this) .addTo(ret); if (ret.isEmpty()) { if (recursive && file.isDirectory()) { try (CloseableIterable<OptionalWithCause<File>> allFiles = model.listFilesUnder(file, true)) { for (OptionalWithCause<File> subfile : allFiles) { if (subfile.isPresent()) { fileStateUpdated(aip, subfile.get(), false).addTo(ret); } else { LOGGER.error("Cannot index file sub-resources", subfile.getCause()); ret.add(subfile.getCause()); } } } catch (NotFoundException | GenericException | RequestNotValidException | AuthorizationDeniedException | IOException e) { LOGGER.error("Cannot index file sub-resources: {}", file, e); ret.add(e); } } } else { LOGGER.error("Cannot index file: {}", file); } return ret; }
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; }
private ReturnWithExceptions<Void, ModelObserver> preservationEventsStateUpdated(final AIP aip) { ReturnWithExceptions<Void, ModelObserver> ret = new ReturnWithExceptions<>(this); try (CloseableIterable<OptionalWithCause<PreservationMetadata>> preservationMetadata = model .listPreservationMetadata(aip.getId(), true)) { for (OptionalWithCause<PreservationMetadata> opm : preservationMetadata) { if (opm.isPresent()) { PreservationMetadata pm = opm.get(); if (pm.getType().equals(PreservationMetadataType.EVENT)) { preservationEventStateUpdated(pm, aip.getState()).addTo(ret); } } else { LOGGER.error("Cannot index premis event", opm.getCause()); ret.add(opm.getCause()); } } } catch (RequestNotValidException | NotFoundException | GenericException | AuthorizationDeniedException | IOException e) { LOGGER.error("Cannot index preservation events", e); ret.add(e); } return ret; }
private ReturnWithExceptions<Void, ModelObserver> preservationEventsPermissionsUpdated(final AIP aip) { ReturnWithExceptions<Void, ModelObserver> ret = new ReturnWithExceptions<>(this); try (CloseableIterable<OptionalWithCause<PreservationMetadata>> preservationMetadata = model .listPreservationMetadata(aip.getId(), true)) { for (OptionalWithCause<PreservationMetadata> opm : preservationMetadata) { if (opm.isPresent()) { PreservationMetadata pm = opm.get(); if (PreservationMetadataType.EVENT.equals(pm.getType())) { preservationEventPermissionsUpdated(pm, aip.getPermissions(), aip.getState()).addTo(ret); } } else { LOGGER.error("Cannot index premis event", opm.getCause()); ret.add(opm.getCause()); } } } catch (RequestNotValidException | NotFoundException | GenericException | AuthorizationDeniedException | IOException e) { LOGGER.error("Cannot index preservation events", e); ret.add(e); } return ret; }
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); }