Commit 0eaa94c6 authored by Matija Obreza's avatar Matija Obreza
Browse files

Distinct method names

parent 9021f3b3
......@@ -129,7 +129,7 @@ public interface RepositoryService {
* @throws NoSuchRepositoryFileException the no such repository file exception
* @throws IOException Signals that an I/O exception has occurred.
*/
RepositoryImage updateBytes(RepositoryImage imageData, String contentType, byte[] bytes) throws NoSuchRepositoryFileException, IOException;
RepositoryImage updateImageBytes(RepositoryImage imageData, String contentType, byte[] bytes) throws NoSuchRepositoryFileException, IOException;
/**
* Remove file and its data from repository.
......@@ -177,7 +177,7 @@ public interface RepositoryService {
* @return the updated metadata
* @throws NoSuchRepositoryFileException when file is not available in the repository
*/
RepositoryImage updateMetadata(UUID uuid, RepositoryImageData imageData) throws NoSuchRepositoryFileException;
RepositoryImage updateImageMetadata(UUID uuid, RepositoryImageData imageData) throws NoSuchRepositoryFileException;
/**
* Remove repository image
......
......@@ -273,15 +273,13 @@ public class RepositoryServiceImpl implements RepositoryService, InitializingBea
if (repositoryFile == null) {
throw new NoSuchRepositoryFileException();
}
if (fileData instanceof RepositoryImageData) {
return updateImageMetadata(uuid, (RepositoryImageData) fileData);
}
fileData.applyTo(repositoryFile);
if (repositoryFile.getContentType().startsWith("image")) {
repositoryFile = repositoryImagePersistence.save((RepositoryImage) repositoryFile);
} else {
repositoryFile = repositoryFilePersistence.save(repositoryFile);
}
repositoryFile = repositoryFilePersistence.save(repositoryFile);
return repositoryFile;
}
......@@ -292,7 +290,7 @@ public class RepositoryServiceImpl implements RepositoryService, InitializingBea
*/
@Override
@Transactional
public RepositoryImage updateMetadata(final UUID uuid, final RepositoryImageData imageData) throws NoSuchRepositoryFileException {
public RepositoryImage updateImageMetadata(final UUID uuid, final RepositoryImageData imageData) throws NoSuchRepositoryFileException {
RepositoryImage repositoryImage = repositoryImagePersistence.findByUuid(uuid);
if (repositoryImage == null) {
throw new NoSuchRepositoryFileException();
......@@ -315,6 +313,9 @@ public class RepositoryServiceImpl implements RepositoryService, InitializingBea
if (repositoryFile == null) {
throw new NoSuchRepositoryFileException();
}
if (repositoryFile instanceof RepositoryImage) {
return updateImageBytes((RepositoryImage) repositoryFile, contentType, bytes);
}
// Calculate SHA-1 and MD5 sums
repositoryFile.setSha1Sum(DigestUtils.sha1Hex(bytes));
......@@ -333,7 +334,7 @@ public class RepositoryServiceImpl implements RepositoryService, InitializingBea
*/
@Override
@Transactional
public RepositoryImage updateBytes(final RepositoryImage repositoryImage, final String contentType, final byte[] bytes) throws NoSuchRepositoryFileException, IOException {
public RepositoryImage updateImageBytes(final RepositoryImage repositoryImage, final String contentType, final byte[] bytes) throws NoSuchRepositoryFileException, IOException {
if (repositoryImage == null) {
throw new NoSuchRepositoryFileException();
}
......
......@@ -104,13 +104,13 @@ public class RepositoryImageUpdateTest {
RepositoryImage repoImage = (RepositoryImage) fileRepoService.getFile(fileUuid);
FileRepositoryTestUtil.checkImage(repoImage, initialPath, initialOriginalFilename, initialExtension, initialContentType, 0, 0, Orientation.PORTRAIT);
repoImage = fileRepoService.updateBytes(repoImage, "image/png", image10x10);
repoImage = fileRepoService.updateImageBytes(repoImage, "image/png", image10x10);
FileRepositoryTestUtil.checkImage(repoImage, initialPath, initialOriginalFilename, initialExtension, initialContentType, 7, 7, Orientation.PORTRAIT);
repoImage = fileRepoService.updateBytes(repoImage, "image/png", image11x10);
repoImage = fileRepoService.updateImageBytes(repoImage, "image/png", image11x10);
FileRepositoryTestUtil.checkImage(repoImage, initialPath, initialOriginalFilename, initialExtension, initialContentType, 11, 10, Orientation.LANDSCAPE);
repoImage = fileRepoService.updateBytes(repoImage, "image/png", image10x11);
repoImage = fileRepoService.updateImageBytes(repoImage, "image/png", image10x11);
FileRepositoryTestUtil.checkImage(repoImage, initialPath, initialOriginalFilename, initialExtension, initialContentType, 10, 11, Orientation.PORTRAIT);
}
}
Supports Markdown
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