diff options
Diffstat (limited to 'adapters/mso-adapter-utils')
5 files changed, 30 insertions, 32 deletions
diff --git a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloud/IdentityAuthenticationTypeJsonSerializer.java b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloud/IdentityAuthenticationTypeJsonSerializer.java index 0777c60278..052f09ab85 100644 --- a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloud/IdentityAuthenticationTypeJsonSerializer.java +++ b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/cloud/IdentityAuthenticationTypeJsonSerializer.java @@ -22,17 +22,15 @@ package org.openecomp.mso.cloud; import java.io.IOException;
import org.codehaus.jackson.JsonGenerator;
-import org.codehaus.jackson.JsonProcessingException;
import org.codehaus.jackson.map.JsonSerializer;
import org.codehaus.jackson.map.SerializerProvider;
-import org.openecomp.mso.cloud.CloudIdentity.IdentityServerType;
public class IdentityAuthenticationTypeJsonSerializer extends JsonSerializer<IdentityAuthenticationTypeAbstract> {
@Override
public void serialize(IdentityAuthenticationTypeAbstract tmpObj, JsonGenerator jsonGenerator, SerializerProvider serializerProvider)
- throws IOException, JsonProcessingException {
+ throws IOException {
jsonGenerator.writeObject(tmpObj.toString());
}
}
diff --git a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/exceptions/MsoException.java b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/exceptions/MsoException.java index ff1cd43b05..b8a7a5571c 100644 --- a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/exceptions/MsoException.java +++ b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/exceptions/MsoException.java @@ -61,6 +61,6 @@ public abstract class MsoException extends Exception if (this.context == null) return getMessage(); else - return ("[" + context + "] " + getMessage()); + return "[" + context + "] " + getMessage(); } } diff --git a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/exceptions/MsoOpenstackException.java b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/exceptions/MsoOpenstackException.java index a62339d0f4..8aa8d3f5e8 100644 --- a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/exceptions/MsoOpenstackException.java +++ b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/exceptions/MsoOpenstackException.java @@ -71,7 +71,13 @@ public class MsoOpenstackException extends MsoException @Override public String toString () { - String error = "" + statusCode + " " + statusMessage + ": " + errorDetail; - return error; + StringBuilder error = new StringBuilder(); + error.append(""); + error.append(statusCode); + error.append(" "); + error.append(statusMessage); + error.append(": "); + error.append(errorDetail); + return error.toString(); } } diff --git a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoCommonUtils.java b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoCommonUtils.java index cd5879c093..e47dea6350 100644 --- a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoCommonUtils.java +++ b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoCommonUtils.java @@ -21,7 +21,6 @@ package org.openecomp.mso.openstack.utils; -import java.lang.StackTraceElement; import org.openecomp.mso.logger.MsoAlarmLogger; import org.openecomp.mso.logger.MsoLogger; import org.openecomp.mso.logger.MessageEnum; @@ -41,7 +40,7 @@ import com.woorea.openstack.quantum.model.NeutronError; public class MsoCommonUtils { - private static MsoLogger LOGGER = MsoLogger.getMsoLogger(MsoLogger.Catalog.RA); + private static MsoLogger logger = MsoLogger.getMsoLogger(MsoLogger.Catalog.RA); protected static MsoAlarmLogger alarmLogger = new MsoAlarmLogger(); protected static String retryDelayProp = "ecomp.mso.adapters.po.retryDelay"; @@ -111,18 +110,18 @@ public class MsoCommonUtils { boolean retry = false; if (retryCodes != null ) { int code = e.getStatus(); - LOGGER.debug ("Config values RetryDelay:" + retryDelay + " RetryCount:" + retryCount + " RetryCodes:" + retryCodes + " ResponseCode:" + code); + logger.debug ("Config values RetryDelay:" + retryDelay + " RetryCount:" + retryCount + " RetryCodes:" + retryCodes + " ResponseCode:" + code); for (String rCode : retryCodes.split (",")) { try { if (retryCount > 0 && code == Integer.parseInt (rCode)) { retryCount--; retry = true; - LOGGER.debug ("OpenStackResponseException ResponseCode:" + code + " at:" + parentServiceMethodName + " request:" + requestType + " Retry indicated. Attempts remaining:" + retryCount); + logger.debug ("OpenStackResponseException ResponseCode:" + code + " at:" + parentServiceMethodName + " request:" + requestType + " Retry indicated. Attempts remaining:" + retryCount); break; } } catch (NumberFormatException e1) { - LOGGER.error (MessageEnum.RA_CONFIG_EXC, "No retries. Exception in parsing retry code in config:" + rCode, "", "", MsoLogger.ErrorCode.SchemaError, "Exception in parsing retry code in config"); + logger.error (MessageEnum.RA_CONFIG_EXC, "No retries. Exception in parsing retry code in config:" + rCode, "", "", MsoLogger.ErrorCode.SchemaError, "Exception in parsing retry code in config"); throw e; } } @@ -132,7 +131,7 @@ public class MsoCommonUtils { try { Thread.sleep (retryDelay * 1000L); } catch (InterruptedException e1) { - LOGGER.debug ("Thread interrupted while sleeping", e1); + logger.debug ("Thread interrupted while sleeping", e1); } } else @@ -143,11 +142,11 @@ public class MsoCommonUtils { if (retryCount > 0) { retryCount--; - LOGGER.debug ("OpenstackConnectException at:" + parentServiceMethodName + " request:" + requestType + " Retry indicated. Attempts remaining:" + retryCount); + logger.debug ("OpenstackConnectException at:" + parentServiceMethodName + " request:" + requestType + " Retry indicated. Attempts remaining:" + retryCount); try { Thread.sleep (retryDelay * 1000L); } catch (InterruptedException e1) { - LOGGER.debug ("Thread interrupted while sleeping", e1); + logger.debug ("Thread interrupted while sleeping", e1); } } else @@ -170,11 +169,11 @@ public class MsoCommonUtils { try { // Failed Keystone calls return an Error entity body. Error error = re.getResponse ().getErrorEntity (Error.class); - LOGGER.error (MessageEnum.RA_CONNECTION_EXCEPTION, "Openstack Keystone Error on " + context + ": " + error, "Openstack", "", MsoLogger.ErrorCode.DataError, "Openstack Keystone Error on " + context); + logger.error (MessageEnum.RA_CONNECTION_EXCEPTION, "Openstack Keystone Error on " + context + ": " + error, "Openstack", "", MsoLogger.ErrorCode.DataError, "Openstack Keystone Error on " + context); me = new MsoOpenstackException (error.getCode (), error.getTitle (), error.getMessage ()); } catch (Exception e2) { // Can't parse the body as an "Error". Report the HTTP error - LOGGER.error (MessageEnum.RA_CONNECTION_EXCEPTION, "HTTP Error on " + context + ": " + re.getStatus() + "," + re.getMessage(), "Openstack", "", MsoLogger.ErrorCode.DataError, "HTTP Error on " + context, e2); + logger.error (MessageEnum.RA_CONNECTION_EXCEPTION, "HTTP Error on " + context + ": " + re.getStatus() + "," + re.getMessage(), "Openstack", "", MsoLogger.ErrorCode.DataError, "HTTP Error on " + context, e2); me = new MsoOpenstackException (re.getStatus (), re.getMessage (), ""); } @@ -192,7 +191,7 @@ public class MsoCommonUtils { me.addContext (context); // Generate an alarm for all connection errors. - LOGGER.error(MessageEnum.RA_GENERAL_EXCEPTION_ARG, "Openstack Keystone connection error on " + context + ": " + e, "Openstack", "", MsoLogger.ErrorCode.DataError, "Openstack Keystone connection error on " + context); + logger.error(MessageEnum.RA_GENERAL_EXCEPTION_ARG, "Openstack Keystone connection error on " + context + ": " + e, "Openstack", "", MsoLogger.ErrorCode.DataError, "Openstack Keystone connection error on " + context); alarmLogger.sendAlarm ("KeystoneIOError", MsoAlarmLogger.CRITICAL, me.getContextMessage ()); } @@ -212,16 +211,16 @@ public class MsoCommonUtils { try { // Failed Heat calls return an Explanation entity body. Explanation explanation = re.getResponse ().getErrorEntity (Explanation.class); - LOGGER.error (MessageEnum.RA_CONNECTION_EXCEPTION, "OpenStack", "Openstack Error on " + context + ": " + explanation.toString(), "Openstack", "", MsoLogger.ErrorCode.DataError, "Exception - Openstack Error on " + context); + logger.error (MessageEnum.RA_CONNECTION_EXCEPTION, "OpenStack", "Openstack Error on " + context + ": " + explanation.toString(), "Openstack", "", MsoLogger.ErrorCode.DataError, "Exception - Openstack Error on " + context); String fullError = explanation.getExplanation() + ", error.type=" + explanation.getError().getType() + ", error.message=" + explanation.getError().getMessage(); - LOGGER.debug(fullError); + logger.debug(fullError); me = new MsoOpenstackException (explanation.getCode (), explanation.getTitle (), //explanation.getExplanation ()); fullError); } catch (Exception e2) { // Couldn't parse the body as an "Explanation". Report the original HTTP error. - LOGGER.error (MessageEnum.RA_CONNECTION_EXCEPTION, "OpenStack", "HTTP Error on " + context + ": " + re.getStatus() + "," + e.getMessage(), "Openstack", "", MsoLogger.ErrorCode.DataError, "Exception - HTTP Error on " + context, e2); + logger.error (MessageEnum.RA_CONNECTION_EXCEPTION, "OpenStack", "HTTP Error on " + context + ": " + re.getStatus() + "," + e.getMessage(), "Openstack", "", MsoLogger.ErrorCode.DataError, "Exception - HTTP Error on " + context, e2); me = new MsoOpenstackException (re.getStatus (), re.getMessage (), ""); } @@ -240,7 +239,7 @@ public class MsoCommonUtils { // Generate an alarm for all connection errors. alarmLogger.sendAlarm ("HeatIOError", MsoAlarmLogger.CRITICAL, me.getContextMessage ()); - LOGGER.error(MessageEnum.RA_CONNECTION_EXCEPTION, "OpenStack", "Openstack Heat connection error on " + context + ": " + e, "Openstack", "", MsoLogger.ErrorCode.DataError, "Openstack Heat connection error on " + context); + logger.error(MessageEnum.RA_CONNECTION_EXCEPTION, "OpenStack", "Openstack Heat connection error on " + context + ": " + e, "Openstack", "", MsoLogger.ErrorCode.DataError, "Openstack Heat connection error on " + context); } return me; @@ -259,11 +258,11 @@ public class MsoCommonUtils { try { // Failed Neutron calls return an NeutronError entity body NeutronError error = re.getResponse ().getErrorEntity (NeutronError.class); - LOGGER.error (MessageEnum.RA_CONNECTION_EXCEPTION, "OpenStack", "Openstack Neutron Error on " + context + ": " + error, "Openstack", "", MsoLogger.ErrorCode.DataError, "Openstack Neutron Error on " + context); + logger.error (MessageEnum.RA_CONNECTION_EXCEPTION, "OpenStack", "Openstack Neutron Error on " + context + ": " + error, "Openstack", "", MsoLogger.ErrorCode.DataError, "Openstack Neutron Error on " + context); me = new MsoOpenstackException (re.getStatus (), error.getType (), error.getMessage ()); } catch (Exception e2) { // Couldn't parse body as a NeutronError. Report the HTTP error. - LOGGER.error (MessageEnum.RA_CONNECTION_EXCEPTION, "OpenStack", "HTTP Error on " + context + ": " + re.getStatus() + "," + e.getMessage(), "Openstack", "", MsoLogger.ErrorCode.DataError, "Openstack HTTP Error on " + context, e2); + logger.error (MessageEnum.RA_CONNECTION_EXCEPTION, "OpenStack", "HTTP Error on " + context + ": " + re.getStatus() + "," + e.getMessage(), "Openstack", "", MsoLogger.ErrorCode.DataError, "Openstack HTTP Error on " + context, e2); me = new MsoOpenstackException (re.getStatus (), re.getMessage (), null); } @@ -282,7 +281,7 @@ public class MsoCommonUtils { // Generate an alarm for all connection errors. alarmLogger.sendAlarm ("NeutronIOError", MsoAlarmLogger.CRITICAL, me.getContextMessage ()); - LOGGER.error(MessageEnum.RA_CONNECTION_EXCEPTION, "OpenStack", "Openstack Neutron Connection error on "+ context + ": " + e, "OpenStack", "", MsoLogger.ErrorCode.DataError, "Openstack Neutron Connection error on "+ context); + logger.error(MessageEnum.RA_CONNECTION_EXCEPTION, "OpenStack", "Openstack Neutron Connection error on "+ context + ": " + e, "OpenStack", "", MsoLogger.ErrorCode.DataError, "Openstack Neutron Connection error on "+ context); } return me; @@ -300,7 +299,7 @@ public class MsoCommonUtils { me.setCategory (MsoExceptionCategory.INTERNAL); // Always generate an alarm for internal exceptions - LOGGER.error(MessageEnum.RA_GENERAL_EXCEPTION_ARG, "An exception occured on "+ context + ": " + e, "OpenStack", "", MsoLogger.ErrorCode.DataError, "An exception occured on "+ context); + logger.error(MessageEnum.RA_GENERAL_EXCEPTION_ARG, "An exception occured on "+ context + ": " + e, "OpenStack", "", MsoLogger.ErrorCode.DataError, "An exception occured on "+ context); alarmLogger.sendAlarm ("AdapterInternalError", MsoAlarmLogger.CRITICAL, me.getContextMessage ()); return me; 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 bd649e867f..c227d72f0c 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 @@ -32,7 +32,6 @@ import java.util.Set; import java.util.Map.Entry; import org.openecomp.mso.db.catalog.beans.HeatTemplateParam; import org.codehaus.jackson.map.ObjectMapper; -import java.util.LinkedHashMap; import org.yaml.snakeyaml.Yaml; @@ -63,7 +62,7 @@ public class MsoYamlEditorWithEnvt { public synchronized Set <MsoHeatEnvironmentParameter> getParameterListFromEnvt() { // In an environment entry, the parameters section can only contain the name:value - // not other attributes. - Set <MsoHeatEnvironmentParameter> paramSet = new HashSet<MsoHeatEnvironmentParameter>(); + Set <MsoHeatEnvironmentParameter> paramSet = new HashSet<>(); Map<String, Object> resourceMap = null; try { resourceMap = (Map<String,Object>) yml.get("parameters"); @@ -79,13 +78,9 @@ public class MsoYamlEditorWithEnvt { while (it.hasNext()) { MsoHeatEnvironmentParameter hep = new MsoHeatEnvironmentParameter(); Map.Entry <String, Object> pair = it.next(); - //Map<String, String> resourceEntry = (Map <String, String>) pair.getValue(); - //String value = null; - String value = null; + String value; Object obj = pair.getValue(); if (obj instanceof java.lang.String) { - //value = (String) pair.getValue(); - // handle block scalar - literals and folded: 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); |