diff options
Diffstat (limited to 'adaptors/netbox-client')
5 files changed, 14 insertions, 78 deletions
diff --git a/adaptors/netbox-client/installer/pom.xml b/adaptors/netbox-client/installer/pom.xml index 1d434a05a..b5aef70c6 100755 --- a/adaptors/netbox-client/installer/pom.xml +++ b/adaptors/netbox-client/installer/pom.xml @@ -21,13 +21,13 @@ <parent> <groupId>org.onap.ccsdk.parent</groupId> <artifactId>odlparent-lite</artifactId> - <version>2.1.0</version> + <version>2.0.2</version> <relativePath/> </parent> <groupId>org.onap.ccsdk.sli.adaptors</groupId> <artifactId>netbox-client-installer</artifactId> - <version>1.2.0-SNAPSHOT</version> + <version>1.0.4-SNAPSHOT</version> <packaging>pom</packaging> <name>ccsdk-sli-adaptors :: netbox-client :: ${project.artifactId}</name> diff --git a/adaptors/netbox-client/pom.xml b/adaptors/netbox-client/pom.xml index 0f2019762..f07b738d1 100644 --- a/adaptors/netbox-client/pom.xml +++ b/adaptors/netbox-client/pom.xml @@ -21,13 +21,13 @@ <parent> <groupId>org.onap.ccsdk.parent</groupId> <artifactId>odlparent-lite</artifactId> - <version>2.1.0</version> + <version>2.0.2</version> <relativePath/> </parent> <groupId>org.onap.ccsdk.sli.adaptors</groupId> <artifactId>netbox-client</artifactId> - <version>1.2.0-SNAPSHOT</version> + <version>1.0.4-SNAPSHOT</version> <packaging>pom</packaging> <name>ccsdk-sli-adaptors :: netbox-client</name> diff --git a/adaptors/netbox-client/provider/pom.xml b/adaptors/netbox-client/provider/pom.xml index 23e3213a4..ec078a4c6 100644 --- a/adaptors/netbox-client/provider/pom.xml +++ b/adaptors/netbox-client/provider/pom.xml @@ -21,13 +21,13 @@ <parent> <groupId>org.onap.ccsdk.parent</groupId> <artifactId>binding-parent</artifactId> - <version>2.1.0</version> + <version>2.0.2</version> <relativePath/> </parent> <groupId>org.onap.ccsdk.sli.adaptors</groupId> <artifactId>netbox-client-provider</artifactId> - <version>1.2.0-SNAPSHOT</version> + <version>1.0.4-SNAPSHOT</version> <packaging>bundle</packaging> <name>ccsdk-sli-adaptors :: netbox-client :: ${project.artifactId}</name> diff --git a/adaptors/netbox-client/provider/src/main/java/org/onap/ccsdk/sli/adaptors/netbox/impl/NetboxClientImpl.java b/adaptors/netbox-client/provider/src/main/java/org/onap/ccsdk/sli/adaptors/netbox/impl/NetboxClientImpl.java index bfb5ee530..4e4761d10 100644 --- a/adaptors/netbox-client/provider/src/main/java/org/onap/ccsdk/sli/adaptors/netbox/impl/NetboxClientImpl.java +++ b/adaptors/netbox-client/provider/src/main/java/org/onap/ccsdk/sli/adaptors/netbox/impl/NetboxClientImpl.java @@ -17,23 +17,16 @@ package org.onap.ccsdk.sli.adaptors.netbox.impl; import com.google.common.collect.Lists; import com.google.gson.JsonSyntaxException; - -import java.io.File; -import java.io.FileInputStream; import java.io.IOException; import java.sql.SQLException; import java.util.ArrayList; import java.util.Map; -import java.util.Properties; - import javax.sql.rowset.CachedRowSet; import org.apache.http.HttpResponse; import org.apache.http.util.EntityUtils; import org.onap.ccsdk.sli.adaptors.netbox.api.NetboxClient; import org.onap.ccsdk.sli.adaptors.netbox.model.IPAddress; import org.onap.ccsdk.sli.adaptors.netbox.model.IPStatus; -import org.onap.ccsdk.sli.adaptors.netbox.property.NetboxProperties; -import org.onap.ccsdk.sli.core.dblib.DBResourceManager; import org.onap.ccsdk.sli.core.dblib.DbLibService; import org.onap.ccsdk.sli.core.sli.SvcLogicContext; import org.onap.ccsdk.sli.core.sli.SvcLogicException; @@ -80,56 +73,9 @@ public class NetboxClientImpl implements NetboxClient { private final NetboxHttpClient client; private final DbLibService dbLibService; - public NetboxClientImpl() { - this(null, null); - } - public NetboxClientImpl(final NetboxHttpClient client, final DbLibService dbLibService) { - if (client == null) { - this.client = new NetboxHttpClient(new NetboxProperties()); - } else { - this.client = client; - } - - if (dbLibService == null) { - Properties dblibProps = System.getProperties(); - - String cfgDir = dblibProps.getProperty("sdnc.config.dir", System.getenv("SDNC_CONFIG_DIR")); - - if ((cfgDir == null) || (cfgDir.length() == 0)) { - cfgDir = "/opt/sdnc/data/properties"; - } - - File dblibPropFile = new File(cfgDir + "/dblib.properties"); - if (dblibPropFile.exists()) { - try { - LOG.debug("Loading dblib properties from {}", dblibPropFile.getAbsolutePath()); - dblibProps = new Properties(); - dblibProps.load(new FileInputStream(dblibPropFile)); - } catch (Exception e) { - LOG.warn("Could not load properties file {}", dblibPropFile.getAbsolutePath(), e); - - dblibProps = System.getProperties(); - } - } - - DbLibService dbSvc = null; - try { - dbSvc = new DBResourceManager(dblibProps); - } catch (Exception e) { - LOG.error("Caught exception trying to create dblib service", e); - } - - try { - dbSvc = new DBResourceManager(dblibProps); - } catch (Exception e) { - LOG.error("Caught exception trying to create dblib service", e); - } - this.dbLibService = dbSvc; - - } else { - this.dbLibService = dbLibService; - } + this.client = client; + this.dbLibService = dbLibService; } @Override diff --git a/adaptors/netbox-client/provider/src/main/java/org/onap/ccsdk/sli/adaptors/netbox/property/NetboxProperties.java b/adaptors/netbox-client/provider/src/main/java/org/onap/ccsdk/sli/adaptors/netbox/property/NetboxProperties.java index 9b4751e64..2eecf6e3a 100644 --- a/adaptors/netbox-client/provider/src/main/java/org/onap/ccsdk/sli/adaptors/netbox/property/NetboxProperties.java +++ b/adaptors/netbox-client/provider/src/main/java/org/onap/ccsdk/sli/adaptors/netbox/property/NetboxProperties.java @@ -60,24 +60,14 @@ public class NetboxProperties { properties.load(in); LOG.info("Loaded {} properties from file {}", properties.size(), ccsdkConfigDir); } catch (Exception e) { - try { - // Try to load config from jar via OSGi - final Bundle bundle = FrameworkUtil.getBundle(NetboxProperties.class); - final BundleContext ctx = bundle.getBundleContext(); - final URL url = ctx.getBundle().getResource(NETBOX_PROPERTY_FILE_NAME); - InputStream inputStream = url.openStream(); + // Try to load config from jar + final Bundle bundle = FrameworkUtil.getBundle(NetboxProperties.class); + final BundleContext ctx = bundle.getBundleContext(); + final URL url = ctx.getBundle().getResource(NETBOX_PROPERTY_FILE_NAME); + + try (InputStream inputStream = url.openStream()) { properties.load(inputStream); LOG.info("Loaded {} properties from file {}", properties.size(), NETBOX_PROPERTY_FILE_NAME); - } catch (NoClassDefFoundError e1) { - // Try to load config from jar via class loader - try (InputStream inputStream = NetboxProperties.class.getResourceAsStream("/"+NETBOX_PROPERTY_FILE_NAME)) { - properties.load(inputStream); - } catch (Exception e2) { - LOG.error("Failed to load properties for file: {} " + NETBOX_PROPERTY_FILE_NAME, e1); - } - ; - LOG.info("Loaded {} properties from file {}", properties.size(), NETBOX_PROPERTY_FILE_NAME); - } catch (IOException e1) { LOG.error("Failed to load properties for file: {} " + NETBOX_PROPERTY_FILE_NAME, e1); } |