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()); }
DIP dip = new DIP(); dip.setId(IdUtils.createUUID()); dip.setFileIds(links); dip.setPermissions(aip.getPermissions()); dip.setTitle(dipTitle); dip.setDescription(dipDescription); dip.setType(RodaConstants.DIP_TYPE_CONVERSION); dip = model.createDIP(dip, true); newRepresentationID = dip.getId(); } else {
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); } }
public static OptionalWithCause<String> getCompleteOpenExternalURL(DIP dip) { OptionalWithCause<String> ret; Optional<String> dipProperty = getDIPProperty(dip, RodaConstants.RODA_OBJECT_DIP, dip.getType(), "openExternalURL"); if (dipProperty.isPresent()) { try { String externalUrl = HandlebarsUtility.executeHandlebars(dipProperty.get(), dip.getProperties()); ret = OptionalWithCause.of(externalUrl); } catch (GenericException e) { ret = OptionalWithCause.empty(e); } } else { ret = OptionalWithCause.of(Optional.empty()); } return ret; }
@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; }
@Override public String getUniqueId(DIP modelObject) { return modelObject.getId(); }
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 { 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); } }
@Override public Map<String, Object> getPreCalculatedFields() { return SolrUtils.getPermissionsAsPreCalculatedFields(dip.getPermissions()); }
links.add(fileLink); DIP dip = new DIP(); dip.setId(IdUtils.createUUID()); dip.setFileIds(links); dip.setPermissions(aip.getPermissions()); dip.setTitle(dipTitle); dip.setDescription(dipDescription); dip.setType(RodaConstants.DIP_TYPE_CONVERSION); dip = model.createDIP(dip, true); newRepresentationID = dip.getId();
public static OptionalWithCause<String> getCompleteDeleteExternalURL(DIP dip) { OptionalWithCause<String> ret; Optional<String> dipProperty = getDIPProperty(dip, RodaConstants.RODA_OBJECT_DIP, dip.getType(), "deleteExternalURL"); if (dipProperty.isPresent()) { try { String externalUrl = HandlebarsUtility.executeHandlebars(dipProperty.get(), dip.getProperties()); ret = OptionalWithCause.of(externalUrl); } catch (GenericException e) { ret = OptionalWithCause.empty(e); } } else { ret = OptionalWithCause.of(Optional.empty()); } return ret; }
private void updateDIPMetadata(DIP dip) throws GenericException, NotFoundException, RequestNotValidException, AuthorizationDeniedException { updateDIPMetadata(dip, ModelUtils.getDIPStoragePath(dip.getId())); }
if (DIP.class.getName().equals(objectClass)) { DIP dip = this.retrieveDIP(id); Permissions permissions = dip.getPermissions(); Set<PermissionType> userPermissions = permissions.getUserPermissions(username);
@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); }
DIP dip = new DIP(); dip.setId(IdUtils.createUUID()); dip.setFileIds(links); dip.setPermissions(aip.getPermissions()); dip.setTitle(dipTitle); dip.setDescription(dipDescription); dip.setType(RodaConstants.DIP_TYPE_CONVERSION); dip = model.createDIP(dip, true); newRepresentationID = dip.getId(); } else {
@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; }
SolrInputDocument doc = super.toSolrDocument(dip, info); doc.addField(RodaConstants.DIP_TITLE, dip.getTitle()); doc.addField(RodaConstants.DIP_DESCRIPTION, dip.getDescription()); doc.addField(RodaConstants.DIP_TYPE, dip.getType()); doc.addField(RodaConstants.DIP_DATE_CREATED, SolrUtils.formatDate(dip.getDateCreated())); doc.addField(RodaConstants.DIP_LAST_MODIFIED, SolrUtils.formatDate(dip.getLastModified())); doc.addField(RodaConstants.DIP_IS_PERMANENT, dip.getIsPermanent()); doc.addField(RodaConstants.DIP_PROPERTIES, JsonUtils.getJsonFromObject(dip.getProperties())); doc.addField(RodaConstants.DIP_AIP_IDS, JsonUtils.getJsonFromObject(dip.getAipIds())); doc.addField(RodaConstants.DIP_REPRESENTATION_IDS, JsonUtils.getJsonFromObject(dip.getRepresentationIds())); doc.addField(RodaConstants.DIP_FILE_IDS, JsonUtils.getJsonFromObject(dip.getFileIds())); for (AIPLink aip : dip.getAipIds()) { aipUUIDs.add(aip.getAipId()); for (RepresentationLink rep : dip.getRepresentationIds()) { representationUUIDs.add(IdUtils.getRepresentationId(rep)); if (!allAipUUIDs.contains(rep.getAipId())) { for (FileLink file : dip.getFileIds()) { fileUUIDs.add(IdUtils.getFileId(file)); if (!allAipUUIDs.contains(file.getAipId())) {
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; }); }
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); }
try (CloseableIterable<OptionalWithCause<DIPFile>> allFiles = model.listDIPFilesUnder(dip.getId(), true)) { for (OptionalWithCause<DIPFile> file : allFiles) { if (file.isPresent()) {