/** * {@inheritDoc} * * @see DocumentAccessBridge#getAttachmentURLs(org.xwiki.model.reference.DocumentReference , boolean) */ @Deprecated public List<String> getAttachmentURLs(DocumentReference documentReference, boolean isFullURL) throws Exception { List<String> urls = new ArrayList<String>(); for (AttachmentReference attachmentReference : getAttachmentReferences(documentReference)) { urls.add(getAttachmentURL(attachmentReference, isFullURL)); } return urls; }
/** * {@inheritDoc} * * @see DocumentAccessBridge#setCurrentUser(String) */ public void setCurrentUser(String userName) { getContext().setUser(userName); }
/** * Utility method for saving an {@link XWikiDocument}. This method takes care of setting authors and creators * appropriately. * * @param doc the {@link XWikiDocument} to be saved. * @param comment the edit comment. * @param isMinorEdit if the change in document is minor. * @throws Exception if an error occurs while saving the document. */ private void saveDocument(XWikiDocument doc, String comment, boolean isMinorEdit) throws Exception { doc.setAuthor(getCurrentUser()); if (doc.isNew()) { doc.setCreator(getCurrentUser()); } getContext().getWiki().saveDocument(doc, comment, isMinorEdit, getContext()); } }
/** * {@inheritDoc} * * @see DocumentAccessBridge#getDocumentContent(String) */ @Deprecated public String getDocumentContent(String documentReference) throws Exception { XWikiContext xcontext = getContext(); return getDocumentContent(documentReference, xcontext.getLanguage()); }
/** * {@inheritDoc} * * @see DocumentAccessBridge#setDocumentContent(String, String, String, boolean) */ @Deprecated public void setDocumentContent(String documentReference, String content, String editComment, boolean isMinorEdit) throws Exception { XWikiContext xcontext = getContext(); XWikiDocument doc = xcontext.getWiki().getDocument(documentReference, xcontext); doc.setContent(content); saveDocument(doc, editComment, isMinorEdit); }
/** * {@inheritDoc} * * @see org.xwiki.bridge.DocumentAccessBridge#isDocumentViewable(org.xwiki.model.reference.DocumentReference) */ public boolean isDocumentViewable(DocumentReference documentReference) { return hasRight(documentReference, "view"); }
return this.getDocumentURL(this.getContext().getDoc().getDocumentReference(), action, queryString, return this.getContext().getURLFactory().createExternalURL( documentReference.getLastSpaceReference().getName(), documentReference.getName(), anchor, documentReference.getWikiReference().getName(), this.getContext()).toString(); } else { return this.getContext().getWiki().getURL(documentReference, action, queryString, anchor, this.getContext());
/** * {@inheritDoc} * * @see DocumentAccessBridge#getAttachments(org.xwiki.bridge.DocumentName) */ @Deprecated public List<org.xwiki.bridge.AttachmentName> getAttachments(org.xwiki.bridge.DocumentName documentName) throws Exception { List<org.xwiki.bridge.AttachmentName> results = new ArrayList<org.xwiki.bridge.AttachmentName>(); DocumentReference documentReference; if (documentName == null) { documentReference = this.currentMixedDocumentReferenceResolver.resolve(getContext().getDoc().getFullName()); } else { documentReference = new DocumentReference(documentName.getWiki(), documentName.getSpace(), documentName.getPage()); } List<AttachmentReference> references = getAttachmentReferences(documentReference); for (AttachmentReference reference : references) { results.add(new org.xwiki.bridge.AttachmentName(new org.xwiki.bridge.DocumentName( reference.getDocumentReference().getWikiReference().getName(), reference.getDocumentReference().getLastSpaceReference().getName(), reference.getDocumentReference().getName()), reference.getName())); } return results; }
/** * {@inheritDoc} * * @see DocumentAccessBridge#getAttachmentURL(org.xwiki.model.reference.AttachmentReference , boolean) */ public String getAttachmentURL(AttachmentReference attachmentReference, boolean isFullURL) { return getAttachmentURL(attachmentReference, null, isFullURL); }
/** * {@inheritDoc} * * @see org.xwiki.bridge.DocumentAccessBridge#getDocumentURL(org.xwiki.model.reference.DocumentReference, * java.lang.String, java.lang.String, java.lang.String) */ public String getDocumentURL(DocumentReference documentReference, String action, String queryString, String anchor) { return getDocumentURL(documentReference, action, queryString, anchor, false); }
/** * {@inheritDoc} * * @see DocumentAccessBridge#getAttachmentURLs(org.xwiki.bridge.DocumentName, boolean) */ @Deprecated public List<String> getAttachmentURLs(org.xwiki.bridge.DocumentName documentName, boolean isFullURL) throws Exception { return getAttachmentURLs(new DocumentReference(documentName.getWiki(), documentName.getSpace(), documentName.getPage()), isFullURL); }
/** * {@inheritDoc} * * @see DocumentAccessBridge#getDocument(org.xwiki.model.reference.DocumentReference) */ @Deprecated public DocumentModelBridge getDocument(org.xwiki.bridge.DocumentName documentName) throws Exception { return getDocument(new DocumentReference(documentName.getWiki(), documentName.getSpace(), documentName.getPage())); }
/** * {@inheritDoc} * * @see DocumentAccessBridge#getAttachmentContent(org.xwiki.bridge.AttachmentName) */ @Deprecated public InputStream getAttachmentContent(org.xwiki.bridge.AttachmentName attachmentName) throws Exception { return getAttachmentContent(new AttachmentReference(attachmentName.getFileName(), new DocumentReference( attachmentName.getDocumentName().getWiki(), attachmentName.getDocumentName().getSpace(), attachmentName.getDocumentName().getPage()))); }
/** * {@inheritDoc} * * @see org.xwiki.bridge.DocumentAccessBridge#setDocumentContent(org.xwiki.model.reference.DocumentReference, * java.lang.String, java.lang.String, boolean) */ public void setDocumentContent(DocumentReference documentReference, String content, String editComment, boolean isMinorEdit) throws Exception { XWikiContext xcontext = getContext(); XWikiDocument doc = xcontext.getWiki().getDocument(documentReference, xcontext); doc.setContent(content); saveDocument(doc, editComment, isMinorEdit); }
/** * {@inheritDoc} * * @see DocumentAccessBridge#isDocumentEditable(org.xwiki.model.reference.DocumentReference) */ public boolean isDocumentEditable(DocumentReference documentReference) { return hasRight(documentReference, "edit"); }
/** * {@inheritDoc} * * @see DocumentAccessBridge#getAttachmentURL(org.xwiki.bridge.AttachmentName, boolean) */ @Deprecated public String getAttachmentURL(org.xwiki.bridge.AttachmentName attachmentName, boolean isFullURL) { return getAttachmentURL(new AttachmentReference(attachmentName.getFileName(), new DocumentReference( attachmentName.getDocumentName().getWiki(), attachmentName.getDocumentName().getWiki(), attachmentName.getDocumentName().getPage())), isFullURL); }
/** * {@inheritDoc} * * @see DocumentAccessBridge#popDocumentFromContext(Map) */ public void popDocumentFromContext(Map<String, Object> backupObjects) { XWikiDocument.restoreContext(backupObjects, getContext()); }
public void setDocumentParentReference(DocumentReference documentReference, DocumentReference parentReference) throws Exception { XWikiContext xcontext = getContext(); XWikiDocument doc = xcontext.getWiki().getDocument(documentReference, xcontext); DocumentReference oldParentReference = doc.getParentReference(); doc.setParentReference(parentReference); saveDocument(doc, String.format("Changed document syntax from [%s] to [%s].", oldParentReference, parentReference), true); }
/** * {@inheritDoc} * * @see DocumentAccessBridge#setAttachmentContent(String, String, byte[]) */ @Deprecated public void setAttachmentContent(String documentReference, String attachmentFilename, byte[] attachmentData) throws Exception { XWikiContext xcontext = getContext(); XWikiDocument doc = xcontext.getWiki().getDocument(documentReference, xcontext); XWikiAttachment attachment = doc.getAttachment(attachmentFilename); if (attachment == null) { attachment = new XWikiAttachment(); doc.getAttachmentList().add(attachment); doc.setComment("Add new attachment " + attachmentFilename); } else { doc.setComment("Update attachment " + attachmentFilename); } attachment.setContent(attachmentData); attachment.setFilename(attachmentFilename); attachment.setAuthor(getCurrentUser()); attachment.setDoc(doc); doc.setAuthor(getCurrentUser()); if (doc.isNew()) { doc.setCreator(getCurrentUser()); } doc.saveAttachmentContent(attachment, xcontext); }
/** * {@inheritDoc} * * @see org.xwiki.bridge.DocumentAccessBridge#isDocumentViewable(java.lang.String) */ @Deprecated public boolean isDocumentViewable(String documentReference) { return hasRight(documentReference, "view"); }