/*-
* ============LICENSE_START=======================================================
- * OPENECOMP - MSO
+ * ONAP - SO
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017 Huawei Technologies Co., Ltd. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
package org.openecomp.mso.openstack.utils;
-
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
* @param tenantId The Openstack ID of the tenant in which to create the Stack
* @param cloudSiteId The cloud identifier (may be a region) in which to create the tenant.
* @param stackName The name of the stack to update
- * @param stackTemplate The Heat template
+ * @param heatTemplate The Heat template
* @param stackInputs A map of key/value inputs
* @param pollForCompletion Indicator that polling should be handled in Java vs. in the client
* @param environment An optional yaml-format string to specify environmental parameters
}
// Obtain the cloud site information where we will create the stack
- CloudSite cloudSite = cloudConfig.getCloudSite (cloudSiteId);
- if (cloudSite == null) {
- throw new MsoCloudSiteNotFound (cloudSiteId);
- }
+ CloudSite cloudSite = cloudConfig.getCloudSite(cloudSiteId).orElseThrow(
+ () -> new MsoCloudSiteNotFound(cloudSiteId));
// Get a Heat client. They are cached between calls (keyed by tenantId:cloudId)
// This could throw MsoTenantNotFound or MsoOpenstackException (both propagated)
Heat heatClient = getHeatClient (cloudSite, tenantId);
if (haveFiles && haveHeatFiles) {
// Let's do this here - not in the bean
LOGGER.debug ("Found files AND heatFiles - combine and add!");
- Map <String, Object> combinedFiles = new HashMap <String, Object> ();
+ Map <String, Object> combinedFiles = new HashMap<>();
for (String keyString : files.keySet ()) {
combinedFiles.put (keyString, files.get (keyString));
}
try {
LOGGER.debug("Current stack " + this.getOutputsAsStringBuilder(heatStack).toString());
} catch (Exception e) {
- LOGGER.debug("an error occurred trying to print out the current outputs of the stack");
+ LOGGER.debug("an error occurred trying to print out the current outputs of the stack", e);
}
sb.append("(outputs is empty)");
return sb;
}
- Map<String, Object> outputs = new HashMap<String,Object>();
+ Map<String, Object> outputs = new HashMap<>();
for (Output outputItem : outputList) {
outputs.put(outputItem.getOutputKey(), outputItem.getOutputValue());
}
int counter = 0;
sb.append("OUTPUTS:\n");
for (String key : outputs.keySet()) {
- sb.append("outputs[" + counter++ + "]: " + key + "=");
+ sb.append("outputs[").append(counter++).append("]: ").append(key).append("=");
Object obj = outputs.get(key);
if (obj instanceof String) {
- sb.append((String)obj +" (a string)");
+ sb.append((String) obj).append(" (a string)");
} else if (obj instanceof JsonNode) {
- sb.append(this.convertNode((JsonNode)obj) + " (a JsonNode)");
+ sb.append(this.convertNode((JsonNode) obj)).append(" (a JsonNode)");
} else if (obj instanceof java.util.LinkedHashMap) {
try {
String str = JSON_MAPPER.writeValueAsString(obj);
- sb.append(str + " (a java.util.LinkedHashMap)");
+ sb.append(str).append(" (a java.util.LinkedHashMap)");
} catch (Exception e) {
+ LOGGER.debug("Exception :", e);
sb.append("(a LinkedHashMap value that would not convert nicely)");
}
} else if (obj instanceof Integer) {
try {
str = obj.toString() + " (an Integer)\n";
} catch (Exception e) {
+ LOGGER.debug("Exception :", e);
str = "(an Integer unable to call .toString() on)";
}
sb.append(str);
try {
str = obj.toString() + " (an ArrayList)";
} catch (Exception e) {
+ LOGGER.debug("Exception :", e);
str = "(an ArrayList unable to call .toString() on?)";
}
sb.append(str);
try {
str = obj.toString() + " (a Boolean)";
} catch (Exception e) {
+ LOGGER.debug("Exception :", e);
str = "(an Boolean unable to call .toString() on?)";
}
sb.append(str);
try {
str = obj.toString() + " (unknown Object type)";
} catch (Exception e) {
+ LOGGER.debug("Exception :", e);
str = "(a value unable to call .toString() on?)";
}
sb.append(str);
final Object obj = JSON_MAPPER.treeToValue(node, Object.class);
final String json = JSON_MAPPER.writeValueAsString(obj);
return json;
- } catch (JsonParseException jpe) {
- LOGGER.debug("Error converting json to string " + jpe.getMessage());
} catch (Exception e) {
- LOGGER.debug("Error converting json to string " + e.getMessage());
+ LOGGER.debug("Error converting json to string " + e.getMessage(), e);
}
return "[Error converting json to string]";
}