diff options
Diffstat (limited to 'catalog-fe/src/main')
15 files changed, 165 insertions, 142 deletions
diff --git a/catalog-fe/src/main/java/org/openecomp/sdc/fe/GzipFilter.java b/catalog-fe/src/main/java/org/openecomp/sdc/fe/GzipFilter.java index 884e688503..99caad2de3 100644 --- a/catalog-fe/src/main/java/org/openecomp/sdc/fe/GzipFilter.java +++ b/catalog-fe/src/main/java/org/openecomp/sdc/fe/GzipFilter.java @@ -1,14 +1,8 @@ package org.openecomp.sdc.fe; -import java.io.IOException; - -import javax.servlet.Filter; -import javax.servlet.FilterChain; -import javax.servlet.FilterConfig; -import javax.servlet.ServletException; -import javax.servlet.ServletRequest; -import javax.servlet.ServletResponse; +import javax.servlet.*; import javax.servlet.http.HttpServletResponse; +import java.io.IOException; public class GzipFilter implements Filter { diff --git a/catalog-fe/src/main/java/org/openecomp/sdc/fe/impl/Audit.java b/catalog-fe/src/main/java/org/openecomp/sdc/fe/impl/Audit.java index 449d8a932d..6eef071eb4 100644 --- a/catalog-fe/src/main/java/org/openecomp/sdc/fe/impl/Audit.java +++ b/catalog-fe/src/main/java/org/openecomp/sdc/fe/impl/Audit.java @@ -20,13 +20,12 @@ package org.openecomp.sdc.fe.impl; -import java.util.Map; - -import javax.servlet.http.HttpServletRequest; - import org.openecomp.sdc.common.api.Constants; import org.slf4j.Logger; +import javax.servlet.http.HttpServletRequest; +import java.util.Map; + public class Audit { private Audit() { diff --git a/catalog-fe/src/main/java/org/openecomp/sdc/fe/impl/HttpRequestInfo.java b/catalog-fe/src/main/java/org/openecomp/sdc/fe/impl/HttpRequestInfo.java index bf39a982c4..bf5165fe58 100644 --- a/catalog-fe/src/main/java/org/openecomp/sdc/fe/impl/HttpRequestInfo.java +++ b/catalog-fe/src/main/java/org/openecomp/sdc/fe/impl/HttpRequestInfo.java @@ -20,12 +20,11 @@ package org.openecomp.sdc.fe.impl; +import javax.servlet.http.HttpServletRequest; import java.io.ByteArrayInputStream; import java.io.InputStream; import java.util.Map; -import javax.servlet.http.HttpServletRequest; - public class HttpRequestInfo { public HttpRequestInfo(HttpServletRequest request, Map<String, String> headersMap, String data) { diff --git a/catalog-fe/src/main/java/org/openecomp/sdc/fe/impl/MdcData.java b/catalog-fe/src/main/java/org/openecomp/sdc/fe/impl/MdcData.java new file mode 100644 index 0000000000..816975fa04 --- /dev/null +++ b/catalog-fe/src/main/java/org/openecomp/sdc/fe/impl/MdcData.java @@ -0,0 +1,38 @@ +package org.openecomp.sdc.fe.impl; + +public class MdcData { + private String serviceInstanceID; + private String userId; + private String remoteAddr; + private String localAddr; + private Long transactionStartTime; + + public MdcData(String serviceInstanceID, String userId, String remoteAddr, String localAddr, Long transactionStartTime) { + super(); + this.serviceInstanceID = serviceInstanceID; + this.userId = userId; + this.remoteAddr = remoteAddr; + this.localAddr = localAddr; + this.transactionStartTime = transactionStartTime; + } + + public Long getTransactionStartTime() { + return transactionStartTime; + } + + public String getUserId() { + return userId; + } + + public String getRemoteAddr() { + return remoteAddr; + } + + public String getLocalAddr() { + return localAddr; + } + + public String getServiceInstanceID() { + return serviceInstanceID; + } + }
\ No newline at end of file diff --git a/catalog-fe/src/main/java/org/openecomp/sdc/fe/impl/PluginStatusBL.java b/catalog-fe/src/main/java/org/openecomp/sdc/fe/impl/PluginStatusBL.java index df68e1927d..4d466b1e2d 100644 --- a/catalog-fe/src/main/java/org/openecomp/sdc/fe/impl/PluginStatusBL.java +++ b/catalog-fe/src/main/java/org/openecomp/sdc/fe/impl/PluginStatusBL.java @@ -1,9 +1,7 @@ package org.openecomp.sdc.fe.impl; -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; - +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; import org.apache.http.client.config.RequestConfig; import org.apache.http.client.methods.CloseableHttpResponse; import org.apache.http.client.methods.HttpHead; @@ -15,8 +13,9 @@ import org.openecomp.sdc.fe.config.PluginsConfiguration.Plugin; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; public class PluginStatusBL { diff --git a/catalog-fe/src/main/java/org/openecomp/sdc/fe/listen/FEAppContextListener.java b/catalog-fe/src/main/java/org/openecomp/sdc/fe/listen/FEAppContextListener.java index 76190bc790..987b1fe82e 100644 --- a/catalog-fe/src/main/java/org/openecomp/sdc/fe/listen/FEAppContextListener.java +++ b/catalog-fe/src/main/java/org/openecomp/sdc/fe/listen/FEAppContextListener.java @@ -20,12 +20,6 @@ package org.openecomp.sdc.fe.listen; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; - -import javax.servlet.ServletContextEvent; -import javax.servlet.ServletContextListener; - import org.openecomp.sdc.common.api.Constants; import org.openecomp.sdc.common.impl.ExternalConfiguration; import org.openecomp.sdc.common.listener.AppContextListener; @@ -36,6 +30,11 @@ import org.openecomp.sdc.fe.servlets.HealthCheckService; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import javax.servlet.ServletContextEvent; +import javax.servlet.ServletContextListener; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; + public class FEAppContextListener extends AppContextListener implements ServletContextListener { private static Logger log = LoggerFactory.getLogger(FEAppContextListener.class.getName()); diff --git a/catalog-fe/src/main/java/org/openecomp/sdc/fe/listen/MyObjectMapperProvider.java b/catalog-fe/src/main/java/org/openecomp/sdc/fe/listen/MyObjectMapperProvider.java index f891ba4e3f..74f60146da 100644 --- a/catalog-fe/src/main/java/org/openecomp/sdc/fe/listen/MyObjectMapperProvider.java +++ b/catalog-fe/src/main/java/org/openecomp/sdc/fe/listen/MyObjectMapperProvider.java @@ -20,12 +20,12 @@ package org.openecomp.sdc.fe.listen; -import javax.ws.rs.ext.ContextResolver; -import javax.ws.rs.ext.Provider; - import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.SerializationFeature; +import javax.ws.rs.ext.ContextResolver; +import javax.ws.rs.ext.Provider; + @Provider public class MyObjectMapperProvider implements ContextResolver<ObjectMapper> { final ObjectMapper defaultObjectMapper; diff --git a/catalog-fe/src/main/java/org/openecomp/sdc/fe/servlets/ConfigMgrServlet.java b/catalog-fe/src/main/java/org/openecomp/sdc/fe/servlets/ConfigMgrServlet.java index 356f9261c6..547f8ac367 100644 --- a/catalog-fe/src/main/java/org/openecomp/sdc/fe/servlets/ConfigMgrServlet.java +++ b/catalog-fe/src/main/java/org/openecomp/sdc/fe/servlets/ConfigMgrServlet.java @@ -20,6 +20,14 @@ package org.openecomp.sdc.fe.servlets; +import org.openecomp.sdc.common.api.Constants; +import org.openecomp.sdc.common.rest.api.RestConfigurationInfo; +import org.openecomp.sdc.common.servlets.BasicServlet; +import org.openecomp.sdc.fe.config.Configuration; +import org.openecomp.sdc.fe.config.ConfigurationManager; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import javax.servlet.ServletContext; import javax.servlet.http.HttpServletRequest; import javax.ws.rs.GET; @@ -29,14 +37,6 @@ import javax.ws.rs.QueryParam; import javax.ws.rs.core.Context; import javax.ws.rs.core.MediaType; -import org.openecomp.sdc.common.api.Constants; -import org.openecomp.sdc.common.rest.api.RestConfigurationInfo; -import org.openecomp.sdc.common.servlets.BasicServlet; -import org.openecomp.sdc.fe.config.Configuration; -import org.openecomp.sdc.fe.config.ConfigurationManager; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - /** * Root resource (exposed at "/" path) */ diff --git a/catalog-fe/src/main/java/org/openecomp/sdc/fe/servlets/FeProxyServlet.java b/catalog-fe/src/main/java/org/openecomp/sdc/fe/servlets/FeProxyServlet.java index a8aa2069e1..b726998555 100644 --- a/catalog-fe/src/main/java/org/openecomp/sdc/fe/servlets/FeProxyServlet.java +++ b/catalog-fe/src/main/java/org/openecomp/sdc/fe/servlets/FeProxyServlet.java @@ -20,30 +20,28 @@ package org.openecomp.sdc.fe.servlets; -import java.util.concurrent.TimeUnit; - -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - +import com.google.common.cache.Cache; +import com.google.common.cache.CacheBuilder; import org.eclipse.jetty.client.api.Response; import org.openecomp.sdc.common.api.Constants; import org.openecomp.sdc.fe.config.Configuration; import org.openecomp.sdc.fe.config.ConfigurationManager; import org.openecomp.sdc.fe.config.FeEcompErrorManager; -import org.openecomp.sdc.fe.mdc.MdcData; +import org.openecomp.sdc.fe.impl.MdcData; import org.openecomp.sdc.fe.utils.BeProtocol; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.slf4j.MDC; -import com.google.common.cache.Cache; -import com.google.common.cache.CacheBuilder; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.util.concurrent.TimeUnit; public class FeProxyServlet extends SSLProxyServlet { private static final long serialVersionUID = 1L; private static final String URL = "%s://%s%s%s"; - private static final String ONBOARDING_CONTEXT = "/onboarding-api"; - private static final String DCAED_CONTEXT = "/dcae-api"; + private static final String ONBOARDING_CONTEXT = "/onboarding-api"; + private static final String DCAED_CONTEXT = "/dcae-api"; private static final Logger log = LoggerFactory.getLogger(FeProxyServlet.class.getName()); private static Cache<String, MdcData> mdcDataCache = CacheBuilder.newBuilder().expireAfterWrite(10, TimeUnit.SECONDS).build(); @@ -108,7 +106,7 @@ public class FeProxyServlet extends SSLProxyServlet { if (mdcData != null) { Long transactionStartTime = mdcData.getTransactionStartTime(); if (transactionStartTime != null) {// should'n ever be null, but - // just to be defensive + // just to be defensive transactionRoundTime = Long.toString(System.currentTimeMillis() - transactionStartTime); } updateMdc(uuid, mdcData.getServiceInstanceID(), mdcData.getUserId(), mdcData.getRemoteAddr(), mdcData.getLocalAddr(), transactionRoundTime); @@ -138,79 +136,78 @@ public class FeProxyServlet extends SSLProxyServlet { MDC.put("timer", transactionStartTime); } - private String getModifiedUrl(HttpServletRequest request) { + + + private String getModifiedUrl(HttpServletRequest request) { Configuration config = getConfiguration(request); if (config == null) { log.error("failed to retrive configuration."); throw new RuntimeException("failed to read FE configuration"); } String uri = request.getRequestURI(); - String protocol; - String host; - String port; + String protocol; + String host; + String port; if (uri.contains(ONBOARDING_CONTEXT)){ - uri = uri.replace("/sdc1/feProxy"+ONBOARDING_CONTEXT,ONBOARDING_CONTEXT); - protocol = config.getOnboarding().getProtocolBe(); - host = config.getOnboarding().getHostBe(); - port = config.getOnboarding().getPortBe().toString(); - } - else if(uri.contains(DCAED_CONTEXT)){ - uri = uri.replace("/sdc1/feProxy"+DCAED_CONTEXT,DCAED_CONTEXT); - protocol = config.getBeProtocol(); - host = config.getBeHost(); - if (config.getBeProtocol().equals(BeProtocol.HTTP.getProtocolName())) { - port = config.getBeHttpPort().toString(); - } else { - port = config.getBeSslPort().toString(); - } + uri = uri.replace("/sdc1/feProxy"+ONBOARDING_CONTEXT,ONBOARDING_CONTEXT); + protocol = config.getOnboarding().getProtocolBe(); + host = config.getOnboarding().getHostBe(); + port = config.getOnboarding().getPortBe().toString(); + }else if(uri.contains(DCAED_CONTEXT)){ + uri = uri.replace("/sdc1/feProxy"+DCAED_CONTEXT,DCAED_CONTEXT); + protocol = config.getBeProtocol(); + host = config.getBeHost(); + if (config.getBeProtocol().equals(BeProtocol.HTTP.getProtocolName())) { + port = config.getBeHttpPort().toString(); + } else { + port = config.getBeSslPort().toString(); + } } else{ - uri = uri.replace("/sdc1/feProxy","/sdc2"); - protocol = config.getBeProtocol(); - host = config.getBeHost(); - if (config.getBeProtocol().equals(BeProtocol.HTTP.getProtocolName())) { - port = config.getBeHttpPort().toString(); - } else { - port = config.getBeSslPort().toString(); - } - - } + uri = uri.replace("/sdc1/feProxy","/sdc2"); + protocol = config.getBeProtocol(); + host = config.getBeHost(); + if (config.getBeProtocol().equals(BeProtocol.HTTP.getProtocolName())) { + port = config.getBeHttpPort().toString(); + } else { + port = config.getBeSslPort().toString(); + } + } - String authority = getAuthority(host, port); - String queryString = getQueryString(request); - return String.format(URL,protocol,authority,uri,queryString); + String authority = getAuthority(host, port); + String queryString = getQueryString(request); + return String.format(URL,protocol,authority,uri,queryString); + } - } - - private Configuration getConfiguration(HttpServletRequest request) { + private Configuration getConfiguration(HttpServletRequest request) { return ((ConfigurationManager) request.getSession().getServletContext().getAttribute(Constants.CONFIGURATION_MANAGER_ATTR)).getConfiguration(); } - private String getAuthority(String host, String port) { - String authority; - if (port==null){ - authority=host; - } - else{ - authority=host+":"+port; - } - return authority; - } - - private String getQueryString(HttpServletRequest request) { - String queryString = request.getQueryString(); - if (queryString != null) { - queryString="?"+queryString; - } - else{ - queryString=""; - } - return queryString; - } + private String getAuthority(String host, String port) { + String authority; + if (port==null){ + authority=host; + } + else{ + authority=host+":"+port; + } + return authority; + } + + private String getQueryString(HttpServletRequest request) { + String queryString = request.getQueryString(); + if (queryString != null) { + queryString="?"+queryString; + } + else{ + queryString=""; + } + return queryString; + } } diff --git a/catalog-fe/src/main/java/org/openecomp/sdc/fe/servlets/KibanaServlet.java b/catalog-fe/src/main/java/org/openecomp/sdc/fe/servlets/KibanaServlet.java index 64784b3265..fb75a06c1d 100644 --- a/catalog-fe/src/main/java/org/openecomp/sdc/fe/servlets/KibanaServlet.java +++ b/catalog-fe/src/main/java/org/openecomp/sdc/fe/servlets/KibanaServlet.java @@ -20,11 +20,6 @@ package org.openecomp.sdc.fe.servlets; -import java.net.URI; - -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - import org.eclipse.jetty.client.api.Request; import org.eclipse.jetty.client.api.Response; import org.eclipse.jetty.proxy.ProxyServlet; @@ -34,6 +29,10 @@ import org.openecomp.sdc.fe.config.ConfigurationManager; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.net.URI; + public class KibanaServlet extends ProxyServlet { private static final long serialVersionUID = 1L; private static Logger log = LoggerFactory.getLogger(KibanaServlet.class.getName()); diff --git a/catalog-fe/src/main/java/org/openecomp/sdc/fe/servlets/LoggingServlet.java b/catalog-fe/src/main/java/org/openecomp/sdc/fe/servlets/LoggingServlet.java index af07810f87..2a75e561e9 100644 --- a/catalog-fe/src/main/java/org/openecomp/sdc/fe/servlets/LoggingServlet.java +++ b/catalog-fe/src/main/java/org/openecomp/sdc/fe/servlets/LoggingServlet.java @@ -4,12 +4,11 @@ import com.google.common.cache.Cache; import com.google.common.cache.CacheBuilder; import org.openecomp.sdc.common.api.Constants; import org.openecomp.sdc.common.servlets.BasicServlet; -import org.openecomp.sdc.fe.mdc.MdcData; +import org.openecomp.sdc.fe.impl.MdcData; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.slf4j.MDC; - import javax.servlet.http.HttpServletRequest; import javax.ws.rs.core.Response; import java.util.concurrent.TimeUnit; diff --git a/catalog-fe/src/main/java/org/openecomp/sdc/fe/servlets/PortalServlet.java b/catalog-fe/src/main/java/org/openecomp/sdc/fe/servlets/PortalServlet.java index 140b293b46..408529f710 100644 --- a/catalog-fe/src/main/java/org/openecomp/sdc/fe/servlets/PortalServlet.java +++ b/catalog-fe/src/main/java/org/openecomp/sdc/fe/servlets/PortalServlet.java @@ -20,20 +20,6 @@ package org.openecomp.sdc.fe.servlets; -import java.io.IOException; -import java.util.Enumeration; -import java.util.List; - -import javax.servlet.RequestDispatcher; -import javax.servlet.ServletException; -import javax.servlet.http.Cookie; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import javax.ws.rs.GET; -import javax.ws.rs.Path; -import javax.ws.rs.core.Context; - import org.openecomp.portalsdk.core.onboarding.util.CipherUtil; import org.openecomp.portalsdk.core.onboarding.util.PortalApiConstants; import org.openecomp.portalsdk.core.onboarding.util.PortalApiProperties; @@ -45,6 +31,19 @@ import org.openecomp.sdc.fe.config.FeEcompErrorManager; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import javax.servlet.RequestDispatcher; +import javax.servlet.ServletException; +import javax.servlet.http.Cookie; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.core.Context; +import java.io.IOException; +import java.util.Enumeration; +import java.util.List; + /** * Root resource (exposed at "/" path) */ diff --git a/catalog-fe/src/main/java/org/openecomp/sdc/fe/servlets/SSLProxyServlet.java b/catalog-fe/src/main/java/org/openecomp/sdc/fe/servlets/SSLProxyServlet.java index 4edcfe1286..ffed2dde8c 100644 --- a/catalog-fe/src/main/java/org/openecomp/sdc/fe/servlets/SSLProxyServlet.java +++ b/catalog-fe/src/main/java/org/openecomp/sdc/fe/servlets/SSLProxyServlet.java @@ -20,11 +20,6 @@ package org.openecomp.sdc.fe.servlets; -import java.util.Enumeration; - -import javax.servlet.ServletException; -import javax.servlet.http.HttpServletRequest; - import org.eclipse.jetty.client.HttpClient; import org.eclipse.jetty.client.api.Request; import org.eclipse.jetty.http.HttpHeader; @@ -37,6 +32,10 @@ import org.openecomp.sdc.fe.utils.BeProtocol; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import javax.servlet.ServletException; +import javax.servlet.http.HttpServletRequest; +import java.util.Enumeration; + public abstract class SSLProxyServlet extends ProxyServlet { private static final long serialVersionUID = 1L; diff --git a/catalog-fe/src/main/resources/application-context.xml b/catalog-fe/src/main/resources/application-context.xml index a5ec92697a..43f7ca354d 100644 --- a/catalog-fe/src/main/resources/application-context.xml +++ b/catalog-fe/src/main/resources/application-context.xml @@ -1,11 +1,10 @@ <?xml version="1.0" encoding="UTF-8"?> -<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context" - xmlns:aop="http://www.springframework.org/schema/aop" xmlns:util="http://www.springframework.org/schema/util" - xsi:schemaLocation=" - http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd +<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xmlns:context="http://www.springframework.org/schema/context" + xmlns:aop="http://www.springframework.org/schema/aop" + xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd - http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd - http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.0.xsd"> + http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd"> <context:annotation-config /> <aop:aspectj-autoproxy proxy-target-class="true" /> diff --git a/catalog-fe/src/main/resources/config/configuration.yaml b/catalog-fe/src/main/resources/config/configuration.yaml index b2dc6da63d..d1156da771 100644 --- a/catalog-fe/src/main/resources/config/configuration.yaml +++ b/catalog-fe/src/main/resources/config/configuration.yaml @@ -27,10 +27,15 @@ healthCheckSocketTimeoutInMs: 5000 healthCheckIntervalInSeconds: 5 onboarding: - protocol: http - host: localhost - port: 8181 - healthCheckUri: "/onboarding/v1.0/healthcheck" + hostFe: localhost + protocolFe: http + portFe: 8181 + + hostBe: localhost + protocolBe: http + portBe: 8080 + + healthCheckUriFe: "/onboarding/v1.0/healthcheck" dcae: protocol: http @@ -92,6 +97,4 @@ kibanaProtocol: http healthStatusExclude: - DE - ES - - DMAPP - -
\ No newline at end of file + - DMAAP |