diff --git a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/HtAssert.java b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/HtAssert.java
index 0998e30..1ece241 100644
--- a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/HtAssert.java
+++ b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/HtAssert.java
@@ -22,9 +22,14 @@
 package org.onap.ccsdk.features.sdnr.wt.common;
 
 import java.util.Arrays;
-
+/**
+ * 
+ * @author Michael Dürre
+ *
+ */
 public class HtAssert {
 
+	
 	public static class HtNullable<T> {
 	}
 
diff --git a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/Resources.java b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/Resources.java
index 1ed74a1..2aee0f8 100644
--- a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/Resources.java
+++ b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/Resources.java
@@ -31,66 +31,76 @@
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+/**
+ * 
+ * @author Michael Dürre
+ *
+ * class to get access to internal jar resources
+ */
 public class Resources {
 
-    private static final Logger LOG = LoggerFactory.getLogger(Resources.class);
+	// constants
+	private static final Logger LOG = LoggerFactory.getLogger(Resources.class);
+	// end of constants
 
-    private static URL getFileURL(Class<?> cls,String resFile) {
-        Bundle b = FrameworkUtil.getBundle(cls);
-        URL u = null;
-        LOG.debug("try to get file {}", resFile);
-        if (b == null) {
-            LOG.info("Load resource as file: {}", resFile);
-            u = getUrlForRessource(cls,resFile);
-        } else {
-            LOG.info("Load resource from bundle: {}", resFile);
-            u = b.getEntry(resFile);
-        }
-        return u;
-    }
+	// static methods
+	private static URL getFileURL(Class<?> cls, String resFile) {
+		Bundle b = FrameworkUtil.getBundle(cls);
+		URL u = null;
+		LOG.debug("try to get file {}", resFile);
+		if (b == null) {
+			LOG.info("Load resource as file: {}", resFile);
+			u = getUrlForRessource(cls, resFile);
+		} else {
+			LOG.info("Load resource from bundle: {}", resFile);
+			u = b.getEntry(resFile);
+		}
+		return u;
+	}
 
-    private static String readFile(final URL u) throws IOException {
-        return readFile(u.openStream());
-    }
+	private static String readFile(final URL u) throws IOException {
+		return readFile(u.openStream());
+	}
 
-    private static String readFile(final InputStream s) throws IOException {
-        // read file
-        final String LR = "\n";
-        BufferedReader in = new BufferedReader(new InputStreamReader(s));
-        StringBuilder sb = new StringBuilder();
-        String inputLine;
-        while ((inputLine = in.readLine()) != null) {
-            sb.append(inputLine+LR);
-        }
-        in.close();
-        s.close();
-        return sb.toString();
-    }
+	private static String readFile(final InputStream s) throws IOException {
+		// read file
+		final String LR = "\n";
+		BufferedReader in = new BufferedReader(new InputStreamReader(s));
+		StringBuilder sb = new StringBuilder();
+		String inputLine;
+		while ((inputLine = in.readLine()) != null) {
+			sb.append(inputLine + LR);
+		}
+		in.close();
+		s.close();
+		return sb.toString();
+	}
 
-    public static String getFileContent( Class<?> cls, String resFile) {
-         LOG.debug("loading file {} from res", resFile);
-         URL u = getFileURL(cls,resFile);
-         String s=null;
-         if (u == null) {
-             LOG.warn("cannot find resfile: {}", resFile);
-             return null;
-         }
-         try {
-             s=readFile(u);
-         } catch (Exception e) {
-             LOG.warn("problem reading file: {}", e.getMessage());
-         }
-         return s;
+	public static String getFileContent(Class<?> cls, String resFile) {
+		LOG.debug("loading file {} from res", resFile);
+		URL u = getFileURL(cls, resFile);
+		String s = null;
+		if (u == null) {
+			LOG.warn("cannot find resfile: {}", resFile);
+			return null;
+		}
+		try {
+			s = readFile(u);
+		} catch (Exception e) {
+			LOG.warn("problem reading file: {}", e.getMessage());
+		}
+		return s;
 
-    }
+	}
 
-    public static URL getUrlForRessource(Class<?> cls,String fileOrDirectory) {
-        //ClassLoader loader = Thread.currentThread().getContextClassLoader();
-        ClassLoader loader = cls.getClassLoader();
-        URL url = loader.getResource(fileOrDirectory);
-        if(url==null && fileOrDirectory.startsWith("/")) {
-            url = loader.getResource(fileOrDirectory.substring(1));
-        }
-        return url;
-    }
+	public static URL getUrlForRessource(Class<?> cls, String fileOrDirectory) {
+		//ClassLoader loader = Thread.currentThread().getContextClassLoader();
+		ClassLoader loader = cls.getClassLoader();
+		URL url = loader.getResource(fileOrDirectory);
+		if (url == null && fileOrDirectory.startsWith("/")) {
+			url = loader.getResource(fileOrDirectory.substring(1));
+		}
+		return url;
+	}
+	// end of static methods
 }
diff --git a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/configuration/ConfigurationFileRepresentation.java b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/configuration/ConfigurationFileRepresentation.java
index 0a432cb..18a69f0 100644
--- a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/configuration/ConfigurationFileRepresentation.java
+++ b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/configuration/ConfigurationFileRepresentation.java
@@ -43,20 +43,25 @@
  */
 public class ConfigurationFileRepresentation implements IConfigChangedListener {
 
+	// constants
 	private static final Logger LOG = LoggerFactory.getLogger(ConfigurationFileRepresentation.class);
 
 	private static final long FILE_POLL_INTERVAL_MS = 1000;
 	private static final String SECTIONNAME_ROOT = "";
 	private static final String LR = "\n";
 	private static final String EMPTY = "";
+	// end of constants
 
+	// variables
 	/** Related configuration file **/
 	private final File mFile;
 	/** Monitor changes of file **/
 	private final ConfigFileObserver fileObserver;
 	/** List of sections **/
 	private final HashMap<String, Section> sections;
+	// end of variables
 
+	// constructors
 	public ConfigurationFileRepresentation(File f) {
 
 		this.mFile = f;
@@ -80,11 +85,67 @@
 	public ConfigurationFileRepresentation(String configurationfile) {
 		this(new File(configurationfile));
 	}
+	// end of constructors
 
+	// getters and setters
 	public synchronized Optional<Section> getSection(String name) {
 		return Optional.ofNullable(sections.get(name));
 	}
+	// end of getters and setters
 
+	// private methods
+	private synchronized void reLoad() {
+		sections.clear();
+		addSection(SECTIONNAME_ROOT);
+		load();
+	}
+
+	private synchronized void load() {
+		LOG.debug("loading file {}", getMFileName());
+		String curSectionName = SECTIONNAME_ROOT;
+		Optional<Section> sectionOptional = this.getSection(curSectionName);
+		Section curSection = sectionOptional.isPresent() ? sectionOptional.get() : this.addSection(curSectionName);
+		BufferedReader br = null;
+		try {
+			br = new BufferedReader(new FileReader(this.mFile));
+			for (String line; (line = br.readLine()) != null;) {
+				line = line.trim();
+				if (line.isEmpty()) {
+					continue;
+				}
+				if (line.startsWith("[") && line.endsWith("]")) {
+					curSectionName = line.substring(1, line.length() - 1);
+					curSection = this.addSection(curSectionName);
+				} else {
+					curSection.addLine(line);
+				}
+			}
+
+		} catch (Exception e) {
+			LOG.info("Problem loading configuration file. {} {}", getMFileName(), e);
+		} finally {
+			try {
+				if (br != null) {
+					br.close();
+				}
+			} catch (IOException e) {
+			}
+		}
+		LOG.debug("finished loading file");
+		LOG.debug("start parsing sections");
+		for (Section section : this.sections.values()) {
+			section.parseLines();
+		}
+		LOG.debug("finished parsing " + this.sections.size() + " sections");
+	}
+
+	private String getMFileName() {
+		return mFile.getAbsolutePath();
+	}
+
+	// end of private methods
+
+	// public methods
 	public synchronized Section addSection(String name) {
 		if (this.sections.containsKey(name)) {
 			return this.sections.get(name);
@@ -94,12 +155,6 @@
 		return s;
 	}
 
-	private synchronized void reLoad() {
-		sections.clear();
-		addSection(SECTIONNAME_ROOT);
-		load();
-	}
-
 	public synchronized void save() {
 		LOG.debug("Write configuration to {}", getMFileName());
 		try (BufferedWriter bw = new BufferedWriter(new FileWriter(this.mFile, false))) {
@@ -188,50 +243,6 @@
 	public synchronized boolean getPropertyBoolean(String section, String propertyKey) {
 		return getProperty(section, propertyKey).equalsIgnoreCase("true");
 	}
+	// end of public methods
 
-	/*
-	 * Private
-	 */
-	private synchronized void load() {
-		LOG.debug("loading file {}", getMFileName());
-		String curSectionName = SECTIONNAME_ROOT;
-		Optional<Section> sectionOptional = this.getSection(curSectionName);
-		Section curSection = sectionOptional.isPresent() ? sectionOptional.get() : this.addSection(curSectionName);
-		BufferedReader br = null;
-		try {
-			br = new BufferedReader(new FileReader(this.mFile));
-			for (String line; (line = br.readLine()) != null;) {
-				line = line.trim();
-				if (line.isEmpty()) {
-					continue;
-				}
-				if (line.startsWith("[") && line.endsWith("]")) {
-					curSectionName = line.substring(1, line.length() - 1);
-					curSection = this.addSection(curSectionName);
-				} else {
-					curSection.addLine(line);
-				}
-			}
-
-		} catch (Exception e) {
-			LOG.info("Problem loading configuration file. {} {}", getMFileName(), e);
-		} finally {
-			try {
-				if (br != null) {
-					br.close();
-				}
-			} catch (IOException e) {
-			}
-		}
-		LOG.debug("finished loading file");
-		LOG.debug("start parsing sections");
-		for (Section section : this.sections.values()) {
-			section.parseLines();
-		}
-		LOG.debug("finished parsing " + this.sections.size() + " sections");
-	}
-
-	private String getMFileName() {
-		return mFile.getAbsolutePath();
-	}
 }
diff --git a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/configuration/subtypes/Section.java b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/configuration/subtypes/Section.java
index fd1e404..b6d277f 100644
--- a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/configuration/subtypes/Section.java
+++ b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/configuration/subtypes/Section.java
@@ -32,24 +32,53 @@
 import org.onap.ccsdk.features.sdnr.wt.common.configuration.exception.ConversionException;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
-
+/**
+ * 
+ * @author Michael Dürre, Herbert Eiselt
+ *
+ * subset of configuration identified by its name
+ */
 public class Section {
 
+	// constants
     private static final Logger LOG = LoggerFactory.getLogger(Section.class);
     private static final String DELIMITER = "=";
     private static final String COMMENTCHARS[] = {"#", ";"};
-
+    // end of constants
+    
+    // variables
     private final String name;
     private final List<String> rawLines;
     private final LinkedHashMap<String, SectionValue> values;
-
+    // end of variables
+    
+    // constructors
     public Section(String name) {
         LOG.debug("new section created: '{}'", name);
         this.name = name;
         this.rawLines = new ArrayList<>();
         this.values = new LinkedHashMap<>();
     }
+    //end of constructors
+    
+    // getters and setters
+    public String getName() {
+        return name;
+    }
+    // end of getters and setters
 
+    // private methods
+    private boolean isCommentLine(String line) {
+        for (String c : COMMENTCHARS) {
+            if (line.startsWith(c)) {
+                return true;
+            }
+        }
+        return false;
+    }
+    // end of private methods
+    
+    // public methods
     public void addLine(String line) {
         LOG.trace("adding raw line:" + line);
         this.rawLines.add(line);
@@ -90,9 +119,7 @@
 		return value;
 	}
 
-    public String getName() {
-        return name;
-    }
+    
 
     public void setProperty(String key, String value) {
         boolean isuncommented = this.isCommentLine(key);
@@ -143,14 +170,7 @@
         }
     }
 
-    private boolean isCommentLine(String line) {
-        for (String c : COMMENTCHARS) {
-            if (line.startsWith(c)) {
-                return true;
-            }
-        }
-        return false;
-    }
+    
 
     public String[] toLines() {
         List<String> lines = new ArrayList<>();
@@ -222,5 +242,6 @@
     public String toString() {
         return "Section [name=" + name + ", rawLines=" + rawLines + ", values=" + values + "]";
     }
+    // end of public methods
 
 }
diff --git a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/configuration/subtypes/SectionValue.java b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/configuration/subtypes/SectionValue.java
index 5e3b533..3aacf9a 100644
--- a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/configuration/subtypes/SectionValue.java
+++ b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/configuration/subtypes/SectionValue.java
@@ -23,13 +23,20 @@
 
 import java.util.ArrayList;
 import java.util.List;
-
+/**
+ * 
+ * @author Michael Dürre, Herbert Eiselt
+ *
+ */
 class SectionValue {
 
+	// variables
     private String value;
     private final List<String> comments;
     private boolean isUncommented;
+    // end of variables    
 
+    // constructors
     public SectionValue(String value, List<String> commentsForValue, boolean isuncommented) {
         this.comments = commentsForValue;
         this.value = value;
@@ -43,9 +50,9 @@
     public SectionValue(String value, boolean isUncommented) {
     	this(value, new ArrayList<String>(), isUncommented);
 	}
-
-    /* Getter / Setter */
-
+    // end of constructors
+    
+    // getters and setters
 	public String getValue() {
 		return value;
 	}
@@ -67,11 +74,14 @@
 	public List<String> getComments() {
 		return comments;
 	}
-
+	// end of getters and setters
+	
+	// public methods
 	@Override
 	public String toString() {
 		return "SectionValue [value=" + value + ", comments=" + comments + ", isUncommented=" + isUncommented + "]";
 	}
+	// end of public methods
 
 
 }
diff --git a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/ExtRestClient.java b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/ExtRestClient.java
index c10c4a6..70b8199 100644
--- a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/ExtRestClient.java
+++ b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/ExtRestClient.java
@@ -30,20 +30,19 @@
 import java.security.spec.InvalidKeySpecException;
 import java.text.ParseException;
 
-import javax.net.ssl.SSLContext;
+import javax.net.ssl.HostnameVerifier;
+import javax.net.ssl.SSLSession;
 
 import org.apache.http.HttpHost;
 import org.apache.http.auth.AuthScope;
 import org.apache.http.auth.UsernamePasswordCredentials;
 import org.apache.http.client.CredentialsProvider;
-import org.apache.http.client.config.RequestConfig.Builder;
 import org.apache.http.impl.client.BasicCredentialsProvider;
 import org.apache.http.impl.nio.client.HttpAsyncClientBuilder;
 import org.elasticsearch.client.Response;
 import org.elasticsearch.client.ResponseException;
 import org.elasticsearch.client.RestClient;
 import org.elasticsearch.client.RestClientBuilder.HttpClientConfigCallback;
-import org.elasticsearch.client.RestClientBuilder.RequestConfigCallback;
 import org.json.JSONException;
 import org.onap.ccsdk.features.sdnr.wt.common.database.config.HostInfo;
 import org.onap.ccsdk.features.sdnr.wt.common.database.config.HostInfo.Protocol;
@@ -66,7 +65,6 @@
 import org.onap.ccsdk.features.sdnr.wt.common.database.requests.SearchRequest;
 import org.onap.ccsdk.features.sdnr.wt.common.database.requests.UpdateByQueryRequest;
 import org.onap.ccsdk.features.sdnr.wt.common.database.requests.UpdateRequest;
-import org.onap.ccsdk.features.sdnr.wt.common.database.responses.AcknowledgedResponse;
 import org.onap.ccsdk.features.sdnr.wt.common.database.responses.ClusterHealthResponse;
 import org.onap.ccsdk.features.sdnr.wt.common.database.responses.ClusterSettingsResponse;
 import org.onap.ccsdk.features.sdnr.wt.common.database.responses.CreateAliasResponse;
@@ -91,272 +89,281 @@
 
 public class ExtRestClient {
 
-	private static final Logger LOG = LoggerFactory.getLogger(ExtRestClient.class);
+    private static final Logger LOG = LoggerFactory.getLogger(ExtRestClient.class);
 
-	private class BasicAuthHttpClientConfigCallback implements HttpClientConfigCallback {
+    private class BasicAuthHttpClientConfigCallback implements HttpClientConfigCallback {
 
-		private final String basicAuthUsername;
-		private final String basicAuthPassword;
-		private final boolean trustAll;
+        private final String basicAuthUsername;
+        private final String basicAuthPassword;
+        private final boolean trustAll;
 
-		BasicAuthHttpClientConfigCallback(String username, String password, boolean trustAll) {
-			this.basicAuthUsername = username;
-			this.basicAuthPassword = password;
-			this.trustAll = trustAll;
-		}
+        BasicAuthHttpClientConfigCallback(String username, String password, boolean trustAll) {
+            this.basicAuthUsername = username;
+            this.basicAuthPassword = password;
+            this.trustAll = trustAll;
+        }
 
-		@Override
-		public HttpAsyncClientBuilder customizeHttpClient(HttpAsyncClientBuilder httpClientBuilder) {
-			HttpAsyncClientBuilder httpAsyncClientBuilder = null;
-			try {
-				httpAsyncClientBuilder = httpClientBuilder.setSSLContext(BaseHTTPClient.setupSsl(this.trustAll));
-			} catch (NoSuchAlgorithmException | KeyManagementException | UnrecoverableKeyException | CertificateException | KeyStoreException | InvalidKeySpecException | IOException e) {
-				LOG.warn("unable to init ssl context for db client: {}",e.getMessage());
-			}
-			if (basicAuthPassword == null || basicAuthUsername == null) {
-				return httpAsyncClientBuilder;
-			}
-			final CredentialsProvider credentialsProvider = new BasicCredentialsProvider();
-			credentialsProvider.setCredentials(AuthScope.ANY,
-					new UsernamePasswordCredentials(basicAuthUsername, basicAuthPassword));
+        @Override
+        public HttpAsyncClientBuilder customizeHttpClient(HttpAsyncClientBuilder httpClientBuilder) {
+            HttpAsyncClientBuilder httpAsyncClientBuilder = null;
+            try {
+                httpAsyncClientBuilder = httpClientBuilder.setSSLContext(BaseHTTPClient.setupSsl(this.trustAll));
+                if(this.trustAll) {
+	                httpAsyncClientBuilder.setSSLHostnameVerifier(new HostnameVerifier() {
+						
+						@Override
+						public boolean verify(String hostname, SSLSession session) {
+							return true;
+						}
+					});
+                }
+            } catch (NoSuchAlgorithmException | KeyManagementException | UnrecoverableKeyException | CertificateException | KeyStoreException | InvalidKeySpecException | IOException e) {
+                LOG.warn("unable to init ssl context for db client: {}",e.getMessage());
+            }
+            if (basicAuthPassword == null || basicAuthUsername == null) {
+                return httpAsyncClientBuilder;
+            }
+            final CredentialsProvider credentialsProvider = new BasicCredentialsProvider();
+            credentialsProvider.setCredentials(AuthScope.ANY,
+                    new UsernamePasswordCredentials(basicAuthUsername, basicAuthPassword));
 
-			return httpAsyncClientBuilder == null ? httpClientBuilder.setDefaultCredentialsProvider(credentialsProvider)
-					: httpAsyncClientBuilder.setDefaultCredentialsProvider(credentialsProvider);
-		}
+            return httpAsyncClientBuilder == null ? httpClientBuilder.setDefaultCredentialsProvider(credentialsProvider)
+                    : httpAsyncClientBuilder.setDefaultCredentialsProvider(credentialsProvider);
+        }
 
-	}
-	//    private class SSLCercAuthHttpClientConfigCallback implements HttpClientConfigCallback {
-	//
-	//        private final String certFilename;
-	//
-	//        SSLCercAuthHttpClientConfigCallback(String certfile) {
-	//            this.certFilename = certfile;
-	//        }
-	//
-	//        @Override
-	//        public HttpAsyncClientBuilder customizeHttpClient(HttpAsyncClientBuilder httpClientBuilder) {
-	//            if (this.certFilename == null) {
-	//                return httpClientBuilder;
-	//            }
-	//
-	//            char[] keystorePass = "MY PASSWORD".toCharArray();
-	//
-	//            FileInputStream fis = null;
-	//
-	//            // Loading KEYSTORE in JKS format
-	//            KeyStore keyStorePci = null;
-	//            try {
-	//                keyStorePci = KeyStore.getInstance(KeyStore.getDefaultType());
-	//            } catch (KeyStoreException e1) {
-	//                LOG.warn("unable to load keystore: {}",e1);
-	//            }
-	//            if (keyStorePci != null) {
-	//                try {
-	//                    fis = new FileInputStream(this.certFilename);
-	//                    keyStorePci.load(fis, keystorePass);
-	//                } catch (Exception e) {
-	//                    LOG.error("Error loading keystore: " + this.certFilename);
-	//                } finally {
-	//                    if (fis != null) {
-	//                        try {
-	//                            fis.close();
-	//                        } catch (IOException e) {
-	//
-	//                        }
-	//                    }
-	//                }
-	//            }
-	//            SSLContext sslcontext=null;
-	//            try {
-	//                sslcontext = SSLContexts.custom().loadKeyMaterial(keyStorePci, keystorePass).build();
-	//            } catch (KeyManagementException | UnrecoverableKeyException | NoSuchAlgorithmException
-	//                    | KeyStoreException e) {
-	//                LOG.warn("unable to load sslcontext: {}",e);
-	//            }
-	//            return httpClientBuilder.setSSLContext(sslcontext);
-	//        }
-	//    }
+    }
+    //    private class SSLCercAuthHttpClientConfigCallback implements HttpClientConfigCallback {
+    //
+    //        private final String certFilename;
+    //
+    //        SSLCercAuthHttpClientConfigCallback(String certfile) {
+    //            this.certFilename = certfile;
+    //        }
+    //
+    //        @Override
+    //        public HttpAsyncClientBuilder customizeHttpClient(HttpAsyncClientBuilder httpClientBuilder) {
+    //            if (this.certFilename == null) {
+    //                return httpClientBuilder;
+    //            }
+    //
+    //            char[] keystorePass = "MY PASSWORD".toCharArray();
+    //
+    //            FileInputStream fis = null;
+    //
+    //            // Loading KEYSTORE in JKS format
+    //            KeyStore keyStorePci = null;
+    //            try {
+    //                keyStorePci = KeyStore.getInstance(KeyStore.getDefaultType());
+    //            } catch (KeyStoreException e1) {
+    //                LOG.warn("unable to load keystore: {}",e1);
+    //            }
+    //            if (keyStorePci != null) {
+    //                try {
+    //                    fis = new FileInputStream(this.certFilename);
+    //                    keyStorePci.load(fis, keystorePass);
+    //                } catch (Exception e) {
+    //                    LOG.error("Error loading keystore: " + this.certFilename);
+    //                } finally {
+    //                    if (fis != null) {
+    //                        try {
+    //                            fis.close();
+    //                        } catch (IOException e) {
+    //
+    //                        }
+    //                    }
+    //                }
+    //            }
+    //            SSLContext sslcontext=null;
+    //            try {
+    //                sslcontext = SSLContexts.custom().loadKeyMaterial(keyStorePci, keystorePass).build();
+    //            } catch (KeyManagementException | UnrecoverableKeyException | NoSuchAlgorithmException
+    //                    | KeyStoreException e) {
+    //                LOG.warn("unable to load sslcontext: {}",e);
+    //            }
+    //            return httpClientBuilder.setSSLContext(sslcontext);
+    //        }
+    //    }
 
-	private final RestClient client;
+    private final RestClient client;
 
-	protected ExtRestClient(HostInfo[] hosts) {
-		this(hosts, null, null,false);
-	}
+    protected ExtRestClient(HostInfo[] hosts) {
+        this(hosts, null, null,false);
+    }
 
-	protected ExtRestClient(HostInfo[] hosts, String username, String password, boolean trustAll) {
-		this.client = RestClient.builder(get(hosts))
-				.setHttpClientConfigCallback(new BasicAuthHttpClientConfigCallback(username, password,trustAll))
-				.build();
-	}
+    protected ExtRestClient(HostInfo[] hosts, String username, String password, boolean trustAll) {
+        this.client = RestClient.builder(get(hosts))
+                .setHttpClientConfigCallback(new BasicAuthHttpClientConfigCallback(username, password,trustAll))
+                .build();
+    }
 
-	public ClusterHealthResponse health(ClusterHealthRequest request)
-			throws UnsupportedOperationException, IOException, JSONException {
-		return new ClusterHealthResponse(this.client.performRequest(request.getInner()));
-	}
+    public ClusterHealthResponse health(ClusterHealthRequest request)
+            throws UnsupportedOperationException, IOException, JSONException {
+        return new ClusterHealthResponse(this.client.performRequest(request.getInner()));
+    }
 
-	public void close() throws IOException {
-		this.client.close();
+    public void close() throws IOException {
+        this.client.close();
 
-	}
+    }
 
-	//
-	public boolean indicesExists(GetIndexRequest request) throws IOException {
-		Response response = this.client.performRequest(request.getInner());
-		return response.getStatusLine().getStatusCode() == 200;
-	}
+    //
+    public boolean indicesExists(GetIndexRequest request) throws IOException {
+        Response response = this.client.performRequest(request.getInner());
+        return response.getStatusLine().getStatusCode() == 200;
+    }
 
-	public ClusterSettingsResponse setupClusterSettings(ClusterSettingsRequest request) throws IOException {
-		return new ClusterSettingsResponse(this.client.performRequest(request.getInner()));
-	}
-	public CreateAliasResponse updateAliases(CreateAliasRequest request) throws IOException {
-		return new CreateAliasResponse(this.client.performRequest(request.getInner()));
-	}
+    public ClusterSettingsResponse setupClusterSettings(ClusterSettingsRequest request) throws IOException {
+        return new ClusterSettingsResponse(this.client.performRequest(request.getInner()));
+    }
+    public CreateAliasResponse updateAliases(CreateAliasRequest request) throws IOException {
+        return new CreateAliasResponse(this.client.performRequest(request.getInner()));
+    }
 
-	public CreateIndexResponse createIndex(CreateIndexRequest request) throws IOException {
-		return new CreateIndexResponse(this.client.performRequest(request.getInner()));
-	}
+    public CreateIndexResponse createIndex(CreateIndexRequest request) throws IOException {
+        return new CreateIndexResponse(this.client.performRequest(request.getInner()));
+    }
 
-	public CreateAliasResponse createAlias(CreateAliasRequest request) throws IOException {
-		return new CreateAliasResponse(this.client.performRequest(request.getInner()));
-	}
+    public CreateAliasResponse createAlias(CreateAliasRequest request) throws IOException {
+        return new CreateAliasResponse(this.client.performRequest(request.getInner()));
+    }
 
-	public DeleteAliasResponse deleteAlias(DeleteAliasRequest request) throws IOException {
-		return new DeleteAliasResponse(this.client.performRequest(request.getInner()));
-	}
+    public DeleteAliasResponse deleteAlias(DeleteAliasRequest request) throws IOException {
+        return new DeleteAliasResponse(this.client.performRequest(request.getInner()));
+    }
 
-	public DeleteIndexResponse deleteIndex(DeleteIndexRequest request) throws IOException {
-		return new DeleteIndexResponse(this.client.performRequest(request.getInner()));
-	}
+    public DeleteIndexResponse deleteIndex(DeleteIndexRequest request) throws IOException {
+        return new DeleteIndexResponse(this.client.performRequest(request.getInner()));
+    }
 
-	public IndexResponse index(IndexRequest request) throws IOException {
-		return new IndexResponse(this.client.performRequest(request.getInner()));
-	}
+    public IndexResponse index(IndexRequest request) throws IOException {
+        return new IndexResponse(this.client.performRequest(request.getInner()));
+    }
 
-	public DeleteResponse delete(DeleteRequest request) throws IOException {
-		Response response = null;
-		try {
-			response = this.client.performRequest(request.getInner());
-		} catch (ResponseException e) {
-			new DeleteResponse(e.getResponse());
-		}
-		return new DeleteResponse(response);
-	}
+    public DeleteResponse delete(DeleteRequest request) throws IOException {
+        Response response = null;
+        try {
+            response = this.client.performRequest(request.getInner());
+        } catch (ResponseException e) {
+            new DeleteResponse(e.getResponse());
+        }
+        return new DeleteResponse(response);
+    }
 
-	public DeleteByQueryResponse deleteByQuery(DeleteByQueryRequest request) throws IOException {
-		Response response = null;
-		try {
-			response = this.client.performRequest(request.getInner());
-		} catch (ResponseException e) {
-			new DeleteResponse(e.getResponse());
-		}
-		return new DeleteByQueryResponse(response);
-	}
+    public DeleteByQueryResponse deleteByQuery(DeleteByQueryRequest request) throws IOException {
+        Response response = null;
+        try {
+            response = this.client.performRequest(request.getInner());
+        } catch (ResponseException e) {
+            new DeleteResponse(e.getResponse());
+        }
+        return new DeleteByQueryResponse(response);
+    }
 
-	public SearchResponse search(SearchRequest request) throws IOException {
-		return this.search(request, false);
-	}
+    public SearchResponse search(SearchRequest request) throws IOException {
+        return this.search(request, false);
+    }
 
-	/**
-	 * Search for database entries
-	 * @param request inputRequest
-	 * @param ignoreParseException especially for usercreated filters which may cause ES server response exceptions
-	 * @return Response with related entries
-	 * @throws IOException of client
-	 */
-	public SearchResponse search(SearchRequest request, boolean ignoreParseException) throws IOException {
-		if (ignoreParseException) {
-			try {
-				return new SearchResponse(this.client.performRequest(request.getInner()));
-			} catch (ResponseException e) {
-				LOG.debug("ignoring Exception for request {}: {}", request, e.getMessage());
-				return new SearchResponse(e.getResponse());
-			}
-		} else {
-			return new SearchResponse(this.client.performRequest(request.getInner()));
-		}
-	}
+    /**
+     * Search for database entries
+     * @param request inputRequest
+     * @param ignoreParseException especially for usercreated filters which may cause ES server response exceptions
+     * @return Response with related entries
+     * @throws IOException of client
+     */
+    public SearchResponse search(SearchRequest request, boolean ignoreParseException) throws IOException {
+        if (ignoreParseException) {
+            try {
+                return new SearchResponse(this.client.performRequest(request.getInner()));
+            } catch (ResponseException e) {
+                LOG.debug("ignoring Exception for request {}: {}", request, e.getMessage());
+                return new SearchResponse(e.getResponse());
+            }
+        } else {
+            return new SearchResponse(this.client.performRequest(request.getInner()));
+        }
+    }
 
-	public GetResponse get(GetRequest request) throws IOException {
-		try {
-			return new GetResponse(this.client.performRequest(request.getInner()));
-		} catch (ResponseException e) {
-			return new GetResponse(e.getResponse());
-		}
-	}
+    public GetResponse get(GetRequest request) throws IOException {
+        try {
+            return new GetResponse(this.client.performRequest(request.getInner()));
+        } catch (ResponseException e) {
+            return new GetResponse(e.getResponse());
+        }
+    }
 
-	public UpdateByQueryResponse update(UpdateByQueryRequest request) throws IOException {
-		return new UpdateByQueryResponse(this.client.performRequest(request.getInner()));
+    public UpdateByQueryResponse update(UpdateByQueryRequest request) throws IOException {
+        return new UpdateByQueryResponse(this.client.performRequest(request.getInner()));
 
-	}
+    }
 
-	public UpdateResponse update(UpdateRequest request) throws IOException {
-		return new UpdateResponse(this.client.performRequest(request.getInner()));
+    public UpdateResponse update(UpdateRequest request) throws IOException {
+        return new UpdateResponse(this.client.performRequest(request.getInner()));
 
-	}
+    }
 
-	public RefreshIndexResponse refreshIndex(RefreshIndexRequest request) throws IOException {
-		return new RefreshIndexResponse(this.client.performRequest(request.getInner()));
-	}
+    public RefreshIndexResponse refreshIndex(RefreshIndexRequest request) throws IOException {
+        return new RefreshIndexResponse(this.client.performRequest(request.getInner()));
+    }
 
-	public NodeStatsResponse stats(NodeStatsRequest request) throws IOException {
-		return new NodeStatsResponse(this.client.performRequest(request.getInner()));
-	}
+    public NodeStatsResponse stats(NodeStatsRequest request) throws IOException {
+        return new NodeStatsResponse(this.client.performRequest(request.getInner()));
+    }
 
-	public ListIndicesResponse getIndices() throws ParseException, IOException {
-		return new ListIndicesResponse(this.client.performRequest(new ListIndicesRequest().getInner()));
-	}
+    public ListIndicesResponse getIndices() throws ParseException, IOException {
+        return new ListIndicesResponse(this.client.performRequest(new ListIndicesRequest().getInner()));
+    }
 
-	public ListAliasesResponse getAliases() throws ParseException, IOException {
-		return new ListAliasesResponse(this.client.performRequest(new ListAliasesRequest().getInner()));
-	}
+    public ListAliasesResponse getAliases() throws ParseException, IOException {
+        return new ListAliasesResponse(this.client.performRequest(new ListAliasesRequest().getInner()));
+    }
 
-	public GetInfoResponse getInfo() throws IOException, Exception {
-		return new GetInfoResponse(this.client.performRequest(new GetInfoRequest().getInner()));
-	}
+    public GetInfoResponse getInfo() throws IOException, Exception {
+        return new GetInfoResponse(this.client.performRequest(new GetInfoRequest().getInner()));
+    }
 
-	public boolean waitForYellowStatus(long timeoutms) {
+    public boolean waitForYellowStatus(long timeoutms) {
 
-		ClusterHealthRequest request = new ClusterHealthRequest();
-		request.timeout(timeoutms / 1000);
-		ClusterHealthResponse response = null;
-		String status = "";
-		try {
-			response = this.health(request);
+        ClusterHealthRequest request = new ClusterHealthRequest();
+        request.timeout(timeoutms / 1000);
+        ClusterHealthResponse response = null;
+        String status = "";
+        try {
+            response = this.health(request);
 
-		} catch (UnsupportedOperationException | IOException | JSONException e) {
-			LOG.error(e.getMessage());
-		}
-		if (response != null) {
-			status = response.getStatus();
-			LOG.debug("Elasticsearch service started with status {}", response.getStatus());
+        } catch (UnsupportedOperationException | IOException | JSONException e) {
+            LOG.error("Exception", e);
+        }
+        if (response != null) {
+            status = response.getStatus();
+            LOG.debug("Elasticsearch service started with status {}", response.getStatus());
 
-		} else {
-			LOG.warn("Elasticsearch service not started yet with status {}. current status is {}", status, "none");
-			return false;
-		}
-		return response.isStatusMinimal(ClusterHealthResponse.HEALTHSTATUS_YELLOW);
+        } else {
+            LOG.warn("Elasticsearch service not started yet with status {}. current status is {}", status, "none");
+            return false;
+        }
+        return response.isStatusMinimal(ClusterHealthResponse.HEALTHSTATUS_YELLOW);
 
-	}
+    }
 
-	private static HttpHost[] get(HostInfo[] hosts) {
-		HttpHost[] httphosts = new HttpHost[hosts.length];
-		for (int i = 0; i < hosts.length; i++) {
-			httphosts[i] = new HttpHost(hosts[i].hostname, hosts[i].port, hosts[i].protocol.toString());
-		}
-		return httphosts;
-	}
+    private static HttpHost[] get(HostInfo[] hosts) {
+        HttpHost[] httphosts = new HttpHost[hosts.length];
+        for (int i = 0; i < hosts.length; i++) {
+            httphosts[i] = new HttpHost(hosts[i].hostname, hosts[i].port, hosts[i].protocol.toString());
+        }
+        return httphosts;
+    }
 
-	public static ExtRestClient createInstance(HostInfo[] hosts) {
-		return new ExtRestClient(hosts);
-	}
+    public static ExtRestClient createInstance(HostInfo[] hosts) {
+        return new ExtRestClient(hosts);
+    }
 
-	public static ExtRestClient createInstance(HostInfo[] hosts, String username, String password,boolean trustAll) {
-		return new ExtRestClient(hosts, username, password, trustAll);
-	}
+    public static ExtRestClient createInstance(HostInfo[] hosts, String username, String password,boolean trustAll) {
+        return new ExtRestClient(hosts, username, password, trustAll);
+    }
 
-	public static ExtRestClient createInstance(String hostname, int port, Protocol protocol) {
-		return createInstance(new HostInfo[] { new HostInfo(hostname, port, protocol) });
+    public static ExtRestClient createInstance(String hostname, int port, Protocol protocol) {
+        return createInstance(new HostInfo[] { new HostInfo(hostname, port, protocol) });
 
-	}
+    }
 
 }
diff --git a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/Portstatus.java b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/Portstatus.java
new file mode 100644
index 0000000..ed6c95f
--- /dev/null
+++ b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/Portstatus.java
@@ -0,0 +1,89 @@
+/*******************************************************************************
+ * ============LICENSE_START========================================================================
+ * ONAP : ccsdk feature sdnr wt
+ * =================================================================================================
+ * Copyright (C) Apache Camel project
+ * =================================================================================================
+ * 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.common.database;
+
+import java.io.IOException;
+import java.net.Socket;
+import org.onap.ccsdk.features.sdnr.wt.common.database.config.HostInfo;
+
+public class Portstatus {
+
+    public static final int MIN_PORT_NUMBER = 0;
+    public static final int MAX_PORT_NUMBER = 65535;
+
+    /**
+     * Checks to see if a specific port is available.
+     *
+     * @param port the port to check for availability
+     */
+    public static boolean isAvailable(String dnsName, int port) {
+        if (port < MIN_PORT_NUMBER || port > MAX_PORT_NUMBER) {
+            throw new IllegalArgumentException("Invalid start port: " + port);
+        }
+
+        Socket ss = null;
+        try {
+            ss = new Socket(dnsName, port);
+            ss.setReuseAddress(true);
+            return true;
+        } catch (IOException e) {
+        } finally {
+            if (ss != null) {
+                try {
+                    ss.close();
+                } catch (IOException e) {
+                    /* should not be thrown */
+                }
+            }
+        }
+
+        return false;
+    }
+
+    public static boolean isAvailable(HostInfo... hosts) {
+        for (HostInfo host : hosts) {
+           if (!isAvailable(host.hostname, host.port)) {
+               return false;
+           }
+       }
+       return true;
+    }
+
+    public static boolean waitSecondsTillAvailable(long timeoutSeconds, HostInfo... hosts) {
+
+        if (timeoutSeconds < 0) {
+            throw new IllegalArgumentException("Invalid timeout: " + timeoutSeconds);
+        }
+        long waitSeconds = 0;
+        boolean res = false;
+        while ( (timeoutSeconds == 0 || ++waitSeconds < timeoutSeconds) && !(res = isAvailable(hosts))) {
+            try {
+                Thread.sleep(1000);
+            } catch (InterruptedException e) {
+                Thread.currentThread().interrupt();
+            }
+        }
+        return res;
+    }
+
+    public static boolean waitSecondsTillAvailable(long timeoutSeconds, String dnsName, int port ) {
+        return waitSecondsTillAvailable(timeoutSeconds, new HostInfo(dnsName, port));
+    }
+
+}
diff --git a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/queries/BoolQueryBuilder.java b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/queries/BoolQueryBuilder.java
index d087867..b362c46 100644
--- a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/queries/BoolQueryBuilder.java
+++ b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/queries/BoolQueryBuilder.java
@@ -39,25 +39,51 @@
 		return "BoolQueryBuilder [inner=" + inner + "]";
 	}
 
+	public static boolean isEmpty(JSONObject o) {
+		return o.keySet().size() <= 0;
+	}
+
 	public BoolQueryBuilder must(QueryBuilder query) {
-		
-		if(this.inner.has("must") || this.inner.has("match") || this.inner.has("regexp") || this.inner.has("range")) {
-			Object x = this.inner.has("must") ?this.inner.get("must"):this.inner;
-			if(x instanceof JSONArray) {
-				((JSONArray)x).put(query.getInner());
-			}
-			else {
+
+		if (!isEmpty(this.inner)) {
+			Object x = this.inner.has("must") ? this.inner.get("must") : this.inner;
+			if (x instanceof JSONArray) {
+				((JSONArray) x).put(query.getInner());
+			} else {
 				this.inner = new JSONObject();
 				this.inner.put("must", new JSONObject());
-				JSONArray a=new JSONArray();
+				JSONArray a = new JSONArray();
 				a.put(x);
 				a.put(query.getInner());
 				this.inner.put("must", a);
 			}
+		} else {
+			this.inner.put("must", query.getInner());
 		}
-		
-		else {
-			this.inner = query.getInner();
+		this.setQuery("bool", this.inner);
+		return this;
+	}
+
+	/**
+	 * @param query
+	 */
+	public BoolQueryBuilder should(QueryBuilder query) {
+		if (!isEmpty(this.inner)) {
+			Object x = this.inner.has("should") ? this.inner.get("should") : this.inner;
+			if (x instanceof JSONArray) {
+				((JSONArray) x).put(query.getInner());
+			} else {
+				this.inner = new JSONObject();
+				//				this.inner.put("should", new JSONObject());
+				JSONArray a = new JSONArray();
+				if (!x.toString().equals("{}")) {
+					a.put(x);
+				}
+				a.put(query.getInner());
+				this.inner.put("should", a);
+			}
+		} else {
+			this.inner.put("should", query.getInner());
 		}
 		this.setQuery("bool", this.inner);
 		return this;
diff --git a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/queries/QueryBuilders.java b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/queries/QueryBuilders.java
index 82ff471..4d5b200 100644
--- a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/queries/QueryBuilders.java
+++ b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/queries/QueryBuilders.java
@@ -47,4 +47,14 @@
 	public static RegexQueryBuilder regex(String propertyName, String re) {
 		return new RegexQueryBuilder().add(propertyName, re);
 	}
+	/**
+	 * @param object
+	 * @return
+	 */
+	public static QueryBuilder searchAllFieldsQuery(String filter) {
+		JSONObject inner = new JSONObject();
+		inner.put("default_field", "*");
+		inner.put("query", filter==null?"":filter);
+		return new QueryBuilder().setQuery("query_string", inner);
+	}
 }
diff --git a/sdnr/wt/common/src/test/java/org/onap/ccsdk/features/sdnr/wt/common/test/TestDbQueries.java b/sdnr/wt/common/src/test/java/org/onap/ccsdk/features/sdnr/wt/common/test/TestDbQueries.java
index 21c68b3..93d4b1a 100644
--- a/sdnr/wt/common/src/test/java/org/onap/ccsdk/features/sdnr/wt/common/test/TestDbQueries.java
+++ b/sdnr/wt/common/src/test/java/org/onap/ccsdk/features/sdnr/wt/common/test/TestDbQueries.java
@@ -52,7 +52,7 @@
 			"}";
 	private static final String MATCH_QUERY_KEY2 = "node-id";
 	private static final Object MATCH_QUERY_VALUE2 = "sim2";
-	private static final String BOOL_QUERY = "{\n" + 
+	private static final String BOOL_QUERY_MUST = "{\n" + 
 			"    \"query\": {\n" + 
 			"        \"bool\": {\n" + 
 			"            \"must\": [\n" + 
@@ -70,6 +70,46 @@
 			"        }\n" + 
 			"    }\n" + 
 			"}";
+	private static final String BOOL_QUERY_MUST_SINGLE = "{\n" + 
+					"    \"query\": {\n" + 
+					"        \"bool\": {\n" + 
+					"            \"must\": {\n" + 
+					"                    \"match\": {\n" + 
+					"                        \""+MATCH_QUERY_KEY+"\": "+MATCH_QUERY_VALUE+"\n" + 
+					"                    }\n" + 
+					"                }\n" + 
+					"        }\n" + 
+					"    }\n" + 
+					"}";
+	private static final String BOOL_QUERY_SHOULD = "{\n" + 
+			"    \"query\": {\n" + 
+			"        \"bool\": {\n" + 
+			"            \"should\": [\n" + 
+			"                {\n" + 
+			"                    \"match\": {\n" + 
+			"                        \""+MATCH_QUERY_KEY+"\": "+MATCH_QUERY_VALUE+"\n" + 
+			"                    }\n" + 
+			"                },\n" + 
+			"                {\n" + 
+			"                    \"match\": {\n" + 
+			"                        \""+MATCH_QUERY_KEY2+"\":"+MATCH_QUERY_VALUE2+" \n" + 
+			"                    }\n" + 
+			"                }\n" + 
+			"            ]\n" + 
+			"        }\n" + 
+			"    }\n" + 
+			"}";
+	private static final String BOOL_QUERY_SHOULD_SINGLE = "{\n" + 
+					"    \"query\": {\n" + 
+					"        \"bool\": {\n" + 
+					"            \"should\": {\n" + 
+					"                    \"match\": {\n" + 
+					"                        \""+MATCH_QUERY_KEY+"\": "+MATCH_QUERY_VALUE+"\n" + 
+					"                    }\n" + 
+					"                }\n" + 
+					"        }\n" + 
+					"    }\n" + 
+					"}";
 	private static final String RANGE_QUERY_KEY = "timestamp";
 	private static final String RANGE_QUERY_LTEND = "2017-08-10T20:00:00.0Z";
 	private static final String RANGE_QUERY = "{\n" + 
@@ -189,13 +229,32 @@
 		testEquals("match query is wrong", MATCH_QUERY, QueryBuilders.matchQuery(MATCH_QUERY_KEY, MATCH_QUERY_VALUE));
 	}
 	@Test
-	public void testBool() {
-		testEquals("bool query is wrong", BOOL_QUERY, 
+	public void testBoolMust() {
+		testEquals("bool query is wrong", BOOL_QUERY_MUST, 
 				QueryBuilders.boolQuery().
 				must(QueryBuilders.matchQuery(MATCH_QUERY_KEY, MATCH_QUERY_VALUE)).
 				must(QueryBuilders.matchQuery(MATCH_QUERY_KEY2, MATCH_QUERY_VALUE2)));
 	}
 	@Test
+	public void testBoolMustSingle() {
+		testEquals("bool single query is wrong", BOOL_QUERY_MUST_SINGLE, 
+				QueryBuilders.boolQuery().
+				must(QueryBuilders.matchQuery(MATCH_QUERY_KEY, MATCH_QUERY_VALUE)));
+	}
+	@Test
+	public void testBoolShould() {
+		testEquals("bool query is wrong", BOOL_QUERY_SHOULD, 
+				QueryBuilders.boolQuery().
+				should(QueryBuilders.matchQuery(MATCH_QUERY_KEY, MATCH_QUERY_VALUE)).
+				should(QueryBuilders.matchQuery(MATCH_QUERY_KEY2, MATCH_QUERY_VALUE2)));
+	}
+	@Test
+	public void testBoolShouldSingle() {
+		testEquals("bool single query is wrong", BOOL_QUERY_SHOULD_SINGLE, 
+				QueryBuilders.boolQuery().
+				should(QueryBuilders.matchQuery(MATCH_QUERY_KEY, MATCH_QUERY_VALUE)));
+	}
+	@Test
 	public void testRange() {
 		testEquals("range query is wrong", RANGE_QUERY, QueryBuilders.rangeQuery(RANGE_QUERY_KEY).lte(RANGE_QUERY_LTEND));
 		
diff --git a/sdnr/wt/common/src/test/java/org/onap/ccsdk/features/sdnr/wt/common/test/TestPortstatus.java b/sdnr/wt/common/src/test/java/org/onap/ccsdk/features/sdnr/wt/common/test/TestPortstatus.java
new file mode 100644
index 0000000..379142d
--- /dev/null
+++ b/sdnr/wt/common/src/test/java/org/onap/ccsdk/features/sdnr/wt/common/test/TestPortstatus.java
@@ -0,0 +1,76 @@
+/*******************************************************************************
+ * ============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.common.test;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import java.io.IOException;
+import java.net.ServerSocket;
+import java.time.Duration;
+import java.time.Instant;
+import org.junit.Test;
+import org.mockito.Mockito;
+import org.onap.ccsdk.features.sdnr.wt.common.database.Portstatus;
+import org.onap.ccsdk.features.sdnr.wt.common.database.config.HostInfo;
+
+public class TestPortstatus extends Mockito{
+
+
+    @Test
+    public void testIsAvailable() throws IOException {
+        assertFalse("Port status should be false", Portstatus.isAvailable("localhost", 4567) );
+        ServerSocket serverSocket = new ServerSocket(4567);
+        assertTrue("Port status should be true", Portstatus.isAvailable("localhost", 4567) );
+        serverSocket.close();
+    }
+
+    @Test
+    public void testWaitIsAvailable() throws IOException {
+        ServerSocket serverSocket = new ServerSocket(4567);
+        assertTrue("Port status should be true", Portstatus.waitSecondsTillAvailable(5, "localhost", 4567) );
+        serverSocket.close();
+    }
+
+    @Test
+    public void testWaitIsAvailableHostInfo() throws IOException {
+        ServerSocket serverSocket = new ServerSocket(4567);
+        assertTrue("Port status should be true", Portstatus.waitSecondsTillAvailable(5, new HostInfo("localhost", 4567)) );
+        serverSocket.close();
+    }
+
+    @Test
+    public void testWaitTillAvailable() throws IOException {
+        Instant start = Instant.now();
+        assertFalse("Port status should be false", Portstatus.waitSecondsTillAvailable(5, "localhost", 4567) );
+        Instant end = Instant.now();
+        long seconds = Duration.between(start, end).getSeconds();
+        assertTrue("Port status timeout 5 expected and not between 3 .. 7 seconds", 3 < seconds && seconds < 7  );
+    }
+
+    @Test
+    public void testWaitTillAvailableHostinfo() throws IOException {
+        Instant start = Instant.now();
+        assertFalse("Port status should be false", Portstatus.waitSecondsTillAvailable(5, new HostInfo("localhost", 4567)));
+        Instant end = Instant.now();
+        long seconds = Duration.between(start, end).getSeconds();
+        assertTrue("Port status timeout 5 expected and not between 3 .. 7 seconds", 3 < seconds && seconds < 7  );
+    }
+
+
+}
diff --git a/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/DataMigrationProviderImpl.java b/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/DataMigrationProviderImpl.java
index 10fc586..a336c0f 100644
--- a/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/DataMigrationProviderImpl.java
+++ b/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/DataMigrationProviderImpl.java
@@ -34,6 +34,7 @@
 
 import org.json.JSONObject;
 import org.onap.ccsdk.features.sdnr.wt.common.database.HtDatabaseClient;
+import org.onap.ccsdk.features.sdnr.wt.common.database.Portstatus;
 import org.onap.ccsdk.features.sdnr.wt.common.database.SearchHit;
 import org.onap.ccsdk.features.sdnr.wt.common.database.SearchResult;
 import org.onap.ccsdk.features.sdnr.wt.common.database.config.HostInfo;
@@ -61,324 +62,363 @@
 
 public class DataMigrationProviderImpl implements DataMigrationProviderService {
 
-	private final Logger LOG = LoggerFactory.getLogger(DataMigrationProviderImpl.class);
-
-	private final HtDatabaseClient dbClient;
 	
-	public DataMigrationProviderImpl(HostInfo[] hosts, String username, String password, boolean trustAll) {
-		this.dbClient = new HtDatabaseClient(hosts, username, password, trustAll);
-	}
+    private static final Logger LOG = LoggerFactory.getLogger(DataMigrationProviderImpl.class);
+    private final HtDatabaseClient dbClient;
 
-	@Override
-	public DataMigrationReport importData(String filename, boolean dryrun) throws Exception {
-		return this.importData(filename, dryrun, Release.CURRENT_RELEASE);
-	}
+    public DataMigrationProviderImpl(HostInfo[] hosts, String username, String password, boolean trustAll, long timeoutms) {
 
-	public DataMigrationReport importData(String filename, boolean dryrun, Release forRelease) throws Exception {
-		DataMigrationReport report = new DataMigrationReport();
-		File file = new File(filename);
-		if (!file.exists()) {
-			if (dryrun) {
-				report.error("file %s not found", filename);
-				return report;
-			}
-			throw new FileNotFoundException(filename);
-		}
-		DataContainer container = null;
-		try {
-			container = DataContainer.load(file);
-		} catch (Exception e) {
-			if (dryrun) {
-				report.error("problem loading file %s: %s", filename, e.getMessage());
-				return report;
-			}
-			throw new Exception("problem loading file " + filename, e);
-		}
-		ReleaseInformation ri = ReleaseInformation.getInstance(forRelease);
-		SearchHitConverter converter;
-		Set<ComponentName> components = ri.getComponents();
-		//for all db components of dest architecture
-		for (ComponentName component : components) {
-			//convert to ComponentData for current release with existing ComponentData of the container
-			converter = SearchHitConverter.Factory.getInstance(container.getRelease(), forRelease, component);
-			if (converter == null) {
-				continue;
-			}
-			ComponentData data = converter.convert(container);
-			if (data != null) {
-				String indexName = ri.getAlias(component);
-				String dataTypeName = ri.getDataType(component);
-				if (dryrun) {
-					report.log("write %d entries into %s/%s", data.size(), indexName, dataTypeName);
-				} else {
-					LOG.debug("write {} entries into {}/{}", data.size(), indexName, dataTypeName);
-				}
-				for (SearchHit item : data) {
-					if (!dryrun) {
-						String id = this.dbClient.doWriteRaw(indexName, dataTypeName, item.getId(),
-								item.getSourceAsString());
-						if (!item.getId().equals(id)) {
-							LOG.warn("entry for {} with original id {} was written with another id {}",
-									component.getValue(), item.getId(), id);
-						}
-					}
-				}
-			} else {
-				if (dryrun) {
-					report.error("unable to convert data for " + component.getValue() + " from version "
-							+ container.getRelease().getValue() + " to " + forRelease.getValue() + "\n");
-				} else {
-					LOG.warn("unable to convert data for {} from version {} to {}", component.getValue(),
-							container.getRelease().getValue(), forRelease.getValue());
-				}
-			}
-		}
-		LOG.info("import of {} completed", filename);
-		if (dryrun) {
-			report.log("import of %s completed", filename);
-		}
-		report.setCompleted(true);
-		return report;
-	}
+        if(timeoutms>0) {
+            Portstatus.waitSecondsTillAvailable(timeoutms/1000, hosts);
+        }
+        this.dbClient = new HtDatabaseClient(hosts, username, password, trustAll);
+    }
 
-	
+    @Override
+    public DataMigrationReport importData(String filename, boolean dryrun) throws Exception {
+        return this.importData(filename, dryrun, Release.CURRENT_RELEASE);
+    }
+
+    public DataMigrationReport importData(String filename, boolean dryrun, Release forRelease) throws Exception {
+        DataMigrationReport report = new DataMigrationReport();
+        File file = new File(filename);
+        if (!file.exists()) {
+            if (dryrun) {
+                report.error("file %s not found", filename);
+                return report;
+            }
+            throw new FileNotFoundException(filename);
+        }
+        DataContainer container = null;
+        try {
+            container = DataContainer.load(file);
+        } catch (Exception e) {
+            if (dryrun) {
+                report.error("problem loading file %s: %s", filename, e.getMessage());
+                return report;
+            }
+            throw new Exception("problem loading file " + filename, e);
+        }
+        ReleaseInformation ri = ReleaseInformation.getInstance(forRelease);
+        SearchHitConverter converter;
+        Set<ComponentName> components = ri.getComponents();
+        //for all db components of dest architecture
+        for (ComponentName component : components) {
+            //convert to ComponentData for current release with existing ComponentData of the container
+            converter = SearchHitConverter.Factory.getInstance(container.getRelease(), forRelease, component);
+            if (converter == null) {
+                continue;
+            }
+            ComponentData data = converter.convert(container);
+            if (data != null) {
+                String indexName = ri.getAlias(component);
+                String dataTypeName = ri.getDataType(component);
+                if (dryrun) {
+                    report.log("write %d entries into %s/%s", data.size(), indexName, dataTypeName);
+                } else {
+                    LOG.debug("write {} entries into {}/{}", data.size(), indexName, dataTypeName);
+                }
+                for (SearchHit item : data) {
+                    if (!dryrun) {
+                        String id = this.dbClient.doWriteRaw(indexName, dataTypeName, item.getId(),
+                                item.getSourceAsString());
+                        if (!item.getId().equals(id)) {
+                            LOG.warn("entry for {} with original id {} was written with another id {}",
+                                    component.getValue(), item.getId(), id);
+                        }
+                    }
+                }
+            } else {
+                if (dryrun) {
+                    report.error("unable to convert data for " + component.getValue() + " from version "
+                            + container.getRelease().getValue() + " to " + forRelease.getValue() + "\n");
+                } else {
+                    LOG.warn("unable to convert data for {} from version {} to {}", component.getValue(),
+                            container.getRelease().getValue(), forRelease.getValue());
+                }
+            }
+        }
+        LOG.info("import of {} completed", filename);
+        if (dryrun) {
+            report.log("import of %s completed", filename);
+        }
+        report.setCompleted(true);
+        return report;
+    }
+
+
+    /**
+     * export data
+     * if file exists .1 (.n) will be created
+     *
+     */
+    @Override
+    public DataMigrationReport exportData(String filename) {
+        DataMigrationReport report = new DataMigrationReport();
+
+        DataContainer container = new DataContainer();
+
+        filename = this.checkFilenameForWrite(filename);
+        LOG.info("output will be written to {}", filename);
+        //autodetect version
+        Release dbRelease = this.autoDetectRelease();
+        if(dbRelease==null) {
+            report.error("unbable to detect db release. is database initialized?");
+            return report;
+        }
+        ReleaseInformation ri = ReleaseInformation.getInstance(dbRelease);
+        boolean componentsSucceeded = true;
+        for(ComponentName c: ri.getComponents()) {
+            ComponentData data = new ComponentData(c);
+            SearchResult<SearchHit> result = this.dbClient.doReadAllJsonData(ri.getAlias(c),ri.getDataType(c),false);
+            data.addAll(result.getHits());
+            container.addComponent(c, data );
+        }
+        try {
+            Files.write(new File(filename).toPath(), Arrays.asList(container.toJSON()), StandardCharsets.UTF_8);
+            report.setCompleted(componentsSucceeded);
+        } catch (IOException e) {
+            LOG.warn("problem writing data to {}: {}", filename, e);
+        }
+        return report;
+    }
+
+    private String checkFilenameForWrite(String filename) {
+        File f = new File(filename);
+        if (!f.exists()) {
+            return filename;
+        }
+        return this.checkFilenameForWrite(filename, 0);
+    }
+
+    private String checkFilenameForWrite(String filename, int apdx) {
+        File f = new File(String.format("$s.$d",filename,apdx));
+        if (!f.exists()) {
+            return filename;
+        }
+        return this.checkFilenameForWrite(filename, apdx + 1);
+    }
+
+    @Override
+    public Release getCurrentVersion() {
+        return Release.CURRENT_RELEASE;
+    }
+
+
+    public Release autoDetectRelease() {
+        EsVersion dbVersion = this.readActualVersion();
+        AliasesEntryList aliases = this.readAliases();
+        IndicesEntryList indices = this.readIndices();
+        if(indices==null) {
+            return null;
+        }
+        List<Release> foundReleases = new ArrayList<>();
+        //if there are active aliases reduce indices to the active ones
+        if(aliases!=null && aliases.size()>0) {
+            indices = indices.subList(aliases.getLinkedIndices());
+        }
+        for(Release r:Release.values()) {
+            if(r.isDbInRange(dbVersion)) {
+                ReleaseInformation ri = ReleaseInformation.getInstance(r);
+                if(ri!=null && ri.containsIndices(indices)) {
+                    foundReleases.add(r);
+                }
+            }
+        }
+        if (foundReleases.size() == 1) {
+            return foundReleases.get(0);
+        }
+        LOG.error("detect {} releases: {}. unable to detect for which one to do sth.",foundReleases.size(), foundReleases);
+        return null;
+    }
+    private EsVersion readActualVersion() {
+        try {
+            GetInfoResponse response = this.dbClient.getInfo();
+            return response.getVersion();
+        } catch (Exception e) {
+            LOG.warn(e.getMessage());
+        }
+        return null;
+    }
+
+    private AliasesEntryList readAliases() {
+        AliasesEntryList entries = null;
+        try {
+            ListAliasesResponse response = this.dbClient.getAliases();
+            entries = response.getEntries();
+        } catch (ParseException | IOException e) {
+            LOG.error(e.getMessage());
+        }
+        return entries;
+    }
+
+    private IndicesEntryList readIndices() {
+        IndicesEntryList entries = null;
+        try {
+            ListIndicesResponse response = this.dbClient.getIndices();
+            entries = response.getEntries();
+        } catch (ParseException | IOException e) {
+            LOG.error(e.getMessage());
+        }
+        return entries;
+    }
+
+    @Override
+    public boolean initDatabase(Release release, int numShards, int numReplicas, String dbPrefix,
+            boolean forceRecreate,long timeoutms) {
+        if(timeoutms>0) {
+            this.dbClient.waitForYellowStatus(timeoutms);
+        }
+        EsVersion dbVersion = this.readActualVersion();
+        if (dbVersion == null) {
+            return false;
+        }
+        if (!release.isDbInRange(dbVersion)) {
+            LOG.warn("db version {} maybe not compatible with release {}", dbVersion, release);
+            return false;
+        }
+        if (forceRecreate) {
+            this.clearDatabase(release, dbPrefix,0);
+        }
+        ReleaseInformation ri = ReleaseInformation.getInstance(release);
+        AliasesEntryList aliases = this.readAliases();
+        IndicesEntryList indices = this.readIndices();
+        if (aliases == null || indices == null) {
+            return false;
+        }
+        AcknowledgedResponse response = null;
+        if(!ri.runPreInitCommands(this.dbClient)) {
+            return false;
+        }
+        for (ComponentName component : ri.getComponents()) {
+            try {
+                if (ri.hasOwnDbIndex(component)) {
+                    //check if index already exists
+                    String indexName = ri.getIndex(component, dbPrefix);
+                    String aliasName = ri.getAlias(component, dbPrefix);
+                    if (indices.findByIndex(indexName) == null) {
+                        LOG.info("creating index for {}", component);
+                        CreateIndexRequest request = new CreateIndexRequest(ri.getIndex(component, dbPrefix));
+                        request.mappings(new JSONObject(ri.getDatabaseMapping(component)));
+                        request.settings(new JSONObject(ri.getDatabaseSettings(component, numShards, numReplicas)));
+                        response = this.dbClient.createIndex(request);
+                        LOG.info(response.isAcknowledged() ? "succeeded" : "failed");
+                    } else {
+                        LOG.info("index {} for {} already exists", indexName, component);
+                    }
+                    //check if alias already exists
+                    if (aliases.findByAlias(aliasName) == null) {
+                        LOG.info("creating alias for {}", component);
+                        response = this.dbClient.createAlias(new CreateAliasRequest(indexName, aliasName));
+                        LOG.info(response.isAcknowledged() ? "succeeded" : "failed");
+                    } else {
+                        LOG.info("alias {} for index {} for {} already exists", aliasName, indexName, component);
+                    }
+                }
+            } catch (IOException e) {
+                LOG.error(e.getMessage());
+                return false;
+            }
+        }
+        if(!ri.runPostInitCommands(this.dbClient)) {
+            return false;
+        }
+        return true;
+    }
+
+    @Override
+    public boolean clearDatabase(Release release, String dbPrefix, long timeoutms) {
+
+        if(timeoutms>0) {
+            this.dbClient.waitForYellowStatus(timeoutms);
+        }
+        //check aliases
+        AliasesEntryList entries = this.readAliases();
+        if (entries == null) {
+            return false;
+        }
+        ReleaseInformation ri = ReleaseInformation.getInstance(release);
+        AcknowledgedResponse response;
+        if (entries.size() <= 0) {
+            LOG.info("no aliases to clear");
+        } else {
+            //check for every component of release if alias exists
+            for (ComponentName component : ri.getComponents()) {
+                String aliasToDelete = ri.getAlias(component, dbPrefix);
+                AliasesEntry entryToDelete = entries.findByAlias(aliasToDelete);
+                if (entryToDelete != null) {
+                    try {
+                        LOG.info("deleting alias {} for index {}", entryToDelete.getAlias(), entryToDelete.getIndex());
+                        response=this.dbClient.deleteAlias(
+                                new DeleteAliasRequest(entryToDelete.getIndex(), entryToDelete.getAlias()));
+                        LOG.info(response.isResponseSucceeded()?"succeeded":"failed");
+                    } catch (IOException e) {
+                        LOG.error(e.getMessage());
+                        return false;
+                    }
+                }
+            }
+        }
+        IndicesEntryList entries2 = this.readIndices();
+        if (entries2 == null) {
+            return false;
+        }
+        if (entries2.size() <= 0) {
+            LOG.info("no indices to clear");
+        } else {
+            //check for every component of release if index exists
+            for (ComponentName component : ri.getComponents()) {
+                String indexToDelete = ri.getIndex(component, dbPrefix);
+                IndicesEntry entryToDelete = entries2.findByIndex(indexToDelete);
+                if (entryToDelete != null) {
+                    try {
+                        LOG.info("deleting index {}", entryToDelete.getName());
+                        response=this.dbClient.deleteIndex(new DeleteIndexRequest(entryToDelete.getName()));
+                        LOG.info(response.isResponseSucceeded()?"succeeded":"failed");
+                    } catch (IOException e) {
+                        LOG.error(e.getMessage());
+                        return false;
+                    }
+                }
+            }
+        }
+
+        return true;
+    }
+
 	/**
-	 * export data
-	 * if file exists .1 (.n) will be created
-	 * 
+	 * @param timeoutms
+	 * @return
 	 */
-	@Override
-	public DataMigrationReport exportData(String filename) {
-		DataMigrationReport report = new DataMigrationReport();
-
-		DataContainer container = new DataContainer();
-
-		filename = this.checkFilenameForWrite(filename);
-		LOG.info("output will be written to {}", filename);
-		//autodetect version
-		Release dbRelease = this.autoDetectRelease();
-		if(dbRelease==null) {
-			report.error("unbable to detect db release. is database initialized?");
-			return report;
-		}
-		ReleaseInformation ri = ReleaseInformation.getInstance(dbRelease);
-		boolean componentsSucceeded = true;
-		for(ComponentName c: ri.getComponents()) {
-			ComponentData data = new ComponentData(c);
-			SearchResult<SearchHit> result = this.dbClient.doReadAllJsonData(ri.getAlias(c),ri.getDataType(c),false);
-			data.addAll(result.getHits());
-			container.addComponent(c, data );
-		}
-		try {
-			Files.write(new File(filename).toPath(), Arrays.asList(container.toJSON()), StandardCharsets.UTF_8);
-			report.setCompleted(componentsSucceeded);
-		} catch (IOException e) {
-			LOG.warn("problem writing data to {}: {}", filename, e);
-		}
-		return report;
-	}
-
-	private String checkFilenameForWrite(String filename) {
-		File f = new File(filename);
-		if (!f.exists()) {
-			return filename;
-		}
-		return this.checkFilenameForWrite(filename, 0);
-	}
-
-	private String checkFilenameForWrite(String filename, int apdx) {
-		File f = new File(String.format("$s.$d",filename,apdx));
-		if (!f.exists()) {
-			return filename;
-		}
-		return this.checkFilenameForWrite(filename, apdx + 1);
-	}
-
-	@Override
-	public Release getCurrentVersion() {
-		return Release.CURRENT_RELEASE;
-	}
-
-
-	public Release autoDetectRelease() {
-		EsVersion dbVersion = this.readActualVersion();
-		AliasesEntryList aliases = this.readAliases();
-		IndicesEntryList indices = this.readIndices();
-		if(indices==null) {
-			return null;
-		}
-		List<Release> foundReleases = new ArrayList<Release>();
-		//if there are active aliases reduce indices to the active ones
-		if(aliases!=null && aliases.size()>0) {
-			indices = indices.subList(aliases.getLinkedIndices());
-		}
-		for(Release r:Release.values()) {
-			if(r.isDbInRange(dbVersion)) {
-				ReleaseInformation ri = ReleaseInformation.getInstance(r);
-				if(ri!=null && ri.containsIndices(indices)) {
-					foundReleases.add(r);
-				}
-			}
-		}
-		if (foundReleases.size() == 1) {
-			return foundReleases.get(0);
-		}
-		LOG.error("detect {} releases: {}. unable to detect for which one to do sth.",foundReleases.size(), foundReleases);
-		return null;
-	}
-	private EsVersion readActualVersion() {
-		try {
-			GetInfoResponse response = this.dbClient.getInfo();
-			return response.getVersion();
-		} catch (Exception e) {
-			LOG.warn(e.getMessage());
-		}
-		return null;
-	}
-
-	private AliasesEntryList readAliases() {
-		AliasesEntryList entries = null;
-		try {
-			ListAliasesResponse response = this.dbClient.getAliases();
-			entries = response.getEntries();
-		} catch (ParseException | IOException e) {
-			LOG.error(e.getMessage());
-		}
-		return entries;
-	}
-
-	private IndicesEntryList readIndices() {
-		IndicesEntryList entries = null;
-		try {
-			ListIndicesResponse response = this.dbClient.getIndices();
-			entries = response.getEntries();
-		} catch (ParseException | IOException e) {
-			LOG.error(e.getMessage());
-		}
-		return entries;
-	}
-
-	@Override
-	public boolean initDatabase(Release release, int numShards, int numReplicas, String dbPrefix,
-			boolean forceRecreate,long timeoutms) {
+	public boolean clearCompleteDatabase(long timeoutms) {
 		if(timeoutms>0) {
-			this.dbClient.waitForYellowStatus(timeoutms);
-		}
-		EsVersion dbVersion = this.readActualVersion();
-		if (dbVersion == null) {
-			return false;
-		}
-		if (!release.isDbInRange(dbVersion)) {
-			LOG.warn("db version {} maybe not compatible with release {}", dbVersion, release);
-			return false;
-		}
-		if (forceRecreate) {
-			this.clearDatabase(release, dbPrefix,0);
-		}
-		ReleaseInformation ri = ReleaseInformation.getInstance(release);
+            this.dbClient.waitForYellowStatus(timeoutms);
+        }
+        //check aliases and indices
 		AliasesEntryList aliases = this.readAliases();
-		IndicesEntryList indices = this.readIndices();
-		if (aliases == null || indices == null) {
-			return false;
-		}
-		AcknowledgedResponse response = null;
-		if(!ri.runPreInitCommands(this.dbClient)) {
-			return false;
-		}
-		for (ComponentName component : ri.getComponents()) {
-			try {
-				if (ri.hasOwnDbIndex(component)) {
-					//check if index already exists
-					String indexName = ri.getIndex(component, dbPrefix);
-					String aliasName = ri.getAlias(component, dbPrefix);
-					if (indices.findByIndex(indexName) == null) {
-						LOG.info("creating index for {}", component);
-						CreateIndexRequest request = new CreateIndexRequest(ri.getIndex(component, dbPrefix));
-						request.mappings(new JSONObject(ri.getDatabaseMapping(component)));
-						request.settings(new JSONObject(ri.getDatabaseSettings(component, numShards, numReplicas)));
-						response = this.dbClient.createIndex(request);
-						LOG.info(response.isAcknowledged() ? "succeeded" : "failed");
-					} else {
-						LOG.info("index {} for {} already exists", indexName, component);
-					}
-					//check if alias already exists
-					if (aliases.findByAlias(aliasName) == null) {
-						LOG.info("creating alias for {}", component);
-						response = this.dbClient.createAlias(new CreateAliasRequest(indexName, aliasName));
-						LOG.info(response.isAcknowledged() ? "succeeded" : "failed");
-					} else {
-						LOG.info("alias {} for index {} for {} already exists", aliasName, indexName, component);
-					}
-				}
+        IndicesEntryList indices = this.readIndices();
+        if (aliases == null || indices == null) {
+            return false;
+        }
+        for(AliasesEntry alias:aliases) {
+        	try {
+        		LOG.info("deleting alias {} for index {}",alias.getAlias(),alias.getIndex());
+				this.dbClient.deleteAlias(new DeleteAliasRequest(alias.getIndex(), alias.getAlias()));
 			} catch (IOException e) {
-				LOG.error(e.getMessage());
+				LOG.error("problem deleting alias {}: {}",alias.getAlias(),e);
 				return false;
 			}
-		}
-		if(!ri.runPostInitCommands(this.dbClient)) {
-			return false;
-		}
-		return true;
-	}
-
-	@Override
-	public boolean clearDatabase(Release release, String dbPrefix, long timeoutms) {
-
-		if(timeoutms>0) {
-			this.dbClient.waitForYellowStatus(timeoutms);
-		}
-		//check aliases
-		AliasesEntryList entries = this.readAliases();
-		if (entries == null) {
-			return false;
-		}
-		ReleaseInformation ri = ReleaseInformation.getInstance(release);
-		AcknowledgedResponse response;
-		if (entries.size() <= 0) {
-			LOG.info("no aliases to clear");
-		} else {
-			//check for every component of release if alias exists
-			for (ComponentName component : ri.getComponents()) {
-				String aliasToDelete = ri.getAlias(component, dbPrefix);
-				AliasesEntry entryToDelete = entries.findByAlias(aliasToDelete);
-				if (entryToDelete != null) {
-					try {
-						LOG.info("deleting alias {} for index {}", entryToDelete.getAlias(), entryToDelete.getIndex());
-						response=this.dbClient.deleteAlias(
-								new DeleteAliasRequest(entryToDelete.getIndex(), entryToDelete.getAlias()));
-						LOG.info(response.isResponseSucceeded()?"succeeded":"failed");
-					} catch (IOException e) {
-						LOG.error(e.getMessage());
-						return false;
-					}
-				}
+        }
+        for(IndicesEntry index : indices) {
+        	try {
+        		LOG.info("deleting index {}",index.getName());
+				this.dbClient.deleteIndex(new DeleteIndexRequest(index.getName()));
+			} catch (IOException e) {
+				LOG.error("problem deleting index {}: {}",index.getName(),e);
+				return false;
 			}
-		}
-		IndicesEntryList entries2 = this.readIndices();
-		if (entries2 == null) {
-			return false;
-		}
-		if (entries2.size() <= 0) {
-			LOG.info("no indices to clear");
-		} else {
-			//check for every component of release if index exists
-			for (ComponentName component : ri.getComponents()) {
-				String indexToDelete = ri.getIndex(component, dbPrefix);
-				IndicesEntry entryToDelete = entries2.findByIndex(indexToDelete);
-				if (entryToDelete != null) {
-					try {
-						LOG.info("deleting index {}", entryToDelete.getName());
-						response=this.dbClient.deleteIndex(new DeleteIndexRequest(entryToDelete.getName()));
-						LOG.info(response.isResponseSucceeded()?"succeeded":"failed");
-					} catch (IOException e) {
-						LOG.error(e.getMessage());
-						return false;
-					}
-				}
-			}
-		}
-
-		return true;
+        }
+        return true;
 	}
 
 }
diff --git a/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/Program.java b/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/Program.java
index a1b92e9..d06ffe1 100644
--- a/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/Program.java
+++ b/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/Program.java
@@ -43,12 +43,15 @@
  */
 public class Program {
 
+	// constants
     private static final String CMD_INITDB = "init";
     private static final String CMD_CLEAR_DB = "delete";
+    private static final String CMD_CLEAR_DB_COMPLETE = "clear";
     private static final String CMD_CREATE_PLUGIN_INIT_FILE = "pluginfile";
     private static final String CMD_IMPORT = "import";
     private static final String CMD_EXPORT = "export";
     private static final String CMD_LIST_VERSION = "list";
+
     private static final String CMD_INITDB_DESCRIPTION = "initialize databse indices and aliases";
     private static final String CMD_CLEAR_DB_DESCRIPTION = "clear database indices and aliases";
     private static final String CMD_CREATE_PLUGIN_INIT_FILE_DESCRIPTION = "create maven plugin file";
@@ -76,12 +79,27 @@
     private static final String OPTION_INPUTFILE_SHORT = "if";
     private static final String OPTION_DEBUG_SHORT = "x";
     private static final String OPTION_TRUSTINSECURESSL_SHORT = "k";
-    private static final String OPTION_DATABSE_SHORT = "db";
-
+    private static final String OPTION_DATABASE_SHORT = "db";
+    private static final String OPTION_COMMAND_SHORT = "c";
+	private static final String OPTION_DATABASEUSER_SHORT = "dbu";
+	private static final String OPTION_DATABASEPASSWORD_SHORT = "dbp";
+	private static final String OPTION_DATABASEPREFIX_SHORT = "p";
+	private static final String OPTION_DATABASEWAIT_SHORT = "w";
+	private static final String OPTION_HELP_SHORT = "h";
+    // end of constants
+	
+	// variables
     private static Options options = init();
-
     private static Log LOG = null;
-
+    // end of variables
+    
+    // public methods
+    public static void main(String[] args) {
+        System.exit( main2(args) );
+    }
+    // end of public methods
+    
+    // private methods
     @SuppressWarnings("unchecked")
     private static <T> T getOptionOrDefault(CommandLine cmd, String option, T def) throws ParseException {
         if (def instanceof Boolean) {
@@ -133,20 +151,22 @@
         // repeat with all other desired appenders
     }
 
-    public static void main(String[] args) {
+    private static int main2(String[] args) {
+
         CommandLineParser parser = new DefaultParser();
         HelpFormatter formatter = new HelpFormatter();
         CommandLine cmd = null;
+       
         try {
             cmd = parser.parse(options, args);
         } catch (ParseException e) {
             System.out.println(e.getMessage());
             printHelp(formatter);
-            System.exit(1);
+            return 1;
         }
         if (cmd == null) {
             printHelp(formatter);
-            System.exit(1);
+            return 1;
         }
         try {
             initLog(getOptionOrDefault(cmd, OPTION_SILENT_SHORT, false), null,
@@ -154,54 +174,75 @@
         } catch (ParseException e2) {
 
         }
-        switch (cmd.getOptionValue("c")) {
+        try {
+			if(getOptionOrDefault(cmd, OPTION_HELP_SHORT, false)) {
+			    printHelp(formatter);
+			    return 0;
+			}
+		} catch (ParseException e2) {
+			return exit(e2);
+		}
+        final String command = cmd.getOptionValue(OPTION_COMMAND_SHORT);
+        if(command==null) {
+        	printHelp(formatter);
+            return 1;
+        }
+        switch (command) {
         case CMD_INITDB:
             try {
                 cmd_init_db(cmd);
             } catch (Exception e1) {
-                exit(e1);
+                return exit(e1);
             }
             break;
         case CMD_CLEAR_DB:
             try {
                 cmd_clear_db(cmd);
             } catch (Exception e1) {
-                exit(e1);
+                return exit(e1);
+            }
+            break;
+        case CMD_CLEAR_DB_COMPLETE:
+        	try {
+                cmd_clear_db_complete(cmd);
+            } catch (Exception e1) {
+                return exit(e1);
             }
             break;
         case CMD_CREATE_PLUGIN_INIT_FILE:
             try {
-                String of = getOptionOrDefault(cmd, "of", null);
+                String of = getOptionOrDefault(cmd, OPTION_OUTPUTFILE_SHORT, null);
                 if (of == null) {
                     throw new Exception("please add the parameter output-file");
                 }
                 MavenDatabasePluginInitFile.create(Release.CURRENT_RELEASE, of);
             } catch (Exception e) {
-                exit(e);
+                return exit(e);
             }
             break;
         case CMD_IMPORT:
             try {
                 cmd_dbimport(cmd);
             } catch (Exception e1) {
-                exit(e1);
+                return exit(e1);
             }
             break;
         case CMD_EXPORT:
             try {
                 cmd_dbexport(cmd);
             } catch (Exception e) {
-                exit(e);
+                return exit(e);
             }
             break;
         case CMD_LIST_VERSION:
             cmd_listversion();
             break;
+
         default:
             printHelp(formatter);
-            break;
+            return 1;
         }
-        System.exit(0);
+        return 0;
     }
 
     private static void printHelp(HelpFormatter formatter) {
@@ -226,16 +267,17 @@
     }
 
    private static void cmd_dbimport(CommandLine cmd) throws Exception {
-        String dbUrl = getOptionOrDefault(cmd, OPTION_DATABSE_SHORT, DEFAULT_DBURL);
-        String username = getOptionOrDefault(cmd, "dbu", null);
-        String password = getOptionOrDefault(cmd, "dbp", null);
+        String dbUrl = getOptionOrDefault(cmd, OPTION_DATABASE_SHORT, DEFAULT_DBURL);
+        String username = getOptionOrDefault(cmd, OPTION_DATABASEUSER_SHORT, null);
+        String password = getOptionOrDefault(cmd, OPTION_DATABASEPASSWORD_SHORT, null);
         String filename = getOptionOrDefault(cmd, OPTION_OUTPUTFILE_SHORT, null);
         boolean trustAll = getOptionOrDefault(cmd, OPTION_TRUSTINSECURESSL_SHORT, false);
         if (filename == null) {
             throw new Exception("please add output file parameter");
         }
+        long timeoutms = getOptionOrDefault(cmd, OPTION_DATABASEWAIT_SHORT, 30)*1000;
         DataMigrationProviderImpl service = new DataMigrationProviderImpl(new HostInfo[] { HostInfo.parse(dbUrl) },
-                username, password, trustAll);
+                username, password, trustAll, timeoutms);
         DataMigrationReport report = service.importData(filename, false);
         LOG.info(report);
         if(!report.completed()) {
@@ -244,16 +286,17 @@
     }
 
     private static void cmd_dbexport(CommandLine cmd) throws Exception {
-        String dbUrl = getOptionOrDefault(cmd, "db", DEFAULT_DBURL);
-        String username = getOptionOrDefault(cmd, "dbu", null);
-        String password = getOptionOrDefault(cmd, "dbp", null);
+        String dbUrl = getOptionOrDefault(cmd, OPTION_DATABASE_SHORT, DEFAULT_DBURL);
+        String username = getOptionOrDefault(cmd, OPTION_DATABASEUSER_SHORT, null);
+        String password = getOptionOrDefault(cmd, OPTION_DATABASEPASSWORD_SHORT, null);
         String filename = getOptionOrDefault(cmd, OPTION_OUTPUTFILE_SHORT, null);
         boolean trustAll = getOptionOrDefault(cmd, OPTION_TRUSTINSECURESSL_SHORT, false);
         if (filename == null) {
             throw new Exception("please add output file parameter");
         }
+        long timeoutms = getOptionOrDefault(cmd, OPTION_DATABASEWAIT_SHORT, 30)*1000;
         DataMigrationProviderImpl service = new DataMigrationProviderImpl(new HostInfo[] { HostInfo.parse(dbUrl) },
-                username, password, trustAll);
+                username, password, trustAll, timeoutms);
         DataMigrationReport report = service.exportData(filename);
         LOG.info(report);
         if(!report.completed()) {
@@ -262,42 +305,54 @@
 
     }
 
-    private static void exit(Exception e) {
+    private static int exit(Exception e) {
         if (LOG != null) {
             LOG.error("Error during execution: {}", e);
         } else {
             System.err.println(e);
         }
-        System.exit(1);
+        return 1;
     }
 
     private static void cmd_clear_db(CommandLine cmd) throws Exception {
         Release r = getOptionOrDefault(cmd, OPTION_VERSION_SHORT, Release.CURRENT_RELEASE);
-        String dbUrl = getOptionOrDefault(cmd, OPTION_DATABSE_SHORT, DEFAULT_DBURL);
-        String dbPrefix = getOptionOrDefault(cmd, "p", DEFAULT_DBPREFIX);
-        String username = getOptionOrDefault(cmd, "dbu", null);
-        String password = getOptionOrDefault(cmd, "dbp", null);
+        String dbUrl = getOptionOrDefault(cmd, OPTION_DATABASE_SHORT, DEFAULT_DBURL);
+        String dbPrefix = getOptionOrDefault(cmd, OPTION_DATABASEPREFIX_SHORT, DEFAULT_DBPREFIX);
+        String username = getOptionOrDefault(cmd, OPTION_DATABASEUSER_SHORT, null);
+        String password = getOptionOrDefault(cmd, OPTION_DATABASEPASSWORD_SHORT, null);
         boolean trustAll = getOptionOrDefault(cmd, OPTION_TRUSTINSECURESSL_SHORT, false);
+        long timeoutms = getOptionOrDefault(cmd, OPTION_DATABASEWAIT_SHORT, 30)*1000;
         DataMigrationProviderImpl service = new DataMigrationProviderImpl(new HostInfo[] { HostInfo.parse(dbUrl) },
-                username, password, trustAll);
-        long timeoutms = getOptionOrDefault(cmd, "w", 30)*1000;
+                username, password, trustAll, timeoutms);
         if (!service.clearDatabase(r, dbPrefix,timeoutms)) {
             throw new Exception("failed to init database");
         }
     }
+    private static void cmd_clear_db_complete(CommandLine cmd) throws Exception {
+        String dbUrl = getOptionOrDefault(cmd, OPTION_DATABASE_SHORT, DEFAULT_DBURL);
+        String username = getOptionOrDefault(cmd, OPTION_DATABASEUSER_SHORT, null);
+        String password = getOptionOrDefault(cmd, OPTION_DATABASEPASSWORD_SHORT, null);
+        boolean trustAll = getOptionOrDefault(cmd, OPTION_TRUSTINSECURESSL_SHORT, false);
+        long timeoutms = getOptionOrDefault(cmd, OPTION_DATABASEWAIT_SHORT, 30)*1000;
+        DataMigrationProviderImpl service = new DataMigrationProviderImpl(new HostInfo[] { HostInfo.parse(dbUrl) },
+                username, password, trustAll, timeoutms);
+        if (!service.clearCompleteDatabase(timeoutms)) {
+        	throw new Exception("failed to init database");
+        }
+    }
 
     private static void cmd_init_db(CommandLine cmd) throws Exception {
         Release r = getOptionOrDefault(cmd, OPTION_VERSION_SHORT, Release.CURRENT_RELEASE);
         int numShards = getOptionOrDefault(cmd, OPTION_SHARDS_SHORT, DEFAULT_SHARDS);
         int numReplicas = getOptionOrDefault(cmd, OPTION_REPLICAS_SHORT, DEFAULT_REPLICAS);
-        String dbUrl = getOptionOrDefault(cmd, "db", DEFAULT_DBURL);
-        String dbPrefix = getOptionOrDefault(cmd, "p", DEFAULT_DBPREFIX);
-        String username = getOptionOrDefault(cmd, "dbu", null);
-        String password = getOptionOrDefault(cmd, "dbp", null);
+        String dbUrl = getOptionOrDefault(cmd, OPTION_DATABASE_SHORT, DEFAULT_DBURL);
+        String dbPrefix = getOptionOrDefault(cmd, OPTION_DATABASEPREFIX_SHORT, DEFAULT_DBPREFIX);
+        String username = getOptionOrDefault(cmd, OPTION_DATABASEUSER_SHORT, null);
+        String password = getOptionOrDefault(cmd,OPTION_DATABASEPASSWORD_SHORT, null);
         boolean trustAll = getOptionOrDefault(cmd, OPTION_TRUSTINSECURESSL_SHORT, false);
+        long timeoutms = getOptionOrDefault(cmd, OPTION_DATABASEWAIT_SHORT, 30)*1000;
         DataMigrationProviderImpl service = new DataMigrationProviderImpl(new HostInfo[] { HostInfo.parse(dbUrl) },
-                username, password, trustAll);
-        long timeoutms = getOptionOrDefault(cmd, "w", 30)*1000;
+                username, password, trustAll, timeoutms);
         boolean forceRecreate = cmd.hasOption(OPTION_FORCE_RECREATE_SHORT);
         if (!service.initDatabase(r, numShards, numReplicas, dbPrefix, forceRecreate,timeoutms)) {
             throw new Exception("failed to init database");
@@ -307,24 +362,24 @@
 
     private static Options init() {
         Options result = new Options();
-        result.addOption(createOption("c", "cmd", true, "command to execute", true));
-        result.addOption(createOption(OPTION_DATABSE_SHORT, "dburl", true, "database url", false));
-        result.addOption(createOption("dbu", "db-username", true, "database basic auth username", false));
-        result.addOption(createOption("dbp", "db-password", true, "database basic auth password", false));
+        result.addOption(createOption(OPTION_COMMAND_SHORT, "cmd", true, "command to execute", false));
+        result.addOption(createOption(OPTION_DATABASE_SHORT, "dburl", true, "database url", false));
+        result.addOption(createOption(OPTION_DATABASEUSER_SHORT, "db-username", true, "database basic auth username", false));
+        result.addOption(createOption(OPTION_DATABASEPASSWORD_SHORT, "db-password", true, "database basic auth password", false));
         result.addOption(createOption(OPTION_REPLICAS_SHORT, "replicas", true, "amount of replicas", false));
         result.addOption(createOption(OPTION_SHARDS_SHORT, "shards", true, "amount of shards", false));
-        result.addOption(createOption("p", "prefix", true, "prefix for db indices", false));
+        result.addOption(createOption(OPTION_DATABASEPREFIX_SHORT, "prefix", true, "prefix for db indices", false));
         result.addOption(createOption(OPTION_VERSION_SHORT, "version", true, "version", false));
         result.addOption(createOption(OPTION_DEBUG_SHORT, "verbose", false, "verbose mode", false));
         result.addOption(createOption(OPTION_TRUSTINSECURESSL_SHORT, "trust-insecure", false,
                 "trust insecure ssl certs", false));
-        result.addOption(createOption("w", "wait", true, "wait for yellow status with timeout in seconds", false));
+        result.addOption(createOption(OPTION_DATABASEWAIT_SHORT, "wait", true, "wait for yellow status with timeout in seconds", false));
         result.addOption(
                 createOption(OPTION_FORCE_RECREATE_SHORT, "force-recreate", false, "delete if sth exists", false));
         result.addOption(createOption(OPTION_SILENT_SHORT, OPTION_SILENT, false, "prevent console output", false));
         result.addOption(createOption(OPTION_OUTPUTFILE_SHORT, "output-file", true, "file to write into", false));
         result.addOption(createOption(OPTION_INPUTFILE_SHORT, "input-file", true, "file to read from", false));
-
+        result.addOption(createOption(OPTION_HELP_SHORT,"help",false,"show help",false));
         return result;
     }
 
@@ -342,4 +397,5 @@
         o.setRequired(required);
         return o;
     }
+    // end of private methods
 }
diff --git a/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/ReleaseInformation.java b/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/ReleaseInformation.java
index f45d5e7..ccae07c 100644
--- a/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/ReleaseInformation.java
+++ b/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/ReleaseInformation.java
@@ -37,13 +37,17 @@
 
 public abstract class ReleaseInformation {
 
+	// variables
 	private final Release release;
 	private final Map<ComponentName, DatabaseInfo> dbMap;
+	// end of variables
 
+	// constructors
 	public ReleaseInformation(Release r, Map<ComponentName, DatabaseInfo> dbMap) {
 		this.release = r;
 		this.dbMap = dbMap;
 	}
+	// end of constructors
 
 	/**
 	 * get database alias for component
@@ -51,28 +55,37 @@
 	 * @return alias or null if not exists
 	 */
 	public String getAlias(ComponentName name) {
-		return this.getAlias(name,"");
+		return this.getAlias(name, "");
 	}
-	public String getAlias(ComponentName name,String prefix) {
-		return dbMap.get(name) == null ? null : prefix+dbMap.get(name).alias;
+
+	public String getAlias(ComponentName name, String prefix) {
+		return dbMap.get(name) == null ? null : prefix + dbMap.get(name).alias;
 	}
 
 	/**
-	 * @param c
-	 * @return
+	 * get index name for component
+	 * @param comp
+	 * @return null if component does not exists in this release, otherwise index name
 	 */
-	public String getIndex(ComponentName name) {
-		return this.getIndex(name,"");
-	}
-	public String getIndex(ComponentName name,String prefix) {
-		return dbMap.get(name) == null ? null : (prefix+dbMap.get(name).getIndex(this.release.getDBSuffix())); 
+	public String getIndex(ComponentName comp) {
+		return this.getIndex(comp, "");
 	}
 
 	/**
-		 * get database datatype (doctype) for component
-		 * @param name
-		 * @return datatype or null if not exists
-		 */
+	 * get index name for component with prefix 
+	 * @param comp
+	 * @param prefix
+	 * @return null if component does not exists in this release, otherwise index name
+	 */
+	public String getIndex(ComponentName comp, String prefix) {
+		return dbMap.get(comp) == null ? null : (prefix + dbMap.get(comp).getIndex(this.release.getDBSuffix()));
+	}
+
+	/**
+	 * get database datatype (doctype) for component
+	 * @param name
+	 * @return datatype or null if not exists
+	 */
 	public String getDataType(ComponentName name) {
 		return dbMap.get(name) == null ? null : dbMap.get(name).doctype;
 	}
@@ -80,20 +93,22 @@
 	public String getDatabaseMapping(ComponentName name) {
 		return dbMap.get(name) == null ? null : dbMap.get(name).getMapping();
 	}
-		/**
+
+	/**
 	 * get database doctype definition for component
 	 * @param name
 	 * @return mappings or null if not exists
 	 */
-	public String getDatabaseMapping(ComponentName name,boolean useStrict) {
+	public String getDatabaseMapping(ComponentName name, boolean useStrict) {
 		return dbMap.get(name) == null ? null : dbMap.get(name).getMapping(useStrict);
 	}
+
 	/**
 	 * get database settings definition for component
 	 * @param name
 	 * @return settings or null if not exists
 	 */
-	public String getDatabaseSettings(ComponentName name,int shards,int replicas) {
+	public String getDatabaseSettings(ComponentName name, int shards, int replicas) {
 		return dbMap.get(name) == null ? null : dbMap.get(name).getSettings(shards, replicas);
 	}
 
@@ -104,7 +119,7 @@
 	 * @return
 	 */
 	public SearchHitConverter getConverter(Release dst, ComponentName comp) {
-		if(dst==this.release && this.getComponents().contains(comp)) {
+		if (dst == this.release && this.getComponents().contains(comp)) {
 			return new KeepDataSearchHitConverter(comp);
 		}
 		return null;
@@ -135,7 +150,7 @@
 	 * @return
 	 */
 	public boolean hasOwnDbIndex(ComponentName component) {
-		return this.getDatabaseMapping(component)!=null;
+		return this.getDatabaseMapping(component) != null;
 	}
 
 	/**
@@ -143,18 +158,18 @@
 	 * @return true if components of this release are covered by the given indices
 	 */
 	protected boolean containsIndices(IndicesEntryList indices) {
-		
-		if(this.dbMap.size()<=0) {
+
+		if (this.dbMap.size() <= 0) {
 			return false;
 		}
-		for(DatabaseInfo entry:this.dbMap.values()) {
+		for (DatabaseInfo entry : this.dbMap.values()) {
 			String dbIndexName = entry.getIndex(this.release.getDBSuffix());
-			if(indices.findByIndex(dbIndexName)==null) {
+			if (indices.findByIndex(dbIndexName) == null) {
 				return false;
 			}
 		}
 		return true;
-		
+
 	}
 
 	/**
@@ -163,13 +178,11 @@
 	 */
 	protected abstract boolean runPreInitCommands(HtDatabaseClient dbClient);
 
-
 	/**
 	 * 
 	 * @param dbClient
 	 * @return if succeeded or not
 	 */
 	protected abstract boolean runPostInitCommands(HtDatabaseClient dbClient);
-	
 
 }
diff --git a/sdnr/wt/data-provider/setup/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/TestMigrationProvider.java b/sdnr/wt/data-provider/setup/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/TestMigrationProvider.java
index 483ca0b..1ec1911 100644
--- a/sdnr/wt/data-provider/setup/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/TestMigrationProvider.java
+++ b/sdnr/wt/data-provider/setup/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/TestMigrationProvider.java
@@ -37,23 +37,23 @@
  */
 public class TestMigrationProvider {
 
-	  private static final String FRANKFURT_BACKUP_FILE = "src/test/resources/test2.bak.json";
-	public static HostInfo[] hosts = new HostInfo[] { new HostInfo("localhost", Integer
-	            .valueOf(System.getProperty("databaseport") != null ? System.getProperty("databaseport") : "49200")) };
+      private static final String FRANKFURT_BACKUP_FILE = "src/test/resources/test2.bak.json";
+    public static HostInfo[] hosts = new HostInfo[] { new HostInfo("localhost", Integer
+                .valueOf(System.getProperty("databaseport") != null ? System.getProperty("databaseport") : "49200")) };
 
-	@Test
-	public void testCreateImport() {
-		DataMigrationProviderImpl provider = new DataMigrationProviderImpl(hosts, null, null,true);
-		
-		try {
-			//create el alto db infrastructure
-			provider.initDatabase(Release.FRANKFURT_R1, 5, 1, "", true,10000);
-			//import data into database
-			DataMigrationReport report = provider.importData(FRANKFURT_BACKUP_FILE, false, Release.FRANKFURT_R1);
-			assertTrue(report.completed());
-			assertEquals(Release.FRANKFURT_R1, provider.autoDetectRelease());
-		} catch (Exception e) {
-			fail(e.getMessage());
-		}
-	}
+    @Test
+    public void testCreateImport() {
+        DataMigrationProviderImpl provider = new DataMigrationProviderImpl(hosts, null, null,true,5000);
+
+        try {
+            //create el alto db infrastructure
+            provider.initDatabase(Release.FRANKFURT_R1, 5, 1, "", true,10000);
+            //import data into database
+            DataMigrationReport report = provider.importData(FRANKFURT_BACKUP_FILE, false, Release.FRANKFURT_R1);
+            assertTrue(report.completed());
+            assertEquals(Release.FRANKFURT_R1, provider.autoDetectRelease());
+        } catch (Exception e) {
+            fail(e.getMessage());
+        }
+    }
 }
