public static Attachment createAttachment( ObjectFactory objectFactory, URI baseUri, com.xpn.xwiki.api.Attachment xwikiAttachment, String xwikiRelativeUrl, String xwikiAbsoluteUrl, XWiki xwikiApi, Boolean withPrettyNames) { Attachment attachment = objectFactory.createAttachment(); fillAttachment( attachment, objectFactory, baseUri, xwikiAttachment, xwikiRelativeUrl, xwikiAbsoluteUrl, xwikiApi, withPrettyNames); Document doc = xwikiAttachment.getDocument(); String attachmentUri = uri( baseUri, AttachmentResource.class, doc.getWiki(), doc.getSpace(), doc.getName(), xwikiAttachment.getFilename()); Link attachmentLink = objectFactory.createLink(); attachmentLink.setHref(attachmentUri); attachmentLink.setRel(Relations.ATTACHMENT_DATA); attachment.getLinks().add(attachmentLink); return attachment; }