/** * @return the document Id of the attachment */ public long getId() { return this.attachment.getId(); }
/** * This is used so that Hibernate will associate this content with the right attachment (metadata). * * @return the id of the attachment (metadata) which this content is associated with. */ public long getId() { return this.attachment.getId(); }
/** * @return the id of the attachment which this archive is associated with. */ public long getId() { return this.attachment.getId(); }
/** * Generate an ID which will be as collision resistant as possible. Because {@link * com.xpn.xwiki.doc.XWikiAttachment#getId()} returns an int cast to a long, this ID is guaranteed to be unique * unless the same attachment is deleted twice in the same second or again in a second which will come around in * another 136 years. * * @param attachment the attachment to get an ID number for. * @param deleteDate the Date the attachment was deleted. * @return an ID number for this deleted attachment. */ private static long generateId(final XWikiAttachment attachment, final Date deleteDate) { return (attachment.getId() << 32) ^ ((deleteDate.getTime() / 1000) & 0x00000000FFFFFFFFL); } }
/** * Constructor from List. Create a new instance of ListAttachmentArchive from a list of attachments. * * @param revisions a List of XWikiAttachment revisions to put in this archive. All revisions are the same * attachment and thus must have the same ID. */ public ListAttachmentArchive(final List<XWikiAttachment> revisions) { // Empty list: if (revisions.size() == 0) { return; } this.revisions.addAll(revisions); Collections.sort(this.revisions, XWikiAttachmentVersionComparitor.INSTANCE); // Sanity check, all revisions should have the same ID. long id = revisions.get(0).getId(); final String firstAttachName = revisions.get(0).getFilename(); for (XWikiAttachment attach : revisions) { if (attach.getId() != id) { throw new IllegalArgumentException("Attachment " + attach.getFilename() + " has a " + "different ID than the first attachment ( " + firstAttachName + " ) so they cannot all be " + "revisions of the same attachment."); } attach.setAttachment_archive(this); } // Set the attachment for this archive to the latest version. this.attachment = this.revisions.get(revisions.size() - 1); }
/** * Constructor from List. Create a new instance of ListAttachmentArchive from a list of attachments. * * @param revisions a List of XWikiAttachment revisions to put in this archive. All revisions are the same * attachment and thus must have the same ID. */ public ListAttachmentArchive(final List<XWikiAttachment> revisions) { // Empty list: if (revisions.isEmpty()) { return; } this.revisions.addAll(revisions); Collections.sort(this.revisions, XWikiAttachmentVersionComparator.INSTANCE); // Sanity check, all revisions should have the same ID. long id = revisions.get(0).getId(); final String firstAttachName = revisions.get(0).getFilename(); for (XWikiAttachment attach : revisions) { if (attach.getId() != id) { throw new IllegalArgumentException("Attachment " + attach.getFilename() + " has a " + "different ID than the first attachment ( " + firstAttachName + " ) so they cannot all be " + "revisions of the same attachment."); } attach.setAttachment_archive(this); } // Set the attachment for this archive to the latest version. this.attachment = this.revisions.get(revisions.size() - 1); }
String.format("%s;%s;%s;%s;%s;%s", image.getId(), image.getVersion(), width, height, keepAspectRatio, quality); byte[] data = this.imageCache.get(key);
protected Attachment newAttachment(Attachment att, XWikiAttachment xAtt, XWikiContext context) { att.setAttDate(xAtt.getDate().getTime()); att.setAuthor(xAtt.getAuthor()); att.setFilename(xAtt.getFilename()); att.setId(xAtt.getId()); att.setImage(xAtt.isImage(context)); att.setMimeType(xAtt.getMimeType(context)); att.setLongSize(xAtt.getLongSize()); att.setDownloadUrl(context.getWiki().getExternalAttachmentURL(xAtt.getDoc().getFullName(), xAtt.getFilename(), context)); return att; }
query.setLong("id", attachment.getId()); if (query.uniqueResult() == null) { session.save(attachment);