private String getDescriptorValue(String key) { String value; try { value = JPath.evaluate(descriptor.get(), key).getString(); } catch (ParserException | IOException e) { throw new RuntimeException(e); } return value; }
@Override protected boolean matchesSafely(final Value item, final Description mismatchDescription) { Value actualValue = item.get(key); if (actualValue == null) { mismatchDescription.appendText("no property with key '" + key + "'"); return false; } if (actualValue.getValueType() != Value.TYPE.STRING) { mismatchDescription.appendText("property with key '" + key + "' is '" + actualValue.getValueType() + "'"); return false; } if (!value.equals(actualValue.getString())) { mismatchDescription.appendText("property with key '" + key + "' had value of '" + actualValue.getString() + "'"); return false; } return true; }
private String getDescriptorValue(String key) { String value; try { value = JPath.evaluate(descriptor.get(), key).getString(); } catch (ParserException | IOException e) { throw new RuntimeException(e); } return value; }
@Override protected boolean matchesSafely(final Value item, final Description mismatchDescription) { Value actualValue = item.get(key); if (actualValue == null) { mismatchDescription.appendText("no property with key '" + key + "'"); return false; } if (actualValue.getValueType() != Value.TYPE.STRING) { mismatchDescription.appendText("property with key '" + key + "' is '" + actualValue.getValueType() + "'"); return false; } if (!value.equals(actualValue.getString())) { mismatchDescription.appendText("property with key '" + key + "' had value of '" + actualValue.getString() + "'"); return false; } return true; }
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); } } }
Value errorMessageValue = statusValue.get("errorMessage"); if (errorMessageValue != null) { errorMessageReference.set(errorMessageValue.getString()); return true;
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) { } } } } }