Re: [xwiki-devs] [xwiki-notifications] r14969 - in platform/core/trunk: xwiki-bridge/src/main/java/org/xwiki/bridge xwiki-core/src/main/java/com/xpn/xwiki/doc xwiki-rendering/src/test/java/org/xwiki/rendering/internal
asiri (SVN) wrote:
Author: asiri Date: 2008-12-30 16:29:22 +0100 (Tue, 30 Dec 2008) New Revision: 14969
Modified: platform/core/trunk/xwiki-bridge/src/main/java/org/xwiki/bridge/DocumentAccessBridge.java platform/core/trunk/xwiki-core/src/main/java/com/xpn/xwiki/doc/DefaultDocumentAccessBridge.java platform/core/trunk/xwiki-rendering/src/test/java/org/xwiki/rendering/internal/MockDocumentAccessBridge.java Log: Added several proposed methods to DocumentAccessBridge.
+ public void setDocumentSyntaxId(String documentName, String syntaxId) throws Exception Missing edit comment. + xcontext.getWiki().saveDocument(doc, xcontext); + }
+ public void setAttachmentContent(String documentName, String AttachmentName, + byte[] attachmentData) throws Exception I think you're saving the document twice, since the first line also saves the document, so the manual save is not needed. + doc.saveAttachmentContent(attachment, xcontext); + xcontext.getWiki().saveDocument(doc, + String.format("Added attachment [%s].", AttachmentName), xcontext); + }
This should have a short description, too
+ /** + * @param documentName The name of the document. + * @param right Access right requested. + * @return True if the current user has the given access right, false otherwise. + */ + private boolean hasRight(String documentName, String right)
Modified: platform/core/trunk/xwiki-rendering/src/test/java/org/xwiki/rendering/internal/MockDocumentAccessBridge.java =================================================================== --- platform/core/trunk/xwiki-rendering/src/test/java/org/xwiki/rendering/internal/MockDocumentAccessBridge.java 2008-12-30 13:43:52 UTC (rev 14968) +++ platform/core/trunk/xwiki-rendering/src/test/java/org/xwiki/rendering/internal/MockDocumentAccessBridge.java 2008-12-30 15:29:22 UTC (rev 14969) @@ -116,14 +116,46 @@ { throw new RuntimeException("Not implemented"); } + + public void setAttachmentContent(String documentName, String AttachmentName, + byte[] attachmentData) throws Exception + { + throw new RuntimeException("Not implemented"); + }
+ public void setDocumentContent(String documentName, String content, String editComment, + boolean isMinorEdit) throws Exception + { + throw new RuntimeException("Not implemented"); + } + + public void setDocumentSyntaxId(String documentName, String syntaxId) throws Exception + { + throw new RuntimeException("Not implemented"); + } + public boolean isDocumentViewable(String documentName) { return true; } + + public boolean isDocumentEditable(String documentName) + { + return true; + }
public boolean hasProgrammingRights() { return true; } + + public String getCurrentUser() + { + throw new RuntimeException("Not implemented"); + } + + public String getDefaultEncoding() + { + throw new RuntimeException("Not implemented"); + } }
Although this is a mock used during test, you should still add javadoc for them: /** * {@inheritDoc} * * @see DocumentAccessBridge#getDefaultEncoding() */ I know that the other methods were not documented, but whenever you see something wrong, you should fix it, and not see it as an excuse for doing more bad things. -- Sergiu Dumitriu http://purl.org/net/sergiu/
Hi,
+ public void setDocumentSyntaxId(String documentName, String syntaxId) throws Exception Missing edit comment.
+ xcontext.getWiki().saveDocument(doc, xcontext); + }
Fixed.
+ public void setAttachmentContent(String documentName, String AttachmentName, + byte[] attachmentData) throws Exception I think you're saving the document twice, since the first line also saves the document, so the manual save is not needed. + doc.saveAttachmentContent(attachment, xcontext); + xcontext.getWiki().saveDocument(doc, + String.format("Added attachment [%s].", AttachmentName), xcontext); + }
Fixed. But with this change I don't see a way to add an edit comment when adding a new attachment. But I think this is ok since we are not changing the document content.
This should have a short description, too
+ /** + * @param documentName The name of the document. + * @param right Access right requested. + * @return True if the current user has the given access right, false otherwise. + */ + private boolean hasRight(String documentName, String right)
Fixed. Although this is a mock used during test, you should still add javadoc
for them:
/** * {@inheritDoc} * * @see DocumentAccessBridge#getDefaultEncoding() */
I know that the other methods were not documented, but whenever you see something wrong, you should fix it, and not see it as an excuse for doing more bad things.
Fixed :) Thanks. - Asiri
participants (2)
-
Asiri Rathnayake -
Sergiu Dumitriu