public void changeRepresentationStates(String aipId, String representationId, List<String> newStates, String updatedBy) throws RequestNotValidException, NotFoundException, GenericException, AuthorizationDeniedException { RodaCoreFactory.checkIfWriteIsAllowedAndIfFalseThrowException(nodeType); AIP aip = retrieveAIP(aipId); Iterator<Representation> it = aip.getRepresentations().iterator(); Optional<Representation> representation = Optional.empty(); while (it.hasNext()) { Representation next = it.next(); if (next.getId().equals(representationId)) { representation = Optional.of(next); break; } } if (representation.isPresent()) { representation.get().setRepresentationStates(newStates); representation.get().setUpdatedOn(new Date()); representation.get().setUpdatedBy(updatedBy); updateAIPMetadata(aip); notifyRepresentationUpdated(representation.get()).failOnError(); } }
public void changeRepresentationType(String aipId, String representationId, String type, String updatedBy) throws RequestNotValidException, NotFoundException, GenericException, AuthorizationDeniedException { RodaCoreFactory.checkIfWriteIsAllowedAndIfFalseThrowException(nodeType); AIP aip = retrieveAIP(aipId); Iterator<Representation> it = aip.getRepresentations().iterator(); while (it.hasNext()) { Representation representation = it.next(); if (representation.getId().equals(representationId)) { representation.setType(type); representation.setUpdatedOn(new Date()); representation.setUpdatedBy(updatedBy); notifyRepresentationUpdated(representation).failOnError(); break; } } updateAIPMetadata(aip); }
public Representation createRepresentation(String aipId, String representationId, boolean original, String type, boolean notify, String createdBy) throws RequestNotValidException, GenericException, NotFoundException, AuthorizationDeniedException, AlreadyExistsException { RodaCoreFactory.checkIfWriteIsAllowedAndIfFalseThrowException(nodeType); Representation representation = new Representation(representationId, aipId, original, type); representation.setCreatedBy(createdBy); representation.setUpdatedBy(createdBy); StoragePath directoryPath = ModelUtils.getRepresentationStoragePath(aipId, representationId); storage.createDirectory(directoryPath); // update AIP metadata AIP aip = ResourceParseUtils.getAIPMetadata(getStorage(), aipId); aip.getRepresentations().add(representation); updateAIPMetadata(aip); if (notify) { notifyRepresentationCreated(representation).failOnError(); } return representation; }
representation.setCreatedBy(aip.getCreatedBy()); representation.setUpdatedOn(updateDate); representation.setUpdatedBy(aip.getUpdatedBy());
public Representation updateRepresentation(String aipId, String representationId, boolean original, String type, StorageService sourceStorage, StoragePath sourcePath, String updatedBy) throws RequestNotValidException, NotFoundException, GenericException, AuthorizationDeniedException, ValidationException { Representation representation; RodaCoreFactory.checkIfWriteIsAllowedAndIfFalseThrowException(nodeType); // XXX possible optimization only creating new files, updating // changed and removing deleted StoragePath representationPath = ModelUtils.getRepresentationStoragePath(aipId, representationId); storage.deleteResource(representationPath); try { storage.copy(sourceStorage, sourcePath, representationPath); } catch (AlreadyExistsException e) { throw new GenericException("Copying after delete gave an unexpected already exists exception", e); } // build return object representation = new Representation(representationId, aipId, original, type); representation.setUpdatedBy(updatedBy); notifyRepresentationUpdated(representation).failOnError(); return representation; }
public Representation createRepresentation(String aipId, String representationId, boolean original, String type, StorageService sourceStorage, StoragePath sourcePath, boolean justData, String createdBy) throws RequestNotValidException, GenericException, NotFoundException, AuthorizationDeniedException, AlreadyExistsException { Representation representation; RodaCoreFactory.checkIfWriteIsAllowedAndIfFalseThrowException(nodeType); if (justData) { StoragePath dataPath = ModelUtils.getRepresentationDataStoragePath(aipId, representationId); StoragePath sourceDataPath = DefaultStoragePath.parse(sourcePath, RodaConstants.STORAGE_DIRECTORY_DATA); storage.copy(sourceStorage, sourceDataPath, dataPath); } else { StoragePath directoryPath = ModelUtils.getRepresentationStoragePath(aipId, representationId); // verify structure of source representation // 20170324 should we validate the representation??? storage.copy(sourceStorage, sourcePath, directoryPath); } representation = new Representation(representationId, aipId, original, type); representation.setCreatedBy(createdBy); representation.setUpdatedBy(createdBy); // update AIP metadata AIP aip = ResourceParseUtils.getAIPMetadata(getStorage(), aipId); aip.getRepresentations().add(representation); updateAIPMetadata(aip); notifyRepresentationCreated(representation).failOnError(); return representation; }