1 package org.onap.portal.restTemplates;
4 import org.onap.portal.domain.dto.ecomp.WidgetCatalog;
5 import org.onap.portal.domain.dto.ecomp.WidgetServiceHeaders;
6 import org.onap.portal.service.WidgetMService;
7 import org.onap.portal.utils.EcompPortalUtils;
8 import org.onap.portalsdk.core.util.SystemProperties;
9 import org.springframework.beans.factory.annotation.Autowired;
10 import org.springframework.core.ParameterizedTypeReference;
11 import org.springframework.http.HttpEntity;
12 import org.springframework.http.HttpMethod;
13 import org.springframework.http.ResponseEntity;
14 import org.springframework.stereotype.Component;
15 import org.springframework.web.client.RestTemplate;
18 public class PortalWMSTemplate {
20 private final RestTemplate template = new RestTemplate();
21 private final WidgetMService widgetMService;
24 public PortalWMSTemplate(WidgetMService widgetMService) {
25 this.widgetMService = widgetMService;
29 @SuppressWarnings("rawtypes")
30 public ResponseEntity<Long> proxyToDestinationByWidgetId(long widgetId) throws Exception {
31 return template.exchange(
32 EcompPortalUtils.widgetMsProtocol() + "://"
33 + widgetMService.getServiceLocation("widgets-service",
34 SystemProperties.getProperty("microservices.widget.local.port"))
35 + "/widget/microservices/widgetCatalog/parameters/" + widgetId,
36 HttpMethod.GET, new HttpEntity(WidgetServiceHeaders.getInstance()), Long.class);
39 public ResponseEntity<List<WidgetCatalog>> getWidgets(long serviceId,
40 ParameterizedTypeReference<List<WidgetCatalog>> typeRef)
42 return template.exchange(
43 EcompPortalUtils.widgetMsProtocol() + "://" + widgetMService
44 .getServiceLocation("widgets-service", SystemProperties.getProperty("microservices.widget.local.port"))
45 + "/widget/microservices/widgetCatalog/service/" + serviceId,
46 HttpMethod.GET, new HttpEntity(WidgetServiceHeaders.getInstance()), typeRef);