diff options
Diffstat (limited to 'sdnr/wt/devicemanager/provider/src/main/java')
32 files changed, 282 insertions, 1741 deletions
diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/database/HtDatabaseClientAbstract.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/database/HtDatabaseClientAbstract.java index 9b7d1159e..5a6554398 100644 --- a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/database/HtDatabaseClientAbstract.java +++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/database/HtDatabaseClientAbstract.java @@ -18,38 +18,27 @@ package org.onap.ccsdk.features.sdnr.wt.devicemanager.base.database; import java.io.IOException; -import java.net.InetAddress; -import java.net.UnknownHostException; import java.nio.charset.StandardCharsets; import java.nio.file.Files; import java.nio.file.Paths; import java.util.HashSet; import java.util.Iterator; -import java.util.List; import java.util.Set; import javax.annotation.Nonnull; import javax.annotation.Nullable; import org.elasticsearch.ElasticsearchException; -import org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse; -import org.elasticsearch.action.admin.cluster.node.info.NodesInfoResponse; import org.elasticsearch.action.admin.indices.alias.IndicesAliasesResponse; import org.elasticsearch.action.admin.indices.create.CreateIndexRequestBuilder; import org.elasticsearch.action.admin.indices.create.CreateIndexResponse; -import org.elasticsearch.action.admin.indices.delete.DeleteIndexRequestBuilder; import org.elasticsearch.action.admin.indices.exists.indices.IndicesExistsResponse; -import org.elasticsearch.action.admin.indices.mapping.put.PutMappingResponse; import org.elasticsearch.action.delete.DeleteResponse; import org.elasticsearch.action.get.GetResponse; import org.elasticsearch.action.index.IndexRequestBuilder; import org.elasticsearch.action.index.IndexResponse; import org.elasticsearch.action.search.SearchResponse; import org.elasticsearch.client.Client; -import org.elasticsearch.client.transport.TransportClient; -import org.elasticsearch.cluster.node.DiscoveryNode; import org.elasticsearch.common.bytes.BytesReference; import org.elasticsearch.common.settings.Settings; -import org.elasticsearch.common.transport.InetSocketTransportAddress; -import org.elasticsearch.common.unit.TimeValue; import org.elasticsearch.index.query.QueryBuilder; import org.elasticsearch.index.query.QueryBuilders; import org.elasticsearch.search.SearchHit; @@ -65,66 +54,10 @@ public class HtDatabaseClientAbstract implements HtDataBase, AutoCloseable { private final Logger log = LoggerFactory.getLogger(HtDatabaseClientAbstract.class); - private static int DELAYSECONDS = 10; private final Client client; private String esIndexAlias; /** - * Full database initialization. - * - * @param esIndex Database index - * @param esNodeserverName Servername or Server-IP that hosts the node. - * @param esClusterName Name of the cluster - * @param esNodeName Name of the node within the cluster to connect to. - * @throws UnknownHostException Servername not known. - */ - public HtDatabaseClientAbstract(String esIndex, String esNodeserverName, String esClusterName, String esNodeName) - throws UnknownHostException { - - this.esIndexAlias = esIndex; - - Settings settings = - Settings.settingsBuilder().put("cluster.name", esClusterName).put("node.name", esNodeName).build(); - this.client = getClient(esNodeserverName, settings); - - } - - /** - * Do not use the hostname, but use the IP for getting the client - * - * @param esIndex index to be used by the client - * @param esClusterName name of the ES cluster - * @param esNodeName name of the node - * @throws UnknownHostException if hostname not known - */ - public HtDatabaseClientAbstract(String esIndex, String esClusterName, String esNodeName) - throws UnknownHostException { - - this.esIndexAlias = esIndex; - Settings settings = - Settings.settingsBuilder().put("cluster.name", esClusterName).put("node.name", esNodeName).build(); - this.client = getClient(null, settings); - } - - - /** - * Simple database initialization. Query all ES configuration information from cluster node. - * - * @param esIndex Database index - * @param esNodeserverHostName Servername or Server-IP that hosts the node. - * @throws UnknownHostException Servername not known. - */ - - public HtDatabaseClientAbstract(String esIndex, String esNodeserverHostName) throws UnknownHostException { - - this.esIndexAlias = esIndex; - - Settings settings = Settings.settingsBuilder().put("client.transport.ignore_cluster_name", true) - .put("client.transport.sniff", true).build(); - this.client = getClient(esNodeserverHostName, settings); - } - - /** * Simple database initialization. Query all ES configuration information from cluster node. * * @param esIndex Database index @@ -140,75 +73,6 @@ public class HtDatabaseClientAbstract implements HtDataBase, AutoCloseable { /*---------------------------------- * some constructing functions, used by public constructors */ - /** - * - * @param esNodeserverName - * @param settings - * @return - * @throws UnknownHostException - */ - private final TransportClient getClient(@Nullable String esNodeserverName, Settings settings) - throws UnknownHostException { - - TransportClient newClient = TransportClient.builder().settings(settings).build(); - - if (esNodeserverName != null) { - InetAddress nodeIp = InetAddress.getByName(esNodeserverName); - newClient.addTransportAddress(new InetSocketTransportAddress(nodeIp, 9300)); - } - - setup(newClient); - return newClient; - } - - private void setup(TransportClient newClient) { - NodesInfoResponse nodeInfos = newClient.admin().cluster().prepareNodesInfo().get(); - String clusterName = nodeInfos.getClusterName().value(); - - // ------ Debug/ Info - StringBuffer logInfo = new StringBuffer(); - logInfo.append("Create ES Client an localhost for Cluster '"); - logInfo.append(clusterName); - logInfo.append("' for index '"); - logInfo.append(esIndexAlias); - logInfo.append("' Nodelist: "); - for (DiscoveryNode node : newClient.connectedNodes()) { - logInfo.append("("); - logInfo.append(node.toString()); - logInfo.append(") "); - } - log.info(logInfo.toString()); - // ------ Debug/ Info - - log.info("Starting Database service. Short wait."); - - ClusterHealthResponse nodeStatus = newClient.admin().cluster().prepareHealth().setWaitForGreenStatus() - // .setWaitForYellowStatus() - .setTimeout(TimeValue.timeValueSeconds(DELAYSECONDS)).get(); - log.debug("Elasticsearch client started with status {}", nodeStatus.toString()); - - - List<DiscoveryNode> nodeList = newClient.connectedNodes(); - - if (nodeList.isEmpty()) { - log.info("ES Client created for nodes: <empty node list>"); - } else { - int t = 0; - for (DiscoveryNode dn : nodeList) { - log.info("ES Client created for node#{}: {}", t, dn.getName()); - } - } - - Runtime.getRuntime().addShutdownHook(new Thread() { - @Override - public void run() { - log.info("Shutdown node " + HtDatabaseClientAbstract.class.getSimpleName()); - } - }); - - log.info("Database service started."); - - } /*---------------------------------- @@ -243,33 +107,6 @@ public class HtDatabaseClientAbstract implements HtDataBase, AutoCloseable { } /** - * Create an ES index. Delete an existing index. - */ - public void doDeleteIndex() { - log.info("Remove index {}", esIndexAlias); - - if (esIndexAlias == null) { - throw new IllegalArgumentException("Missing Index"); - } - - try { - - // Delete index - IndicesExistsResponse res = client.admin().indices().prepareExists(esIndexAlias).execute().actionGet(); - - if (res.isExists()) { - log.info("Delete Index start: {}", esIndexAlias); - DeleteIndexRequestBuilder delIdx = client.admin().indices().prepareDelete(esIndexAlias); - delIdx.execute().actionGet(); - log.info("Delete Index done."); - } - - } catch (ElasticsearchException e) { - log.warn(e.getDetailedMessage()); - } - } - - /** * Verify if index already created * * @return boolean accordingly @@ -412,107 +249,6 @@ public class HtDatabaseClientAbstract implements HtDataBase, AutoCloseable { } /** - * Write a JSON mapping definition for a document from a file to ES Hint: A later change of the - * mapping is not possible. - * - * @param jsonString String with mapping definition in JSON Format - */ - - public void doWriteMappingJson(String jsonString) { - - if (esIndexAlias == null) { - throw new IllegalArgumentException("Missing Index"); - } - if (jsonString == null) { - String s = "Mapping string parameter is null"; - log.warn(s); - throw new IllegalArgumentException(s); - } - - try { - // MAPPING GOES HERE - log.debug("Check status of ES index: {}", esIndexAlias); - - final IndicesExistsResponse indexStatus = - client.admin().indices().prepareExists(esIndexAlias).execute().actionGet(); - - if (indexStatus.isExists()) { - log.debug("ES index exists: {}", esIndexAlias); - // A change of mapping is not working. This here works only for new datatypes - - PutMappingResponse res = client.admin().indices().preparePutMapping(esIndexAlias).setSource(jsonString) - .execute().actionGet(); - if (log.isDebugEnabled()) { - log.debug("Result: {}", res); - } - - } else { - log.debug("Create not existing ES index: {}", esIndexAlias); - - CreateIndexRequestBuilder createIndexRequestBuilder = - client.admin().indices().prepareCreate(esIndexAlias); - createIndexRequestBuilder.addMapping(jsonString).execute().actionGet(); - } - - } catch (ElasticsearchException e) { - log.warn(e.getDetailedMessage()); - } - } - - /** - * Write a Json mapping definition for a document from a file to ES - * - * @param fileName Filename with json definition. - */ - public void doWriteMappingFromFile(String fileName) { - - - log.info("Write mapping from File: {}", fileName); - - if (esIndexAlias == null) { - throw new IllegalArgumentException("Missing Index"); - } - - if (fileName == null) { - log.warn("No mapping for {} specified in parameter file.", esIndexAlias); - return; - } - - String content = null; - - try { - content = new String(Files.readAllBytes(Paths.get(fileName)), StandardCharsets.UTF_8); - } catch (IOException e1) { - log.warn("Problem with file {}: {}", fileName, e1.getMessage()); - } - - doWriteMappingJson(content); - - } - - /** - * Write list with json objects from json files - * - * @param docTypeAndFileName List with 2 String Array. String[0] Contains the dataType name - * String[1] Contains the filename - */ - public void doWriteJsonFiles(List<String[]> docTypeAndFileName) { - - if (docTypeAndFileName != null) { - log.debug("Write number of JSONFiles: {}", docTypeAndFileName.size()); - int t = 1; - for (String[] s : docTypeAndFileName) { - if (s.length == 2) { - writeJsonObjectsFromFile(s[0], s[1]); - } else { - log.warn("Wrong parameters number. Entry: {}", t); - } - t++; - } - } - } - - /** * Write one object into Database * * @param esId Database index diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/database/HtDatabaseNode.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/database/HtDatabaseNode.java index 47d7570e8..6a23a3460 100644 --- a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/database/HtDatabaseNode.java +++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/database/HtDatabaseNode.java @@ -27,7 +27,6 @@ import java.nio.charset.StandardCharsets; import java.nio.file.Files; import java.nio.file.Path; import java.util.List; -import javax.annotation.Nullable; import org.apache.lucene.util.Version; import org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse; import org.elasticsearch.client.Client; @@ -233,13 +232,11 @@ public class HtDatabaseNode implements AutoCloseable { /** * Start as singleton - * + * @param config data + * @param akkaConfig data + * @param geoConfig data * @return the node or null if external node used */ - public static @Nullable HtDatabaseNode start(EsConfig config) throws IllegalStateException { - return start(config, null, null); - } - public static HtDatabaseNode start(EsConfig config, AkkaConfig akkaConfig, GeoConfig geoConfig) { if (isPortAvailable(ES_PORT)) { LOGGER.info("ES Port not in use. Start internal ES."); diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/database/HtDatabaseUpdateFile.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/database/HtDatabaseUpdateFile.java index f846000b7..186b89c6c 100644 --- a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/database/HtDatabaseUpdateFile.java +++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/database/HtDatabaseUpdateFile.java @@ -6,9 +6,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. See the License for the specific language governing permissions and limitations under @@ -34,81 +34,76 @@ import org.json.JSONTokener; public class HtDatabaseUpdateFile extends ZipFile { - public static final String FILENAME_DEFAULT = "elasticsearch_update.zip"; + public static final String FILENAME_DEFAULT = "elasticsearch_update.zip"; - public class EsUpdateObject { - public final String Uri; - public final String Method; - public final JSONObject Body; + public class EsUpdateObject { + public final String Uri; + public final String Method; + public final JSONObject Body; - public EsUpdateObject(JSONObject o) { - this.Uri = o.getString("uri"); - this.Method = o.getString("method"); - this.Body = o.getJSONObject("body"); - } - } + public EsUpdateObject(JSONObject o) { + this.Uri = o.getString("uri"); + this.Method = o.getString("method"); + this.Body = o.getJSONObject("body"); + } + } - public interface FileReadCallback { - void read(EsUpdateObject obj,String filename); + public interface FileReadCallback { + void read(EsUpdateObject obj,String filename); - void onerror(String filename,IOException e); - } + void onerror(String filename,IOException e); + } - private static final Comparator<ZipEntry> byfilenameComparator = new Comparator<ZipEntry>() { + private static final Comparator<ZipEntry> byfilenameComparator = (o1, o2) -> o1.getName().compareTo(o2.getName()); - @Override - public int compare(ZipEntry o1, ZipEntry o2) { - return o1.getName().compareTo(o2.getName()); - } - }; + public HtDatabaseUpdateFile(String filename) throws IOException { + super(filename); + } - public HtDatabaseUpdateFile(String filename) throws IOException { - super(filename); - } + private static String readFile(final InputStream s) throws IOException { + // read file + BufferedReader in = new BufferedReader(new InputStreamReader(s)); + StringBuilder sb = new StringBuilder(); + String inputLine; + while ((inputLine = in.readLine()) != null) { + sb.append(inputLine); + } + in.close(); + s.close(); + return sb.toString(); + } - private static String readFile(final InputStream s) throws IOException { - // read file - BufferedReader in = new BufferedReader(new InputStreamReader(s)); - StringBuilder sb = new StringBuilder(); - String inputLine; - while ((inputLine = in.readLine()) != null) { - sb.append(inputLine); - } - in.close(); - s.close(); - return sb.toString(); - } - - public boolean readFiles(FileReadCallback cb) { - boolean r=true; - Enumeration<? extends ZipEntry> entries = this.entries(); - ArrayList<? extends ZipEntry> list = Collections.list(entries); - Collections.sort(list, byfilenameComparator); - for (ZipEntry entry : list) { - if (entry.isDirectory()) - continue; - try { - InputStream stream = this.getInputStream(entry); - Object data = new JSONTokener(readFile(stream)).nextValue(); - stream.close(); - if(data instanceof JSONArray) - { - JSONArray a=(JSONArray)data; - for(int i=0;i<a.length();i++) - { - cb.read(new EsUpdateObject(a.getJSONObject(i)),entry.getName()); - } - } - else if(data instanceof JSONObject) - { - cb.read(new EsUpdateObject( (JSONObject)data),entry.getName()); - } - } catch (IOException e) { - r=false; - cb.onerror(entry.getName(),e); - } - } - return r; - } + public boolean readFiles(FileReadCallback cb) { + boolean r=true; + Enumeration<? extends ZipEntry> entries = this.entries(); + ArrayList<? extends ZipEntry> list = Collections.list(entries); + Collections.sort(list, byfilenameComparator); + for (ZipEntry entry : list) { + if (entry.isDirectory()) { + continue; + } + try { + InputStream stream = this.getInputStream(entry); + Object data = new JSONTokener(readFile(stream)).nextValue(); + stream.close(); + if(data instanceof JSONArray) + { + JSONArray a=(JSONArray)data; + for(int i=0;i<a.length();i++) + { + cb.read(new EsUpdateObject(a.getJSONObject(i)),entry.getName()); + } + } + else if(data instanceof JSONObject) + { + cb.read(new EsUpdateObject( (JSONObject)data),entry.getName()); + } + } catch (IOException e) { + r=false; + cb.onerror(entry.getName(),e); + } + } + return r; + } } diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/database/HtMapper.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/database/HtMapper.java index 64d3fa02a..9d8ddc3ae 100644 --- a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/database/HtMapper.java +++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/database/HtMapper.java @@ -6,9 +6,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. See the License for the specific language governing permissions and limitations under @@ -18,10 +18,6 @@ package org.onap.ccsdk.features.sdnr.wt.devicemanager.base.database; import java.io.IOException; -import java.nio.file.Files; -import java.nio.file.Paths; -import java.util.List; - import javax.annotation.Nullable; import org.elasticsearch.common.bytes.BytesReference; @@ -30,7 +26,6 @@ import org.slf4j.LoggerFactory; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.databind.JsonMappingException; -import com.fasterxml.jackson.databind.JsonNode; /** * @author Herbert @@ -69,33 +64,6 @@ public class HtMapper<T> { return objectMapperWrite.objectToJson(object); } - public String objectListToJson( List<T> objectList ) { - return objectMapperWrite.objectListToJson( objectList ); - } - - public T readValue( JsonNode node ) { - - try { - T object = objectMapperRead.readValue(node.traverse(), clazz); - return object; - } catch (JsonParseException e) { - mappingFailures++; - log.warn(e.toString()); - } catch (JsonMappingException e) { - mappingFailures++; - log.warn(e.toString()); - } catch (IOException e) { - mappingFailures++; - log.warn(e.toString()); - } catch (Exception e) { - mappingFailures++; - log.warn(e.toString()); - } - log.warn("Can not parse: {} {} ", clazz, node); - return null; - - } - /** * Do the mapping from Json to class * Block further mapping if there is are to many failures @@ -104,9 +72,9 @@ public class HtMapper<T> { */ public @Nullable T getObjectFromJson(byte[] json) { - if (json == null) - return null; - else if (mappingFailures < 10) { + if (json == null) { + return null; + } else if (mappingFailures < 10) { try { T object = objectMapperRead.readValue(json, clazz); return object; @@ -140,27 +108,4 @@ public class HtMapper<T> { } - /** - * Read json from File. - * @param fileName File with JSON text - * @return Object Object - */ - public T readJsonObjectFromFile( String fileName ) { - byte[] content = null; - log.debug("Filename readJsonObjectFromFile: {}",fileName); - - try { - content = Files.readAllBytes(Paths.get(fileName)); - } catch (IOException e1) { - log.warn("IO Problem: {}", e1.getMessage()); - } - - if (content != null) { - return getObjectFromJson(content); - } else { - return null; - } - } - - } diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/internalTypes/IniConfigurationFile.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/internalTypes/IniConfigurationFile.java index 8fe64b5ca..ebb46547e 100644 --- a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/internalTypes/IniConfigurationFile.java +++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/internalTypes/IniConfigurationFile.java @@ -108,21 +108,6 @@ public class IniConfigurationFile { this.load(); } - public String getProperty(String key, String defValue) { - Section s; - if (key.contains(".")) { - s = this.getSection(key.substring(0, key.indexOf("."))); - key = key.substring(key.indexOf(".") + 1); - } else { - s = this.getSection(SECTIONNAME_ROOT); - } - - String v = s.getProperty(key); - if (v == null || v.isEmpty()) { - return defValue; - } - return v; - } public void setProperty(String key, String value) { Section s; @@ -135,17 +120,6 @@ public class IniConfigurationFile { s.setProperty(key, value); } - public int getProperty(String key, int defValue) throws ConversionException { - Section s; - if (key.contains(".")) { - s = this.getSection(key.substring(0, key.indexOf("."))); - key = key.substring(key.indexOf(".") + 1); - } else { - s = this.getSection(SECTIONNAME_ROOT); - } - - return s.getInt(key, defValue); - } public void setProperty(String key, int value) { Section s; @@ -158,17 +132,6 @@ public class IniConfigurationFile { s.setProperty(key, String.format("%d", value)); } - public boolean getProperty(String key, boolean defValue) throws ConversionException { - Section s; - if (key.contains(".")) { - s = this.getSection(key.substring(0, key.indexOf("."))); - key = key.substring(key.indexOf(".") + 1); - } else { - s = this.getSection(SECTIONNAME_ROOT); - } - - return s.getBoolean(key, defValue); - } public void setProperty(String key, boolean value) { Section s; diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/internalTypes/InternalDateAndTime.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/internalTypes/InternalDateAndTime.java index cc5b8316d..cc47362c0 100644 --- a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/internalTypes/InternalDateAndTime.java +++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/internalTypes/InternalDateAndTime.java @@ -33,8 +33,9 @@ public class InternalDateAndTime { private static final NetconfTimeStamp NETCONFTIME_CONVERTER = NetconfTimeStamp.getConverter(); private static final InternalDateAndTime TESTPATTERN = new InternalDateAndTime("2017-01-01T00:00:00.0Z"); + private static final String INITIALPATTERN = "0000-00-00T00:00:00.0Z"; - String internalDateAndTime; + String internalDateAndTime = INITIALPATTERN; /** * Static builder ONF1.2 @@ -79,7 +80,11 @@ public class InternalDateAndTime { * @param time as input */ private InternalDateAndTime(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.DateAndTime time) { - internalDateAndTime = NETCONFTIME_CONVERTER.getTimeStampFromNetconf(time.getValue()); + if (time != null) { + internalDateAndTime = NETCONFTIME_CONVERTER.getTimeStampFromNetconf(time.getValue()); + } else { + internalDateAndTime = INITIALPATTERN; + } } /** diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/internalTypes/Resources.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/internalTypes/Resources.java index b4fec083a..edd9d4968 100644 --- a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/internalTypes/Resources.java +++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/internalTypes/Resources.java @@ -69,10 +69,9 @@ public class Resources { f = new File(RESSOURCEROOT + resFile); } else { try { - f = new File(b.getEntry(resFile).toURI()); } catch (URISyntaxException e) { - + LOG.warn("Con not load file: {}",e.getMessage()); } } return f; @@ -203,10 +202,9 @@ public class Resources { } /** - * Used for reading plugins from resource files - * /elasticsearch/plugins/head - * /etc/elasticsearch-plugins - * /elasticsearch/plugins + * Used for reading plugins from resource files /elasticsearch/plugins/head + * /etc/elasticsearch-plugins /elasticsearch/plugins + * * @param resFolder resource folder pointing to the related files * @param dstFolder destination * @param rootDirToRemove part from full path to remove @@ -232,14 +230,14 @@ public class Resources { srcFilename = srcUrl.getFile(); if (srcFilename.endsWith("/")) { - LOG.warn("Skip directory: {}", srcFilename); - continue; + LOG.warn("Skip directory: {}", srcFilename); + continue; } LOG.debug("try to copy res {} to {}", srcFilename, dstFolder); if (rootDirToRemove != null) { - srcFilename = srcFilename - .substring(srcFilename.indexOf(rootDirToRemove) + rootDirToRemove.length() + 1); + srcFilename = + srcFilename.substring(srcFilename.indexOf(rootDirToRemove) + rootDirToRemove.length() + 1); LOG.debug("dstfilename trimmed to {}", srcFilename); } dstFilename = dstFolder + "/" + srcFilename; @@ -255,7 +253,8 @@ public class Resources { return success; } - private static Enumeration<URL> getResourceFolderFiles (String folder) { + + private static Enumeration<URL> getResourceFolderFiles(String folder) { LOG.info("Get ressource: {}", folder); URL url = getUrlForRessource(folder); String path = url.getPath(); @@ -266,7 +265,7 @@ public class Resources { for (File f : files) { try { if (f.isDirectory()) { - urlCollection.addAll(Collections.list(getResourceFolderFiles(folder+"/"+f.getName()))); + urlCollection.addAll(Collections.list(getResourceFolderFiles(folder + "/" + f.getName()))); } else { urlCollection.add(f.toURI().toURL()); } @@ -279,13 +278,14 @@ public class Resources { Enumeration<URL> urls = Collections.enumeration(urlCollection); return urls; - } + } - private static URL getUrlForRessource (String fileOrDirectory) { - ClassLoader loader = Thread.currentThread().getContextClassLoader(); + private static URL getUrlForRessource(String fileOrDirectory) { + //ClassLoader loader = Thread.currentThread().getContextClassLoader(); + ClassLoader loader = Resources.class.getClassLoader(); URL url = loader.getResource(fileOrDirectory); return url; - } + } public static boolean extractFileTo(String resFile, File oFile) { if (oFile == null) { diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/internalTypes/TemplateFile.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/internalTypes/TemplateFile.java deleted file mode 100644 index 3703e18a6..000000000 --- a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/internalTypes/TemplateFile.java +++ /dev/null @@ -1,84 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START======================================================================== - * ONAP : ccsdk feature sdnr wt - * ================================================================================================= - * Copyright (C) 2019 highstreet technologies GmbH 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.onap.ccsdk.features.sdnr.wt.devicemanager.base.internalTypes; - -import java.io.BufferedReader; -import java.io.File; -import java.io.FileNotFoundException; -import java.io.FileReader; -import java.io.IOException; -import java.util.HashMap; -import java.util.Map; - -public class TemplateFile { - - protected final HashMap<String, Object> mKeyValuePairs; - private final String mContent; - - public TemplateFile(String content) { - this.mKeyValuePairs = new HashMap<>(); - this.mContent = content; - - } - - public TemplateFile(File f) throws IOException { - this(initialize(f)); - } - - public void addValue(String key, Object value) { - this.mKeyValuePairs.put(key, value); - } - - public void removeValue(String key) { - this.mKeyValuePairs.remove(key); - } - - private String replace() { - String s = this.mContent; - String key; - Object value; - for (Map.Entry<String, Object> entry : this.mKeyValuePairs.entrySet()) { - key = entry.getKey(); - value = entry.getValue(); - if (value != null) { - s = s.replace(key, value.toString()); - } - } - return s; - } - - @Override - public String toString() { - return this.replace(); - } - - private static String initialize(File f) throws FileNotFoundException, IOException { - StringBuilder sb = new StringBuilder(); - try (BufferedReader br = new BufferedReader(new FileReader(f));) { - String line = br.readLine(); - - while (line != null) { - sb.append(line); - line = br.readLine(); - } - br.close(); - } - return sb.toString(); - } - -} diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/internalTypes/TimeSpan.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/internalTypes/TimeSpan.java deleted file mode 100644 index 551955d45..000000000 --- a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/internalTypes/TimeSpan.java +++ /dev/null @@ -1,650 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START======================================================================== - * ONAP : ccsdk feature sdnr wt - * ================================================================================================= - * Copyright (C) 2019 highstreet technologies GmbH 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========================================================================== - ******************************************************************************/ -/* - * SoSy-Lab Common is a library of useful utilities. - * This file is part of SoSy-Lab Common. - * - * Copyright (C) 2007-2015 Dirk Beyer - * 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. - */ -package org.onap.ccsdk.features.sdnr.wt.devicemanager.base.internalTypes; - -import static com.google.common.base.Preconditions.checkArgument; -import static com.google.common.base.Preconditions.checkNotNull; -import static java.util.concurrent.TimeUnit.DAYS; -import static java.util.concurrent.TimeUnit.HOURS; -import static java.util.concurrent.TimeUnit.MICROSECONDS; -import static java.util.concurrent.TimeUnit.MILLISECONDS; -import static java.util.concurrent.TimeUnit.MINUTES; -import static java.util.concurrent.TimeUnit.NANOSECONDS; -import static java.util.concurrent.TimeUnit.SECONDS; - -import com.google.common.annotations.VisibleForTesting; -import com.google.common.base.Ascii; -import com.google.common.collect.EnumHashBiMap; -import com.google.common.collect.ImmutableSortedSet; -import com.google.common.collect.Lists; -import com.google.common.collect.Ordering; -import com.google.common.math.LongMath; -import com.google.common.primitives.Longs; - -import java.io.Serializable; -import java.util.Arrays; -import java.util.EnumSet; -import java.util.Iterator; -import java.util.List; -import java.util.Locale; -import java.util.concurrent.TimeUnit; -import java.util.function.Function; -import java.util.regex.Matcher; -import java.util.regex.Pattern; -import javax.annotation.CheckReturnValue; -import javax.annotation.Nullable; - -/** - * This is an immutable representation of some time span, using a {@link TimeUnit} and a value. - * - * <p>The value may be positive or negative. All operations check for overflows and underflows, the - * behavior on overflow and underflow differs and is documented for each method. - * - * <p>Two instances are considered equal if they represent the exact same time span regardless of - * their unit, for example, 60s and 1min are considered equal. - */ - -public final class TimeSpan implements Comparable<TimeSpan>, Serializable { - - private static final long serialVersionUID = -4013592312989551009L; - - private static final ImmutableSortedSet<TimeUnit> ALL_UNITS = - ImmutableSortedSet.copyOf(EnumSet.allOf(TimeUnit.class)); - - static { - assert ALL_UNITS.higher(SECONDS).equals(MINUTES); // assert expected order of set - } - - private static final EnumHashBiMap<TimeUnit, String> TIME_UNITS = - EnumHashBiMap.create(TimeUnit.class); - - static { - TIME_UNITS.put(NANOSECONDS, "ns"); - TIME_UNITS.put(MICROSECONDS, "µs"); - TIME_UNITS.put(MILLISECONDS, "ms"); - TIME_UNITS.put(SECONDS, "s"); - TIME_UNITS.put(MINUTES, "min"); - TIME_UNITS.put(HOURS, "h"); - TIME_UNITS.put(DAYS, "d"); - } - - private static final Pattern ONLY_DIGITS = Pattern.compile(" *([0-9]+) *"); - - private enum CharType { - BEGIN, - END, - LETTER, - DIGIT, - WHITESPACE - } - - private final long span; - private final TimeUnit unit; - - private TimeSpan(long pSpan, TimeUnit pUnit) { - span = pSpan; - unit = checkNotNull(pUnit); - } - - public static TimeSpan of(long pSpan, TimeUnit pUnit) { - return new TimeSpan(pSpan, pUnit); - } - - public static TimeSpan ofSeconds(long pSeconds) { - return new TimeSpan(pSeconds, SECONDS); - } - - public static TimeSpan ofMillis(long pMillis) { - return new TimeSpan(pMillis, MILLISECONDS); - } - - public static TimeSpan ofNanos(long pNanos) { - return new TimeSpan(pNanos, NANOSECONDS); - } - - public static TimeSpan empty() { - return new TimeSpan(0, DAYS); - } - - /** - * Converts the given {@link String} into a {@link TimeSpan} object. Supported units are day, - * hour, minute and second. - * - * @param input the {@link String} to convert - * @return a {@link TimeSpan} represented by the given {@link String} - * @throws IllegalArgumentException if the input is not a valid string representation of a {@link - * TimeSpan}. - */ - public static TimeSpan valueOf(String input) { - - // only seconds: use simple regex - Matcher secondMatcher = ONLY_DIGITS.matcher(input); - if (secondMatcher.matches()) { - return ofSeconds(Long.parseLong(secondMatcher.group(1))); - } - - // values with units: more elaborate parsing necessary - List<String> tokens = splitIntoTokens(input); - - long days = 0; - long hours = 0; - long minutes = 0; - long seconds = 0; - - Iterator<String> it = tokens.iterator(); - - while (it.hasNext()) { - // first: value - String nextString = it.next(); - long value = Long.parseLong(nextString); - - // second: unit - if (!it.hasNext()) { - throw new IllegalArgumentException("Value " + nextString + " has no unit."); - } - - String unit = it.next(); - switch (unit) { - case "day": - case "days": - case "d": - if (days != 0) { - throw new IllegalArgumentException("Days set twice: " + unit); - } - days = value; - break; - - case "h": - case "hour": - case "hours": - if (hours != 0) { - throw new IllegalArgumentException("Hours set twice: " + unit); - } - hours = value; - break; - - case "min": - case "m": - if (minutes != 0) { - throw new IllegalArgumentException("Minutes set twice: " + unit); - } - minutes = value; - break; - - case "s": - if (seconds != 0) { - throw new IllegalArgumentException("Seconds set twice: " + unit); - } - seconds = value; - break; - - default: - throw new IllegalArgumentException("Unknown unit: " + unit); - } - } - - return sum(of(seconds, SECONDS), of(minutes, MINUTES), of(hours, HOURS), of(days, DAYS)); - } - - private static List<String> splitIntoTokens(String input) { - List<String> tokens = Lists.newArrayList(); - CharType previous = CharType.BEGIN; - int pos = 0; - - for (int i = 0; i <= input.length(); ++i) { - - CharType current; - if (i == input.length()) { - current = CharType.END; - } else { - char currentChar = input.charAt(i); - if (Character.isLetter(currentChar)) { - current = CharType.LETTER; - } else if (Character.isDigit(currentChar)) { - current = CharType.DIGIT; - } else if (Character.isWhitespace(currentChar)) { - current = CharType.WHITESPACE; - } else { - throw new IllegalArgumentException( - "Unreconized character '" + currentChar + "' when parsing " + input); - } - } - - if (current != previous) { - // we want to use the previous token - if (previous == CharType.LETTER || previous == CharType.DIGIT) { - tokens.add(input.substring(pos, i)); - } - - if (current == CharType.LETTER || current == CharType.DIGIT) { - pos = i; - } - - previous = current; - } - } - - return tokens; - } - - /** - * Get the value of this TimeSpan represented in the given unit. If the given unit is larger than - * the current unit, precision may be lost. - * - * @throws ArithmeticException If the value cannot be represented in the given unit due to - * overflow. - */ - public long getChecked(TimeUnit dest) { - if (dest.compareTo(unit) < 0) { - // Example case: we have seconds, but we want milliseconds (can overflow) - long factor = dest.convert(1, unit); - assert factor > 1; - return LongMath.checkedMultiply(span, factor); - } - - // Example case: we have nanoseconds, but we want seconds (cannot overflow) - return dest.convert(span, unit); - } - - /** - * Get the value of this TimeSpan represented in the given unit. If the given unit is larger than - * the current unit, precision may be lost. If the value cannot be represented in the given unit - * due to overflow, Long.MAX_VALUE/Long.MIN_VALUE is returned. - */ - public long getSaturated(TimeUnit dest) { - return dest.convert(span, unit); - } - - /** - * Return a TimeSpan that represents (approximately) the same time span, but whose unit is the - * given unit. If the given unit is larger than the current unit, precision may be lost. - * - * @throws ArithmeticException If the value cannot be represented in the given unit - */ - public TimeSpan toChecked(TimeUnit dest) { - if (dest.equals(unit)) { - return this; - } - return new TimeSpan(getChecked(dest), dest); - } - - /** - * Return a TimeSpan that represents (approximately) the same time span, but whose unit is the - * given unit. If the given unit is larger than the current unit, precision may be lost. If the - * value cannot be represented in the given unit due to overflow, Long.MAX_VALUE/Long.MIN_VALUE is - * returned. - */ - public TimeSpan toSaturated(TimeUnit dest) { - if (dest.equals(unit)) { - return this; - } - return new TimeSpan(getSaturated(dest), dest); - } - - /** - * Return a TimeSpan that represents (approximately) the same time span, but whose unit is the - * given unit, if possible. If the given unit is larger than the current unit, precision may be - * lost. If the value cannot be represented in the given unit due to overflow, the resulting - * TimeSpan does not use the given unit, but the closest unit one that still allows to hold the - * exact value. - */ - @VisibleForTesting - TimeSpan toIfPossible(TimeUnit dest) { - if (dest.equals(unit)) { - return this; - } - if (dest.compareTo(unit) < 0) { - // Example case: we have seconds, but we want milliseconds (can overflow). - // Overflow is expected to be very rare. - // Loop will terminate because at one time "dest" becomes equal to "this.unit" - // and then toChecked succeeds for sure. - while (true) { - try { - return toChecked(dest); - } catch (ArithmeticException e) { - dest = checkNotNull(ALL_UNITS.higher(dest)); - } - } - - } else { - // Example case: we have nanoseconds, but we want seconds (cannot overflow). - return new TimeSpan(getSaturated(dest), dest); - } - } - - /** - * Get the value of this TimeSpan as seconds. If the current unit is smaller than seconds, - * precision may be lost. - * - * @throws ArithmeticException If the value cannot be represented as seconds due to overflow. - */ - public long asSeconds() { - return getChecked(SECONDS); - } - - /** - * Get the value of this TimeSpan as milliseconds. If the current unit is smaller than - * milliseconds, precision may be lost. - * - * @throws ArithmeticException If the value cannot be represented as milliseconds due to overflow. - */ - public long asMillis() { - return getChecked(MILLISECONDS); - } - - /** - * Get the value of this TimeSpan as nanoseconds. - * - * @throws ArithmeticException If the value cannot be represented as milliseconds due to overflow. - */ - public long asNanos() { - return getChecked(NANOSECONDS); - } - - public TimeUnit getUnit() { - return unit; - } - - /** - * Return a strings that represents (approximately) this time span, in the given unit if possible. - * If the given unit is larger than the current unit, precision may be lost. If the value cannot - * be represented in the given unit due to overflow, the result does not use the given unit, but - * the closest unit one that still allows to hold the exact value. - */ - public String formatAs(TimeUnit dest) { - if (dest.compareTo(unit) <= 0) { - // Example case: we have seconds, but we want milliseconds - return toIfPossible(dest).toString(); - } - - // Example case: we have nanoseconds, but we want seconds - long scaleFactor = unit.convert(1L, dest); - assert scaleFactor > 0; - return String.format(Locale.US, "%9.3f%s", (double) span / scaleFactor, TIME_UNITS.get(dest)); - } - - /** Check whether this time span is empty, i.e., represents 0ns (or 0ms or 0s or ...). */ - public boolean isEmpty() { - return span == 0; - } - - @Override - public boolean equals(@Nullable Object obj) { - if (obj == this) { - return true; - } - if (!(obj instanceof TimeSpan)) { - return false; - } - TimeSpan other = (TimeSpan) obj; - if (this.unit == other.unit) { - return this.span == other.span; - } - TimeUnit leastCommonUnit = leastCommonUnit(this, other); - try { - return this.getChecked(leastCommonUnit) == other.getChecked(leastCommonUnit); - } catch (ArithmeticException e) { - // In case of overflow, both values cannot be the same. - return false; - } - } - - @Override - public int hashCode() { - // Need to use a fixed unit here to be consistent with equals: - // 60s and 1min need to have the same hashCode. - // Saturation is ok, all really large values just have the same hash code. - return Longs.hashCode(getSaturated(NANOSECONDS)); - } - - @Override - public int compareTo(TimeSpan other) { - if (this.unit == other.unit) { - return Long.compare(this.span, other.span); - } - TimeUnit leastCommonUnit = leastCommonUnit(this, other); - try { - return Long.compare(this.getChecked(leastCommonUnit), other.getChecked(leastCommonUnit)); - } catch (ArithmeticException e) { - // Only one of the two calls can overflow, - // and it has to be the one with the larger unit. - // Thus in case of overflow the TimeSpan with the larger unit also has the larger value. - return this.unit.compareTo(other.unit); - } - } - - private static TimeUnit leastCommonUnit(TimeSpan a, TimeSpan b) { - return Ordering.natural().min(a.unit, b.unit); - } - - @Override - public String toString() { - return DEFAULT_FORMAT.apply(this); - } - - /** - * Create a new time span that is the sum of two time spans. The unit of the returned time span is - * the more precise one if possible, otherwise the closest unit that still allows to hold both - * input values and the result. Note that this can loose precision when adding a very large and a - * very small value. - * - * @throws ArithmeticException If no unit is large enough to represent the result value. - */ - public static TimeSpan sum(TimeSpan a, TimeSpan b) { - TimeUnit leastCommonUnit = leastCommonUnit(a, b); - while (true) { - try { - return new TimeSpan( - LongMath.checkedAdd(a.getChecked(leastCommonUnit), b.getChecked(leastCommonUnit)), - leastCommonUnit); - } catch (ArithmeticException e) { - // Overflow is expected to be very rare, thus handle exception case instead of checking. - // Try again with next unit. - leastCommonUnit = ALL_UNITS.higher(leastCommonUnit); - if (leastCommonUnit == null) { - // overflow from addition - throw e; - } - } - } - } - - /** - * Create a new time span that is the sum of several time spans. The unit of the returned time - * span is the most precise one if possible, otherwise the closest unit that still allows to hold - * input values and the result. Note that this can loose precision when adding very large and very - * small values. - * - * @throws ArithmeticException If no unit is large enough to represent the result value. - */ - public static TimeSpan sum(Iterable<TimeSpan> timeSpans) { - Iterator<TimeSpan> it = timeSpans.iterator(); - checkArgument(it.hasNext()); - - TimeSpan result = it.next(); - // TODO Summing in loop looses more precision than necessary. - while (it.hasNext()) { - result = sum(result, it.next()); - } - return result; - } - - /** - * Create a new time span that is the sum of several time spans. The unit of the returned time - * span is the most precise one. - */ - public static TimeSpan sum(TimeSpan... t) { - return sum(Arrays.asList(t)); - } - - /** - * Create a new time span that is the difference of two time spans. The unit of the returned time - * span is the more precise one if possible, otherwise the closest unit that still allows to hold - * both input values and the result. Note that this can loose precision when subtracting a very - * large and a very small value. - */ - public static TimeSpan difference(TimeSpan a, TimeSpan b) { - TimeUnit leastCommonUnit = leastCommonUnit(a, b); - while (true) { - try { - return new TimeSpan( - LongMath.checkedSubtract(a.getChecked(leastCommonUnit), b.getChecked(leastCommonUnit)), - leastCommonUnit); - } catch (ArithmeticException e) { - // Overflow is expected to be very rare, thus handle exception case instead of checking. - // Try again with next unit. - leastCommonUnit = ALL_UNITS.higher(leastCommonUnit); - if (leastCommonUnit == null) { - // overflow from subtraction - throw e; - } - } - } - } - - /** - * Create a new time span that is the current one multiplied by a non-negative integral factor. - * The unit of the returned time span is the same as the current one if possible, otherwise the - * closest unit that still allows to the result. Note that this can loose precision. - */ - @CheckReturnValue - public TimeSpan multiply(int factor) { - checkArgument(factor >= 0, "Cannot multiply TimeSpan with negative value %s", factor); - TimeUnit dest = unit; - while (true) { - try { - return new TimeSpan(LongMath.checkedMultiply(getChecked(dest), factor), dest); - } catch (ArithmeticException e) { - // Overflow is expected to be very rare, thus handle exception case instead of checking. - // Try again with next unit. - dest = ALL_UNITS.higher(dest); - if (dest == null) { - // overflow from multiplication - throw e; - } - } - } - } - - /** - * Create a new time span that is the current one divided by a non-negative integral value. The - * result of the division is rounded down (integer division). The unit of the returned time span - * is the same as the current one. - */ - @CheckReturnValue - public TimeSpan divide(int divisor) { - checkArgument(divisor >= 0, "Cannot divide TimeSpan by negative value %s", divisor); - return new TimeSpan(span / divisor, unit); - } - - // Code for formatting as string - - private static final Function<TimeSpan, String> FORMAT_SIMPLE = - pInput -> pInput.span + TIME_UNITS.get(pInput.unit); - - @VisibleForTesting - static final Function<TimeSpan, String> FORMAT_HUMAN_READABLE_LARGE = - pInput -> { - TimeUnit unit = pInput.getUnit(); - StringBuilder result = new StringBuilder(); - boolean started = false; - - long years = pInput.getChecked(DAYS) / 365; - if (years > 0) { - started = true; - result.append(years).append("a "); - } - - long days = pInput.getChecked(DAYS) - years * 365; - if (started || days > 0) { - started = true; - result.append(days).append("d "); - } - if (unit.equals(DAYS)) { - return result.toString().trim(); - } - - long hours = pInput.getChecked(HOURS) - years * 365 * 24 - days * 24; - if (started || hours > 0) { - started = true; - result.append(String.format("%02dh ", hours)); - } - if (unit.equals(HOURS)) { - return result.toString().trim(); - } - - long minutes = - pInput.getChecked(MINUTES) - years * 365 * 24 * 60 - days * 24 * 60 - hours * 60; - if (started || minutes > 0) { - result.append(String.format("%02dmin ", minutes)); - } - if (unit.equals(MINUTES)) { - started = true; - return result.toString().trim(); - } - - long seconds = - pInput.getChecked(SECONDS) - - years * 365 * 24 * 60 * 60 - - days * 24 * 60 * 60 - - hours * 60 * 60 - - minutes * 60; - result.append(String.format("%02ds", seconds)); - - return result.toString(); - }; - - private static final String DEFAULT_FORMAT_PROPERTY_NAME = - TimeSpan.class.getCanonicalName() + ".defaultFormat"; - - private static final Function<TimeSpan, String> DEFAULT_FORMAT; - - static { - String format = - Ascii.toUpperCase(System.getProperty(DEFAULT_FORMAT_PROPERTY_NAME, "SIMPLE").trim()); - switch (format) { - case "HUMAN_READABLE_LARGE": - DEFAULT_FORMAT = FORMAT_HUMAN_READABLE_LARGE; - break; - case "SIMPLE": - DEFAULT_FORMAT = FORMAT_SIMPLE; - break; - default: - DEFAULT_FORMAT = FORMAT_SIMPLE; - } - } -} diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/netconf/ONFCoreInterfacePac.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/netconf/ONFCoreInterfacePac.java deleted file mode 100644 index 1c9c8e073..000000000 --- a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/netconf/ONFCoreInterfacePac.java +++ /dev/null @@ -1,37 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START======================================================================== - * ONAP : ccsdk feature sdnr wt - * ================================================================================================= - * Copyright (C) 2019 highstreet technologies GmbH 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.onap.ccsdk.features.sdnr.wt.devicemanager.base.netconf; - -/** - * @author herbert - * - */ -public class ONFCoreInterfacePac<T> { - - - Class<T> myClass; - - ONFCoreInterfacePac( Class<T> myClass ) { - this.myClass = myClass; - } - - -} diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/netconf/ONFCoreNetworkElement12.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/netconf/ONFCoreNetworkElement12.java index de43e5760..b57e8c906 100644 --- a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/netconf/ONFCoreNetworkElement12.java +++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/netconf/ONFCoreNetworkElement12.java @@ -336,7 +336,7 @@ public class ONFCoreNetworkElement12 extends ONFCoreNetworkElement12Base } } else { - LOG.debug("Mountpoint '{}' NE-Name '{}'", getMountPointNodeName(), optionalNe.getName().toString()); + LOG.debug("Mountpoint '{}' NE-Name '{}'", getMountPointNodeName(), optionalNe.getName()); List<Lp> actualInterfaceList = getLtpList(optionalNe); if (!interfaceList.equals(actualInterfaceList)) { LOG.debug("Mountpoint '{}' Update LTP List. Elements {}", getMountPointNodeName(), @@ -364,13 +364,13 @@ public class ONFCoreNetworkElement12 extends ONFCoreNetworkElement12Base UniversalId uuid; synchronized (pmLock) { - for (Lp ltp : interfaceList) { + for (Lp lp : interfaceList) { idxStart = resultList.size(); - uuid = ltp.getUuid(); - Class<?> lpClass = getLpExtension(ltp); + uuid = lp.getUuid(); + Class<?> lpClass = getLpExtension(lp); - ONFLayerProtocolName lpName = ONFLayerProtocolName.valueOf(ltp.getLayerProtocolName()); + ONFLayerProtocolName lpName = ONFLayerProtocolName.valueOf(lp.getLayerProtocolName()); microwaveModel.readTheFaultsOfMicrowaveModel(lpName, lpClass, uuid, resultList); @@ -422,21 +422,21 @@ public class ONFCoreNetworkElement12 extends ONFCoreNetworkElement12Base } /** - * Get from LayProtocolExtensions the related generated ONF Interface PAC class which represents it. + * Get from LayerProtocolExtensions the related generated ONF Interface PAC class which represents it. * - * @param ltp logical termination point + * @param lp logical termination point * @return Class of InterfacePac */ @Nullable - private Class<?> getLpExtension(@Nullable Lp ltp) { + private Class<?> getLpExtension(@Nullable Lp lp) { String capability = EMPTY; String revision = EMPTY; String conditionalPackage = EMPTY; Class<?> res = null; - if (ltp != null) { - for (Extension e : getExtensionList(ltp)) { + if (lp != null) { + for (Extension e : getExtensionList(lp)) { if (e.getValueName().contentEquals("capability")) { capability = e.getValue(); int idx = capability.indexOf("?"); diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/netconf/ONFCoreNetworkElementFactory.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/netconf/ONFCoreNetworkElementFactory.java index 3fc8b133f..a314fd99f 100644 --- a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/netconf/ONFCoreNetworkElementFactory.java +++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/netconf/ONFCoreNetworkElementFactory.java @@ -18,6 +18,7 @@ package org.onap.ccsdk.features.sdnr.wt.devicemanager.base.netconf; import com.google.common.base.Optional; +import com.google.common.util.concurrent.CheckedFuture; import javax.annotation.Nonnull; import javax.annotation.Nullable; import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.netconf.container.Capabilities; @@ -57,6 +58,7 @@ public class ONFCoreNetworkElementFactory { ONFCoreNetworkElementRepresentation res = null; try (ReadOnlyTransaction tx = dataBroker.newReadOnlyTransaction();){ + CheckedFuture<Optional<Node>, ReadFailedException> checkedFuture = tx.read(LogicalDatastoreType.OPERATIONAL, instanceIdentifier); Optional<Node> nodeOption = tx.read(LogicalDatastoreType.OPERATIONAL, instanceIdentifier).checkedGet(); if (nodeOption.isPresent()) { Node node = nodeOption.get(); @@ -64,7 +66,7 @@ public class ONFCoreNetworkElementFactory { if (nnode != null) { ConnectionStatus csts = nnode.getConnectionStatus(); if (csts == ConnectionStatus.Connected) { - Capabilities capabilities = new Capabilities(nnode); + Capabilities capabilities = Capabilities.getAvailableCapabilities(nnode); LOG.info("Mountpoint {} capabilities {}", mountPointNodeName, capabilities); res = ONFCoreNetworkElement12.build(mountPointNodeName, capabilities, mountpointDataBroker, webSocketService, databaseService, dcaeProvider, aotsmClient, maintenanceService, diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/netconf/container/Capabilities.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/netconf/container/Capabilities.java index 008a8fae7..d64996c65 100644 --- a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/netconf/container/Capabilities.java +++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/netconf/container/Capabilities.java @@ -23,7 +23,6 @@ package org.onap.ccsdk.features.sdnr.wt.devicemanager.base.netconf.container; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; -import java.lang.reflect.Proxy; import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.ArrayList; @@ -32,29 +31,40 @@ import java.util.Date; import java.util.List; import java.util.Optional; import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.NetconfNode; +import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.netconf.node.connection.status.AvailableCapabilities; import org.opendaylight.yangtools.yang.common.QName; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +/** + * Wrapper class for capabilites for Boron and later releases. Uses generics because yang model was + * changed from Boron to later version. Interface class: + * org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.netconf.node.connection.status.available.capabilities.AvailableCapability + */ public class Capabilities { private static final Logger LOG = LoggerFactory.getLogger(Capabilities.class); - private static final String INTERFACE_AVAILABLECAPABILITY = - "org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.netconf.node.connection.status.available.capabilities.AvailableCapability"; + private static final String METHODNAME = "getCapability"; private final List<String> capabilities = new ArrayList<>(); private final DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd"); - public Capabilities() { - - } - - public Capabilities(NetconfNode nnode) { - LOG.info("Create Capabilities constructor"); + private Capabilities() {} + public static Capabilities getAvailableCapabilities(NetconfNode nnode) { + LOG.info("GetAvailableCapabilities for node"); + Capabilities capabilities = new Capabilities(); if (nnode != null) { - constructor(nnode.getAvailableCapabilities().getAvailableCapability()); + AvailableCapabilities availableCapabilites = nnode.getAvailableCapabilities(); + if (availableCapabilites != null) { + capabilities.constructor(availableCapabilites.getAvailableCapability()); + } else { + LOG.debug("empty capabilites"); + } + } else { + LOG.debug("No node provided"); } + return capabilities; } /** @@ -66,45 +76,27 @@ public class Capabilities { * - Carbon: List<AvailableCapability> */ private void constructor(List<?> pcapabilities) { - for (Object capability : pcapabilities) { - if (LOG.isTraceEnabled()) { - LOG.trace("capability class: {} Interfaces: {}", capability.getClass().getName(), - Arrays.toString(capability.getClass().getInterfaces())); - } - if (capability instanceof String) { // ODL Boron specific - this.capabilities.add((String) capability); - } else if (hasInterface(capability, INTERFACE_AVAILABLECAPABILITY)) { // Carbon specific part .. handled via - // generic - try { - Method method = capability.getClass().getDeclaredMethod("getCapability"); - this.capabilities.add(method.invoke(capability).toString()); - } catch (NoSuchMethodException | SecurityException | IllegalAccessException | IllegalArgumentException - | InvocationTargetException e) { - LOG.warn("Unknown capability class leads to a problem", e); + if (pcapabilities != null) { + Method methodGetCapability; + + for (Object capability : pcapabilities) { + + if (capability instanceof String) { // ODL Boron specific + this.capabilities.add((String) capability); + } else { // Carbon specific part .. handled via generics + try { + methodGetCapability = capability.getClass().getDeclaredMethod(METHODNAME); + methodGetCapability.setAccessible(true); + this.capabilities.add(methodGetCapability.invoke(capability).toString()); + } catch (NoSuchMethodException | SecurityException | IllegalAccessException + | IllegalArgumentException | InvocationTargetException e) { + LOG.warn("Capability class with missing interface method {}: {} {} {}", METHODNAME, + e.getMessage(), capability.getClass(), + Arrays.toString(capability.getClass().getInterfaces())); + } } - } else { - LOG.warn("Unknown capability class: {}", capability.getClass(), - Arrays.toString(capability.getClass().getInterfaces())); - } - } - } - - /** - * check if namespace is supported by given capabilites - * - * @param theCapability Capability to search - * @return true if available - */ - @Deprecated - public boolean isSupportingNamespace(QName theCapability) { - String theNameSpace = theCapability.getNamespace().toString(); - for (String capability : capabilities) { - if (capability.contains(theNameSpace)) { - LOG.trace("Check {} against {}", capability, theNameSpace); - return true; } } - return false; } /** @@ -129,45 +121,25 @@ public class Capabilities { revision = formatter.format((Date) revisionObject); } else { revision = revisionObject.toString(); - LOG.warn("Revision number type not supported. Class:{} String:{}", revisionObject.getClass().getName(), - revisionObject); + LOG.debug("Revision number type not supported. Use toString().String:{} Class:{} ", revisionObject, + revisionObject.getClass().getName()); } + LOG.trace("isSupportingNamespaceAndRevision: Model namespace {}?[revision {}]", namespace, revision); for (String capability : capabilities) { if (capability.contains(namespace) && capability.contains(revision)) { - LOG.trace("Model namespace {}?[revision {}]", namespace, revision); + LOG.trace("Verify true with: {}", capability); return true; + } else { + LOG.trace("Verify false with: {}", capability); } } return false; } - public void add(String qname) { - capabilities.add(qname); - } - @Override public String toString() { return "Capabilities [capabilities=" + capabilities + "]"; } - /** - * Check if object is proxy and has specific interface - * - * @param object Name of the object to verify - * @param interfaceName is the name of the interface - * @return boolean accordingly - */ - static boolean hasInterface(Object object, String interfaceName) { - if (object instanceof Proxy) { - Class<?>[] interfaces = object.getClass().getInterfaces(); - for (Class<?> i : interfaces) { - if (i.getName().equals(interfaceName)) { - return true; - } - } - } - return false; - } - } diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/netconf/container/ONFLayerProtocolName.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/netconf/container/ONFLayerProtocolName.java index ece7e7aa1..68627a862 100644 --- a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/netconf/container/ONFLayerProtocolName.java +++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/netconf/container/ONFLayerProtocolName.java @@ -6,9 +6,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. See the License for the specific language governing permissions and limitations under @@ -53,5 +53,9 @@ public enum ONFLayerProtocolName { return Unknown; } + public String getValue() { + return myLayerProtocolName; + } + } diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/netconf/util/GenericTransactionUtils.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/netconf/util/GenericTransactionUtils.java index 83063a05a..403ba0ad4 100644 --- a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/netconf/util/GenericTransactionUtils.java +++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/netconf/util/GenericTransactionUtils.java @@ -26,10 +26,8 @@ import javax.annotation.Nullable; import org.apache.commons.lang3.exception.ExceptionUtils; import org.opendaylight.controller.md.sal.binding.api.DataBroker; import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction; -import org.opendaylight.controller.md.sal.binding.api.WriteTransaction; import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException; -import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException; import org.opendaylight.yangtools.yang.binding.DataObject; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; import org.slf4j.Logger; @@ -42,32 +40,6 @@ import com.google.common.util.concurrent.CheckedFuture; public final class GenericTransactionUtils { static final Logger LOG = LoggerFactory.getLogger(GenericTransactionUtils.class); - public static <T extends DataObject> boolean writeData(DataBroker dataBroker, - LogicalDatastoreType logicalDatastoreType, InstanceIdentifier<T> iid, T dataObject, boolean isAdd) { - Preconditions.checkNotNull(dataBroker); - WriteTransaction modification = dataBroker.newWriteOnlyTransaction(); - if (isAdd) { - if (dataObject == null) { - LOG.warn("Invalid attempt to add a non-existent object to path {}", iid); - return false; - } - modification.merge(logicalDatastoreType, iid, dataObject, true /* createMissingParents */); - } else { - modification.delete(LogicalDatastoreType.CONFIGURATION, iid); - } - CheckedFuture<Void, TransactionCommitFailedException> commitFuture = modification.submit(); - try { - commitFuture.checkedGet(); - LOG.debug("Transaction success for {} of object {}", isAdd ? "add" : "delete", dataObject); - return true; - } catch (Exception e) { - LOG.warn("Transaction failed with error {} for {} of object {}", e.getMessage(), isAdd ? "add" : "delete", - dataObject); - modification.cancel(); - return false; - } - } - /** * Deliver the data back or null. Warning * diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/netconf/wrapperc/WrapperEquipmentPacRev170402.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/netconf/wrapperc/WrapperEquipmentPacRev170402.java index 03e830e5a..aeda48ea7 100644 --- a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/netconf/wrapperc/WrapperEquipmentPacRev170402.java +++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/netconf/wrapperc/WrapperEquipmentPacRev170402.java @@ -21,7 +21,6 @@ import java.lang.reflect.Constructor; import java.lang.reflect.InvocationTargetException; import java.util.ArrayList; import java.util.List; -import javax.annotation.Nullable; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.internalTypes.InternalDateAndTime; @@ -102,26 +101,4 @@ public class WrapperEquipmentPacRev170402 implements OnfInterfacePac { return resultList; } - /** - * Read problems of specific interfaces - * - * @param interfacePacUuid Universal index of Equipmentpac - * @return EquipmentPac or null - */ - public @Nullable EquipmentPac readEquipmentPac(UniversalId interfacePacUuid) { - - final Class<?> clazzPac = EquipmentPac.class; - - LOG.info("DBRead Get problems for class {} from mountpoint {} for uuid {}", clazzPac.getSimpleName(), - coreData.getMountpoint(), interfacePacUuid.getValue()); - - InstanceIdentifier<EquipmentPac> equipmentIID = - InstanceIdentifier.builder(EquipmentPac.class, new EquipmentPacKey(interfacePacUuid)).build(); - - EquipmentPac res = GenericTransactionUtils.readData(coreData.getDataBroker(), LogicalDatastoreType.OPERATIONAL, - equipmentIID); - - return res; - } - } diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/netconf/wrapperc/WrapperMicrowaveModelRev170324.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/netconf/wrapperc/WrapperMicrowaveModelRev170324.java index b62940109..5c7e8d261 100644 --- a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/netconf/wrapperc/WrapperMicrowaveModelRev170324.java +++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/netconf/wrapperc/WrapperMicrowaveModelRev170324.java @@ -6,9 +6,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. See the License for the specific language governing permissions and limitations under @@ -26,7 +26,6 @@ import java.util.List; import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.internalTypes.InternalDateAndTime; import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.internalTypes.InternalSeverity; import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.netconf.ONFCOreNetworkElementCoreData; -import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.netconf.ONFCoreNetworkElement12; import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.netconf.container.ExtendedAirInterfaceHistoricalPerformanceType12; import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.netconf.container.ONFLayerProtocolName; import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.netconf.util.GenericTransactionUtils; @@ -79,7 +78,7 @@ import org.slf4j.LoggerFactory; public class WrapperMicrowaveModelRev170324 implements OnfMicrowaveModel, MicrowaveModelListener { - private static final Logger LOG = LoggerFactory.getLogger(ONFCoreNetworkElement12.class); + private static final Logger LOG = LoggerFactory.getLogger(WrapperMicrowaveModelRev170324.class); public static final QName QNAME = MwAirInterfacePac.QNAME; @@ -91,89 +90,93 @@ public class WrapperMicrowaveModelRev170324 implements OnfMicrowaveModel, Microw * Setter/Getter */ + @Override public void setCoreData(ONFCOreNetworkElementCoreData coreData) { - this.coreData = coreData; - } + this.coreData = coreData; + } - public ONFCOreNetworkElementCoreData getCoreData() { - return coreData; - } + public ONFCOreNetworkElementCoreData getCoreData() { + return coreData; + } - @Override - public void setOnfMicrowaveModelListener(OnfMicrowaveModelNotification microwaveModelListener) { - this.microwaveModelListener = microwaveModelListener; - } + @Override + public void setOnfMicrowaveModelListener(OnfMicrowaveModelNotification microwaveModelListener) { + this.microwaveModelListener = microwaveModelListener; + } - @SuppressWarnings("unchecked") - @Override - public <T extends NotificationListener> T getNotificationListener() { - return (T)this; - } + @SuppressWarnings("unchecked") + @Override + public <T extends NotificationListener> T getNotificationListener() { + return (T)this; + } /*----------------------------------------------------------------------------- * Interfacefunctions */ + @Override public void readTheFaultsOfMicrowaveModel(ONFLayerProtocolName lpName, Class<?> lpClass, UniversalId uuid, - List<ProblemNotificationXml> resultList) { + List<ProblemNotificationXml> resultList) { - switch (lpName) { - case MWAirInterface: - readTheFaultsOfMwAirInterfacePac(uuid, resultList); - break; + switch (lpName) { + case MWAirInterface: + readTheFaultsOfMwAirInterfacePac(uuid, resultList); + break; - case EthernetContainer12: - readTheFaultsOfMwEthernetContainerPac(uuid, resultList); - break; + case EthernetContainer12: + readTheFaultsOfMwEthernetContainerPac(uuid, resultList); + break; - case TDMContainer: - readTheFaultsOfMwTdmContainerPac(uuid, resultList); - break; + case TDMContainer: + readTheFaultsOfMwTdmContainerPac(uuid, resultList); + break; - case Structure: - if (lpClass == MwHybridMwStructurePac.class) { - readTheFaultsOfMwHybridMwStructurePac(uuid, resultList); + case Structure: + if (lpClass == MwHybridMwStructurePac.class) { + readTheFaultsOfMwHybridMwStructurePac(uuid, resultList); - } else if (lpClass == MwAirInterfaceDiversityPac.class) { - readTheFaultsOfMwAirInterfaceDiversityPac(uuid, resultList); + } else if (lpClass == MwAirInterfaceDiversityPac.class) { + readTheFaultsOfMwAirInterfaceDiversityPac(uuid, resultList); - } else if (lpClass == MwPureEthernetStructurePac.class) { - readTheFaultsOfMwPureEthernetStructurePac(uuid, resultList); + } else if (lpClass == MwPureEthernetStructurePac.class) { + readTheFaultsOfMwPureEthernetStructurePac(uuid, resultList); - } else { - LOG.warn("Unassigned lp model {} class {}", lpName, lpClass); - } - break; + } else { + LOG.warn("Unassigned lp model {} class {}", lpName, lpClass); + } + break; case Ethernet: // No alarms supported break; case EthernetContainer10: default: LOG.warn("Unassigned or not expected lp in model {}", lpName); - } + } } - public List<? extends OtnHistoryDataG> readTheHistoricalPerformanceData(ONFLayerProtocolName lpName, Lp lp) { - switch (lpName) { - case MWAirInterface: - return readTheHistoricalPerformanceDataOfMwAirInterfacePac(lp); - - case EthernetContainer12: - return readTheHistoricalPerformanceDataOfEthernetContainer(lp); - - case EthernetContainer10: - case EthernetPhysical: - case Ethernet: - case TDMContainer: - case Structure: - case Unknown: - LOG.debug("Do not read HistoricalPM data for {} {}", lpName, lp.getUuid().getValue()); - break; - } - return new ArrayList<>(); + @Override + public List<? extends OtnHistoryDataG> readTheHistoricalPerformanceData(ONFLayerProtocolName lpName, Lp lp) { + switch (lpName) { + case MWAirInterface: + return readTheHistoricalPerformanceDataOfMwAirInterfacePac(lp); + + case EthernetContainer12: + return readTheHistoricalPerformanceDataOfEthernetContainer(lp); + + case EthernetContainer10: + case EthernetPhysical: + case Ethernet: + case TDMContainer: + case Structure: + case Unknown: + LOG.debug("Do not read HistoricalPM data for {} {}", lpName, lp.getUuid().getValue()); + break; + } + return new ArrayList<>(); } - public Class<?> getClassForLtpExtension(QName qName) { + @Override + public Class<?> getClassForLtpExtension(QName qName) { Class<?> res = null; if (qName.equals(MwAirInterfacePac.QNAME)) { res = MwAirInterfacePac.class; @@ -189,8 +192,8 @@ public class WrapperMicrowaveModelRev170324 implements OnfMicrowaveModel, Microw res = MwTdmContainerPac.class; } LOG.info("Found QName {} mapped to {}", String.valueOf(qName), String.valueOf(res)); - return res; - } + return res; + } /*----------------------------------------------------------------------------- * Reading problems for specific interface pacs @@ -213,7 +216,7 @@ public class WrapperMicrowaveModelRev170324 implements OnfMicrowaveModel, Microw // AirInterfaceCurrentProblemTypeG.class; LOG.info("DBRead Get problems for class {} from mountpoint {} for uuid {}", clazzPac.getSimpleName(), - coreData.getMountpoint(), interfacePacUuid.getValue()); + coreData.getMountpoint(), interfacePacUuid.getValue()); // Step 2.2: construct data and the relative iid InstanceIdentifier<AirInterfaceCurrentProblems> mwAirInterfaceIID = InstanceIdentifier @@ -484,7 +487,7 @@ public class WrapperMicrowaveModelRev170324 implements OnfMicrowaveModel, Microw // Step 2.3: read to the config data store AirInterfaceHistoricalPerformances airHistoricalPerformanceData = GenericTransactionUtils.readData( - coreData.getDataBroker(), LogicalDatastoreType.OPERATIONAL, mwAirInterfaceHistoricalPerformanceIID); + coreData.getDataBroker(), LogicalDatastoreType.OPERATIONAL, mwAirInterfaceHistoricalPerformanceIID); if (airHistoricalPerformanceData == null) { LOG.debug("DBRead MWAirInterfacePac Id {} no AirInterfaceHistoricalPerformances", @@ -530,7 +533,7 @@ public class WrapperMicrowaveModelRev170324 implements OnfMicrowaveModel, Microw } else { // import // org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170320.ethernet.container.historical.performances.g.HistoricalPerformanceDataList - // org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.ethernet.container.historical.performances.g.HistoricalPerformanceDataList + // org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.ethernet.container.historical.performances.g.HistoricalPerformanceDataList List<org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.ethernet.container.historical.performances.g.HistoricalPerformanceDataList> airHistPMList = ethContainerHistoricalPerformanceData .getHistoricalPerformanceDataList(); LOG.debug("DBRead {} Id {} Records intermediate: {}", myName, ethContainerPacuuId, airHistPMList.size()); @@ -553,7 +556,7 @@ public class WrapperMicrowaveModelRev170324 implements OnfMicrowaveModel, Microw InternalDateAndTime.valueOf(notification.getTimeStamp()), notification.getObjectIdRef().getValue()); microwaveModelListener.onObjectCreationNotification(notificationXml); - } + } @Override public void onObjectDeletionNotification(ObjectDeletionNotification notification) { @@ -565,8 +568,9 @@ public class WrapperMicrowaveModelRev170324 implements OnfMicrowaveModel, Microw notification.getObjectIdRef().getValue() ); microwaveModelListener.onObjectDeletionNotification(notificationXml); - } + } + @Override public void onProblemNotification(ProblemNotification notification) { LOG.debug("Got event of type :: {}", ProblemNotification.class.getSimpleName()); @@ -576,7 +580,7 @@ public class WrapperMicrowaveModelRev170324 implements OnfMicrowaveModel, Microw notification.getCounter().toString(), InternalDateAndTime.valueOf(notification.getTimeStamp())); microwaveModelListener.onProblemNotification(notificationXml); - } + } @Override public void onAttributeValueChangedNotification(AttributeValueChangedNotification notification) { @@ -587,7 +591,7 @@ public class WrapperMicrowaveModelRev170324 implements OnfMicrowaveModel, Microw notification.getObjectIdRef().getValue(), notification.getAttributeName(), notification.getNewValue()); microwaveModelListener.onAttributeValueChangedNotification(notificationXml); - } + } } diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/netconf/wrapperc/WrapperMicrowaveModelRev180907.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/netconf/wrapperc/WrapperMicrowaveModelRev180907.java index d35115fd9..0328d79de 100644 --- a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/netconf/wrapperc/WrapperMicrowaveModelRev180907.java +++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/netconf/wrapperc/WrapperMicrowaveModelRev180907.java @@ -6,9 +6,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. See the License for the specific language governing permissions and limitations under @@ -33,7 +33,6 @@ import org.opendaylight.yangtools.yang.common.QName; import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.internalTypes.InternalDateAndTime; import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.internalTypes.InternalSeverity; import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.netconf.ONFCOreNetworkElementCoreData; -import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.netconf.ONFCoreNetworkElement12; import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.netconf.container.ExtendedAirInterfaceHistoricalPerformanceType1211; import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.netconf.container.ONFLayerProtocolName; import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.netconf.util.GenericTransactionUtils; @@ -82,7 +81,7 @@ import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.r public class WrapperMicrowaveModelRev180907 implements OnfMicrowaveModel, MicrowaveModelListener { - private static final Logger LOG = LoggerFactory.getLogger(ONFCoreNetworkElement12.class); + private static final Logger LOG = LoggerFactory.getLogger(WrapperMicrowaveModelRev180907.class); public static final QName QNAME = MwAirInterfacePac.QNAME; @@ -96,6 +95,7 @@ public class WrapperMicrowaveModelRev180907 implements OnfMicrowaveModel, Microw * Setter/Getter */ + @Override public void setCoreData(ONFCOreNetworkElementCoreData coreData) { this.coreData = coreData; } @@ -119,6 +119,7 @@ public class WrapperMicrowaveModelRev180907 implements OnfMicrowaveModel, Microw * Interfacefunctions */ + @Override public void readTheFaultsOfMicrowaveModel(ONFLayerProtocolName lpName, Class<?> lpClass, UniversalId uuid, List<ProblemNotificationXml> resultList) { @@ -158,7 +159,8 @@ public class WrapperMicrowaveModelRev180907 implements OnfMicrowaveModel, Microw } } - public List<? extends OtnHistoryDataG> readTheHistoricalPerformanceData(ONFLayerProtocolName lpName, Lp lp) { + @Override + public List<? extends OtnHistoryDataG> readTheHistoricalPerformanceData(ONFLayerProtocolName lpName, Lp lp) { switch (lpName) { case MWAirInterface: return readTheHistoricalPerformanceDataOfMwAirInterfacePac(lp); @@ -178,7 +180,8 @@ public class WrapperMicrowaveModelRev180907 implements OnfMicrowaveModel, Microw return new ArrayList<>(); } - public Class<?> getClassForLtpExtension(QName qName) { + @Override + public Class<?> getClassForLtpExtension(QName qName) { Class<?> res = null; if (qName.equals(MwAirInterfacePac.QNAME)) { res = MwAirInterfacePac.class; @@ -571,6 +574,7 @@ public class WrapperMicrowaveModelRev180907 implements OnfMicrowaveModel, Microw microwaveModelListener.onObjectDeletionNotification(notificationXml); } + @Override public void onProblemNotification(ProblemNotification notification) { LOG.debug("Got event of type :: {}", ProblemNotification.class.getSimpleName()); diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/netconf/wrapperc/WrapperMicrowaveModelRev181010.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/netconf/wrapperc/WrapperMicrowaveModelRev181010.java index c3970a8d4..9a6b42589 100644 --- a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/netconf/wrapperc/WrapperMicrowaveModelRev181010.java +++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/base/netconf/wrapperc/WrapperMicrowaveModelRev181010.java @@ -6,9 +6,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. See the License for the specific language governing permissions and limitations under @@ -33,7 +33,6 @@ import org.opendaylight.yangtools.yang.common.QName; import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.internalTypes.InternalDateAndTime; import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.internalTypes.InternalSeverity; import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.netconf.ONFCOreNetworkElementCoreData; -import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.netconf.ONFCoreNetworkElement12; import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.netconf.container.ExtendedAirInterfaceHistoricalPerformanceType1211p; import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.netconf.container.ONFLayerProtocolName; import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.netconf.util.GenericTransactionUtils; @@ -82,7 +81,7 @@ import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.r public class WrapperMicrowaveModelRev181010 implements OnfMicrowaveModel, MicrowaveModelListener { - private static final Logger LOG = LoggerFactory.getLogger(ONFCoreNetworkElement12.class); + private static final Logger LOG = LoggerFactory.getLogger(WrapperMicrowaveModelRev181010.class); public static final QName QNAME = MwAirInterfacePac.QNAME; @@ -95,6 +94,7 @@ public class WrapperMicrowaveModelRev181010 implements OnfMicrowaveModel, Microw * Setter/Getter */ + @Override public void setCoreData(ONFCOreNetworkElementCoreData coreData) { this.coreData = coreData; } @@ -118,6 +118,7 @@ public class WrapperMicrowaveModelRev181010 implements OnfMicrowaveModel, Microw * Interfacefunctions */ + @Override public void readTheFaultsOfMicrowaveModel(ONFLayerProtocolName lpName, Class<?> lpClass, UniversalId uuid, List<ProblemNotificationXml> resultList) { @@ -157,7 +158,8 @@ public class WrapperMicrowaveModelRev181010 implements OnfMicrowaveModel, Microw } } - public List<? extends OtnHistoryDataG> readTheHistoricalPerformanceData(ONFLayerProtocolName lpName, Lp lp) { + @Override + public List<? extends OtnHistoryDataG> readTheHistoricalPerformanceData(ONFLayerProtocolName lpName, Lp lp) { switch (lpName) { case MWAirInterface: return readTheHistoricalPerformanceDataOfMwAirInterfacePac(lp); @@ -177,7 +179,8 @@ public class WrapperMicrowaveModelRev181010 implements OnfMicrowaveModel, Microw return new ArrayList<>(); } - public Class<?> getClassForLtpExtension(QName qName) { + @Override + public Class<?> getClassForLtpExtension(QName qName) { Class<?> res = null; if (qName.equals(MwAirInterfacePac.QNAME)) { res = MwAirInterfacePac.class; @@ -547,6 +550,7 @@ public class WrapperMicrowaveModelRev181010 implements OnfMicrowaveModel, Microw return resultList; } + @Override public void onObjectCreationNotification(ObjectCreationNotification notification) { LOG.debug("Got event of type :: {}", ObjectCreationNotification.class.getSimpleName()); @@ -569,6 +573,7 @@ public class WrapperMicrowaveModelRev181010 implements OnfMicrowaveModel, Microw microwaveModelListener.onObjectDeletionNotification(notificationXml); } + @Override public void onProblemNotification(ProblemNotification notification) { LOG.debug("Got event of type :: {}", ProblemNotification.class.getSimpleName()); diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/config/HtDevicemanagerConfiguration.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/config/HtDevicemanagerConfiguration.java index 6167248f0..c07bf4620 100644 --- a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/config/HtDevicemanagerConfiguration.java +++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/config/HtDevicemanagerConfiguration.java @@ -79,13 +79,18 @@ public class HtDevicemanagerConfiguration { } return mObj; } - public static HtDevicemanagerConfiguration getTestConfiguration() { - return getTestConfiguration(CONFIGURATIONTESTFILE); + return getTestConfiguration(CONFIGURATIONTESTFILE,false); } - - public static HtDevicemanagerConfiguration getTestConfiguration(final String filename) { - if (mObjTest == null) { + + public static HtDevicemanagerConfiguration getTestConfiguration(boolean newInstance) { + return getTestConfiguration(CONFIGURATIONTESTFILE,newInstance); + } + public static HtDevicemanagerConfiguration getTestConfiguration(String filename) { + return getTestConfiguration(filename,false); + } + public static HtDevicemanagerConfiguration getTestConfiguration(final String filename,boolean newInstance) { + if (mObjTest == null || newInstance) { mObjTest = new HtDevicemanagerConfiguration(filename); } return mObjTest; diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/config/impl/AaiConfig.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/config/impl/AaiConfig.java index b30b3271d..fd5d04e6a 100644 --- a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/config/impl/AaiConfig.java +++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/config/impl/AaiConfig.java @@ -345,6 +345,15 @@ public class AaiConfig extends BaseSubConfig { return true; } + public String getBaseUri() { + String s; + if(!this.apiVersion.startsWith("/")) { + s="/"+this.apiVersion; + } + else + s=this.apiVersion; + return s; + } public String getBaseUrl() { String url=this.baseUrl; if(!url.endsWith("/")) { diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/config/impl/AkkaConfig.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/config/impl/AkkaConfig.java index 6c416a257..55d5b9a11 100644 --- a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/config/impl/AkkaConfig.java +++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/config/impl/AkkaConfig.java @@ -72,14 +72,7 @@ public class AkkaConfig { public boolean isSingleNode() { return !this.isCluster(); } - public static AkkaConfig defaultSingleNodeConfig() - { - AkkaConfig cfg=new AkkaConfig(); - cfg.cluserConfig=new ClusterConfig(); - return cfg; - } - - public static AkkaConfig parse(String content) throws Exception { + public static AkkaConfig parse(String content) throws Exception { Config cfg = ConfigFactory.parseString(content); AkkaConfig c = new AkkaConfig(); c.cluserConfig=new ClusterConfig(cfg.getConfig("odl-cluster-data").getConfig("akka").getConfig("cluster")); diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/database/types/EsEventBase.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/database/types/EsEventBase.java index d1731459e..bcd2849d2 100644 --- a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/database/types/EsEventBase.java +++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/database/types/EsEventBase.java @@ -6,9 +6,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. See the License for the specific language governing permissions and limitations under @@ -40,8 +40,4 @@ public class EsEventBase extends EsObject { this.event = event; } - public static String getEsdatatypename() { - return ESDATATYPENAME; - } - } diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/database/types/EsFaultCurrent.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/database/types/EsFaultCurrent.java index b39b2e296..97c48f1ff 100644 --- a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/database/types/EsFaultCurrent.java +++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/database/types/EsFaultCurrent.java @@ -6,9 +6,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. See the License for the specific language governing permissions and limitations under @@ -56,9 +56,6 @@ public class EsFaultCurrent extends EsObject { public static QueryBuilder getQueryForOneNode( String nodeName) { return QueryBuilders.termQuery("faultCurrent.nodeName", nodeName); } - public static QueryBuilder getQueryForAll() { - return QueryBuilders.matchAllQuery(); - } public static QueryBuilder getQueryForOneNodeAndObjectId( String nodeName, String objectId) { BoolQueryBuilder bq = QueryBuilders.boolQuery(); @@ -68,8 +65,4 @@ public class EsFaultCurrent extends EsObject { //return QueryBuilders.termQuery("faultCurrent.objectId", objectId); } - - public static String getEsdatatypename() { - return ESDATATYPENAME; - } } diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/database/types/EsFaultLog.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/database/types/EsFaultLog.java index 87c77ea99..06a893ad7 100644 --- a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/database/types/EsFaultLog.java +++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/database/types/EsFaultLog.java @@ -6,9 +6,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. See the License for the specific language governing permissions and limitations under @@ -40,8 +40,4 @@ public class EsFaultLog extends EsObject { this.fault = fault; } - public static String getEsdatatypename() { - return ESDATATYPENAME; - } - } diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/database/types/EsVersionInfo.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/database/types/EsVersionInfo.java deleted file mode 100644 index ca5b36717..000000000 --- a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/database/types/EsVersionInfo.java +++ /dev/null @@ -1,75 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START======================================================================== - * ONAP : ccsdk feature sdnr wt - * ================================================================================================= - * Copyright (C) 2019 highstreet technologies GmbH 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.onap.ccsdk.features.sdnr.wt.devicemanager.impl.database.types; - -import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.database.EsObject; -import org.osgi.framework.Version; - -/** - * - * Create a VersionInfo Object Network to be recorded in the database - * - */ - -public class EsVersionInfo extends EsObject { - - public static final String ESDATATYPENAME = "versioninfo"; - private static final String EMPTY = ""; - - private Version bundleVersion; - private String build = EMPTY; - private String version = EMPTY; - - public EsVersionInfo() { - } - - public Version getBundleVersion() { - return bundleVersion; - } - - public void setBundleVersion(Version bundleVersion) { - this.bundleVersion = bundleVersion; - } - - public String getBuild() { - return build; - } - - public void setBuild(String build) { - this.build = build; - } - - public String getVersion() { - return version; - } - - public void setVersion(String version) { - this.version = version; - } - - public static String getEsdatatypename() { - return ESDATATYPENAME; - } - - @Override - public String toString() { - return "EsVersionInfo [bundleVersion=" + bundleVersion + ", build=" + build + ", version=" + version + "]"; - } - - - } diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/index/impl/IndexMwtnService.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/index/impl/IndexMwtnService.java index 4a9ac9881..e175515ae 100644 --- a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/index/impl/IndexMwtnService.java +++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/index/impl/IndexMwtnService.java @@ -35,9 +35,9 @@ public class IndexMwtnService implements AutoCloseable { /** Index name to be used */ public static final String INDEX = "mwtn"; /** Location of mapping data **/ - private static final String MAPPING = "/elasticsearch/index/mwtn/mwtnMapping.json"; + private static final String MAPPING = "elasticsearch/index/mwtn/mwtnMapping.json"; /** Location of configuration data **/ - private static final String MODELDATA = "/elasticsearch/index/mwtn/modelDescription"; + private static final String MODELDATA = "elasticsearch/index/mwtn/modelDescription"; private final HtDatabaseClientAbstract client; diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/index/impl/IndexUpdateService.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/index/impl/IndexUpdateService.java index db567f28c..4af48922e 100644 --- a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/index/impl/IndexUpdateService.java +++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/index/impl/IndexUpdateService.java @@ -98,7 +98,7 @@ public class IndexUpdateService implements AutoCloseable { } public void start() { - this.taskHandle = this.scheduler.scheduleAtFixedRate(checkForUpdateTask, 0, 120, TimeUnit.SECONDS); + this.taskHandle = this.scheduler.scheduleAtFixedRate(checkForUpdateTask, 0, 30, TimeUnit.SECONDS); } public void stop() { diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/ptp/impl/GeoLocation.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/ptp/impl/GeoLocation.java deleted file mode 100644 index 1838c33c7..000000000 --- a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/ptp/impl/GeoLocation.java +++ /dev/null @@ -1,48 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START======================================================================== - * ONAP : ccsdk feature sdnr wt - * ================================================================================================= - * Copyright (C) 2019 highstreet technologies GmbH 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.onap.ccsdk.features.sdnr.wt.devicemanager.ptp.impl; - -/** - * Path list with logical-termination-point list - "path" : [{ - "path-id": "4d778388-41c8-11e7-a919-92ebcb67fe33", - "path-name": "NE-10-ClockIdentity", - "layer-protocol-name": "PTP", - "directionality": "unidirectional", - "logical-termination-point": [{ - "ltp-reference":"yep", - "physical-port-reference": "shelf:1-slot:1-Card-port:5", - "node-reference":"NE-10", - "site-reference": "site-a", - "site-name": "GUI-Label", - "geo-location": { - "longitude": "54.123456", - "latitude": "13.123456" - }] - }] - - * @author herbert - */ - -public class GeoLocation { - String longitude; - String latitude; -} diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/ptp/impl/LogicalTerminationPoint.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/ptp/impl/LogicalTerminationPoint.java deleted file mode 100644 index 6efd3f90c..000000000 --- a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/ptp/impl/LogicalTerminationPoint.java +++ /dev/null @@ -1,55 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START======================================================================== - * ONAP : ccsdk feature sdnr wt - * ================================================================================================= - * Copyright (C) 2019 highstreet technologies GmbH 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.onap.ccsdk.features.sdnr.wt.devicemanager.ptp.impl; - -/** - * Path list with logical-termination-point list - "path" : [{ - "path-id": "4d778388-41c8-11e7-a919-92ebcb67fe33", - "path-name": "NE-10-ClockIdentity", - "layer-protocol-name": "PTP", - "directionality": "unidirectional", - "logical-termination-point": [{ - "ltp-reference":"yep", - "physical-port-reference": "shelf:1-slot:1-Card-port:5", - "node-reference":"NE-10", - "site-reference": "site-a", - "site-name": "GUI-Label", - "geo-location": { - "longitude": "54.123456", - "latitude": "13.123456" - }] - }] - - - * @author herbert - * - */ -public class LogicalTerminationPoint { - - String ltpReference; - String physicalPortReference; - String nodeReference; - String siteReference; - String siteName; - GeoLocation geoLocation; - -} diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/ptp/impl/Path.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/ptp/impl/Path.java deleted file mode 100644 index 60a236d14..000000000 --- a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/ptp/impl/Path.java +++ /dev/null @@ -1,54 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START======================================================================== - * ONAP : ccsdk feature sdnr wt - * ================================================================================================= - * Copyright (C) 2019 highstreet technologies GmbH 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.onap.ccsdk.features.sdnr.wt.devicemanager.ptp.impl; - -import java.util.List; - -/** - * Path list with logical-termination-point list - "path" : [{ - "path-id": "4d778388-41c8-11e7-a919-92ebcb67fe33", - "path-name": "NE-10-ClockIdentity", - "layer-protocol-name": "PTP", - "directionality": "unidirectional", - "logical-termination-point": [{ - "ltp-reference":"yep", - "physical-port-reference": "shelf:1-slot:1-Card-port:5", - "node-reference":"NE-10", - "site-reference": "site-a", - "site-name": "GUI-Label", - "geo-location": { - "longitude": "54.123456", - "latitude": "13.123456" - }] - }] - * @author herbert - * - */ -public class Path { - - String pathId; - String pathName; - String layperProtocolName; - String directionality; - List<LogicalTerminationPoint> logicalTerminationPoints; - -} diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/ptp/impl/PtpManagerImpl.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/ptp/impl/PtpManagerImpl.java deleted file mode 100644 index 3bb16938e..000000000 --- a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/ptp/impl/PtpManagerImpl.java +++ /dev/null @@ -1,29 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START======================================================================== - * ONAP : ccsdk feature sdnr wt - * ================================================================================================= - * Copyright (C) 2019 highstreet technologies GmbH 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.onap.ccsdk.features.sdnr.wt.devicemanager.ptp.impl; - -/** - * @author herbert - * - */ -public class PtpManagerImpl { - -} |