summaryrefslogtreecommitdiffstats
path: root/sdnr/wt/apigateway/provider
diff options
context:
space:
mode:
Diffstat (limited to 'sdnr/wt/apigateway/provider')
-rw-r--r--sdnr/wt/apigateway/provider/pom.xml92
-rw-r--r--sdnr/wt/apigateway/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/apigateway/AaiServlet.java82
-rw-r--r--sdnr/wt/apigateway/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/apigateway/BaseServlet.java366
-rw-r--r--sdnr/wt/apigateway/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/apigateway/EsServlet.java103
-rw-r--r--sdnr/wt/apigateway/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/apigateway/MyProperties.java247
-rw-r--r--sdnr/wt/apigateway/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/apigateway/SitedocServlet.java80
-rw-r--r--sdnr/wt/apigateway/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/apigateway/TerrainServlet.java79
-rw-r--r--sdnr/wt/apigateway/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/apigateway/TilesServlet.java89
-rw-r--r--sdnr/wt/apigateway/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/apigateway/TopologyServlet.java89
-rw-r--r--sdnr/wt/apigateway/provider/src/main/resources/org/opendaylight/blueprint/blueprint.xml58
-rw-r--r--sdnr/wt/apigateway/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/apigateway/test/TestAaiServlet.java87
-rw-r--r--sdnr/wt/apigateway/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/apigateway/test/TestDatabaseServlet.java93
-rw-r--r--sdnr/wt/apigateway/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/apigateway/test/TestProperties.java114
-rw-r--r--sdnr/wt/apigateway/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/apigateway/test/helper/HelpAaiServlet.java62
-rw-r--r--sdnr/wt/apigateway/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/apigateway/test/helper/HelpEsServlet.java63
-rw-r--r--sdnr/wt/apigateway/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/apigateway/test/helper/HelpServlet.java58
-rw-r--r--sdnr/wt/apigateway/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/apigateway/test/helper/HelpServletBase.java206
-rw-r--r--sdnr/wt/apigateway/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/apigateway/test/helper/IPublicServlet.java41
-rw-r--r--sdnr/wt/apigateway/provider/src/test/resources/log4j.properties33
19 files changed, 0 insertions, 2042 deletions
diff --git a/sdnr/wt/apigateway/provider/pom.xml b/sdnr/wt/apigateway/provider/pom.xml
deleted file mode 100644
index 6d34933fa..000000000
--- a/sdnr/wt/apigateway/provider/pom.xml
+++ /dev/null
@@ -1,92 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- ~ ============LICENSE_START=======================================================
- ~ ONAP : ccsdk features
- ~ ================================================================================
- ~ Copyright (C) 2018 highstreet technologies GmbH Intellectual Property.
- ~ All rights reserved.
- ~ ================================================================================
- ~ Update Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
- ~ ================================================================================
- ~ Licensed under the Apache License, Version 2.0 (the "License");
- ~ you may not use this file except in compliance with the License.
- ~ You may obtain a copy of the License at
- ~
- ~ http://www.apache.org/licenses/LICENSE-2.0
- ~
- ~ Unless required by applicable law or agreed to in writing, software
- ~ distributed under the License is distributed on an "AS IS" BASIS,
- ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- ~ See the License for the specific language governing permissions and
- ~ limitations under the License.
- ~ ============LICENSE_END=======================================================
- ~
- -->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>org.onap.ccsdk.parent</groupId>
- <artifactId>binding-parent</artifactId>
- <version>2.5.4</version>
- <relativePath/>
- </parent>
-
- <groupId>org.onap.ccsdk.features.sdnr.wt</groupId>
- <artifactId>sdnr-wt-apigateway-provider</artifactId>
- <version>1.6.0-SNAPSHOT</version>
- <packaging>bundle</packaging>
-
- <name>ccsdk-features :: ${project.artifactId}</name>
-
- <properties>
- <maven.javadoc.skip>true</maven.javadoc.skip>
- </properties>
-
- <dependencies>
- <dependency>
- <groupId>jakarta.servlet</groupId>
- <artifactId>jakarta.servlet-api</artifactId>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.osgi</groupId>
- <artifactId>org.osgi.core</artifactId>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.json</groupId>
- <artifactId>json</artifactId>
- </dependency>
- <dependency>
- <groupId>org.mockito</groupId>
- <artifactId>mockito-core</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>sdnr-wt-common</artifactId>
- <version>${project.version}</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.osgi</groupId>
- <artifactId>osgi.cmpn</artifactId>
- <version>7.0.0</version>
- <scope>compile</scope>
- </dependency>
- </dependencies>
-
- <build>
- <plugins>
- <!-- fixed bug for sonarcube -->
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-surefire-plugin</artifactId>
- <configuration>
- <useSystemClassLoader>false</useSystemClassLoader>
- </configuration>
- </plugin>
- </plugins>
- </build>
-</project>
diff --git a/sdnr/wt/apigateway/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/apigateway/AaiServlet.java b/sdnr/wt/apigateway/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/apigateway/AaiServlet.java
deleted file mode 100644
index 219e75a78..000000000
--- a/sdnr/wt/apigateway/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/apigateway/AaiServlet.java
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * ONAP : CCSDK.apps.sdnr.wt.apigateway
- * ================================================================================
- * 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.apigateway;
-
-import java.io.IOException;
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-public class AaiServlet extends BaseServlet {
-
- private static final long serialVersionUID = 5946205120796162644L;
- private static final String OFFLINE_RESPONSE_MESSAGE = "AAI interface is offline";
- private static boolean trustAll = false;
-
- public AaiServlet() {
- super();
- }
-
- @Override
- protected void doOptions(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
- resp.setStatus(200);
- }
-
- @Override
- protected String getOfflineResponse() {
- return OFFLINE_RESPONSE_MESSAGE;
- }
-
- @Override
- protected boolean isOff() {
- return MyProperties.getInstance().isAAIOff();
- }
-
- @Override
- protected String getRemoteUrl(String uri) {
-
- if (uri.startsWith("/")) {
- uri = uri.substring(1);
- }
- if (uri.startsWith("aai")) {
- uri = uri.substring("aai".length());
- }
- if (uri.startsWith("/")) {
- uri = uri.substring(1);
- }
- String base = MyProperties.getInstance().getAAIBaseUrl();
- if (!base.endsWith("/")) {
- base += "/";
- }
-
- return base + uri;
- }
-
- @Override
- protected boolean doTrustAll() {
- return trustAll;
- }
-
- @Override
- protected void trustAll(boolean trust) {
- trustAll = trust;
- }
-}
diff --git a/sdnr/wt/apigateway/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/apigateway/BaseServlet.java b/sdnr/wt/apigateway/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/apigateway/BaseServlet.java
deleted file mode 100644
index 7c8a9a1d9..000000000
--- a/sdnr/wt/apigateway/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/apigateway/BaseServlet.java
+++ /dev/null
@@ -1,366 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * ONAP : CCSDK.apps.sdnr.wt.apigateway
- * ================================================================================
- * 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.apigateway;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.net.HttpURLConnection;
-import java.net.URL;
-import java.net.URLConnection;
-import java.nio.charset.StandardCharsets;
-import java.security.KeyManagementException;
-import java.security.NoSuchAlgorithmException;
-import java.util.Enumeration;
-import java.util.List;
-import java.util.Map;
-import javax.net.ssl.HostnameVerifier;
-import javax.net.ssl.HttpsURLConnection;
-import javax.net.ssl.SSLContext;
-import javax.net.ssl.TrustManager;
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServlet;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public abstract class BaseServlet extends HttpServlet {
-
- private static final long serialVersionUID = 7403047480257892794L;
- private static Logger LOG = LoggerFactory.getLogger(BaseServlet.class);
- private static SSLContext sc;
- private static TrustManager[] trustCerts = null;
- private static final int BUFSIZE = 2048;
-
- protected abstract String getOfflineResponse();
-
- protected abstract boolean isOff();
-
- protected abstract boolean doTrustAll();
-
- protected abstract void trustAll(boolean trust);
-
- protected abstract String getRemoteUrl(String uri);
-
- private static void setupSslTrustAll(boolean trustall) throws NoSuchAlgorithmException, KeyManagementException {
-
- sc = SSLContext.getInstance("TLSv1.2");
- if (trustall) {
- if (trustCerts == null) {
- trustCerts = new TrustManager[] {new javax.net.ssl.X509TrustManager() {
- @Override
- public java.security.cert.X509Certificate[] getAcceptedIssuers() {
- return new java.security.cert.X509Certificate[] {};
- }
-
- @Override
- public void checkClientTrusted(java.security.cert.X509Certificate[] certs, String authType) {
- // do not check anything when trust all
- }
-
- @Override
- public void checkServerTrusted(java.security.cert.X509Certificate[] certs, String authType) {
- // do not check anything when trust all
- }
- }};
- }
- } else {
- if (trustCerts != null) {
- trustCerts = null;
- }
- }
- // Init the SSLContext with a TrustManager[] and SecureRandom()
- sc.init(null, trustCerts, new java.security.SecureRandom());
- }
-
- public BaseServlet() {
- try {
- MyProperties.Instantiate();
- } catch (Exception e) {
- LOG.error(e.getMessage());
- }
- this.trysslSetup(true);
- }
-
- private void trysslSetup() {
- this.trysslSetup(false);
- }
-
- /**
- * init or deinit ssl insecure mode regarding to property
- *
- * @param force init independent from property
- */
- private void trysslSetup(boolean force) {
- // if trustall config has changed
- boolean trustAll = MyProperties.getInstance().trustInsecure();
- if (force || this.doTrustAll() != trustAll) {
- this.trustAll(trustAll);
- // resetup ssl config
- try {
- setupSslTrustAll(trustAll);
- } catch (Exception e) {
- LOG.error("problem setting up SSL: {}", e.getMessage());
- }
- }
- }
-
- protected void sendOffResponse(HttpServletResponse response) {
- response.setStatus(200);// HTML/OK
- response.setHeader("Content-Type", "text/html; charset=utf-8");
- try {
- response.getOutputStream().write(this.getOfflineResponse().getBytes(StandardCharsets.UTF_8));
- } catch (IOException e) {
- LOG.debug("problem writing offline response");
- }
-
- }
-
- @Override
- protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
- if (this.isOff()) {
- this.sendOffResponse(resp);
- } else {
- this.trysslSetup();
- HttpURLConnection http = null;
- try {
- http = (HttpURLConnection) this.getConnection(req, "GET");
- } catch (IOException e) {
- LOG.warn(e.getMessage());
- }
- if (http != null) {
- try {
- this.handleRequest(http, req, resp, "GET");
- } catch (IOException e) {
- LOG.warn(e.getMessage());
- }
- http.disconnect();
- } else {
- this.set404Response(resp);
- }
- }
- }
-
- @Override
- protected void doPut(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
- if (this.isOff()) {
- this.sendOffResponse(resp);
- } else {
- this.trysslSetup();
- HttpURLConnection http = null;
- try {
- http = (HttpURLConnection) this.getConnection(req, "PUT");
- } catch (IOException e) {
- LOG.warn(e.getMessage());
- }
- if (http != null) {
- try {
- this.handleRequest(http, req, resp, "PUT");
- } catch (IOException e) {
- LOG.warn(e.getMessage());
- }
- http.disconnect();
- } else {
- this.set404Response(resp);
- }
- }
- }
-
- @Override
- protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
- if (this.isOff()) {
- this.sendOffResponse(resp);
- } else {
- this.trysslSetup();
- HttpURLConnection http = null;
- try {
- http = (HttpURLConnection) this.getConnection(req, "POST");
- } catch (IOException e) {
- LOG.warn(e.getMessage());
- }
- if (http != null) {
- try {
- this.handleRequest(http, req, resp, "POST");
- } catch (IOException e) {
- LOG.warn(e.getMessage());
- }
- http.disconnect();
- } else {
- this.set404Response(resp);
- }
- }
- }
-
- @Override
- protected void doDelete(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
- if (this.isOff()) {
- this.sendOffResponse(resp);
- } else {
- this.trysslSetup();
- HttpURLConnection http = null;
- try {
- http = (HttpURLConnection) this.getConnection(req, "DELETE");
- } catch (IOException e) {
- LOG.warn(e.getMessage());
- }
- if (http != null) {
- try {
- this.handleRequest(http, req, resp, "DELETE");
- } catch (IOException e) {
- LOG.warn(e.getMessage());
- }
- http.disconnect();
- } else {
- this.set404Response(resp);
- }
- }
- }
-
- private void set404Response(HttpServletResponse resp) {
- resp.setStatus(404);
- }
-
- private URLConnection getConnection(HttpServletRequest req, final String method) throws IOException {
-
- LOG.debug("{} Request to {}", method, req.getRequestURL());
- String surl = this.getRemoteUrl(req.getRequestURI());
- if ("GET".equals(method)) {
- Enumeration<?> params = req.getParameterNames();
- if (params != null) {
- String param;
- if (params.hasMoreElements()) {
- param = (String) params.nextElement();
- surl += "?" + param + "=" + req.getParameter(param);
- }
- while (params.hasMoreElements()) {
- param = (String) params.nextElement();
- surl += "&" + param + "=" + req.getParameter(param);
- }
- }
- }
- LOG.debug("RemoteURL: {}", surl);
- if (surl == null) {
- return null;
- }
- URL url = new URL(surl);
- URLConnection http = url.openConnection();
- ((HttpURLConnection) http).setRequestMethod(method);
- if (url.toString().startsWith("https")) {
- ((HttpsURLConnection) http).setSSLSocketFactory(sc.getSocketFactory());
- if (this.doTrustAll()) {
- HostnameVerifier allHostsValid = (hostname, session) -> true;
- ((HttpsURLConnection) http).setHostnameVerifier(allHostsValid);
- }
- }
- http.setDoOutput(true);
- // copy request headers
- String s = "";
- Enumeration<?> headers = req.getHeaderNames();
- while (headers.hasMoreElements()) {
- String h = (String) headers.nextElement();
- String v = req.getHeader(h);
- if (h != null && h.equals("Host")) {
- v = url.getAuthority();
- }
- s += String.format("%s:%s;", h, v);
- http.setRequestProperty(h, v);
- }
- LOG.debug("Request Headers: {}", s);
- return http;
- }
-
- private void handleRequest(HttpURLConnection http, HttpServletRequest req, HttpServletResponse resp, String method)
- throws IOException {
- byte[] buffer = new byte[BUFSIZE];
- int len = 0, lensum = 0;
- // send request
- // Send the message to destination
- OutputStream output = null;
- if (!method.equals("GET")) {
- try {
- output = http.getOutputStream();
- } catch (Exception e) {
- LOG.debug("problem reading output stream: {}", e.getMessage());
- }
- }
- if (output != null) {
- while (true) {
- len = req.getInputStream().read(buffer, 0, BUFSIZE);
- if (len <= 0) {
- break;
- }
- lensum += len;
- output.write(buffer, 0, len);
- }
- }
- LOG.debug("written {} data out", lensum);
- int responseCode = http.getResponseCode();
- // Receive answer
- InputStream response;
- if (responseCode >= 200 && responseCode < 300) {
- response = http.getInputStream();
- } else {
- response = http.getErrorStream();
- if (response == null) {
- http.getInputStream();
- }
- }
-
- LOG.debug("ResponseCode: {}", responseCode);
- resp.setStatus(responseCode);
- Map<String, List<String>> set = http.getHeaderFields();
- String s = "";
- if (set != null) {
- for (Map.Entry<String, List<String>> entry : set.entrySet()) {
- if (entry.getKey() == null) {
- continue;
- }
- for (String v : entry.getValue()) {
- resp.setHeader(entry.getKey(), v);
- s += String.format("%s:%s;", entry.getKey(), v);
- }
- if (MyProperties.getInstance().corsEnabled()) {
- resp.setHeader("Access-Control-Allow-Origin", "*");
- // resp.setHeader("Access-Control-Allow-Methods", "GET,PUT,POST,DELETE");
- resp.setHeader("Access-Control-Allow-Headers", "Content-Type, Authorization");
- }
-
- }
- }
- LOG.debug("Received Headers: {}", s);
- lensum = 0;
- if (response != null) {
- while (true) {
- len = response.read(buffer, 0, BUFSIZE);
- if (len <= 0) {
- break;
- }
- lensum += len;
- resp.getOutputStream().write(buffer, 0, len);
- }
- } else {
- LOG.debug("response is null");
- }
- LOG.debug("Received {} bytes", lensum);
- }
-
-}
diff --git a/sdnr/wt/apigateway/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/apigateway/EsServlet.java b/sdnr/wt/apigateway/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/apigateway/EsServlet.java
deleted file mode 100644
index e1a9ae0f8..000000000
--- a/sdnr/wt/apigateway/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/apigateway/EsServlet.java
+++ /dev/null
@@ -1,103 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * ONAP : CCSDK.apps.sdnr.wt.apigateway
- * ================================================================================
- * 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.apigateway;
-
-import java.io.IOException;
-import javax.servlet.Servlet;
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import org.osgi.service.component.annotations.Component;
-import org.osgi.service.http.whiteboard.propertytypes.HttpWhiteboardServletName;
-import org.osgi.service.http.whiteboard.propertytypes.HttpWhiteboardServletPattern;
-
-@HttpWhiteboardServletPattern("/database/*")
-@HttpWhiteboardServletName("EsServlet")
-@Component(service = Servlet.class)
-public class EsServlet extends BaseServlet {
-
- private static final long serialVersionUID = -3996363343749995011L;
- private static final String OFFLINE_RESPONSE_MESSAGE = "Database interface is offline";
-
- private static boolean trustAll = false;
-
- public EsServlet() {
- super();
- }
-
- @Override
- protected void doOptions(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
- if (MyProperties.getInstance().corsEnabled()) {
- resp.addHeader("Access-Control-Allow-Origin", "*");
- resp.addHeader("Access-Control-Allow-Methods", "GET,PUT,POST,DELETE");
- resp.addHeader("Access-Control-Allow-Headers", "Content-Type, Authorization");
- }
- resp.setStatus(200);
- }
-
- @Override
- protected String getOfflineResponse() {
- return OFFLINE_RESPONSE_MESSAGE;
- }
-
- @Override
- protected boolean isOff() {
- return MyProperties.getInstance().isEsOff();
- }
-
- @Override
- protected String getRemoteUrl(String uri) {
- if (uri != null && uri.length() > 0) {
- uri = uri.substring("/database".length());
- }
- return MyProperties.getInstance().getEsBaseUrl() + uri;
- }
-
- @Override
- protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
- super.doGet(req, resp);
- }
-
- @Override
- protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
- super.doPost(req, resp);
- }
-
- @Override
- protected void doPut(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
- super.doPut(req, resp);
- }
-
- @Override
- protected void doDelete(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
- super.doDelete(req, resp);
- }
-
- @Override
- protected boolean doTrustAll() {
- return trustAll;
- }
-
- @Override
- protected void trustAll(boolean trust) {
- trustAll = trust;
- }
-}
diff --git a/sdnr/wt/apigateway/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/apigateway/MyProperties.java b/sdnr/wt/apigateway/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/apigateway/MyProperties.java
deleted file mode 100644
index 560330f85..000000000
--- a/sdnr/wt/apigateway/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/apigateway/MyProperties.java
+++ /dev/null
@@ -1,247 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * ONAP : CCSDK.apps.sdnr.wt.apigateway
- * ================================================================================
- * 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.apigateway;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Properties;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-import org.json.JSONArray;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class MyProperties {
-
- private static Logger LOG = LoggerFactory.getLogger(MyProperties.class);
- public static final String PROPFILE = "etc/apigateway.properties";
- private static final String DEFAULT_AAI_HEADERS = "[\"X-FromAppId:SDNR\",\"Authorization:Basic QUFJOkFBSQ==\"]";
- private static final String DEFAULT_CORSENABLED = "0";
- private static final String DEFAULT_TRUSTINSECURE = "0";
- private static final String DEFAULT_ESDATABASE = "http://sdnrdb:9200";
- private static final String DEFAULT_AAI = "off";
- private static final String DEFAULT_URL_OFF = "off";
- private static final String DEFAULT_TILES = "${TILEURL}";
- private static final String DEFAULT_TOPOLOGY = "${TOPOURL}";
- private static final String DEFAULT_SITEDOC = "${SITEDOCURL}";
- private static final String DEFAULT_TERRAIN = "${TERRAINURL}";
-
- private static MyProperties mObj;
- private static final String ENVVARIABLE = "${";
- private static final String REGEXENVVARIABLE = "(\\$\\{[A-Z0-9_-]+\\})";
- private static final Pattern ENV_PATTERN = Pattern.compile(REGEXENVVARIABLE);
-
-
- private String aaiBase;
- private Map<String, String> aaiHeaders;
- private String esBase;
- private String tilesBase;
- private String topologyBase;
- private String sitedocBase;
- private String terrainBase;
-
- private boolean trustInsecure;
- private boolean corsEnabled;
-
- public boolean isAAIOff() {
- return this.aaiBase == null ? true : this.aaiBase.equals("off");
- }
-
- public boolean isEsOff() {
- return this.esBase == null ? true : this.esBase.equals("off");
- }
-
- public boolean isTilesOff() {
- return this.tilesBase == null ? true : this.tilesBase.equals("off");
- }
-
- public boolean isTopologyOff() {
- return this.topologyBase == null ? true : this.topologyBase.equals("off");
- }
-
- public String getAAIBaseUrl() {
- return this.aaiBase;
- }
-
- public String getEsBaseUrl() {
- return this.esBase;
- }
-
- public String getTilesBaseUrl() {
- return this.tilesBase;
- }
-
- public String getTopologyBaseUrl() {
- return this.topologyBase;
- }
- public String getSitedocBaseUrl() {
- return this.sitedocBase;
- }
-
- public String getTerrainBaseUrl() {
- return this.terrainBase;
- }
-
- public Map<String, String> getAAIHeaders() {
- return this.aaiHeaders;
- }
-
- public boolean trustInsecure() {
- return this.trustInsecure;
- }
-
- public boolean corsEnabled() {
- return this.corsEnabled;
- }
-
- public static MyProperties Instantiate() throws IOException, NumberFormatException {
- return Instantiate(new File(PROPFILE));
- }
-
- public static MyProperties Instantiate(File file) throws IOException, NumberFormatException {
-
- return Instantiate(file, false);
- }
-
- public static MyProperties Instantiate(File file, boolean force) throws IOException, NumberFormatException {
- if (mObj == null || force) {
- mObj = new MyProperties(file);
- LOG.debug("instantiated: {}", mObj.toString());
- }
- return mObj;
- }
-
- private MyProperties(File file) throws IOException, NumberFormatException {
- this.aaiBase = DEFAULT_AAI;
- this.trustInsecure = false;
- if (!file.exists()) {
- this.writeDefaults(file);
- }
- this.load(new FileInputStream(file));
- }
-
- public void load(InputStream in) throws IOException, NumberFormatException {
-
- Properties defaultProps = new Properties();
- defaultProps.load(in);
- in.close();
-
- this.aaiBase = getProperty(defaultProps,"aai", DEFAULT_AAI);
- this.aaiHeaders = parseHeadersMap(getProperty(defaultProps,"aaiHeaders", DEFAULT_AAI_HEADERS));
- this.esBase = getProperty(defaultProps,"database", DEFAULT_ESDATABASE);
- this.tilesBase = getProperty(defaultProps,"tiles", DEFAULT_TILES, DEFAULT_URL_OFF);
- this.topologyBase = getProperty(defaultProps,"topology", DEFAULT_TOPOLOGY, DEFAULT_URL_OFF);
- this.sitedocBase = getProperty(defaultProps,"sitedoc", DEFAULT_SITEDOC, DEFAULT_URL_OFF);
- this.terrainBase = getProperty(defaultProps,"terrain", DEFAULT_TERRAIN, DEFAULT_URL_OFF);
- this.trustInsecure = Integer.parseInt(getProperty(defaultProps,"insecure", DEFAULT_TRUSTINSECURE)) == 1;
- this.corsEnabled = Integer.parseInt(getProperty(defaultProps,"cors", DEFAULT_CORSENABLED)) == 1;
- }
- private static String getProperty(Properties props,final String key, final String defValue) {
- return getProperty(props, key, defValue, null);
- }
- private static String getProperty(Properties props,final String key, final String defValue, final String valueIfEmpty) {
-
- LOG.debug("try to get property for {} with def {}", key, defValue);
- String value = props.getProperty(key,defValue);
- //try to read env var
- if (value != null && value.contains(ENVVARIABLE)) {
-
- LOG.debug("try to find env var(s) for {}", value);
- final Matcher matcher = ENV_PATTERN.matcher(value);
- String tmp = new String(value);
- while (matcher.find() && matcher.groupCount() > 0) {
- final String mkey = matcher.group(1);
- if (mkey != null) {
- try {
- LOG.debug("match found for v={} and env key={}", tmp, mkey);
- //String env=System.getenv(mkey.substring(2,mkey.length()-1));
- String env = System.getenv(mkey.substring(2, mkey.length() - 1));
- tmp = tmp.replace(mkey, env == null ? "" : env);
- } catch (SecurityException e) {
- LOG.warn("unable to read env {}: {}", value, e);
- }
- }
- }
- value = tmp;
- }
- if((value==null || value.isEmpty()) && valueIfEmpty!=null) {
- value = valueIfEmpty;
- }
- return value;
- }
- private static Map<String, String> parseHeadersMap(String s) {
- Map<String, String> r = new HashMap<>();
- try {
- JSONArray a = new JSONArray(s);
- if (a.length() > 0) {
- for (int i = 0; i < a.length(); i++) {
- String item = a.getString(i);
- String[] hlp = item.split(":");
- if (hlp.length > 1) {
- r.put(hlp[0], hlp[1]);
- }
- }
- }
- } catch (Exception e) {
- LOG.warn("problem loading headers map: {}", e.getMessage());
- }
- return r;
- }
-
- private String writeDefaults(File f) throws IOException {
- StringBuilder sb = new StringBuilder();
- final String LR = "\n";
- FileWriter fw = new FileWriter(f);
- sb.append("aai=" + DEFAULT_AAI + LR);
- sb.append("aaiHeaders=" + DEFAULT_AAI_HEADERS + LR);
- sb.append("database=" + DEFAULT_ESDATABASE + LR);
- sb.append("tiles=" + DEFAULT_TILES + LR);
- sb.append("topology=" + DEFAULT_TOPOLOGY + LR);
- sb.append("terrain=" + DEFAULT_TERRAIN + LR);
- sb.append("insecure=" + DEFAULT_TRUSTINSECURE + LR);
- sb.append("cors=" + DEFAULT_CORSENABLED);
- try {
- fw.write(sb.toString());
- } catch (Exception e) {
- LOG.warn("problem writing default values to propertyfile {} : {}", f.getAbsolutePath(), e.getMessage());
- } finally {
- fw.close();
- }
- return sb.toString();
- }
-
- public static MyProperties getInstance() {
- return mObj;
- }
-
- @Override
- public String toString() {
- return "MyProperties [aaiBase=" + aaiBase + ", aaiHeaders=" + aaiHeaders + ", esBase=" + esBase
- + ", trustInsecure=" + trustInsecure + ", corsEnabled=" + corsEnabled + "]";
- }
-
-
-}
diff --git a/sdnr/wt/apigateway/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/apigateway/SitedocServlet.java b/sdnr/wt/apigateway/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/apigateway/SitedocServlet.java
deleted file mode 100644
index d96ddb613..000000000
--- a/sdnr/wt/apigateway/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/apigateway/SitedocServlet.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * ONAP : CCSDK.apps.sdnr.wt.apigateway
- * ================================================================================
- * 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.apigateway;
-
-import java.io.IOException;
-import javax.servlet.Servlet;
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import org.osgi.service.component.annotations.Component;
-import org.osgi.service.http.whiteboard.propertytypes.HttpWhiteboardServletName;
-import org.osgi.service.http.whiteboard.propertytypes.HttpWhiteboardServletPattern;
-
-@HttpWhiteboardServletPattern("/sitedoc/*")
-@HttpWhiteboardServletName("SitedocServlet")
-@Component(service = Servlet.class)
-public class SitedocServlet extends BaseServlet {
-
- private static final long serialVersionUID = 5946205120796162644L;
- private static final String OFFLINE_RESPONSE_MESSAGE = "Topology interface is offline";
- private static final String BASEURL = "/sitedoc";
- private static final String SITEDOC_SUBPATH = "/topology/stadok";
- private static boolean trustAll = false;
-
- public SitedocServlet() {
- super();
- }
-
- @Override
- protected void doOptions(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
- resp.setStatus(200);
- }
-
- @Override
- protected String getOfflineResponse() {
- return OFFLINE_RESPONSE_MESSAGE;
- }
-
- @Override
- protected boolean isOff() {
- return MyProperties.getInstance().isTopologyOff();
- }
-
- @Override
- protected String getRemoteUrl(String uri) {
-
- if (uri != null && uri.length() > 0) {
- uri = uri.substring(BASEURL.length());
- }
- return MyProperties.getInstance().getSitedocBaseUrl() + SITEDOC_SUBPATH + uri;
- }
-
- @Override
- protected boolean doTrustAll() {
- return trustAll;
- }
-
- @Override
- protected void trustAll(boolean trust) {
- trustAll = trust;
- }
-}
diff --git a/sdnr/wt/apigateway/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/apigateway/TerrainServlet.java b/sdnr/wt/apigateway/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/apigateway/TerrainServlet.java
deleted file mode 100644
index 5b5cc8ab9..000000000
--- a/sdnr/wt/apigateway/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/apigateway/TerrainServlet.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * ONAP : CCSDK.apps.sdnr.wt.apigateway
- * ================================================================================
- * 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.apigateway;
-
-import java.io.IOException;
-import javax.servlet.Servlet;
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import org.osgi.service.component.annotations.Component;
-import org.osgi.service.http.whiteboard.propertytypes.HttpWhiteboardServletName;
-import org.osgi.service.http.whiteboard.propertytypes.HttpWhiteboardServletPattern;
-
-@HttpWhiteboardServletPattern("/terrain/*")
-@HttpWhiteboardServletName("TerrainServlet")
-@Component(service = Servlet.class)
-public class TerrainServlet extends BaseServlet {
-
- private static final long serialVersionUID = 5946205120796162644L;
- private static final String OFFLINE_RESPONSE_MESSAGE = "Terrain interface is offline";
- private static final String BASEURL = "/terrain";
- private static boolean trustAll = false;
-
- public TerrainServlet() {
- super();
- }
-
- @Override
- protected void doOptions(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
- resp.setStatus(200);
- }
-
- @Override
- protected String getOfflineResponse() {
- return OFFLINE_RESPONSE_MESSAGE;
- }
-
- @Override
- protected boolean isOff() {
- return MyProperties.getInstance().isTopologyOff();
- }
-
- @Override
- protected String getRemoteUrl(String uri) {
-
- if (uri != null && uri.length() > 0) {
- uri = uri.substring(BASEURL.length());
- }
- return MyProperties.getInstance().getTerrainBaseUrl() + uri;
- }
-
- @Override
- protected boolean doTrustAll() {
- return trustAll;
- }
-
- @Override
- protected void trustAll(boolean trust) {
- trustAll = trust;
- }
-}
diff --git a/sdnr/wt/apigateway/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/apigateway/TilesServlet.java b/sdnr/wt/apigateway/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/apigateway/TilesServlet.java
deleted file mode 100644
index 1978d7c6f..000000000
--- a/sdnr/wt/apigateway/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/apigateway/TilesServlet.java
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * ONAP : CCSDK.apps.sdnr.wt.apigateway
- * ================================================================================
- * 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.apigateway;
-
-import java.io.IOException;
-import javax.servlet.Servlet;
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import org.osgi.service.component.annotations.Component;
-import org.osgi.service.http.whiteboard.propertytypes.HttpWhiteboardServletName;
-import org.osgi.service.http.whiteboard.propertytypes.HttpWhiteboardServletPattern;
-
-@HttpWhiteboardServletPattern("/tiles/*")
-@HttpWhiteboardServletName("TilesServlet")
-@Component(service = Servlet.class)
-public class TilesServlet extends BaseServlet {
-
- private static final long serialVersionUID = 5946205120796162644L;
- private static final String OFFLINE_RESPONSE_MESSAGE = "Tiles interface is offline";
- private static boolean trustAll = false;
-
- public TilesServlet() {
- super();
- }
-
- @Override
- protected void doOptions(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
- resp.setStatus(200);
- }
-
- @Override
- protected String getOfflineResponse() {
- return OFFLINE_RESPONSE_MESSAGE;
- }
-
- @Override
- protected boolean isOff() {
- return MyProperties.getInstance().isTilesOff();
- }
-
- @Override
- protected String getRemoteUrl(String uri) {
-
- if (uri.startsWith("/")) {
- uri = uri.substring(1);
- }
- if (uri.startsWith("tiles")) {
- uri = uri.substring("tiles".length());
- }
- if (uri.startsWith("/")) {
- uri = uri.substring(1);
- }
- String base = MyProperties.getInstance().getTilesBaseUrl();
- if (!base.endsWith("/")) {
- base += "/";
- }
-
- return base + uri;
- }
-
- @Override
- protected boolean doTrustAll() {
- return trustAll;
- }
-
- @Override
- protected void trustAll(boolean trust) {
- trustAll = trust;
- }
-}
diff --git a/sdnr/wt/apigateway/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/apigateway/TopologyServlet.java b/sdnr/wt/apigateway/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/apigateway/TopologyServlet.java
deleted file mode 100644
index 0350d966b..000000000
--- a/sdnr/wt/apigateway/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/apigateway/TopologyServlet.java
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * ONAP : CCSDK.apps.sdnr.wt.apigateway
- * ================================================================================
- * 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.apigateway;
-
-import java.io.IOException;
-import javax.servlet.Servlet;
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import org.osgi.service.component.annotations.Component;
-import org.osgi.service.http.whiteboard.propertytypes.HttpWhiteboardServletName;
-import org.osgi.service.http.whiteboard.propertytypes.HttpWhiteboardServletPattern;
-
-@HttpWhiteboardServletPattern("/topology/*")
-@HttpWhiteboardServletName("TopologyServlet")
-@Component(service = Servlet.class)
-public class TopologyServlet extends BaseServlet {
-
- private static final long serialVersionUID = 5946205120796162644L;
- private static final String OFFLINE_RESPONSE_MESSAGE = "Topology interface is offline";
- private static boolean trustAll = false;
-
- public TopologyServlet() {
- super();
- }
-
- @Override
- protected void doOptions(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
- resp.setStatus(200);
- }
-
- @Override
- protected String getOfflineResponse() {
- return OFFLINE_RESPONSE_MESSAGE;
- }
-
- @Override
- protected boolean isOff() {
- return MyProperties.getInstance().isTopologyOff();
- }
-
- @Override
- protected String getRemoteUrl(String uri) {
-
- if (uri.startsWith("/")) {
- uri = uri.substring(1);
- }
- if (uri.startsWith("topology")) {
- uri = uri.substring("topology".length());
- }
- if (uri.startsWith("/")) {
- uri = uri.substring(1);
- }
- String base = MyProperties.getInstance().getTopologyBaseUrl();
- if (!base.endsWith("/")) {
- base += "/";
- }
-
- return base + uri;
- }
-
- @Override
- protected boolean doTrustAll() {
- return trustAll;
- }
-
- @Override
- protected void trustAll(boolean trust) {
- trustAll = trust;
- }
-}
diff --git a/sdnr/wt/apigateway/provider/src/main/resources/org/opendaylight/blueprint/blueprint.xml b/sdnr/wt/apigateway/provider/src/main/resources/org/opendaylight/blueprint/blueprint.xml
deleted file mode 100644
index a6166b433..000000000
--- a/sdnr/wt/apigateway/provider/src/main/resources/org/opendaylight/blueprint/blueprint.xml
+++ /dev/null
@@ -1,58 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- ~ ============LICENSE_START=======================================================
- ~ ONAP : ccsdk features
- ~ ================================================================================
- ~ Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
- ~ ================================================================================
- ~ Licensed under the Apache License, Version 2.0 (the "License");
- ~ you may not use this file except in compliance with the License.
- ~ You may obtain a copy of the License at
- ~
- ~ http://www.apache.org/licenses/LICENSE-2.0
- ~
- ~ Unless required by applicable law or agreed to in writing, software
- ~ distributed under the License is distributed on an "AS IS" BASIS,
- ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- ~ See the License for the specific language governing permissions and
- ~ limitations under the License.
- ~ ============LICENSE_END=======================================================
- ~
- -->
-
-<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0">
-
- <bean id="aaiServlet"
- class="org.onap.ccsdk.features.sdnr.wt.apigateway.AaiServlet">
- </bean>
-
-
- <bean id="esServlet"
- class="org.onap.ccsdk.features.sdnr.wt.apigateway.EsServlet">
- </bean>
-
-
- <bean id="tilesServlet"
- class="org.onap.ccsdk.features.sdnr.wt.apigateway.TilesServlet">
- </bean>
-
-
- <bean id="topologyServlet"
- class="org.onap.ccsdk.features.sdnr.wt.apigateway.TopologyServlet">
- </bean>
-
-
- <bean id="sitedocServlet"
- class="org.onap.ccsdk.features.sdnr.wt.apigateway.SitedocServlet">
- </bean>
-
- <bean id="terrainServlet"
- class="org.onap.ccsdk.features.sdnr.wt.apigateway.TerrainServlet">
- </bean>
-
- <!-- <service interface="javax.servlet.http.HttpServlet" ref="terrainServlet">
- <service-properties>
- <entry key="alias" value="/terrain"/>
- </service-properties>
- </service>-->
-</blueprint>
diff --git a/sdnr/wt/apigateway/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/apigateway/test/TestAaiServlet.java b/sdnr/wt/apigateway/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/apigateway/test/TestAaiServlet.java
deleted file mode 100644
index 3436c36f2..000000000
--- a/sdnr/wt/apigateway/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/apigateway/test/TestAaiServlet.java
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * ONAP : CCSDK.apps.sdnr.wt.apigateway
- * ================================================================================
- * 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.apigateway.test;
-
-import java.io.ByteArrayInputStream;
-import java.io.File;
-import java.io.IOException;
-import javax.servlet.ServletException;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.onap.ccsdk.features.sdnr.wt.apigateway.MyProperties;
-import org.onap.ccsdk.features.sdnr.wt.apigateway.test.helper.HelpAaiServlet;
-import org.onap.ccsdk.features.sdnr.wt.apigateway.test.helper.HelpEsServlet;
-import org.onap.ccsdk.features.sdnr.wt.apigateway.test.helper.HelpServletBase;
-
-public class TestAaiServlet extends HelpServletBase {
-
- private static final int PORT = 40001;
-
- public TestAaiServlet() {
- super("/aai", PORT);
- }
-
- @Test
- public void test() throws ServletException, IOException {
-
- String tmpFilename = "tmp.cfg";
- File tmpFile = new File(tmpFilename);
- if (tmpFile.exists())
- tmpFile.delete();
- MyProperties properties = MyProperties.Instantiate(tmpFile, true);
- String query = "{\"query\":{\"match_all\":{}}}";
- String tmpconfigcontent =
- "aai=off" + LR + "aaiHeaders=[]" + LR + "database=off" + LR + "insecure=0" + LR + "cors=0";
- String tmpconfigcontent2 = "aai=http://" + HOST + ":" + PORT + LR + "aaiHeaders=[]" + LR + "database=off" + LR
- + "insecure=1" + LR + "cors=1";
- this.setServlet(new HelpAaiServlet());
- // test disabled message
- properties.load(new ByteArrayInputStream(tmpconfigcontent.getBytes()));
- String expectedResponse = "offline";
- testrequest(HTTPMETHOD_GET, query, expectedResponse, false);
- testrequest(HTTPMETHOD_POST, query, expectedResponse, false);
- testrequest(HTTPMETHOD_PUT, query, expectedResponse, false);
- testrequest(HTTPMETHOD_DELETE, query, expectedResponse, false);
-
- // initEsTestWebserver(port);
- properties.load(new ByteArrayInputStream(tmpconfigcontent2.getBytes()));
- testrequest(HTTPMETHOD_GET, query, HelpEsServlet.RESPONSE_GET, true);
- testrequest(HTTPMETHOD_POST, query, HelpEsServlet.RESPONSE_POST, true);
- testrequest(HTTPMETHOD_PUT, query, HelpEsServlet.RESPONSE_PUT, true);
- testrequest(HTTPMETHOD_DELETE, query, HelpEsServlet.RESPONSE_DELETE, true);
- testrequest(HTTPMETHOD_OPTIONS, query, "", false);
- // stopTestWebserver();
- if (tmpFile.exists())
- tmpFile.delete();
-
- }
-
- @Before
- public void init() throws IOException {
- HelpServletBase.initEsTestWebserver(PORT);
- }
-
- @After
- public void deinit() {
- HelpServletBase.stopTestWebserver();
- }
-}
diff --git a/sdnr/wt/apigateway/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/apigateway/test/TestDatabaseServlet.java b/sdnr/wt/apigateway/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/apigateway/test/TestDatabaseServlet.java
deleted file mode 100644
index 45eac88cd..000000000
--- a/sdnr/wt/apigateway/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/apigateway/test/TestDatabaseServlet.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * ONAP : CCSDK.apps.sdnr.wt.apigateway
- * ================================================================================
- * 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.apigateway.test;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.onap.ccsdk.features.sdnr.wt.apigateway.MyProperties;
-import org.onap.ccsdk.features.sdnr.wt.apigateway.test.helper.HelpEsServlet;
-import org.onap.ccsdk.features.sdnr.wt.apigateway.test.helper.HelpServletBase;
-import java.io.*;
-import javax.servlet.ServletException;
-
-public class TestDatabaseServlet extends HelpServletBase {
-
- private static final int PORT = 40002;
-
- public TestDatabaseServlet() {
- super("/database", PORT);
- }
-
-
-
- final String LR = "\n";
-
-
-
- @Test
- public void test() throws ServletException, IOException {
-
- String tmpFilename = "tmp1.cfg";
- File tmpFile = new File(tmpFilename);
- if (tmpFile.exists())
- tmpFile.delete();
- MyProperties properties = MyProperties.Instantiate(tmpFile, true);
- String query = "{\"query\":{\"match_all\":{}}}";
- String tmpconfigcontent =
- "aai=off" + LR + "aaiHeaders=[]" + LR + "database=off" + LR + "insecure=0" + LR + "cors=0";
- String tmpconfigcontent2 = "aai=off" + LR + "aaiHeaders=[]" + LR + "database=http://" + HOST + ":" + PORT + LR
- + "insecure=1" + LR + "cors=1";
- this.setServlet(new HelpEsServlet());
- // test diabled message
- properties.load(new ByteArrayInputStream(tmpconfigcontent.getBytes()));
- String expectedResponse = "offline";
- testrequest(HTTPMETHOD_GET, query, expectedResponse, false);
- testrequest(HTTPMETHOD_POST, query, expectedResponse, false);
- testrequest(HTTPMETHOD_PUT, query, expectedResponse, false);
- testrequest(HTTPMETHOD_DELETE, query, expectedResponse, false);
-
- // initEsTestWebserver(port);
- properties.load(new ByteArrayInputStream(tmpconfigcontent2.getBytes()));
- testrequest(HTTPMETHOD_GET, query, HelpEsServlet.RESPONSE_GET, true);
- testrequest(HTTPMETHOD_POST, query, HelpEsServlet.RESPONSE_POST, true);
- testrequest(HTTPMETHOD_PUT, query, HelpEsServlet.RESPONSE_PUT, true);
- testrequest(HTTPMETHOD_DELETE, query, HelpEsServlet.RESPONSE_DELETE, true);
- testrequest(HTTPMETHOD_OPTIONS, query, "", false);
- // stopTestWebserver();
-
-
- if (tmpFile.exists())
- tmpFile.delete();
-
-
- }
-
- @Before
- public void init() throws IOException {
- HelpServletBase.initEsTestWebserver(PORT);
- }
-
- @After
- public void deinit() {
- HelpServletBase.stopTestWebserver();
- }
-}
diff --git a/sdnr/wt/apigateway/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/apigateway/test/TestProperties.java b/sdnr/wt/apigateway/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/apigateway/test/TestProperties.java
deleted file mode 100644
index 761afe20e..000000000
--- a/sdnr/wt/apigateway/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/apigateway/test/TestProperties.java
+++ /dev/null
@@ -1,114 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * ONAP : CCSDK.apps.sdnr.wt.apigateway
- * ================================================================================
- * 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.apigateway.test;
-
-import static org.junit.Assert.*;
-import java.io.ByteArrayInputStream;
-import java.io.File;
-import java.util.HashMap;
-import java.util.Map;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.onap.ccsdk.features.sdnr.wt.apigateway.MyProperties;
-
-public class TestProperties {
-
- private static final boolean DEFAULT_CORSENABLED = false;
- private static final boolean DEFAULT_AAIOFF = true;
- private static final boolean DEFAULT_ESOFF = false;
- private static final boolean DEFAULT_TRUSTINSECURE = false;
- private static final String DEFAULT_AAIBASEURL = "off";
- private static Map<String, String> DEFAULT_AAIHEADERS = new HashMap<String, String>();
- private static final String DEFAULT_ESBASEURL = "http://sdnrdb:9200";
-
- private static final boolean CUSTOM_CORSENABLED = true;
- private static final boolean CUSTOM_AAIOFF = false;
- private static final boolean CUSTOM_ESOFF = false;
- private static final boolean CUSTOM_TRUSTINSECURE = true;
- private static final String CUSTOM_AAIBASEURL = "https://aai.tld:2214";
- private static Map<String, String> CUSTOM_AAIHEADERS = new HashMap<String, String>();
- private static final String CUSTOM_ESBASEURL = "http://localhost:9200";
-
- private static final String LR = "\n";
- final String tmpFilename = "tmp2.cfg";
-
- @Before
- @After
- public void init() {
- File f = new File(tmpFilename);
- if (f.exists()) {
- f.delete();
- }
- }
-
- @Test
- public void test() {
- DEFAULT_AAIHEADERS.put("X-FromAppId", "SDNR");
- DEFAULT_AAIHEADERS.put("Authorization", "Basic QUFJOkFBSQ==");
- CUSTOM_AAIHEADERS.put("X-FromAppId", "SDNC");
- CUSTOM_AAIHEADERS.put("Authorization", "Basic 1234");
- final String TESTPROPERTYFILECONTENT = "aai=" + CUSTOM_AAIBASEURL + LR + "aaiHeaders=[\"X-FromAppId:"
- + CUSTOM_AAIHEADERS.get("X-FromAppId") + "\",\"Authorization:" + CUSTOM_AAIHEADERS.get("Authorization")
- + "\"]" + LR + "database=" + CUSTOM_ESBASEURL + LR + "insecure=" + (CUSTOM_TRUSTINSECURE ? "1" : "0")
- + LR + "cors=" + (CUSTOM_CORSENABLED ? "1" : "0");
- File ftest = new File(tmpFilename);
- MyProperties prop = null;
- ftest = new File(tmpFilename);
- try {
- prop = MyProperties.Instantiate(ftest, true);
- } catch (Exception e) {
- fail("error instantiating properties");
- }
- assertNotNull("problem without exception instantiating properties", prop);
-
- assertEquals("default config file was not created", true, ftest.exists());
-
- // test default values
- assertEquals("default value is not correct", DEFAULT_CORSENABLED, prop.corsEnabled());
- assertEquals("default value is not correct", DEFAULT_AAIOFF, prop.isAAIOff());
- assertEquals("default value is not correct", DEFAULT_ESOFF, prop.isEsOff());
- assertEquals("default value is not correct", DEFAULT_TRUSTINSECURE, prop.trustInsecure());
- assertEquals("default value is not correct", DEFAULT_AAIBASEURL, prop.getAAIBaseUrl());
- assertEquals("default value is not correct", DEFAULT_AAIHEADERS, prop.getAAIHeaders());
- assertEquals("default value is not correct", DEFAULT_ESBASEURL, prop.getEsBaseUrl());
-
- try {
- prop.load(new ByteArrayInputStream(TESTPROPERTYFILECONTENT.getBytes()));
- } catch (Exception e) {
- fail("error loading custom values into properties");
- }
-
- // test custom values
- assertEquals("custom value is not correct", CUSTOM_CORSENABLED, prop.corsEnabled());
- assertEquals("custom value is not correct", CUSTOM_AAIOFF, prop.isAAIOff());
- assertEquals("custom value is not correct", CUSTOM_ESOFF, prop.isEsOff());
- assertEquals("custom value is not correct", CUSTOM_TRUSTINSECURE, prop.trustInsecure());
- assertEquals("custom value is not correct", CUSTOM_AAIBASEURL, prop.getAAIBaseUrl());
- assertEquals("custom value is not correct", CUSTOM_AAIHEADERS, prop.getAAIHeaders());
- assertEquals("custom value is not correct", CUSTOM_ESBASEURL, prop.getEsBaseUrl());
-
- // delete autogenerated testfile
- ftest.delete();
-
- }
-
-}
diff --git a/sdnr/wt/apigateway/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/apigateway/test/helper/HelpAaiServlet.java b/sdnr/wt/apigateway/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/apigateway/test/helper/HelpAaiServlet.java
deleted file mode 100644
index 5d4c8f507..000000000
--- a/sdnr/wt/apigateway/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/apigateway/test/helper/HelpAaiServlet.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * ONAP : CCSDK.apps.sdnr.wt.apigateway
- * ================================================================================
- * Copyright (C) 2018 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.apigateway.test.helper;
-
-import java.io.IOException;
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import org.onap.ccsdk.features.sdnr.wt.apigateway.AaiServlet;
-
-public class HelpAaiServlet extends AaiServlet implements IPublicServlet {
-
- private static final long serialVersionUID = 1L;
- public static final String RESPONSE_GET = "This is the response get";
- public static final String RESPONSE_POST = "This is the response post";
- public static final String RESPONSE_PUT = "This is the response put";
- public static final String RESPONSE_DELETE = "This is the response delete";
- public static final String RESPONSE_OPTIONS = "This is the response options";
-
- @Override
- public void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
- super.doGet(req, resp);
- }
-
- @Override
- public void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
- super.doPost(req, resp);
- }
-
- @Override
- public void doPut(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
- super.doPut(req, resp);
- }
-
- @Override
- public void doOptions(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
- super.doOptions(req, resp);
- }
-
- @Override
- public void doDelete(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
- super.doDelete(req, resp);
- }
-}
diff --git a/sdnr/wt/apigateway/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/apigateway/test/helper/HelpEsServlet.java b/sdnr/wt/apigateway/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/apigateway/test/helper/HelpEsServlet.java
deleted file mode 100644
index fe89c9fc4..000000000
--- a/sdnr/wt/apigateway/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/apigateway/test/helper/HelpEsServlet.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * ONAP : CCSDK.apps.sdnr.wt.apigateway
- * ================================================================================
- * Copyright (C) 2018 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.apigateway.test.helper;
-
-import java.io.IOException;
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import org.onap.ccsdk.features.sdnr.wt.apigateway.EsServlet;
-
-public class HelpEsServlet extends EsServlet implements IPublicServlet {
-
- private static final long serialVersionUID = 6502905928958752573L;
-
- public static final String RESPONSE_GET = "This is the response get";
- public static final String RESPONSE_POST = "This is the response post";
- public static final String RESPONSE_PUT = "This is the response put";
- public static final String RESPONSE_DELETE = "This is the response delete";
- public static final String RESPONSE_OPTIONS = "This is the response options";
-
- @Override
- public void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
- super.doGet(req, resp);
- }
-
- @Override
- public void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
- super.doPost(req, resp);
- }
-
- @Override
- public void doPut(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
- super.doPut(req, resp);
- }
-
- @Override
- public void doOptions(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
- super.doOptions(req, resp);
- }
-
- @Override
- public void doDelete(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
- super.doDelete(req, resp);
- }
-}
diff --git a/sdnr/wt/apigateway/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/apigateway/test/helper/HelpServlet.java b/sdnr/wt/apigateway/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/apigateway/test/helper/HelpServlet.java
deleted file mode 100644
index eeff762ac..000000000
--- a/sdnr/wt/apigateway/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/apigateway/test/helper/HelpServlet.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * ONAP : CCSDK.apps.sdnr.wt.apigateway
- * ================================================================================
- * Copyright (C) 2018 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.apigateway.test.helper;
-
-import java.io.IOException;
-
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import org.onap.ccsdk.features.sdnr.wt.apigateway.EsServlet;
-
-public class HelpServlet extends EsServlet {
-
- private static final long serialVersionUID = 1L;
-
- @Override
- public void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
- super.doGet(req, resp);
- }
-
- @Override
- public void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
- super.doPost(req, resp);
- }
-
- @Override
- public void doPut(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
- super.doPut(req, resp);
- }
-
- @Override
- public void doOptions(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
- super.doOptions(req, resp);
- }
-
- @Override
- public void doDelete(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
- super.doDelete(req, resp);
- }
-}
diff --git a/sdnr/wt/apigateway/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/apigateway/test/helper/HelpServletBase.java b/sdnr/wt/apigateway/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/apigateway/test/helper/HelpServletBase.java
deleted file mode 100644
index 4048012bb..000000000
--- a/sdnr/wt/apigateway/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/apigateway/test/helper/HelpServletBase.java
+++ /dev/null
@@ -1,206 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * ONAP : CCSDK.apps.sdnr.wt.apigateway
- * ================================================================================
- * Copyright (C) 2018 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.apigateway.test.helper;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-import com.sun.net.httpserver.HttpExchange;
-import com.sun.net.httpserver.HttpHandler;
-import com.sun.net.httpserver.HttpServer;
-import java.io.IOException;
-import java.io.OutputStream;
-import java.net.InetSocketAddress;
-import java.util.Enumeration;
-import java.util.Map;
-import java.util.Vector;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import org.junit.After;
-import org.junit.Before;
-import org.onap.ccsdk.features.sdnr.wt.common.test.ServletInputStreamFromByteArrayInputStream;
-import org.onap.ccsdk.features.sdnr.wt.common.test.ServletOutputStreamToStringWriter;
-
-@SuppressWarnings("restriction")
-public class HelpServletBase {
-
- public static final String HTTPMETHOD_GET = "GET";
- public static final String HTTPMETHOD_POST = "POST";
- public static final String HTTPMETHOD_PUT = "PUT";
- public static final String HTTPMETHOD_DELETE = "DELETE";
- public static final String HTTPMETHOD_OPTIONS = "OPTIONS";
- private IPublicServlet servlet;
- private static HttpServer server;
- private static ExecutorService httpThreadPool;
-
- public final String HOST = "localhost";
- protected static int testPort;
- private final String baseUri;
- protected static final String LR = "\n";
-
- public HelpServletBase(String baseuri, int port) {
- this.baseUri = baseuri;
- testPort = port;
- }
-
- public void setServlet(IPublicServlet s) {
- this.servlet = s;
- }
-
- protected void testrequest(String method, String data, String expectedResponse, boolean exact) {
- this.testrequest("/mwtn/test", method, data, expectedResponse, exact, null);
- }
-
- protected void testrequest(String uri, String method, String data, String expectedResponse, boolean exact) {
- this.testrequest(uri, method, data, expectedResponse, exact, null);
- }
-
- protected void testrequest(String uri, String method, String data, String expectedResponse, boolean exact,
- Map<String, String> headersToCheck) {
-
- HttpServletRequest mockRequest = mock(HttpServletRequest.class);
- HttpServletResponse mockResponse = mock(HttpServletResponse.class);
-
- ServletOutputStreamToStringWriter printOut = new ServletOutputStreamToStringWriter();
- ServletInputStreamFromByteArrayInputStream inputStream = new ServletInputStreamFromByteArrayInputStream(data.getBytes());
- Vector<String> headers = new Vector<String>();
- headers.addElement("Accept");
- headers.add("User-Agent");
- Enumeration<String> headerNames = headers.elements();
- try {
- when(mockRequest.getRequestURI()).thenReturn(this.baseUri + uri);
- when(mockRequest.getHeaderNames()).thenReturn(headerNames);
- when(mockRequest.getHeader("Accept")).thenReturn("application/json");
- when(mockRequest.getHeader("User-Agent")).thenReturn("Gecko abc");
- when(mockRequest.getInputStream()).thenReturn(inputStream);
- when(mockResponse.getOutputStream()).thenReturn(printOut);
- System.out.println("do a " + method + " request");
- if (method == HTTPMETHOD_GET)
- this.servlet.doGet(mockRequest, mockResponse);
- else if (method == HTTPMETHOD_POST)
- this.servlet.doPost(mockRequest, mockResponse);
- else if (method == HTTPMETHOD_PUT)
- this.servlet.doPut(mockRequest, mockResponse);
- else if (method == HTTPMETHOD_DELETE)
- this.servlet.doDelete(mockRequest, mockResponse);
- else if (method == HTTPMETHOD_OPTIONS)
- this.servlet.doOptions(mockRequest, mockResponse);
- else
- fail("http request method " + method + " test not implemented");
- } catch (Exception e) {
- System.err.println(e.getMessage());
- }
-
- verify(mockResponse).setStatus(200);
- if (exact)
- assertEquals(expectedResponse, printOut.getStringWriter().toString());
- else
- assertTrue("response not for method " + method + "correct", printOut.getStringWriter().toString().contains(expectedResponse));
- // currently unable to check extra headers
- if (headersToCheck != null) {
-
- }
- }
-
- @Before
- private void init() throws IOException {
-
-
- initEsTestWebserver(testPort);
- }
-
- @After
- private void deinit() {
- stopTestWebserver();
- }
-
- public static void initEsTestWebserver(int port) throws IOException {
- initEsTestWebserver(port, "/mwtn/test");
- }
-
- public static void initEsTestWebserver(int port, String baseUri) throws IOException {
- server = HttpServer.create(new InetSocketAddress("127.0.0.1", port), 0);
- httpThreadPool = Executors.newFixedThreadPool(5);
- server.setExecutor(httpThreadPool);
- server.createContext(baseUri, new MyHandler());
- //server.createContext("/", new MyRootHandler());
- server.setExecutor(null); // creates a default executor
- server.start();
- System.out.println("http server started");
- }
-
- public static void stopTestWebserver() {
- if (server != null) {
- server.stop(0);
- httpThreadPool.shutdownNow();
- System.out.println("http server stopped");
- }
- }
-
-
-
- public static class MyHandler implements HttpHandler {
- @Override
- public void handle(HttpExchange t) throws IOException {
- String method = t.getRequestMethod();
- System.out.println(String.format("req received: %s %s", method, t.getRequestURI()));
- OutputStream os = null;
- try {
- if (method.equals(HTTPMETHOD_GET)) {
- t.sendResponseHeaders(200, HelpEsServlet.RESPONSE_GET.length());
- os = t.getResponseBody();
- os.write(HelpEsServlet.RESPONSE_GET.getBytes());
- } else if (method.equals(HTTPMETHOD_POST)) {
- t.sendResponseHeaders(200, HelpEsServlet.RESPONSE_POST.length());
- os = t.getResponseBody();
- os.write(HelpEsServlet.RESPONSE_POST.getBytes());
- } else if (method.equals(HTTPMETHOD_PUT)) {
- t.sendResponseHeaders(200, HelpEsServlet.RESPONSE_PUT.length());
- os = t.getResponseBody();
- os.write(HelpEsServlet.RESPONSE_PUT.getBytes());
- } else if (method.equals(HTTPMETHOD_DELETE)) {
- t.sendResponseHeaders(200, HelpEsServlet.RESPONSE_DELETE.length());
- os = t.getResponseBody();
- os.write(HelpEsServlet.RESPONSE_DELETE.getBytes());
- } else if (method.equals(HTTPMETHOD_OPTIONS)) {
- t.sendResponseHeaders(200, HelpEsServlet.RESPONSE_OPTIONS.length());
- //os = t.getResponseBody();
- //os.write(RESPONSE_OPTIONS.getBytes());
- } else {
- t.sendResponseHeaders(404, 0);
- }
- System.out.println("req handled successful");
-
- } catch (Exception e) {
- System.out.println(e.getMessage());
- } finally {
- if (os != null) {
- os.close();
- }
- }
- }
- }
-}
diff --git a/sdnr/wt/apigateway/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/apigateway/test/helper/IPublicServlet.java b/sdnr/wt/apigateway/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/apigateway/test/helper/IPublicServlet.java
deleted file mode 100644
index bf7fc56f4..000000000
--- a/sdnr/wt/apigateway/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/apigateway/test/helper/IPublicServlet.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP : CCSDK
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights
- * reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-
-package org.onap.ccsdk.features.sdnr.wt.apigateway.test.helper;
-
-import java.io.IOException;
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-public interface IPublicServlet {
-
- public void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException;
-
- public void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException;
-
- public void doPut(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException;
-
- public void doOptions(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException;
-
- public void doDelete(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException;
-}
diff --git a/sdnr/wt/apigateway/provider/src/test/resources/log4j.properties b/sdnr/wt/apigateway/provider/src/test/resources/log4j.properties
deleted file mode 100644
index 2a2f8099e..000000000
--- a/sdnr/wt/apigateway/provider/src/test/resources/log4j.properties
+++ /dev/null
@@ -1,33 +0,0 @@
-#
-# ============LICENSE_START=======================================================
-# ONAP : ccsdk features
-# ================================================================================
-# Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
-# ================================================================================
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-# ============LICENSE_END=======================================================
-#
-#
-
-log4j.rootLogger=INFO, out
-
-log4j.logger.org.apache.camel.impl.converter=WARN
-log4j.logger.org.apache.camel.management=WARN
-log4j.logger.org.apache.camel.impl.DefaultPackageScanClassResolver=WARN
-log4j.logger.org.springframework=ERROR
-
-# CONSOLE appender not used by default
-log4j.appender.out=org.apache.log4j.ConsoleAppender
-log4j.appender.out.layout=org.apache.log4j.PatternLayout
-log4j.appender.out.layout.ConversionPattern=%d [%-15.15t] %-5p %-30.30c{1} - %m%n
-