class RenameExistingFilter extends AbstractUploadFilter {

    @Override
    public void apply(final Path file, final Local local, final TransferStatus status,
                      final ProgressListener listener) throws BackgroundException {
        // Rename existing file before putting new file in place
        if(status.isExists()) {
            Path rename;
            do {
                final String proposal = MessageFormat.format(PreferencesFactory.get().getProperty("queue.upload.file.rename.format"),
                        FilenameUtils.getBaseName(file.getName()),
                        UserDateFormatterFactory.get().getMediumFormat(System.currentTimeMillis(), false).replace(Path.DELIMITER, '-').replace(':', '-'),
                        StringUtils.isNotBlank(file.getExtension()) ? String.format(".%s", file.getExtension()) : StringUtils.EMPTY);
                rename = new Path(file.getParent(), proposal, file.getType());
            }
            while(find.withCache(cache).find(rename));
            if(log.isInfoEnabled()) {
                log.info(String.format("Rename existing file %s to %s", file, rename));
            }
            move.move(file, rename, new TransferStatus().exists(false), new Delete.DisabledCallback(), new DisabledConnectionCallback());
            if(log.isDebugEnabled()) {
                log.debug(String.format("Clear exist flag for file %s", file));
            }
            status.setExists(false);
        }
        super.apply(file, local, status, listener);
    }

    public  RenameExistingFilter(final SymlinkResolver<Local> symlinkResolver, final Session<?> session);
    public  RenameExistingFilter(final SymlinkResolver<Local> symlinkResolver, final Session<?> session,
                                final UploadFilterOptions options);

}