private Map<String, Object> parseResponse(String response) { return JsonUtil.convertJsonToMap(response); }
private String attemptToParseDescriptionFromResponseBody(String responseBody) { Map<String, Object> responseEntity = JsonUtil.convertJsonToMap(responseBody); Object result = responseEntity.get("description"); return result instanceof String ? (String) result : null; }
private Object getExistingAppFileDigest(Map<String, String> envAsMap) { String applicationDeployAttributes = envAsMap.get(com.sap.cloud.lm.sl.cf.core.Constants.ENV_DEPLOY_ATTRIBUTES); Map<String, Object> deployAttributesMap = JsonUtil.convertJsonToMap(applicationDeployAttributes); return deployAttributesMap.get(com.sap.cloud.lm.sl.cf.core.Constants.ATTR_APP_CONTENT_DIGEST); }
private Object getExistingAppFileDigest(Map<String, String> envAsMap) { String applicationDeployAttributes = envAsMap.get(com.sap.cloud.lm.sl.cf.core.Constants.ENV_DEPLOY_ATTRIBUTES); Map<String, Object> deployAttributesMap = JsonUtil.convertJsonToMap(applicationDeployAttributes); return deployAttributesMap.get(com.sap.cloud.lm.sl.cf.core.Constants.ATTR_APP_CONTENT_DIGEST); }
public Platform parsePlatformJson(InputStream json) throws ParsingException { // TODO: Java 9 - Remove the second variable (https://blogs.oracle.com/darcy/more-concise-try-with-resources-statements-in-jdk-9). try (InputStream closableJson = json) { return parsePlatform(JsonUtil.convertJsonToMap(closableJson)); } catch (IOException e) { throw new IllegalStateException(e.getMessage(), e); } }
private Map<String, Object> getVcapApplicationFromEnvironment() { String vcapApplication = environment.getString(CFG_VCAP_APPLICATION); try { return JsonUtil.convertJsonToMap(vcapApplication); } catch (ParsingException e) { LOGGER.warn(format(Messages.INVALID_VCAP_APPLICATION, vcapApplication), e); return Collections.emptyMap(); } }
private static DeployedMtaMetadata parseMtaMetadata(CloudApplication app, Map<String, String> appEnv) { String envValue = appEnv.get(Constants.ENV_MTA_METADATA); if (envValue == null) { return null; } Map<String, Object> mtaMetadata = JsonUtil.convertJsonToMap(envValue); return buildMtaMetadata(app, mtaMetadata); }
private Map<String, Object> getApplicationDeployAttributes() { Map<String, String> applicationEnv = app.getEnvAsMap(); String applicationDeployAttributes = applicationEnv.get(Constants.ENV_DEPLOY_ATTRIBUTES); return JsonUtil.convertJsonToMap(applicationDeployAttributes); }
public static Map<String, Object> convertJsonToMap(String json) throws ParsingException { return convertJsonToMap(json, new TypeToken<Map<String, Object>>() { }.getType()); }
public static Map<String, Object> convertJsonToMap(InputStream json) throws ParsingException { return convertJsonToMap(json, new TypeToken<Map<String, Object>>() { }.getType()); }
static Map<String, Object> getXsPlaceholderReplacementValues(DelegateExecution context) { byte[] replacementValuesJson = (byte[]) context.getVariable(Constants.VAR_XS_PLACEHOLDER_REPLACEMENT_VALUES); return JsonUtil.convertJsonToMap(new String(replacementValuesJson, StandardCharsets.UTF_8)); }
private void updateAppDigest(Map<String, String> newAppEnv, Map<String, String> existingAppEnv) { Object existingFileDigest = getExistingAppFileDigest(existingAppEnv); if (existingFileDigest == null) { return; } String newAppDeployAttributes = newAppEnv.get(com.sap.cloud.lm.sl.cf.core.Constants.ENV_DEPLOY_ATTRIBUTES); TreeMap<String, Object> newAppDeployAttributesMap = new TreeMap<>(JsonUtil.convertJsonToMap(newAppDeployAttributes)); newAppDeployAttributesMap.put(com.sap.cloud.lm.sl.cf.core.Constants.ATTR_APP_CONTENT_DIGEST, existingFileDigest); newAppEnv.put(com.sap.cloud.lm.sl.cf.core.Constants.ENV_DEPLOY_ATTRIBUTES, JsonUtil.toJson(newAppDeployAttributesMap, true)); }
private void updateAppDigest(Map<String, String> newAppEnv, Map<String, String> existingAppEnv) { Object existingFileDigest = getExistingAppFileDigest(existingAppEnv); if (existingFileDigest == null) { return; } String newAppDeployAttributes = newAppEnv.get(com.sap.cloud.lm.sl.cf.core.Constants.ENV_DEPLOY_ATTRIBUTES); TreeMap<String, Object> newAppDeployAttributesMap = new TreeMap<>(JsonUtil.convertJsonToMap(newAppDeployAttributes)); newAppDeployAttributesMap.put(com.sap.cloud.lm.sl.cf.core.Constants.ATTR_APP_CONTENT_DIGEST, existingFileDigest); newAppEnv.put(com.sap.cloud.lm.sl.cf.core.Constants.ENV_DEPLOY_ATTRIBUTES, JsonUtil.toJson(newAppDeployAttributesMap, true)); }
private static String parseModuleName(CloudApplication app, Map<String, String> appEnv) { String envValue = appEnv.get(Constants.ENV_MTA_MODULE_METADATA); if (envValue == null) { return null; } Map<String, Object> mtaModuleMetadata = JsonUtil.convertJsonToMap(envValue); return (String) getRequired(mtaModuleMetadata, Constants.ATTR_NAME, MessageFormat.format(Messages.ENV_OF_APP_0_CONTAINS_INVALID_VALUE_FOR_1, app.getName(), Constants.ENV_MTA_MODULE_METADATA)); }
@SuppressWarnings("unchecked") protected String addPageOfResources(RestTemplate restTemplate, String controllerUrl, String path, List<Map<String, Object>> allResources, Map<String, Object> urlVariables) { String response = restTemplate.getForObject(getUrl(controllerUrl, path), String.class, urlVariables); Map<String, Object> responseMap = JsonUtil.convertJsonToMap(response); validateResponse(responseMap); List<Map<String, Object>> newResources = (List<Map<String, Object>>) responseMap.get("resources"); if (!CollectionUtils.isEmpty(newResources)) { allResources.addAll(newResources); } String nextUrl = (String) responseMap.get("next_url"); return nextUrl == null ? null : decode(nextUrl); }
private static Map<String, Object> parseAttributes(CloudApplication app, String attributesJson) { if (attributesJson == null) { return null; } try { return JsonUtil.convertJsonToMap(attributesJson); } catch (ParsingException e) { throw new ParsingException(e, Messages.COULD_NOT_PARSE_ATTRIBUTES_OF_APP_0, app.getName()); } }
private String attmeptToGetLoggingEndpoint(CloudControllerClient client) { RestTemplate restTemplate = getRestTemplate(client); String controllerUrl = client.getCloudControllerUrl() .toString(); String infoV2Url = getUrl(controllerUrl, V2_INFO_ENDPOINT); String infoV2Json = restTemplate.getForObject(infoV2Url, String.class); Map<String, Object> infoV2Map = JsonUtil.convertJsonToMap(infoV2Json); // The standard CloudFoundryOperations.getCloudInfo() method tries to retrieve the logging endpoint from a field named // 'logging_endpoint', which was replaced with 'doppler_logging_endpoint' in // https://github.com/cloudfoundry/cloud_controller_ng/commit/b02a23c38ebda79a3bbd2c78716c627147bf042f. return CloudUtil.parse(String.class, infoV2Map.get("doppler_logging_endpoint")); }
private void mergeCredentials(CloudServiceExtended service, InputStream credentialsJson) { Map<String, Object> existingCredentials = service.getCredentials(); Map<String, Object> credentials = JsonUtil.convertJsonToMap(credentialsJson); if (existingCredentials == null) { existingCredentials = Collections.emptyMap(); } Map<String, Object> result = PropertiesUtil.mergeExtensionProperties(credentials, existingCredentials); service.setCredentials(result); }
private void mergeCredentials(CloudServiceExtended service, InputStream credentialsJson) { Map<String, Object> existingCredentials = service.getCredentials(); Map<String, Object> credentials = JsonUtil.convertJsonToMap(credentialsJson); if (existingCredentials == null) { existingCredentials = Collections.emptyMap(); } Map<String, Object> result = PropertiesUtil.mergeExtensionProperties(credentials, existingCredentials); service.setCredentials(result); }
public ConfigurationSubscription toConfigurationSubscription() { try { ConfigurationFilter parsedFilter = JsonUtil.fromJson(filter, ConfigurationFilter.class); Map<String, Object> parsedResourceProperties = JsonUtil.convertJsonToMap(resourceProperties); ResourceDto resourceDto = new ResourceDto(resourceName, parsedResourceProperties); ModuleDto moduleDto = JsonUtil.fromJson(module, ModuleDto.class); return new ConfigurationSubscription(id, mtaId, spaceId, appName, parsedFilter, moduleDto, resourceDto); } catch (SLException e) { throw new IllegalStateException(format(Messages.UNABLE_TO_PARSE_SUBSCRIPTION, e.getMessage()), e); } }