+ public JsonNode getAsdContentNode(String asdContent) throws JsonProcessingException {
+ return objectMapper.readTree(new Gson().toJsonTree(new Yaml().load(asdContent)).toString());
+ }
+
+ String getAsdDefinitionLocation(final File csarFile) {
+ return getAsdDefinitionLocation(
+ getFileFromCsar(csarFile, RappCsarPathProvider.TOSCA_METADATA_LOCATION).toString());
+ }
+
+ public String getAsdDefinitionLocation(final String toscaMetadata) {
+ String asdLocation = "";
+ if (toscaMetadata != null && !toscaMetadata.isEmpty()) {
+ final String entry = filter(on("\n").split(toscaMetadata),
+ line -> line.contains(RappCsarPathProvider.ENTRY_DEFINITIONS_INDEX)).iterator().next();
+ asdLocation = entry.replace(RappCsarPathProvider.ENTRY_DEFINITIONS_INDEX + ":", "").trim();
+ }
+ return asdLocation;
+ }
+
+ public List<DeploymentItem> getDeploymentItems(Rapp rApp) {
+ List<DeploymentItem> deploymentItems = new ArrayList<>();
+ File csarFile = getCsarFile(rApp);
+ String asdDefinitionLocation = getAsdDefinitionLocation(csarFile);
+ if (asdDefinitionLocation != null && !asdDefinitionLocation.isEmpty()) {
+ try {
+ String asdContent = getFileFromCsar(csarFile, asdDefinitionLocation).toString();
+ JsonNode jsonNode = getAsdContentNode(asdContent);
+ JsonNode artifactsJsonNode = jsonNode.at(RappCsarPathProvider.ARTIFACTS_LOCATION_JSON_POINTER);
+ artifactsJsonNode.forEach(artifactJsonNode -> {
+ DeploymentItem deploymentItem =
+ objectMapper.convertValue(artifactJsonNode.at("/properties"), DeploymentItem.class);
+ deploymentItem.setFile(artifactJsonNode.at("/file").asText());
+ deploymentItems.add(deploymentItem);
+ });
+ } catch (Exception e) {
+ logger.warn("Unable to get the deployment items", e);
+ }
+ }
+ return deploymentItems;
+ }
+