@Override public String getUniqueId(DIP modelObject) { return modelObject.getId(); }
private void updateDIPMetadata(DIP dip) throws GenericException, NotFoundException, RequestNotValidException, AuthorizationDeniedException { updateDIPMetadata(dip, ModelUtils.getDIPStoragePath(dip.getId())); }
@Override public ReturnWithExceptions<Void, ModelObserver> dipUpdated(DIP dip, boolean commit) { ReturnWithExceptions<Void, ModelObserver> ret = dipDeleted(dip.getId(), commit); dipCreated(dip, commit).addTo(ret); return ret; }
private CloseableIterable<OptionalWithCause<DIPFile>> listDIPFiles() throws RODAException { CloseableIterable<OptionalWithCause<DIP>> dips = list(DIP.class); return CloseableIterables.concat(dips, odip -> { CloseableIterable<?> dipFiles = CloseableIterables.empty(); if (odip.isPresent()) { DIP dip = odip.get(); try { dipFiles = listDIPFilesUnder(dip.getId(), true); } catch (RODAException e) { LOGGER.error("Error getting DIP files under a DIP " + dip.getId()); } } return (CloseableIterable<OptionalWithCause<DIPFile>>) dipFiles; }); }
public DIP updateDIP(DIP dip) throws GenericException, NotFoundException, AuthorizationDeniedException { RodaCoreFactory.checkIfWriteIsAllowedAndIfFalseThrowException(nodeType); try { dip.setLastModified(new Date()); updateDIPMetadata(dip, DefaultStoragePath.parse(RodaConstants.STORAGE_CONTAINER_DIP, dip.getId())); } catch (GenericException | RequestNotValidException e) { LOGGER.error("Error updating DIP in storage", e); throw new GenericException(e); } notifyDIPUpdated(dip, false).failOnError(); return dip; }
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); }
@Override public List<Object> toCsvValues() { return Arrays.asList(super.getId(), super.getTitle(), super.getDescription(), super.getType(), super.getDateCreated(), super.getLastModified(), super.getIsPermanent(), super.getProperties(), super.getAipIds(), super.getRepresentationIds(), super.getFileIds(), super.getPermissions(), openExternalURL); }
public DIP createDIP(DIP dip, boolean notify) throws GenericException, AuthorizationDeniedException { RodaCoreFactory.checkIfWriteIsAllowedAndIfFalseThrowException(nodeType); try { Directory directory; if (StringUtils.isNotBlank(dip.getId())) { try { directory = storage .createDirectory(DefaultStoragePath.parse(RodaConstants.STORAGE_CONTAINER_DIP, dip.getId())); } catch (AlreadyExistsException | GenericException | AuthorizationDeniedException e) { directory = storage.createRandomDirectory(DefaultStoragePath.parse(RodaConstants.STORAGE_CONTAINER_DIP)); dip.setId(directory.getStoragePath().getName()); } } else { directory = storage.createRandomDirectory(DefaultStoragePath.parse(RodaConstants.STORAGE_CONTAINER_DIP)); dip.setId(directory.getStoragePath().getName()); } dip.setDateCreated(new Date()); dip.setLastModified(new Date()); createDIPMetadata(dip, directory.getStoragePath()); if (notify) { notifyDIPCreated(dip, false).failOnError(); } return dip; } catch (NotFoundException | RequestNotValidException | AlreadyExistsException e) { LOGGER.error("Error creating DIP in storage", e); throw new GenericException(e); } }
@Override public ReturnWithExceptions<Void, ModelObserver> dipPermissionsUpdated(DIP dip) { ReturnWithExceptions<Void, ModelObserver> ret = new ReturnWithExceptions<>(this); SolrUtils.update(index, IndexedDIP.class, dip.getId(), SolrUtils.getPermissionsAsPreCalculatedFields(dip.getPermissions()), (ModelObserver) this).addTo(ret); if (ret.isEmpty()) { try (CloseableIterable<OptionalWithCause<DIPFile>> allFiles = model.listDIPFilesUnder(dip.getId(), true)) { for (OptionalWithCause<DIPFile> dipFile : allFiles) { if (dipFile.isPresent()) { SolrUtils.update(index, DIPFile.class, IdUtils.getDIPFileId(dipFile.get()), SolrUtils.getPermissionsAsPreCalculatedFields(dip.getPermissions()), (ModelObserver) this).addTo(ret); } else { LOGGER.error("Cannot do a partial update on DIP file", dipFile.getCause()); ret.add(dipFile.getCause()); } } } catch (AuthorizationDeniedException | IOException | NotFoundException | GenericException | RequestNotValidException e) { LOGGER.error("Cannot do a partial update", e); ret.add(e); } } return ret; }
public DIP(DIP other) { this(other.getId(), other.getTitle(), other.getDescription(), other.getType(), other.getDateCreated(), other.getLastModified(), other.getIsPermanent(), other.getProperties(), other.getAipIds(), other.getRepresentationIds(), other.getFileIds(), other.getPermissions()); }
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); } }
try (CloseableIterable<OptionalWithCause<DIPFile>> allFiles = model.listDIPFilesUnder(dip.getId(), true)) { for (OptionalWithCause<DIPFile> file : allFiles) { if (file.isPresent()) {
dip.setType(RodaConstants.DIP_TYPE_CONVERSION); dip = model.createDIP(dip, true); newRepresentationID = dip.getId();
dip.setType(RodaConstants.DIP_TYPE_CONVERSION); dip = model.createDIP(dip, true); newRepresentationID = dip.getId(); } else {
dip.setType(RodaConstants.DIP_TYPE_CONVERSION); dip = model.createDIP(dip, true); newRepresentationID = dip.getId(); } else {