1 package org.onap.portal.restTemplates;
3 import org.onap.portal.domain.dto.ecomp.WidgetServiceHeaders;
4 import org.onap.portal.service.WidgetMService;
5 import org.onap.portal.utils.EcompPortalUtils;
6 import org.onap.portalsdk.core.util.SystemProperties;
7 import org.springframework.beans.factory.annotation.Autowired;
8 import org.springframework.http.HttpEntity;
9 import org.springframework.http.HttpMethod;
10 import org.springframework.http.ResponseEntity;
11 import org.springframework.stereotype.Component;
12 import org.springframework.web.client.RestTemplate;
15 public class PortalWMSTemplate {
17 private final RestTemplate template = new RestTemplate();
19 private final WidgetMService widgetMService;
22 public PortalWMSTemplate(WidgetMService widgetMService) {
23 this.widgetMService = widgetMService;
27 @SuppressWarnings("rawtypes")
28 public ResponseEntity<Long> proxyToDestinationByWidgetId(long widgetId) throws Exception {
29 return template.exchange(
30 EcompPortalUtils.widgetMsProtocol() + "://"
31 + widgetMService.getServiceLocation("widgets-service",
32 SystemProperties.getProperty("microservices.widget.local.port"))
33 + "/widget/microservices/widgetCatalog/parameters/" + widgetId,
34 HttpMethod.GET, new HttpEntity(WidgetServiceHeaders.getInstance()), Long.class);