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

JAutodoc and source cleanup

parent 9e191f18
......@@ -24,9 +24,17 @@ public abstract class FileRepositoryException extends Exception {
/** The Constant serialVersionUID. */
private static final long serialVersionUID = 1L;
/**
* Instantiates a new file repository exception.
*/
public FileRepositoryException() {
}
/**
* Instantiates a new file repository exception.
*
* @param message the message
*/
public FileRepositoryException(final String message) {
super(message);
}
......
......@@ -22,9 +22,17 @@ package org.genesys.filerepository;
*/
public class InvalidRepositoryFileDataException extends FileRepositoryException {
/**
* Instantiates a new invalid repository file data exception.
*/
public InvalidRepositoryFileDataException() {
}
/**
* Instantiates a new invalid repository file data exception.
*
* @param message the message
*/
public InvalidRepositoryFileDataException(final String message) {
super(message);
}
......
......@@ -16,6 +16,7 @@
package org.genesys.filerepository;
// TODO: Auto-generated Javadoc
/**
* The InvalidRepositoryPathException is thrown when Repository is not happy
* with your selected path.
......@@ -24,6 +25,11 @@ public class InvalidRepositoryPathException extends FileRepositoryException {
/** The Constant serialVersionUID. */
private static final long serialVersionUID = 1L;
/**
* Instantiates a new invalid repository path exception.
*
* @param message the message
*/
public InvalidRepositoryPathException(final String message) {
super(message);
}
......
......@@ -16,6 +16,7 @@
package org.genesys.filerepository;
// TODO: Auto-generated Javadoc
/**
* The Class NoSuchRepositoryFileException.
*/
......@@ -23,9 +24,17 @@ public class NoSuchRepositoryFileException extends FileRepositoryException {
/** The Constant serialVersionUID. */
private static final long serialVersionUID = 1L;
/**
* Instantiates a new no such repository file exception.
*/
public NoSuchRepositoryFileException() {
}
/**
* Instantiates a new no such repository file exception.
*
* @param message the message
*/
public NoSuchRepositoryFileException(final String message) {
super(message);
}
......
......@@ -18,6 +18,11 @@ package org.genesys.filerepository;
import org.springframework.data.jpa.repository.JpaRepository;
/**
* The Interface RepositoryPersistence.
*
* @param <T> the generic type
*/
public interface RepositoryPersistence<T> extends JpaRepository<T, Long> {
}
......@@ -31,6 +31,7 @@ import javax.persistence.OrderColumn;
import org.genesys.blocks.model.AuditedVersionedModel;
import org.genesys.blocks.model.Copyable;
// TODO: Auto-generated Javadoc
/**
* {@link ImageGallery} is a collection of ordered {@link RepositoryImage}
* instances.
......@@ -45,6 +46,7 @@ import org.genesys.blocks.model.Copyable;
@Entity(name = "repositorygallery")
public class ImageGallery extends AuditedVersionedModel implements Copyable<ImageGallery> {
/** The Constant serialVersionUID. */
private static final long serialVersionUID = 6043583851401365284L;
/**
......@@ -144,6 +146,10 @@ public class ImageGallery extends AuditedVersionedModel implements Copyable<Imag
this.images = images;
}
/*
* (non-Javadoc)
* @see org.genesys.blocks.model.Copyable#apply(java.lang.Object)
*/
@Override
public ImageGallery apply(final ImageGallery source) {
this.active = source.active;
......@@ -154,6 +160,10 @@ public class ImageGallery extends AuditedVersionedModel implements Copyable<Imag
return this;
}
/*
* (non-Javadoc)
* @see org.genesys.blocks.model.Copyable#copy()
*/
@Override
public ImageGallery copy() {
final ImageGallery copy = new ImageGallery();
......
......@@ -94,6 +94,12 @@ public class RepositoryDocument extends RepositoryFile implements DocumentMetada
this.abstrct = abstrct;
}
/**
* Apply.
*
* @param source the source
* @return the repository document
*/
public RepositoryDocument apply(final RepositoryDocument source) {
super.apply(source);
......
......@@ -41,6 +41,7 @@ import org.genesys.blocks.model.InMemoryIdGenerator;
import org.genesys.filerepository.metadata.BaseMetadata;
import org.genesys.filerepository.service.BytesStorageService;
// TODO: Auto-generated Javadoc
/**
* The Class RepositoryFile.
*/
......@@ -56,6 +57,7 @@ public class RepositoryFile extends AuditedVersionedModelWithoutId implements En
/** The Constant serialVersionUID. */
private static final long serialVersionUID = -4816923593950502695L;
/** The id. */
@Id
@GeneratedValue(strategy = GenerationType.TABLE)
@Column(name = "id", unique = true, nullable = false, length = 20)
......@@ -142,7 +144,7 @@ public class RepositoryFile extends AuditedVersionedModelWithoutId implements En
@Column(length = 32, nullable = false)
private String md5Sum;
/** Byte length */
/** Byte length. */
@Column(nullable = false)
private int size;
......@@ -214,9 +216,9 @@ public class RepositoryFile extends AuditedVersionedModelWithoutId implements En
}
/**
* Get the path of the file used by {@link BytesStorageService}
* Get the path of the file used by {@link BytesStorageService}.
*
* @return
* @return the storage path
*/
@Transient
public String getStoragePath() {
......@@ -230,18 +232,27 @@ public class RepositoryFile extends AuditedVersionedModelWithoutId implements En
* Get the full path to the file as used by {@link BytesStorageService}. This is
* the concatenation of {@link #getStoragePath()} and {@link #getFilename()}.
*
* @return
* @return the storage full path
*/
@Transient
public String getStorageFullPath() {
return getStoragePath() + "/" + getFilename();
}
/*
* (non-Javadoc)
* @see org.genesys.blocks.model.EntityId#getId()
*/
@Override
public Long getId() {
return id;
}
/**
* Sets the id.
*
* @param id the new id
*/
public void setId(final Long id) {
this.id = id;
}
......@@ -621,6 +632,8 @@ public class RepositoryFile extends AuditedVersionedModelWithoutId implements En
}
/**
* Gets the size.
*
* @return the size
*/
public final int getSize() {
......@@ -628,12 +641,18 @@ public class RepositoryFile extends AuditedVersionedModelWithoutId implements En
}
/**
* Sets the size.
*
* @param size the size to set
*/
public final void setSize(final int size) {
this.size = size;
}
/*
* (non-Javadoc)
* @see org.genesys.blocks.model.Copyable#apply(java.lang.Object)
*/
@Override
public RepositoryFile apply(final RepositoryFile source) {
this.active = source.active;
......@@ -661,6 +680,10 @@ public class RepositoryFile extends AuditedVersionedModelWithoutId implements En
return this;
}
/*
* (non-Javadoc)
* @see org.genesys.blocks.model.Copyable#copy()
*/
@Override
public RepositoryFile copy() {
final RepositoryFile copy = new RepositoryFile();
......
......@@ -26,6 +26,7 @@ import javax.persistence.Transient;
import org.genesys.filerepository.metadata.ImageMetadata;
// TODO: Auto-generated Javadoc
/**
* An {@link RepositoryImage} is an graphics file in one of the supported image
* formats (PNG and JPG). It extends the {@link RepositoryFile} by including
......@@ -129,6 +130,12 @@ public class RepositoryImage extends RepositoryFile implements ImageMetadata {
orientation = width > height ? Orientation.LANDSCAPE : Orientation.PORTRAIT;
}
/**
* Apply.
*
* @param source the source
* @return the repository image
*/
public RepositoryImage apply(final RepositoryImage source) {
super.apply(source);
......
......@@ -50,16 +50,16 @@ public interface RepositoryFilePersistence extends RepositoryPersistence<Reposit
List<RepositoryFile> findByPath(String repositoryPath);
/**
* List repository files at specified paths
* List repository files at specified paths.
*
* @param path
* @return
* @param paths the paths
* @return the list
*/
@Query("select rf from RepositoryFile rf where rf.path in ?1")
List<RepositoryFile> findByPath(Collection<String> paths);
/**
* List distinct paths starting with the prefix
* List distinct paths starting with the prefix.
*
* @param prefix the prefix
* @param pageable the pagination
......@@ -69,7 +69,7 @@ public interface RepositoryFilePersistence extends RepositoryPersistence<Reposit
List<String> listDistinctPaths(String prefix, Pageable pageable);
/**
* List distinct paths starting with the prefix
* List distinct paths starting with the prefix.
*
* @param prefix the prefix
* @return the list of paths
......@@ -78,7 +78,7 @@ public interface RepositoryFilePersistence extends RepositoryPersistence<Reposit
List<String> listDistinctPaths(String prefix);
/**
* Find files with missing hashes
* Find files with missing hashes.
*
* @return the list
*/
......@@ -86,12 +86,16 @@ public interface RepositoryFilePersistence extends RepositoryPersistence<Reposit
List<RepositoryFile> findByMissingHashSums();
/**
* Find repository file by path and originalFilename
* Find repository file by path and originalFilename.
*
* @param path the path
* @param originalFilename the original filename
* @return the repository file
*/
RepositoryFile findByPathAndOriginalFilename(String path, String originalFilename);
/**
* Count files with matching path
* Count files with matching path.
*
* @param path Repository path
* @return Number of files at specified path
......
......@@ -39,7 +39,7 @@ public interface BytesStorageService {
/**
* Removes the file with specified filename from repository at the specified
* path
* path.
*
* @param path the path
* @param filename the filename
......
......@@ -21,6 +21,7 @@ import org.genesys.filerepository.model.ImageGallery;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
// TODO: Auto-generated Javadoc
/**
* The ImageGalleryService.
*/
......@@ -56,7 +57,7 @@ public interface ImageGalleryService {
* Delete the image gallery, but don't remove the images at that path.
*
* @param imageGallery the image gallery
* @throws InvalidRepositoryPathException
* @throws InvalidRepositoryPathException the invalid repository path exception
*/
void removeGallery(ImageGallery imageGallery) throws InvalidRepositoryPathException;
......
......@@ -80,12 +80,12 @@ public interface RepositoryService {
RepositoryFile getFile(UUID fileUuid) throws NoSuchRepositoryFileException;
/**
* Get repository file by its path and filename
* Get repository file by its path and filename.
*
* @param path
* @param filename
* @return
* @throws NoSuchRepositoryFileException
* @param path the path
* @param filename the filename
* @return the file
* @throws NoSuchRepositoryFileException the no such repository file exception
*/
RepositoryFile getFile(String path, String filename) throws NoSuchRepositoryFileException;
......@@ -119,6 +119,7 @@ public interface RepositoryService {
/**
* Update file metadata. The update is based on the record UUID.
*
* @param <T> the generic type
* @param uuid UUID of the repository file
* @param fileData the file data
* @return the updated RepositoryFile
......@@ -175,13 +176,14 @@ public interface RepositoryService {
RepositoryFile moveFile(RepositoryFile repositoryFile, String newPath) throws NoSuchRepositoryFileException, InvalidRepositoryPathException;
/**
* Update path and originalFilename of repository file
* Update path and originalFilename of repository file.
*
* @param repositoryFile
* @param fullPath
* @return
* @throws InvalidRepositoryPathException
* @throws InvalidRepositoryFileDataException
* @param repositoryFile the repository file
* @param fullPath the full path
* @return the repository file
* @throws InvalidRepositoryPathException the invalid repository path exception
* @throws InvalidRepositoryFileDataException the invalid repository file data
* exception
*/
RepositoryFile moveAndRenameFile(RepositoryFile repositoryFile, String fullPath) throws InvalidRepositoryPathException, InvalidRepositoryFileDataException;
......@@ -194,21 +196,23 @@ public interface RepositoryService {
List<RepositoryImage> listImages(String path);
/**
* List all paths within the prefix, including prefix itself if such paths exist
* List all paths within the prefix, including prefix itself if such paths
* exist.
*
* @param prefix The prefix
* @param pageRequest Pagination
* @return Distinct list of paths in repository starting with prefix
* @throws InvalidRepositoryPathException
* @throws InvalidRepositoryPathException the invalid repository path exception
*/
List<String> listPaths(String prefix, Pageable pageRequest) throws InvalidRepositoryPathException;
/**
* List all paths within the prefix, including prefix itself if such paths exist
* List all paths within the prefix, including prefix itself if such paths
* exist.
*
* @param prefix
* @return
* @throws InvalidRepositoryPathException
* @param prefix the prefix
* @return the list
* @throws InvalidRepositoryPathException the invalid repository path exception
*/
List<String> listPaths(String prefix) throws InvalidRepositoryPathException;
......@@ -235,20 +239,20 @@ public interface RepositoryService {
RepositoryImage removeImage(RepositoryImage repositoryImage) throws NoSuchRepositoryFileException, IOException;
/**
* Test if repository contains the path
* Test if repository contains the path.
*
* @param path
* @param path the path
* @return true if at least one entry exists at specified path
* @throws InvalidRepositoryPathException
* @throws InvalidRepositoryPathException the invalid repository path exception
*/
boolean hasPath(Path path) throws InvalidRepositoryPathException;
/**
* Move all repository items to a new path
* Move all repository items to a new path.
*
* @param currentPath
* @param newPath
* @throws InvalidRepositoryPathException
* @param currentPath the current path
* @param newPath the new path
* @throws InvalidRepositoryPathException the invalid repository path exception
*/
void renamePath(String currentPath, String newPath) throws InvalidRepositoryPathException;
......
......@@ -16,10 +16,20 @@
package org.genesys.filerepository.service;
// TODO: Auto-generated Javadoc
/**
* The Class VirusFoundException.
*/
public class VirusFoundException extends Exception {
/** The Constant serialVersionUID. */
private static final long serialVersionUID = 3070028170493142618L;
/**
* Instantiates a new virus found exception.
*
* @param message the message
*/
public VirusFoundException(final String message) {
super(message);
}
......
......@@ -18,11 +18,19 @@ package org.genesys.filerepository.service;
import java.io.IOException;
// TODO: Auto-generated Javadoc
/**
* The VirusScanner
* The VirusScanner.
*/
public interface VirusScanner {
/**
* Scan.
*
* @param bytes the bytes
* @throws VirusFoundException the virus found exception
* @throws IOException Signals that an I/O exception has occurred.
*/
void scan(byte[] bytes) throws VirusFoundException, IOException;
}
......@@ -24,11 +24,23 @@ import org.genesys.filerepository.model.RepositoryImage;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
// TODO: Auto-generated Javadoc
/**
* The Class AbstractImageGalleryAspects.
*/
@Aspect
public abstract class AbstractImageGalleryAspects {
/** The Constant LOG. */
protected Logger LOG = LoggerFactory.getLogger(getClass());
/**
* After repository image save iterable.
*
* @param joinPoint the join point
* @param repositoryImages the repository images
* @return the object
* @throws Throwable the throwable
*/
@AfterReturning(value = "execution(* org.genesys.filerepository.persistence.RepositoryImagePersistence.save(*))", returning = "repositoryImages")
public Object afterRepositoryImageSaveIterable(final JoinPoint joinPoint, final Iterable<RepositoryImage> repositoryImages) throws Throwable {
......@@ -41,8 +53,21 @@ public abstract class AbstractImageGalleryAspects {
return repositoryImages;
}
/**
* Adds the image to gallery.
*
* @param repositoryImage the repository image
*/
protected abstract void addImageToGallery(RepositoryImage repositoryImage);
/**
* After repository image save.
*
* @param joinPoint the join point
* @param repositoryImage the repository image
* @return the object
* @throws Throwable the throwable
*/
@AfterReturning(value = "execution(* org.genesys.filerepository.persistence.RepositoryImagePersistence.save(*))", returning = "repositoryImage")
public Object afterRepositoryImageSave(final JoinPoint joinPoint, final RepositoryImage repositoryImage) throws Throwable {
......@@ -57,6 +82,14 @@ public abstract class AbstractImageGalleryAspects {
return repositoryImage;
}
/**
* Around repository image delete.
*
* @param joinPoint the join point
* @param repositoryImage the repository image
* @return the object
* @throws Throwable the throwable
*/
@Around(value = "execution(* org.genesys.filerepository.persistence.RepositoryImagePersistence.delete(*)) && args(repositoryImage)")
public Object aroundRepositoryImageDelete(final ProceedingJoinPoint joinPoint, final RepositoryImage repositoryImage) throws Throwable {
......@@ -79,5 +112,10 @@ public abstract class AbstractImageGalleryAspects {
return repositoryImage;
}
/**
* Removes the image from gallery.
*
* @param repositoryImage the repository image
*/
protected abstract void removeImageFromGallery(RepositoryImage repositoryImage);
}
\ No newline at end of file
......@@ -29,6 +29,7 @@ import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
// TODO: Auto-generated Javadoc
/**
* Handles magical updates to {@link ImageGallery} when files are added to
* {@link RepositoryImagePersistence}.
......@@ -43,16 +44,28 @@ publ