From 6de53c790b4955e7b639a886db182598175a562c Mon Sep 17 00:00:00 2001 From: sasinda Date: Sun, 19 Aug 2012 12:15:13 +0530 Subject: [PATCH] added Unit Tests for Ral. --- .../data/fileStore/FileStoreManager.java | 2 +- .../data/fileStore/FileStoreManagerImpl.java | 2 +- .../xwiki/android/data/rdb/EntityManager.java | 2 +- .../xwiki/android/rest/ral/DocumentRao.java | 33 +- .../android/rest/ral/RESTfulManager.java | 20 +- .../android/rest/ral/XmlDocumentRao.java | 40 +- .../android/rest/ral/XmlRESTFulManager.java | 20 +- .../rest/ral/algo/DocRetreiveStrategy.java | 296 +++-- .../rest/ral/algo/DocUpdateStrategy.java | 12 +- .../rest/ral/algo/IDocRetreiveStrategy.java | 9 +- .../rest/ral/wrappers/DocumentWrapper.java | 25 +- .../rest/reference/DocumentReference.java | 35 +- .../rest/reference/EntityReference.java | 12 +- .../rest/reference/PropertyReference.java | 7 +- .../rest/reference/SpaceReference.java | 7 +- .../android/rest/reference/WikiReference.java | 8 +- .../transformation/DocumentBuilder_XML.java | 171 ++- .../transformation/XModelTranslator_XML.java | 36 +- .../xwiki/android/xmodel/blog/XBlogPost.java | 28 +- .../android/xmodel/entity/Attachment.java | 8 +- .../xwiki/android/xmodel/entity/Comment.java | 29 +- .../xwiki/android/xmodel/entity/Document.java | 259 +++- .../android/xmodel/entity/DocumentBase.java | 541 --------- .../xwiki/android/xmodel/entity/Resource.java | 43 - .../org/xwiki/android/xmodel/entity/Tag.java | 39 +- .../android/xmodel/xobjects/XComment.java | 20 +- .../android/xmodel/xobjects/XObject.java | 4 +- .../xmodel/xobjects/XSimpleObject.java | 15 +- .../xwiki/android/xmodel/xobjects/XTag.java | 2 +- .../xwiki/android/xmodel/xobjects/XUtils.java | 48 +- .../org/xwiki/android/rest/HttpConnector.java | 2 +- .../xwiki/android/rest/RestConnection.java | 8 - .../Upgrade Http Connector, RestConnection | 100 -- .../src/org/xwiki/android/rest/XWikiAPI.java | 660 ---------- .../android/rest/XWikiRestConnecion.java | 1074 ----------------- xwiki-android-test-core/project.properties | 3 +- .../xwiki/android/core/test/TestTemplate.java | 33 +- .../android/core/test/properties/Env.java | 40 - .../rest/ral/test/TestDocumentRaoCreate.java | 113 +- .../rest/ral/test/TestDocumentRaoDelete.java | 159 +-- .../ral/test/TestDocumentRaoRetreive.java | 228 ++-- .../rest/ral/test/TestDocumentRaoUpdate.java | 237 ++-- .../android/test/rest/env/TestConstants.java | 7 +- .../org/xwiki/android/resources/Comment.java | 2 +- .../src/org/xwiki/android/resources/Page.java | 2 +- .../xwiki/android/resources/PageSummary.java | 20 +- 46 files changed, 1281 insertions(+), 3180 deletions(-) delete mode 100644 xwiki-android-core/src/org/xwiki/android/xmodel/entity/DocumentBase.java delete mode 100644 xwiki-android-core/src/org/xwiki/android/xmodel/entity/Resource.java delete mode 100644 xwiki-android-rest/src/org/xwiki/android/rest/RestConnection.java delete mode 100644 xwiki-android-rest/src/org/xwiki/android/rest/Upgrade Http Connector, RestConnection delete mode 100644 xwiki-android-rest/src/org/xwiki/android/rest/XWikiAPI.java delete mode 100644 xwiki-android-rest/src/org/xwiki/android/rest/XWikiRestConnecion.java delete mode 100644 xwiki-android-test-core/src/org/xwiki/android/core/test/properties/Env.java diff --git a/xwiki-android-core/src/org/xwiki/android/data/fileStore/FileStoreManager.java b/xwiki-android-core/src/org/xwiki/android/data/fileStore/FileStoreManager.java index b44c528..1cb1e14 100644 --- a/xwiki-android-core/src/org/xwiki/android/data/fileStore/FileStoreManager.java +++ b/xwiki-android-core/src/org/xwiki/android/data/fileStore/FileStoreManager.java @@ -2,7 +2,7 @@ import java.io.File; -import org.xwiki.android.xmodel.entity.DocumentBase; +import org.xwiki.android.xmodel.entity.XWikiPage; public interface FileStoreManager { diff --git a/xwiki-android-core/src/org/xwiki/android/data/fileStore/FileStoreManagerImpl.java b/xwiki-android-core/src/org/xwiki/android/data/fileStore/FileStoreManagerImpl.java index 13f20f3..2ebd248 100644 --- a/xwiki-android-core/src/org/xwiki/android/data/fileStore/FileStoreManagerImpl.java +++ b/xwiki-android-core/src/org/xwiki/android/data/fileStore/FileStoreManagerImpl.java @@ -3,7 +3,7 @@ import java.io.File; import org.xwiki.android.context.XWikiApplicationContext; -import org.xwiki.android.xmodel.entity.DocumentBase; +import org.xwiki.android.xmodel.entity.XWikiPage; import android.content.Context; diff --git a/xwiki-android-core/src/org/xwiki/android/data/rdb/EntityManager.java b/xwiki-android-core/src/org/xwiki/android/data/rdb/EntityManager.java index b19b293..de7dc9e 100644 --- a/xwiki-android-core/src/org/xwiki/android/data/rdb/EntityManager.java +++ b/xwiki-android-core/src/org/xwiki/android/data/rdb/EntityManager.java @@ -13,7 +13,7 @@ import org.xwiki.android.entity.SyncOutEntity; import org.xwiki.android.entity.User; import org.xwiki.android.rest.reference.DocumentReference; -import org.xwiki.android.xmodel.entity.DocumentBase; +import org.xwiki.android.xmodel.entity.XWikiPage; import com.j256.ormlite.android.apptools.OrmLiteSqliteOpenHelper; import com.j256.ormlite.support.ConnectionSource; diff --git a/xwiki-android-core/src/org/xwiki/android/rest/ral/DocumentRao.java b/xwiki-android-core/src/org/xwiki/android/rest/ral/DocumentRao.java index 049fcde..bfdc867 100644 --- a/xwiki-android-core/src/org/xwiki/android/rest/ral/DocumentRao.java +++ b/xwiki-android-core/src/org/xwiki/android/rest/ral/DocumentRao.java @@ -7,18 +7,7 @@ public interface DocumentRao extends Rao { - //parts of a doc. - int PAGE = 1; - /** - * all Objects except comment and tag objects. - */ - int OBJECTS = 2; - int COMMENTS = 4; - int TAGS = 8; - int ATTACHMENTS = 16; - int COMMENT_OBJECTS=32; - int TAG_OBJECT=64; - int ALL = 2147483647; + /** * semantics: @@ -57,23 +46,9 @@ public interface DocumentRao extends Rao */ Document retreive(DocumentReference dref) throws RestConnectionException, RaoException; - // TODO: SPECIFY default semantics ;-) - /** - * - * @param dref ex: flags=OBJECTS+TAGS. Loads a Document object with XObjects and tags only. - * @param flags - * @return - */ - Document retreive(DocumentReference dref, int flags); - /** - * - * @param dref - * @param flags - * @param objTypeArgs - * ex: Blog.BlogPostClass:0:2 blog post objects from index 0 to 2. i.e 3 objs if available. - * @return - */ - Document retreive(DocumentReference dref, int flags, String... objTypeArgs); + Document retreive(DocumentReference dref, FetchConfig lazyConfig) throws RestConnectionException, RaoException; + + Document retreive(Document doc, FetchConfig lazyConfig); void delete(DocumentReference dRef) throws RestConnectionException, RaoException; } diff --git a/xwiki-android-core/src/org/xwiki/android/rest/ral/RESTfulManager.java b/xwiki-android-core/src/org/xwiki/android/rest/ral/RESTfulManager.java index c35372f..c7f1424 100644 --- a/xwiki-android-core/src/org/xwiki/android/rest/ral/RESTfulManager.java +++ b/xwiki-android-core/src/org/xwiki/android/rest/ral/RESTfulManager.java @@ -1,23 +1,19 @@ package org.xwiki.android.rest.ral; -import java.util.Properties; - -import org.xwiki.android.resources.Space; -import org.xwiki.android.resources.Wiki; -import org.xwiki.android.rest.RestConnection; -import org.xwiki.android.rest.XWikiAPI; -import org.xwiki.android.xmodel.entity.Document; +import org.xwiki.android.rest.XWikiRestConnector; +import org.xwiki.android.rest.rpc.RestClient; public interface RESTfulManager -{ +{ DocumentRao newDocumentRao(); SpaceRao newSpaceRao(); WikiRao newWikiRao(); + + RestClient getRestClient(); - RestConnection getConnection(); - - - + @Deprecated + XWikiRestConnector getRestConnector(); + } diff --git a/xwiki-android-core/src/org/xwiki/android/rest/ral/XmlDocumentRao.java b/xwiki-android-core/src/org/xwiki/android/rest/ral/XmlDocumentRao.java index 17bcbd3..49fea0d 100644 --- a/xwiki-android-core/src/org/xwiki/android/rest/ral/XmlDocumentRao.java +++ b/xwiki-android-core/src/org/xwiki/android/rest/ral/XmlDocumentRao.java @@ -20,13 +20,13 @@ import org.xwiki.android.resources.Tags; import org.xwiki.android.rest.RestConnectionException; import org.xwiki.android.rest.RestException; -import org.xwiki.android.rest.XWikiRestConnecion; -import org.xwiki.android.rest.XWikiAPI; +import org.xwiki.android.rest.XWikiRestConnector; import org.xwiki.android.rest.ral.algo.DocRetreiveStrategy; import org.xwiki.android.rest.ral.algo.DocUpdateStrategy; import org.xwiki.android.rest.ral.algo.IDocRetreiveStrategy; import org.xwiki.android.rest.ral.algo.IDocUpdateStragegy; import org.xwiki.android.rest.reference.DocumentReference; +import org.xwiki.android.rest.rpc.XWikiAPI; import org.xwiki.android.rest.transformation.DocLaunchPadForXML; import org.xwiki.android.rest.transformation.DocumentDismantler_XML; import org.xwiki.android.xmodel.entity.Attachment; @@ -57,7 +57,7 @@ class XmlDocumentRao implements DocumentRao public XmlDocumentRao(String serverUrl, String username, String password) { - api = new XWikiRestConnecion(serverUrl, username, password); + api = new XWikiRestConnector(serverUrl, username, password); retStr = new DocRetreiveStrategy(username, password, serverUrl); updStr = new DocUpdateStrategy(serverUrl, username, password); // consider IoC to app context @@ -200,11 +200,13 @@ public int compare(Object object1, Object object2) int start = used; int end = Math.min(avail, used + needed); for (int j = used; j < end; j++) { - Comment cnw=newCmnts.get(j); + Comment cnw=newCmnts.get(j); + int tmpId=cnw.getId(); + cnw.setId(++svrCmntId); api.addPageComment(wikiName, spaceName, pageName, cnw); - svrCmntId++; + for(Comment c:newCmnts){ - if(c.getReplyTo()==cnw.getId()){ + if(c.getReplyTo()!=null && c.getReplyTo()==tmpId){ c.setReplyTo(svrCmntId); } } @@ -223,10 +225,11 @@ public int compare(Object object1, Object object2) if(used @DatabaseField protected String pageName; + + protected String pageVersion; + + protected String language; public DocumentReference() { @@ -77,10 +81,35 @@ public void setPageName(String pageName) this.pageName = pageName; } - @Override - public String getURL() + public String getVersion() { - return getAuthority() + "/xwiki/xmlrpc/wikis/" + wikiName + "/spaces" + spaceName + "/pages" + pageName; + return pageVersion; } + public void setVersion(String version) + { + this.pageVersion = version; + } + + public String getLanguage() + { + return language; + } + /** + * refers to a translation of a Document. + * When retrieving the document will have a XWikiPage in the translatedPages set. + * Also mind that the Documents direct content, version, ... will be null. + * The XWikiPage in translatedPages will have them filled. + * @param language + */ + public void setLanguage(String language) + { + this.language = language; + } + + + + + + } diff --git a/xwiki-android-core/src/org/xwiki/android/rest/reference/EntityReference.java b/xwiki-android-core/src/org/xwiki/android/rest/reference/EntityReference.java index 330fc07..5e80a32 100644 --- a/xwiki-android-core/src/org/xwiki/android/rest/reference/EntityReference.java +++ b/xwiki-android-core/src/org/xwiki/android/rest/reference/EntityReference.java @@ -18,6 +18,9 @@ public abstract class EntityReference implements Serializable // do not mark this class as @DatabaseTable, table inheritance is not yet supported in ORMLite. // make inheriting class mark @DatabaseTable + + // !***! These are to identify multiple Xwiki servers that may have identically named but different documents. + /** * http:// scheme. host section sample:- http://username:password@host:8080/directory/file?querryparam #fragment */ @@ -47,15 +50,6 @@ public String getAuthority() return authInfo.getUserName() + ":" + authInfo.getPassword() + "@" + host + ":" + port; } - public abstract String getURL(); - - // special setters - - public void setFromURL() throws MalformedURLException - { - // TODO: implement - } - public String getHost() { return host; diff --git a/xwiki-android-core/src/org/xwiki/android/rest/reference/PropertyReference.java b/xwiki-android-core/src/org/xwiki/android/rest/reference/PropertyReference.java index 455a3a6..89cb27e 100644 --- a/xwiki-android-core/src/org/xwiki/android/rest/reference/PropertyReference.java +++ b/xwiki-android-core/src/org/xwiki/android/rest/reference/PropertyReference.java @@ -3,11 +3,6 @@ public class PropertyReference extends EntityReference { - @Override - public String getURL() - { - // TODO Auto-generated method stub - return null; - } + } diff --git a/xwiki-android-core/src/org/xwiki/android/rest/reference/SpaceReference.java b/xwiki-android-core/src/org/xwiki/android/rest/reference/SpaceReference.java index 83b02dd..1b396eb 100644 --- a/xwiki-android-core/src/org/xwiki/android/rest/reference/SpaceReference.java +++ b/xwiki-android-core/src/org/xwiki/android/rest/reference/SpaceReference.java @@ -26,10 +26,5 @@ public void setSpace(String space) this.space = space; } - @Override - public String getURL() - { - // TODO Auto-generated method stub - return null; - } + } diff --git a/xwiki-android-core/src/org/xwiki/android/rest/reference/WikiReference.java b/xwiki-android-core/src/org/xwiki/android/rest/reference/WikiReference.java index be91011..923a497 100644 --- a/xwiki-android-core/src/org/xwiki/android/rest/reference/WikiReference.java +++ b/xwiki-android-core/src/org/xwiki/android/rest/reference/WikiReference.java @@ -14,10 +14,6 @@ public void setWiki(String wiki) this.wiki = wiki; } - @Override - public String getURL() - { - // TODO Auto-generated method stub - return null; - } + + } diff --git a/xwiki-android-core/src/org/xwiki/android/rest/transformation/DocumentBuilder_XML.java b/xwiki-android-core/src/org/xwiki/android/rest/transformation/DocumentBuilder_XML.java index b41d37b..4007fa9 100644 --- a/xwiki-android-core/src/org/xwiki/android/rest/transformation/DocumentBuilder_XML.java +++ b/xwiki-android-core/src/org/xwiki/android/rest/transformation/DocumentBuilder_XML.java @@ -22,6 +22,7 @@ import org.xwiki.android.rest.ral.wrappers.XSimpleObjectWrapper_RAL; import org.xwiki.android.rest.reference.Link; import org.xwiki.android.xmodel.entity.Document; +import org.xwiki.android.xmodel.entity.XWikiPage; import org.xwiki.android.xmodel.xobjects.XProperty; import org.xwiki.android.xmodel.xobjects.XSimpleObject; import org.xwiki.android.xmodel.xobjects.XUtils; @@ -30,8 +31,8 @@ public class DocumentBuilder_XML implements DocumentBuilder { - private final String TAG=this.getClass().getSimpleName(); - + private final String TAG = this.getClass().getSimpleName(); + Document d; XObjectFactory xofac; XPropertyFactory xpfac; @@ -42,23 +43,42 @@ public DocumentBuilder_XML(Page page) xofac = new XObjectFactory(); xpfac = new XPropertyFactory(); } + + public DocumentBuilder_XML(Document doc) + { + d = doc; + xofac = new XObjectFactory(); + xpfac = new XPropertyFactory(); + } + /** * Create document without page data. Build it wrapped with a DocumentWrapper. + * * @param wikiName * @param spaceName * @param pageName */ - public DocumentBuilder_XML(String wikiName, String spaceName, String pageName){ - d=new Document(wikiName, spaceName, pageName); + public DocumentBuilder_XML(String wikiName, String spaceName, String pageName) + { + d = new Document(wikiName, spaceName, pageName); } - private DocumentBuilder initWithPage(Page p) + /** + * start off with a new document. The earlier build will be lost. + * + * @param p + * @return + */ + public DocumentBuilder initWithPage(Page p) { - d = new Document(p.wiki, p.space, p.name); + return withPage(p); + } - List linksRes = p.links; - if(linksRes!=null){ + public DocumentBuilder withPage(Page p) + { + List linksRes = p.links; + if (linksRes != null) { List links = new ArrayList(); for (org.xwiki.android.resources.Link lres : linksRes) { Link l = new Link(); @@ -67,9 +87,9 @@ private DocumentBuilder initWithPage(Page p) links.add(l); } d.setLinks(links); - } - - d.setRemoteId(p.id); + } + + d.setId(p.id); d.setFullName(p.fullName); d.setWikiName(p.wiki); d.setSpaceName(p.space); @@ -105,7 +125,63 @@ private DocumentBuilder initWithPage(Page p) return this; } - /* (non-Javadoc) + public DocumentBuilder withTranslatedPage(Page trns) + { + XWikiPage page = new XWikiPage(null, null, null) + { + }; + List linksRes = trns.links; + if (linksRes != null) { + List links = new ArrayList(); + for (org.xwiki.android.resources.Link lres : linksRes) { + Link l = new Link(); + l.setHref(lres.href); + l.setRelType(lres.getRel()); + links.add(l); + } + page.setLinks(links); + } + + page.setId(trns.id); + page.setFullName(trns.fullName); + page.setWikiName(trns.wiki); + page.setSpaceName(trns.space); + page.setPageName(trns.name); + page.setTitle(trns.title); + page.setParentFullName(trns.parent); + page.setParentId(trns.parentId); + page.setXwikiRelativeUrl(trns.xwikiRelativeUrl); + page.setXwikiAbsoluteUrl(trns.xwikiAbsoluteUrl); + + Translations trsRes = trns.getTranslations(); + if (!trsRes.getTranslations().isEmpty()) { + List ts = new ArrayList(); + for (Translation tres : trsRes.translations) { + String t = tres.getLanguage(); + ts.add(t); + } + page.setTranslations(ts); + page.setDefalutTranslation(trsRes.getDefault()); + } + + page.setSyntax(trns.syntax); + page.setLanguage(trns.language); + page.setVersion(trns.version); + page.setMajorVersion(trns.majorVersion); + page.setMinorVersion(trns.minorVersion); + page.setCreated(XUtils.toDate(trns.created)); + page.setCreator(trns.creator); + page.setModified(XUtils.toDate(trns.modified)); + page.setModifier(trns.modifier); + page.setContent(trns.content); + + page.setEdited(false); + d.setTranslationPage(page); + return this; + } + + /* + * (non-Javadoc) * @see org.xwiki.android.xmlrpc.transformation.DocumentBuilder#withObject(org.xwiki.android.resources.Object) */ @Override @@ -114,9 +190,9 @@ public DocumentBuilder withObject(Object res) XSimpleObject xo = xofac.newXSimpleObject(res.className); // object's links not supported yet.For performance enhancements. - String xokey=res.getClassName()+"/"+res.getNumber(); - Log.d(TAG, "creating xobject for "+xokey); - + // String xokey=res.getClassName()+"/"+res.getNumber(); + // Log.d(TAG, "creating xobject for "+xokey); + xo.setId(res.id); xo.setGuid(res.guid); xo.setPageid(res.pageId); @@ -137,16 +213,19 @@ public DocumentBuilder withObject(Object res) // xp.setType(pres.getType());//implicit for the XProperty obj. xp.setName(pres.name); xp.setValueFromString(pres.getValue()); - xo.setProperty(key,xp); - Log.d(TAG, "added xproperty "+key); + xo.setProperty(key, xp); + Log.d(TAG, "added xproperty " + key); } xo.setEdited(false); - d.setObject(xokey, xo); + d.setObject(xo); return this; } - /* (non-Javadoc) - * @see org.xwiki.android.xmlrpc.transformation.DocumentBuilder#withObjectSummary(org.xwiki.android.resources.ObjectSummary) + /* + * (non-Javadoc) + * @see + * org.xwiki.android.xmlrpc.transformation.DocumentBuilder#withObjectSummary(org.xwiki.android.resources.ObjectSummary + * ) */ @Override public DocumentBuilder withObjectSummary(ObjectSummary res) @@ -164,13 +243,15 @@ public DocumentBuilder withObjectSummary(ObjectSummary res) xo.setNumber(res.number); xo.setHeadline(res.headline); XSimpleObjectWrapper_RAL xowrap = new XSimpleObjectWrapper_RAL(xo); + xo.setEdited(false); - d.setObject(res.className + "/" + res.number, xowrap); + d.setObject(xowrap); return this; } - /* (non-Javadoc) + /* + * (non-Javadoc) * @see org.xwiki.android.xmlrpc.transformation.DocumentBuilder#withComments(org.xwiki.android.resources.Comments) */ @Override @@ -182,25 +263,34 @@ public DocumentBuilder withComments(Comments cmnts) return this; } - /* (non-Javadoc) + /* + * (non-Javadoc) * @see org.xwiki.android.xmlrpc.transformation.DocumentBuilder#withComment(org.xwiki.android.resources.Comment) */ @Override public DocumentBuilder withComment(Comment cmntRes) { org.xwiki.android.xmodel.entity.Comment c = new org.xwiki.android.xmodel.entity.Comment(); - c.setId(cmntRes.id); + + c.setId(-1); + c.setId(cmntRes.id);// if u send a comment resource without seting id it will always have id =0; Though + // entity.comment has def val -1 it will be overriden c.setAuthor(cmntRes.author); c.setDate(XUtils.toDate(cmntRes.date)); c.setText(cmntRes.text); - c.setReplyTo(cmntRes.replyTo); + if (cmntRes.replyTo != null) { + c.setReplyTo(cmntRes.replyTo); + } + c.setEdited(false); - d.addComment(c); + d.setComment(c); + // TODO: keep link if needed. c.addLink(new Link...cmntRes.getLinks().get(0) ...); return this; } - /* (non-Javadoc) + /* + * (non-Javadoc) * @see org.xwiki.android.xmlrpc.transformation.DocumentBuilder#withTags(org.xwiki.android.resources.Tags) */ @Override @@ -208,25 +298,30 @@ public DocumentBuilder withTags(Tags tags) { for (Tag tr : tags.getTags()) { org.xwiki.android.xmodel.entity.Tag t = new org.xwiki.android.xmodel.entity.Tag(tr.name); + t.setEdited(false); d.addTag(t); } return this; } - /* (non-Javadoc) - * @see org.xwiki.android.xmlrpc.transformation.DocumentBuilder#withAttachments(org.xwiki.android.resources.Attachments) + /* + * (non-Javadoc) + * @see + * org.xwiki.android.xmlrpc.transformation.DocumentBuilder#withAttachments(org.xwiki.android.resources.Attachments) */ @Override public DocumentBuilder withAttachments(Attachments attachments) { - for(Attachment ares:attachments.getAttachments()){ + for (Attachment ares : attachments.getAttachments()) { withAttachment(ares); } return this; } - /* (non-Javadoc) - * @see org.xwiki.android.xmlrpc.transformation.DocumentBuilder#withAttachment(org.xwiki.android.resources.Attachment) + /* + * (non-Javadoc) + * @see + * org.xwiki.android.xmlrpc.transformation.DocumentBuilder#withAttachment(org.xwiki.android.resources.Attachment) */ @Override public DocumentBuilder withAttachment(Attachment attachment) @@ -241,9 +336,9 @@ public DocumentBuilder withAttachment(Attachment attachment) a.setMimeType(attachment.mimeType); a.setAuthor(attachment.author); a.setDate(XUtils.toDate(attachment.date)); - - URL absUrl=null; - URL relUrl=null; + + URL absUrl = null; + URL relUrl = null; try { absUrl = new URL(attachment.xwikiAbsoluteUrl); relUrl = new URL(attachment.xwikiRelativeUrl); @@ -253,9 +348,10 @@ public DocumentBuilder withAttachment(Attachment attachment) } a.setXwikiAbsoluteUrl(absUrl);// can convert to URL to make android independant. a.setXwikiRelativeUrl(relUrl); + a.setEdited(false); a.setNew(false); - d.addAttachment(a); + d.setAttachment(a); return this; } @@ -366,7 +462,8 @@ public DocumentBuilder withAttachment(Attachment attachment) // return this; // } // - /* (non-Javadoc) + /* + * (non-Javadoc) * @see org.xwiki.android.xmlrpc.transformation.DocumentBuilder#build() */ @Override diff --git a/xwiki-android-core/src/org/xwiki/android/rest/transformation/XModelTranslator_XML.java b/xwiki-android-core/src/org/xwiki/android/rest/transformation/XModelTranslator_XML.java index c4d0dd8..7143e99 100644 --- a/xwiki-android-core/src/org/xwiki/android/rest/transformation/XModelTranslator_XML.java +++ b/xwiki-android-core/src/org/xwiki/android/rest/transformation/XModelTranslator_XML.java @@ -21,17 +21,18 @@ import org.xwiki.android.resources.Translations; import org.xwiki.android.xmodel.entity.Document; +import org.xwiki.android.xmodel.entity.XWikiPage; import org.xwiki.android.xmodel.xobjects.XComment; import org.xwiki.android.xmodel.xobjects.XProperty; import org.xwiki.android.xmodel.xobjects.XSimpleObject; public class XModelTranslator_XML { - public Page toPage(Document doc) + public Page toPage(XWikiPage doc) { Page page = new Page(); - page.id = doc.getRemoteId(); + page.id = doc.getId(); page.fullName = doc.getFullName(); page.wiki = doc.getWikiName(); page.space = doc.getSpaceName(); @@ -73,8 +74,8 @@ public Page toPage(Document doc) return page; } - - public Object toObject(XSimpleObject xso) + + public Object toObject(XSimpleObject xso) { Object obj = new Object(); @@ -120,23 +121,22 @@ public Object toObject(XSimpleObject xso) } public Object toObject(org.xwiki.android.xmodel.entity.Comment c){ - XComment xc=new XComment(); + XComment xc=new XComment(); xc.setNumber((c.getId())); - xc.setAuthor(c.getAuthor()); - xc.setDate(c.getDate()); + if(c.getAuthor()!=null){ + xc.setAuthor(c.getAuthor()); + } + if(c.getDate()!=null){ + xc.setDate(c.getDate()); + } xc.setComment(c.getText()); - xc.setReplyto(c.getReplyTo()); + if(c.getReplyTo()!=-1){ + xc.setReplyto(c.getReplyTo()); + } return toObject(xc); } - public Object toObject(Comment c){ - XComment xc=new XComment(); - xc.setAuthor(c.getAuthor()); - xc.setComment(c.getText()); - //xc.setDate(c.getDate()); - //TODO - return toObject(xc); - } + public Comment toComment(org.xwiki.android.xmodel.entity.Comment c) { @@ -148,7 +148,9 @@ public Comment toComment(org.xwiki.android.xmodel.entity.Comment c) } cres.highlight = c.getHighlight(); cres.text = c.getText(); - cres.replyTo = c.getReplyTo(); + if(!(c.getReplyTo()==-1)){ + cres.replyTo =c.getReplyTo(); + } return cres; } diff --git a/xwiki-android-core/src/org/xwiki/android/xmodel/blog/XBlogPost.java b/xwiki-android-core/src/org/xwiki/android/xmodel/blog/XBlogPost.java index 0837d90..113dab6 100644 --- a/xwiki-android-core/src/org/xwiki/android/xmodel/blog/XBlogPost.java +++ b/xwiki-android-core/src/org/xwiki/android/xmodel/blog/XBlogPost.java @@ -39,7 +39,7 @@ public void setCategory(String category) XDBTreeListProperty prop = (XDBTreeListProperty) fields.get("category"); if (prop == null) { prop = new XDBTreeListProperty(); - fields.put("category", prop); + setProperty("category", prop); } prop.getValue().clear(); prop.getValue().add(category); @@ -59,7 +59,7 @@ public void setContent(String content) XTextAreaProperty prop = (XTextAreaProperty) fields.get("content"); if (prop == null) { prop = new XTextAreaProperty(); - fields.put("content", prop); + setProperty("content", prop); } prop.setValue(content); } @@ -78,7 +78,7 @@ public void setExtract(String extract) XTextAreaProperty prop = (XTextAreaProperty) fields.get("extract"); if (prop == null) { prop = new XTextAreaProperty(); - fields.put("extract", prop); + setProperty("extract", prop); } prop.setValue(extract); } @@ -101,7 +101,7 @@ public void setHidden(boolean hidden) XBooleanProperty prop = (XBooleanProperty) fields.get("hidden"); if (prop == null) { prop = new XBooleanProperty(); - fields.put("hidden", prop); + setProperty("hidden", prop); } prop.setValue(hidden); } @@ -120,7 +120,7 @@ public void setPublishDate(Date publishDate) XDateProperty prop = (XDateProperty) fields.get("publishDate"); if (prop == null) { prop = new XDateProperty(); - fields.put("publishDate", prop); + setProperty("publishDate", prop); } prop.setValue(publishDate); } @@ -143,7 +143,7 @@ public void setPublished(boolean published) XBooleanProperty prop = (XBooleanProperty) fields.get("published"); if (prop == null) { prop = new XBooleanProperty(); - fields.put("published", prop); + setProperty("published", prop); } prop.setValue(published); } @@ -162,7 +162,7 @@ public void setTitle(String title) XStringProperty prop = (XStringProperty) fields.get("title"); if (prop == null) { prop = new XStringProperty(); - fields.put("title", prop); + setProperty("title", prop); } prop.setValue(title); } @@ -174,7 +174,7 @@ public XDBTreeListProperty getPCategory() public void setpCategory(XDBTreeListProperty category) { - fields.put("category", category); + setProperty("category", category); } public XTextAreaProperty getpContent() @@ -184,7 +184,7 @@ public XTextAreaProperty getpContent() public void setpContent(XTextAreaProperty content) { - fields.put("content", content); + setProperty("content", content); } public XTextAreaProperty getpExtract() @@ -194,7 +194,7 @@ public XTextAreaProperty getpExtract() public void setpExtract(XTextAreaProperty extract) { - fields.put("extract", extract); + setProperty("extract", extract); } public XBooleanProperty getpHidden() @@ -204,7 +204,7 @@ public XBooleanProperty getpHidden() public void setpHidden(XBooleanProperty hidden) { - fields.put("hidden", hidden); + setProperty("hidden", hidden); } public XDateProperty getpPublishDate() @@ -214,7 +214,7 @@ public XDateProperty getpPublishDate() public void setpPublishDate(XDateProperty publishDate) { - fields.put("publishDate", publishDate); + setProperty("publishDate", publishDate); } public XBooleanProperty getpPublished() @@ -224,7 +224,7 @@ public XBooleanProperty getpPublished() public void setpPublished(XBooleanProperty published) { - fields.put("published", published); + setProperty("published", published); } public XStringProperty getpTitle() @@ -234,7 +234,7 @@ public XStringProperty getpTitle() public void setpTitle(XStringProperty title) { - fields.put("title", title); + setProperty("title", title); } } diff --git a/xwiki-android-core/src/org/xwiki/android/xmodel/entity/Attachment.java b/xwiki-android-core/src/org/xwiki/android/xmodel/entity/Attachment.java index bffcf78..fcc6156 100644 --- a/xwiki-android-core/src/org/xwiki/android/xmodel/entity/Attachment.java +++ b/xwiki-android-core/src/org/xwiki/android/xmodel/entity/Attachment.java @@ -5,7 +5,7 @@ import java.net.URL; -public class Attachment extends Resource +public class Attachment extends XWikiResource { // remote private String id; @@ -163,5 +163,11 @@ public boolean equals(Object o) return false; return ((Attachment) o).getName().equals(getName()); } + + @Override + public String toString() + { + return "@: "+ name +" file: "+ (file!=null? file.getAbsolutePath() : "nil") ; + } } diff --git a/xwiki-android-core/src/org/xwiki/android/xmodel/entity/Comment.java b/xwiki-android-core/src/org/xwiki/android/xmodel/entity/Comment.java index f7d5d34..e175b71 100644 --- a/xwiki-android-core/src/org/xwiki/android/xmodel/entity/Comment.java +++ b/xwiki-android-core/src/org/xwiki/android/xmodel/entity/Comment.java @@ -7,9 +7,9 @@ import org.xwiki.android.rest.reference.Link; import org.xwiki.android.xmodel.xobjects.XComment; -public class Comment extends Resource +public class Comment extends XWikiResource { - List links; + int id = -1; // -1 to mean null String author; Date date; @@ -74,27 +74,12 @@ public void setReplies(List replies) { this.replies = replies; } + - public List getLinks() - { - return links; - } - - public void addLink(Link link) - { - links.add(link); - } - - public void removeLink(int index) - { - links.remove(index); - } - - public void clearLinks() - { - links.clear(); - } - + // + //getter setteres + // + public int getId() { return id; diff --git a/xwiki-android-core/src/org/xwiki/android/xmodel/entity/Document.java b/xwiki-android-core/src/org/xwiki/android/xmodel/entity/Document.java index 65fd5ae..30f8573 100644 --- a/xwiki-android-core/src/org/xwiki/android/xmodel/entity/Document.java +++ b/xwiki-android-core/src/org/xwiki/android/xmodel/entity/Document.java @@ -1,11 +1,13 @@ package org.xwiki.android.xmodel.entity; import java.util.ArrayList; +import java.util.Collection; import java.util.HashMap; import java.util.HashSet; import java.util.Hashtable; import java.util.List; import java.util.Map; +import java.util.Map.Entry; import java.util.Set; import org.xwiki.android.resources.Attachments; @@ -21,11 +23,11 @@ * Objects are shallow objects that can have only XProperties for * property fields. */ -public class Document extends DocumentBase +public class Document extends XWikiPage { // things in a retreived document. - private DocumentBase parent; + private XWikiPage parent; private List children; @@ -38,6 +40,11 @@ public class Document extends DocumentBase // -->key is: mypic private List tags; // search by key not needed + private Map translationPages; //key : fr, en, si ... + + private List history; + + // resources that get newly added. // no keys. These are to be posted to server.Server will define the keys @@ -47,6 +54,7 @@ public class Document extends DocumentBase private List newComments; private List newTags; // just a ref to tags. We always have to send the // whole set in Rest. + private List newTranslationPages; // resources to update @@ -57,6 +65,7 @@ public class Document extends DocumentBase // mypic // space.png private List editedComments; + private List editedTranslationPages; // resources to delete private List deletedObjects; // value= of the deleted obj. @@ -64,6 +73,7 @@ public class Document extends DocumentBase private List deletedAttachments; private List deletedCommetns; private List deletedTags; + private List deletedTranslationPages; public Document(String wikiName, String spaceName, String pageName) { @@ -87,6 +97,12 @@ public Document(String wikiName, String spaceName, String pageName) tags = new ArrayList(); newTags = new ArrayList(); deletedTags = new ArrayList(); + + translationPages=null;// will be init when setting + newTranslationPages=null; + editedTranslationPages=null; + deletedTranslationPages=null; + } /** @@ -109,6 +125,7 @@ public XSimpleObject getObject(String key) XSimpleObject obj = objects.get(key); if (obj != null) { obj.setEdited(true); + obj.setNew(false); } return obj; } @@ -159,7 +176,9 @@ public void setObject(String key, XSimpleObject object) } /** - * + * When creating the doc on the server side this object will be added with best try to achieve the same obj number at server side. + * In a update operation the corresponding object at the server will be updated. + * If you does not want this set operation to affect the server when either updating or crating make object.setEdited(false). * @param object * @return key to refer this obj. */ @@ -216,18 +235,27 @@ public void deleteObject(String key) public Comment getComment(int id) { - return comments.get(id); + Comment c=comments.get(id); + if(c!=null){ + c.setEdited(true); + c.setNew(false); + } + return c; } /** - * + * Add a cmnt. No cmnt id needed for the cmnt. A new negative valued id will be temporary assigned. * @param cmnt * @return id of the new comment. */ public int addComment(Comment cmnt) { if (!newComments.contains(cmnt) && !comments.containsKey(cmnt.getId())) { - newComments.add(cmnt); + if(cmnt.isNew()){ + if(!newComments.contains(cmnt)){ + newComments.add(cmnt); + } + } int id = -newComments.size() - 10; comments.put(id, cmnt); cmnt.setId(id); @@ -239,7 +267,7 @@ public int addComment(Comment cmnt) } /** - * + * Add a cmnt. No cmnt id needed for the cmnt. * @param cmnt * @param cascade * if true adds all the reply comments as well to the document. @@ -271,10 +299,12 @@ public void setComment(int id, Comment cmnt) "comment id should be gt or eq to 0, \n If you are seting a comment that was added with add method no need to set again"); } cmnt.setId(id); - comments.put(id, cmnt); - if (!editedComments.contains(cmnt)) { - editedComments.add(cmnt); - } + comments.put(id, cmnt); + if(cmnt.isEdited()){ + if (!editedComments.contains(cmnt)) { + editedComments.add(cmnt); + } + } if (cmnt.getDocument() != null) { if (this != cmnt.getDocument()) throw new IllegalStateException("comment is already owned by another doc"); @@ -285,6 +315,12 @@ public void setComment(int id, Comment cmnt) } + /** + * set a comment with id. + * In create operations, it will be tried to achieve the same comment id in server. + * In updates the comment will be updated. + * @param cmnt + */ public void setComment(Comment cmnt) { int id = cmnt.getId(); @@ -293,9 +329,11 @@ public void setComment(Comment cmnt) "comment id should be gt or eq to 0, \n If you are seting a comment that was added with add method no need to set again"); } comments.put(id, cmnt); - if (!editedComments.contains(cmnt)) { - editedComments.add(cmnt); - } + if(cmnt.isEdited()){ + if (!editedComments.contains(cmnt)) { + editedComments.add(cmnt); + } + } if (cmnt.getDocument() != null) { if (this != cmnt.getDocument()) throw new IllegalStateException("comment is already owned by another doc"); @@ -348,7 +386,10 @@ public void clearTags() public Attachment getAttachment(String name) { Attachment a = attatchments.get(name); - a.setEdited(true); + if(a!=null){ + a.setEdited(true); + a.setNew(false); + } return attatchments.get(name); } @@ -360,6 +401,23 @@ public String addAttachment(Attachment a) attatchments.put(a.getName(), a); return a.getName(); } + + public void setAttachment(Attachment a) + { + if (a.getName() == null) { + throw new IllegalArgumentException("attachment name should be set"); + } + + if (a.isEdited() == true) { + int i = editedAttachments.indexOf(a); + if (i > -1) { + editedAttachments.add(i, a); + } else { + editedAttachments.add(a); + } + } + attatchments.put(a.getName(), a); + } public void setAttachment(String name, Attachment a) { @@ -373,9 +431,9 @@ public void setAttachment(String name, Attachment a) editedAttachments.add(i, a); } else { editedAttachments.add(a); - } - attatchments.put(name, a); + } } + attatchments.put(name, a); } @@ -392,7 +450,10 @@ public boolean deleteAttachment(String name) { Attachment a = attatchments.remove(name); if (!deletedAttachments.contains(name)) { - deletedAttachments.add(a.getName()); + deletedAttachments.add(a.getName()); + editedAttachments.remove(a); + newAttachments.remove(a); + } if (a == null) { Log.w(this.getClass().getSimpleName(), "marking an unknown attachment to be deleted"); @@ -403,12 +464,141 @@ public boolean deleteAttachment(String name) } + public XWikiPage getTranslationPage(String lang){ + XWikiPage p=translationPages.get(lang); + if(p!=null){ + p.setEdited(true); + p.setNew(false); + } + return p; + } + /** + * adds a translation page to the doc. + * When doc is created on server the translation pages are added + * In a update operation if translation page already exists it will be updated in normal non strict updates. + * setting page.isNew(false) will ignore page under above operations. + * @param page + * @return + */ + public String addTranslationPage(XWikiPage page){ + //verification + if(page.getLanguage()==null){ + throw new IllegalArgumentException("please set language for the translated XWikiPage."); + } + String lang=page.getLanguage(); + + if(translationPages==null){ + init_DataStructuresForTranslations(); + } + + if(page.isNew()){ + boolean alreadyAdded=false; + for(int i=0;i(2); + newTranslationPages=new ArrayList(2); + editedTranslationPages=new ArrayList(2); + deletedTranslationPages=new ArrayList(2); + } + + public List getHistory() + { + return history; + } + + /** + * This is set by rest when fetching/retrieving. + * @param history + */ + public void setHistory(List history){ + this.history=history; + } + public Map getAllObjects() { return objects; } - public DocumentBase getParentDocument() + public XWikiPage getParentDocument() { return parent; } @@ -509,7 +699,7 @@ public List listTagDeletions() return deletedTags; } - public void setParent(DocumentBase parent) + public void setParent(XWikiPage parent) { if (parentFullName == null) { parentFullName = parent.fullName; @@ -524,6 +714,35 @@ public void setChildren(List children) { this.children = children; } + + public String toString(){ + String s=""; + s+= "wiki: "+wikiName+"space: "+spaceName+" name: "+name +"\n"; + s+= " Objects new ["+newObjects.size()+"] , edited ["+editedObjects.size()+"] deleted ["+deletedObjects.size()+"]\n ------------------------------------ \n"; + Set keySet = objects.keySet(); + for(String key:keySet){ + s+= key +"\n" ; + } + s+=" Comments ---> ids: "; + Set keySet2 = comments.keySet(); + for(Integer key:keySet2){ + s+= key +", " ; + } + + s+= "\n tags --->"; + for(Tag t:tags){ + s+=t+", "; + } + + s+= "\n attachments \n------------------\n"; + + Collection values = attatchments.values(); + for(Attachment a :values ){ + s+=a+", "; + } + + return s; + } } diff --git a/xwiki-android-core/src/org/xwiki/android/xmodel/entity/DocumentBase.java b/xwiki-android-core/src/org/xwiki/android/xmodel/entity/DocumentBase.java deleted file mode 100644 index 2c0bcee..0000000 --- a/xwiki-android-core/src/org/xwiki/android/xmodel/entity/DocumentBase.java +++ /dev/null @@ -1,541 +0,0 @@ -package org.xwiki.android.xmodel.entity; - -import java.util.Date; -import java.util.List; -import org.xwiki.android.rest.reference.DocumentReference; -import org.xwiki.android.rest.reference.Link; - -/** - * Contains the properties of a Page +Additional methods for Document. - * - * @author xwiki dev: not saved to DB. Only the DocumentReference is saved. - */ - -public abstract class DocumentBase extends Resource -{ - - // Resource fields - // - protected List links; - - protected String remoteId;// id field in the resource representation. Mobile apps normally use ReSTful URL to - // identify a resource.Not this. - - protected String fullName; - - protected String wikiName;// wiki in page element - - protected String spaceName;// space in page element - - protected String name; // name in page element (same) - - protected String title; - - protected String parentFullName;// parent in resoruce repr. - - protected String parentId; - - protected String xwikiRelativeUrl; - - protected String xwikiAbsoluteUrl; - - protected List translations; - - protected String defalutTranslation; - - protected String syntax; - - protected String language; - - protected String version; - - protected int majorVersion; - - protected int minorVersion; - - protected Date created; // Date created. From date string in page. - - protected String creator; // user string - - protected Date modified; // Date string - - protected String modifier; // user string - - protected String content; - - // other fields - protected DocumentReference docRef; - - - - public DocumentBase(String wikiName, String spaceName, String pageName) - { - docRef = new DocumentReference(wikiName, spaceName, pageName); - this.name = pageName; - this.wikiName = wikiName; - this.spaceName = spaceName; - } - - /** - * @return - */ - public DocumentReference getDocumentReference() - { - return docRef; - } - - /** - * @param - */ - public void setDocumentReference(DocumentReference docRef) - { - this.docRef = docRef; - } - - - - // /** - // * valid for only Documents retreived from server. - // * @return - // */ - // public boolean isCachedCopy(){ - // return offlineMode; - // } - - - - // resource value getter setters - // ----------------------------- - - public List getLinks() - { - return links; - } - - public void setLinks(List links) - { - this.links = links; - } - - - /** - * Gets the value of the id property. - * - * @return possible object is {@link String } - */ - public String getRemoteId() - { - return remoteId; - } - - - - /** - * Sets the value of the id property. - * - * @param value allowed object is {@link String } - */ - public void setRemoteId(String value) - { - this.remoteId = value; - } - - /** - * Gets the value of the fullName property. * - * - * @return possible object is {@link String } - */ - public String getFullName() - { - return fullName; - } - - /** - * Sets the value of the fullName property. * - * - * @param value allowed object is {@link String } - */ - public void setFullName(String value) - { - this.fullName = value; - } - - /** - * Gets the value of the wiki property. - * - * @return possible object is {@link String } - */ - public String getWikiName() - { - return wikiName; - } - - /** - * Sets the value of the wiki property. - * - * @param value allowed object is {@link String } - */ - public void setWikiName(String value) - { - this.wikiName = value; - } - - /** - * Gets the value of the space property. - * - * @return possible object is {@link String } - */ - public String getSpaceName() - { - return spaceName; - } - - /** - * Sets the value of the space property. - * - * @param value allowed object is {@link String } - */ - public void setSpaceName(String value) - { - this.spaceName = value; - } - - // TODO:Consider refactor rename back to getName() ? confuse with name,fullName ? - /** - * get Page Name. - * @return the value of the name property in the Rest model "Page" element.. - */ - public String getPageName() - { - return name; - } - - /** - * Sets the value of the name property. - * - * @param value allowed object is {@link String } - */ - public void setPageName(String name) - { - this.name = name; - } - - /** - * Gets the value of the title property. - * - * @return possible object is {@link String } - */ - public String getTitle() - { - return title; - } - - /** - * Sets the value of the title property. - * - * @param value allowed object is {@link String } - */ - public void setTitle(String value) - { - this.title = value; - } - - /** - * Gets the value of the parent property. - * - * @return possible object is {@link String } - */ - public String getParentFullName() - { - return parentFullName; - } - - /** - * Sets the value of the parent property. - * - * @param value allowed object is {@link String } - */ - public void setParentFullName(String parent) - { - this.parentFullName = parent; - } - - /** - * Gets the value of the parentId property. - * - * @return possible object is {@link String } - */ - public String getParentId() - { - return parentId; - } - - /** - * Sets the value of the parentId property. - * - * @param value allowed object is {@link String } - */ - public void setParentId(String value) - { - this.parentId = value; - } - - /** - * Gets the value of the xwikiRelativeUrl property. - * - * @return possible object is {@link String } - */ - public String getXwikiRelativeUrl() - { - return xwikiRelativeUrl; - } - - /** - * Sets the value of the xwikiRelativeUrl property. - * - * @param value allowed object is {@link String } - */ - public void setXwikiRelativeUrl(String value) - { - this.xwikiRelativeUrl = value; - } - - /** - * Gets the value of the xwikiAbsoluteUrl property. - * - * @return possible object is {@link String } - */ - public String getXwikiAbsoluteUrl() - { - return xwikiAbsoluteUrl; - } - - /** - * Sets the value of the xwikiAbsoluteUrl property. - * - * @param value allowed object is {@link String } - */ - public void setXwikiAbsoluteUrl(String value) - { - this.xwikiAbsoluteUrl = value; - } - - /** - * Gets the value of the translations property. - * - * @return possible object is {@link Translations } - */ - public List getTranslations() - { - return translations; - } - - /** - * Sets the value of the translations property. - * - * @param value allowed object is {@link Translations } - */ - public void setTranslations(List translations) - { - this.translations = translations; - } - - public String getDefalutTranslation() - { - return defalutTranslation; - } - - public void setDefalutTranslation(String defalutTranslation) - { - this.defalutTranslation = defalutTranslation; - } - - /** - * Gets the value of the syntax property. - * - * @return possible object is {@link String } - */ - public String getSyntax() - { - return syntax; - } - - /** - * Sets the value of the syntax property. - * - * @param value allowed object is {@link String } - */ - public void setSyntax(String value) - { - this.syntax = value; - } - - public String getLanguage() - { - return language; - } - - /** - * Sets the value of the language property. - * - * @param value allowed object is {@link String } - */ - public void setLanguage(String value) - { - this.language = value; - - } - - /** - * Gets the value of the version property. - * - * @return possible object is {@link String } - */ - public String getVersion() - { - return version; - } - - /** - * Sets the value of the version property. - * - * @param value allowed object is {@link String } - */ - public void setVersion(String value) - { - this.version = value; - } - - /** - * Gets the value of the majorVersion property. - */ - public int getMajorVersion() - { - return majorVersion; - } - - /** - * Sets the value of the majorVersion property. - */ - public void setMajorVersion(int value) - { - this.majorVersion = value; - } - - /** - * Gets the value of the minorVersion property. - */ - public int getMinorVersion() - { - return minorVersion; - } - - /** - * Sets the value of the minorVersion property. - */ - public void setMinorVersion(int value) - { - this.minorVersion = value; - } - - /** - * Gets the value of the created property. - * - * @return possible object is {@link String } - */ - public Date getCreated() - { - return created; - } - - /** - * Sets the value of the created property. - * - * @param value allowed object is {@link String } - */ - public void setCreated(Date date) - { - this.created = date; - } - - /** - * Gets the value of the creator property. - * - * @return possible object is {@link String } - */ - public String getCreator() - { - return creator; - } - - /** - * Sets the value of the creator property. - * - * @param value allowed object is {@link String } - */ - public void setCreator(String value) - { - this.creator = value; - } - - /** - * Gets the value of the modified property. - * - * @return possible object is {@link String } - */ - public Date getModified() - { - return modified; - } - - /** - * Sets the value of the modified property. - * - * @param value allowed object is {@link String } - */ - public void setModified(Date d) - { - this.modified = d; - } - - /** - * Gets the value of the modifier property. - * - * @return possible object is {@link String } - */ - public String getModifier() - { - return modifier; - } - - /** - * Sets the value of the modifier property. - * - * @param value allowed object is {@link String } - */ - public void setModifier(String value) - { - this.modifier = value; - } - - /** - * Gets the value of the content property. - * - * @return possible object is {@link String } - */ - public String getContent() - { - return content; - } - - /** - * Sets the value of the content property. - * - * @param value allowed object is {@link String } - */ - public void setContent(String value) - { - this.content = value; - } - -} diff --git a/xwiki-android-core/src/org/xwiki/android/xmodel/entity/Resource.java b/xwiki-android-core/src/org/xwiki/android/xmodel/entity/Resource.java deleted file mode 100644 index a63d723..0000000 --- a/xwiki-android-core/src/org/xwiki/android/xmodel/entity/Resource.java +++ /dev/null @@ -1,43 +0,0 @@ -package org.xwiki.android.xmodel.entity; - -import java.io.Serializable; - -public class Resource implements Serializable -{ - - private boolean isNew=true; - - private boolean edited=true; - - public void setNew(boolean val) - { - isNew = val; - } - - /** - * This value is set/get for the following purpose. if a resource is new always add this resource to the containing - * resource's new list. For example Document.add(myobj); myedit(myobj);//update the myobj in the newObjects list of - * Document. If the client edited a clone of the myobj and now wants to reset myobj. Use - * Document.setObject("client side gen key for myobj", myobj2); setObject will check whether the resource is new and - * update the newObjects list also. The Document.addObject() method will set this property to true. Otherwise do not - * touch this property explicitly - */ - public boolean isNew() - { - return isNew; - } - - public boolean isEdited() - { - return edited; - } - /** - * - * @param altered true=mark object for update. - */ - public void setEdited(boolean altered) - { - this.edited = altered; - } - -} diff --git a/xwiki-android-core/src/org/xwiki/android/xmodel/entity/Tag.java b/xwiki-android-core/src/org/xwiki/android/xmodel/entity/Tag.java index b5755bd..28f38d1 100644 --- a/xwiki-android-core/src/org/xwiki/android/xmodel/entity/Tag.java +++ b/xwiki-android-core/src/org/xwiki/android/xmodel/entity/Tag.java @@ -1,15 +1,10 @@ package org.xwiki.android.xmodel.entity; -import java.util.List; - -import org.xwiki.android.rest.reference.Link; -import org.xwiki.android.xmodel.xobjects.XTag; - -import com.j256.ormlite.table.DatabaseTable; - -public class Tag +public class Tag extends XWikiResource { - private List links; + + private static final long serialVersionUID = 3416603502937027872L; + private String name; // private XTag xobj; // private int index; @@ -18,26 +13,7 @@ public Tag(String name) { this.name=name; } - - public List getLinks() - { - return links; - } - - public void addLink(Link link) - { - links.add(link); - } - - public void removeLink(int index) - { - links.remove(index); - } - - public void clearLinks() - { - links.clear(); - } + public String getName() { @@ -48,5 +24,10 @@ public void setName(String name) { this.name = name; } + @Override + public String toString() + { + return name; + } } diff --git a/xwiki-android-core/src/org/xwiki/android/xmodel/xobjects/XComment.java b/xwiki-android-core/src/org/xwiki/android/xmodel/xobjects/XComment.java index 4a822c7..74b6994 100644 --- a/xwiki-android-core/src/org/xwiki/android/xmodel/xobjects/XComment.java +++ b/xwiki-android-core/src/org/xwiki/android/xmodel/xobjects/XComment.java @@ -23,7 +23,7 @@ public void setAuthor(String author) XStringProperty prop = (XStringProperty) fields.get("author"); if (prop == null) { prop = new XStringProperty(); - fields.put("author", prop); + setProperty("author", prop); } prop.setValue(author); } @@ -40,7 +40,7 @@ public void setComment(String comment) XTextAreaProperty prop = (XTextAreaProperty) fields.get("comment"); if (prop == null) { prop = new XTextAreaProperty(); - fields.put("comment", prop); + setProperty("comment", prop); } prop.setValue(comment); } @@ -57,7 +57,7 @@ public void setDate(Date date) XDateProperty prop = (XDateProperty) fields.get("date"); if (prop == null) { prop = new XDateProperty(); - fields.put("date", prop); + setProperty("date", prop); } prop.setValue(date); } @@ -74,7 +74,7 @@ public void setHighlight(String highlight) XTextAreaProperty prop = (XTextAreaProperty) fields.get("highlight"); if (prop == null) { prop = new XTextAreaProperty(); - fields.put("highlight", prop); + setProperty("highlight", prop); } prop.setValue(highlight); } @@ -91,7 +91,7 @@ public void setReplyto(Integer replyto) XIntegerProperty prop = (XIntegerProperty) fields.get("replyto"); if (prop == null) { prop = new XIntegerProperty(); - fields.put("replyto", prop); + setProperty("replyto", prop); } prop.setValue(replyto); } @@ -104,7 +104,7 @@ public XStringProperty getpAuthor() } public void setpAuthor(XStringProperty author) { - fields.put("author", author); + setProperty("author", author); } public XTextAreaProperty getpComment() @@ -113,7 +113,7 @@ public XTextAreaProperty getpComment() } public void setpComment(XTextAreaProperty comment) { - fields.put("comment", comment); + setProperty("comment", comment); } public XDateProperty getpDate() { @@ -121,7 +121,7 @@ public XDateProperty getpDate() } public void setpDate(XDateProperty date) { - fields.put("date", date); + setProperty("date", date); } public XTextAreaProperty getpHighlight() { @@ -129,7 +129,7 @@ public XTextAreaProperty getpHighlight() } public void setpHighlight(XTextAreaProperty highlight) { - fields.put("highlight", highlight); + setProperty("highlight", highlight); } public XIntegerProperty getpReplyto() { @@ -137,7 +137,7 @@ public XIntegerProperty getpReplyto() } public void setpReplyto(XIntegerProperty replyto) { - fields.put("replyto", replyto); + setProperty("replyto", replyto); } } diff --git a/xwiki-android-core/src/org/xwiki/android/xmodel/xobjects/XObject.java b/xwiki-android-core/src/org/xwiki/android/xmodel/xobjects/XObject.java index 85adc98..a1fd1df 100644 --- a/xwiki-android-core/src/org/xwiki/android/xmodel/xobjects/XObject.java +++ b/xwiki-android-core/src/org/xwiki/android/xmodel/xobjects/XObject.java @@ -8,13 +8,13 @@ import java.util.Map; import org.xwiki.android.rest.reference.Link; -import org.xwiki.android.xmodel.entity.Resource; +import org.xwiki.android.xmodel.entity.XWikiResource; /** * @author sasindap * @param :The type of fields. i.e: XProperty, XObject */ -public abstract class XObject extends Resource implements Serializable, Cloneable +public abstract class XObject extends XWikiResource implements Serializable, Cloneable { protected Map fields; diff --git a/xwiki-android-core/src/org/xwiki/android/xmodel/xobjects/XSimpleObject.java b/xwiki-android-core/src/org/xwiki/android/xmodel/xobjects/XSimpleObject.java index 4c0d228..7133fda 100644 --- a/xwiki-android-core/src/org/xwiki/android/xmodel/xobjects/XSimpleObject.java +++ b/xwiki-android-core/src/org/xwiki/android/xmodel/xobjects/XSimpleObject.java @@ -144,14 +144,23 @@ public void setProperties(Map props){ /** * * @param p - * property to set. Key will be p.getName. + * property to set. */ public void setProperty(XProperty p){ if(p.getName()==null)throw new NullPointerException();//no need for HashTable. But if we change to HashMap or ... fields.put(p.getName(), p); } - public void setProperty(String key,XProperty p){ - fields.put(key,p); + /** + * Ignored if either parameter is null. + * Key will be set to the property name. + * @param key must be property name. + * @param p the property. + */ + public void setProperty(String key,XProperty p){ + if(p!=null && key !=null){ + p.setName(key); + fields.put(key,p); + } } public void removeProperty(String pname){ diff --git a/xwiki-android-core/src/org/xwiki/android/xmodel/xobjects/XTag.java b/xwiki-android-core/src/org/xwiki/android/xmodel/xobjects/XTag.java index 42773b5..37c2ffe 100644 --- a/xwiki-android-core/src/org/xwiki/android/xmodel/xobjects/XTag.java +++ b/xwiki-android-core/src/org/xwiki/android/xmodel/xobjects/XTag.java @@ -42,7 +42,7 @@ public List getTags() public void setpTags(XStaticListProperty prop){ - fields.put("tags",prop); + setProperty("tags",prop); } public XStaticListProperty getpTags(){ return (XStaticListProperty) fields.get("tags"); diff --git a/xwiki-android-core/src/org/xwiki/android/xmodel/xobjects/XUtils.java b/xwiki-android-core/src/org/xwiki/android/xmodel/xobjects/XUtils.java index 63c3476..ff5296e 100644 --- a/xwiki-android-core/src/org/xwiki/android/xmodel/xobjects/XUtils.java +++ b/xwiki-android-core/src/org/xwiki/android/xmodel/xobjects/XUtils.java @@ -1,9 +1,13 @@ package org.xwiki.android.xmodel.xobjects; + + import java.text.DateFormat; import java.text.ParseException; import java.text.SimpleDateFormat; +import java.util.ArrayList; import java.util.Arrays; +import java.util.Collections; import java.util.Date; import java.util.List; @@ -39,31 +43,43 @@ public static boolean toBoolean(String val) throws IllegalArgumentException return value; } - public static Date toDate(String ds) + public static Date toDate(String ds) throws IllegalArgumentException { - - String[] fmts = {"yyyy-MM-dd'T'HH:mm:ssZ", "yyyy-mm-dd HH:mm:ss.SSS"}; - int ivr[] = {0, -1};// input validation routine - + String orig=ds; + String[] fmts = {"yyyy-MM-dd'T'HH:mm:ssZ","yyyy-mm-dd'T'HH:mm:ss.SSSZ","yyyy-mm-dd HH:mm:ss.SSSZ" ,"yyyy-mm-dd HH:mm:ss.SSS"}; //when adding format see ivr[], Input validation routine + //ex:{2012-08-13T22:26:54+05:30, 2012-08-13T22:26:54.510+05:30 ,2012-08-13 22:26:54.377+05:30 ,2012-08-13 22:26:54.377 + int ivr[] = {0, 1, 1,-1};// input validation routine + String[] tried=new String[fmts.length]; //for debug only + for (int i = 0; i < fmts.length; i++) { + ds=orig; String fmtStr=fmts[i]; int key=ivr[i]; // IVR s switch (key) { - case 0: { - if(ds.length()>21){ - String gmt = ds.substring(20); + case 0: { //removes : in 05:30 to 0530 >> at the end 2012-08-13T22:26:54+05:30 ---> 2012-08-13T22:26:54+0530 + if(ds.length()>21){ + String gmt = ds.substring(20); gmt = gmt.substring(0, 2) + gmt.substring(3); - System.out.println(gmt); + //System.out.println(gmt); ds = ds.substring(0, 20) + gmt; - } - } + } break; + } + case 1: { //same as in 0 : 2012-08-13 22:26:54.377+05:30 ---> 2012-08-13 22:26:54.377+0530 + if(ds.length()>25){ + String gmt = ds.substring(24); + gmt = gmt.substring(0, 2) + gmt.substring(3); + //System.out.println(gmt); + ds = ds.substring(0, 24) + gmt; + } + break; + } default: break; } - + tried[i]=ds; //try to parse DateFormat fmt = new SimpleDateFormat(fmtStr); Date d = null; @@ -73,10 +89,9 @@ public static Date toDate(String ds) } catch (ParseException e) { } } - // end - throw new IllegalArgumentException( - "date format not supported. Only supported format are [...] see XUtils.toDate(String)"); + + throw new IllegalArgumentException("Unable to Parse"+orig+". After validation processing = "+Arrays.asList(tried)+" .Only supported format are [...] see"+XUtils.class.getSimpleName()+"#toDate(String)"); } /** @@ -86,6 +101,9 @@ public static Date toDate(String ds) */ public static List toStringList(String listStr, String seperators) { + if(listStr==null){ + return new ArrayList(); + } seperators = "[" + seperators + "]"; String[] items = listStr.split(seperators); return Arrays.asList(items); diff --git a/xwiki-android-rest/src/org/xwiki/android/rest/HttpConnector.java b/xwiki-android-rest/src/org/xwiki/android/rest/HttpConnector.java index a8d8ad2..f83e477 100644 --- a/xwiki-android-rest/src/org/xwiki/android/rest/HttpConnector.java +++ b/xwiki-android-rest/src/org/xwiki/android/rest/HttpConnector.java @@ -278,7 +278,7 @@ public int checkLogin(String username, String password, String Url) throws RestC String Uri; int responseCode = 0; - Uri = "http://" + Url + "/xwiki/rest/"; + Uri = "http://" + Url + "/xwiki/xmlrpc/"; try { requestUri = new URI(Uri); diff --git a/xwiki-android-rest/src/org/xwiki/android/rest/RestConnection.java b/xwiki-android-rest/src/org/xwiki/android/rest/RestConnection.java deleted file mode 100644 index cc4b133..0000000 --- a/xwiki-android-rest/src/org/xwiki/android/rest/RestConnection.java +++ /dev/null @@ -1,8 +0,0 @@ -package org.xwiki.android.rest; - -public interface RestConnection -{ - XWikiAPI getBaseAPI(); - boolean isClosed(); - void close(); -} diff --git a/xwiki-android-rest/src/org/xwiki/android/rest/Upgrade Http Connector, RestConnection b/xwiki-android-rest/src/org/xwiki/android/rest/Upgrade Http Connector, RestConnection deleted file mode 100644 index 9850c5e..0000000 --- a/xwiki-android-rest/src/org/xwiki/android/rest/Upgrade Http Connector, RestConnection +++ /dev/null @@ -1,100 +0,0 @@ -PoC. -We can achieve parellel http connections in this layer. -Use implementations of RestConnection to adjust params. -RestConnection.close() should shutdown the http connection manager of the http client. - -sample code// - -import org.apache.http.HttpEntity; -import org.apache.http.HttpResponse; -import org.apache.http.client.HttpClient; -import org.apache.http.client.methods.HttpGet; -import org.apache.http.client.methods.HttpUriRequest; -import org.apache.http.conn.ClientConnectionManager; -import org.apache.http.conn.scheme.PlainSocketFactory; -import org.apache.http.conn.scheme.Scheme; -import org.apache.http.conn.scheme.SchemeRegistry; -import org.apache.http.impl.client.DefaultHttpClient; -import org.apache.http.impl.conn.PoolingClientConnectionManager; -import org.apache.http.protocol.BasicHttpContext; -import org.apache.http.protocol.HttpContext; -import org.apache.http.util.EntityUtils; - -import java.io.IOException; - -/** - * Created with IntelliJ IDEA. - * User: admin - * Date: 8/11/12 - * Time: 1:53 PM - * To change this template use File | Settings | File Templates. - */ -public class org.xwiki.android.test.org.xwiki.test.integration.Main { - - static DefaultHttpClient client; - public static void main(String[] args) throws IOException, InterruptedException { - - SchemeRegistry schemeRegistry = new SchemeRegistry(); - schemeRegistry.register( - new Scheme("http", 80, PlainSocketFactory.getSocketFactory())); - - ClientConnectionManager cm = new PoolingClientConnectionManager(schemeRegistry); - HttpClient httpClient = new DefaultHttpClient(cm); - -// URIs to perform GETs on - String[] urisToGet = { - "http://www.domain1.com/", - "http://www.domain2.com/", - "http://www.domain3.com/", - "http://www.domain4.com/" - }; - -// create a thread for each URI - GetThread[] threads = new GetThread[urisToGet.length]; - for (int i = 0; i < threads.length; i++) { - HttpGet httpget = new HttpGet(urisToGet[i]); - threads[i] = new GetThread(httpClient, httpget); - } - -// start the threads - for (int j = 0; j < threads.length; j++) { - threads[j].start(); - } - -// join the threads - for (int j = 0; j < threads.length; j++) { - threads[j].join(); - } - - } - - static class GetThread extends Thread { - - private final HttpClient httpClient; - private final HttpContext context; - private final HttpGet httpget; - - public GetThread(HttpClient httpClient, HttpGet httpget) { - this.httpClient = httpClient; - this.context = new BasicHttpContext(); - this.httpget = httpget; - } - - @Override - public void run() { - try { - HttpResponse response = this.httpClient.execute(this.httpget, this.context); - HttpEntity entity = response.getEntity(); - if (entity != null) { - // do something useful with the entity - } - // ensure the connection gets released to the manager - EntityUtils.consume(entity); - } catch (Exception ex) { - this.httpget.abort(); - } - } - - } - -} \ No newline at end of file diff --git a/xwiki-android-rest/src/org/xwiki/android/rest/XWikiAPI.java b/xwiki-android-rest/src/org/xwiki/android/rest/XWikiAPI.java deleted file mode 100644 index 38dc5a7..0000000 --- a/xwiki-android-rest/src/org/xwiki/android/rest/XWikiAPI.java +++ /dev/null @@ -1,660 +0,0 @@ -package org.xwiki.android.rest; - -import java.io.InputStream; - -import org.xwiki.android.resources.Attachments; -import org.xwiki.android.resources.Class; -import org.xwiki.android.resources.Classes; -import org.xwiki.android.resources.Comment; -import org.xwiki.android.resources.Comments; -import org.xwiki.android.resources.History; -import org.xwiki.android.resources.Object; -import org.xwiki.android.resources.Objects; -import org.xwiki.android.resources.Page; -import org.xwiki.android.resources.Pages; -import org.xwiki.android.resources.Properties; -import org.xwiki.android.resources.Property; -import org.xwiki.android.resources.SearchResults; -import org.xwiki.android.resources.Spaces; -import org.xwiki.android.resources.Tag; -import org.xwiki.android.resources.Tags; -import org.xwiki.android.resources.Translations; -import org.xwiki.android.resources.Wikis; - -/** - * - * @author xwiki gsoc 2012 - * - */ -public interface XWikiAPI -{ - - /** - * Set the user credentials for accession - * - * @param username - * username of the user account in XWiki - * @param password - * password of the user account in XWiki - */ - void setAuthentication(String username, String password); - - /** - * @param wikiName - * name of the Wiki - * @param keyword - * text to search - * @return Search results of the searched keyword within Wiki contents - */ - SearchResults searchInWiki(String wikiName, String keyword) throws RestConnectionException, RestException, - RestException; - - /** - * @param wikiName - * name of the Wiki - * @param spaceName - * name of the space - * @param keyword - * text to search - * @return Search results of the searched keyword in provided space - */ - SearchResults searchInSpace(String wikiName, String spaceName, String keyword) throws RestConnectionException, - RestException, RestException; - - /** - * @return list of wikis in the provided XWiki URL domain - */ - Wikis getWikis() throws RestConnectionException, RestException, RestException; - - /** - * @param wikiName - * name of the Wiki - * @return all the tags used in the wiki - */ - Tags getWikiTags(String wikiName) throws RestConnectionException, RestException, RestException; - - /** - * @param wikiName - * name of the Wiki - * @return lists all the classes in the specified Wiki - */ - Classes getWikiClasses(String wikiName) throws RestConnectionException, RestException, RestException; - - /** - * @param wikiName - * name of the Wiki - * @param classname - * name of the class - * @return Class of the provided classname in the specified Wiki - */ - Class getWikiClasses(String wikiName, String classname) throws RestConnectionException, RestException, - RestException; - - /** - * @param wikiName - * name of the wiki - * @return list of spaces in the provided Wiki - */ - Spaces getSpaces(String wikiName) throws RestConnectionException, RestException; - - /** - * @param wikiName - * name of the wiki - * @param spaceName - * name of the space - * @return list of all the pages in specific Wiki and Space - */ - Pages getAllPages(String wikiName, String spaceName) throws RestConnectionException, RestException; - - boolean existsPage(String wikiName, String spaceName, String pageName) throws RestConnectionException,RestException; - - /** - * @param wikiName - * name of the wiki - * @param spaceName - * name of the space - * @param pageName - * name of the page - * @return Page object according to the field values - */ - Page getPage(String wikiName, String spaceName, String pageName) throws RestConnectionException, RestException; - - /** - * Add page to the server according to the provided field values - * - * @param wikiName - * name of the wiki - * @param spaceName - * name of the space - * @param pageName - * name of the page - * @param page - * Page object which is to be added - * @return status of the HTTP response - */ - String addPage(String wikiName, String spaceName, String pageName, Page page) throws RestConnectionException, - RestException; - - /** - * Delete page in the server - * - * @param wikiName - * name of the Wiki - * @param spaceName - * name of the space - * @param pageName - * name of the page - * @return status of the HTTP response - */ - String deletePage(String wikiName, String spaceName, String pageName) throws RestConnectionException, RestException; - - /** - * Delete page translation - * - * @param wikiName - * name of the Wiki - * @param spaceName - * name of the space - * @param pageName - * name of the page - * @param language - * specific language to delete - * @return status of the HTTP response - */ - String deletePage(String wikiName, String spaceName, String pageName, String language) - throws RestConnectionException, RestException; - - /** - * @param wikiName - * name of the Wiki - * @param spaceName - * name of the space - * @param pageName - * name of the page - * @return history of the page according to the field values - */ - History getPageHistory(String wikiName, String spaceName, String pageName) throws RestConnectionException, - RestException; - - /** - * @param wikiName - * name of the Wiki - * @param spaceName - * name of the space - * @param pageName - * name of the page - * @param version - * version of the page - * @return Page of the specified version - */ - Page getPageInVersionHistory(String wikiName, String spaceName, String pageName, String version) - throws RestConnectionException, RestException; - - /** - * @param wikiName - * name of the Wiki - * @param spaceName - * name of the space - * @param pageName - * name of the page - * @return Children pages of the specific page - */ - Pages getPageChildren(String wikiName, String spaceName, String pageName) throws RestConnectionException, - RestException; - - /** - * @param wikiName - * name of the Wiki - * @param spaceName - * name of the space - * @param pageName - * name of the page - * @return Tags of the page - */ - Tags getPageTags(String wikiName, String spaceName, String pageName) throws RestConnectionException, RestException; - - /** - * Adds page tag to the provided page - * - * @param wikiName - * name of the Wiki - * @param spaceName - * name of the space - * @param pageName - * name of the page - * @param tag - * tag to be added - * @return status of the HTTP response - */ - String addPageTag(String wikiName, String spaceName, String pageName, Tag tag) throws RestConnectionException, - RestException; - - /** - * - * @param wikiName - * @param spaceName - * @param pageName - * @param tags set of tags to replace with - * @return - * @throws RestConnectionException - * @throws RestException - */ - public String setTags(String wikiName, String spaceName, String pageName,Tags tags) throws RestConnectionException, RestException; - - /** - * get all comments in page - * @param wikiName - * name of the Wiki - * @param spaceName - * name of the space - * @param pageName - * name of the page - * @return all the comments in the specific page - */ - Comments getPageComments(String wikiName, String spaceName, String pageName) throws RestConnectionException, - RestException; - - /** - * check whether a comment exists for the given page. - * @param wikiName - * @param spaceName - * @param pageName - * @param commentId - * @return - * @throws RestConnectionException - * @throws RestException - */ - public boolean existsPageComment(String wikiName, String spaceName, String pageName,int commentId) throws RestConnectionException, RestException; - - /** - * get a comment. - * @param commentId ID of the comment in the page - * @return comment of a page selected using comment ID - * @throws RestConnectionException - * @throws RestException - */ - public Comment getPageComment(String wikiName, String spaceName, String pageName, int commentId) throws RestConnectionException, RestException; - - /** - * Add comment to the page - * - * @param wikiName - * name of the Wiki - * @param spaceName - * name of the space - * @param pageName - * name of the page - * @param comment - * Comment object to be added - * @return status of the HTTP response - */ - - String addPageComment(String wikiName, String spaceName, String pageName, Comment comment) - throws RestConnectionException, RestException; - - - /** - * @param wikiName - * name of the Wiki - * @param spaceName - * name of the space - * @param pageName - * name of the page - * @param version - * version of the page - * @return All the comments of the page specific version - */ - Comments getPageCommentsInHistory(String wikiName, String spaceName, String pageName, String version) - throws RestConnectionException, RestException; - - /** - * @param wikiName - * name of the Wiki - * @param spaceName - * name of the space - * @param pageName - * name of the page - * @param version - * version of the page - * @param commentId - * ID of the comment - * @return comments Comments of specific comment ID in specific page history - * version - */ - Comments getPageCommentsInHistory(String wikiName, String spaceName, String pageName, String version, - String commentId) throws RestConnectionException, RestException; - - /** - * @param wikiName - * name of the Wiki - * @param spaceName - * name of the space - * @param pageName - * name of the page - * @return list all the attachments in a specific page - */ - Attachments getAllPageAttachments(String wikiName, String spaceName, String pageName) - throws RestConnectionException, RestException; - - /** - * Gets a stream of data of a attachment - * - * @param wikiName - * name of the Wiki - * @param spaceName - * name of the space - * @param pageName - * name of the page - * @param attachmentName - * filename of the attachment. - * @return InputStream of the attachment raw data - */ - InputStream getPageAttachment(String wikiName, String spaceName, String pageName, String attachmentName) - throws RestConnectionException, RestException; - - /** - * Add attachment to a page - * - * @param wikiName - * name of the Wiki - * @param spaceName - * name of the space - * @param pageName - * name of the page - * @param filePath - * absolute path to the attachment in internal/external memory of - * the device - * @param attachmentName - * filename of the attachment - * @return status of the HTTP response - */ - String putPageAttachment(String wikiName, String spaceName, String pageName, String filePath, String attachmentName) - throws RestConnectionException, RestException; - - /** - * Delete the page attachment by its name - * - * @param wikiName - * name of the Wiki - * @param spaceName - * name of the space - * @param pageName - * name of the page - * @param attachmentName - * name of the attachment - * @return status of the HTTP response - */ - String deletePageAttachment(String wikiName, String spaceName, String pageName, String attachmentName) - throws RestConnectionException, RestException; - - /** - * @param wikiName - * name of the Wiki - * @param spaceName - * name of the space - * @param pageName - * name of the page - * @param pageVersion - * version of the page - * @return list of all attachments in the specified page history version - */ - Attachments getPageAttachmentsInHistory(String wikiName, String spaceName, String pageName, String pageVersion) - throws RestConnectionException, RestException; - - /** - * @param wikiName - * name of the Wiki - * @param spaceName - * name of the space - * @param pageName - * name of the page - * @param pageVersion - * version of the page - * @param attachmentName - * filename of the attachment - * @return InputStream of attachment raw data in a specific page history - * version - */ - InputStream getPageAttachmentsInHistory(String wikiName, String spaceName, String pageName, String pageVersion, - String attachmentName) throws RestConnectionException, RestException; - - /** - * @param wikiName - * name of the Wiki - * @param spaceName - * name of the space - * @param pageName - * name of the page - * @param attachmentName - * filename of the attachment - * @return list of attachment version history of a specific attachment - */ - Attachments getPageAttachmentsInAttachmentHistory(String wikiName, String spaceName, String pageName, - String attachmentName) throws RestConnectionException, RestException; - - /** - * @param wikiName - * name of the Wiki - * @param spaceName - * name of the space - * @param pageName - * name of the page - * @param attachmentName - * filename of the attachment - * @param attachmentVersion - * version of the attachment - * @return Stream of attachment raw data in a specific attachment version of - * a specified page - */ - InputStream getPageAttachmentsInAttachmentHistory(String wikiName, String spaceName, String pageName, - String attachmentName, String attachmentVersion) throws RestConnectionException, RestException; - - /** - * @param wikiName - * name of the Wiki - * @param spaceName - * name of the space - * @param pageName - * name of the page - * @return list all the Translations of a specific page - */ - Translations getAllPageTranslations(String wikiName, String spaceName, String pageName) - throws RestConnectionException, RestException; - - /** - * @param wikiName - * name of the Wiki - * @param spaceName - * name of the space - * @param pageName - * name of the page - * @param language - * language name of the page translations - * @return Page of the geted language - */ - Page getPageTranslation(String wikiName, String spaceName, String pageName, String language) - throws RestConnectionException, RestException; - - /** - * @param wikiName - * name of the Wiki - * @param spaceName - * name of the space - * @param pageName - * name of the page - * @param language - * language of the page - * @return Page history versions in a given language - */ - History getPageHistoryInLanguage(String wikiName, String spaceName, String pageName, String language) - throws RestConnectionException, RestException; - - /** - * @param wikiName - * name of the Wiki - * @param spaceName - * name of the space - * @param pageName - * name of the page - * @param language - * language of the page - * @param version - * version of the page - * @return Translated page of the given history version - */ - Page getPageTranslationInHistory(String wikiName, String spaceName, String pageName, String language, String version) - throws RestConnectionException, RestException; - - - boolean existsObject(String wikiName, String spaceName, String pageName, String objectClassname, - int objectNumber)throws RestConnectionException,RestException; - /** - * Adds provided object to the given page - * - * @param wikiName - * name of the Wiki - * @param spaceName - * name of the space - * @param pageName - * name of the page - * @param object - * Object to be added to page - * @return status of the HTTP response - */ - String addObject(String wikiName, String spaceName, String pageName, Object object) throws RestConnectionException, - RestException; - - /** - * Update object in a page - * - * @param objectClassname - * name of the class of the object - * @param objectNumber - * number of the object in the class - * @param object - * Object object to be updated in the page - * @return status of the HTTP put request - * @throws RestConnectionException - * @throws RestException - */ - public String updateObject(String wikiName, String spaceName, String pageName, String objectClassname, - int objectNumber, Object object) throws RestConnectionException, RestException; - - /** - * @param wikiName - * name of the Wiki - * @param spaceName - * name of the space - * @param pageName - * name of the page - * @return All the objects of the specified page - */ - Objects getAllObjects(String wikiName, String spaceName, String pageName) throws RestConnectionException, - RestException; - - /** - * @param wikiName - * name of the Wiki - * @param spaceName - * name of the space - * @param pageName - * name of the page - * @param objectClassname - * class name of the objects - * @return All the objects which have given class name of the specified page - */ - Objects getObjectsInClass(String wikiName, String spaceName, String pageName, String objectClassname) - throws RestConnectionException, RestException; - - /** - * @param wikiName - * name of the Wiki - * @param spaceName - * name of the space - * @param pageName - * name of the page - * @param objectClassname - * class name of the objects - * @param objectNumber - * number of the object in the specific class - * @return Object of the given class name and object number of the specified - * page - */ - Object getObject(String wikiName, String spaceName, String pageName, String objectClassname, int objectNumber) - throws RestConnectionException, RestException; - - /** - * Deletes the given object. Object can be selected using class name and the - * object number - * - * @param wikiName - * name of the Wiki - * @param spaceName - * name of the space - * @param pageName - * name of the page - * @param objectClassname - * class name of the objects - * @param objectNumber - * number of the object in the specified class - * @return status of the HTTP response of the delete operation - */ - String deleteObject(String wikiName, String spaceName, String pageName, String objectClassname, String objectNumber) - throws RestConnectionException, RestException; - - /** - * @param wikiName - * name of the Wiki - * @param spaceName - * name of the space - * @param pageName - * name of the page - * @param objectClassname - * class name of the objects - * @param objectNumber - * number of the object in the specified class - * @return lists all the properties of a specific object - */ - Properties getObjectAllProperties(String wikiName, String spaceName, String pageName, String objectClassname, - String objectNumber) throws RestConnectionException, RestException; - - /** - * @param wikiName - * name of the Wiki - * @param spaceName - * name of the space - * @param pageName - * name of the page - * @param objectClassname - * class name of objects - * @param objectNumber - * number of the object in the page - * @param propertyName - * name of the property in the object - * @return Property out of list of properties in a given object of a page - */ - Property getObjectProperty(String wikiName, String spaceName, String pageName, String objectClassname, - String objectNumber, String propertyName) throws RestConnectionException, RestException; - //TODO: refactor number to int - - /** - * Adds the property to the object of a page - * - * @param wikiName - * name of the Wiki - * @param spaceName - * name of the space - * @param pageName - * name of the page - * @param objectClassname - * class name of the objects - * @param objectNumber - * number of the object - * @param property - * Property object to be added to the object in a page - * @return status of the HTTP response - */ - String addObjectProperty(String wikiName, String spaceName, String pageName, String objectClassname, - String objectNumber, Property property) throws RestConnectionException, RestException; - -} \ No newline at end of file diff --git a/xwiki-android-rest/src/org/xwiki/android/rest/XWikiRestConnecion.java b/xwiki-android-rest/src/org/xwiki/android/rest/XWikiRestConnecion.java deleted file mode 100644 index 25d9ec6..0000000 --- a/xwiki-android-rest/src/org/xwiki/android/rest/XWikiRestConnecion.java +++ /dev/null @@ -1,1074 +0,0 @@ -package org.xwiki.android.rest; - -import java.io.InputStream; -import java.io.UnsupportedEncodingException; -import java.net.URLEncoder; - -import org.xwiki.android.resources.Attachments; -import org.xwiki.android.resources.Class; -import org.xwiki.android.resources.Classes; -import org.xwiki.android.resources.Comment; -import org.xwiki.android.resources.Comments; -import org.xwiki.android.resources.History; -import org.xwiki.android.resources.Object; -import org.xwiki.android.resources.Objects; -import org.xwiki.android.resources.Page; -import org.xwiki.android.resources.Pages; -import org.xwiki.android.resources.Properties; -import org.xwiki.android.resources.Property; -import org.xwiki.android.resources.SearchResults; -import org.xwiki.android.resources.Spaces; -import org.xwiki.android.resources.Tag; -import org.xwiki.android.resources.Tags; -import org.xwiki.android.resources.Translations; -import org.xwiki.android.resources.Wikis; - -import android.util.Log; - -public class XWikiRestConnecion implements RestConnection, XWikiAPI -{ - - private static final String TAG ="XWikiRestConnecion"; - - /** - * URL of the XWiki domain - */ - private String URLprefix; - - /** - * Username for accessing XWiki - */ - private String username; - - /** - * Password for accessing XWiki - */ - private String password; - - /** - * State of the gets has user authentication or not - */ - private boolean isAuthenticated = false; - - /** - * @param URLprefix URL of the XWiki domain - */ - public XWikiRestConnecion(String URLprefix) - { - this.URLprefix = URLprefix; - isAuthenticated = false; - } - - /** - * Constructor for directly setting user credentials. - * - * @param URLprefix URL of the XWiki domain - * @param username username of the user account - * @param password password of the user account - */ - public XWikiRestConnecion(String URLprefix, String username, String password) - { - this.URLprefix = URLprefix; - this.username = username; - this.password = password; - isAuthenticated = true; - } - - /* - * (non-Javadoc) - * @see org.xwiki.android.xmlrpc.XWikiRestfulAPI#setAuthentication(java.lang.String, java.lang.String) - */ - @Override - public void setAuthentication(String username, String password) - { - this.username = username; - this.password = password; - isAuthenticated = true; - } - - /** - * Converts strings to UCS Transformation Format - 8-bit(UTF-8) for calling XWiki RESTful API Does URL encoding of - * the keyword. - * - * @param word text to convert - * @return converted text - */ - private String urlEncode(String word) - { - - // Convert keyword to UTF-8 - try { - word = URLEncoder.encode(word, "UTF-8"); - - } catch (UnsupportedEncodingException e) { - Log.d("Error", "Unsupported keyword is found"); - word = "error in converting to UTF-8"; - e.printStackTrace(); - } - - return word; - } - - /* - * (non-Javadoc) - * @see org.xwiki.android.xmlrpc.XWikiRestfulAPI#getSearch(java.lang.String, java.lang.String) - */ - @Override - public SearchResults searchInWiki(String wikiName, String keyword) throws RestConnectionException, RestException, RestException - { - - wikiName = urlEncode(wikiName); - keyword = urlEncode(keyword); - - Search search = new Search(URLprefix); - - if (isAuthenticated) { - search.setAuthenticaion(username, password); - } - - return search.doWikiSearch(wikiName, keyword); - } - - /* - * (non-Javadoc) - * @see org.xwiki.android.xmlrpc.XWikiRestfulAPI#getSearch(java.lang.String, java.lang.String, java.lang.String) - */ - @Override - public SearchResults searchInSpace(String wikiName, String spaceName, String keyword) throws RestConnectionException, RestException - { - - wikiName = urlEncode(wikiName); - spaceName = urlEncode(spaceName); - keyword = urlEncode(keyword); - - Search search = new Search(URLprefix); - if (isAuthenticated) { - search.setAuthenticaion(username, password); - } - return search.doSpacesSearch(wikiName, spaceName, keyword); - } - - /* - * (non-Javadoc) - * @see org.xwiki.android.xmlrpc.XWikiRestfulAPI#getWikis() - */ - @Override - public Wikis getWikis() throws RestConnectionException, RestException - { - - WikiResources wikiresources = new WikiResources(URLprefix); - if (isAuthenticated) { - wikiresources.setAuthenticaion(username, password); - } - Wikis wikis = wikiresources.getWikis(); - return wikis; - } - - /* - * (non-Javadoc) - * @see org.xwiki.android.xmlrpc.XWikiRestfulAPI#getSpaces(java.lang.String) - */ - @Override - public Spaces getSpaces(String wikiName) throws RestConnectionException, RestException - { - wikiName = urlEncode(wikiName); - SpaceResources spacesresources = new SpaceResources(URLprefix, wikiName); - if (isAuthenticated) { - spacesresources.setAuthenticaion(username, password); - } - return spacesresources.getSpaces(); - } - - /* - * (non-Javadoc) - * @see org.xwiki.android.xmlrpc.XWikiRestfulAPI#getAllPages(java.lang.String, java.lang.String) - */ - @Override - public Pages getAllPages(String wikiName, String spaceName) throws RestConnectionException, RestException - { - wikiName = urlEncode(wikiName); - spaceName = urlEncode(spaceName); - PageResources pagesresources = new PageResources(URLprefix, wikiName, spaceName); - if (isAuthenticated) { - pagesresources.setAuthenticaion(username, password); - } - return pagesresources.getAllPages(); - } - - @Override - public boolean existsPage(String wikiName, String spaceName, String pageName) throws RestConnectionException, RestException - { - wikiName = urlEncode(wikiName); - spaceName = urlEncode(spaceName); - pageName = urlEncode(pageName); - - PageResources pagesresources = new PageResources(URLprefix, wikiName, spaceName); - if (isAuthenticated) { - pagesresources.setAuthenticaion(username, password); - } - return pagesresources.exists(pageName); - - } - - - @Override - public Page getPage(String wikiName, String spaceName, String pageName) throws RestConnectionException, RestException - { - wikiName = urlEncode(wikiName); - spaceName = urlEncode(spaceName); - pageName = urlEncode(pageName); - - PageResources pagesresources = new PageResources(URLprefix, wikiName, spaceName); - if (isAuthenticated) { - pagesresources.setAuthenticaion(username, password); - } - return pagesresources.getPage(pageName); - } - - /* - * (non-Javadoc) - * @see org.xwiki.android.xmlrpc.XWikiRestfulAPI#addPage(java.lang.String, java.lang.String, java.lang.String, - * org.xwiki.android.resources.Page) - */ - @Override - public String addPage(String wikiName, String spaceName, String pageName, Page page) throws RestConnectionException, RestException - { - wikiName = urlEncode(wikiName); - spaceName = urlEncode(spaceName); - pageName = urlEncode(pageName); - - PageResources pagesresources = new PageResources(URLprefix, wikiName, spaceName); - if (isAuthenticated) { - pagesresources.setAuthenticaion(username, password); - } - return pagesresources.addPage(page); - } - - /* - * (non-Javadoc) - * @see org.xwiki.android.xmlrpc.XWikiRestfulAPI#deletePage(java.lang.String, java.lang.String, java.lang.String) - */ - @Override - public String deletePage(String wikiName, String spaceName, String pageName) throws RestConnectionException, RestException - { - wikiName = urlEncode(wikiName); - spaceName = urlEncode(spaceName); - pageName = urlEncode(pageName); - - PageResources pagesresources = new PageResources(URLprefix, wikiName, spaceName); - if (isAuthenticated) { - pagesresources.setAuthenticaion(username, password); - } - return pagesresources.deletePage(pageName); - } - - /* - * (non-Javadoc) - * @see org.xwiki.android.xmlrpc.XWikiRestfulAPI#deletePage(java.lang.String, java.lang.String, java.lang.String, - * java.lang.String) - */ - @Override - public String deletePage(String wikiName, String spaceName, String pageName, String language) - throws RestConnectionException, RestException - - { - wikiName = urlEncode(wikiName); - spaceName = urlEncode(spaceName); - pageName = urlEncode(pageName); - - PageResources pagesresources = new PageResources(URLprefix, wikiName, spaceName); - if (isAuthenticated) { - pagesresources.setAuthenticaion(username, password); - } - return pagesresources.deletePageTranslation(pageName, language); - } - - /* - * (non-Javadoc) - * @see org.xwiki.android.xmlrpc.XWikiRestfulAPI#getPageHistory(java.lang.String, java.lang.String, java.lang.String) - */ - - @Override - public History getPageHistory(String wikiName, String spaceName, String pageName) throws RestConnectionException, RestException - { - wikiName = urlEncode(wikiName); - spaceName = urlEncode(spaceName); - pageName = urlEncode(pageName); - - HistoryResources historyresources = new HistoryResources(URLprefix, wikiName, spaceName, pageName); - if (isAuthenticated) { - historyresources.setAuthenticaion(username, password); - } - return historyresources.getPageHistory(); - } - - /* - * (non-Javadoc) - * @see org.xwiki.android.xmlrpc.XWikiRestfulAPI#getPageInVersionHistory(java.lang.String, java.lang.String, - * java.lang.String, java.lang.String) - */ - - @Override - public Page getPageInVersionHistory(String wikiName, String spaceName, String pageName, String version) - throws RestConnectionException, RestException - { - wikiName = urlEncode(wikiName); - spaceName = urlEncode(spaceName); - pageName = urlEncode(pageName); - - PageResources pagesresources = new PageResources(URLprefix, wikiName, spaceName); - if (isAuthenticated) { - pagesresources.setAuthenticaion(username, password); - } - return pagesresources.getPageHistoryOnVersion(pageName, version); - } - - /* - * (non-Javadoc) - * @see org.xwiki.android.xmlrpc.XWikiRestfulAPI#getPageChildren(java.lang.String, java.lang.String, java.lang.String) - */ - - @Override - public Pages getPageChildren(String wikiName, String spaceName, String pageName) throws RestConnectionException, RestException - { - wikiName = urlEncode(wikiName); - spaceName = urlEncode(spaceName); - pageName = urlEncode(pageName); - - PageResources pagesresources = new PageResources(URLprefix, wikiName, spaceName); - if (isAuthenticated) { - pagesresources.setAuthenticaion(username, password); - } - return pagesresources.getPageChildren(pageName); - - } - - /* - * (non-Javadoc) - * @see org.xwiki.android.xmlrpc.XWikiRestfulAPI#getPageTags(java.lang.String, java.lang.String, java.lang.String) - */ - - @Override - public Tags getPageTags(String wikiName, String spaceName, String pageName) throws RestConnectionException, RestException - { - wikiName = urlEncode(wikiName); - spaceName = urlEncode(spaceName); - pageName = urlEncode(pageName); - - TagResources tagresources = new TagResources(URLprefix, wikiName, spaceName, pageName); - if (isAuthenticated) { - tagresources.setAuthenticaion(username, password); - } - return tagresources.getTags(); - } - - /* - * (non-Javadoc) - * @see org.xwiki.android.xmlrpc.XWikiRestfulAPI#addPageTag(java.lang.String, java.lang.String, java.lang.String, - * org.xwiki.android.resources.Tag) - */ - - @Override - public String addPageTag(String wikiName, String spaceName, String pageName, Tag tag) throws RestConnectionException, RestException - { - wikiName = urlEncode(wikiName); - spaceName = urlEncode(spaceName); - pageName = urlEncode(pageName); - - TagResources tagresources = new TagResources(URLprefix, wikiName, spaceName, pageName); - if (isAuthenticated) { - tagresources.setAuthenticaion(username, password); - } - return tagresources.addTag(tag); - - } - @Override - public String setTags(String wikiName, String spaceName, String pageName,Tags tags)throws RestConnectionException, RestException{ - wikiName = urlEncode(wikiName); - spaceName = urlEncode(spaceName); - pageName = urlEncode(pageName); - - TagResources tagresources = new TagResources(URLprefix, wikiName, spaceName, pageName); - if (isAuthenticated) { - tagresources.setAuthenticaion(username, password); - } - return tagresources.setTags(tags); - } - - /* - * (non-Javadoc) - * @see org.xwiki.android.xmlrpc.XWikiRestfulAPI#getWikiTags(java.lang.String) - */ - - @Override - public Tags getWikiTags(String wikiName) throws RestConnectionException, RestException - { - wikiName = urlEncode(wikiName); - - TagResources tagresources = new TagResources(URLprefix, wikiName); - if (isAuthenticated) { - tagresources.setAuthenticaion(username, password); - } - return tagresources.getTags(); - } - - /* - * (non-Javadoc) - * @see org.xwiki.android.xmlrpc.XWikiRestfulAPI#getPageComments(java.lang.String, java.lang.String, java.lang.String) - */ - - @Override - public Comments getPageComments(String wikiName, String spaceName, String pageName) throws RestConnectionException, RestException - { - wikiName = urlEncode(wikiName); - spaceName = urlEncode(spaceName); - pageName = urlEncode(pageName); - - CommentResources commentresources = new CommentResources(URLprefix, wikiName, spaceName, pageName); - if (isAuthenticated) { - commentresources.setAuthenticaion(username, password); - } - return commentresources.getPageComments(); - } - - @Override - public boolean existsPageComment(String wikiName, String spaceName, String pageName, int commentId) - throws RestConnectionException, RestException - { - wikiName = urlEncode(wikiName); - spaceName = urlEncode(spaceName); - pageName = urlEncode(pageName); - - CommentResources commentresources = new CommentResources(URLprefix, wikiName, spaceName, pageName); - if (isAuthenticated) { - commentresources.setAuthenticaion(username, password); - } - return commentresources.exists(commentId); - } - - @Override - public Comment getPageComment(String wikiName, String spaceName, String pageName, int commentId) throws RestConnectionException, RestException - { - wikiName = urlEncode(wikiName); - spaceName = urlEncode(spaceName); - pageName = urlEncode(pageName); - - CommentResources commentresources = new CommentResources(URLprefix, wikiName, spaceName, pageName); - if (isAuthenticated) { - commentresources.setAuthenticaion(username, password); - } - return commentresources.getPageComment(commentId); - } - - /* - * (non-Javadoc) - * @see org.xwiki.android.xmlrpc.XWikiRestfulAPI#addPageComment(java.lang.String, java.lang.String, java.lang.String, - * org.xwiki.android.resources.Comment) - */ - - @Override - public String addPageComment(String wikiName, String spaceName, String pageName, Comment comment) - throws RestConnectionException, RestException - { - wikiName = urlEncode(wikiName); - spaceName = urlEncode(spaceName); - pageName = urlEncode(pageName); - - CommentResources commentresources = new CommentResources(URLprefix, wikiName, spaceName, pageName); - if (isAuthenticated) { - commentresources.setAuthenticaion(username, password); - return commentresources.addPageComment(comment); - } else { - return "Autherization details are not provided"; - } - } - - - - /* - * (non-Javadoc) - * @see org.xwiki.android.xmlrpc.XWikiRestfulAPI#getPageCommentsInHistory(java.lang.String, java.lang.String, - * java.lang.String, java.lang.String) - */ - - @Override - public Comments getPageCommentsInHistory(String wikiName, String spaceName, String pageName, String version) - throws RestConnectionException, RestException - { - wikiName = urlEncode(wikiName); - spaceName = urlEncode(spaceName); - pageName = urlEncode(pageName); - - CommentResources commentresources = new CommentResources(URLprefix, wikiName, spaceName, pageName); - if (isAuthenticated) { - commentresources.setAuthenticaion(username, password); - } - return commentresources.getPageCommentsInHistory(version); - } - - /* - * (non-Javadoc) - * @see org.xwiki.android.xmlrpc.XWikiRestfulAPI#getPageCommentsInHistory(java.lang.String, java.lang.String, - * java.lang.String, java.lang.String, java.lang.String) - */ - - @Override - public Comments getPageCommentsInHistory(String wikiName, String spaceName, String pageName, String version, - String commentId) throws RestConnectionException, RestException - { - wikiName = urlEncode(wikiName); - spaceName = urlEncode(spaceName); - pageName = urlEncode(pageName); - - CommentResources commentresources = new CommentResources(URLprefix, wikiName, spaceName, pageName); - if (isAuthenticated) { - commentresources.setAuthenticaion(username, password); - } - return commentresources.getPageCommentsInHistory(version, commentId); - } - - /* - * (non-Javadoc) - * @see org.xwiki.android.xmlrpc.XWikiRestfulAPI#getAllPageAttachments(java.lang.String, java.lang.String, - * java.lang.String) - */ - - @Override - public Attachments getAllPageAttachments(String wikiName, String spaceName, String pageName) - throws RestConnectionException, RestException - { - wikiName = urlEncode(wikiName); - spaceName = urlEncode(spaceName); - pageName = urlEncode(pageName); - - AttachmentResources attachmentresources = new AttachmentResources(URLprefix, wikiName, spaceName, pageName); - if (isAuthenticated) { - attachmentresources.setAuthenticaion(username, password); - } - - return attachmentresources.getAllPageAttachments(); - } - - /* - * (non-Javadoc) - * @see org.xwiki.android.xmlrpc.XWikiRestfulAPI#getPageAttachment(java.lang.String, java.lang.String, - * java.lang.String, java.lang.String) - */ - - @Override - public InputStream getPageAttachment(String wikiName, String spaceName, String pageName, String attachmentName) - throws RestConnectionException, RestException - { - wikiName = urlEncode(wikiName); - spaceName = urlEncode(spaceName); - pageName = urlEncode(pageName); - attachmentName = urlEncode(attachmentName); - - AttachmentResources attachmentresources = new AttachmentResources(URLprefix, wikiName, spaceName, pageName); - if (isAuthenticated) { - attachmentresources.setAuthenticaion(username, password); - } - return attachmentresources.getPageAttachment(attachmentName); - } - - /* - * (non-Javadoc) - * @see org.xwiki.android.xmlrpc.XWikiRestfulAPI#addPageAttachment(java.lang.String, java.lang.String, - * java.lang.String, java.lang.String, java.lang.String) - */ - - @Override - public String putPageAttachment(String wikiName, String spaceName, String pageName, String filePath, - String attachmentName) throws RestConnectionException, RestException - { - wikiName = urlEncode(wikiName); - spaceName = urlEncode(spaceName); - pageName = urlEncode(pageName); - attachmentName = urlEncode(attachmentName); - - AttachmentResources attachmentresources = new AttachmentResources(URLprefix, wikiName, spaceName, pageName); - if (isAuthenticated) { - attachmentresources.setAuthenticaion(username, password); - } - return attachmentresources.putPageAttachment(filePath, attachmentName); - } - - - - /* - * (non-Javadoc) - * @see org.xwiki.android.xmlrpc.XWikiRestfulAPI#deletePageAttachment(java.lang.String, java.lang.String, - * java.lang.String, java.lang.String) - */ - - @Override - public String deletePageAttachment(String wikiName, String spaceName, String pageName, String attachmentName) - throws RestConnectionException, RestException - { - wikiName = urlEncode(wikiName); - spaceName = urlEncode(spaceName); - pageName = urlEncode(pageName); - attachmentName = urlEncode(attachmentName); - - AttachmentResources attachmentresources = new AttachmentResources(URLprefix, wikiName, spaceName, pageName); - if (isAuthenticated) { - attachmentresources.setAuthenticaion(username, password); - } - return attachmentresources.deletePageAttachment(attachmentName); - } - - /* - * (non-Javadoc) - * @see org.xwiki.android.xmlrpc.XWikiRestfulAPI#getPageAttachmentsInHistory(java.lang.String, java.lang.String, - * java.lang.String, java.lang.String) - */ - - @Override - public Attachments getPageAttachmentsInHistory(String wikiName, String spaceName, String pageName, - String pageVersion) throws RestConnectionException, RestException - { - wikiName = urlEncode(wikiName); - spaceName = urlEncode(spaceName); - pageName = urlEncode(pageName); - - AttachmentResources attachmentresources = new AttachmentResources(URLprefix, wikiName, spaceName, pageName); - if (isAuthenticated) { - attachmentresources.setAuthenticaion(username, password); - } - return attachmentresources.getPageAttachmentsInHistory(pageVersion); - } - - /* - * (non-Javadoc) - * @see org.xwiki.android.xmlrpc.XWikiRestfulAPI#getPageAttachmentsInHistory(java.lang.String, java.lang.String, - * java.lang.String, java.lang.String, java.lang.String) - */ - - @Override - public InputStream getPageAttachmentsInHistory(String wikiName, String spaceName, String pageName, - String pageVersion, String attachmentName) throws RestConnectionException, RestException - { - wikiName = urlEncode(wikiName); - spaceName = urlEncode(spaceName); - pageName = urlEncode(pageName); - attachmentName = urlEncode(attachmentName); - - AttachmentResources attachmentresources = new AttachmentResources(URLprefix, wikiName, spaceName, pageName); - if (isAuthenticated) { - attachmentresources.setAuthenticaion(username, password); - } - return attachmentresources.getPageAttachmentsInHistory(pageVersion, attachmentName); - } - - /* - * (non-Javadoc) - * @see org.xwiki.android.xmlrpc.XWikiRestfulAPI#getPageAttachmentsInAttachmentHistory(java.lang.String, - * java.lang.String, java.lang.String, java.lang.String) - */ - - @Override - public Attachments getPageAttachmentsInAttachmentHistory(String wikiName, String spaceName, String pageName, - String attachmentName) throws RestConnectionException, RestException - { - wikiName = urlEncode(wikiName); - spaceName = urlEncode(spaceName); - pageName = urlEncode(pageName); - attachmentName = urlEncode(attachmentName); - - AttachmentResources attachmentresources = new AttachmentResources(URLprefix, wikiName, spaceName, pageName); - if (isAuthenticated) { - attachmentresources.setAuthenticaion(username, password); - } - return attachmentresources.getPageAttachmentsInAttachmentHistory(attachmentName); - } - - /* - * (non-Javadoc) - * @see org.xwiki.android.xmlrpc.XWikiRestfulAPI#getPageAttachmentsInAttachmentHistory(java.lang.String, - * java.lang.String, java.lang.String, java.lang.String, java.lang.String) - */ - - @Override - public InputStream getPageAttachmentsInAttachmentHistory(String wikiName, String spaceName, String pageName, - String attachmentName, String attachmentVersion) throws RestConnectionException, RestException - { - wikiName = urlEncode(wikiName); - spaceName = urlEncode(spaceName); - pageName = urlEncode(pageName); - attachmentName = urlEncode(attachmentName); - - AttachmentResources attachmentresources = new AttachmentResources(URLprefix, wikiName, spaceName, pageName); - if (isAuthenticated) { - attachmentresources.setAuthenticaion(username, password); - } - return attachmentresources.getPageAttachmentsInAttachmentHistory(attachmentName, attachmentVersion); - } - - /* - * (non-Javadoc) - * @see org.xwiki.android.xmlrpc.XWikiRestfulAPI#getWikiClasses(java.lang.String) - */ - - @Override - public Classes getWikiClasses(String wikiName) throws RestConnectionException, RestException - { - wikiName = urlEncode(wikiName); - - ClassResources classresources = new ClassResources(URLprefix, wikiName); - if (isAuthenticated) { - classresources.setAuthenticaion(username, password); - } - return classresources.getWikiClasses(); - } - - /* - * (non-Javadoc) - * @see org.xwiki.android.xmlrpc.XWikiRestfulAPI#getWikiClasses(java.lang.String, java.lang.String) - */ - - @Override - public Class getWikiClasses(String wikiName, String classname) throws RestConnectionException, RestException - { - wikiName = urlEncode(wikiName); - classname = urlEncode(classname); - - ClassResources classresources = new ClassResources(URLprefix, wikiName); - if (isAuthenticated) { - classresources.setAuthenticaion(username, password); - } - return classresources.getWikiClasses(classname); - } - - /* - * (non-Javadoc) - * @see org.xwiki.android.xmlrpc.XWikiRestfulAPI#getAllPageTranslations(java.lang.String, java.lang.String, - * java.lang.String) - */ - - @Override - public Translations getAllPageTranslations(String wikiName, String spaceName, String pageName) - throws RestConnectionException, RestException - { - wikiName = urlEncode(wikiName); - spaceName = urlEncode(spaceName); - pageName = urlEncode(pageName); - - TranslationResources translationresources = new TranslationResources(URLprefix, wikiName, spaceName, pageName); - if (isAuthenticated) { - translationresources.setAuthenticaion(username, password); - } - return translationresources.getAllTranslations(); - } - - /* - * (non-Javadoc) - * @see org.xwiki.android.xmlrpc.XWikiRestfulAPI#getPageTranslation(java.lang.String, java.lang.String, - * java.lang.String, java.lang.String) - */ - - @Override - public Page getPageTranslation(String wikiName, String spaceName, String pageName, String language) - throws RestConnectionException, RestException - { - wikiName = urlEncode(wikiName); - spaceName = urlEncode(spaceName); - pageName = urlEncode(pageName); - - PageResources pageresources = new PageResources(URLprefix, wikiName, spaceName); - if (isAuthenticated) { - pageresources.setAuthenticaion(username, password); - } - return pageresources.getPageTranslation(pageName, language); - } - - /* - * (non-Javadoc) - * @see org.xwiki.android.xmlrpc.XWikiRestfulAPI#getPageHistoryInLanguage(java.lang.String, java.lang.String, - * java.lang.String, java.lang.String) - */ - - @Override - public History getPageHistoryInLanguage(String wikiName, String spaceName, String pageName, String language) - throws RestConnectionException, RestException - { - wikiName = urlEncode(wikiName); - spaceName = urlEncode(spaceName); - pageName = urlEncode(pageName); - - HistoryResources historyresources = new HistoryResources(URLprefix, wikiName, spaceName, pageName); - if (isAuthenticated) { - historyresources.setAuthenticaion(username, password); - } - return historyresources.getPageHistory(language); - } - - /* - * (non-Javadoc) - * @see org.xwiki.android.xmlrpc.XWikiRestfulAPI#getPageTranslationInHistory(java.lang.String, java.lang.String, - * java.lang.String, java.lang.String, java.lang.String) - */ - - @Override - public Page getPageTranslationInHistory(String wikiName, String spaceName, String pageName, String language, - String version) throws RestConnectionException, RestException - { - wikiName = urlEncode(wikiName); - spaceName = urlEncode(spaceName); - pageName = urlEncode(pageName); - - PageResources pageresources = new PageResources(URLprefix, wikiName, spaceName); - if (isAuthenticated) { - pageresources.setAuthenticaion(username, password); - } - return pageresources.getPageTranslation(pageName, language, version); - } - - @Override - public boolean existsObject(String wikiName, String spaceName, String pageName, String objectClassname, - int objectNumber) throws RestConnectionException, RestException - { - wikiName = urlEncode(wikiName); - spaceName = urlEncode(spaceName); - pageName = urlEncode(pageName); - objectClassname = urlEncode(objectClassname); - String objNumber=urlEncode(objectNumber+""); - - ObjectResources objectresources = new ObjectResources(URLprefix, wikiName, spaceName, pageName); - if (isAuthenticated) { - objectresources.setAuthenticaion(username, password); - } - boolean val= objectresources.exists(objectClassname,objNumber); - return val; - - } - - /* - * (non-Javadoc) - * @see org.xwiki.android.xmlrpc.XWikiRestfulAPI#addObject(java.lang.String, java.lang.String, java.lang.String, - * org.xwiki.android.resources.Object) - */ - - @Override - public String addObject(String wikiName, String spaceName, String pageName, Object object) - throws RestConnectionException, RestException - { - wikiName = urlEncode(wikiName); - spaceName = urlEncode(spaceName); - pageName = urlEncode(pageName); - - ObjectResources objectresources = new ObjectResources(URLprefix, wikiName, spaceName, pageName); - if (isAuthenticated) { - objectresources.setAuthenticaion(username, password); - } - return objectresources.addObject(object); - } - - /** - * Update object in a page - * - * @param objectClassname name of the class of the object - * @param objectNumber number of the object in the class - * @param object Object object to be updated in the page - * @return status of the HTTP put request - * @throws RestConnectionException - * @throws RestException - */ - @Override - public String updateObject(String wikiName, String spaceName, String pageName,String objectClassname, int objectNumber, Object object) throws RestConnectionException, RestException - { - wikiName = urlEncode(wikiName); - spaceName = urlEncode(spaceName); - pageName = urlEncode(pageName); - - ObjectResources objectresources = new ObjectResources(URLprefix, wikiName, spaceName, pageName); - if (isAuthenticated) { - objectresources.setAuthenticaion(username, password); - } - return objectresources.updateObject(objectClassname, ""+objectNumber, object); - - } - - /* - * (non-Javadoc) - * @see org.xwiki.android.xmlrpc.XWikiRestfulAPI#getAllObjects(java.lang.String, java.lang.String, java.lang.String) - */ - - @Override - public Objects getAllObjects(String wikiName, String spaceName, String pageName) throws RestConnectionException, RestException - { - wikiName = urlEncode(wikiName); - spaceName = urlEncode(spaceName); - pageName = urlEncode(pageName); - - ObjectResources objectresources = new ObjectResources(URLprefix, wikiName, spaceName, pageName); - if (isAuthenticated) { - objectresources.setAuthenticaion(username, password); - } - return objectresources.getAllObjects(); - } - - /* - * (non-Javadoc) - * @see org.xwiki.android.xmlrpc.XWikiRestfulAPI#getObjectsInClass(java.lang.String, java.lang.String, - * java.lang.String, java.lang.String) - */ - - @Override - public Objects getObjectsInClass(String wikiName, String spaceName, String pageName, String objectClassname) - throws RestConnectionException, RestException - { - wikiName = urlEncode(wikiName); - spaceName = urlEncode(spaceName); - pageName = urlEncode(pageName); - objectClassname = urlEncode(objectClassname); - - ObjectResources objectresources = new ObjectResources(URLprefix, wikiName, spaceName, pageName); - if (isAuthenticated) { - objectresources.setAuthenticaion(username, password); - } - return objectresources.getObjectsInClassname(objectClassname); - } - - /* - * (non-Javadoc) - * @see org.xwiki.android.xmlrpc.XWikiRestfulAPI#getObject(java.lang.String, java.lang.String, java.lang.String, - * java.lang.String, java.lang.String) - */ - - @Override - public Object getObject(String wikiName, String spaceName, String pageName, String objectClassname, int objectNumber) - throws RestConnectionException, RestException - { - wikiName = urlEncode(wikiName); - spaceName = urlEncode(spaceName); - pageName = urlEncode(pageName); - objectClassname = urlEncode(objectClassname); - String objectNumberStr = urlEncode("" + objectNumber); - - ObjectResources objectresources = new ObjectResources(URLprefix, wikiName, spaceName, pageName); - if (isAuthenticated) { - objectresources.setAuthenticaion(username, password); - } - return objectresources.getObject(objectClassname, objectNumberStr); - } - - /* - * (non-Javadoc) - * @see org.xwiki.android.xmlrpc.XWikiRestfulAPI#deleteObject(java.lang.String, java.lang.String, java.lang.String, - * java.lang.String, java.lang.String) - */ - - @Override - public String deleteObject(String wikiName, String spaceName, String pageName, String objectClassname, - String objectNumber) throws RestConnectionException, RestException - { - wikiName = urlEncode(wikiName); - spaceName = urlEncode(spaceName); - pageName = urlEncode(pageName); - objectClassname = urlEncode(objectClassname); - objectNumber = urlEncode(objectNumber); - - ObjectResources objectresources = new ObjectResources(URLprefix, wikiName, spaceName, pageName); - if (isAuthenticated) { - objectresources.setAuthenticaion(username, password); - } - return objectresources.deleteObject(objectClassname, objectNumber); - } - - /* - * (non-Javadoc) - * @see org.xwiki.android.xmlrpc.XWikiRestfulAPI#getObjectAllProperties(java.lang.String, java.lang.String, - * java.lang.String, java.lang.String, java.lang.String) - */ - - @Override - public Properties getObjectAllProperties(String wikiName, String spaceName, String pageName, - String objectClassname, String objectNumber) throws RestConnectionException, RestException - { - wikiName = urlEncode(wikiName); - spaceName = urlEncode(spaceName); - pageName = urlEncode(pageName); - objectClassname = urlEncode(objectClassname); - objectNumber = urlEncode(objectNumber); - - ObjectResources objectresources = new ObjectResources(URLprefix, wikiName, spaceName, pageName); - if (isAuthenticated) { - objectresources.setAuthenticaion(username, password); - } - return objectresources.getObjectProperties(objectClassname, objectNumber); - } - - /* - * (non-Javadoc) - * @see org.xwiki.android.xmlrpc.XWikiRestfulAPI#getObjectProperty(java.lang.String, java.lang.String, - * java.lang.String, java.lang.String, java.lang.String, java.lang.String) - */ - - @Override - public Property getObjectProperty(String wikiName, String spaceName, String pageName, String objectClassname, - String objectNumber, String propertyName) throws RestConnectionException, RestException - { - wikiName = urlEncode(wikiName); - spaceName = urlEncode(spaceName); - pageName = urlEncode(pageName); - objectClassname = urlEncode(objectClassname); - objectNumber = urlEncode(objectNumber); - propertyName = urlEncode(propertyName); - - ObjectResources objectresources = new ObjectResources(URLprefix, wikiName, spaceName, pageName); - if (isAuthenticated) { - objectresources.setAuthenticaion(username, password); - } - return objectresources.getObjectProperty(objectClassname, objectNumber, propertyName); - } - - /* - * (non-Javadoc) - * @see org.xwiki.android.xmlrpc.XWikiRestfulAPI#addProperty(java.lang.String, java.lang.String, java.lang.String, - * java.lang.String, java.lang.String, org.xwiki.android.resources.Property) - */ - - @Override - public String addObjectProperty(String wikiName, String spaceName, String pageName, String objectClassname, - String objectNumber, Property property) throws RestConnectionException, RestException - { - wikiName = urlEncode(wikiName); - spaceName = urlEncode(spaceName); - pageName = urlEncode(pageName); - objectClassname = urlEncode(objectClassname); - objectNumber = urlEncode(objectNumber); - - ObjectResources objectresources = new ObjectResources(URLprefix, wikiName, spaceName, pageName); - if (isAuthenticated) { - objectresources.setAuthenticaion(username, password); - } - return objectresources.addObjectProperty(objectClassname, objectNumber, property); - } - - //connection methods - - - @Override - public XWikiAPI getBaseAPI() - { - return this; - } - - @Override - public boolean isClosed() - { - return false; - } - - @Override - public void close() - { - Log.e(TAG, "not implemented: should release any resources: Also see that HttpConnector does not release resources"); - //httpclient.getConnectionManager().shutdown(); - //refer: http://hc.apache.org/httpcomponents-client-ga/tutorial/html/connmgmt.html - //throw new UnsupportedOperationException("should be releasing resources."); - } - - - -} diff --git a/xwiki-android-test-core/project.properties b/xwiki-android-test-core/project.properties index 01b98dd..0d7f4ae 100644 --- a/xwiki-android-test-core/project.properties +++ b/xwiki-android-test-core/project.properties @@ -12,4 +12,5 @@ # Project target. target=android-7 -android.library.reference.1=../xwiki-android-rest +android.library.reference.1=..\\xwiki-android-rest +android.library.reference.2=../xwiki-android-core diff --git a/xwiki-android-test-core/src/org/xwiki/android/core/test/TestTemplate.java b/xwiki-android-test-core/src/org/xwiki/android/core/test/TestTemplate.java index 2d3a066..d12a64c 100644 --- a/xwiki-android-test-core/src/org/xwiki/android/core/test/TestTemplate.java +++ b/xwiki-android-test-core/src/org/xwiki/android/core/test/TestTemplate.java @@ -1,12 +1,12 @@ package org.xwiki.android.core.test; -import org.xwiki.android.core.test.properties.Env; +import org.xwiki.android.core.test.properties.TestConstants; import org.xwiki.android.rest.RestConnectionException; -import org.xwiki.android.rest.XWikiAPI; import org.xwiki.android.rest.ral.DocumentRao; import org.xwiki.android.rest.ral.RESTfulManager; import org.xwiki.android.rest.ral.RaoException; import org.xwiki.android.rest.ral.XmlRESTFulManager; +import org.xwiki.android.rest.rpc.XWikiAPI; import org.xwiki.android.svc.cmn.LoginFacade; import org.xwiki.android.xmodel.entity.Document; @@ -17,7 +17,7 @@ public class TestTemplate extends AndroidTestCase { private static final String TAG = TestTemplate.class.getSimpleName(); - int count; + static int count=1; // test org.xwiki.android.test.fixture.teardown.env parameters. String serverUrl, username, password, wikiName, spaceName, pageName; @@ -29,21 +29,8 @@ public class TestTemplate extends AndroidTestCase // api used for output verification XWikiAPI api; - - public TestTemplate() - { - // things that need to run only one time. workaround for @BeforeClass - // obtain vars from Var class - username = Env.USERNAME; - password = Env.PASSWORD; - serverUrl = Env.URL; - - wikiName = Env.WIKI_NAME; - spaceName = Env.SPACE_NAME; - pageName = Env.PAGE_NAME; - count=0; - } + @@ -55,9 +42,19 @@ protected void setUp() throws Exception //run before each testxxxx; // + username = TestConstants.USERNAME; + password = TestConstants.PASSWORD; + serverUrl = TestConstants.SERVER_URL; + + wikiName = TestConstants.WIKI_NAME; + spaceName = TestConstants.SPACE_NAME; + pageName = TestConstants.PAGE_NAME; + count=0; + + rm = new XmlRESTFulManager(serverUrl, username, password); - api = rm.getConnection().getBaseAPI(); + api = rm.getRestConnector().getBaseAPI(); rao = rm.newDocumentRao(); doc = new Document(wikiName, spaceName, pageName); doc.setTitle(pageName); diff --git a/xwiki-android-test-core/src/org/xwiki/android/core/test/properties/Env.java b/xwiki-android-test-core/src/org/xwiki/android/core/test/properties/Env.java deleted file mode 100644 index 83f66cc..0000000 --- a/xwiki-android-test-core/src/org/xwiki/android/core/test/properties/Env.java +++ /dev/null @@ -1,40 +0,0 @@ -package org.xwiki.android.core.test.properties; - -public interface Env -{ - String WIKI_NAME = "xwiki"; - - String SPACE_NAME = "Blog"; - - String PAGE_NAME = "test2"; - - String TEMP_PAGE_NAME ="tempTestPage"; //used for create method tests. because page needss to be deleted for creation - - String URL = "10.0.2.2:8080"; - - String USERNAME = "superadmin"; - - String PASSWORD = "admin"; - - // String PAGE_VERSION = "1.0"; - - String COMMENT_ID = "0"; - - // String LANGUAGE = "null"; - - String CLASS_NAME = "Blog.BlogPostClass"; - - int OBJECT_NUMBER = 0; - - String OBJECT_PROPERTY_NAME = "content"; - - // String SEARCH_KEWORD = "test"; - - String TAG_WORD = "testTag"; - - String ATTACHMENT_NAME = "note.txt"; - - - - // String ATTACHMENT_VERSION = "1.0"; -} diff --git a/xwiki-android-test-core/src/org/xwiki/android/rest/ral/test/TestDocumentRaoCreate.java b/xwiki-android-test-core/src/org/xwiki/android/rest/ral/test/TestDocumentRaoCreate.java index 2cf7019..510510f 100644 --- a/xwiki-android-test-core/src/org/xwiki/android/rest/ral/test/TestDocumentRaoCreate.java +++ b/xwiki-android-test-core/src/org/xwiki/android/rest/ral/test/TestDocumentRaoCreate.java @@ -1,6 +1,7 @@ package org.xwiki.android.rest.ral.test; import java.io.File; +import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.PrintWriter; import java.util.List; @@ -8,18 +9,19 @@ import junit.framework.AssertionFailedError; import org.xwiki.android.context.XWikiApplicationContext; -import org.xwiki.android.core.test.properties.Env; +import org.xwiki.android.core.test.properties.TestConstants; import org.xwiki.android.resources.Comments; import org.xwiki.android.resources.Object; import org.xwiki.android.resources.Property; import org.xwiki.android.rest.PageResources; import org.xwiki.android.rest.RestConnectionException; import org.xwiki.android.rest.RestException; -import org.xwiki.android.rest.XWikiAPI; +import org.xwiki.android.rest.XWikiRestConnector; import org.xwiki.android.rest.ral.DocumentRao; import org.xwiki.android.rest.ral.RESTfulManager; import org.xwiki.android.rest.ral.RaoException; import org.xwiki.android.rest.ral.XmlRESTFulManager; +import org.xwiki.android.rest.rpc.XWikiAPI; import org.xwiki.android.svc.cmn.LoginFacade; import org.xwiki.android.xmodel.blog.XBlogPost; import org.xwiki.android.xmodel.entity.Attachment; @@ -48,7 +50,7 @@ public class TestDocumentRaoCreate extends AndroidTestCase DocumentRao rao; // api used for output verification - XWikiAPI api; + XWikiRestConnector api; // test inputs Document doc; @@ -60,38 +62,44 @@ public class TestDocumentRaoCreate extends AndroidTestCase Attachment a1; File af1; - public TestDocumentRaoCreate() - { - username = Env.USERNAME; - password = Env.PASSWORD; - serverUrl = Env.URL; - - wikiName = Env.WIKI_NAME; - spaceName = Env.SPACE_NAME; - pageName = Env.TEMP_PAGE_NAME; - attachmentName = Env.ATTACHMENT_NAME; - } - + @Override - protected void setUp() throws Exception + public void setUp() throws Exception { super.setUp(); + username = TestConstants.USERNAME; + password = TestConstants.PASSWORD; + serverUrl = TestConstants.SERVER_URL; + + wikiName = TestConstants.WIKI_NAME; + spaceName = TestConstants.SPACE_NAME; + pageName = TestConstants.CREATE_PAGE_NAME+"-"+count; + attachmentName = TestConstants.ATTACHMENT_NAME; + + rm = new XmlRESTFulManager(serverUrl, username, password); - api = rm.getConnection().getBaseAPI(); + api = rm.getRestConnector(); rao = rm.newDocumentRao(); doc = new Document(wikiName, spaceName, pageName); doc.setTitle(pageName); - // setup preconditions on serverside - if (count < 7) - api.deletePage(wikiName, spaceName, pageName); - if (count == 1) { + // setup preconditions on serverside //TODO: change as you add more methods and you need to keep the tempTestPage undeleted after a test. + api.deletePage(wikiName, spaceName, pageName); + + if (count == 8) {//make attachment file Application sys = XWikiApplicationContext.getInstance(); FileOutputStream fos = sys.openFileOutput(attachmentName, Context.MODE_WORLD_READABLE); PrintWriter writer = new PrintWriter(fos); writer.println("this is a text attachment."); writer.flush(); writer.close(); + FileInputStream fis=sys.openFileInput(attachmentName); + byte[] buff=new byte[30]; + int i=0; + while(i!=-1){ + i= fis.read(buff); + } + Log.d(TAG, new String(buff)); af1 = sys.getFileStreamPath(attachmentName); } Log.d(TAG, "setup test method:" + count); @@ -99,7 +107,7 @@ protected void setUp() throws Exception } @Override - protected void tearDown() throws Exception + public void tearDown() throws Exception { super.tearDown(); count++; @@ -291,17 +299,52 @@ public void testCreate_06_WithCmnts_SequenceCheck() throws Throwable } } - - // public void testCreate_07_WithAttachment() throws Throwable - // { - // - // Attachment a=new Attachment(attachmentName, af1); - // doc.addAttachment(a); - // rao.create(doc); - // assertNotNull(api.getPageAttachment(wikiName, spaceName, pageName, - // attachmentName)); - // - // - // - // } + + public void testCreate_07_WithCmnts_SequenceCheck2() throws Throwable + { + + c1 = new Comment("1"); + c2 = new Comment("2"); + c3 = new Comment("0"); + c3.setId(0); //here the set id is changed + c4 = new Comment("6"); + c4.setId(6); + + c1.addReplyComment(c2); + c3.addReplyComment(c4); + + doc.addComment(c1, true); + doc.setComment(c3); + doc.setComment(c4); + + rao.create(doc); + + boolean success = api.existsPage(wikiName, spaceName, pageName); + assertTrue(success); + if (success) { + Comments cmnts = api.getPageComments(wikiName, spaceName, pageName); + List clst = cmnts.comments; + assertEquals(4, clst.size()); + int replyto = clst.get(2).replyTo; + assertEquals(1, replyto); + replyto=clst.get(3).replyTo; + assertEquals(0, replyto); + + assertEquals("6", clst.get(3).text); + } + + } + + public void testCreate_08_WithAttachment() throws Throwable + { + assertNotNull("No file to upload as attachement. Set it up in setup method" ,af1); + Attachment a=new Attachment(attachmentName, af1); + doc.addAttachment(a); + rao.create(doc); + assertNotNull(api.getPageAttachment(wikiName, spaceName, pageName, + attachmentName)); + + + + } } diff --git a/xwiki-android-test-core/src/org/xwiki/android/rest/ral/test/TestDocumentRaoDelete.java b/xwiki-android-test-core/src/org/xwiki/android/rest/ral/test/TestDocumentRaoDelete.java index a4b26f7..93c5b5e 100644 --- a/xwiki-android-test-core/src/org/xwiki/android/rest/ral/test/TestDocumentRaoDelete.java +++ b/xwiki-android-test-core/src/org/xwiki/android/rest/ral/test/TestDocumentRaoDelete.java @@ -1,78 +1,81 @@ -//package org.xwiki.android.rest.ral.test; -// -//import org.xwiki.android.core.test.properties.Env; -//import org.xwiki.android.rest.RestConnectionException; -//import org.xwiki.android.rest.XWikiAPI; -//import org.xwiki.android.rest.ral.DocumentRao; -//import org.xwiki.android.rest.ral.RESTfulManager; -//import org.xwiki.android.rest.ral.RaoException; -//import org.xwiki.android.rest.ral.XmlRESTFulManager; -//import org.xwiki.android.svc.cmn.LoginFacade; -//import org.xwiki.android.xmodel.entity.Document; -// -//import android.test.AndroidTestCase; -//import android.util.Log; -// -//public class TestDocumentRaoDelete extends AndroidTestCase -//{ -// -// private static final String TAG = TestDocumentRaoDelete.class.getSimpleName(); -// int count; -// -// // test org.xwiki.android.test.fixture.teardown.env parameters. -// String serverUrl, username, password, wikiName, spaceName, pageName; -// -// // tested apis -// RESTfulManager rm; -// DocumentRao rao; -// Document doc; -// -// // api used for output verification -// XWikiAPI api; -// -// -// public TestDocumentRaoDelete() -// { -// // things that need to run only one time. workaround for @BeforeClass -// // obtain vars from Var class -// username = Env.USERNAME; -// password = Env.PASSWORD; -// serverUrl = Env.URL; -// -// wikiName = Env.WIKI_NAME; -// spaceName = Env.SPACE_NAME; -// pageName = Env.PAGE_NAME; -// count=0; -// } -// -// -// -// @Override -// protected void setUp() throws Exception -// { -// super.setUp(); -// rm = new XmlRESTFulManager(serverUrl, username, password); -// api = rm.getConnection().getBaseAPI(); -// rao = rm.newDocumentRao(); -// doc = new Document(wikiName, spaceName, pageName); -// doc.setTitle(pageName); -// } -// -// @Override -// protected void tearDown() throws Exception -// { -// super.tearDown(); -// count++; -// } -// -// public void testYourThing1() throws Throwable -// { -// assertTrue(true); -// } -// -// public void testYourThing2() throws Throwable -// { -// assertTrue(true); -// } -// -//} +package org.xwiki.android.rest.ral.test; + +import org.xwiki.android.core.test.properties.TestConstants; +import org.xwiki.android.resources.Page; +import org.xwiki.android.rest.RestConnectionException; +import org.xwiki.android.rest.XWikiRestConnector; +import org.xwiki.android.rest.ral.DocumentRao; +import org.xwiki.android.rest.ral.RESTfulManager; +import org.xwiki.android.rest.ral.RaoException; +import org.xwiki.android.rest.ral.XmlRESTFulManager; +import org.xwiki.android.rest.rpc.XWikiAPI; +import org.xwiki.android.svc.cmn.LoginFacade; +import org.xwiki.android.xmodel.entity.Document; + +import android.test.AndroidTestCase; +import android.util.Log; + +public class TestDocumentRaoDelete extends AndroidTestCase +{ + + private static final String TAG = TestDocumentRaoDelete.class.getSimpleName(); + static int count=1; + + // test org.xwiki.android.test.fixture.teardown.env parameters. + String serverUrl, username, password, wikiName, spaceName, pageName; + + // tested apis + RESTfulManager rm; + DocumentRao rao; + Document doc; + + // api used for output verification + XWikiRestConnector api; + + + + + + @Override + protected void setUp() throws Exception + { + super.setUp(); + username = TestConstants.USERNAME; + password = TestConstants.PASSWORD; + serverUrl = TestConstants.SERVER_URL; + + wikiName = TestConstants.WIKI_NAME; + spaceName = TestConstants.SPACE_NAME; + pageName = TestConstants.CREATE_PAGE_NAME; + + rm = new XmlRESTFulManager(serverUrl, username, password); + api = rm.getRestConnector(); + rao = rm.newDocumentRao(); + doc = new Document(wikiName, spaceName, pageName); + doc.setTitle(pageName); + Page p=new Page(); + p.setName(pageName); + p.setTitle(pageName); + api.addPage(wikiName, spaceName, pageName, p); + } + + @Override + protected void tearDown() throws Exception + { + super.tearDown(); + count++; + } + + public void testDelete01() throws Throwable + { + rao.delete(doc); + } + + public void testDelete02() throws Throwable + { + rao.delete(doc.getDocumentReference()); + } + + + +} diff --git a/xwiki-android-test-core/src/org/xwiki/android/rest/ral/test/TestDocumentRaoRetreive.java b/xwiki-android-test-core/src/org/xwiki/android/rest/ral/test/TestDocumentRaoRetreive.java index f8e9fcb..f9db7eb 100644 --- a/xwiki-android-test-core/src/org/xwiki/android/rest/ral/test/TestDocumentRaoRetreive.java +++ b/xwiki-android-test-core/src/org/xwiki/android/rest/ral/test/TestDocumentRaoRetreive.java @@ -1,102 +1,126 @@ -//package org.xwiki.android.rest.ral.test; -// -//import org.xwiki.android.core.test.properties.Env; -//import org.xwiki.android.resources.Object; -//import org.xwiki.android.resources.Property; -//import org.xwiki.android.rest.RestConnectionException; -//import org.xwiki.android.rest.XWikiAPI; -//import org.xwiki.android.rest.ral.DocumentRao; -//import org.xwiki.android.rest.ral.RESTfulManager; -//import org.xwiki.android.rest.ral.RaoException; -//import org.xwiki.android.rest.ral.XmlRESTFulManager; -//import org.xwiki.android.svc.cmn.LoginFacade; -//import org.xwiki.android.xmodel.blog.XBlogPost; -//import org.xwiki.android.xmodel.entity.Document; -// -//import android.test.AndroidTestCase; -//import android.util.Log; -// -//public class TestDocumentRaoRetreive extends AndroidTestCase -//{ -// -// private static final String TAG = TestDocumentRaoRetreive.class.getSimpleName(); -// // test org.xwiki.android.test.fixture.teardown.env parameters. -// String serverUrl, username, password, wikiName, spaceName, pageName,objectClassname,propertyName; -// int objectNumber; -// -// // tested apis -// RESTfulManager rm; -// DocumentRao rao; -// Document doc; -// -// // api used for output verification -// XWikiAPI api; -// -// static int count=0; -// -// public TestDocumentRaoRetreive() -// { -// super(); -// username = Env.USERNAME; -// password = Env.PASSWORD; -// serverUrl = Env.URL; -// -// wikiName = Env.WIKI_NAME; -// spaceName = Env.SPACE_NAME; -// pageName = Env.PAGE_NAME; -// objectClassname=Env.CLASS_NAME; -// objectNumber=Env.OBJECT_NUMBER; -// propertyName=Env.OBJECT_PROPERTY_NAME; -// count=0; -// } -// -// -// -// @Override -// protected void setUp() throws Exception -// { -// super.setUp(); -// rm = new XmlRESTFulManager(serverUrl, username, password); -// api = rm.getConnection().getBaseAPI(); -// rao = rm.newDocumentRao(); -// doc = new Document(wikiName, spaceName, pageName); -// doc.setTitle(pageName); -// //check precondition -// if(count==0){ -// boolean pre=api.existsPage(wikiName, spaceName, pageName); -// if(!pre){ -// Log.e(TAG, "preconditions failed. Please create a page to retreive. refer Env class"); -// } -// pre=api.existsObject(wikiName, spaceName, pageName, objectClassname, objectNumber); -// if(!pre){ -// Log.e(TAG, "preconditions failed. Please create a Object (blogPost) to retreive. refer Env class"); -// } -// -// Property p=api.getObjectProperty(wikiName, spaceName, pageName, objectClassname, objectNumber+"", propertyName); -// assertNotNull(p); -// assertTrue(pre); -// } -// } -// -// @Override -// protected void tearDown() throws Exception -// { -// super.tearDown(); -// } -// -// public void testRetreive() throws Throwable -// { -// boolean success; -// try { -// Document docRet=rao.retreive(doc); -// assertNotNull(docRet); -// XBlogPost blgPost=(XBlogPost) docRet.getObject(objectClassname+"/"+objectNumber); -// assertNotNull(blgPost); -// assertNotNull(blgPost.getContent()); -// }catch (RaoException e) { -// success=false; -// } -// -// } -// -//} +package org.xwiki.android.rest.ral.test; + +import java.util.Map; + +import org.xwiki.android.core.test.properties.TestConstants; +import org.xwiki.android.resources.Property; +import org.xwiki.android.rest.XWikiRestConnector; +import org.xwiki.android.rest.ral.DocumentRao; +import org.xwiki.android.rest.ral.RESTfulManager; +import org.xwiki.android.rest.ral.RaoException; +import org.xwiki.android.rest.ral.XmlRESTFulManager; +import org.xwiki.android.rest.rpc.XWikiAPI; +import org.xwiki.android.xmodel.blog.XBlogPost; +import org.xwiki.android.xmodel.entity.Attachment; +import org.xwiki.android.xmodel.entity.Comment; +import org.xwiki.android.xmodel.entity.Document; +import org.xwiki.android.xmodel.entity.Tag; + +import android.test.AndroidTestCase; +import android.util.Log; + +public class TestDocumentRaoRetreive extends AndroidTestCase +{ + + private static final String TAG = TestDocumentRaoRetreive.class.getSimpleName(); + // test org.xwiki.android.test.fixture.teardown.env parameters. + String serverUrl, username, password, wikiName, spaceName, pageName, objectClassname, propertyName; + int objectNumber; + + // tested apis + RESTfulManager rm; + DocumentRao rao; + Document doc; + + // api used for output verification + XWikiRestConnector api; + + static int count = 1; + + @Override + protected void setUp() throws Exception + { + super.setUp(); + username = TestConstants.USERNAME; + password = TestConstants.PASSWORD; + serverUrl = TestConstants.SERVER_URL; + + wikiName = TestConstants.WIKI_NAME; + spaceName = TestConstants.SPACE_NAME; + pageName = TestConstants.PAGE_NAME; + objectClassname = TestConstants.CLASS_NAME; + objectNumber = TestConstants.OBJECT_NUMBER; + propertyName = TestConstants.OBJECT_PROPERTY_NAME; + + rm = new XmlRESTFulManager(serverUrl, username, password); + api = rm.getRestConnector(); + rao = rm.newDocumentRao(); + doc = new Document(wikiName, spaceName, pageName); + doc.setTitle(pageName); + // check precondition + if (count == 0) { + boolean pre = api.existsPage(wikiName, spaceName, pageName); + assertTrue("preconditions failed. Please create a page to retreive. refer Env class", pre); + + pre = api.existsObject(wikiName, spaceName, pageName, objectClassname, objectNumber); + + assertTrue("preconditions failed. Please create a Object (blogPost) to retreive. refer Env class", pre); + + pre = api.existsPageComment(wikiName, spaceName, pageName, 0); + assertTrue("preconditions failed. Please create comments to retreive. refer Env class", pre); + + Property p = + api.getObjectProperty(wikiName, spaceName, pageName, objectClassname, objectNumber + "", propertyName); + assertNotNull(p); + assertTrue(pre); + } + } + + @Override + protected void tearDown() throws Exception + { + super.tearDown(); + } + + public void testRetreive_01() throws Throwable + { + boolean success; + try { + Document rdoc = rao.retreive(doc); + + //verifications + assertNotNull(rdoc); + Log.d(TAG, rdoc.toString()); + + XBlogPost blgPost = (XBlogPost) rdoc.getObject(objectClassname + "/" + objectNumber); + assertNotNull(blgPost); + assertNotNull(blgPost.getContent()); + + int numcmnts=rdoc.getAllComments().size(); + assertTrue(numcmnts>=2); + + Comment c=rdoc.getComment(0); + Comment c2=rdoc.getComment(1); + assertNotNull(c); + assertNotNull(c2); + assertTrue(c2.getReplyTo()==c.getId()); + + Tag t=rdoc.getTags().get(0); + assertNotNull(t); + + Map allAttatchments = rdoc.getAllAttatchments(); + assertTrue(allAttatchments.size()>0); + Attachment a=rdoc.getAttachment("a.png"); + assertNotNull(a); + + } catch (RaoException e) { + success = false; + } + + } + + public void testRetreive_02_inHistory(){ + + } + +} diff --git a/xwiki-android-test-core/src/org/xwiki/android/rest/ral/test/TestDocumentRaoUpdate.java b/xwiki-android-test-core/src/org/xwiki/android/rest/ral/test/TestDocumentRaoUpdate.java index a0cfb7d..f8cdaa9 100644 --- a/xwiki-android-test-core/src/org/xwiki/android/rest/ral/test/TestDocumentRaoUpdate.java +++ b/xwiki-android-test-core/src/org/xwiki/android/rest/ral/test/TestDocumentRaoUpdate.java @@ -1,99 +1,138 @@ -//package org.xwiki.android.rest.ral.test; -// -//import org.xwiki.android.core.test.properties.Env; -//import org.xwiki.android.rest.RestConnectionException; -//import org.xwiki.android.rest.XWikiAPI; -//import org.xwiki.android.rest.ral.DocumentRao; -//import org.xwiki.android.rest.ral.RESTfulManager; -//import org.xwiki.android.rest.ral.RaoException; -//import org.xwiki.android.rest.ral.XmlRESTFulManager; -//import org.xwiki.android.svc.cmn.LoginFacade; -//import org.xwiki.android.xmodel.blog.XBlogPost; -//import org.xwiki.android.xmodel.entity.Comment; -//import org.xwiki.android.xmodel.entity.Document; -// -//import android.test.AndroidTestCase; -//import android.util.Log; -// -//public class TestDocumentRaoUpdate extends AndroidTestCase -//{ -// -// private static final String TAG = TestDocumentRaoUpdate.class.getSimpleName(); -// // test org.xwiki.android.test.fixture.teardown.env parameters. -// String serverUrl, username, password, wikiName, spaceName, pageName; -// -// int count; -// -// // tested apis -// RESTfulManager rm; -// DocumentRao rao; -// Document doc; -// -// // api used for output verification -// XWikiAPI api; -// -// public TestDocumentRaoUpdate() -// { -// // things that need to run only one time. workaround for @BeforeClass -// // obtain vars from Var class -// username = Env.USERNAME; -// password = Env.PASSWORD; -// serverUrl = Env.URL; -// -// wikiName = Env.WIKI_NAME; -// spaceName = Env.SPACE_NAME; -// pageName = Env.PAGE_NAME; -// count = 0; -// } -// -// @Override -// protected void setUp() throws Exception -// { -// super.setUp(); -// rm = new XmlRESTFulManager(serverUrl, username, password); -// api = rm.getConnection().getBaseAPI(); -// rao = rm.newDocumentRao(); -// doc = new Document(wikiName, spaceName, pageName); -// doc.setTitle(pageName); -// } -// -// @Override -// protected void tearDown() throws Exception -// { -// super.tearDown(); -// count++; -// } -// -// public void testUpdate1() throws Throwable -// { -// boolean success = false; -// -// XBlogPost xb = new XBlogPost(); -// xb.setContent("edited"); -// xb.setNumber(0); -// doc.setObject(xb); -// -// try { -// rao.update(doc); -// } catch (RaoException e) { -// success = false; -// } -// assertTrue(success); -// -// } -// -// public void testUpdate2() throws Throwable -// { -// boolean success = false; -// -// Comment cmnt = new Comment("hi comment"); -// doc.addComment(cmnt); -// try { -// rao.update(doc); -// } catch (RaoException e) { -// success = false; -// } -// assertTrue(success); -// } -// -//} +package org.xwiki.android.rest.ral.test; + +import java.util.ArrayList; +import java.util.List; + +import org.xwiki.android.core.test.properties.TestConstants; +import org.xwiki.android.resources.Attribute; +import org.xwiki.android.resources.Objects; +import org.xwiki.android.resources.Page; +import org.xwiki.android.resources.Object; +import org.xwiki.android.resources.Property; +import org.xwiki.android.rest.RestConnectionException; +import org.xwiki.android.rest.XWikiRestConnector; +import org.xwiki.android.rest.ral.DocumentRao; +import org.xwiki.android.rest.ral.RESTfulManager; +import org.xwiki.android.rest.ral.RaoException; +import org.xwiki.android.rest.ral.XmlRESTFulManager; +import org.xwiki.android.rest.rpc.XWikiAPI; +import org.xwiki.android.svc.cmn.LoginFacade; +import org.xwiki.android.xmodel.blog.XBlogPost; +import org.xwiki.android.xmodel.entity.Comment; +import org.xwiki.android.xmodel.entity.Document; + +import android.test.AndroidTestCase; +import android.util.Log; + +public class TestDocumentRaoUpdate extends AndroidTestCase +{ + + private static final String TAG = TestDocumentRaoUpdate.class.getSimpleName(); + // test org.xwiki.android.test.fixture.teardown.env parameters. + String serverUrl, username, password, wikiName, spaceName, pageName; + + static int count = 1; + + // tested apis + RESTfulManager rm; + DocumentRao rao; + Document doc; + + // api used for output verification + XWikiRestConnector api; + + @Override + protected void setUp() throws Exception + { + super.setUp(); + username = TestConstants.USERNAME; + password = TestConstants.PASSWORD; + serverUrl = TestConstants.SERVER_URL; + + wikiName = TestConstants.WIKI_NAME; + spaceName = TestConstants.SPACE_NAME; + pageName = TestConstants.CREATE_PAGE_NAME + "-" + count; + + rm = new XmlRESTFulManager(serverUrl, username, password); + api = rm.getRestConnector(); + rao = rm.newDocumentRao(); + doc = new Document(wikiName, spaceName, pageName); + doc.setTitle(pageName); + + // setup external fixture + Page page = new Page(); + page.setName(pageName); + page.setSpace(spaceName); + page.setWiki(wikiName); + api.addPage(wikiName, spaceName, pageName, page); + Object o = new Object(); + o.setClassName("Blog.BlogPostClass"); + Property content = new Property(); + content.attributes = new ArrayList();// needed by simple xml serializer + Property category = new Property(); + category.attributes = new ArrayList(); + Property published = new Property(); + published.attributes = new ArrayList(); + content.name = "content"; + content.value = "BlogPost in to be updated document"; + category.setName("category"); + category.setValue("Blog.Other"); + published.setName("published"); + published.setValue("1"); + o.withProperties(content, category, published); + api.addObject(wikiName, spaceName, pageName, o); + + } + + @Override + protected void tearDown() throws Exception + { + super.tearDown(); + count++; + } + + public void testUpdate_01() throws Throwable + { + + XBlogPost xb = new XBlogPost(); + xb.setContent("edited"); + xb.setNumber(0); + doc.setObject(xb); + rao.update(doc); + + // verify + boolean success = false; + Object object = api.getObject(wikiName, spaceName, pageName, "Blog.BlogPostClass", 0); + for (Property p : object.getProperties()) { + if (p.name.equals("content")) { + success = p.getValue().equals("edited"); + } + } + assertTrue(success); + + } + + public void testUpdate_02() throws Throwable + { + boolean success = true; + + //get state of external fixture page. + int numCmntsBefore=0; + List comments = api.getPageComments(wikiName, spaceName, pageName).comments; + if(comments!=null){ + numCmntsBefore=comments.size(); + } + + //tested logic + Comment cmnt = new Comment("hi comment"); + doc.addComment(cmnt); + rao.update(doc); + + //verify if new comment was added. + int numCmntsAfter =api.getPageComments(wikiName, spaceName, pageName).comments.size(); + assertTrue(numCmntsAfter == numCmntsBefore+1); + } + + //public void testUp + +} diff --git a/xwiki-android-test-rest/src/org/xwiki/android/test/rest/env/TestConstants.java b/xwiki-android-test-rest/src/org/xwiki/android/test/rest/env/TestConstants.java index 4143ef9..4dedac4 100644 --- a/xwiki-android-test-rest/src/org/xwiki/android/test/rest/env/TestConstants.java +++ b/xwiki-android-test-rest/src/org/xwiki/android/test/rest/env/TestConstants.java @@ -7,7 +7,7 @@ public class TestConstants { - public static final int SERVER_INDEX; //not used. + public static final int SERVER_INDEX; public static final String HOST = "10.0.2.2"; public static final int PORT = 8080; //actual port is port+server_index public static final String SCHEME="http://"; @@ -18,12 +18,9 @@ public class TestConstants { //external test fixture. public static final String WIKI_NAME = "xwiki"; - public static final String SPACE_NAME = "Blog"; - public static final String PAGE_NAME = "test2"; - - public static final String PAGE_VERSION = "1.1"; + public static final String PAGE_VERSION = "1.1"; public static final String COMMENT_ID = "0"; public static final String COMMENT_TEXT = "hi"; diff --git a/xwiki-rest-model/xwiki-rest-model-simplexml/src/org/xwiki/android/resources/Comment.java b/xwiki-rest-model/xwiki-rest-model-simplexml/src/org/xwiki/android/resources/Comment.java index 0f17056..a342448 100644 --- a/xwiki-rest-model/xwiki-rest-model-simplexml/src/org/xwiki/android/resources/Comment.java +++ b/xwiki-rest-model/xwiki-rest-model-simplexml/src/org/xwiki/android/resources/Comment.java @@ -53,7 +53,7 @@ @Root @Namespace(reference="http://www.xwiki.org") -public class Comment extends LinkCollection +public class Comment extends LinkCollection implements Resource { @Element(required = false) public int id; diff --git a/xwiki-rest-model/xwiki-rest-model-simplexml/src/org/xwiki/android/resources/Page.java b/xwiki-rest-model/xwiki-rest-model-simplexml/src/org/xwiki/android/resources/Page.java index d564e50..8ff1f75 100644 --- a/xwiki-rest-model/xwiki-rest-model-simplexml/src/org/xwiki/android/resources/Page.java +++ b/xwiki-rest-model/xwiki-rest-model-simplexml/src/org/xwiki/android/resources/Page.java @@ -55,7 +55,7 @@ @Root @Namespace(reference = "http://www.xwiki.org") -public class Page extends PageSummary +public class Page extends PageSummary { @Element(required = false) diff --git a/xwiki-rest-model/xwiki-rest-model-simplexml/src/org/xwiki/android/resources/PageSummary.java b/xwiki-rest-model/xwiki-rest-model-simplexml/src/org/xwiki/android/resources/PageSummary.java index 4d5f1dd..68bdb69 100644 --- a/xwiki-rest-model/xwiki-rest-model-simplexml/src/org/xwiki/android/resources/PageSummary.java +++ b/xwiki-rest-model/xwiki-rest-model-simplexml/src/org/xwiki/android/resources/PageSummary.java @@ -58,7 +58,7 @@ @Root @Namespace(reference = "http://www.xwiki.org") -public class PageSummary extends LinkCollection +public class PageSummary extends LinkCollection implements Resource { @Element(required = false) @@ -150,11 +150,11 @@ public String getWiki() /** * Sets the value of the wiki property. * - * @param value allowed object is {@link String } + * @param wikiName allowed object is {@link String } */ - public void setWiki(String value) + public void setWiki(String wikiName) { - this.wiki = value; + this.wiki = wikiName; } /** @@ -170,11 +170,11 @@ public String getSpace() /** * Sets the value of the space property. * - * @param value allowed object is {@link String } + * @param spaceName allowed object is {@link String } */ - public void setSpace(String value) + public void setSpace(String spaceName) { - this.space = value; + this.space = spaceName; } /** @@ -190,11 +190,11 @@ public String getName() /** * Sets the value of the name property. * - * @param value allowed object is {@link String } + * @param name allowed object is {@link String } */ - public void setName(String value) + public void setName(String name) { - this.name = value; + this.name = name; } /**