Commit c6b222cf authored by Matija Obreza's avatar Matija Obreza
Browse files

(Eclipse) Code cleanup

parent 1bed03d8
......@@ -143,7 +143,7 @@ public class RepositoryFile extends BaseEntity implements BaseMetadata {
// TODO See if we can have a setter instead
/*
* (non-Javadoc)
*
*
* @see org.genesys2.server.filerepository.metadata.BaseMetadata#getIdentifier()
*/
// of this formula.
......@@ -201,7 +201,7 @@ public class RepositoryFile extends BaseEntity implements BaseMetadata {
/*
* (non-Javadoc)
*
*
* @see org.genesys2.server.filerepository.metadata.BaseMetadata#getTitle()
*/
@Override
......@@ -220,7 +220,7 @@ public class RepositoryFile extends BaseEntity implements BaseMetadata {
/*
* (non-Javadoc)
*
*
* @see org.genesys2.server.filerepository.metadata.BaseMetadata#getSubject()
*/
@Override
......@@ -239,7 +239,7 @@ public class RepositoryFile extends BaseEntity implements BaseMetadata {
/*
* (non-Javadoc)
*
*
* @see org.genesys2.server.filerepository.metadata.BaseMetadata#getDescription()
*/
@Override
......@@ -258,7 +258,7 @@ public class RepositoryFile extends BaseEntity implements BaseMetadata {
/*
* (non-Javadoc)
*
*
* @see org.genesys2.server.filerepository.metadata.BaseMetadata#getCreator()
*/
@Override
......@@ -277,7 +277,7 @@ public class RepositoryFile extends BaseEntity implements BaseMetadata {
/*
* (non-Javadoc)
*
*
* @see org.genesys2.server.filerepository.metadata.BaseMetadata#getCreated()
*/
@Override
......@@ -296,7 +296,7 @@ public class RepositoryFile extends BaseEntity implements BaseMetadata {
/*
* (non-Javadoc)
*
*
* @see org.genesys2.server.filerepository.metadata.BaseMetadata#getRightsHolder( )
*/
@Override
......@@ -315,7 +315,7 @@ public class RepositoryFile extends BaseEntity implements BaseMetadata {
/*
* (non-Javadoc)
*
*
* @see org.genesys2.server.filerepository.metadata.BaseMetadata#getAccessRights( )
*/
@Override
......@@ -334,7 +334,7 @@ public class RepositoryFile extends BaseEntity implements BaseMetadata {
/*
* (non-Javadoc)
*
*
* @see org.genesys2.server.filerepository.metadata.BaseMetadata#getLicense()
*/
@Override
......@@ -353,7 +353,7 @@ public class RepositoryFile extends BaseEntity implements BaseMetadata {
/*
* (non-Javadoc)
*
*
* @see org.genesys2.server.filerepository.metadata.BaseMetadata#getFormat()
*/
@Override
......@@ -381,7 +381,7 @@ public class RepositoryFile extends BaseEntity implements BaseMetadata {
/*
* (non-Javadoc)
*
*
* @see org.genesys2.server.filerepository.metadata.BaseMetadata#getExtent()
*/
@Override
......@@ -400,7 +400,7 @@ public class RepositoryFile extends BaseEntity implements BaseMetadata {
/*
* (non-Javadoc)
*
*
* @see org.genesys2.server.filerepository.metadata.BaseMetadata# getBibliographicCitation()
*/
@Override
......@@ -419,7 +419,7 @@ public class RepositoryFile extends BaseEntity implements BaseMetadata {
/*
* (non-Javadoc)
*
*
* @see org.genesys2.server.filerepository.metadata.BaseMetadata#getDateSubmitted ()
*/
@Override
......@@ -447,7 +447,7 @@ public class RepositoryFile extends BaseEntity implements BaseMetadata {
/*
* (non-Javadoc)
*
*
* @see org.genesys2.server.filerepository.metadata.BaseMetadata#getModified()
*/
@Override
......
......@@ -145,8 +145,8 @@ public interface RepositoryService {
* @throws NoSuchRepositoryFileException the no such repository file exception
* @throws InvalidRepositoryPathException when the new path is invalid
*/
RepositoryFile moveFile(RepositoryFile repositoryFile, String newPath) throws NoSuchRepositoryFileException,
InvalidRepositoryPathException;
RepositoryFile moveFile(RepositoryFile repositoryFile, String newPath)
throws NoSuchRepositoryFileException, InvalidRepositoryPathException;
/**
* List all {@link RepositoryImage} entries at specified path.
......
......@@ -156,12 +156,12 @@ public class ImageGalleryAspects {
imagesList = new ArrayList<RepositoryImage>(1);
}
if (! imagesList.contains(repositoryImage)) {
if (!imagesList.contains(repositoryImage)) {
if (LOG.isDebugEnabled()) {
LOG.debug("Adding " + repositoryImage + " to image gallery at path=" + imageGallery.getPath());
}
imagesList.add(repositoryImage);
imageGalleryService.saveImageOrder(imageGallery);
}
}
......
......@@ -86,13 +86,13 @@ public class FilesystemStorageServiceImpl implements BytesStorageService {
/*
* (non-Javadoc)
*
*
* @see org.genesys2.server.filerepository.service.BytesStorageService#upsert( java.lang.String, java.lang.String,
* byte[])
*/
@Override
public void upsert(final String path, final String filename, final byte[] data) throws FileNotFoundException,
IOException {
public void upsert(final String path, final String filename, final byte[] data)
throws FileNotFoundException, IOException {
final File destinationDir = new File(repoDir, path);
if (!destinationDir.getCanonicalPath().startsWith(repoDir.getCanonicalPath()))
......@@ -111,7 +111,7 @@ public class FilesystemStorageServiceImpl implements BytesStorageService {
/*
* (non-Javadoc)
*
*
* @see org.genesys2.server.filerepository.service.BytesStorageService#remove( java.lang.String, java.lang.String)
*/
@Override
......@@ -137,7 +137,7 @@ public class FilesystemStorageServiceImpl implements BytesStorageService {
/*
* (non-Javadoc)
*
*
* @see org.genesys2.server.filerepository.service.BytesStorageService#get(java. lang.String, java.lang.String)
*/
@Override
......@@ -160,7 +160,7 @@ public class FilesystemStorageServiceImpl implements BytesStorageService {
/*
* (non-Javadoc)
*
*
* @see org.genesys2.server.filerepository.service.BytesStorageService#exists(java.lang.String, java.lang.String)
*/
@Override
......@@ -173,7 +173,7 @@ public class FilesystemStorageServiceImpl implements BytesStorageService {
/*
* (non-Javadoc)
*
*
* @see org.genesys2.server.filerepository.service.BytesStorageService#listFiles(java.lang.String)
*/
@Override
......
......@@ -66,7 +66,7 @@ public class ImageGalleryServiceImpl implements ImageGalleryService {
/*
* (non-Javadoc)
*
*
* @see org.genesys2.server.filerepository.service.ImageGalleryService#loadImageGallery(java.lang.String)
*/
@Override
......@@ -91,7 +91,7 @@ public class ImageGalleryServiceImpl implements ImageGalleryService {
/*
* (non-Javadoc)
*
*
* @see org.genesys2.server.filerepository.service.ImageGalleryService#createImageGallery(java.lang.String,
* java.lang.String, java.lang.String)
*/
......@@ -108,8 +108,8 @@ public class ImageGalleryServiceImpl implements ImageGalleryService {
imageGallery.setTitle(title);
imageGallery.setDescription(description);
final List<RepositoryImage> images = new ArrayList<RepositoryImage>(repositoryService.listImages(imageGallery
.getPath()));
final List<RepositoryImage> images = new ArrayList<RepositoryImage>(
repositoryService.listImages(imageGallery.getPath()));
imageGallery.setImages(images);
......@@ -118,7 +118,7 @@ public class ImageGalleryServiceImpl implements ImageGalleryService {
/*
* (non-Javadoc)
*
*
* @see
* org.genesys2.server.filerepository.service.ImageGalleryService#removeGallery(org.genesys2.server.filerepository.
* model.ImageGallery)
......@@ -158,13 +158,14 @@ public class ImageGalleryServiceImpl implements ImageGalleryService {
/*
* (non-Javadoc)
*
*
* @see org.genesys2.server.filerepository.service.ImageGalleryService#updateImageGalery(org.genesys2.server.
* filerepository.model.ImageGallery, java.lang.String, java.lang.String)
*/
@Override
@Transactional
public ImageGallery updateImageGalery(final ImageGallery imageGallery, final String title, final String description) {
public ImageGallery updateImageGalery(final ImageGallery imageGallery, final String title,
final String description) {
final ImageGallery imageGallery2 = imageGalleryPersistence.findOne(imageGallery.getId());
imageGallery2.setTitle(title);
......@@ -176,7 +177,7 @@ public class ImageGalleryServiceImpl implements ImageGalleryService {
/*
* (non-Javadoc)
*
*
* @see
* org.genesys2.server.filerepository.service.ImageGalleryService#saveImageOrder(org.genesys2.server.filerepository.
* model.ImageGallery)
......@@ -281,15 +282,18 @@ public class ImageGalleryServiceImpl implements ImageGalleryService {
* @return the page
*/
@Override
public Page<ImageGallery> listImageGalleries(Pageable pageable) {
public Page<ImageGallery> listImageGalleries(final Pageable pageable) {
return imageGalleryPersistence.findAll(pageable);
}
/* (non-Javadoc)
* @see org.genesys2.server.filerepository.service.ImageGalleryService#listImageGalleries(java.lang.String, org.springframework.data.domain.Pageable)
/*
* (non-Javadoc)
*
* @see org.genesys2.server.filerepository.service.ImageGalleryService#listImageGalleries(java.lang.String,
* org.springframework.data.domain.Pageable)
*/
@Override
public Page<ImageGallery> listImageGalleries(String prefix, Pageable pageable) {
public Page<ImageGallery> listImageGalleries(final String prefix, final Pageable pageable) {
return imageGalleryPersistence.listByPath(prefix, pageable);
}
}
......@@ -67,15 +67,16 @@ public class RepositoryServiceImpl implements RepositoryService {
/*
* (non-Javadoc)
*
*
* @see org.genesys2.server.filerepository.service.RepositoryService#addFile(java .lang.String, java.lang.String,
* java.lang.String, byte[], org.genesys2.server.filerepository.model.RepositoryFile)
*/
@Override
@Transactional
public RepositoryFile addFile(final String repositoryPath, final String originalFilename, final String contentType,
final byte[] bytes, final RepositoryFile metaData) throws InvalidRepositoryPathException,
InvalidRepositoryFileDataException {
final byte[] bytes, final RepositoryFile metaData)
throws InvalidRepositoryPathException, InvalidRepositoryFileDataException {
if (!PathValidator.isValidPath(repositoryPath)) {
if (LOG.isDebugEnabled()) {
LOG.debug("Invalid path provided path=" + repositoryPath);
......@@ -109,7 +110,7 @@ public class RepositoryServiceImpl implements RepositoryService {
/*
* (non-Javadoc)
*
*
* @see org.genesys2.server.filerepository.service.RepositoryService#addImage( java.lang.String, java.lang.String,
* java.lang.String, byte[], org.genesys2.server.filerepository.model.RepositoryImage)
*/
......@@ -140,7 +141,7 @@ public class RepositoryServiceImpl implements RepositoryService {
try (final InputStream in = new ByteArrayInputStream(bytes)) {
in.mark(0);
String detectedContentType = URLConnection.guessContentTypeFromStream(in);
final String detectedContentType = URLConnection.guessContentTypeFromStream(in);
if (detectedContentType != null && !detectedContentType.equals(contentType)) {
// overwrite contentType
LOG.warn("Replacing content type; provided={} detected={}", contentType, detectedContentType);
......@@ -170,7 +171,7 @@ public class RepositoryServiceImpl implements RepositoryService {
/*
* (non-Javadoc)
*
*
* @see org.genesys2.server.filerepository.service.RepositoryService#getFile(java .util.UUID)
*/
@Override
......@@ -188,12 +189,13 @@ public class RepositoryServiceImpl implements RepositoryService {
/*
* (non-Javadoc)
*
*
* @see org.genesys2.server.filerepository.service.RepositoryService#getFileBytes (java.lang.String,
* java.lang.String)
*/
@Override
public byte[] getFileBytes(final String repositoryPath, final String filename) throws NoSuchRepositoryFileException {
public byte[] getFileBytes(final String repositoryPath, final String filename)
throws NoSuchRepositoryFileException {
byte[] data = null;
try {
......@@ -207,7 +209,7 @@ public class RepositoryServiceImpl implements RepositoryService {
/*
* (non-Javadoc)
*
*
* @see org.genesys2.server.filerepository.service.RepositoryService#getFiles( java.lang.String)
*/
@Override
......@@ -220,7 +222,7 @@ public class RepositoryServiceImpl implements RepositoryService {
/*
* (non-Javadoc)
*
*
* @see org.genesys2.server.filerepository.service.RepositoryService#updateFile(
* org.genesys2.server.filerepository.model .RepositoryFile)
*/
......@@ -240,8 +242,12 @@ public class RepositoryServiceImpl implements RepositoryService {
return repositoryFile;
}
/* (non-Javadoc)
* @see org.genesys2.server.filerepository.service.RepositoryService#updateMetadata(org.genesys2.server.filerepository.model.RepositoryImage)
/*
* (non-Javadoc)
*
* @see
* org.genesys2.server.filerepository.service.RepositoryService#updateMetadata(org.genesys2.server.filerepository.
* model.RepositoryImage)
*/
@Override
public RepositoryImage updateMetadata(RepositoryImage repositoryImage) throws NoSuchRepositoryFileException {
......@@ -255,7 +261,7 @@ public class RepositoryServiceImpl implements RepositoryService {
/*
* (non-Javadoc)
*
*
* @see org.genesys2.server.filerepository.service.RepositoryService#updateBytes(
* org.genesys2.server.filerepository.model .RepositoryFile, java.lang.String, byte[])
*/
......@@ -274,7 +280,7 @@ public class RepositoryServiceImpl implements RepositoryService {
/*
* (non-Javadoc)
*
*
* @see org.genesys2.server.filerepository.service.RepositoryService#updateBytes(
* org.genesys2.server.filerepository.model .RepositoryImage, java.lang.String, byte[])
*/
......@@ -302,14 +308,14 @@ public class RepositoryServiceImpl implements RepositoryService {
/*
* (non-Javadoc)
*
*
* @see org.genesys2.server.filerepository.service.RepositoryService#removeFile(
* org.genesys2.server.filerepository.model .RepositoryFile)
*/
@Override
@Transactional
public RepositoryFile removeFile(final RepositoryFile repositoryFile) throws NoSuchRepositoryFileException,
IOException {
public RepositoryFile removeFile(final RepositoryFile repositoryFile)
throws NoSuchRepositoryFileException, IOException {
if (repositoryFile == null)
throw new NoSuchRepositoryFileException();
......@@ -326,7 +332,7 @@ public class RepositoryServiceImpl implements RepositoryService {
/*
* (non-Javadoc)
*
*
* @see org.genesys2.server.filerepository.service.RepositoryService#moveFile(org
* .genesys2.server.filerepository.model .RepositoryFile, java.lang.String)
*/
......@@ -378,7 +384,7 @@ public class RepositoryServiceImpl implements RepositoryService {
/*
* (non-Javadoc)
*
*
* @see org.genesys2.server.filerepository.service.RepositoryService#listImages(java.lang.String)
*/
@Override
......@@ -388,12 +394,12 @@ public class RepositoryServiceImpl implements RepositoryService {
/*
* (non-Javadoc)
*
*
* @see org.genesys2.server.filerepository.service.RepositoryService#listPaths(java.lang.String)
*/
@Override
public List<String> listPaths(String prefix, Pageable pageable) {
List<String> paths = repositoryFilePersistence.listDistinctPaths(prefix, pageable);
public List<String> listPaths(final String prefix, final Pageable pageable) {
final List<String> paths = repositoryFilePersistence.listDistinctPaths(prefix, pageable);
paths.remove(prefix);
return paths;
}
......
......@@ -116,7 +116,8 @@ public class FileRepositoryAddTest {
fileData.setSubject(subject);
fileData.setTitle(title);
final RepositoryFile repoFile = fileRepoService.addFile(path, originalFilename, contentType, SOME_BYTES, fileData);
final RepositoryFile repoFile = fileRepoService.addFile(path, originalFilename, contentType, SOME_BYTES,
fileData);
FileRepositoryTestUtil.checkFile(repoFile, path, originalFilename, extension, contentType);
FileRepositoryTestUtil.checkMetadata(repoFile, bibliographicCitation, accessRights, created, creator,
......
......@@ -71,7 +71,7 @@ public class FileRepositoryDirectoryTest {
final String extension = ".txt";
final String originalFilename = "folderfile" + extension;
List<RepositoryFile> repoFiles = new ArrayList<RepositoryFile>(20);
final List<RepositoryFile> repoFiles = new ArrayList<RepositoryFile>(20);
repoFiles.add(fileRepoService.addFile(PATH + "aa/", originalFilename, contentType, SOME_BYTES, null));
repoFiles.add(fileRepoService.addFile(PATH + "aa/", originalFilename, contentType, SOME_BYTES, null));
repoFiles.add(fileRepoService.addFile(PATH + "aa/", originalFilename, contentType, SOME_BYTES, null));
......@@ -112,7 +112,7 @@ public class FileRepositoryDirectoryTest {
assertThat("Paths not in correct order", paths,
contains(PATH + "bb/cc/", PATH + "bb/cc/ee/", PATH + "bb/cc/ee/ff/"));
for (RepositoryFile repoFile : repoFiles) {
for (final RepositoryFile repoFile : repoFiles) {
fileRepoService.removeFile(repoFile);
}
......
......@@ -128,8 +128,8 @@ public class FileRepositoryExtensionTest {
@Test
public void extensionDotFileIsNullOnAdd() throws NoSuchRepositoryFileException, InvalidRepositoryPathException,
InvalidRepositoryFileDataException, IOException {
final RepositoryFile repoFile = fileRepoService.addFile(initialPath, ".gitignore", initialContentType, EMPTY_BYTES,
null);
final RepositoryFile repoFile = fileRepoService.addFile(initialPath, ".gitignore", initialContentType,
EMPTY_BYTES, null);
FileRepositoryTestUtil.checkFile(repoFile, initialPath, ".gitignore", null, initialContentType);
fileRepoService.removeFile(repoFile);
}
......
......@@ -73,7 +73,8 @@ public class FileRepositoryUpdateTest {
@Before
public void beforeTest() throws InvalidRepositoryPathException, InvalidRepositoryFileDataException {
fileUuid = fileRepoService
.addFile(initialPath, initialOriginalFilename, initialContentType, "initial".getBytes(), null).getUuid();
.addFile(initialPath, initialOriginalFilename, initialContentType, "initial".getBytes(), null)
.getUuid();
}
/**
......@@ -209,7 +210,8 @@ public class FileRepositoryUpdateTest {
// Move
final String newPath = "/new/" + System.currentTimeMillis() + "/";
fileData = fileRepoService.moveFile(fileData, newPath);
FileRepositoryTestUtil.checkFile(fileData, newPath, initialOriginalFilename, initialExtension, initialContentType);
FileRepositoryTestUtil.checkFile(fileData, newPath, initialOriginalFilename, initialExtension,
initialContentType);
// Move back
fileData = fileRepoService.moveFile(fileData, initialPath);
......
......@@ -312,7 +312,7 @@ public class S3StorageServiceTest {
/**
* Ensure 404 exception is not thrown for non-existent file.
*
*
* @throws IOException
*/
@Test
......
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