Skip to content

Commit

Permalink
RAL: Update Complete. Checked for edited Xobjects.
Browse files Browse the repository at this point in the history
  • Loading branch information
sasinda committed Jul 28, 2012
1 parent f803985 commit 522d7f7
Show file tree
Hide file tree
Showing 10 changed files with 567 additions and 301 deletions.
27 changes: 17 additions & 10 deletions xwiki-android-client/res/layout/blogeditor.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,32 +18,39 @@
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<Button
android:id="@+id/btnPost"
android:id="@+id/btnPublish"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0.39"
android:text="Post" />
android:layout_weight="0.21"
android:text="Publish" />

<Button
android:id="@+id/btnPublish"
android:id="@+id/btnPost"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0.19"
android:text="Publish" />
android:layout_weight="0.39"
android:text="Post" />

<Button
android:id="@+id/btnSave"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Save" />

<Button
android:id="@+id/btnLoad"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Load" />
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0.19"
android:text="more" />

</LinearLayout>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ protected void onActivityResult(int requestCode, int resultCode, Intent data)

private void retreiveAndLaunchEditDoc()
{

}

private void showRetreiveDialog()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,20 @@ public class EditPostActivity extends Activity implements OnClickListener {

private final String TAG=this.getClass().getSimpleName();

private Button btnSave,btnLoad,btnPost,btnPublish;

private BlogDocument mydoc;
private BlogDocument.BlogDocumentRemoteCallbacks myRmtClbks;
private EditText etPost;
private String title;
private String category;
ProgressDialog progressDialog;
Dialog dialog;
EditText etTitle;
AutoCompleteTextView actvCategory;
private boolean update;

//View widgets
private Button btnSave,btnLoad,btnPost,btnPublish;
private ProgressDialog progressDialog;
private Dialog dialog;
private EditText etTitle;
private AutoCompleteTextView actvCategory;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Expand All @@ -57,11 +61,12 @@ protected void onCreate(Bundle savedInstanceState) {

//show dialog to get page name, category

Document d=(Document) getIntent().getSerializableExtra("UPDATE_DOC");
Document d=(Document) getIntent().getSerializableExtra(ARG_UPDATE_DOC);
if(d!=null){
mydoc=new BlogDocument(d);
etPost.setText(mydoc.getContent());
Log.d(TAG,mydoc.getContent());
update=true;
}else{
showDialog();
}
Expand Down Expand Up @@ -141,8 +146,14 @@ public void onBlogPostSent(boolean success) {
finish();
}
};
mydoc.setContent(etPost.getText().toString());
mydoc.post(myRmtClbks);
if(update){
mydoc.setContent(etPost.getText().toString());
mydoc.postUpdate(myRmtClbks);
}else{
mydoc.setContent(etPost.getText().toString());
mydoc.post(myRmtClbks);
}


}else if(v.getId()==R.id.btnPublish){
progressDialog =progressDialog.show(this, "Publishing", "Please wait...", true);
Expand All @@ -154,6 +165,12 @@ public void onBlogPostSent(boolean success) {
}
};
mydoc.setContent(etPost.getText().toString());
if(update){
mydoc.publishUpdate(myRmtClbks);
}else{
mydoc.publish(myRmtClbks);
}
mydoc.setContent(etPost.getText().toString());
mydoc.publish(myRmtClbks);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,12 @@ public FileStoreManager getFileStoreManager()
*/

public RESTfulManager newRESTfulManager()
{
return new XmlRESTFulManager();
{
UserSession session = getUserSession();
String username = session.getUserName();
String password = session.getPassword();
String serverUrl = session.getRealm();
return new XmlRESTFulManager(serverUrl, username, password);
}

public EntityManager newEntityManager()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public FSDocumentReference save(Document doc, String tag)
File f;
String wikiName = doc.getWikiName();
String spaceName = doc.getSpaceName();
String pageName = doc.getSimpleName();
String pageName = doc.getPageName();
String dirPath = FSDIR.getAbsolutePath() + wikiName + "/" + spaceName + "/" + pageName;
String filePath=dirPath+"/doc.ser";
f = new File(filePath);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -217,9 +217,10 @@ public void setSpaceName(String 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 getSimpleName()
public String getPageName()
{
return name;
}
Expand All @@ -229,7 +230,7 @@ public String getSimpleName()
*
* @param value allowed object is {@link String }
*/
public void setSimpleName(String name)
public void setPageName(String name)
{
this.name = name;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,12 @@ public static Date toDate(String ds)
// IVR s
switch (key) {
case 0: {
String gmt = ds.substring(20);
gmt = gmt.substring(0, 2) + gmt.substring(3);
System.out.println(gmt);
ds = ds.substring(0, 20) + gmt;
if(ds.length()>21){
String gmt = ds.substring(20);
gmt = gmt.substring(0, 2) + gmt.substring(3);
System.out.println(gmt);
ds = ds.substring(0, 20) + gmt;
}
}
break;
default:
Expand Down
21 changes: 19 additions & 2 deletions xwiki-android-rest/src/org/xwiki/android/rest/TagResources.java
Original file line number Diff line number Diff line change
Expand Up @@ -151,10 +151,27 @@ public String addTag(Tag tag) throws RestConnectionException, RestException
temp_tags.getTags().add(tag);

return super.putRequest(Uri, buildXml(temp_tags));
}
throw new IllegalStateException("tagType should be =0 or 1");
}

public String setTags(Tags tags)throws RestConnectionException, RestException
{
String Uri = null;

if (tagType == 0) {

Uri = "http://" + URLprefix + PAGE_URL_PREFIX + wikiName + "/tags";

return super.putRequest(Uri, buildXml(tags));

} else {
return null;
Uri =
"http://" + URLprefix + PAGE_URL_PREFIX + wikiName + "/spaces/" + spaceName + "/pages/" + pageName
+ "/tags";
return super.putRequest(Uri, buildXml(tags));
}

}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,18 @@ public String addPageTag(String wikiName, String spaceName, String pageName, Tag
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)
Expand Down Expand Up @@ -542,7 +554,7 @@ public InputStream getPageAttachment(String wikiName, String spaceName, String p
*/

@Override
public String addPageAttachment(String wikiName, String spaceName, String pageName, String filePath,
public String putPageAttachment(String wikiName, String spaceName, String pageName, String filePath,
String attachmentName) throws RestConnectionException, RestException
{
wikiName = urlEncode(wikiName);
Expand Down Expand Up @@ -805,6 +817,31 @@ public String addObject(String wikiName, String spaceName, String pageName, Obje
}
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, String 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)
Expand Down
Loading

0 comments on commit 522d7f7

Please sign in to comment.