public JSON getClientHttpDataJson() throws IOException, ParserException { return JSON.parse(waitForValue("client-http-data-json")); } }
public JSON getClientHttpDataJson() throws IOException, ParserException { return JSON.parse(waitForValue("client-http-data-json")); } }
public JSON testDeserializerByIdentifier(String deserializerIdentifier) throws Exception { HttpGet get = new HttpGet(baseUrl + TEST_STORAGE_URL + "/identifier/" + deserializerIdentifier); get.addHeader(HttpHeaders.ACCEPT, APPLICATION_JSON); ResponseHandler<String> responseHandler = new BasicResponseHandler(); String response = userRequestSender.sendRequestAsUser(get, responseHandler, defaultUsername, defaultPassword); return JSON.parse(response); } }
@Override protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { if (req.getRequestURI().endsWith("/webhook") || req.getRequestURI().endsWith("-lifecycle")) { String version = req.getHeader(HttpHeaderNames.ATLASSIAN_CONNECT_VERSION); final String authorizationHeader = getAuthorizationHeader(req); try { webHooksQueue.push(new JsonWebHookBody(getFullURL(req), JSON.parse(IOUtils.toString(req.getReader())), version, authorizationHeader)); resp.getWriter().write("OKEY DOKEY"); } catch (ParserException e) { throw new ServletException(e); } } }
@Override protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { if (req.getRequestURI().endsWith("/webhook") || req.getRequestURI().endsWith("-lifecycle")) { String version = req.getHeader(HttpHeaderNames.ATLASSIAN_CONNECT_VERSION); final String authorizationHeader = getAuthorizationHeader(req); try { String readerToParse = IOUtils.toString(req.getReader()); JSON json = readerToParse.equals("") ? null : JSON.parse(readerToParse); webHooksQueue.push(new JsonWebHookBody(getFullURL(req), json, version, authorizationHeader)); resp.getWriter().write("OKEY DOKEY"); } catch (ParserException e) { throw new ServletException(e); } } }
private JSON getPluginJson(String addonKey) { try { return JSON.parse(connectClient.getUpmPluginJson(addonKey)); } catch (Exception e) { fail("add-on is not installed"); return null; } }
public void run(final String defaultUsername, final String defaultPassword) throws Exception { Callable<Boolean> statusChecker = () -> { HttpGet statusGet = new HttpGet(statusUrl); ResponseHandler<String> statusHandler = new BasicResponseHandler(); String response = userRequestSender.sendRequestAsUser(statusGet, statusHandler, defaultUsername, defaultPassword); if (null != response && StringUtils.isNotBlank(response) && response.startsWith("{") && response.endsWith("}")) { JSON json = JSON.parse(response); return (null != json.get("enabled")); } return false; }; ScheduledFuture<Boolean> statusCheck = scheduledExecutor.schedule(statusChecker, period, TimeUnit.MILLISECONDS); long abortAfter = System.currentTimeMillis() + timeout; while (!statusCheck.get() && abortAfter > System.currentTimeMillis()) { statusCheck = scheduledExecutor.schedule(statusChecker, period, TimeUnit.MILLISECONDS); } if (abortAfter <= System.currentTimeMillis()) { throw new ConnectAddonInstallException("Connect App Plugin did not install within the allotted timeout"); } } }
public void install(String registerUrl, boolean checkStatus) throws Exception { //get a upm token String token = getUpmToken(); HttpPost post = new HttpPost(baseUrl + UPM_URL_PATH + "?token=" + token); post.addHeader(HttpHeaders.ACCEPT, APPLICATION_JSON); final ObjectNode installRequest = JsonNodeFactory.instance.objectNode(); installRequest.put("pluginUri", registerUrl); installRequest.put("pluginName", "the plugin name"); post.setEntity(new StringEntity(installRequest.toString(), ContentType.create("application/vnd.atl.plugins.install.uri+json"))); ResponseHandler<String> responseHandler = new BasicResponseHandler(); String response = userRequestSender.sendRequestAsUser(post, responseHandler, defaultUsername, defaultPassword); if (Strings.isNullOrEmpty(response) || (!response.startsWith("{") && !response.endsWith("}"))) { install(registerUrl); } else { JSON json = JSON.parse(response); if (null == json.get("enabled")) { URI uri = new URI(baseUrl); final String statusUrl = uri.getScheme() + "://" + uri.getHost() + ":" + uri.getPort() + json.get("links").get("self").getString(); // JCE-635 the timeout here used to be 1 minute but needed to be bumped - it should be changed back if possible InstallStatusChecker statusChecker = checkStatus ? new InstallStatusChecker(userRequestSender, statusUrl, 4, TimeUnit.MINUTES, 500, TimeUnit.MILLISECONDS) : new InstallStatusChecker(userRequestSender, statusUrl, 5, TimeUnit.SECONDS, 500, TimeUnit.MILLISECONDS); statusChecker.run(defaultUsername, defaultPassword); } } }
String response = userRequestSender.sendRequestAsUser(statusGet, statusHandler, defaultUsername, defaultPassword); if (null != response && StringUtils.isNotBlank(response) && response.startsWith("{") && response.endsWith("}")) { JSON json = JSON.parse(response);
public void install(String registerUrl, boolean checkStatus) throws Exception { //get a upm token String token = getUpmToken(); HttpPost post = new HttpPost(baseUrl + UPM_URL_PATH + "?token=" + token); post.addHeader("Accept", "application/json"); post.setEntity(new StringEntity("{ \"pluginUri\": \"" + registerUrl + "\", \"pluginName\": \"the plugin name\" }", ContentType.create("application/vnd.atl.plugins.install.uri+json"))); ResponseHandler<String> responseHandler = new BasicResponseHandler(); String response = userRequestSender.sendRequestAsUser(post, responseHandler, defaultUsername, defaultPassword); if (Strings.isNullOrEmpty(response) || (!response.startsWith("{") && !response.endsWith("}"))) { install(registerUrl); } else { JSON json = JSON.parse(response); if (null == json.get("enabled")) { URI uri = new URI(baseUrl); final String statusUrl = uri.getScheme() + "://" + uri.getHost() + ":" + uri.getPort() + json.get("links").get("self").getString(); if (checkStatus) { InstallStatusChecker statusChecker = new InstallStatusChecker(userRequestSender, statusUrl, 1, TimeUnit.MINUTES, 500, TimeUnit.MILLISECONDS); statusChecker.run(defaultUsername, defaultPassword); } else { InstallStatusChecker statusChecker = new InstallStatusChecker(userRequestSender, statusUrl, 5, TimeUnit.SECONDS, 500, TimeUnit.MILLISECONDS); try { statusChecker.run(defaultUsername, defaultPassword); } catch (Exception e) { } } } } }