public static DIP getDIPMetadata(StorageService storage, String dipId, StoragePath storagePath) throws RequestNotValidException, GenericException, NotFoundException, AuthorizationDeniedException { DefaultStoragePath metadataStoragePath = DefaultStoragePath.parse(storagePath, RodaConstants.STORAGE_DIP_METADATA_FILENAME); Binary binary = storage.getBinary(metadataStoragePath); String json; DIP dip; try (InputStream inputStream = binary.getContent().createInputStream()) { json = IOUtils.toString(inputStream, Charset.forName(RodaConstants.DEFAULT_ENCODING)); dip = JsonUtils.getObjectFromJson(json, DIP.class); } catch (IOException | GenericException e) { throw new GenericException("Could not parse DIP metadata of " + dipId + " at " + metadataStoragePath, e); } // Setting information that does not come in JSON dip.setId(dipId); return dip; }
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); } }
dip.setId(IdUtils.createUUID()); dip.setFileIds(links); dip.setPermissions(aip.getPermissions());
dip.setId(IdUtils.createUUID()); dip.setFileIds(links); dip.setPermissions(aip.getPermissions());
dip.setId(IdUtils.createUUID()); dip.setFileIds(links); dip.setPermissions(aip.getPermissions());