2 * ============LICENSE_START=======================================================
3 * ONAP : ccsdk features
4 * ================================================================================
5 * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property.
7 * ================================================================================
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
19 * ============LICENSE_END=========================================================
22 package org.onap.ccsdk.features.sdnr.wt.dataprovider.http;
24 import java.io.IOException;
25 import javax.servlet.ServletException;
26 import javax.servlet.http.HttpServletRequest;
27 import javax.servlet.http.HttpServletResponse;
29 import org.onap.ccsdk.features.sdnr.wt.common.http.BaseServlet;
30 import org.onap.ccsdk.features.sdnr.wt.dataprovider.data.MediatorServerDataProvider;
31 import org.slf4j.Logger;
32 import org.slf4j.LoggerFactory;
34 public class MsServlet extends BaseServlet {
39 private static Logger LOG = LoggerFactory.getLogger(MsServlet.class);
40 private static final long serialVersionUID = -5361461082028405171L;
41 private static final String OFFLINE_RESPONSE_MESSAGE = "MediatorServer interface is offline";
42 private static boolean trustAll = false;
43 private static MediatorServerDataProvider entryProvider;
50 protected void doOptions(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
55 protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
56 super.doGet(req, resp);
60 protected String getOfflineResponse() {
61 return OFFLINE_RESPONSE_MESSAGE;
64 public void triggerReloadDatabaseEntries() {
65 LOG.debug("external reload triggered");
66 entryProvider.triggerReloadSync();
70 protected boolean isOff() {
75 protected String getRemoteUrl(String uri) {
76 String dbServerId = "0";
79 if (uri.length() > 0) {
80 uri = uri.substring("/ms/".length());
81 int idx = uri.indexOf("/");
82 dbServerId = uri.substring(0, idx);
83 uri = uri.substring(idx);
85 LOG.debug("request for ms server with id={}", dbServerId);
86 String url = this.getBaseUrl(dbServerId) + uri;
87 LOG.debug("dest-url: {}", url);
91 protected String getBaseUrl(String dbServerId) {
92 return entryProvider.getHostUrl(dbServerId);
96 protected boolean doTrustAll() {
101 protected void trustAll(boolean trust) {
105 public void setDataProvider(MediatorServerDataProvider mediatorServerDataProvider) {
106 entryProvider = mediatorServerDataProvider;
110 protected boolean trustInsecure() {
115 protected boolean isCorsEnabled() {