diff --git a/xwiki-android-client/res/layout/blogmain.xml b/xwiki-android-client/res/layout/blogmain.xml
index 61d37fb..2ddec5e 100644
--- a/xwiki-android-client/res/layout/blogmain.xml
+++ b/xwiki-android-client/res/layout/blogmain.xml
@@ -9,5 +9,11 @@
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="New Post" />
+
+
\ No newline at end of file
diff --git a/xwiki-android-client/src/org/xwiki/android/client/blog/Blogger.java b/xwiki-android-client/src/org/xwiki/android/client/blog/Blogger.java
index 0070837..bddeb07 100644
--- a/xwiki-android-client/src/org/xwiki/android/client/blog/Blogger.java
+++ b/xwiki-android-client/src/org/xwiki/android/client/blog/Blogger.java
@@ -1,43 +1,123 @@
package org.xwiki.android.client.blog;
+
import org.xwiki.android.client.R;
import org.xwiki.android.client.R.layout;
import org.xwiki.android.components.login.LoginActivity;
+import org.xwiki.android.rest.ral.RaoException;
+import org.xwiki.android.rest.reference.DocumentReference;
+import org.xwiki.android.svc.blog.BlogDocument;
+import org.xwiki.android.svc.xmodel.DocumentRemoteSvcCallbacks;
+import org.xwiki.android.svc.xmodel.DocumentSvc;
+import org.xwiki.android.svc.xmodel.DocumentSvcImpl;
+import org.xwiki.android.xmodel.entity.Document;
import android.app.Activity;
+import android.app.Dialog;
+import android.app.ProgressDialog;
+import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
+import android.view.LayoutInflater;
import android.view.View;
+import android.view.WindowManager;
import android.view.View.OnClickListener;
+import android.widget.ArrayAdapter;
+import android.widget.AutoCompleteTextView;
import android.widget.Button;
+import android.widget.EditText;
+import android.widget.Toast;
+
+public class Blogger extends Activity implements OnClickListener
+{
+
+ private static final int REQUEST_CODE_EDITPOST = 0;
+
+ private Button btn_newpost,btn_retreive;
+ private EditText etPageName;
+
+ private Dialog ret_dialog;
+ private ProgressDialog progDialog;
+
+ private DocumentSvc dsvc;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState)
+ {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.blogmain);// show loading screen
+ // startActivity(new Intent(this,BlogPrefernces.class));
+ btn_newpost = (Button) findViewById(R.id.btn_newPost);
+ btn_newpost.setOnClickListener(this);
+ btn_retreive = (Button) findViewById(R.id.blg_btn_retreive);
+ btn_retreive.setOnClickListener(this);
+
+ dsvc=new DocumentSvcImpl();
+ }
+
+ public void onClick(View v)
+ {
+ if (v.getId() == R.id.btn_newPost) {
+ Intent intent = new Intent(this, EditPostActivity.class);
+ startActivityForResult(intent, REQUEST_CODE_EDITPOST);
+ } else if (v.getId() == R.id.blg_btn_retreive) {
+ showRetreiveDialog();
+ }
+
+ }
+
+ @Override
+ protected void onActivityResult(int requestCode, int resultCode, Intent data)
+ {
+ if (requestCode == REQUEST_CODE_EDITPOST) {
+
+ }
+ }
+
+ private void retreiveAndLaunchEditDoc()
+ {
+
+ }
+
+ private void showRetreiveDialog()
+ {
+ ret_dialog = new Dialog(this);
+ ret_dialog.getWindow().setFlags(WindowManager.LayoutParams.FLAG_BLUR_BEHIND,
+ WindowManager.LayoutParams.FLAG_BLUR_BEHIND);
+ ret_dialog.setTitle("Page to retreive");
+ LayoutInflater li = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
+ View dialogView = li.inflate(R.layout.blog_retreive_dialog, null);
+ ret_dialog.setContentView(dialogView);
+ ret_dialog.show();
+
+ Button okBtn = (Button) dialogView.findViewById(R.id.blg_ret_btn_ok);
+ etPageName = (EditText) dialogView.findViewById(R.id.blg_ret_et_pageName);
-public class Blogger extends Activity implements OnClickListener {
-
- private static final int REQUEST_CODE_EDITPOST = 0;
-
-
- private Button btn_newpost;
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.blogmain);//show loading screen
- //startActivity(new Intent(this,BlogPrefernces.class));
- btn_newpost=(Button) findViewById(R.id.btn_newPost);
- btn_newpost.setOnClickListener(this);
- }
-
- public void onClick(View v) {
- if(v.getId()==R.id.btn_newPost){
- Intent intent=new Intent(this,EditPostActivity.class);
- startActivityForResult(intent, REQUEST_CODE_EDITPOST);
- }
- }
-
- @Override
- protected void onActivityResult(int requestCode, int resultCode, Intent data) {
- if(requestCode==REQUEST_CODE_EDITPOST){
-
- }
- }
-
+ okBtn.setOnClickListener(new OnClickListener()
+ {
+ @Override
+ public void onClick(View v)
+ {
+ DocumentReference dref=new DocumentReference("xwiki","Blog",etPageName.getText().toString());
+ DocumentRemoteSvcCallbacks clbk=new DocumentRemoteSvcCallbacks()
+ {
+ @Override
+ public void onFullyRetreived(Document res, boolean success, RaoException ex)
+ {
+ if(success){
+ ret_dialog.dismiss();
+ progDialog.dismiss();
+ Intent i=new Intent(Blogger.this,EditPostActivity.class);
+ i.putExtra(EditPostActivity.ARG_UPDATE_DOC, res);
+ startActivity(i);
+ }else{
+ progDialog.dismiss();
+ }
+
+ }
+ };
+ progDialog=ProgressDialog.show(Blogger.this, "Processing", "Fetching document from server");
+ dsvc.retreive(dref, clbk);
+ }
+ });
+ }
}
diff --git a/xwiki-android-client/src/org/xwiki/android/client/blog/EditPostActivity.java b/xwiki-android-client/src/org/xwiki/android/client/blog/EditPostActivity.java
index d897dfa..a7df677 100644
--- a/xwiki-android-client/src/org/xwiki/android/client/blog/EditPostActivity.java
+++ b/xwiki-android-client/src/org/xwiki/android/client/blog/EditPostActivity.java
@@ -1,21 +1,17 @@
package org.xwiki.android.client.blog;
-import java.io.Serializable;
-import java.util.List;
-
-import org.xwiki.android.blog.svc.BlogDocument;
+import org.xwiki.android.svc.blog.BlogDocument;
+import org.xwiki.android.xmodel.entity.Document;
import org.xwiki.android.client.R;
-import org.xwiki.android.components.login.LoginActivity;
import org.xwiki.android.context.XWikiApplicationContext;
import org.xwiki.android.context.XWikiApplicationContextAPI;
-import org.xwiki.android.fileStore.FSDocumentReference;
-
import android.app.Activity;
import android.app.Dialog;
import android.app.ProgressDialog;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
+import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
@@ -28,8 +24,12 @@
public class EditPostActivity extends Activity implements OnClickListener {
+ public static final String ARG_UPDATE_DOC="UPDATE_DOC";
+
private static final int REQUEST_CODE_LOADSAVEDPOSTS=0;
+ private final String TAG=this.getClass().getSimpleName();
+
private Button btnSave,btnLoad,btnPost,btnPublish;
private BlogDocument mydoc;
private BlogDocument.BlogDocumentRemoteCallbacks myRmtClbks;
@@ -57,7 +57,16 @@ protected void onCreate(Bundle savedInstanceState) {
//show dialog to get page name, category
- showDialog();
+ Document d=(Document) getIntent().getSerializableExtra("UPDATE_DOC");
+ if(d!=null){
+ mydoc=new BlogDocument(d);
+ etPost.setText(mydoc.getContent());
+ Log.d(TAG,mydoc.getContent());
+ }else{
+ showDialog();
+ }
+
+
@@ -104,13 +113,16 @@ protected void onActivityResult(int requestCode, int resultCode, Intent data)
{
if(resultCode==RESULT_OK){
if(requestCode==REQUEST_CODE_LOADSAVEDPOSTS){
+ XWikiApplicationContextAPI ctx=XWikiApplicationContext.getInstance();
+ mydoc=(BlogDocument) ctx.pop(LoadSavedPostsActivity.RET_BLOGDOC);
etPost.setText(mydoc.getContent());
}
}
}
- public void onClick(View v) {
+ @Override
+ public void onClick(View v) {
if (v.getId()==R.id.btnSave) {
mydoc.setContent(etPost.getText().toString());
@@ -118,8 +130,6 @@ public void onClick(View v) {
}else if(v.getId()==R.id.btnLoad){
Intent i=new Intent(this,LoadSavedPostsActivity.class);
- XWikiApplicationContextAPI ctx=(XWikiApplicationContextAPI) getApplication();
- ctx.put("blgDoc", mydoc);
startActivityForResult(i,REQUEST_CODE_LOADSAVEDPOSTS);
}else if(v.getId()==R.id.btnPost){
diff --git a/xwiki-android-client/src/org/xwiki/android/client/blog/LoadSavedPostsActivity.java b/xwiki-android-client/src/org/xwiki/android/client/blog/LoadSavedPostsActivity.java
index 4d22874..5be47ab 100644
--- a/xwiki-android-client/src/org/xwiki/android/client/blog/LoadSavedPostsActivity.java
+++ b/xwiki-android-client/src/org/xwiki/android/client/blog/LoadSavedPostsActivity.java
@@ -1,14 +1,24 @@
package org.xwiki.android.client.blog;
import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+
+
-import org.xwiki.android.blog.svc.BlogDocument;
-import org.xwiki.android.blog.svc.BlogDocument.BlogDocumentLocalCallbacks;
import org.xwiki.android.context.XWikiApplicationContext;
import org.xwiki.android.context.XWikiApplicationContextAPI;
import org.xwiki.android.fileStore.FSDocumentReference;
-import org.xwiki.android.xmodel.svc.DocumentSvc;
-import org.xwiki.android.xmodel.svc.DocumentSvcImpl;
+import org.xwiki.android.svc.blog.BlogDocument;
+
+import org.xwiki.android.svc.xmodel.DocumentLocalSvcCallbacks;
+import org.xwiki.android.svc.xmodel.DocumentLocalSvcs;
+import org.xwiki.android.svc.xmodel.DocumentSvc;
+import org.xwiki.android.svc.xmodel.DocumentSvcImpl;
+import org.xwiki.android.xmodel.blog.XBlogPost;
+import org.xwiki.android.xmodel.entity.Document;
+
import android.app.ListActivity;
import android.app.ProgressDialog;
@@ -17,13 +27,15 @@
import android.widget.ArrayAdapter;
import android.widget.ListView;
-public class LoadSavedPostsActivity extends ListActivity
-{
- private LoadSavedPostsActivity activityCtx;
- private BlogDocumentLocalCallbacks clbk;
- private BlogDocument doc;
+public class LoadSavedPostsActivity extends ListActivity
+{
+ public static final String RET_BLOGDOC="RET_VALUE_DOC";
+
+ private DocumentLocalSvcCallbacks clbk;
+
+ private BlogDocument rsltDoc;
private List refList;
@@ -34,12 +46,10 @@ protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
DocumentSvc svc = new DocumentSvcImpl();
- activityCtx = this;
- XWikiApplicationContextAPI ctx=(XWikiApplicationContext)getApplicationContext();
- doc = (BlogDocument) ctx.pop("blgDoc");
init();
- doc.listBlogDocuments(clbk);
-
+ svc.listBySpace("Blog", clbk);
+ // svc.listByTag("SavedBlogPost",clbk);
+
}
@Override
@@ -47,16 +57,17 @@ protected void onListItemClick(ListView l, View v, int position, long id)
{
FSDocumentReference fsref = refList.get(position);
myProgressDialog = ProgressDialog.show(this, "loading", "Please wait...", true);
- doc.load(fsref, clbk);
+ DocumentLocalSvcs svc=new DocumentSvcImpl();
+ svc.load(fsref, clbk);
}
private void init()
{
- clbk = doc.new BlogDocumentLocalCallbacks()
+ clbk = new DocumentLocalSvcCallbacks()
{
-
+
@Override
- public void onListingComplete(List rslts)
+ public void onListingComplete(List rslts, Map matchedby)
{
refList = rslts;
String[] list = new String[rslts.size()];
@@ -66,18 +77,23 @@ public void onListingComplete(List rslts)
}
ArrayAdapter adapter =
- new ArrayAdapter(activityCtx, android.R.layout.simple_list_item_1, list);
+ new ArrayAdapter(LoadSavedPostsActivity.this, android.R.layout.simple_list_item_1, list);
setListAdapter(adapter);
}
@Override
- public void onBlogPostLoaded()
+ public void onLoadComplete(Document entity)
{
myProgressDialog.dismiss();
setResult(RESULT_OK);
+ rsltDoc=new BlogDocument(entity);
+ XWikiApplicationContextAPI ctx=XWikiApplicationContext.getInstance();
+ ctx.put(RET_BLOGDOC, rsltDoc);
finish();
}
};
}
}
+
+
diff --git a/xwiki-android-client/src/org/xwiki/android/client/dev/QuickTest.java b/xwiki-android-client/src/org/xwiki/android/client/dev/QuickTest.java
index 9f968cd..eb7d86d 100644
--- a/xwiki-android-client/src/org/xwiki/android/client/dev/QuickTest.java
+++ b/xwiki-android-client/src/org/xwiki/android/client/dev/QuickTest.java
@@ -7,8 +7,7 @@
import org.xwiki.android.context.XWikiApplicationContext;
import org.xwiki.android.dal.EntityManager;
-import org.xwiki.android.ral.RESTfulManager;
-import org.xwiki.android.ral.XmlRESTFulManager;
+
import org.xwiki.android.xmodel.entity.Document;
import com.j256.ormlite.dao.Dao;
diff --git a/xwiki-android-components/src/org/xwiki/android/components/login/LoginActivity.java b/xwiki-android-components/src/org/xwiki/android/components/login/LoginActivity.java
index d69adce..4726796 100644
--- a/xwiki-android-components/src/org/xwiki/android/components/login/LoginActivity.java
+++ b/xwiki-android-components/src/org/xwiki/android/components/login/LoginActivity.java
@@ -23,11 +23,12 @@
import java.util.ArrayList;
import java.util.List;
-import org.xwiki.android.cmnSvc.LoginFacade;
+
import org.xwiki.android.components.IntentExtra;
import org.xwiki.android.components.R;
import org.xwiki.android.dal.EntityManager;
import org.xwiki.android.rest.HttpConnector;
+import org.xwiki.android.svc.cmn.LoginFacade;
import org.xwiki.android.entity.*;
import com.j256.ormlite.dao.Dao;
diff --git a/xwiki-android-core/src/org/xwiki/android/bgsvcs/SyncBackgroundService.java b/xwiki-android-core/src/org/xwiki/android/bgsvcs/SyncBackgroundService.java
index 436afd5..4535260 100644
--- a/xwiki-android-core/src/org/xwiki/android/bgsvcs/SyncBackgroundService.java
+++ b/xwiki-android-core/src/org/xwiki/android/bgsvcs/SyncBackgroundService.java
@@ -2,6 +2,7 @@
import java.io.IOException;
import java.sql.SQLException;
+import java.util.Date;
import java.util.List;
import java.util.Timer;
import java.util.TimerTask;
@@ -13,12 +14,12 @@
import org.xwiki.android.fileStore.DocumentFao;
import org.xwiki.android.fileStore.FSDocumentReference;
import org.xwiki.android.fileStore.FileStoreManager;
-import org.xwiki.android.ral.DocumentRao;
-import org.xwiki.android.ral.RESTfulManager;
-import org.xwiki.android.ral.RaoException;
-import org.xwiki.android.rest.RestConnectorException;
+import org.xwiki.android.rest.RestConnectionException;
+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.svc.xmodel.DocumentRemoteSvcCallbacks;
import org.xwiki.android.xmodel.entity.Document;
-import org.xwiki.android.xmodel.svc.DocumentRemoteSvcCallbacks;
import android.app.Service;
import android.content.Intent;
@@ -59,6 +60,7 @@ public void run()
{
XWikiApplicationContext ctx=XWikiApplicationContext.getInstance();
EntityManager em=ctx.newEntityManager();
+ boolean allOk=true;
try {
Dao dao = em.getDao(SyncOutEntity.class);
List list=dao.queryForAll();
@@ -79,20 +81,28 @@ public void onCreated(Document res, boolean success,RaoException ex) {
Document doc=fao.load(ref);
try {
rao.create(doc);
- } catch (RestConnectorException e) {
+ dao.delete(s);
+ } catch (RestConnectionException e) {
+ allOk=false;
+ s.setLastTried(new Date());
+ dao.update(s);
e.printStackTrace();
break;//abort sync. retry after SYNC_PERIOD
} catch (RaoException e) {
//doc may be already created.
try {
rao.update(doc);
- } catch (RestConnectorException e1) {
+ dao.delete(s);
+ } catch (RestConnectionException e1) {
+ allOk=false;
+ s.setLastTried(new Date());
+ dao.update(s);
e1.printStackTrace();
break;
} catch (RaoException e1) {
// we cannot do an update also.
//donot delete and recreate. Just mark failed.
- s.setStatus(StatusType.FAILED);
+ s.setStatus(StatusType.ABORTED);
dao.update(s);
e1.printStackTrace();
}
diff --git a/xwiki-android-core/src/org/xwiki/android/blog/svc/BlogDocument.java b/xwiki-android-core/src/org/xwiki/android/blog/svc/BlogDocument.java
deleted file mode 100644
index b82f68e..0000000
--- a/xwiki-android-core/src/org/xwiki/android/blog/svc/BlogDocument.java
+++ /dev/null
@@ -1,188 +0,0 @@
-package org.xwiki.android.blog.svc;
-
-import java.io.IOException;
-import java.io.Serializable;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import org.xwiki.android.blog.xobj.XBlogPost;
-import org.xwiki.android.fileStore.FSDocumentReference;
-import org.xwiki.android.ral.RaoException;
-import org.xwiki.android.rest.RestConnectorException;
-import org.xwiki.android.xmodel.entity.Document;
-import org.xwiki.android.xmodel.entity.Document;
-import org.xwiki.android.xmodel.svc.DocumentLocalSvcCallbacks;
-import org.xwiki.android.xmodel.svc.DocumentSvc;
-import org.xwiki.android.xmodel.svc.DocumentRemoteSvcCallbacks;
-import org.xwiki.android.xmodel.svc.DocumentSvcImpl;
-
-/**
- * @author xwiki gsoc 2012 DEMO :Low lvl Service API usage Demo. Demo class. To show usage of Document, DocumentService
- * APIs. Just to make things simple, BlogDocument class has no separation of concerns such as represent model vs
- * services.
- */
-public class BlogDocument implements Serializable
-{
- public static final String SAVE_TAG="svdBlgPst";
- Document doc;
-
- XBlogPost blgPost;
- String xBlogPostType="Blog.BlogPostClass";
- DocumentSvc docsvc;
-
- public BlogDocument(String wikiName, String spaceName, String pageName, String category)
- {
- doc = new Document(wikiName, spaceName, pageName);
- blgPost = new XBlogPost();
- doc.addObject(blgPost);
- doc.setTitle(doc.getSimpleName());
- blgPost.setTitle(doc.getTitle());
- blgPost.setCategory(category);
- blgPost.setHidden(false);
-
-
- docsvc = new DocumentSvcImpl();
- // DocumentSvc construction code was not sent to XWikiApplication Context. Rationale: We will eventually go to
- // Android native Bind Services.
- // The service connection handling should be done at this layer.Then the logic for constructing the service is
- // transformed to that of binding to a service.
- }
-
- // demo: explain
- // It is the blog svc layers knowledge that the content should go to a XBlogPost(-->BlogPostClass in Xwiki
- // Enterprise) object.
- public void setContent(String content)
- {
- blgPost.setContent(content);// blgPost is the XBlogPost obj in the doc.
- }
-
- public String getContent(){
- return blgPost.getContent();
- }
-
- /**
- * @param clbk The above call back is implemented in the activity and passed to post method.It is because posting is
- * done asynchronously. Activity is notified of the progress through the callback. ( BlogDocumentCallback
- * associates with UI threads Looper.)
- */
- public void post(BlogDocumentRemoteCallbacks clbk)
- {
- blgPost.setPublished(false);
- docsvc.create(doc, clbk);
- }
-
- public void publish(BlogDocumentRemoteCallbacks clbk)
- {
- blgPost.setPublished(true);
- docsvc.create(doc, clbk);
- }
-
- public void save(){
- docsvc.save(doc, SAVE_TAG, null);
- }
-
- public void load(FSDocumentReference fsref, BlogDocumentLocalCallbacks clbk){
- docsvc.load(fsref,clbk);
- }
-
- public void listBlogDocuments(BlogDocumentLocalCallbacks clbk)
- {
- docsvc.listBySpace("Blog", clbk);
- //svc.listByTag("SavedBlogPost");
- }
-
-
-
- /*
- * demo: explain. * Also that page's title must be set.(Although this validation constraint is low level, validation
- * is not added to Document object to save performance. API user should remember to fill them.The server will send
- * back an error and in the android system there is a runtime RestAPIUsageException) The title property of XBlogPost
- * object should also be filled.However this is blog svc layer knowledge.
- */
- private void initializeDoc()
- {
-
- }
-
- /**
- *
- * for remote restful method results.
- *
- */
- public abstract class BlogDocumentRemoteCallbacks extends DocumentRemoteSvcCallbacks
- {
- @Override
- public void onCreated(Document res, boolean success, RaoException ex)
- {
- if (success) {
- onBlogPostSent(true);
- } else {
- if (ex != null) {// document was already in the server.
- // we can either tell the user, or simply
- docsvc.delete(doc.getDocumentReference(), this);
- // we have to delete and create.
- // If we want to update we need to retreive the original document first.
- // If the whole doc is not needed, we can use a Rao to update the single object.
- docsvc.create(doc, this);
- }
- }
- }
-
- @Override
- public void handleException(RestConnectorException e)
- {
- // SyncServic.syncLater(doc)
- docsvc.save(doc, null, null);// !!! unending loop if file saving is not successful, and u pass 'this' as
- // callback ;-)
- onBlogPostSent(false);
- }
-
- // define absract method for the activity to put it's logic in.
-
- /**
- * if success is false, Don't worry. Doc has been stored in the local device and sent for the sync service.(yet
- * to impl ;-))
- */
- public abstract void onBlogPostSent(boolean success);
-
-
-
-
-
- }
- /**
- *
- * for local file store callbacks.
- *
- */
- public abstract class BlogDocumentLocalCallbacks extends DocumentLocalSvcCallbacks{
- //
- //for filestore callbacks
- //
-
- @Override
- public void onListingComplete(List rslts, Map matchedby){
- onListingComplete(rslts);
- }
-
- @Override
- public void onLoadComplete(Document entity){
- doc=(Document)entity;
- String blgPostKey="";
- Set keys= doc.getAllObjects().keySet();
- for(String key:keys){
- if(key.startsWith(xBlogPostType)){
- blgPostKey=key;
- break;
- }
- }
- blgPost=(XBlogPost) doc.getObject(blgPostKey);
- onBlogPostLoaded();
- }
-
- //make it simple for the activities to implement.
- public abstract void onListingComplete(List rslts);
- public abstract void onBlogPostLoaded();
- }
-}
diff --git a/xwiki-android-core/src/org/xwiki/android/blog/xobj/XBlogPost.java b/xwiki-android-core/src/org/xwiki/android/blog/xobj/XBlogPost.java
deleted file mode 100644
index 2589b6c..0000000
--- a/xwiki-android-core/src/org/xwiki/android/blog/xobj/XBlogPost.java
+++ /dev/null
@@ -1,236 +0,0 @@
-package org.xwiki.android.blog.xobj;
-
-import java.util.Date;
-
-import org.xwiki.android.xmodel.xobjects.XBooleanProperty;
-import org.xwiki.android.xmodel.xobjects.XDBTreeListProperty;
-import org.xwiki.android.xmodel.xobjects.XDateProperty;
-import org.xwiki.android.xmodel.xobjects.XSimpleObject;
-import org.xwiki.android.xmodel.xobjects.XStringProperty;
-import org.xwiki.android.xmodel.xobjects.XTextAreaProperty;
-
-/**
- * @author sasinda corresponds to XWiki Enterprise BlogPostClass. Naming convention is BlogPostClass --> XBlogPost (add
- * prefix 'X', drop suffix 'Class')
- */
-public class XBlogPost extends XSimpleObject
-{
-
- public XBlogPost()
- {
- super("Blog.BlogPostClass");// set Type.
- }
-
- public String getCategory()
- {
- XDBTreeListProperty prop = (XDBTreeListProperty) fields.get("category");
- if (prop != null) {
- return prop.getValue().toString();
- }
- return null;
- }
-
- public void setCategory(String category)
- {
- XDBTreeListProperty prop = (XDBTreeListProperty) fields.get("category");
- if (prop == null) {
- prop = new XDBTreeListProperty();
- fields.put("category", prop);
- }
- prop.getValue().clear();
- prop.getValue().add(category);
- }
-
- public String getContent()
- {
- XTextAreaProperty prop = (XTextAreaProperty) fields.get("content");
- if (prop != null) {
- return prop.getValue();
- }
- return null;
- }
-
- public void setContent(String content)
- {
- XTextAreaProperty prop = (XTextAreaProperty) fields.get("content");
- if (prop == null) {
- prop = new XTextAreaProperty();
- fields.put("content", prop);
- }
- prop.setValue(content);
- }
-
- public String getExtract()
- {
- XTextAreaProperty prop = (XTextAreaProperty) fields.get("extract");
- if (prop != null) {
- return prop.getValue();
- }
- return null;
- }
-
- public void setExtract(String extract)
- {
- XTextAreaProperty prop = (XTextAreaProperty) fields.get("extract");
- if (prop == null) {
- prop = new XTextAreaProperty();
- fields.put("extract", prop);
- }
- prop.setValue(extract);
- }
-
- /**
- * @return value of the "hidden" property. Or 'false' if the property is not yet set. Use getpHidden() to check
- * whether the property is set.
- */
- public boolean isHidden()
- {
- XBooleanProperty prop = (XBooleanProperty) fields.get("hidden");
- if (prop != null) {
- return prop.getValue();
- }
- return false;
- }
-
- public void setHidden(boolean hidden)
- {
- XBooleanProperty prop = (XBooleanProperty) fields.get("hidden");
- if (prop == null) {
- prop = new XBooleanProperty();
- fields.put("hidden", prop);
- }
- prop.setValue(hidden);
- }
-
- public Date getPublishDate()
- {
- XDateProperty prop = (XDateProperty) fields.get("publishDate");
- if (prop != null) {
- return prop.getValue();
- }
- return null;
- }
-
- public void setPublishDate(Date publishDate)
- {
- XDateProperty prop = (XDateProperty) fields.get("publishDate");
- if (prop == null) {
- prop = new XDateProperty();
- fields.put("publishDate", prop);
- }
- prop.setValue(publishDate);
- }
-
- /**
- * @return value of the "published" property. Or 'false' even if the property is not set. Use getpPublished() to
- * check whether the property is set.
- */
- public boolean isPublished()
- {
- XBooleanProperty prop = (XBooleanProperty) fields.get("published");
- if (prop != null) {
- return prop.getValue();
- }
- return false;
- }
-
- public void setPublished(boolean published)
- {
- XBooleanProperty prop = (XBooleanProperty) fields.get("published");
- if (prop == null) {
- prop = new XBooleanProperty();
- fields.put("published", prop);
- }
- prop.setValue(published);
- }
-
- public String getTitle()
- {
- XStringProperty prop = (XStringProperty) fields.get("title");
- if (prop != null) {
- return prop.getValue();
- }
- return null;
- }
-
- public void setTitle(String title)
- {
- XStringProperty prop = (XStringProperty) fields.get("title");
- if (prop == null) {
- prop = new XStringProperty();
- fields.put("title", prop);
- }
- prop.setValue(title);
- }
-
- public XDBTreeListProperty getPCategory()
- {
- return (XDBTreeListProperty) fields.get("category");
- }
-
- public void setpCategory(XDBTreeListProperty category)
- {
- fields.put("category", category);
- }
-
- public XTextAreaProperty getpContent()
- {
- return (XTextAreaProperty) fields.get("content");
- }
-
- public void setpContent(XTextAreaProperty content)
- {
- fields.put("content", content);
- }
-
- public XTextAreaProperty getpExtract()
- {
- return (XTextAreaProperty) fields.get("extract");
- }
-
- public void setpExtract(XTextAreaProperty extract)
- {
- fields.put("extract", extract);
- }
-
- public XBooleanProperty getpHidden()
- {
- return (XBooleanProperty) fields.get("hidden");
- }
-
- public void setpHidden(XBooleanProperty hidden)
- {
- fields.put("hidden", hidden);
- }
-
- public XDateProperty getpPublishDate()
- {
- return (XDateProperty) fields.get("publishDate");
- }
-
- public void setpPublishDate(XDateProperty publishDate)
- {
- fields.put("publishDate", publishDate);
- }
-
- public XBooleanProperty getpPublished()
- {
- return (XBooleanProperty) fields.get("published");
- }
-
- public void setpPublished(XBooleanProperty published)
- {
- fields.put("published", published);
- }
-
- public XStringProperty getpTitle()
- {
- return (XStringProperty) fields.get("title");
- }
-
- public void setpTitle(XStringProperty title)
- {
- fields.put("title", title);
- }
-
-}
diff --git a/xwiki-android-core/src/org/xwiki/android/blog/xobj/XCategory.java b/xwiki-android-core/src/org/xwiki/android/blog/xobj/XCategory.java
deleted file mode 100644
index e7c941d..0000000
--- a/xwiki-android-core/src/org/xwiki/android/blog/xobj/XCategory.java
+++ /dev/null
@@ -1,11 +0,0 @@
-package org.xwiki.android.blog.xobj;
-
-import org.xwiki.android.xmodel.xobjects.XSimpleObject;
-
-public class XCategory extends XSimpleObject
-{
- public XCategory()
- {
- super("");
- }
-}
diff --git a/xwiki-android-core/src/org/xwiki/android/cmnSvc/LoginFacade.java b/xwiki-android-core/src/org/xwiki/android/cmnSvc/LoginFacade.java
deleted file mode 100644
index 0ab0577..0000000
--- a/xwiki-android-core/src/org/xwiki/android/cmnSvc/LoginFacade.java
+++ /dev/null
@@ -1,139 +0,0 @@
-package org.xwiki.android.cmnSvc;
-
-import java.sql.SQLException;
-import java.util.Date;
-import java.util.List;
-
-import org.xwiki.android.context.XWikiApplicationContext;
-import org.xwiki.android.dal.EntityManager;
-import org.xwiki.android.entity.LoginAttempt;
-import org.xwiki.android.entity.User;
-import org.xwiki.android.rest.HttpConnector;
-import org.xwiki.android.rest.RestConnectorException;
-
-import com.j256.ormlite.dao.Dao;
-
-import android.content.Context;
-import android.util.Log;
-
-public class LoginFacade
-{
- /**
- * Send login request to user. Create new user if new entry. Logs the login attempt.
- *
- * @param username
- * @param password
- * @param url
- * @param remPwd : wether to remember the password.
- * @param ctx the activity context or application context
- * @return response Code.
- */
- public int login(String username, String password, String url, boolean remPwd)
- {
- HttpConnector httpConnector = new HttpConnector();
- int code=0;
- try {
- code = httpConnector.checkLogin(username, password, url);
- } catch (RestConnectorException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- // start seperate thread to add login attempt to DB. (update LoginAttempt , update User if new user data
- // combination )
- Thread statusUpdater = new Thread(new statusUpdater(username, password, url, code, remPwd));
- statusUpdater.start();
- return code;
- }
-
- // TODO: revise: what about using a method local inner class?
- /**
- * @author sasinda runnable. Update the XWikiApplicationContext,(initialize user session) Update database if new
- * username, xwiki server realm combination Log the login attempt.
- */
- private class statusUpdater implements Runnable
- {
-
- private String usrname, pwd, url;
-
- private String realm;// url can be anything, realm identifies the part of the url where the user is
- // authenticated
-
- private int code;
-
- private boolean remPwd;
-
- statusUpdater(String usrname, String pwd, String url, int code, boolean remPwd)
- {
- this.usrname = usrname;
- this.pwd = pwd;
- this.url = url;
- this.code = code;
- this.remPwd = remPwd;
- }
-
- public void run()
- {
- XWikiApplicationContext ctx = XWikiApplicationContext.getInstance();
- EntityManager eman = ctx.newEntityManager();
- Log.i(LoginFacade.class.getSimpleName(), "updating state " + usrname + " " + pwd + " " + url + " " + code);
- if (code == 200) {// success
- // update context to authenticated state. if new user add to db;
-
- try {
- Dao udao = eman.getDao(User.class);
- User search = new User();
- search.setUserName(usrname);
- search.setWikiRealm(url);
- List matches = udao.queryForMatching(search);
- if (matches.isEmpty()) {
- // this is a new user -->create new entry
- search.setPassword(pwd);// User object should manage if pwd is null
-
- // ctx update
- ((XWikiApplicationContext) ctx.getApplicationContext()).updateToAuthenticatedState(search);
- // db
- User dbuser = search.clone();
- if (remPwd == false) {
- dbuser.setPassword(null);
- }
- udao.create(dbuser);
- Log.i(LoginFacade.class.getSimpleName(), "created new user db entry " + dbuser.getUserName()
- + " " + dbuser.get_id());
- } else {
- User u = matches.get(0);
- User ucpy = u.clone();
- // if pwd was not saved earlier save it now. If remPwd is false delete existing remembered pwd
- // entry
- if (u.getPassword() == null & pwd != null || pwd == null & u.getPassword() != null) {
- ucpy.setPassword(pwd);
- udao.update(ucpy);
- }
- ((XWikiApplicationContext) ctx.getApplicationContext()).updateToAuthenticatedState(u);
- }
- // log the attempt
- Dao logins = eman.getDao(LoginAttempt.class);
- LoginAttempt la = new LoginAttempt(usrname, url, new Date(), LoginAttempt.STATUS_SUCCEED, code);
- logins.create(la);
- } catch (SQLException e) {
- Log.e(this.getClass().getSimpleName(), "cannot create/update entry of user", e);
- // if db fail update the ctx yet with new val
- ((XWikiApplicationContext) ctx.getApplicationContext()).updateToAuthenticatedState(new User(null,
- null, usrname, pwd, url, null));
- }
-
- } else {
- Dao logins;
- try {
- logins = eman.getDao(LoginAttempt.class);
- LoginAttempt la = new LoginAttempt(usrname, url, new Date(), LoginAttempt.STATUS_FAILURE, code);
- logins.create(la);
- } catch (SQLException e) {
- e.printStackTrace();
- }
- }
- eman.close();
- }
-
- }
-
-}
diff --git a/xwiki-android-core/src/org/xwiki/android/cmnSvc/SyncService.java b/xwiki-android-core/src/org/xwiki/android/cmnSvc/SyncService.java
deleted file mode 100644
index 45ea9cb..0000000
--- a/xwiki-android-core/src/org/xwiki/android/cmnSvc/SyncService.java
+++ /dev/null
@@ -1,59 +0,0 @@
-package org.xwiki.android.cmnSvc;
-
-import java.io.File;
-import java.sql.SQLException;
-
-import org.xwiki.android.context.XWikiApplicationContext;
-import org.xwiki.android.context.XWikiApplicationContextAPI;
-import org.xwiki.android.dal.EntityManager;
-import org.xwiki.android.entity.SyncOutEntity;
-import org.xwiki.android.fileStore.DocumentFao;
-import org.xwiki.android.fileStore.FSDocumentReference;
-import org.xwiki.android.fileStore.FileStoreManager;
-import org.xwiki.android.xmodel.entity.Document;
-
-import com.j256.ormlite.dao.Dao;
-
-/**
- *
- * @author xwiki gsoc 2012
- * Marks a FSDocumentReference to be syned out.
- */
-public class SyncService
-{
-
- private FileStoreManager fsmngr;
- private EntityManager emngr;
-
- public SyncService(){
- XWikiApplicationContextAPI ctx=XWikiApplicationContext.getInstance();
- fsmngr=ctx.getFileStoreManager();
- }
-
- /**
- * Saves the document in default filestore location for documents,and sends the doc to the server later.
- * @param doc
- */
- public void SyncOutLater(Document doc){
- DocumentFao fao=fsmngr.getDocumentFao();
- FSDocumentReference ref=fao.save(doc, "Sync");
- SyncOutLater(ref);
- }
-
- /**
- * Sync out the document refered by ref.
- * Document should have been presaved.
- * @param doc
- */
- public void SyncOutLater(FSDocumentReference ref){
- SyncOutEntity se=new SyncOutEntity(ref);
- try {
- Daodao=emngr.getDao(SyncOutEntity.class);
- dao.create(se);
- emngr.close();
- } catch (SQLException e) {
- e.printStackTrace();
- }
-
- }
-}
diff --git a/xwiki-android-core/src/org/xwiki/android/context/XWikiApplicationContext.java b/xwiki-android-core/src/org/xwiki/android/context/XWikiApplicationContext.java
index fa688db..7672595 100644
--- a/xwiki-android-core/src/org/xwiki/android/context/XWikiApplicationContext.java
+++ b/xwiki-android-core/src/org/xwiki/android/context/XWikiApplicationContext.java
@@ -10,8 +10,8 @@
import org.xwiki.android.entity.User;
import org.xwiki.android.fileStore.FileStoreManager;
import org.xwiki.android.fileStore.FileStoreManagerImpl;
-import org.xwiki.android.ral.RESTfulManager;
-import org.xwiki.android.ral.XmlRESTFulManager;
+import org.xwiki.android.rest.ral.RESTfulManager;
+import org.xwiki.android.rest.ral.XmlRESTFulManager;
import android.app.Application;
import android.content.Context;
diff --git a/xwiki-android-core/src/org/xwiki/android/context/XWikiApplicationContextAPI.java b/xwiki-android-core/src/org/xwiki/android/context/XWikiApplicationContextAPI.java
index 300d1a0..8194ecc 100644
--- a/xwiki-android-core/src/org/xwiki/android/context/XWikiApplicationContextAPI.java
+++ b/xwiki-android-core/src/org/xwiki/android/context/XWikiApplicationContextAPI.java
@@ -2,7 +2,7 @@
import org.xwiki.android.entity.User;
import org.xwiki.android.fileStore.FileStoreManager;
-import org.xwiki.android.ral.RESTfulManager;
+import org.xwiki.android.rest.ral.RESTfulManager;
/**
* @author xwiki Cast the activity/service.getApplicationContext to this interface if only XWiki specific methods are
diff --git a/xwiki-android-core/src/org/xwiki/android/dal/EntityManager.java b/xwiki-android-core/src/org/xwiki/android/dal/EntityManager.java
index 03a181f..9621c0c 100644
--- a/xwiki-android-core/src/org/xwiki/android/dal/EntityManager.java
+++ b/xwiki-android-core/src/org/xwiki/android/dal/EntityManager.java
@@ -12,7 +12,7 @@
import org.xwiki.android.entity.SyncOutEntity;
import org.xwiki.android.entity.User;
import org.xwiki.android.fileStore.FSDocumentReference;
-import org.xwiki.android.ral.reference.DocumentReference;
+import org.xwiki.android.rest.reference.DocumentReference;
import org.xwiki.android.xmodel.entity.DocumentBase;
import com.j256.ormlite.android.apptools.OrmLiteSqliteOpenHelper;
diff --git a/xwiki-android-core/src/org/xwiki/android/entity/SyncOutEntity.java b/xwiki-android-core/src/org/xwiki/android/entity/SyncOutEntity.java
index 6c8ba1a..56516e6 100644
--- a/xwiki-android-core/src/org/xwiki/android/entity/SyncOutEntity.java
+++ b/xwiki-android-core/src/org/xwiki/android/entity/SyncOutEntity.java
@@ -7,107 +7,112 @@
import com.j256.ormlite.field.DataType;
import com.j256.ormlite.field.DatabaseField;
import com.j256.ormlite.table.DatabaseTable;
+
/**
- *
* @author xwiki gsoc 2012
- * @version 1.0
- * Marker to sync documents (out)to the server. *
- * Sync out= sync direction: device to server.
- * Sync in = sync direction: server to device.
+ * @version 1.0 Marker to sync documents (out)to the server. * Sync out= sync direction: device to server. Sync in =
+ * sync direction: server to device.
*/
-
-@DatabaseTable(tableName="C_SyncOut")
+@DatabaseTable(tableName = "C_SyncOut")
public class SyncOutEntity
{
- @DatabaseField(generatedId=true)
- int _id;
-
- @DatabaseField(foreign=true, unique=true)
- private FSDocumentReference docref;
-
- @DatabaseField
- private boolean delAftrSync;
-
- @DatabaseField
- private StratergyType stratery;//not used yet.For advanced use. Things like do Create doc, abort if already created.
-
- @DatabaseField
- private StatusType status;
-
- @DatabaseField
- private Date lastTried;
-
- private SyncOutEntity()
- {
- //for ORMlite
- }
-
- public SyncOutEntity(FSDocumentReference ref)
- {
- this.docref=ref;
- stratery=StratergyType.DEFALUT;
- delAftrSync=true;
- }
-
- public enum StratergyType{
- DEFALUT, CREATE , UPDATE
- }
- public enum StatusType{
- SUCCESS, PARTIALLYCOMPLETE, FAILED
- }
-
-
- public FSDocumentReference getDocref()
- {
- return docref;
- }
-
- public void setDocref(FSDocumentReference docref)
- {
- this.docref = docref;
- }
-
- public boolean isDelAftrSync()
- {
- return delAftrSync;
- }
-
- public void setDelAftrSync(boolean delAftrSync)
- {
- this.delAftrSync = delAftrSync;
- }
-
- public StratergyType getStratery()
- {
- return stratery;
- }
-
- public void setStratery(StratergyType stratery)
- {
- this.stratery = stratery;
- }
-
- public StatusType getStatus()
- {
- return status;
- }
-
- public void setStatus(StatusType status)
- {
- this.status = status;
- }
-
- public Date getLastTried()
- {
- return lastTried;
- }
-
- public void setLastTried(Date lastTried)
- {
- this.lastTried = lastTried;
- }
-
-
-
+ @DatabaseField(generatedId = true)
+ int _id;
+
+ @DatabaseField(foreign = true, unique = true)
+ private FSDocumentReference docref;
+
+ @DatabaseField
+ private boolean delAftrSync;
+
+ @DatabaseField
+ private StratergyType stratery;// not used yet.For advanced use. Things like do Create doc, abort if already
+ // created.
+
+ @DatabaseField
+ private StatusType status;
+
+ @DatabaseField
+ private Date lastTried;
+
+ private SyncOutEntity()
+ {
+ // for ORMlite
+ }
+
+ public SyncOutEntity(FSDocumentReference ref)
+ {
+ this.docref = ref;
+ stratery = StratergyType.DEFALUT;
+ delAftrSync = true;
+ status = StatusType.PENDING;
+ }
+
+ public enum StratergyType
+ {
+ DEFALUT,
+ CREATE,
+ UPDATE
+ }
+
+ public enum StatusType
+ {
+ SUCCESS,
+ PARTIALLYCOMPLETE,
+ FAILED, //last try failed
+ ABORTED, //completely aborted retry
+ PENDING
+ }
+
+ public FSDocumentReference getDocref()
+ {
+ return docref;
+ }
+
+ public void setDocref(FSDocumentReference docref)
+ {
+ this.docref = docref;
+ }
+
+ public boolean isDelAftrSync()
+ {
+ return delAftrSync;
+ }
+
+ public void setDelAftrSync(boolean delAftrSync)
+ {
+ this.delAftrSync = delAftrSync;
+ }
+
+ public StratergyType getStratery()
+ {
+ return stratery;
+ }
+
+ public void setStratery(StratergyType stratery)
+ {
+ this.stratery = stratery;
+ }
+
+ public StatusType getStatus()
+ {
+ return status;
+ }
+
+ public void setStatus(StatusType status)
+ {
+ this.status = status;
+ }
+
+ public Date getLastTried()
+ {
+ return lastTried;
+ }
+
+ public void setLastTried(Date lastTried)
+ {
+ this.lastTried = lastTried;
+ }
+
}
diff --git a/xwiki-android-core/src/org/xwiki/android/fileStore/DocumentFaoImpSer.java b/xwiki-android-core/src/org/xwiki/android/fileStore/DocumentFaoImpSer.java
index 614dd35..fa4cedc 100644
--- a/xwiki-android-core/src/org/xwiki/android/fileStore/DocumentFaoImpSer.java
+++ b/xwiki-android-core/src/org/xwiki/android/fileStore/DocumentFaoImpSer.java
@@ -15,7 +15,7 @@
import org.xwiki.android.context.XWikiApplicationContext;
import org.xwiki.android.dal.EntityManager;
-import org.xwiki.android.ral.reference.DocumentReference;
+import org.xwiki.android.rest.reference.DocumentReference;
import org.xwiki.android.xmodel.entity.Document;
import android.util.Log;
diff --git a/xwiki-android-core/src/org/xwiki/android/fileStore/FSDocumentReference.java b/xwiki-android-core/src/org/xwiki/android/fileStore/FSDocumentReference.java
index f6f4ce8..ba8d3a8 100644
--- a/xwiki-android-core/src/org/xwiki/android/fileStore/FSDocumentReference.java
+++ b/xwiki-android-core/src/org/xwiki/android/fileStore/FSDocumentReference.java
@@ -2,7 +2,7 @@
import java.io.File;
-import org.xwiki.android.ral.reference.DocumentReference;
+import org.xwiki.android.rest.reference.DocumentReference;
import com.j256.ormlite.field.DatabaseField;
import com.j256.ormlite.table.DatabaseTable;
diff --git a/xwiki-android-core/src/org/xwiki/android/ral/DocumentRao.java b/xwiki-android-core/src/org/xwiki/android/ral/DocumentRao.java
deleted file mode 100644
index dd8e3f5..0000000
--- a/xwiki-android-core/src/org/xwiki/android/ral/DocumentRao.java
+++ /dev/null
@@ -1,49 +0,0 @@
-package org.xwiki.android.ral;
-
-import org.xwiki.android.ral.reference.DocumentReference;
-import org.xwiki.android.ral.reference.EntityReference;
-import org.xwiki.android.rest.RestConnectorException;
-import org.xwiki.android.xmodel.entity.Document;
-
-public interface DocumentRao extends Rao
-{
- // conversion param
- int PAGE = 1;
- int OBJECTS = 2;
- int COMMENTS = 4;
- int TAGS = 8;
- int ATTACHMENTS = 16;
- int COMMENT_OBJECTS=32;
- int TAG_OBJECT=64;
- int ALL = 2147483647;
-
- /**
- * default semantics
- *
- * @param dref
- * @return
- * @throws RestConnectorException
- * @throws RaoException
- */
- Document retreive(DocumentReference dref) throws RestConnectorException, 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);
-
- void delete(DocumentReference dRef) throws RestConnectorException, RaoException;
-}
diff --git a/xwiki-android-core/src/org/xwiki/android/ral/RALUtils.java b/xwiki-android-core/src/org/xwiki/android/ral/RALUtils.java
deleted file mode 100644
index 4dda98e..0000000
--- a/xwiki-android-core/src/org/xwiki/android/ral/RALUtils.java
+++ /dev/null
@@ -1,9 +0,0 @@
-package org.xwiki.android.ral;
-
-public class RALUtils
-{
- public static int getStatusCode(String statusLine){
- // can use split(" ") and parse. More robust.
- return Integer.parseInt(statusLine.substring(9, 12));
- }
-}
diff --git a/xwiki-android-core/src/org/xwiki/android/ral/RESTfulManager.java b/xwiki-android-core/src/org/xwiki/android/ral/RESTfulManager.java
deleted file mode 100644
index 27e6c0a..0000000
--- a/xwiki-android-core/src/org/xwiki/android/ral/RESTfulManager.java
+++ /dev/null
@@ -1,14 +0,0 @@
-package org.xwiki.android.ral;
-
-import org.xwiki.android.resources.Space;
-import org.xwiki.android.resources.Wiki;
-import org.xwiki.android.xmodel.entity.Document;
-
-public interface RESTfulManager
-{
- DocumentRao newDocumentRao();
-
- SpaceRao newSpaceRao();
-
- WikiRao newWikiRao();
-}
diff --git a/xwiki-android-core/src/org/xwiki/android/ral/Rao.java b/xwiki-android-core/src/org/xwiki/android/ral/Rao.java
deleted file mode 100644
index cf7a96b..0000000
--- a/xwiki-android-core/src/org/xwiki/android/ral/Rao.java
+++ /dev/null
@@ -1,34 +0,0 @@
-package org.xwiki.android.ral;
-
-
-import java.util.List;
-
-import org.xwiki.android.ral.reference.EntityReference;
-import org.xwiki.android.rest.RestConnectorException;
-
-/**
- * @author xwiki gsoc 2012
- * @version 1.0 RESTful Access Object Interface [1]Behavior is unspecified for multiple concurrent requests for the same
- * Rao.
- * @param : type of the RAO.
- */
-// TODO: rectify [1] above.
-interface Rao
-{
- T create(T resrc) throws RestConnectorException,RaoException;
-
- T retreive(T resrc) throws RestConnectorException,RaoException;
-
- List querry()throws RestConnectorException,RaoException;
-
- T update(T resrc)throws RestConnectorException,RaoException;// TODO: not yet specified.
-
- void delete(T resrc)throws RestConnectorException,RaoException;
-
-}
-
-/**
- * note: When implementing do not give the responsibilities of off line syncing to components below RAOs. Use seperate
- * android Services to access RAOs from above and use them to sync when online. Those responsibilities go to the
- * seperate sync module.
- **/
diff --git a/xwiki-android-core/src/org/xwiki/android/ral/RaoException.java b/xwiki-android-core/src/org/xwiki/android/ral/RaoException.java
deleted file mode 100644
index 23f01b0..0000000
--- a/xwiki-android-core/src/org/xwiki/android/ral/RaoException.java
+++ /dev/null
@@ -1,10 +0,0 @@
-package org.xwiki.android.ral;
-
-/**
- * @author xwiki gsoc 2012 For exceptional situations where client is doing some thing wrong due to lack of knowledge of
- * the remote servers state.Ex: Call to create a document that already exsist in the remote server.
- */
-public class RaoException extends Exception
-{
-
-}
diff --git a/xwiki-android-core/src/org/xwiki/android/ral/SpaceRao.java b/xwiki-android-core/src/org/xwiki/android/ral/SpaceRao.java
deleted file mode 100644
index f8a82ae..0000000
--- a/xwiki-android-core/src/org/xwiki/android/ral/SpaceRao.java
+++ /dev/null
@@ -1,9 +0,0 @@
-package org.xwiki.android.ral;
-
-import org.xwiki.android.xmodel.entity.Space;
-
-
-public interface SpaceRao extends Rao
-{
-
-}
diff --git a/xwiki-android-core/src/org/xwiki/android/ral/WikiRao.java b/xwiki-android-core/src/org/xwiki/android/ral/WikiRao.java
deleted file mode 100644
index 54baf5e..0000000
--- a/xwiki-android-core/src/org/xwiki/android/ral/WikiRao.java
+++ /dev/null
@@ -1,8 +0,0 @@
-package org.xwiki.android.ral;
-
-import org.xwiki.android.xmodel.entity.Wiki;
-
-public interface WikiRao extends Rao
-{
-
-}
diff --git a/xwiki-android-core/src/org/xwiki/android/ral/XmlDocumentRao.java b/xwiki-android-core/src/org/xwiki/android/ral/XmlDocumentRao.java
deleted file mode 100644
index e4bf40b..0000000
--- a/xwiki-android-core/src/org/xwiki/android/ral/XmlDocumentRao.java
+++ /dev/null
@@ -1,150 +0,0 @@
-package org.xwiki.android.ral;
-
-import java.io.IOException;
-import java.util.List;
-
-import org.xwiki.android.context.UserSession;
-import org.xwiki.android.context.XWikiApplicationContext;
-import org.xwiki.android.context.XWikiApplicationContextAPI;
-import org.xwiki.android.ral.reference.DocumentReference;
-import org.xwiki.android.ral.reference.EntityReference;
-import org.xwiki.android.ral.transformation.DocLaunchPadForXML;
-import org.xwiki.android.ral.transformation.DocumentDismantler_XML;
-import org.xwiki.android.resources.Object;
-import org.xwiki.android.resources.Page;
-import org.xwiki.android.rest.PageResources;
-import org.xwiki.android.rest.Requests;
-import org.xwiki.android.rest.IllegalRestUsageException;
-import org.xwiki.android.rest.RestConnectorException;
-import org.xwiki.android.rest.XWikiRestConnector;
-import org.xwiki.android.rest.XWikiRestfulAPI;
-import org.xwiki.android.xmodel.entity.Document;
-import org.xwiki.android.xmodel.entity.Document;
-import org.xwiki.android.xmodel.xobjects.XUtils;
-
-/**
- * @author xwiki gsoc 2012
- * @version 0.8 alpha uses simplexml Rest model. Non public. Use XMLRestfulManager to create new. Very primitive
- * implementation with single Http Connection for all work. *
- */
-// TODO: current impl only support single http connection through Requests
-// class. Implement for multiple parallel connections to reduce latency.
-class XmlDocumentRao implements DocumentRao
-{
- private static int PAGE = DocumentDismantler_XML.PAGE;
- private static int OBJECTS = DocumentDismantler_XML.OBJECTS;
- private static int ALL = DocumentDismantler_XML.ALL;
- private XWikiRestfulAPI api;
-
- public XmlDocumentRao()
- {
- UserSession session = XWikiApplicationContext.getInstance().getUserSession();
- api = new XWikiRestConnector(session.getRealm(), session.getUserName(), session.getPassword());
- // consider IoC to app context
- }
-
- /**
- * create the doc on server.
- */
- @Override
- public Document create(Document doc) throws RestConnectorException, RaoException
- {
- DocumentDismantler_XML con = new DocumentDismantler_XML(ALL);
- DocLaunchPadForXML pad = con.convertDocument(doc);
-
- Page page = pad.getPage();
- String wikiName = pad.getWikiName();
- String spaceName = pad.getSpaceName();
- String pageName = pad.getPageName();
- String statusLine;
-
- statusLine = api.addPage(wikiName, spaceName, pageName, page);
- int statusCode = RALUtils.getStatusCode(statusLine);
-
- if (200 <= statusCode & statusCode < 300) {
- for (Object object : pad.getNewObjects()) {// TODO: these can be
- // done in parallel
- if (statusLine.equals("error")) {// TODO:returning error should be totally removed from underlying
- // layer.
- break;
- }
- statusLine = api.addObject(wikiName, spaceName, pageName, object);
- }
- }
- // there are no altered objects to be updated since the doc is new.
- // TODO:current impl of Request does not return response body. So null
- // for doc.
- // 304 if there was error in page representation.
- // 201 created.
- int code = RALUtils.getStatusCode(statusLine);
- if (200 <= code & code < 300) {
- return null;
- } else {
- throw new IllegalRestUsageException("status line is:" + statusLine);
- }
-
- }
-
- @Override
- public Document retreive(Document doc) throws RestConnectorException, RaoException
- {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public Document retreive(DocumentReference dref) throws RestConnectorException, RaoException
- {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public Document retreive(DocumentReference dref, int flags)
- {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public Document retreive(DocumentReference dref, int flags, String... objTypeArgs)
- {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public List querry() throws RestConnectorException, RaoException
- {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public Document update(Document res) throws RestConnectorException, RaoException
- {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public void delete(DocumentReference dRef) throws RestConnectorException, RaoException
- {
- DocumentReference docRef = dRef;
- String wikiName = docRef.getWikiName();
- String spaceName = docRef.getSpaceName();
- String pageName = docRef.getPageName();
- api.deletePage(wikiName, spaceName, pageName);
-
- }
-
-
-
- @Override
- public void delete(Document resrc) throws RestConnectorException, RaoException
- {
- delete(resrc.getDocumentReference());
- }
-
-
-
-
-
-}
diff --git a/xwiki-android-core/src/org/xwiki/android/ral/XmlRESTFulManager.java b/xwiki-android-core/src/org/xwiki/android/ral/XmlRESTFulManager.java
deleted file mode 100644
index 5f67f49..0000000
--- a/xwiki-android-core/src/org/xwiki/android/ral/XmlRESTFulManager.java
+++ /dev/null
@@ -1,29 +0,0 @@
-package org.xwiki.android.ral;
-
-import org.xwiki.android.resources.Space;
-import org.xwiki.android.resources.Wiki;
-import org.xwiki.android.xmodel.entity.Document;
-
-public class XmlRESTFulManager implements RESTfulManager
-{
-
- public DocumentRao newDocumentRao()
- {
- return new XmlDocumentRao();
- }
-
- public SpaceRao newSpaceRao()
- {
- // TODO Auto-generated method stub
- throw new UnsupportedOperationException("not yet supported");
-
- }
-
- public WikiRao newWikiRao()
- {
- // TODO Auto-generated method stub
- throw new UnsupportedOperationException("not yet supported");
-
- }
-
-}
diff --git a/xwiki-android-core/src/org/xwiki/android/ral/reference/DocumentReference.java b/xwiki-android-core/src/org/xwiki/android/ral/reference/DocumentReference.java
deleted file mode 100644
index 23d14e3..0000000
--- a/xwiki-android-core/src/org/xwiki/android/ral/reference/DocumentReference.java
+++ /dev/null
@@ -1,86 +0,0 @@
-package org.xwiki.android.ral.reference;
-
-import org.xwiki.android.xmodel.entity.Document;
-
-import com.j256.ormlite.field.DatabaseField;
-import com.j256.ormlite.table.DatabaseTable;
-
-public class DocumentReference extends EntityReference
-{
- @DatabaseField
- protected String wikiName;
-
- @DatabaseField
- protected String spaceName;
-
- @DatabaseField
- protected String pageName;
-
- public DocumentReference()
- {
- // for ORMLite
- }
-
- public DocumentReference(String wikiName, String spaceName, String pageName)
- {
- super();
- this.wikiName = wikiName;
- this.spaceName = spaceName;
- this.pageName = pageName;
- }
-
- /**
- * @return the wikiName
- */
- public String getWikiName()
- {
- return wikiName;
- }
-
- /**
- * @return the spaceName
- */
- public String getSpaceName()
- {
- return spaceName;
- }
-
- /**
- * @return the pageName
- */
- public String getPageName()
- {
- return pageName;
- }
-
- /**
- * @param wikiName the wikiName to set
- */
- public void setWikiName(String wikiName)
- {
- this.wikiName = wikiName;
- }
-
- /**
- * @param spaceName the spaceName to set
- */
- public void setSpaceName(String spaceName)
- {
- this.spaceName = spaceName;
- }
-
- /**
- * @param pageName the pageName to set
- */
- public void setPageName(String pageName)
- {
- this.pageName = pageName;
- }
-
- @Override
- public String getURL()
- {
- return getAuthority() + "/xwiki/rest/wikis/" + wikiName + "/spaces" + spaceName + "/pages" + pageName;
- }
-
-}
diff --git a/xwiki-android-core/src/org/xwiki/android/ral/reference/EntityReference.java b/xwiki-android-core/src/org/xwiki/android/ral/reference/EntityReference.java
deleted file mode 100644
index ff41729..0000000
--- a/xwiki-android-core/src/org/xwiki/android/ral/reference/EntityReference.java
+++ /dev/null
@@ -1,116 +0,0 @@
-package org.xwiki.android.ral.reference;
-
-import java.io.File;
-import java.io.Serializable;
-import java.net.MalformedURLException;
-
-import org.xwiki.android.context.XWikiApplicationContext;
-import org.xwiki.android.context.XWikiApplicationContextAPI;
-import org.xwiki.android.entity.User;
-
-import com.j256.ormlite.field.DatabaseField;
-
-/**
- * @author xwiki gsoc 2012 support both file:// (for local) and http:// (for remote) URI types.
- */
-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
-
- /**
- * http:// scheme. host section sample:- http://username:password@host:8080/directory/file?querryparam #fragment
- */
- @DatabaseField
- protected String host;
-
- @DatabaseField
- protected String port;
-
- @DatabaseField
- protected String serverName; // also named urlPrefix in old code.
-
- /**
- * http:// scheme. user info section: the username:password part
- */
- @DatabaseField(foreign = true)
- User authInfo;
-
- public EntityReference()
- {
- XWikiApplicationContextAPI ctx = XWikiApplicationContext.getInstance();
- String server = ctx.getUserSession().getRealm(); // host+port //TODO: When xwiki-android supports multiple
- // wikis, which may be seperate authentication realms, you
- // might need to change here.
- String arg[] = server.split(":");
- host = arg[0];
- port = arg[1];
- }
-
- // special getters
- 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;
- }
-
- public void setHost(String host)
- {
- this.host = host;
- }
-
- public String getPort()
- {
- return port;
- }
-
- public void setPort(String port)
- {
- this.port = port;
- }
-
- /**
- * @return host+port , www.xwiki.org
- */
- public String getServerName()
- {
- return serverName;
- }
-
- /**
- * @param address : host:port or something like www.xwiki.org.
- */
- public void setServerName(String address)
- {
- if (address.contains(":")) {
- String[] args = address.split(":");
- host = args[0];
- port = args[1];
- }
- serverName = address;
- }
-
- public User getAuthInfo()
- {
- return authInfo;
- }
-
- public void setAuthInfo(User authInfo)
- {
- this.authInfo = authInfo;
- }
-
-}
diff --git a/xwiki-android-core/src/org/xwiki/android/ral/reference/Link.java b/xwiki-android-core/src/org/xwiki/android/ral/reference/Link.java
deleted file mode 100644
index 9d09dc3..0000000
--- a/xwiki-android-core/src/org/xwiki/android/ral/reference/Link.java
+++ /dev/null
@@ -1,90 +0,0 @@
-package org.xwiki.android.ral.reference;
-
-import java.io.Serializable;
-
-/**
- * @author xwiki gsoc 2012 http://www.xwiki.org/rel/wikis The representation containing the list of virtual wikis.
- * http://www.xwiki.org/rel/spaces The representation containing the list of spaces in a wiki.
- * http://www.xwiki.org/rel/pages The representation containing the list of pages in a space.
- * http://www.xwiki.org/rel/translation The representation containing a translation of a page.
- * http://www.xwiki.org/rel/page The representation for a page. http://www.xwiki.org/rel/space The
- * representation for a space. http://www.xwiki.org/rel/parent The representation for the page that is parent of
- * the current resource. http://www.xwiki.org/rel/home The representation for the page that is the home of the
- * current resource. http://www.xwiki.org/rel/attachmentData The representation of the actual attachment data.
- * http://www.xwiki.org/rel/comments The representation of the list of comments associated to the current
- * resource. http://www.xwiki.org/rel/attachments The representation of the list of attachments associated to
- * the current resource. http://www.xwiki.org/rel/objects The representation of the list of objects associated
- * to the current resource. http://www.xwiki.org/rel/object The representation for an object.
- * http://www.xwiki.org/rel/classes The representation of the list of classes associated to the current
- * resource. http://www.xwiki.org/rel/history The representation of the list of history information associated
- * to the current resource. http://www.xwiki.org/rel/class The representation for a class.
- * http://www.xwiki.org/rel/property The representation for a property. http://www.xwiki.org/rel/properties The
- * representation of the list of properties associated to the current resource.
- * http://www.xwiki.org/rel/modifications The representation of the list of modifications associated to the
- * current resource. http://www.xwiki.org/rel/children The representation of the list of children associated to
- * the current resource. http://www.xwiki.org/rel/tags The representation of the list of tags associated to the
- * current resource. http://www.xwiki.org/rel/tag The representation of a tag. http://www.xwiki.org/rel/search
- * The representation for a search resource. http://www.xwiki.org/rel/syntaxes The representation for a syntax
- * resource.
- */
-
-// TODO: implement all above.
-
-public class Link implements Serializable
-{
- private static final String REL_SPACE = "space";
-
- private static final String REL_PARENT = "parent";
-
- private static final String REL_CHILDREN = "children";
-
- private static final String REL_HISTORY = "history";
-
- private static final String REL_COMMENTS = "comments";
-
- private static final String REL_OBJECTS = "objects";
-
- private static final String REL_TAGS = "tags";
-
- private static final String REL_ATTACHMENTS = "attachments";
-
- private static final String REL_SYNTAXES = "syntaxes";
-
- private static final String REL_SELF = "self";
-
- private static final String REL_CLASS = "class";
-
- private String rel;
-
- private String href;
-
- /**
- * truncates the fully qualified rel type name and sets ex: http://www.xwiki.org/rel/space --> space
- *
- * @param fullTypeid
- */
- public void setRelType(String fqRelType)
- {
- if (fqRelType.startsWith("http://")) {
- rel = fqRelType.substring(25);
- } else {
- this.rel = fqRelType;
- }
- }
-
- public void setHref(String href)
- {
- this.href = href;
- }
-
- public String getRelType()
- {
- return rel;
- }
-
- public String getHref()
- {
- return href;
- }
-
-}
diff --git a/xwiki-android-core/src/org/xwiki/android/ral/reference/ObjectReference.java b/xwiki-android-core/src/org/xwiki/android/ral/reference/ObjectReference.java
deleted file mode 100644
index 46ab65a..0000000
--- a/xwiki-android-core/src/org/xwiki/android/ral/reference/ObjectReference.java
+++ /dev/null
@@ -1,35 +0,0 @@
-package org.xwiki.android.ral.reference;
-
-public class ObjectReference extends DocumentReference
-{
- public ObjectReference(String wikiName, String spaceName, String pageName, String objType, int number)
- {
- super(wikiName, spaceName, pageName);
- type = objType;
- this.number = number;
- }
-
- String type;
-
- int number;
-
- public String getType()
- {
- return type;
- }
-
- public void setType(String type)
- {
- this.type = type;
- }
-
- public int getNumber()
- {
- return number;
- }
-
- public void setNumber(int number)
- {
- this.number = number;
- }
-}
diff --git a/xwiki-android-core/src/org/xwiki/android/ral/reference/PropertyReference.java b/xwiki-android-core/src/org/xwiki/android/ral/reference/PropertyReference.java
deleted file mode 100644
index d843172..0000000
--- a/xwiki-android-core/src/org/xwiki/android/ral/reference/PropertyReference.java
+++ /dev/null
@@ -1,13 +0,0 @@
-package org.xwiki.android.ral.reference;
-
-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/ral/reference/SpaceReference.java b/xwiki-android-core/src/org/xwiki/android/ral/reference/SpaceReference.java
deleted file mode 100644
index 1577452..0000000
--- a/xwiki-android-core/src/org/xwiki/android/ral/reference/SpaceReference.java
+++ /dev/null
@@ -1,35 +0,0 @@
-package org.xwiki.android.ral.reference;
-
-public class SpaceReference extends EntityReference
-{
- String wiki;
-
- String space;
-
- public String getWiki()
- {
- return wiki;
- }
-
- public void setWiki(String wiki)
- {
- this.wiki = wiki;
- }
-
- public String getSpace()
- {
- return space;
- }
-
- 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/ral/reference/WikiReference.java b/xwiki-android-core/src/org/xwiki/android/ral/reference/WikiReference.java
deleted file mode 100644
index d7bf16a..0000000
--- a/xwiki-android-core/src/org/xwiki/android/ral/reference/WikiReference.java
+++ /dev/null
@@ -1,23 +0,0 @@
-package org.xwiki.android.ral.reference;
-
-public class WikiReference extends EntityReference
-{
- String wiki;
-
- public String getWiki()
- {
- return wiki;
- }
-
- 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/ral/transformation/DocLaunchPadForXML.java b/xwiki-android-core/src/org/xwiki/android/ral/transformation/DocLaunchPadForXML.java
deleted file mode 100644
index 9b895c0..0000000
--- a/xwiki-android-core/src/org/xwiki/android/ral/transformation/DocLaunchPadForXML.java
+++ /dev/null
@@ -1,121 +0,0 @@
-package org.xwiki.android.ral.transformation;
-
-import java.util.ArrayList;
-import java.util.Hashtable;
-import java.util.List;
-import java.util.Map;
-
-import org.xwiki.android.resources.Attachment;
-import org.xwiki.android.resources.Comment;
-import org.xwiki.android.resources.Page;
-import org.xwiki.android.resources.Object;
-import org.xwiki.android.resources.Tags;
-
-/**
- * @author xwiki gsoc 2012 A scratch pad for converting. !!! Public but for ral package use only.
- */
-public class DocLaunchPadForXML
-{
- Page page;
-
- String wikiName, spaceName, pageName;
-
- List