private void auth(KevoreeRegistryClient client) throws MojoExecutionException, UnirestException, KevoreeRegistryException { HttpResponse<RAuth> authRes = client.auth(login, password); if (authRes.getStatus() == 401) { throw new MojoExecutionException("You are not logged in"); } else { throw new MojoExecutionException("Something went wrong while authenticating " + login + " (status: " + authRes.getStatusText()+")"); } } }
case 400: logger.error( "ClientRequestMalformed returned by Microcks server: " + response.getStatusText()); throw new MicrocksConnectorException("ClientRequestMalformed returned by Microcks server"); case 500: throw new MicrocksConnectorException("InternalServerError returned by Microcks server"); default: logger.error("Unexpected response from Microcks server: " + response.getStatusText()); throw new MicrocksConnectorException( "Unexpected response by Microcks server: " + response.getStatusText());
.header("Accept", "application/json").header("Authorization", "token " + githubPAT).asJson(); if (response.getStatus() != 200) { throw new Exception("Failed to list Issues: " + response.getStatusText());
protected JSONObject getJSonResponse(BaseRequest request) throws UnirestException { HttpResponse<String> response = request.asString(); if (response.getStatus() == 423) { String error = new JSONObject(response.getBody()).getString("detail"); throw new SeleniumRobotServerException(error); } if (response.getStatus() >= 400) { try { String error = new JSONObject(response.getBody()).getString("detail"); throw new SeleniumRobotServerException(String.format("request to %s failed: %s", request.getHttpRequest().getUrl(), error)); } catch (Exception e) { throw new UnirestException(String.format("request to %s failed: %s", request.getHttpRequest().getUrl(), response.getStatusText())); } } if (response.getStatus() == 204) { return new JSONObject(); } return new JSONObject(response.getBody()); }
protected JSONArray getJSonArray(BaseRequest request) throws UnirestException { HttpResponse<String> response = request.asString(); if (response.getStatus() == 423) { String error = new JSONObject(response.getBody()).getString("detail"); throw new SeleniumRobotServerException(error); } if (response.getStatus() >= 400) { try { String error = new JSONObject(response.getBody()).getString("detail"); throw new SeleniumRobotServerException(String.format("request to %s failed: %s", request.getHttpRequest().getUrl(), error)); } catch (Exception e) { throw new UnirestException(String.format("request to %s failed: %s", request.getHttpRequest().getUrl(), response.getStatusText())); } } if (response.getStatus() == 204) { return new JSONArray(); } return new JSONArray(response.getBody()); }
+ response.getStatus()+":" + response.getStatusText() +"\n" +response.getBody());
throw new UnirestException("Unexpected response from Bitbucket: " + response.getStatus() + "::" + response.getStatusText());
throw new UnirestException("Unexpected response from Bitbucket: " + response.getStatus() + "::" + response.getStatusText());
throw new MojoExecutionException("Namespace \""+namespace+"\" does not exist in the registry"); } else { throw new MojoExecutionException("Unable to create " + namespace + "." + tdef.getName() + "/" + tdef.getVersion() + "(status: " + newTdefRes.getStatusText() + ")"); throw new MojoExecutionException("Unable to find " + namespace + "." + tdef.getName() + "/" + tdef.getVersion() + " (status: " + tdefRes.getStatusText() + ")");
logger.error("Mise à jour du statut impossible: " + response.getStatusText());
/** * connect to server */ @Override public void login() { if (!initialized) { throw new ConfigurationException("test manager has not been previously initialized"); } try { HttpResponse<String> response = Unirest.get(serverUrl + "/authentication-point/authenticate") .basicAuth(user, password).asString(); if (response.getStatus() != 200) { throw new ConfigurationException("Cannot connect to HP server: " + response.getStatusText()); } } catch (UnirestException e) { throw new ConfigurationException("Cannot connect to HP server", e); } loggedIn = true; }
HttpResponse<JsonNode> response = request.body(requestBody).asJson(); if (response.getStatus() != 200) { throw new UnirestException("Unexpected response from GitHub: " + response.getStatus() + "::" + response.getStatusText());
getLog().info("Successfully updated"); } else { throw new MojoExecutionException("Unable to update DeployUnit " + regDu.getPlatform() + ":" + regDu.getName() + ":" + regDu.getVersion() + " (status: " + updatedDuRes.getStatusText() + ")"); getLog().info("Successfully created"); } else { throw new MojoExecutionException("Unable to create DeployUnit " + newDu.getPlatform() + ":" + newDu.getName() + ":" + newDu.getVersion() + " (status=" + newDuRes.getStatusText() + ")");
throw new UnirestException("Unexpected response from Bitbucket: " + responseStatus + "::" + response.getStatusText());
/** * @see io.apicurio.hub.api.connectors.ISourceConnector#createResourceContent(java.lang.String, java.lang.String, java.lang.String) */ @Override public void createResourceContent(String repositoryUrl, String commitMessage, String content) throws SourceConnectorException { try { String b64Content = Base64.encodeBase64String(content.getBytes(StandardCharsets.UTF_8)); GitHubResource resource = GitHubResourceResolver.resolve(repositoryUrl); GitHubCreateFileRequest requestBody = new GitHubCreateFileRequest(); requestBody.setMessage(commitMessage); requestBody.setContent(b64Content); requestBody.setBranch(resource.getBranch()); String createContentUrl = this.endpoint("/repos/:org/:repo/contents/:path") .bind("org", resource.getOrganization()) .bind("repo", resource.getRepository()) .bind("path", resource.getResourcePath()) .toString(); HttpRequestWithBody request = Unirest.put(createContentUrl).header("Content-Type", "application/json; charset=utf-8"); addSecurityTo(request); HttpResponse<InputStream> response = request.body(requestBody).asBinary(); if (response.getStatus() != 201) { throw new UnirestException("Unexpected response from GitHub: " + response.getStatus() + "::" + response.getStatusText()); } } catch (UnirestException e) { logger.error("Error creating Github resource content.", e); throw new SourceConnectorException("Error creating Github resource content.", e); } }
@Override public void open() throws TexeraException { if (cursor == OPENED) { return; } try { String asterixAddress = "http://" + predicate.getHost() + ":" + predicate.getPort() + "/query/service"; String asterixQuery = generateAsterixQuery(predicate); HttpResponse<JsonNode> jsonResponse = Unirest.post(asterixAddress) .queryString("statement", asterixQuery) .field("mode", "immediate") .asJson(); // if status is 200 OK, store the results if (jsonResponse.getStatus() == 200) { this.resultJsonArray = jsonResponse.getBody().getObject().getJSONArray("results"); } else { throw new DataflowException("Send query to asterix failed: " + "error status: " + jsonResponse.getStatusText() + ", " + "error body: " + jsonResponse.getBody().toString()); } cursor = OPENED; } catch (UnirestException e) { throw new DataflowException(e); } }
return (TypeDefinition) model.findByPath("/packages[" + fqn.namespace + "]/typeDefinitions[name=" + fqn.name + ",version=" + fqn.version.tdef + "]"); } else { throw new KevScriptException("Unable to find " + fqn.namespace + "." + fqn.name + "/" + fqn.version + " in " + this.client.baseUrl() + " (status: " + tdefRes.getStatusText() + ")");
throw new UnirestException("Unexpected response from GitHub: " + response.getStatus() + "::" + response.getStatusText());
throw new UnirestException("Unexpected response from Bitbucket: " + response.getStatus() + "::" + response.getStatusText());
/** * Uses the GH API to add a commit comment. * @param repositoryUrl * @param commitSha * @param commitComment * @throws UnirestException * @throws SourceConnectorException */ private void addCommitComment(String repositoryUrl, String commitSha, String commitComment) throws UnirestException, SourceConnectorException { GitHubCreateCommitCommentRequest body = new GitHubCreateCommitCommentRequest(); body.setBody(commitComment); GitHubResource resource = GitHubResourceResolver.resolve(repositoryUrl); String addCommentUrl = this.endpoint("/repos/:org/:repo/commits/:sha/comments") .bind("org", resource.getOrganization()) .bind("repo", resource.getRepository()) .bind("path", resource.getResourcePath()) .bind("sha", commitSha) .toString(); HttpRequestWithBody request = Unirest.post(addCommentUrl).header("Content-Type", "application/json; charset=utf-8"); addSecurityTo(request); HttpResponse<JsonNode> response = request.body(body).asJson(); if (response.getStatus() != 201) { throw new UnirestException("Unexpected response from GitHub: " + response.getStatus() + "::" + response.getStatusText()); } }