Skip to content

Commit 712820b

Browse files
committed
Fix status check and return
1 parent dcfd46c commit 712820b

3 files changed

Lines changed: 10 additions & 7 deletions

File tree

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<groupId>com.chatopera.bot</groupId>
88
<artifactId>sdk</artifactId>
9-
<version>3.5.3</version>
9+
<version>3.5.4</version>
1010

1111
<name>sdk</name>
1212
<description>Java SDK for Chatopera Bot Service. Get Java API Docs at https://chatopera.github.io/chatopera-sample-java/apidocs/</description>

src/main/java/com/chatopera/bot/sdk/Chatbot.java

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ public Response command(final String method, String path, final JSONObject paylo
200200
}
201201
break;
202202
case "DELETE":
203-
if(payload != null){
203+
if (payload != null) {
204204
result = RestAPI.delete(url.toString(), auth(method, fullPath.toString()), payload);
205205
} else {
206206
result = RestAPI.delete(url.toString(), auth(method, fullPath.toString()));
@@ -232,8 +232,8 @@ public Response command(final String method, String path, final JSONObject paylo
232232
}
233233
}
234234

235-
if (result.has("msg")){
236-
if(result.isNull("msg")){
235+
if (result.has("msg")) {
236+
if (result.isNull("msg")) {
237237
resp.setMsg("");
238238
} else {
239239
resp.setMsg(result.getString("msg"));
@@ -253,8 +253,11 @@ public Response command(final String method, String path, final JSONObject paylo
253253
if (result.has("total_page"))
254254
resp.setTotal_page(result.getInt("total_page"));
255255

256-
resp.setStatus(result.optJSONObject("status", new JSONObject()));
257-
256+
if (result.has("status")) {
257+
resp.setStatus(result.optJSONObject("status", new JSONObject()));
258+
} else {
259+
resp.setStatus(null);
260+
}
258261
return resp;
259262
}
260263

src/main/java/com/chatopera/bot/sdk/TrainMgr.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public TrainMgr(final String clientId, final String clientSecret) throws Malform
5353
*/
5454
public Status getStatus() throws ChatbotException, ResourceInvalidException {
5555
Response resp = this.chatbot.command("GET", "/clause/devver/build");
56-
if (resp.getRc() == 0) {
56+
if (resp.getStatus() != null && resp.getStatus().has("retrain")) {
5757
Status status = new Status(resp.getStatus());
5858
return status;
5959
} else {

0 commit comments

Comments
 (0)