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);
storage.copy(sourceStorage, sourcePath, directoryPath);
}
representation = new Representation(representationId, aipId, original, type);
representation.setCreatedBy(createdBy);
representation.setUpdatedBy(createdBy);
AIP aip = ResourceParseUtils.getAIPMetadata(getStorage(), aipId);
aip.getRepresentations().add(representation);
updateAIPMetadata(aip);
notifyRepresentationCreated(representation).failOnError();
return representation;
}