Commit 638d905c authored by Matija Obreza's avatar Matija Obreza
Browse files

Source code formatted

parent 2ced252a
......@@ -26,10 +26,9 @@ public abstract class FileRepositoryException extends Exception {
public FileRepositoryException() {
}
public FileRepositoryException(String message) {
super(message);
}
}
......@@ -36,8 +36,8 @@ public interface BaseMetadata extends Serializable {
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 +51,8 @@ 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,8 +66,7 @@ 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
*/
......@@ -81,16 +80,15 @@ public interface BaseMetadata extends Serializable {
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
*/
......
......@@ -23,8 +23,7 @@ package org.genesys2.server.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
*/
......
......@@ -29,8 +29,8 @@ import javax.persistence.OrderColumn;
/**
* {@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
*/
......@@ -57,9 +57,7 @@ public class ImageGallery extends BaseEntity {
/** The images. */
@ManyToMany(cascade = {})
@JoinTable(name = "repositorygalleryimage",
joinColumns = @JoinColumn(name = "galleryId"),
inverseJoinColumns = @JoinColumn(name = "imageId"))
@JoinTable(name = "repositorygalleryimage", joinColumns = @JoinColumn(name = "galleryId"), inverseJoinColumns = @JoinColumn(name = "imageId"))
@OrderColumn(name = "position")
private List<RepositoryImage> images;
......
......@@ -26,8 +26,8 @@ import org.genesys2.server.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
*/
......
......@@ -127,15 +127,15 @@ public class RepositoryFile extends BaseEntity implements BaseMetadata {
@Column
@Temporal(TemporalType.TIMESTAMP)
private Date dateRetrieved;
/** Sha1sum hash of the bytes. */
/** Sha1sum hash of the bytes. */
// TODO Update to nullable = false in next release
@Column(length=40, nullable = true)
@Column(length = 40, nullable = true)
private String sha1Sum;
/** MD5 hash of the bytes. */
/** MD5 hash of the bytes. */
// TODO Update to nullable = false in next release
@Column(length=32, nullable = true)
@Column(length = 32, nullable = true)
private String md5Sum;
/**
......
......@@ -27,8 +27,8 @@ import org.genesys2.server.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 image-specific metadata defined in {@link 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 image-specific metadata
* defined in {@link ImageMetadata}.
*
* @author mobreza
*/
......
......@@ -68,8 +68,7 @@ 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,8 +76,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 <code>height</code>_<code>uuid</code>.<code>ext</code>.
* 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.
* @param width Maximum width of thumbnail image. Can be null.
......
......@@ -47,8 +47,8 @@ public interface RepositoryService {
* @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, InvalidRepositoryFileDataException, IOException;
RepositoryFile addFile(String repositoryPath, String originalFilename, String contentType, byte[] bytes, RepositoryFile metaData)
throws InvalidRepositoryPathException, InvalidRepositoryFileDataException, IOException;
/**
* Add a new image to the file repository.
......@@ -63,8 +63,8 @@ public interface RepositoryService {
* @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, InvalidRepositoryFileDataException, IOException;
RepositoryImage addImage(String repositoryPath, String originalFilename, String contentType, byte[] bytes, RepositoryImage metaData)
throws InvalidRepositoryPathException, InvalidRepositoryFileDataException, IOException;
/**
* Get repository file by its UUID.
......@@ -112,8 +112,7 @@ public interface RepositoryService {
* @throws NoSuchRepositoryFileException the no such repository file exception
* @throws IOException Signals that an I/O exception has occurred.
*/
RepositoryFile updateBytes(RepositoryFile fileData, String contentType, byte[] bytes)
throws NoSuchRepositoryFileException, IOException;
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}.
......@@ -125,8 +124,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 updateBytes(RepositoryImage imageData, String contentType, byte[] bytes) throws NoSuchRepositoryFileException, IOException;
/**
* Remove file and its data from repository.
......@@ -147,8 +145,7 @@ 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.
......
......@@ -58,11 +58,8 @@ public class ImageGalleryAspects {
* @return the object
* @throws Throwable the throwable
*/
@AfterReturning(
value = "execution(* org.genesys2.server.filerepository.persistence.RepositoryImagePersistence.save(*))",
returning = "repositoryImages")
public Object afterRepositoryImageSaveIterable(final JoinPoint joinPoint,
final Iterable<RepositoryImage> repositoryImages) throws Throwable {
@AfterReturning(value = "execution(* org.genesys2.server.filerepository.persistence.RepositoryImagePersistence.save(*))", returning = "repositoryImages")
public Object afterRepositoryImageSaveIterable(final JoinPoint joinPoint, final Iterable<RepositoryImage> repositoryImages) throws Throwable {
if (LOG.isDebugEnabled()) {
LOG.debug("Many images were saved: " + repositoryImages);
......@@ -83,11 +80,8 @@ public class ImageGalleryAspects {
* @return the object
* @throws Throwable the throwable
*/
@AfterReturning(
value = "execution(* org.genesys2.server.filerepository.persistence.RepositoryImagePersistence.save(*))",
returning = "repositoryImage")
public Object afterRepositoryImageSave(final JoinPoint joinPoint, final RepositoryImage repositoryImage)
throws Throwable {
@AfterReturning(value = "execution(* org.genesys2.server.filerepository.persistence.RepositoryImagePersistence.save(*))", returning = "repositoryImage")
public Object afterRepositoryImageSave(final JoinPoint joinPoint, final RepositoryImage repositoryImage) throws Throwable {
if (LOG.isTraceEnabled()) {
LOG.trace("1 image was saved: " + repositoryImage);
......@@ -109,12 +103,10 @@ public class ImageGalleryAspects {
* @throws Throwable the throwable
*/
@Around(value = "execution(* org.genesys2.server.filerepository.persistence.RepositoryImagePersistence.delete(*)) && args(repositoryImage)")
public Object aroundRepositoryImageDelete(final ProceedingJoinPoint joinPoint,
final RepositoryImage repositoryImage) throws Throwable {
public Object aroundRepositoryImageDelete(final ProceedingJoinPoint joinPoint, final RepositoryImage repositoryImage) throws Throwable {
if (LOG.isTraceEnabled() && repositoryImage != null) {
LOG.trace("1 image is being deleted path={} originalFilename={}", repositoryImage.getPath(),
repositoryImage.getOriginalFilename());
LOG.trace("1 image is being deleted path={} originalFilename={}", repositoryImage.getPath(), repositoryImage.getOriginalFilename());
}
removeImageFromGallery(repositoryImage);
......
......@@ -126,7 +126,7 @@ public class FilesystemStorageServiceImpl implements BytesStorageService {
// Delete empty dir
if (destinationDir.exists() && destinationDir.isDirectory()) {
String[] dirContents = destinationDir.list();
if (dirContents != null && dirContents.length == 0) {
if (LOG.isDebugEnabled()) {
......
......@@ -93,8 +93,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)
* @see org.genesys2.server.filerepository.service.ImageGalleryService#createImageGallery(java.lang.String, java.lang.String, java.lang.String)
*/
@Override
@Transactional
......@@ -109,8 +108,7 @@ 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);
......@@ -120,9 +118,7 @@ public class ImageGalleryServiceImpl implements ImageGalleryService {
/*
* (non-Javadoc)
*
* @see
* org.genesys2.server.filerepository.service.ImageGalleryService#removeGallery(org.genesys2.server.filerepository.
* model.ImageGallery)
* @see org.genesys2.server.filerepository.service.ImageGalleryService#removeGallery(org.genesys2.server.filerepository. model.ImageGallery)
*/
@Override
@Transactional
......@@ -164,13 +160,12 @@ 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)
* @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);
......@@ -183,9 +178,7 @@ public class ImageGalleryServiceImpl implements ImageGalleryService {
/*
* (non-Javadoc)
*
* @see
* org.genesys2.server.filerepository.service.ImageGalleryService#saveImageOrder(org.genesys2.server.filerepository.
* model.ImageGallery)
* @see org.genesys2.server.filerepository.service.ImageGalleryService#saveImageOrder(org.genesys2.server.filerepository. model.ImageGallery)
*/
@Override
@Transactional
......@@ -199,8 +192,8 @@ public class ImageGalleryServiceImpl implements ImageGalleryService {
}
/**
* For each image in the gallery, generate a PNG thumbnail at maximum width x maximum height as specified. Save
* bytes to {@link BytesStorageService} directly, not through {@link RepositoryService}.
* For each image in the gallery, generate a PNG thumbnail at maximum width x maximum height as specified. Save bytes to {@link BytesStorageService} directly, not through
* {@link RepositoryService}.
*
* Throws NotAnImageException if original bytes are not of an image,
*
......@@ -213,7 +206,7 @@ public class ImageGalleryServiceImpl implements ImageGalleryService {
public void ensureThumbnails(final ImageGallery imageGallery, final Integer width, final Integer height) {
final ImageGallery imageGallery2 = imageGalleryPersistence.findOne(imageGallery.getId());
if (CollectionUtils.isEmpty(imageGallery2.getImages())) {
LOG.debug("ImageGallery has no images, skipping thumbnail generation for path=" + imageGallery2.getPath());
return;
......@@ -242,22 +235,18 @@ public class ImageGalleryServiceImpl implements ImageGalleryService {
* @throws IOException Signals that an I/O exception has occurred.
* @throws InvalidRepositoryPathException if path is messed up
*/
private void ensureThumbnail(final String thumbPath, final Integer width, final Integer height,
final RepositoryImage repositoryImage) throws IOException, InvalidRepositoryPathException {
private void ensureThumbnail(final String thumbPath, final Integer width, final Integer height, final RepositoryImage repositoryImage) throws IOException, InvalidRepositoryPathException {
final String filename = getThumbnailFilename(width, height, repositoryImage.getUuid());
if (!bytesStorageService.exists(thumbPath, filename)) {
if (LOG.isDebugEnabled()) {
LOG.debug("Generating new thumbnail width={} height={} for image={}", width, height,
repositoryImage.getUuid());
LOG.debug("Generating new thumbnail width={} height={} for image={}", width, height, repositoryImage.getUuid());
}
final byte[] bytesPng = thumbnailGenerator.createThumbnail(width, height,
bytesStorageService.get(repositoryImage.getPath(), repositoryImage.getFilename()));
final byte[] bytesPng = thumbnailGenerator.createThumbnail(width, height, bytesStorageService.get(repositoryImage.getPath(), repositoryImage.getFilename()));
if (LOG.isDebugEnabled()) {
LOG.debug("Persisting new thumbnail width={} height={} for image={}", width, height,
repositoryImage.getUuid());
LOG.debug("Persisting new thumbnail width={} height={} for image={}", width, height, repositoryImage.getUuid());
}
bytesStorageService.upsert(thumbPath, filename, bytesPng);
......@@ -299,8 +288,7 @@ public class ImageGalleryServiceImpl implements ImageGalleryService {
/*
* (non-Javadoc)
*
* @see org.genesys2.server.filerepository.service.ImageGalleryService#listImageGalleries(java.lang.String,
* org.springframework.data.domain.Pageable)
* @see org.genesys2.server.filerepository.service.ImageGalleryService#listImageGalleries(java.lang.String, org.springframework.data.domain.Pageable)
*/
@Override
public Page<ImageGallery> listImageGalleries(final String prefix, final Pageable pageable) {
......
......@@ -67,12 +67,11 @@ public class RepositoryServiceImpl implements RepositoryService, InitializingBea
@Autowired
private BytesStorageService bytesStorageService;
@Override
public void afterPropertiesSet() throws Exception {
addMissingHashSums();
}
/**
* Just in case.
*/
......@@ -96,13 +95,12 @@ public class RepositoryServiceImpl implements RepositoryService, InitializingBea
/*
* (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)
* @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)
public RepositoryFile addFile(final String repositoryPath, final String originalFilename, final String contentType, final byte[] bytes, final RepositoryFile metaData)
throws InvalidRepositoryPathException, InvalidRepositoryFileDataException, IOException {
PathValidator.checkValidPath(repositoryPath);
......@@ -141,13 +139,12 @@ public class RepositoryServiceImpl implements RepositoryService, InitializingBea
/*
* (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)
* @see org.genesys2.server.filerepository.service.RepositoryService#addImage( java.lang.String, java.lang.String, java.lang.String, byte[],
* org.genesys2.server.filerepository.model.RepositoryImage)
*/
@Override
@Transactional
public RepositoryImage addImage(final String repositoryPath, final String originalFilename,
final String contentType, final byte[] bytes, final RepositoryImage metaData)
public RepositoryImage addImage(final String repositoryPath, final String originalFilename, final String contentType, final byte[] bytes, final RepositoryImage metaData)
throws InvalidRepositoryPathException, InvalidRepositoryFileDataException, IOException {
PathValidator.checkValidPath(repositoryPath);
......@@ -164,7 +161,7 @@ public class RepositoryServiceImpl implements RepositoryService, InitializingBea
// Calculate SHA-1 and MD5 sums
repositoryImage.setSha1Sum(DigestUtils.sha1Hex(bytes));
repositoryImage.setMd5Sum(DigestUtils.md5Hex(bytes));
repositoryImage.setPath(repositoryPath);
repositoryImage.setOriginalFilename(originalFilename);
repositoryImage.setContentType(contentType);
......@@ -225,12 +222,10 @@ public class RepositoryServiceImpl implements RepositoryService, InitializingBea
/*
* (non-Javadoc)
*
* @see org.genesys2.server.filerepository.service.RepositoryService#getFileBytes (java.lang.String,
* java.lang.String)
* @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 {
......@@ -258,8 +253,7 @@ public class RepositoryServiceImpl implements RepositoryService, InitializingBea
/*
* (non-Javadoc)
*
* @see org.genesys2.server.filerepository.service.RepositoryService#updateFile(
* org.genesys2.server.filerepository.model .RepositoryFile)
* @see org.genesys2.server.filerepository.service.RepositoryService#updateFile( org.genesys2.server.filerepository.model .RepositoryFile)
*/
@Override
@Transactional
......@@ -280,9 +274,7 @@ public class RepositoryServiceImpl implements RepositoryService, InitializingBea
/*
* (non-Javadoc)
*
* @see
* org.genesys2.server.filerepository.service.RepositoryService#updateMetadata(org.genesys2.server.filerepository.
* model.RepositoryImage)
* @see org.genesys2.server.filerepository.service.RepositoryService#updateMetadata(org.genesys2.server.filerepository. model.RepositoryImage)
*/
@Override
public RepositoryImage updateMetadata(RepositoryImage repositoryImage) throws NoSuchRepositoryFileException {
......@@ -297,20 +289,18 @@ public class RepositoryServiceImpl implements RepositoryService, InitializingBea
/*
* (non-Javadoc)
*
* @see org.genesys2.server.filerepository.service.RepositoryService#updateBytes(
* org.genesys2.server.filerepository.model .RepositoryFile, java.lang.String, byte[])
* @see org.genesys2.server.filerepository.service.RepositoryService#updateBytes( org.genesys2.server.filerepository.model .RepositoryFile, java.lang.String, byte[])
*/
@Override
@Transactional
public RepositoryFile updateBytes(final RepositoryFile repositoryFile, final String contentType, final byte[] bytes)
throws NoSuchRepositoryFileException, IOException {
public RepositoryFile updateBytes(final RepositoryFile repositoryFile, final String contentType, final byte[] bytes) throws NoSuchRepositoryFileException, IOException {
if (repositoryFile == null)
throw new NoSuchRepositoryFileException();
// Calculate SHA-1 and MD5 sums
repositoryFile.setSha1Sum(DigestUtils.sha1Hex(bytes));
repositoryFile.setMd5Sum(DigestUtils.md5Hex(bytes));
repositoryFile.setContentType(contentType);
bytesStorageService.upsert(repositoryFile.getPath(), repositoryFile.getFilename(), bytes);
......@@ -320,20 +310,18 @@ public class RepositoryServiceImpl implements RepositoryService, InitializingBea
/*
* (non-Javadoc)
*
* @see org.genesys2.server.filerepository.service.RepositoryService#updateBytes(
* org.genesys2.server.filerepository.model .RepositoryImage, java.lang.String, byte[])
* @see org.genesys2.server.filerepository.service.RepositoryService#updateBytes( org.genesys2.server.filerepository.model .RepositoryImage, java.lang.String, byte[])
*/
@Override
@Transactional
public RepositoryImage updateBytes(final RepositoryImage repositoryImage, final String contentType, final byte[] bytes)
throws NoSuchRepositoryFileException, IOException {
public RepositoryImage updateBytes(final RepositoryImage repositoryImage, final String contentType, final byte[] bytes) throws NoSuchRepositoryFileException, IOException {
if (repositoryImage == null)
throw new NoSuchRepositoryFileException();
// Calculate SHA-1 and MD5 sums
repositoryImage.setSha1Sum(DigestUtils.sha1Hex(bytes));
repositoryImage.setMd5Sum(DigestUtils.md5Hex(bytes));
repositoryImage.setContentType(contentType);
final InputStream in = new ByteArrayInputStream(bytes);
......@@ -352,13 +340,11 @@ public class RepositoryServiceImpl implements RepositoryService, InitializingBea
/*
* (non-Javadoc)
*
* @see org.genesys2.server.filerepository.service.RepositoryService#removeFile(
* org.genesys2.server.filerepository.model .RepositoryFile)
* @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();
......@@ -376,14 +362,12 @@ public class RepositoryServiceImpl implements RepositoryService, InitializingBea
/*
* (non-Javadoc)
*
* @see org.genesys2.server.filerepository.service.RepositoryService#moveFile(org
* .genesys2.server.filerepository.model .RepositoryFile, java.lang.String)
* @see org.genesys2.server.filerepository.service.RepositoryService#moveFile(org .genesys2.server.filerepository.model .RepositoryFile, java.lang.String)
*/
@Override
@Transactional
public RepositoryFile moveFile(final RepositoryFile repositoryFile, final String newPath)
throws NoSuchRepositoryFileException, InvalidRepositoryPathException {
public RepositoryFile moveFile(final RepositoryFile repositoryFile, final String newPath) throws NoSuchRepositoryFileException, InvalidRepositoryPathException {
PathValidator.checkValidPath(newPath);
if (repositoryFile == null)
......
......@@ -62,8 +62,7 @@ public class S3StorageServiceImpl implements BytesStorageService {
private final static Logger LOG = LoggerFactory.getLogger(S3StorageServiceImpl.class);
/** The Constant HEADER_DATE_FORMAT. */
private static final SimpleDateFormat HEADER_DATE_FORMAT = new SimpleDateFormat(
"EEE', 'dd' 'MMM' 'yyyy' 'HH:mm:ss' 'Z", Locale.US);
private static final SimpleDateFormat HEADER_DATE_FORMAT = new SimpleDateFormat("EEE', 'dd' 'MMM' 'yyyy' 'HH:mm:ss' 'Z", Locale.US);
/** The rest template. */
private final RestTemplate restTemplate = initializeRestTemplate();
......@@ -91,12 +90,10 @@ public class S3StorageServiceImpl implements BytesStorageService {
/*
* (non-Javadoc)
*
* @see org.genesys2.server.filerepository.service.BytesStorageService#upsert (java.lang.String, java.lang.String,
* byte[])
* @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 {
if (!PathValidator.isValidPath(path))
throw new IOException("Path is not valid");
......@@ -193,8 +190,7 @@ public class S3StorageServiceImpl implements BytesStorageService {
}
/**