diff options
4 files changed, 84 insertions, 99 deletions
diff --git a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoYamlEditorWithEnvt.java b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoYamlEditorWithEnvt.java index c227d72f0c..8002087ddd 100644 --- a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoYamlEditorWithEnvt.java +++ b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoYamlEditorWithEnvt.java @@ -27,6 +27,7 @@ import java.io.ByteArrayInputStream; import java.io.InputStream; import java.util.HashSet; import java.util.Iterator; +import java.util.LinkedHashMap; import java.util.Map; import java.util.Set; import java.util.Map.Entry; @@ -73,33 +74,32 @@ public class MsoYamlEditorWithEnvt { if (resourceMap == null) { return paramSet; } - Iterator <Entry <String, Object>> it = resourceMap.entrySet().iterator(); - - while (it.hasNext()) { - MsoHeatEnvironmentParameter hep = new MsoHeatEnvironmentParameter(); - Map.Entry <String, Object> pair = it.next(); - String value; - Object obj = pair.getValue(); - if (obj instanceof java.lang.String) { - value = yaml.dump(obj); - // but this adds an extra '\n' at the end - which won't hurt - but we don't need it - value = value.substring(0, value.length() - 1); - } else if (obj instanceof java.util.LinkedHashMap) { - //Handle that it's json - try { - value = JSON_MAPPER.writeValueAsString(obj); - } catch (Exception e) { - LOGGER.debug("Exception:", e); - value = "_BAD_JSON_MAPPING"; - } - } else { - //this handles integers/longs/floats/etc. - value = String.valueOf(obj); - } - hep.setName((String) pair.getKey()); - hep.setValue(value); - paramSet.add(hep); - } + + for (Entry<String, Object> stringObjectEntry : resourceMap.entrySet()) { + MsoHeatEnvironmentParameter hep = new MsoHeatEnvironmentParameter(); + Entry<String, Object> pair = stringObjectEntry; + String value; + Object obj = pair.getValue(); + if (obj instanceof String) { + value = yaml.dump(obj); + // but this adds an extra '\n' at the end - which won't hurt - but we don't need it + value = value.substring(0, value.length() - 1); + } else if (obj instanceof LinkedHashMap) { + //Handle that it's json + try { + value = JSON_MAPPER.writeValueAsString(obj); + } catch (Exception e) { + LOGGER.debug("Exception:", e); + value = "_BAD_JSON_MAPPING"; + } + } else { + //this handles integers/longs/floats/etc. + value = String.valueOf(obj); + } + hep.setName((String) pair.getKey()); + hep.setValue(value); + paramSet.add(hep); + } return paramSet; } public synchronized Set <MsoHeatEnvironmentResource> getResourceListFromEnvt() { @@ -107,15 +107,14 @@ public class MsoYamlEditorWithEnvt { Set<MsoHeatEnvironmentResource> resourceList = new HashSet<>(); @SuppressWarnings("unchecked") Map<String, Object> resourceMap = (Map<String,Object>) yml.get("resource_registry"); - Iterator<Entry <String,Object>> it = resourceMap.entrySet().iterator(); - - while (it.hasNext()) { - MsoHeatEnvironmentResource her = new MsoHeatEnvironmentResource(); - Map.Entry<String, Object> pair = it.next(); - her.setName((String) pair.getKey()); - her.setValue((String) pair.getValue()); - resourceList.add(her); - } + + for (Entry<String, Object> stringObjectEntry : resourceMap.entrySet()) { + MsoHeatEnvironmentResource her = new MsoHeatEnvironmentResource(); + Entry<String, Object> pair = stringObjectEntry; + her.setName((String) pair.getKey()); + her.setValue((String) pair.getValue()); + resourceList.add(her); + } return resourceList; } catch (Exception e) { LOGGER.debug("Exception:", e); @@ -126,35 +125,34 @@ public class MsoYamlEditorWithEnvt { Set <HeatTemplateParam> paramSet = new HashSet <> (); @SuppressWarnings("unchecked") Map <String, Object> resourceMap = (Map <String, Object>) yml.get ("parameters"); - Iterator <Entry <String, Object>> it = resourceMap.entrySet ().iterator (); - while (it.hasNext ()) { - HeatTemplateParam param = new HeatTemplateParam (); - Map.Entry <String, Object> pair = it.next (); + for (Entry<String, Object> stringObjectEntry : resourceMap.entrySet()) { + HeatTemplateParam param = new HeatTemplateParam(); + Entry<String, Object> pair = stringObjectEntry; @SuppressWarnings("unchecked") - Map <String, String> resourceEntry = (Map <String, String>) pair.getValue (); + Map<String, String> resourceEntry = (Map<String, String>) pair.getValue(); String value = null; try { - value = resourceEntry.get ("default"); - } catch (java.lang.ClassCastException cce) { + value = resourceEntry.get("default"); + } catch (ClassCastException cce) { LOGGER.debug("Exception:", cce); - // This exception only - the value is an integer. For what we're doing - // here - we don't care - so set value to something - and it will - // get marked as not being required - which is correct. - //System.out.println("cce exception!"); - value = "300"; - // okay + // This exception only - the value is an integer. For what we're doing + // here - we don't care - so set value to something - and it will + // get marked as not being required - which is correct. + //System.out.println("cce exception!"); + value = "300"; + // okay } - param.setParamName ((String) pair.getKey ()); + param.setParamName((String) pair.getKey()); if (value != null) { - param.setRequired (false); + param.setRequired(false); } else { - param.setRequired (true); + param.setRequired(true); } - value = resourceEntry.get ("type"); - param.setParamType (value); + value = resourceEntry.get("type"); + param.setParamType(value); - paramSet.add (param); + paramSet.add(param); } return paramSet; diff --git a/asdc-controller/src/main/java/org/openecomp/mso/asdc/util/YamlEditor.java b/asdc-controller/src/main/java/org/openecomp/mso/asdc/util/YamlEditor.java index f94e0a153b..a90fdeb8e6 100644 --- a/asdc-controller/src/main/java/org/openecomp/mso/asdc/util/YamlEditor.java +++ b/asdc-controller/src/main/java/org/openecomp/mso/asdc/util/YamlEditor.java @@ -82,12 +82,10 @@ public class YamlEditor { @SuppressWarnings("unchecked") Map <String, Object> resourceMap = (Map <String, Object>) yml.get ("resources"); - Iterator <Entry <String, Object>> it = resourceMap.entrySet ().iterator (); - while (it.hasNext ()) { - Map.Entry <String, Object> pair = it.next (); + for (Entry<String, Object> pair : resourceMap.entrySet()) { @SuppressWarnings("unchecked") - Map <String, String> resourceEntry = (Map <String, String>) pair.getValue (); - typeList.add (resourceEntry.get ("type")); + Map<String, String> resourceEntry = (Map<String, String>) pair.getValue(); + typeList.add(resourceEntry.get("type")); } return typeList; } @@ -100,28 +98,27 @@ public class YamlEditor { Set <HeatTemplateParam> paramSet = new HashSet <HeatTemplateParam> (); @SuppressWarnings("unchecked") Map <String, Object> resourceMap = (Map <String, Object>) yml.get ("parameters"); - Iterator <Entry <String, Object>> it = resourceMap.entrySet ().iterator (); - while (it.hasNext ()) { - HeatTemplateParam param = new HeatTemplateParam (); - Map.Entry <String, Object> pair = it.next (); + for (Entry<String, Object> stringObjectEntry : resourceMap.entrySet()) { + HeatTemplateParam param = new HeatTemplateParam(); + Entry<String, Object> pair = stringObjectEntry; @SuppressWarnings("unchecked") - Map <String, String> resourceEntry = (Map <String, String>) pair.getValue (); - - param.setParamName (pair.getKey ()); + Map<String, String> resourceEntry = (Map<String, String>) pair.getValue(); + + param.setParamName(pair.getKey()); // System.out.println(pair.getKey()+":"+type); if (resourceEntry.containsKey("default")) { - param.setRequired (false); + param.setRequired(false); } else { - param.setRequired (true); + param.setRequired(true); } // Now set the type - String value = resourceEntry.get ("type"); - param.setParamType (value); - + String value = resourceEntry.get("type"); + param.setParamType(value); + param.setHeatTemplateArtifactUuid(artifactUUID); - paramSet.add (param); + paramSet.add(param); } return paramSet; diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/dmaap/DmaapPropertiesLoader.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/dmaap/DmaapPropertiesLoader.java index a21dbe8477..1bdecbf2a7 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/dmaap/DmaapPropertiesLoader.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/dmaap/DmaapPropertiesLoader.java @@ -39,9 +39,8 @@ public class DmaapPropertiesLoader { } public DmaapProperties getImpl() { - Iterator<DmaapProperties> propertyImpls = services.iterator(); - while (propertyImpls.hasNext()) { - return propertyImpls.next(); + for (DmaapProperties service : services) { + return service; } return null; diff --git a/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/domain/ServiceDecomposition.java b/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/domain/ServiceDecomposition.java index 0e985cc8f1..15a1cee5c0 100644 --- a/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/domain/ServiceDecomposition.java +++ b/bpmn/MSOCoreBPMN/src/main/java/org/openecomp/mso/bpmn/core/domain/ServiceDecomposition.java @@ -186,15 +186,13 @@ public class ServiceDecomposition extends JsonWrapper implements Serializable { @JsonIgnore
public String getVnfResource(String resourceObjectId) {
- Iterator<Resource> iter = getServiceResources().iterator();
- while (iter.hasNext()) {
- Resource resource = iter.next();
- //resource.getModelInfo().getModelInvariantId();
+ for (Resource resource : getServiceResources()) {
+ //resource.getModelInfo().getModelInvariantId();
- if ("extracted information".equals(resourceObjectId)){
- return resource.toJsonString();
- }
- }
+ if ("extracted information".equals(resourceObjectId)) {
+ return resource.toJsonString();
+ }
+ }
return "";
}
@@ -290,13 +288,11 @@ public class ServiceDecomposition extends JsonWrapper implements Serializable { public boolean replaceResource(Resource newResource){
boolean result = false;
List serviceResources = getServiceResources();
- Iterator<Resource> iter = serviceResources.iterator();
- while (iter.hasNext()) {
- Resource resource = iter.next();
+ for (Resource resource : (Iterable<Resource>) serviceResources) {
System.out.println("resource found");
- if (resource.resourceType == newResource.resourceType){
+ if (resource.resourceType == newResource.resourceType) {
System.out.println("resource type matches");
- if (resource.getResourceId().equalsIgnoreCase(newResource.getResourceId())){
+ if (resource.getResourceId().equalsIgnoreCase(newResource.getResourceId())) {
System.out.println("resource id matches");
//returns TRUE if replacement is a success
result = Collections.replaceAll(serviceResources, resource, newResource);
@@ -326,12 +322,9 @@ public class ServiceDecomposition extends JsonWrapper implements Serializable { */
public boolean deleteResource(Resource resource){
List serviceResources = getServiceResources();
- Iterator<Resource> iter = serviceResources.iterator();
- while (iter.hasNext()) {
- Resource item = iter.next();
-
- if (item.resourceType == resource.resourceType){
- if (item.getResourceId().equalsIgnoreCase(resource.getResourceId())){
+ for (Resource item : (Iterable<Resource>) serviceResources) {
+ if (item.resourceType == resource.resourceType) {
+ if (item.getResourceId().equalsIgnoreCase(resource.getResourceId())) {
//returns TRUE if replacement is a success
return serviceResources.remove(resource);
}
@@ -377,10 +370,8 @@ public class ServiceDecomposition extends JsonWrapper implements Serializable { @JsonIgnore
public Resource getServiceResource(String resourceId){
List<Resource> resources = getServiceResources();
- Iterator<Resource> iter = resources.iterator();
- while (iter.hasNext()){
- Resource resource = iter.next();
- if (resource.getResourceId().equalsIgnoreCase(resourceId)){
+ for (Resource resource : resources) {
+ if (resource.getResourceId().equalsIgnoreCase(resourceId)) {
//match
return resource;
}
|