Class ImageFileService<E extends ImageFile,​D extends ImageFileDao<E>>


  • @Service("imageFileService")
    public class ImageFileService<E extends ImageFile,​D extends ImageFileDao<E>>
    extends FileService<E,​D>
    Service class for the ImageFile model.
    Author:
    Daniel Koch, Johannes Weskamm
    • Constructor Detail

      • ImageFileService

        public ImageFileService()
        Default constructor, which calls the type-constructor
      • ImageFileService

        protected ImageFileService​(Class<E> entityClass)
        Constructor that sets the concrete entity class for the service. Subclasses MUST call this constructor.
    • Method Detail

      • scaleImage

        public static byte[] scaleImage​(byte[] imageBytes,
                                        String outputFormat,
                                        Integer targetSize)
                                 throws Exception
        Scales 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 use Qualifier to define the correct dao here. Otherwise, spring can not decide which dao has to be autowired here as there are multiple candidates.
        Overrides:
        setDao in class FileService<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 Exception
        Description copied from class: FileService
        Method persists a given MultipartFile as a bytearray in the database
        Overrides:
        uploadFile in class FileService<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 Exception
        Method persists a given Image as a bytearray in the database
        Parameters:
        file -
        createThumbnail -
        thumbnailTargetSize -
        Throws:
        Exception