summaryrefslogtreecommitdiffstats
path: root/ecomp-portal-BE-common
diff options
context:
space:
mode:
Diffstat (limited to 'ecomp-portal-BE-common')
-rw-r--r--ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/controller/MicroserviceController.java7
-rw-r--r--ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/controller/WebAnalyticsExtAppController.java10
-rw-r--r--ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/controller/WidgetsCatalogController.java33
-rw-r--r--ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/controller/WidgetsCatalogMarkupController.java5
-rw-r--r--ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/MicroserviceProxyServiceImpl.java3
-rw-r--r--ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/utils/EPCommonSystemProperties.java1
-rw-r--r--ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/utils/EcompPortalUtils.java14
7 files changed, 43 insertions, 30 deletions
diff --git a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/controller/MicroserviceController.java b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/controller/MicroserviceController.java
index bc21dd98..42a62b5f 100644
--- a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/controller/MicroserviceController.java
+++ b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/controller/MicroserviceController.java
@@ -33,6 +33,7 @@ import org.openecomp.portalapp.portal.ecomp.model.PortalRestStatusEnum;
import org.openecomp.portalapp.portal.logging.aop.EPAuditLog;
import org.openecomp.portalapp.portal.service.ConsulHealthService;
import org.openecomp.portalapp.portal.service.MicroserviceService;
+import org.openecomp.portalapp.portal.utils.EcompPortalUtils;
import org.openecomp.portalsdk.core.util.SystemProperties;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.EnableAspectJAutoProxy;
@@ -54,8 +55,6 @@ import org.springframework.web.client.RestTemplate;
@EPAuditLog
public class MicroserviceController extends EPRestrictedBaseController {
- private static final String HTTPS = "https://";
-
String whatService = "widgets-service";
RestTemplate template = new RestTemplate();
@@ -64,7 +63,7 @@ public class MicroserviceController extends EPRestrictedBaseController {
@Autowired
private MicroserviceService microserviceService;
-
+
@RequestMapping(value = { "/portalApi/microservices" }, method = RequestMethod.POST)
public PortalRestResponse<String> createMicroservice(HttpServletRequest request, HttpServletResponse response,
@RequestBody MicroserviceData newServiceData) throws Exception {
@@ -114,7 +113,7 @@ public class MicroserviceController extends EPRestrictedBaseController {
};
// If this service is assoicated with widgets, cannnot be deleted
ResponseEntity<List<WidgetCatalog>> ans = (ResponseEntity<List<WidgetCatalog>>) template.exchange(
- HTTPS + consulHealthService.getServiceLocation(whatService, SystemProperties.getProperty("microservices.widget.local.port"))
+ EcompPortalUtils.widgetMsProtocol() + "://" + consulHealthService.getServiceLocation(whatService, SystemProperties.getProperty("microservices.widget.local.port"))
+ "/widget/microservices/widgetCatalog/service/" + serviceId,
HttpMethod.GET, new HttpEntity(WidgetServiceHeaders.getInstance()), typeRef);
List<WidgetCatalog> widgets = ans.getBody();
diff --git a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/controller/WebAnalyticsExtAppController.java b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/controller/WebAnalyticsExtAppController.java
index b5761617..662de30a 100644
--- a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/controller/WebAnalyticsExtAppController.java
+++ b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/controller/WebAnalyticsExtAppController.java
@@ -77,8 +77,10 @@ public class WebAnalyticsExtAppController extends EPRestrictedRESTfulBaseControl
private static final String MACHINE_LEARNING_SERVICE_CTX = "/ml_api";
private static final String REGISTER_ACTION = MACHINE_LEARNING_SERVICE_CTX + "/" + "registerAction";
private static final String CONSUL_ML_SERVICE_ID = "machine-learning";
- private static final String SERVICE_PROTOCOL = "http";
private static final String APP_KEY = "uebkey";
+ private EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(WebAnalyticsExtAppController.class);
+ private AsyncRestTemplate restTemplate = new AsyncRestTemplate();
+
@Autowired
AuditService auditService;
@@ -86,10 +88,6 @@ public class WebAnalyticsExtAppController extends EPRestrictedRESTfulBaseControl
@Autowired
AppsCacheService appCacheService;
- private EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(WebAnalyticsExtAppController.class);
-
- private AsyncRestTemplate restTemplate = new AsyncRestTemplate();
-
SuccessCallback<ResponseEntity<String>> successCallback = new SuccessCallback<ResponseEntity<String>>() {
@Override
public void onSuccess(ResponseEntity<String> arg) {
@@ -230,7 +228,7 @@ public class WebAnalyticsExtAppController extends EPRestrictedRESTfulBaseControl
// send it!
ListenableFuture<ResponseEntity<String>> out = restTemplate.exchange(
- SERVICE_PROTOCOL + "://"
+ EcompPortalUtils.widgetMsProtocol() + "://"
+ consulHealthService.getServiceLocation(CONSUL_ML_SERVICE_ID,
SystemProperties.getProperty("microservices.m-learn.local.port"))
+ REGISTER_ACTION,
diff --git a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/controller/WidgetsCatalogController.java b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/controller/WidgetsCatalogController.java
index 9ac81e9a..84150b54 100644
--- a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/controller/WidgetsCatalogController.java
+++ b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/controller/WidgetsCatalogController.java
@@ -44,6 +44,8 @@ import org.openecomp.portalapp.portal.logging.aop.EPAuditLog;
import org.openecomp.portalapp.portal.service.ConsulHealthService;
import org.openecomp.portalapp.portal.service.MicroserviceService;
import org.openecomp.portalapp.portal.service.WidgetParameterService;
+import org.openecomp.portalapp.portal.utils.CustomLoggingFilter;
+import org.openecomp.portalapp.portal.utils.EcompPortalUtils;
import org.openecomp.portalapp.util.EPUserUtils;
import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate;
import org.openecomp.portalsdk.core.util.SystemProperties;
@@ -76,8 +78,6 @@ import org.springframework.web.multipart.commons.CommonsMultipartResolver;
@EPAuditLog
public class WidgetsCatalogController extends EPRestrictedBaseController {
- private static final String HTTPS = "https://";
-
EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(WidgetsCatalogController.class);
RestTemplate template = new RestTemplate();
String whatService = "widgets-service";
@@ -106,16 +106,16 @@ public class WidgetsCatalogController extends EPRestrictedBaseController {
}
return false;
}
- });
+ });
}
@RequestMapping(value = { "/portalApi/microservices/widgetCatalog/{loginName}" }, method = RequestMethod.GET)
public List<WidgetCatalog> getUserWidgetCatalog(HttpServletRequest request, HttpServletResponse response,
@PathVariable("loginName") String loginName) throws RestClientException, Exception {
List<WidgetCatalog> widgets = new ArrayList<>();
- try {
+ try {CustomLoggingFilter d;
ResponseEntity<ArrayList> ans = template.exchange(
- HTTPS + consulHealthService.getServiceLocation(whatService,
+ EcompPortalUtils.widgetMsProtocol() + "://" + consulHealthService.getServiceLocation(whatService,
SystemProperties.getProperty("microservices.widget.local.port"))
+ "/widget/microservices/widgetCatalog/" + loginName,
HttpMethod.GET, new HttpEntity(WidgetServiceHeaders.getInstance()), ArrayList.class);
@@ -133,9 +133,11 @@ public class WidgetsCatalogController extends EPRestrictedBaseController {
public List<WidgetCatalog> getWidgetCatalog(HttpServletRequest request, HttpServletResponse response)
throws RestClientException, Exception {
List<WidgetCatalog> widgets = new ArrayList<>();
+
+ String p = EcompPortalUtils.widgetMsProtocol();
try {
ResponseEntity<ArrayList> ans = template.exchange(
- HTTPS + consulHealthService.getServiceLocation(whatService,
+ EcompPortalUtils.widgetMsProtocol() + "://" + consulHealthService.getServiceLocation(whatService,
SystemProperties.getProperty("microservices.widget.local.port"))
+ "/widget/microservices/widgetCatalog",
HttpMethod.GET, new HttpEntity(WidgetServiceHeaders.getInstance()), ArrayList.class);
@@ -155,7 +157,7 @@ public class WidgetsCatalogController extends EPRestrictedBaseController {
@RequestBody WidgetCatalog newWidgetCatalog, @PathVariable("widgetId") long widgetId)
throws RestClientException, Exception {
template.exchange(
- HTTPS + consulHealthService.getServiceLocation(whatService,
+ EcompPortalUtils.widgetMsProtocol() + "://" + consulHealthService.getServiceLocation(whatService,
SystemProperties.getProperty("microservices.widget.local.port"))
+ "/widget/microservices/widgetCatalog/" + widgetId,
HttpMethod.PUT, new HttpEntity(newWidgetCatalog, WidgetServiceHeaders.getInstance()), String.class);
@@ -165,7 +167,7 @@ public class WidgetsCatalogController extends EPRestrictedBaseController {
public void deleteOnboardingWidget(HttpServletRequest request, HttpServletResponse response,
@PathVariable("widgetId") long widgetId) throws RestClientException, Exception {
template.exchange(
- HTTPS + consulHealthService.getServiceLocation(whatService,
+ EcompPortalUtils.widgetMsProtocol() + "://" + consulHealthService.getServiceLocation(whatService,
SystemProperties.getProperty("microservices.widget.local.port"))
+ "/widget/microservices/widgetCatalog/" + widgetId,
HttpMethod.DELETE, new HttpEntity(WidgetServiceHeaders.getInstance()), String.class);
@@ -192,7 +194,7 @@ public class WidgetsCatalogController extends EPRestrictedBaseController {
multipartRequest.add("file", new FileSystemResource(tmp_folder + fileName));
multipartRequest.add("widget", request.getParameter("newWidget"));
respond = template.postForObject(
- HTTPS + consulHealthService.getServiceLocation(whatService,
+ EcompPortalUtils.widgetMsProtocol() + "://" + consulHealthService.getServiceLocation(whatService,
SystemProperties.getProperty("microservices.widget.local.port"))
+ "/widget/microservices/widgetCatalog/" + widgetId,
new HttpEntity<>(multipartRequest, WidgetServiceHeaders.getInstance()), String.class);
@@ -233,7 +235,7 @@ public class WidgetsCatalogController extends EPRestrictedBaseController {
multipartRequest.add("widget", request.getParameter("newWidget"));
respond = template.postForObject(
- HTTPS + consulHealthService.getServiceLocation(whatService,
+ EcompPortalUtils.widgetMsProtocol() + "://" + consulHealthService.getServiceLocation(whatService,
SystemProperties.getProperty("microservices.widget.local.port"))
+ "/widget/microservices/widgetCatalog",
new HttpEntity<>(multipartRequest, WidgetServiceHeaders.getInstance()), String.class);
@@ -255,7 +257,7 @@ public class WidgetsCatalogController extends EPRestrictedBaseController {
@RequestMapping(value = "/portalApi/microservices/{widgetId}/framework.js", method = RequestMethod.GET)
public String getWidgetFramework(HttpServletRequest request, HttpServletResponse response,
@PathVariable("widgetId") long widgetId) throws RestClientException, Exception {
- return template.getForObject(HTTPS
+ return template.getForObject(EcompPortalUtils.widgetMsProtocol() + "://"
+ consulHealthService.getServiceLocation(whatService,
SystemProperties.getProperty("microservices.widget.local.port"))
+ "/widget/microservices/" + widgetId + "/framework.js", String.class,
@@ -265,7 +267,7 @@ public class WidgetsCatalogController extends EPRestrictedBaseController {
@RequestMapping(value = "/portalApi/microservices/{widgetId}/controller.js", method = RequestMethod.GET)
public String getWidgetController(HttpServletRequest request, HttpServletResponse response,
@PathVariable("widgetId") long widgetId) throws RestClientException, Exception {
- return template.getForObject(HTTPS
+ return template.getForObject(EcompPortalUtils.widgetMsProtocol() + "://"
+ consulHealthService.getServiceLocation(whatService,
SystemProperties.getProperty("microservices.widget.local.port"))
+ "/widget/microservices/" + widgetId + "/controller.js", String.class,
@@ -275,7 +277,7 @@ public class WidgetsCatalogController extends EPRestrictedBaseController {
@RequestMapping(value = "/portalApi/microservices/{widgetId}/style.css", method = RequestMethod.GET)
public String getWidgetCSS(HttpServletRequest request, HttpServletResponse response,
@PathVariable("widgetId") long widgetId) throws RestClientException, Exception {
- return template.getForObject(HTTPS
+ return template.getForObject(EcompPortalUtils.widgetMsProtocol() + "://"
+ consulHealthService.getServiceLocation(whatService,
SystemProperties.getProperty("microservices.widget.local.port"))
+ "/widget/microservices/" + widgetId + "/styles.css", String.class,
@@ -289,7 +291,7 @@ public class WidgetsCatalogController extends EPRestrictedBaseController {
List<WidgetParameterResult> list = new ArrayList<>();
Long serviceId = template.exchange(
- HTTPS + consulHealthService.getServiceLocation(whatService,
+ EcompPortalUtils.widgetMsProtocol() + "://" + consulHealthService.getServiceLocation(whatService,
SystemProperties.getProperty("microservices.widget.local.port"))
+ "/widget/microservices/widgetCatalog/parameters/" + widgetId,
HttpMethod.GET, new HttpEntity(WidgetServiceHeaders.getInstance()), Long.class).getBody();
@@ -336,7 +338,7 @@ public class WidgetsCatalogController extends EPRestrictedBaseController {
ServletContext context = request.getServletContext();
byte[] byteFile = template.exchange(
- HTTPS + consulHealthService.getServiceLocation(whatService,
+ EcompPortalUtils.widgetMsProtocol() + "://" + consulHealthService.getServiceLocation(whatService,
SystemProperties.getProperty("microservices.widget.local.port"))
+ "/widget/microservices/download/" + widgetId,
HttpMethod.GET, new HttpEntity(WidgetServiceHeaders.getInstance()), byte[].class).getBody();
@@ -388,5 +390,4 @@ public class WidgetsCatalogController extends EPRestrictedBaseController {
}
return new PortalRestResponse<String>(PortalRestStatusEnum.OK, "SUCCESS", "");
}
-
}
diff --git a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/controller/WidgetsCatalogMarkupController.java b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/controller/WidgetsCatalogMarkupController.java
index b0bc9fc4..e8bd9622 100644
--- a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/controller/WidgetsCatalogMarkupController.java
+++ b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/controller/WidgetsCatalogMarkupController.java
@@ -26,6 +26,7 @@ import org.openecomp.portalapp.controller.EPUnRestrictedBaseController;
import org.openecomp.portalapp.portal.domain.WidgetServiceHeaders;
import org.openecomp.portalapp.portal.logging.aop.EPAuditLog;
import org.openecomp.portalapp.portal.service.ConsulHealthService;
+import org.openecomp.portalapp.portal.utils.EcompPortalUtils;
import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate;
import org.openecomp.portalsdk.core.util.SystemProperties;
import org.springframework.beans.factory.annotation.Autowired;
@@ -46,9 +47,7 @@ import org.springframework.web.multipart.commons.CommonsMultipartResolver;
public class WidgetsCatalogMarkupController extends EPUnRestrictedBaseController {
private EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(WidgetsCatalogMarkupController.class);
-
private RestTemplate template = new RestTemplate();
-
private final String whatService = "widgets-service";
@Autowired
@@ -77,7 +76,7 @@ public class WidgetsCatalogMarkupController extends EPUnRestrictedBaseController
@PathVariable("widgetId") long widgetId) throws RestClientException, Exception {
return template
.getForObject(
- "https://"
+ EcompPortalUtils.widgetMsProtocol() + "://"
+ consulHealthService.getServiceLocation(whatService,
SystemProperties.getProperty("microservices.widget.local.port"))
+ "/widget/microservices/markup/" + widgetId,
diff --git a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/MicroserviceProxyServiceImpl.java b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/MicroserviceProxyServiceImpl.java
index df835a92..6b9a4416 100644
--- a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/MicroserviceProxyServiceImpl.java
+++ b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/service/MicroserviceProxyServiceImpl.java
@@ -30,6 +30,7 @@ import org.openecomp.portalapp.portal.domain.MicroserviceParameter;
import org.openecomp.portalapp.portal.domain.WidgetCatalogParameter;
import org.openecomp.portalapp.portal.domain.WidgetServiceHeaders;
import org.openecomp.portalapp.portal.logging.aop.EPMetricsLog;
+import org.openecomp.portalapp.portal.utils.EcompPortalUtils;
import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate;
import org.openecomp.portalsdk.core.onboarding.util.CipherUtil;
import org.openecomp.portalsdk.core.util.SystemProperties;
@@ -137,7 +138,7 @@ public class MicroserviceProxyServiceImpl implements MicroserviceProxyService {
@SuppressWarnings({ "rawtypes", "unchecked" })
ResponseEntity<Long> ans = (ResponseEntity<Long>) template.exchange(
- "https://"
+ EcompPortalUtils.widgetMsProtocol() + "://"
+ consulHealthService.getServiceLocation(whatService,
SystemProperties.getProperty("microservices.widget.local.port"))
+ "/widget/microservices/widgetCatalog/parameters/" + widgetId,
diff --git a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/utils/EPCommonSystemProperties.java b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/utils/EPCommonSystemProperties.java
index 8ef4593f..23bb3567 100644
--- a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/utils/EPCommonSystemProperties.java
+++ b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/utils/EPCommonSystemProperties.java
@@ -61,5 +61,6 @@ public class EPCommonSystemProperties extends SystemProperties {
public static final String AUTH_USER_SERVER = "auth_user_server";
public static final String EXTERNAL_ACCESS_ENABLE = "external_access_enable";
+ public static final String WIDGET_MS_PROTOCOL = "microservices.widget.protocol";
} \ No newline at end of file
diff --git a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/utils/EcompPortalUtils.java b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/utils/EcompPortalUtils.java
index 48c2dbe8..2b39da0a 100644
--- a/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/utils/EcompPortalUtils.java
+++ b/ecomp-portal-BE-common/src/main/java/org/openecomp/portalapp/portal/utils/EcompPortalUtils.java
@@ -340,5 +340,19 @@ public class EcompPortalUtils {
}
}
}
+
+ public static String widgetMsProtocol(){
+ final String protocol;
+ try{
+ protocol = SystemProperties.getProperty(EPCommonSystemProperties.WIDGET_MS_PROTOCOL);
+ return (protocol == null || protocol.trim().equals("")) ? "https" : protocol ;
+ }
+ catch(IllegalStateException ese){
+ //looks like SystemProperties.getProperty throws IllegalStateException if it cannot find a property you are looking for
+ //In order to not break the code if a non-required property is missing from system.properties, returning https as default
+ //when this exception is caught.
+ return "https";
+ }
+ }
}