Changeset View
Changeset View
Standalone View
Standalone View
src/main/java/net/wildfyre/posts/Draft.java
Show First 20 Lines • Show All 146 Lines • ▼ Show 20 Lines | public class Draft extends PostData implements PostData.Setters<Draft> { | ||||
/** | /** | ||||
* Saves this Draft server-side. | * Saves this Draft server-side. | ||||
* | * | ||||
* <p>This method will perform the API calls in the current thread.</p> | * <p>This method will perform the API calls in the current thread.</p> | ||||
* | * | ||||
* @return This object itself, to allow method-chaining. | * @return This object itself, to allow method-chaining. | ||||
*/ | */ | ||||
public Draft save(){ | public Draft save(){ | ||||
if(isOnlyLocal) saveFirstTime(); | if (isOnlyLocal) saveFirstTime(); | ||||
else { saveAsEdit(); | else saveAsEdit(); | ||||
isOnlyLocal = false;} | |||||
return this; | return this; | ||||
} | } | ||||
void saveFirstTime(){ | void saveFirstTime(){ | ||||
try { | try { | ||||
JsonObject json = new Request(POST, "/areas/" + areaID + "/drafts/") | JsonObject json = new Request(POST, "/areas/" + areaID + "/drafts/") | ||||
.addToken(Internal.token()) | .addToken(Internal.token()) | ||||
.addJson(toJsonSimple()) | .addJson(toJsonSimple()) | ||||
.getJson() | .getJson() | ||||
.asObject(); | .asObject(); | ||||
this.update(json); | this.update(json); | ||||
area().cachedDraft(this); | area().cachedDraft(this); | ||||
isOnlyLocal = false; | |||||
} catch (IssueInTransferException e) { | } catch (IssueInTransferException e) { | ||||
e.printStackTrace(); //TODO | e.printStackTrace(); //TODO | ||||
} catch (Request.CantConnectException e) { | } catch (Request.CantConnectException e) { | ||||
e.printStackTrace(); //TODO | e.printStackTrace(); //TODO | ||||
} catch (InvalidJsonException e) { | } catch (InvalidJsonException e) { | ||||
e.printStackTrace(); //TODO | e.printStackTrace(); //TODO | ||||
Show All 35 Lines | public class Draft extends PostData implements PostData.Setters<Draft> { | ||||
} | } | ||||
void deleteServerSide() { | void deleteServerSide() { | ||||
deleteLocal(); | deleteLocal(); | ||||
try { | try { | ||||
new Request(DELETE, "/areas/" + areaID + "/drafts/" + postID) | new Request(DELETE, "/areas/" + areaID + "/drafts/" + postID) | ||||
.addToken(Internal.token()) | .addToken(Internal.token()) | ||||
.getJson(); | .getRaw(); | ||||
CLOVIS: Why do you get it raw here? | |||||
Done Inline ActionsServer returns 204 No Content Hackintosh5: Server returns 204 No Content
As the name says, there's No Content. A valid JSON string must… | |||||
Done Inline ActionsOK CLOVIS: OK | |||||
//Nothing to do | //Nothing to do | ||||
} catch (IssueInTransferException e) { | } catch (IssueInTransferException e) { | ||||
e.printStackTrace(); //TODO: see T262 | e.printStackTrace(); //TODO: see T262 | ||||
} catch (Request.CantConnectException e) { | } catch (Request.CantConnectException e) { | ||||
e.printStackTrace(); //TODO: see T262 | e.printStackTrace(); //TODO: see T262 | ||||
} | } | ||||
▲ Show 20 Lines • Show All 60 Lines • Show Last 20 Lines |
Why do you get it raw here?