Loading src/com/owncloud/android/lib/common/operations/RemoteOperationResult.java +2 −1 Original line number Diff line number Diff line Loading @@ -122,7 +122,8 @@ public class RemoteOperationResult implements Serializable { NOT_AVAILABLE, MAINTENANCE_MODE, LOCK_FAILED, DELAYED_IN_POWER_SAVE_MODE DELAYED_IN_POWER_SAVE_MODE, ACCOUNT_USES_OLD_LOGIN } private boolean mSuccess = false; Loading src/com/owncloud/android/lib/resources/notifications/RegisterAccountDeviceForNotificationsOperation.java +16 −2 Original line number Diff line number Diff line Loading @@ -55,10 +55,12 @@ public class RegisterAccountDeviceForNotificationsOperation extends RemoteOperat // JSON Node names private static final String NODE_OCS = "ocs"; private static final String NODE_DATA = "data"; private static final String MESSAGE = "message"; private static final String PUSH_TOKEN_HASH = "pushTokenHash"; private static final String DEVICE_PUBLIC_KEY = "devicePublicKey"; private static final String PROXY_SERVER = "proxyServer"; private static final String INVALID_SESSION_TOKEN = "INVALID_SESSION_TOKEN"; private String pushTokenHash; private String devicePublicKey; Loading Loading @@ -101,7 +103,11 @@ public class RegisterAccountDeviceForNotificationsOperation extends RemoteOperat pushResponse = parseResult(response); result.setPushResponseData(pushResponse); } else { if (isInvalidSessionToken(response)) { result = new RemoteOperationResult(false, status, post.getResponseHeaders()); } else { result = new RemoteOperationResult(RemoteOperationResult.ResultCode.ACCOUNT_USES_OLD_LOGIN); } } } catch (Exception e) { Loading @@ -127,6 +133,14 @@ public class RegisterAccountDeviceForNotificationsOperation extends RemoteOperat return gson.fromJson(jsonDataObject, pushResponseType); } private boolean isInvalidSessionToken(String response) { JsonParser jsonParser = new JsonParser(); JsonObject jo = (JsonObject)jsonParser.parse(response); String message = String.valueOf(jo.getAsJsonObject(NODE_OCS).getAsJsonObject(NODE_DATA).get(MESSAGE)); return INVALID_SESSION_TOKEN.equals(message); } private boolean isSuccess(int status) { return (status == HttpStatus.SC_OK || status == HttpStatus.SC_CREATED); } Loading Loading
src/com/owncloud/android/lib/common/operations/RemoteOperationResult.java +2 −1 Original line number Diff line number Diff line Loading @@ -122,7 +122,8 @@ public class RemoteOperationResult implements Serializable { NOT_AVAILABLE, MAINTENANCE_MODE, LOCK_FAILED, DELAYED_IN_POWER_SAVE_MODE DELAYED_IN_POWER_SAVE_MODE, ACCOUNT_USES_OLD_LOGIN } private boolean mSuccess = false; Loading
src/com/owncloud/android/lib/resources/notifications/RegisterAccountDeviceForNotificationsOperation.java +16 −2 Original line number Diff line number Diff line Loading @@ -55,10 +55,12 @@ public class RegisterAccountDeviceForNotificationsOperation extends RemoteOperat // JSON Node names private static final String NODE_OCS = "ocs"; private static final String NODE_DATA = "data"; private static final String MESSAGE = "message"; private static final String PUSH_TOKEN_HASH = "pushTokenHash"; private static final String DEVICE_PUBLIC_KEY = "devicePublicKey"; private static final String PROXY_SERVER = "proxyServer"; private static final String INVALID_SESSION_TOKEN = "INVALID_SESSION_TOKEN"; private String pushTokenHash; private String devicePublicKey; Loading Loading @@ -101,7 +103,11 @@ public class RegisterAccountDeviceForNotificationsOperation extends RemoteOperat pushResponse = parseResult(response); result.setPushResponseData(pushResponse); } else { if (isInvalidSessionToken(response)) { result = new RemoteOperationResult(false, status, post.getResponseHeaders()); } else { result = new RemoteOperationResult(RemoteOperationResult.ResultCode.ACCOUNT_USES_OLD_LOGIN); } } } catch (Exception e) { Loading @@ -127,6 +133,14 @@ public class RegisterAccountDeviceForNotificationsOperation extends RemoteOperat return gson.fromJson(jsonDataObject, pushResponseType); } private boolean isInvalidSessionToken(String response) { JsonParser jsonParser = new JsonParser(); JsonObject jo = (JsonObject)jsonParser.parse(response); String message = String.valueOf(jo.getAsJsonObject(NODE_OCS).getAsJsonObject(NODE_DATA).get(MESSAGE)); return INVALID_SESSION_TOKEN.equals(message); } private boolean isSuccess(int status) { return (status == HttpStatus.SC_OK || status == HttpStatus.SC_CREATED); } Loading