@@ -0,0 +1,1513 @@
+package de.unistuttgart.iste.rss.bugminer.storage;%0A%0Aimport de.unistuttgart.iste.rss.bugminer.annotations.DataDirectory;%0Aimport org.springframework.beans.factory.annotation.Autowired;%0A%0Aimport java.io.IOException;%0Aimport java.nio.file.Files;%0Aimport java.nio.file.Path;%0Aimport java.util.UUID;%0A%0A/**%0A * An Implementation of @%7Blink BlobStorage%7D that saves the blob in the local file system%0A */%0Apublic class FileBasedBlobStorage implements BlobStorage %7B%0A%09@Autowired%0A%09@DataDirectory%0A%09private Path dataDirectory;%0A%0A%09private Path getRoot() %7B%0A%09%09return dataDirectory.resolve(%22blobs%22);%0A%09%7D%0A%0A%09private String createNewKey() %7B%0A%09%09return UUID.randomUUID().toString();%0A%09%7D%0A%0A%09private Path getFileName(String key) %7B%0A%09%09return getRoot().resolve(key);%0A%09%7D%0A%0A%09@Override%0A%09public String put(byte%5B%5D data) throws IOException %7B%0A%09%09Files.createDirectories(getRoot());%0A%09%09String key = createNewKey();%0A%09%09Files.write(getFileName(key), data);%0A%09%09return key;%0A%09%7D%0A%0A%09@Override%0A%09public byte%5B%5D getBytes(String key) throws BlobNotFoundException, IOException %7B%0A%09%09Path fileName = getFileName(key);%0A%09%09if (!Files.exists(fileName)) %7B%0A%09%09%09throw new BlobNotFoundException(String.format(%0A%09%09%09%09%09%22There is no blob with the key %25s%22, key));%0A%09%09%7D%0A%09%09return Files.readAllBytes(fileName);%0A%09%7D%0A%0A%09@Override%0A%09public void delete(String key) throws BlobNotFoundException, IOException %7B%0A%09%09Path fileName = getFileName(key);%0A%09%09if (!Files.exists(fileName)) %7B%0A%09%09%09throw new BlobNotFoundException(String.format(%0A%09%09%09%09%09%22There is no blob with the key %25s%22, key));%0A%09%09%7D%0A%09%09Files.delete(fileName);%0A%09%7D%0A%7D%0A

Implement file based BlobStorage