@Test(expected = ContentAddressableStorageException.class) public void givenContainerNotFoundWhenCreateFolderThenRaiseAnException() throws Exception { storage.createFolder(CONTAINER_NAME, FOLDER_NAME); }
@Override public void createFolder(String containerName, String folderName) throws ContentAddressableStorageNotFoundException, ContentAddressableStorageAlreadyExistException, ContentAddressableStorageServerException { ParametersChecker.checkParameter(ErrorMessage.CONTAINER_FOLDER_NAMES_ARE_A_MANDATORY_PARAMETER.getMessage(), containerName, folderName); if (!isExistingContainer(containerName)) { LOGGER.error(ErrorMessage.CONTAINER_NOT_FOUND.getMessage() + containerName); throw new ContentAddressableStorageNotFoundException( ErrorMessage.CONTAINER_NOT_FOUND.getMessage() + containerName); } if (isExistingFolder(containerName, folderName)) { LOGGER.info(ErrorMessage.FOLDER_ALREADY_EXIST + folderName); throw new ContentAddressableStorageAlreadyExistException( ErrorMessage.FOLDER_ALREADY_EXIST.getMessage() + folderName); } try { Path folderPath = getFolderPath(containerName, folderName); Files.createDirectories(folderPath); } catch (IOException ex) { throw new ContentAddressableStorageServerException(ex); } }
WorkspaceFileSystem implements WorkspaceContentAddressableStorage { @Override public void createFolder(String containerName, String folderName) throws ContentAddressableStorageNotFoundException, ContentAddressableStorageAlreadyExistException, ContentAddressableStorageServerException { ParametersChecker.checkParameter(ErrorMessage.CONTAINER_FOLDER_NAMES_ARE_A_MANDATORY_PARAMETER.getMessage(), containerName, folderName); if (!isExistingContainer(containerName)) { LOGGER.error(ErrorMessage.CONTAINER_NOT_FOUND.getMessage() + containerName); throw new ContentAddressableStorageNotFoundException( ErrorMessage.CONTAINER_NOT_FOUND.getMessage() + containerName); } if (isExistingFolder(containerName, folderName)) { LOGGER.info(ErrorMessage.FOLDER_ALREADY_EXIST + folderName); throw new ContentAddressableStorageAlreadyExistException( ErrorMessage.FOLDER_ALREADY_EXIST.getMessage() + folderName); } try { Path folderPath = getFolderPath(containerName, folderName); Files.createDirectories(folderPath); } catch (IOException ex) { throw new ContentAddressableStorageServerException(ex); } } }
WorkspaceFileSystem implements WorkspaceContentAddressableStorage { @Override public void createFolder(String containerName, String folderName) throws ContentAddressableStorageNotFoundException, ContentAddressableStorageAlreadyExistException, ContentAddressableStorageServerException { ParametersChecker.checkParameter(ErrorMessage.CONTAINER_FOLDER_NAMES_ARE_A_MANDATORY_PARAMETER.getMessage(), containerName, folderName); if (!isExistingContainer(containerName)) { LOGGER.error(ErrorMessage.CONTAINER_NOT_FOUND.getMessage() + containerName); throw new ContentAddressableStorageNotFoundException( ErrorMessage.CONTAINER_NOT_FOUND.getMessage() + containerName); } if (isExistingFolder(containerName, folderName)) { LOGGER.info(ErrorMessage.FOLDER_ALREADY_EXIST + folderName); throw new ContentAddressableStorageAlreadyExistException( ErrorMessage.FOLDER_ALREADY_EXIST.getMessage() + folderName); } try { Path folderPath = getFolderPath(containerName, folderName); Files.createDirectories(folderPath); } catch (IOException ex) { throw new ContentAddressableStorageServerException(ex); } } WorkspaceFileSystem(StorageConfiguration configuration); }
WorkspaceFileSystem implements WorkspaceContentAddressableStorage { @Override public void createFolder(String containerName, String folderName) throws ContentAddressableStorageNotFoundException, ContentAddressableStorageAlreadyExistException, ContentAddressableStorageServerException { ParametersChecker.checkParameter(ErrorMessage.CONTAINER_FOLDER_NAMES_ARE_A_MANDATORY_PARAMETER.getMessage(), containerName, folderName); if (!isExistingContainer(containerName)) { LOGGER.error(ErrorMessage.CONTAINER_NOT_FOUND.getMessage() + containerName); throw new ContentAddressableStorageNotFoundException( ErrorMessage.CONTAINER_NOT_FOUND.getMessage() + containerName); } if (isExistingFolder(containerName, folderName)) { LOGGER.info(ErrorMessage.FOLDER_ALREADY_EXIST + folderName); throw new ContentAddressableStorageAlreadyExistException( ErrorMessage.FOLDER_ALREADY_EXIST.getMessage() + folderName); } try { Path folderPath = getFolderPath(containerName, folderName); Files.createDirectories(folderPath); } catch (IOException ex) { throw new ContentAddressableStorageServerException(ex); } } WorkspaceFileSystem(StorageConfiguration configuration); void checkWorkspaceFile(String... paths); @Override void createContainer(String containerName); @Override void purgeContainer(String containerName); @Override void purgeOldFilesInContainer(String containerName, TimeToLive timeToLive); @Override void deleteContainer(String containerName, boolean recursive); @Override boolean isExistingContainer(String containerName); @Override void createFolder(String containerName, String folderName); @Override void deleteFolder(String containerName, String folderName); @Override boolean isExistingFolder(String containerName, String folderName); @Override List<URI> getListUriDigitalObjectFromFolder(String containerName, String folderName); @Override void uncompressObject(String containerName, String folderName, String archiveMimeType,
        InputStream inputStreamObject); @Override void putObject(String containerName, String objectName, InputStream stream); @Override void putAtomicObject(String containerName, String objectName, InputStream stream, long size); @Override Response getObject(String containerName, String objectName, Long chunkOffset,
        Long maxChunkSize); @Override void deleteObject(String containerName, String objectName); @Override boolean isExistingObject(String containerName, String objectName); @Override String computeObjectDigest(String containerName, String objectName, DigestType algo); @Override ContainerInformation getContainerInformation(String containerName); @Override JsonNode getObjectInformation(String containerName, String objectName); @Override long countObjects(String containerName); void compress(String containerName, List<String> folderNames, String zipName,
        String outputContainer); }
WorkspaceFileSystem implements WorkspaceContentAddressableStorage { @Override public void createFolder(String containerName, String folderName) throws ContentAddressableStorageNotFoundException, ContentAddressableStorageAlreadyExistException, ContentAddressableStorageServerException { ParametersChecker.checkParameter(ErrorMessage.CONTAINER_FOLDER_NAMES_ARE_A_MANDATORY_PARAMETER.getMessage(), containerName, folderName); if (!isExistingContainer(containerName)) { LOGGER.error(ErrorMessage.CONTAINER_NOT_FOUND.getMessage() + containerName); throw new ContentAddressableStorageNotFoundException( ErrorMessage.CONTAINER_NOT_FOUND.getMessage() + containerName); } if (isExistingFolder(containerName, folderName)) { LOGGER.info(ErrorMessage.FOLDER_ALREADY_EXIST + folderName); throw new ContentAddressableStorageAlreadyExistException( ErrorMessage.FOLDER_ALREADY_EXIST.getMessage() + folderName); } try { Path folderPath = getFolderPath(containerName, folderName); Files.createDirectories(folderPath); } catch (IOException ex) { throw new ContentAddressableStorageServerException(ex); } } WorkspaceFileSystem(StorageConfiguration configuration); void checkWorkspaceFile(String... paths); @Override void createContainer(String containerName); @Override void purgeContainer(String containerName); @Override void purgeOldFilesInContainer(String containerName, TimeToLive timeToLive); @Override void deleteContainer(String containerName, boolean recursive); @Override boolean isExistingContainer(String containerName); @Override void createFolder(String containerName, String folderName); @Override void deleteFolder(String containerName, String folderName); @Override boolean isExistingFolder(String containerName, String folderName); @Override List<URI> getListUriDigitalObjectFromFolder(String containerName, String folderName); @Override void uncompressObject(String containerName, String folderName, String archiveMimeType,
        InputStream inputStreamObject); @Override void putObject(String containerName, String objectName, InputStream stream); @Override void putAtomicObject(String containerName, String objectName, InputStream stream, long size); @Override Response getObject(String containerName, String objectName, Long chunkOffset,
        Long maxChunkSize); @Override void deleteObject(String containerName, String objectName); @Override boolean isExistingObject(String containerName, String objectName); @Override String computeObjectDigest(String containerName, String objectName, DigestType algo); @Override ContainerInformation getContainerInformation(String containerName); @Override JsonNode getObjectInformation(String containerName, String objectName); @Override long countObjects(String containerName); void compress(String containerName, List<String> folderNames, String zipName,
        String outputContainer);  }