Commit b3bd1647 authored by Matija Obreza's avatar Matija Obreza

RepositoryService#getFileBytes by path removed

- Could not check permissions
parent 7a090433
Pipeline #6708 passed with stage
in 3 minutes and 21 seconds
......@@ -108,16 +108,6 @@ public interface RepositoryService {
*/
RepositoryFile getFile(Path path, String filename) throws NoSuchRepositoryFileException, InvalidRepositoryPathException;
/**
* Get repository file bytes by its path and filename.
*
* @param repositoryPath path to the file
* @param filename name of the file in the storage, not original filename
* @return the file bytes
* @throws NoSuchRepositoryFileException the no such repository file exception
*/
byte[] getFileBytes(Path repositoryPath) throws NoSuchRepositoryFileException;
/**
* Gets the file bytes.
*
......
......@@ -117,11 +117,11 @@ public class RepositoryServiceImpl implements RepositoryService, InitializingBea
LOG.debug("Updating SHA-1 and MD5 for file uuid={}", repositoryFile.getUuid());
}
try {
final byte[] bytes = getFileBytes(repositoryFile.getFolder().getFolderPath().resolve(repositoryFile.getFilename()));
final byte[] bytes = getFileBytes(repositoryFile);
repositoryFile.setSha1Sum(DigestUtils.sha1Hex(bytes));
repositoryFile.setMd5Sum(DigestUtils.md5Hex(bytes));
repositoryFilePersistence.save(repositoryFile);
} catch (final NoSuchRepositoryFileException e) {
} catch (final IOException e) {
LOG.warn("Failed to generate hash sums: {}", e.getMessage());
}
}
......@@ -329,27 +329,6 @@ public class RepositoryServiceImpl implements RepositoryService, InitializingBea
return repositoryFile;
}
/*
* (non-Javadoc)
* @see org.genesys.filerepository.service.RepositoryService#getFileBytes
* (java.lang.String, java.lang.String)
*/
/**
* @deprecated Permission check not possible, use {@link #getFileBytes(RepositoryFile)}
*/
@Override
public byte[] getFileBytes(final Path filePath) throws NoSuchRepositoryFileException {
byte[] data = null;
try {
data = bytesStorageService.get(filePath);
} catch (final IOException e) {
e.printStackTrace();
}
return data;
}
/*
* (non-Javadoc)
* @see
......
......@@ -67,6 +67,9 @@ public class ImageGalleryThumbnailsTest extends RepositoryServiceTest {
/** The file repo service. */
@Autowired
private RepositoryService fileRepoService;
@Autowired
private BytesStorageService bytesStorageService;
/**
* After test.
......@@ -120,7 +123,7 @@ public class ImageGalleryThumbnailsTest extends RepositoryServiceTest {
imageGalleryService.ensureThumbnails(imageGallery, 100, 200);
final byte[] thumbBytes1 = fileRepoService.getFileBytes(Paths.get(ImageGalleryService.THUMB_PATH, repoImage1.getThumbnailPath(), "100x200" + ".png"));
final byte[] thumbBytes1 = bytesStorageService.get(Paths.get(ImageGalleryService.THUMB_PATH, repoImage1.getThumbnailPath(), "100x200" + ".png"));
assertThat("Thumbnail must not be null", thumbBytes1, notNullValue());
try (InputStream is = new ByteArrayInputStream(thumbBytes1)) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment