Package de.terrestris.shoguncore.service
Class ImageFileService<E extends ImageFile,D extends ImageFileDao<E>>
- java.lang.Object
-
- de.terrestris.shoguncore.service.AbstractDaoService<E,D>
-
- de.terrestris.shoguncore.service.AbstractCrudService<E,D>
-
- de.terrestris.shoguncore.service.PermissionAwareCrudService<E,D>
-
- de.terrestris.shoguncore.service.FileService<E,D>
-
- de.terrestris.shoguncore.service.ImageFileService<E,D>
-
@Service("imageFileService") public class ImageFileService<E extends ImageFile,D extends ImageFileDao<E>> extends FileService<E,D>Service class for theImageFilemodel.- Author:
- Daniel Koch, Johannes Weskamm
-
-
Field Summary
-
Fields inherited from class de.terrestris.shoguncore.service.PermissionAwareCrudService
permissionCollectionService
-
Fields inherited from class de.terrestris.shoguncore.service.AbstractDaoService
dao, logger
-
-
Constructor Summary
Constructors Modifier Constructor Description ImageFileService()Default constructor, which calls the type-constructorprotectedImageFileService(Class<E> entityClass)Constructor that sets the concrete entity class for the service.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description EsaveImage(org.springframework.web.multipart.MultipartFile file, boolean createThumbnail, Integer thumbnailTargetSize)Method persists a given Image as a bytearray in the databasestatic byte[]scaleImage(byte[] imageBytes, String outputFormat, Integer targetSize)Scales an image by the given dimensionsvoidsetDao(D dao)We have to useQualifierto define the correct dao here.EuploadFile(org.springframework.web.multipart.MultipartFile file)Method persists a given MultipartFile as a bytearray in the database-
Methods inherited from class de.terrestris.shoguncore.service.PermissionAwareCrudService
addAndSaveGroupPermissions, addAndSaveUserPermissions, findAllUserGroupPermissionsOfUserGroup, findAllUserPermissionsOfUser, getPermissionCollectionService, removeAndSaveGroupPermissions, removeAndSaveUserPermissions, setPermissionCollectionService
-
Methods inherited from class de.terrestris.shoguncore.service.AbstractCrudService
delete, findAll, findAllRestricted, findAllWhereFieldEquals, findAllWithCollectionContaining, findById, findBySimpleFilter, loadById, saveOrUpdate, updatePartialWithJsonNode
-
Methods inherited from class de.terrestris.shoguncore.service.AbstractDaoService
getDao, getEntityClass
-
-
-
-
Method Detail
-
scaleImage
public static byte[] scaleImage(byte[] imageBytes, String outputFormat, Integer targetSize) throws ExceptionScales an image by the given dimensions- Parameters:
outputFormat-targetSize- width/height in px (square)- Throws:
Exception
-
setDao
@Autowired @Qualifier("imageFileDao") public void setDao(D dao)We have to useQualifierto define the correct dao here. Otherwise, spring can not decide which dao has to be autowired here as there are multiple candidates.- Overrides:
setDaoin classFileService<E extends ImageFile,D extends ImageFileDao<E>>- Parameters:
dao- the dao to set
-
uploadFile
@PreAuthorize("isAuthenticated()") public E uploadFile(org.springframework.web.multipart.MultipartFile file) throws ExceptionDescription copied from class:FileServiceMethod persists a given MultipartFile as a bytearray in the database- Overrides:
uploadFilein classFileService<E extends ImageFile,D extends ImageFileDao<E>>- Parameters:
file-- Throws:
Exception
-
saveImage
@PreAuthorize("isAuthenticated()") public E saveImage(org.springframework.web.multipart.MultipartFile file, boolean createThumbnail, Integer thumbnailTargetSize) throws ExceptionMethod persists a given Image as a bytearray in the database- Parameters:
file-createThumbnail-thumbnailTargetSize-- Throws:
Exception
-
-