diff options
author | Lukasz Muszkieta <lukasz.muszkieta@nokia.com> | 2017-12-18 15:03:24 +0100 |
---|---|---|
committer | Seshu Kumar M <seshu.kumar.m@huawei.com> | 2018-01-03 05:08:44 +0000 |
commit | 4108c5aca1ee4c556af3937c09c4415d2ebbde70 (patch) | |
tree | 3ce4af7faaa655dac3e96769fa6608327d46d091 /adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack | |
parent | 58ee7ac8ab60a17a508358a4c1353eac00411be5 (diff) |
refactoring - remove unused code
Issue-ID: SO-360
Change-Id: Iac9653fa6d5f10de7986fa3d511535d74f0c24c8
Signed-off-by: Lukasz Muszkieta <lukasz.muszkieta@nokia.com>
Diffstat (limited to 'adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack')
7 files changed, 20 insertions, 148 deletions
diff --git a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/exceptions/MsoCloudIdentityNotFound.java b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/exceptions/MsoCloudIdentityNotFound.java index fe380b27b9..7e21d9d15a 100644 --- a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/exceptions/MsoCloudIdentityNotFound.java +++ b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/exceptions/MsoCloudIdentityNotFound.java @@ -20,29 +20,22 @@ package org.openecomp.mso.openstack.exceptions; - /** - * Cloud site not found exception. + * Signals that an attempt to find a specific mso cloud identity has failed. */ public class MsoCloudIdentityNotFound extends MsoException { - /** - * Serialization id. - */ private static final long serialVersionUID = 2583769056266415665L; + /** * Default constructor (needed for BPEL/JAXB) */ public MsoCloudIdentityNotFound () { super("Cloud Identity not found"); super.category=MsoExceptionCategory.USERDATA; - } - - /** - * Constructor to create a new MsoOpenstackException instance - * @param cloudSite the cloud site - */ + } + public MsoCloudIdentityNotFound (String cloudIdentity) { // Set the detailed error as the Exception 'message' super("Cloud Identity [" + cloudIdentity + "] not found"); diff --git a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/exceptions/MsoCloudSiteNotFound.java b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/exceptions/MsoCloudSiteNotFound.java index 17a5d55698..7c6e98d55f 100644 --- a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/exceptions/MsoCloudSiteNotFound.java +++ b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/exceptions/MsoCloudSiteNotFound.java @@ -20,15 +20,11 @@ package org.openecomp.mso.openstack.exceptions; - /** - * Cloud site not found exception. + * Signals that an attempt to find a specific mso cloud site has failed. */ public class MsoCloudSiteNotFound extends MsoException { - /** - * Serialization id. - */ private static final long serialVersionUID = 2583769056266415664L; /** @@ -38,11 +34,7 @@ public class MsoCloudSiteNotFound extends MsoException { super("Cloud site not found"); super.category=MsoExceptionCategory.USERDATA; } - - /** - * Constructor to create a new MsoOpenstackException instance - * @param cloudSite the cloud site - */ + public MsoCloudSiteNotFound (String cloudSite) { // Set the detailed error as the Exception 'message' super("Cloud Site [" + cloudSite + "] not found"); diff --git a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/exceptions/MsoTenantAlreadyExists.java b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/exceptions/MsoTenantAlreadyExists.java index 49d3a267a0..7a597d6f4d 100644 --- a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/exceptions/MsoTenantAlreadyExists.java +++ b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/exceptions/MsoTenantAlreadyExists.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -20,16 +20,13 @@ package org.openecomp.mso.openstack.exceptions; - - public class MsoTenantAlreadyExists extends MsoOpenstackException { private static final long serialVersionUID = 1L; - // Constructor to create a new MsoOpenstackException instance public MsoTenantAlreadyExists (String tenant, String cloud) { // Set the detailed error as the Exception 'message' super(409, "Conflict", "Tenant " + tenant + " already exists in Cloud " + cloud); } - + } diff --git a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/CloudConfigInitializer.java b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/CloudConfigInitializer.java deleted file mode 100644 index 43a6171699..0000000000 --- a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/CloudConfigInitializer.java +++ /dev/null @@ -1,97 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. 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. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.openstack.utils; - - -import javax.ejb.EJB; -import javax.servlet.ServletContextEvent; -import javax.servlet.ServletContextListener; -import javax.servlet.annotation.WebListener; - -import org.openecomp.mso.cloud.CloudConfigFactory; -import org.openecomp.mso.cloud.CloudConfigIdentityMapper; -import org.openecomp.mso.logger.MessageEnum; -import org.openecomp.mso.logger.MsoLogger; - -/** - * This class will attempt to initialize Cloud Config when part of a web application. - * - * - * - */ -@WebListener -public class CloudConfigInitializer implements ServletContextListener -{ - - private CloudConfigFactory cloudConfigFactory=new CloudConfigFactory(); - - public CloudConfigInitializer () { - } - - @Override - public void contextDestroyed(ServletContextEvent event) { - // Nothing to do... - } - - - @Override - public void contextInitialized(ServletContextEvent event) - { - - // Note - this logger may be before or after MSO Logging configuration applied - MsoLogger initLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.GENERAL); - try { - // Look first in the init-parameters - String msoPropConfigParam = event.getServletContext().getInitParameter("mso.cloud_config.configuration"); - - String[] configFileSplit = msoPropConfigParam.split(","); - for (String msoPropConfig:configFileSplit) { - String[] msoPropDecoded = msoPropConfig.split("="); - - try { - cloudConfigFactory.initializeCloudConfig(msoPropDecoded[0], Integer.valueOf(msoPropDecoded[1])); - initLogger.info(MessageEnum.RA_CONFIG_LOAD, msoPropDecoded[0], "", ""); - initLogger.debug("Mso properties successfully loaded:"+msoPropDecoded[0]+"(Timer(mins):"+Integer.valueOf(msoPropDecoded[1])); - } catch (NumberFormatException ne) { - initLogger.error(MessageEnum.RA_CONFIG_EXC, msoPropDecoded[0] + ". MSO Properties failed due to conversion error (in web.xml file)", "", "", MsoLogger.ErrorCode.DataError, "MSO Properties failed due to conversion error (in web.xml file)", ne); - } - } - - // Second, obtain class name that will register all mappings - String msoMapperClassParam = event.getServletContext().getInitParameter("mso.cloud_config.mapper.class"); - if (msoMapperClassParam != null) { - Class<?> mapperClass = Class.forName(msoMapperClassParam); - if (CloudConfigIdentityMapper.class.isAssignableFrom(mapperClass)) { - ((CloudConfigIdentityMapper)mapperClass.newInstance()).registerAllMappings(); - initLogger.info(MessageEnum.RA_CONFIG_LOAD,msoMapperClassParam+"(Openstack authentication mapper class)","",""); - } else { - initLogger.info(MessageEnum.RA_CONFIG_LOAD,msoMapperClassParam+"(Openstack authentication mapper class not an implementation of CloudConfigIdentityMapper)","",""); - } - } else { - initLogger.info(MessageEnum.RA_CONFIG_LOAD,"Openstack authentication mapper class not specified in web.xml (ONLY core authentication mechanisms will be loaded)","",""); - } - - } - catch (Exception e) { - initLogger.error(MessageEnum.RA_CONFIG_EXC, "Unknown. MSO Properties failed to initialize completely", "", "", MsoLogger.ErrorCode.AvailabilityError, "Exception - MSO Properties failed to initialize completely", e); - } - } -} 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 e47dea6350..269f6b0cdf 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 @@ -40,14 +40,12 @@ import com.woorea.openstack.quantum.model.NeutronError; public class MsoCommonUtils { - private static MsoLogger logger = MsoLogger.getMsoLogger(MsoLogger.Catalog.RA); - protected static MsoAlarmLogger alarmLogger = new MsoAlarmLogger(); - - protected static String retryDelayProp = "ecomp.mso.adapters.po.retryDelay"; + private static MsoLogger logger = MsoLogger.getMsoLogger(MsoLogger.Catalog.RA); + protected static MsoAlarmLogger alarmLogger = new MsoAlarmLogger(); + protected static String retryDelayProp = "ecomp.mso.adapters.po.retryDelay"; protected static String retryCountProp = "ecomp.mso.adapters.po.retryCount"; protected static String retryCodesProp = "ecomp.mso.adapters.po.retryCodes"; - - protected static int retryDelayDefault = 5; + protected static int retryDelayDefault = 5; protected static int retryCountDefault = 3; protected static String retryCodesDefault = "504"; @@ -81,7 +79,6 @@ public class MsoCommonUtils { } } - long start = System.currentTimeMillis (); String requestType; if (request.getClass ().getEnclosingClass () != null) { requestType = request.getClass ().getEnclosingClass ().getSimpleName () + "." @@ -308,7 +305,7 @@ public class MsoCommonUtils { public static boolean isNullOrEmpty (String s) { return s == null || s.isEmpty(); } - - + + } diff --git a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoKeystoneUtils.java b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoKeystoneUtils.java index 8e35e39b22..ee89840c50 100644 --- a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoKeystoneUtils.java +++ b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoKeystoneUtils.java @@ -26,8 +26,6 @@ import java.util.Calendar; import java.util.HashMap; import java.util.Map; -import org.openecomp.mso.cloud.CloudConfig; -import org.openecomp.mso.cloud.CloudConfigFactory; import org.openecomp.mso.cloud.CloudIdentity; import org.openecomp.mso.cloud.CloudSite; import org.openecomp.mso.logger.MsoAlarmLogger; @@ -39,9 +37,6 @@ import org.openecomp.mso.openstack.exceptions.MsoCloudSiteNotFound; import org.openecomp.mso.openstack.exceptions.MsoException; import org.openecomp.mso.openstack.exceptions.MsoOpenstackException; import org.openecomp.mso.openstack.exceptions.MsoTenantAlreadyExists; -import org.openecomp.mso.properties.MsoJavaProperties; -import org.openecomp.mso.properties.MsoPropertiesException; -import org.openecomp.mso.properties.MsoPropertiesFactory; import com.woorea.openstack.base.client.OpenStackBaseException; import com.woorea.openstack.base.client.OpenStackConnectException; import com.woorea.openstack.base.client.OpenStackRequest; @@ -87,7 +82,7 @@ public class MsoKeystoneUtils extends MsoTenantUtils { * <p> * * @param tenantName The tenant name to create - * @param cloudId The cloud identifier (may be a region) in which to create the tenant. + * @param cloudSiteId The cloud identifier (may be a region) in which to create the tenant. * @return the tenant ID of the newly created tenant * @throws MsoTenantAlreadyExists Thrown if the requested tenant already exists * @throws MsoOpenstackException Thrown if the Openstack API call returns an exception @@ -200,7 +195,7 @@ public class MsoKeystoneUtils extends MsoTenantUtils { * @return the tenant properties of the queried tenant, or null if not found * @throws MsoOpenstackException Thrown if the Openstack API call returns an exception */ - public MsoTenant queryTenant (String tenantId, String cloudSiteId) throws MsoException, MsoCloudSiteNotFound { + public MsoTenant queryTenant (String tenantId, String cloudSiteId) throws MsoException { // Obtain the cloud site information where we will query the tenant CloudSite cloudSite = cloudConfig.getCloudSite (cloudSiteId); if (cloudSite == null) { @@ -679,11 +674,11 @@ public class MsoKeystoneUtils extends MsoTenantUtils { * This may be useful if cached credentials get out of sync. */ public static void adminCacheReset () { - adminClientCache = new HashMap <String, KeystoneCacheEntry> (); + adminClientCache = new HashMap<>(); } @Override - public String getKeystoneUrl(String regionId, String msoPropID, CloudIdentity cloudIdentity) throws MsoException { + public String getKeystoneUrl(String regionId, String msoPropID, CloudIdentity cloudIdentity) { return cloudIdentity.getIdentityUrl(); } } diff --git a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoTenantUtilsFactory.java b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoTenantUtilsFactory.java index be49cd947f..a659fb629e 100644 --- a/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoTenantUtilsFactory.java +++ b/adapters/mso-adapter-utils/src/main/java/org/openecomp/mso/openstack/utils/MsoTenantUtilsFactory.java @@ -24,19 +24,14 @@ import org.openecomp.mso.cloud.CloudConfig; import org.openecomp.mso.cloud.CloudConfigFactory; import org.openecomp.mso.cloud.CloudIdentity; import org.openecomp.mso.cloud.CloudSite; -import org.openecomp.mso.logger.MsoLogger; -import org.openecomp.mso.properties.MsoJavaProperties; import java.lang.reflect.InvocationTargetException; public class MsoTenantUtilsFactory { - private static MsoLogger LOGGER = MsoLogger.getMsoLogger (MsoLogger.Catalog.RA); - private CloudConfigFactory cloudConfigFactory= new CloudConfigFactory(); - protected CloudConfig cloudConfig; - protected MsoJavaProperties msoProps = null; + private CloudConfig cloudConfig; private String msoPropID; public MsoTenantUtilsFactory (String msoPropID) { |