@Test public void testDeleteImage() throws Exception { imageService.deleteImage(imageName, Constants.PRODUCT_IMAGE_REPOSITORY_URL_PATTERN, "file:" + File.separator + File.separator + new File("target/imgrepo").getAbsolutePath() + File.separator); SeoImage seoImage = imageService.getSeoImage(Constants.PRODUCT_IMAGE_REPOSITORY_URL_PATTERN + imageName); assertNull("Found image with name " + imageName, seoImage); }
@Override public boolean deleteImage(final String imageFileName, final String storagePrefix, final String pathToRepository) { final SeoImage seoImage = getSeoImage(storagePrefix + imageFileName); if (seoImage != null) { getGenericDao().delete(seoImage); } final MediaFileNameStrategy strategy = getImageNameStrategy(storagePrefix); final String file = strategy.resolveFileName(imageFileName); final String code = strategy.resolveObjectCode(imageFileName); String pathInRepository = pathToRepository + strategy.resolveRelativeInternalFileNamePath(file, code, null); try { ioProvider.delete(pathInRepository, Collections.emptyMap()); return true; } catch (IOException e) { return false; } }
ImageServiceImpl extends BaseGenericServiceImpl<SeoImage> implements ImageService { @Override public boolean deleteImage(final String imageFileName, final String storagePrefix, final String pathToRepository) { final SeoImage seoImage = getSeoImage(storagePrefix + imageFileName); if (seoImage != null) { getGenericDao().delete(seoImage); } final MediaFileNameStrategy strategy = getImageNameStrategy(storagePrefix); final String file = strategy.resolveFileName(imageFileName); final String code = strategy.resolveObjectCode(imageFileName); String pathInRepository = pathToRepository + strategy.resolveRelativeInternalFileNamePath(file, code, null); try { ioProvider.delete(pathInRepository, Collections.emptyMap()); return true; } catch (IOException e) { return false; } } }
ImageServiceImpl extends BaseGenericServiceImpl<SeoImage> implements ImageService { @Override public boolean deleteImage(final String imageFileName, final String storagePrefix, final String pathToRepository) { final SeoImage seoImage = getSeoImage(storagePrefix + imageFileName); if (seoImage != null) { getGenericDao().delete(seoImage); } final MediaFileNameStrategy strategy = getImageNameStrategy(storagePrefix); final String file = strategy.resolveFileName(imageFileName); final String code = strategy.resolveObjectCode(imageFileName); String pathInRepository = pathToRepository + strategy.resolveRelativeInternalFileNamePath(file, code, null); try { ioProvider.delete(pathInRepository, Collections.emptyMap()); return true; } catch (IOException e) { return false; } } ImageServiceImpl(final GenericDAO<SeoImage, Long> seoImageDao,
                            final MediaFileNameStrategyResolver mediaFileNameStrategyResolver,
                            final String allowedSizes,
                            final int borderColorR,
                            final int borderColorG,
                            final int borderColorB,
                            final boolean cropToFit,
                            final int forceCropToFitOnSize,
                            final boolean replaceFilesModeOn,
                            final IOProvider ioProvider); }
ImageServiceImpl extends BaseGenericServiceImpl<SeoImage> implements ImageService { @Override public boolean deleteImage(final String imageFileName, final String storagePrefix, final String pathToRepository) { final SeoImage seoImage = getSeoImage(storagePrefix + imageFileName); if (seoImage != null) { getGenericDao().delete(seoImage); } final MediaFileNameStrategy strategy = getImageNameStrategy(storagePrefix); final String file = strategy.resolveFileName(imageFileName); final String code = strategy.resolveObjectCode(imageFileName); String pathInRepository = pathToRepository + strategy.resolveRelativeInternalFileNamePath(file, code, null); try { ioProvider.delete(pathInRepository, Collections.emptyMap()); return true; } catch (IOException e) { return false; } } ImageServiceImpl(final GenericDAO<SeoImage, Long> seoImageDao,
                            final MediaFileNameStrategyResolver mediaFileNameStrategyResolver,
                            final String allowedSizes,
                            final int borderColorR,
                            final int borderColorG,
                            final int borderColorB,
                            final boolean cropToFit,
                            final int forceCropToFitOnSize,
                            final boolean replaceFilesModeOn,
                            final IOProvider ioProvider); void setConfig(final Resource config); @Override byte[] resizeImage(final String filename,
                              final byte[] content,
                              final String width,
                              final String height); @Override byte[] resizeImage(final String filename,
                              final byte[] content,
                              final String width,
                              final String height,
                              final boolean cropToFit); @Override boolean isSizeAllowed(final String size); @Override boolean isSizeAllowed(final String width, final String height); @Override MediaFileNameStrategy getImageNameStrategy(final String url); @Override byte[] resizeImage(final String original,
                              final String resized,
                              final String width,
                              final String height); @Override byte[] resizeImage(final String original,
                              final String resized,
                              final String width,
                              final String height,
                              final boolean cropToFit); @Override boolean isImageInRepository(final String fullFileName,
                                       final String code,
                                       final String storagePrefix,
                                       final String pathToRepository); @Override String addImageToRepository(final String fullFileName,
                                       final String code,
                                       final byte[] imgBody,
                                       final String storagePrefix,
                                       final String pathToRepository); @Override byte[] imageToByteArray(final String fileName,
                                   final String code,
                                   final String storagePrefix,
                                   final String pathToRepository); @Override boolean deleteImage(final String imageFileName,
                               final String storagePrefix,
                               final String pathToRepository); @Override SeoImage getSeoImage(final String imageName); SystemService getSystemService(); }
ImageServiceImpl extends BaseGenericServiceImpl<SeoImage> implements ImageService { @Override public boolean deleteImage(final String imageFileName, final String storagePrefix, final String pathToRepository) { final SeoImage seoImage = getSeoImage(storagePrefix + imageFileName); if (seoImage != null) { getGenericDao().delete(seoImage); } final MediaFileNameStrategy strategy = getImageNameStrategy(storagePrefix); final String file = strategy.resolveFileName(imageFileName); final String code = strategy.resolveObjectCode(imageFileName); String pathInRepository = pathToRepository + strategy.resolveRelativeInternalFileNamePath(file, code, null); try { ioProvider.delete(pathInRepository, Collections.emptyMap()); return true; } catch (IOException e) { return false; } } ImageServiceImpl(final GenericDAO<SeoImage, Long> seoImageDao,
                            final MediaFileNameStrategyResolver mediaFileNameStrategyResolver,
                            final String allowedSizes,
                            final int borderColorR,
                            final int borderColorG,
                            final int borderColorB,
                            final boolean cropToFit,
                            final int forceCropToFitOnSize,
                            final boolean replaceFilesModeOn,
                            final IOProvider ioProvider); void setConfig(final Resource config); @Override byte[] resizeImage(final String filename,
                              final byte[] content,
                              final String width,
                              final String height); @Override byte[] resizeImage(final String filename,
                              final byte[] content,
                              final String width,
                              final String height,
                              final boolean cropToFit); @Override boolean isSizeAllowed(final String size); @Override boolean isSizeAllowed(final String width, final String height); @Override MediaFileNameStrategy getImageNameStrategy(final String url); @Override byte[] resizeImage(final String original,
                              final String resized,
                              final String width,
                              final String height); @Override byte[] resizeImage(final String original,
                              final String resized,
                              final String width,
                              final String height,
                              final boolean cropToFit); @Override boolean isImageInRepository(final String fullFileName,
                                       final String code,
                                       final String storagePrefix,
                                       final String pathToRepository); @Override String addImageToRepository(final String fullFileName,
                                       final String code,
                                       final byte[] imgBody,
                                       final String storagePrefix,
                                       final String pathToRepository); @Override byte[] imageToByteArray(final String fileName,
                                   final String code,
                                   final String storagePrefix,
                                   final String pathToRepository); @Override boolean deleteImage(final String imageFileName,
                               final String storagePrefix,
                               final String pathToRepository); @Override SeoImage getSeoImage(final String imageName); SystemService getSystemService();  }