Package org.fluxtream.core.connectors.updaters

Examples of org.fluxtream.core.connectors.updaters.UpdateFailedException


                                                                                                                                                "oauth with the Withings API. Please head to <a href=\"javascript:App.manageConnectors()\">Manage Connectors</a>,<br>" +
                                                                                                                                                "scroll to the Withings connector, and renew your tokens (look for the <i class=\"icon-resize-small icon-large\"></i> icon)");
            // Record permanent failure since this connector won't work again until
            // it is reauthenticated
            guestService.setApiKeyStatus(updateInfo.apiKey.getId(), ApiKey.Status.STATUS_PERMANENT_FAILURE, null, ApiKey.PermanentFailReason.NEEDS_REAUTH);
            throw new UpdateFailedException("requires token reauthorization",true, ApiKey.PermanentFailReason.NEEDS_REAUTH);
        }

        // do v1 API call
        String url = "http://wbsapi.withings.net/measure";
        Map<String,String> parameters = new HashMap<String,String>();
View Full Code Here


            final Token token = new Token(accessToken, guestService.getApiKeyAttribute(updateInfo.apiKey, "tokenSecret"));
            service.signRequest(token, request);
            Response response = request.send();
            httpResponseCode = response.getCode();
            if (httpResponseCode!=200)
                throw new UpdateFailedException("Unexpected response code: " + httpResponseCode);
            String json = response.getBody();
            JSONObject jsonObject = JSONObject.fromObject(json);
            final int withingsStatusCode = jsonObject.getInt("status");
            String message = null;
            if (withingsStatusCode !=0) {
                switch (withingsStatusCode) {
                    case 247:
                        message = "247 : The userid provided is absent, or incorrect";
                        throw new UpdateFailedException(message, true,
                                                        ApiKey.PermanentFailReason.unknownReason(message));
                    case 250:
                        // 250 : The provided userid and/or Oauth credentials do not match
                        throw new AuthExpiredException();
                    case 286:
                        message = "286 : No such subscription was found";
                        throw new UpdateFailedException(message, true,
                                                        ApiKey.PermanentFailReason.unknownReason(message));
                    case 293:
                        message = "293 : The callback URL is either absent or incorrect";
                        throw new UpdateFailedException(message, true,
                                                        ApiKey.PermanentFailReason.unknownReason(message));
                    case 294:
                        message = "294 : No such subscription could be deleted";
                        throw new UpdateFailedException(message, true,
                                                        ApiKey.PermanentFailReason.unknownReason(message));
                    case 304:
                        message = "304 : The comment is either absent or incorrect";
                        throw new UpdateFailedException(message, true,
                                                        ApiKey.PermanentFailReason.unknownReason(message));
                    case 305:
                        // 305: Too many notifications are already set
                        throw new RateLimitExceededException();
                    case 342:
                        message = "342 : The signature (using Oauth) is invalid";
                        throw new UpdateFailedException( message, true,
                                                        ApiKey.PermanentFailReason.unknownReason(message));
                    case 343:
                        message = "343 : Wrong Notification Callback Url don't exist";
                        throw new UpdateFailedException(message, true,
                                                        ApiKey.PermanentFailReason.unknownReason(message));
                    case 601:
                        // 601: Too Many Requests
                        throw new RateLimitReachedException();
                    case 2554:
                        message = "2554 : Wrong action or wrong webservice";
                        throw new UpdateFailedException(message, true,
                                                        ApiKey.PermanentFailReason.unknownReason(message));
                    case 2555:
                        message = "2555 : An unknown error occurred";
                        throw new UpdateFailedException(message, false,
                                                        ApiKey.PermanentFailReason.unknownReason(message));
                    case 2556:
                        message = "2556 : Service is not defined";
                        throw new UpdateFailedException(message, true,
                                                        ApiKey.PermanentFailReason.unknownReason(message));
                    default:
                    throw new UnexpectedHttpResponseCodeException(withingsStatusCode, "Unexpected status code: " + withingsStatusCode);
                }
View Full Code Here

TOP

Related Classes of org.fluxtream.core.connectors.updaters.UpdateFailedException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.