public synchronized Version[] getVersions() { try { return getAttachment_archive().getVersions(); } catch (Exception ex) { LOG.warn(String.format("Cannot retrieve versions of attachment [%s@%s]: %s", getFilename(), getDoc() .getFullName(), ex.getMessage())); return new Version[] {new Version(this.getVersion())}; } }
/** * @param archive the attachment archive to delete. * @param fileTools tools for getting the metadata and versions of the attachment and locks. * @param provider the file provider for gettign the files to delete. */ public AttachmentArchiveDeleteRunnable(final XWikiAttachmentArchive archive, final FilesystemStoreTools fileTools, final AttachmentFileProvider provider) { final List<File> toDelete = new ArrayList<>(); toDelete.add(provider.getAttachmentVersioningMetaFile()); final Version[] versions = archive.getVersions(); for (int i = 0; i < versions.length; i++) { toDelete.add(provider.getAttachmentVersionContentFile(versions[i].toString())); } for (File file : toDelete) { new FileDeleteTransactionRunnable(file, fileTools.getBackupFile(file), fileTools.getLockForFile(file)) .runIn(this); } } }
/** * @param archive the attachment archive to delete. * @param fileTools tools for getting the metadata and versions of the attachment and locks. * @param provider the file provider for gettign the files to delete. */ public AttachmentArchiveDeleteRunnable(final XWikiAttachmentArchive archive, final FilesystemStoreTools fileTools, final AttachmentFileProvider provider) { final List<File> toDelete = new ArrayList<File>(); toDelete.add(provider.getAttachmentVersioningMetaFile()); final Version[] versions = archive.getVersions(); for (int i = 0; i < versions.length; i++) { toDelete.add(provider.getAttachmentVersionContentFile(versions[i].toString())); } for (File file : toDelete) { new FileDeleteTransactionRunnable(file, fileTools.getBackupFile(file), fileTools.getLockForFile(file)).runIn(this); } } }
return; if (archive.getVersions().length == 0 && archive.getAttachment() != null) { archive.updateArchive(context); final Version[] versions = archive.getVersions(); final List<XWikiAttachment> attachmentVersions = new ArrayList<>(versions.length);
return; if (archive.getVersions().length == 0 && archive.getAttachment() != null) { archive.updateArchive(context); final Version[] versions = archive.getVersions(); final List<XWikiAttachment> attachmentVersions = new ArrayList<XWikiAttachment>(versions.length);