Commit 3c9b9077 authored by Matija Obreza's avatar Matija Obreza
Browse files

Source code cleanup

parent 9b22e4e6
/*
* Copyright 2016 Global Crop Diversity Trust, www.croptrust.org
* Copyright 2017 Global Crop Diversity Trust
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
......
/*
* Copyright 2016 Global Crop Diversity Trust, www.croptrust.org
* Copyright 2017 Global Crop Diversity Trust
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
......
/*
* Copyright 2016 Global Crop Diversity Trust, www.croptrust.org
* Copyright 2017 Global Crop Diversity Trust
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
......@@ -24,8 +24,8 @@ public class InvalidRepositoryFileDataException extends FileRepositoryException
public InvalidRepositoryFileDataException() {
}
public InvalidRepositoryFileDataException(String message) {
public InvalidRepositoryFileDataException(final String message) {
super(message);
}
......
/*
* Copyright 2016 Global Crop Diversity Trust, www.croptrust.org
* Copyright 2017 Global Crop Diversity Trust
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
......@@ -17,7 +17,8 @@
package org.genesys.filerepository;
/**
* The InvalidRepositoryPathException is thrown when Repository is not happy with your selected path.
* The InvalidRepositoryPathException is thrown when Repository is not happy
* with your selected path.
*/
public class InvalidRepositoryPathException extends FileRepositoryException {
/** The Constant serialVersionUID. */
......
/*
* Copyright 2016 Global Crop Diversity Trust, www.croptrust.org
* Copyright 2017 Global Crop Diversity Trust
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
......@@ -26,7 +26,7 @@ public class NoSuchRepositoryFileException extends FileRepositoryException {
public NoSuchRepositoryFileException() {
}
public NoSuchRepositoryFileException(String message) {
public NoSuchRepositoryFileException(final String message) {
super(message);
}
......
/*
* Copyright 2016 Global Crop Diversity Trust, www.croptrust.org
* Copyright 2017 Global Crop Diversity Trust
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
......@@ -29,15 +29,17 @@ import java.util.Date;
public interface BaseMetadata extends Serializable {
/**
* Get the permanent unique identifier of the resource. Commonly a Uniform Resource Locator (URL).
* Get the permanent unique identifier of the resource. Commonly a Uniform
* Resource Locator (URL).
*
* @return the identifier
*/
String getIdentifier();
/**
* Title is a property that refers to the name or names by which a resource is formally known. It may be qualified and repeated. Commonly used in conjunction with
* dc:alternative.
* Title is a property that refers to the name or names by which a resource is
* formally known. It may be qualified and repeated. Commonly used in
* conjunction with dc:alternative.
*
* @return the title
*/
......@@ -51,8 +53,9 @@ public interface BaseMetadata extends Serializable {
String getSubject();
/**
* This property refers to the description of the content of a resource. The description is a potentially rich source of indexable terms and assist the users in their selection
* of an appropriate resource.
* This property refers to the description of the content of a resource. The
* description is a potentially rich source of indexable terms and assist the
* users in their selection of an appropriate resource.
*
* @return the description
*/
......@@ -66,29 +69,34 @@ public interface BaseMetadata extends Serializable {
String getCreator();
/**
* A point or period of time when the resource was created by the {@link #getCreator()}. This is not a {@link Date} type to allow for text like "Jan - Feb 2016".
* A point or period of time when the resource was created by the
* {@link #getCreator()}. This is not a {@link Date} type to allow for text like
* "Jan - Feb 2016".
*
* @return the created
*/
String getCreated();
/**
* Relationship between the resource and a person or an organization owning or managing rights over this resource.
* Relationship between the resource and a person or an organization owning or
* managing rights over this resource.
*
* @return the rights holder
*/
String getRightsHolder();
/**
* Access rights provides information about restrictions to view, search or use a resource based on attributes of the resource itself or the category of user. E.g.: My
* colleagues only
* Access rights provides information about restrictions to view, search or use
* a resource based on attributes of the resource itself or the category of
* user. E.g.: My colleagues only
*
* @return the access rights
*/
String getAccessRights();
/**
* Legal document giving official permission to do something with the resource. E.g. http://www.gnu.org/licenses/gpl.html
* Legal document giving official permission to do something with the resource.
* E.g. http://www.gnu.org/licenses/gpl.html
*
* @return the license
*/
......@@ -102,7 +110,8 @@ public interface BaseMetadata extends Serializable {
String getFormat();
/**
* Size (e.g. bytes, pages, inches, etc.) or duration (e.g. hours, minutes, days, etc.) of a resource.
* Size (e.g. bytes, pages, inches, etc.) or duration (e.g. hours, minutes,
* days, etc.) of a resource.
*
* @return the extent
*/
......
/*
* Copyright 2016 Global Crop Diversity Trust, www.croptrust.org
* Copyright 2017 Global Crop Diversity Trust
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
......@@ -23,7 +23,8 @@ package org.genesys.filerepository.metadata;
public interface DocumentMetadata extends BaseMetadata {
/**
* The language of the intellectual content of the resource. Best practice would be to select a value from the three letter language tags of ISO639.
* The language of the intellectual content of the resource. Best practice would
* be to select a value from the three letter language tags of ISO639.
*
* @return the language
*/
......
/*
* Copyright 2016 Global Crop Diversity Trust, www.croptrust.org
* Copyright 2017 Global Crop Diversity Trust
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
......@@ -37,7 +37,8 @@ public interface ImageMetadata extends BaseMetadata {
Integer getHeight();
/**
* Get image orientation. Landscape = width is greater than height. Portrait = width is less or equal height;
* Get image orientation. Landscape = width is greater than height. Portrait =
* width is less or equal height;
*
* @return the orientation
*/
......
/*
* Copyright 2016 Global Crop Diversity Trust, www.croptrust.org
* Copyright 2017 Global Crop Diversity Trust
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
......@@ -32,10 +32,13 @@ import org.genesys.blocks.model.AuditedVersionedModel;
import org.genesys.blocks.model.Copyable;
/**
* {@link ImageGallery} is a collection of ordered {@link RepositoryImage} instances.
* {@link ImageGallery} is a collection of ordered {@link RepositoryImage}
* instances.
*
* Gallery has a dedicated "path" in the file repository, where new images are posted. When an image is removed from the
* Gallery, it may be removed if it is hosted in the Gallery path, but must be kept as-is if it does not share the path.
* Gallery has a dedicated "path" in the file repository, where new images are
* posted. When an image is removed from the Gallery, it may be removed if it is
* hosted in the Gallery path, but must be kept as-is if it does not share the
* path.
*
* @author mobreza
*/
......@@ -45,7 +48,8 @@ public class ImageGallery extends AuditedVersionedModel implements Copyable<Imag
private static final long serialVersionUID = 6043583851401365284L;
/**
* Each Gallery has a dedicated "path" in the file repository. A gallery "owns" a unique path in the repository.
* Each Gallery has a dedicated "path" in the file repository. A gallery "owns"
* a unique path in the repository.
*/
@Column(name = "path", nullable = false, unique = true)
private String path;
......@@ -141,7 +145,7 @@ public class ImageGallery extends AuditedVersionedModel implements Copyable<Imag
}
@Override
public ImageGallery apply(ImageGallery source) {
public ImageGallery apply(final ImageGallery source) {
this.active = source.active;
this.description = source.description;
this.path = source.path;
......@@ -152,7 +156,7 @@ public class ImageGallery extends AuditedVersionedModel implements Copyable<Imag
@Override
public ImageGallery copy() {
ImageGallery copy = new ImageGallery();
final ImageGallery copy = new ImageGallery();
copy.apply(this);
copy.images = new ArrayList<>(this.images);
return copy;
......
/*
* Copyright 2016 Global Crop Diversity Trust, www.croptrust.org
* Copyright 2017 Global Crop Diversity Trust
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
......@@ -26,8 +26,9 @@ import org.genesys.filerepository.metadata.ImageMetadata;
// TODO: Auto-generated Javadoc
/**
* An {@link RepositoryDocument} is an graphics file in one of the supported image formats (PNG and JPG). It extends the
* {@link RepositoryFile} by including image-specific metadata defined in {@link ImageMetadata}.
* An {@link RepositoryDocument} is an graphics file in one of the supported
* image formats (PNG and JPG). It extends the {@link RepositoryFile} by
* including image-specific metadata defined in {@link ImageMetadata}.
*
* @author mobreza
*/
......@@ -48,7 +49,6 @@ public class RepositoryDocument extends RepositoryFile implements DocumentMetada
/*
* (non-Javadoc)
*
* @see org.genesys.filerepository.model.RepositoryFile#prePersist()
*/
@Override
......@@ -60,7 +60,6 @@ public class RepositoryDocument extends RepositoryFile implements DocumentMetada
/*
* (non-Javadoc)
*
* @see org.genesys.filerepository.metadata.DocumentMetadata#getLanguage()
*/
@Override
......@@ -79,7 +78,6 @@ public class RepositoryDocument extends RepositoryFile implements DocumentMetada
/*
* (non-Javadoc)
*
* @see org.genesys.filerepository.metadata.DocumentMetadata#getAbstract()
*/
@Override
......@@ -96,7 +94,7 @@ public class RepositoryDocument extends RepositoryFile implements DocumentMetada
this.abstrct = abstrct;
}
public RepositoryDocument apply(RepositoryDocument source) {
public RepositoryDocument apply(final RepositoryDocument source) {
super.apply(source);
this.abstrct = source.abstrct;
......
/*
* Copyright 2017 Global Crop Diversity Trust, www.croptrust.org
* Copyright 2017 Global Crop Diversity Trust
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
......@@ -215,7 +215,7 @@ public class RepositoryFile extends AuditedVersionedModelWithoutId implements En
/**
* Get the path of the file used by {@link BytesStorageService}
*
*
* @return
*/
@Transient
......@@ -229,7 +229,7 @@ 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
*/
@Transient
......@@ -630,12 +630,12 @@ public class RepositoryFile extends AuditedVersionedModelWithoutId implements En
/**
* @param size the size to set
*/
public final void setSize(int size) {
public final void setSize(final int size) {
this.size = size;
}
@Override
public RepositoryFile apply(RepositoryFile source) {
public RepositoryFile apply(final RepositoryFile source) {
this.active = source.active;
this.accessRights = source.accessRights;
this.bibliographicCitation = source.bibliographicCitation;
......@@ -663,7 +663,7 @@ public class RepositoryFile extends AuditedVersionedModelWithoutId implements En
@Override
public RepositoryFile copy() {
RepositoryFile copy = new RepositoryFile();
final RepositoryFile copy = new RepositoryFile();
copy.apply(this);
return copy;
}
......@@ -676,7 +676,7 @@ public class RepositoryFile extends AuditedVersionedModelWithoutId implements En
public int hashCode() {
final int prime = 31;
int result = super.hashCode();
result = prime * result + ((id == null) ? 0 : id.hashCode());
result = (prime * result) + ((id == null) ? 0 : id.hashCode());
return result;
}
......@@ -685,14 +685,14 @@ public class RepositoryFile extends AuditedVersionedModelWithoutId implements En
* @see java.lang.Object#equals(java.lang.Object)
*/
@Override
public boolean equals(Object obj) {
public boolean equals(final Object obj) {
if (this == obj)
return true;
if (!super.equals(obj))
return false;
if (getClass() != obj.getClass())
return false;
RepositoryFile other = (RepositoryFile) obj;
final RepositoryFile other = (RepositoryFile) obj;
if (id == null) {
if (other.id != null)
return false;
......
/*
* Copyright 2017 Global Crop Diversity Trust, www.croptrust.org
* Copyright 2017 Global Crop Diversity Trust
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
......@@ -27,7 +27,8 @@ import javax.persistence.Transient;
import org.genesys.filerepository.metadata.ImageMetadata;
/**
* An {@link RepositoryImage} is an graphics file in one of the supported image formats (PNG and JPG). It extends the {@link RepositoryFile} by including
* An {@link RepositoryImage} is an graphics file in one of the supported image
* formats (PNG and JPG). It extends the {@link RepositoryFile} by including
* image-specific metadata defined in {@link ImageMetadata}.
*
* @author mobreza
......@@ -102,7 +103,8 @@ public class RepositoryImage extends RepositoryFile implements ImageMetadata {
}
/**
* See {@link ImageMetadata#getOrientation()}: Landscape = width is greater than height.
* See {@link ImageMetadata#getOrientation()}: Landscape = width is greater than
* height.
*
* @return the orientation
*/
......@@ -127,7 +129,7 @@ public class RepositoryImage extends RepositoryFile implements ImageMetadata {
orientation = width > height ? Orientation.LANDSCAPE : Orientation.PORTRAIT;
}
public RepositoryImage apply(RepositoryImage source) {
public RepositoryImage apply(final RepositoryImage source) {
super.apply(source);
this.height = source.height;
......@@ -139,7 +141,7 @@ public class RepositoryImage extends RepositoryFile implements ImageMetadata {
/**
* Get the path where thumbnails of this image are stored.
*
*
* @return Thumbnails path
*/
@Transient
......
/*
* Copyright 2016 Global Crop Diversity Trust, www.croptrust.org
* Copyright 2017 Global Crop Diversity Trust
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
......
/*
* Copyright 2016 Global Crop Diversity Trust, www.croptrust.org
* Copyright 2017 Global Crop Diversity Trust
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
......
/*
* Copyright 2016 Global Crop Diversity Trust, www.croptrust.org
* Copyright 2017 Global Crop Diversity Trust
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
......@@ -51,7 +51,7 @@ public interface RepositoryFilePersistence extends RepositoryPersistence<Reposit
/**
* List repository files at specified paths
*
*
* @param path
* @return
*/
......@@ -70,7 +70,7 @@ public interface RepositoryFilePersistence extends RepositoryPersistence<Reposit
/**
* List distinct paths starting with the prefix
*
*
* @param prefix the prefix
* @return the list of paths
*/
......@@ -92,7 +92,7 @@ public interface RepositoryFilePersistence extends RepositoryPersistence<Reposit
/**
* Count files with matching path
*
*
* @param path Repository path
* @return Number of files at specified path
*/
......
/*
* Copyright 2016 Global Crop Diversity Trust, www.croptrust.org
* Copyright 2017 Global Crop Diversity Trust
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
......
/*
* Copyright 2016 Global Crop Diversity Trust, www.croptrust.org
* Copyright 2017 Global Crop Diversity Trust
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
......@@ -38,7 +38,8 @@ public interface BytesStorageService {
void upsert(String path, String filename, byte[] data) throws IOException;
/**
* Removes the file with specified filename from repository at the specified path
* Removes the file with specified filename from repository at the specified
* path
*
* @param path the path
* @param filename the filename
......
/*
* Copyright 2017 Global Crop Diversity Trust, www.croptrust.org
* Copyright 2017 Global Crop Diversity Trust
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
......@@ -36,12 +36,14 @@ public interface ImageGalleryService {
* Loads gallery with the specified path.
*
* @param path Image gallery path in the repository
* @return the ImageGallery or <code>null</code> if no gallery exists at the specified path.
* @return the ImageGallery or <code>null</code> if no gallery exists at the
* specified path.
*/
ImageGallery loadImageGallery(String path);
/**
* Create a gallery at the specified path if it does not exist. Path of the gallery must be unique in the repository.
* Create a gallery at the specified path if it does not exist. Path of the
* gallery must be unique in the repository.
*
* @param path Image gallery path in the repository.
* @param title Image gallery title in English.
......@@ -69,7 +71,8 @@ public interface ImageGalleryService {
ImageGallery updateImageGalery(ImageGallery imageGallery, String title, String description);
/**
* Reorder images in the gallery as specified. Images not listed are added to the end of the image list in no particular order.
* Reorder images in the gallery as specified. Images not listed are added to
* the end of the image list in no particular order.
*
* @param imageGallery the image gallery
* @return the image gallery
......@@ -77,7 +80,8 @@ public interface ImageGalleryService {
ImageGallery saveImageOrder(ImageGallery imageGallery);
/**
* Ensure that thumbnails of images in the gallery exist in the repository at the {@link ImageGallery#path}/_thumb/ <code>width</code>x
* Ensure that thumbnails of images in the gallery exist in the repository at
* the {@link ImageGallery#path}/_thumb/ <code>width</code>x
* <code>height</code>_<code>uuid</code>. <code>ext</code>.
*
* @param imageGallery The ImageGallery.
......
/*
* Copyright 2016 Global Crop Diversity Trust, www.croptrust.org
* Copyright 2017 Global Crop Diversity Trust
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
......@@ -45,7 +45,8 @@ public interface RepositoryService {
* @param metaData the meta data
* @return the repository file
* @throws InvalidRepositoryPathException the invalid repository path exception
* @throws InvalidRepositoryFileDataException the invalid repository file data exception
* @throws InvalidRepositoryFileDataException the invalid repository file data
* exception
* @throws IOException when things go wrong on bytes storage level
*/
RepositoryFile addFile(String repositoryPath, String originalFilename, String contentType, byte[] bytes, RepositoryFile metaData) throws InvalidRepositoryPathException,
......@@ -61,7 +62,8 @@ public interface RepositoryService {
* @param metaData the meta data
* @return the repository image
* @throws InvalidRepositoryPathException the invalid repository path exception
* @throws InvalidRepositoryFileDataException the invalid repository file data exception
* @throws InvalidRepositoryFileDataException the invalid repository file data
* exception
* @throws IOException when things go wrong on bytes storage level
*/
RepositoryImage addImage(String repositoryPath, String originalFilename, String contentType, byte[] bytes, RepositoryImage metaData) throws InvalidRepositoryPathException,
......@@ -72,13 +74,14 @@ public interface RepositoryService {
*
* @param fileUuid the file uuid
* @return the file
* @throws NoSuchRepositoryFileException when file is not available in the repository
* @throws NoSuchRepositoryFileException when file is not available in the
* repository
*/
RepositoryFile getFile(UUID fileUuid) throws NoSuchRepositoryFileException;
/**
* Get repository file by its path and filename
*
*
* @param path
* @param filename
* @return
......@@ -119,7 +122,8 @@ public interface RepositoryService {
* @param uuid UUID of the repository file
* @param fileData the file data
* @return the updated RepositoryFile
* @throws NoSuchRepositoryFileException when file is not available in the repository
* @throws NoSuchRepositoryFileException when file is not available in the
* repository
*/
<T extends RepositoryFile> T updateMetadata(UUID uuid, T fileData) throws NoSuchRepositoryFileException;
......@@ -136,7 +140,8 @@ public interface RepositoryService {
RepositoryFile updateBytes(RepositoryFile fileData, String contentType, byte[] bytes) throws NoSuchRepositoryFileException, IOException;
/**
* Load image to validate data and contentType, update image bytes and generate updated {@link ImageMetadata}.
* Load image to validate data and contentType, update image bytes and generate
* updated {@link ImageMetadata}.
*
* @param imageData the image data
* @param contentType the content type
......@@ -152,7 +157,8 @@ public interface RepositoryService {
*
* @param repositoryFile the repository file
* @return the deleted entity