74707445342567ad31140307592584e78e07a863
[portal.git] / portal-BE / src / main / java / org / onap / portal / restTemplates / PortalWMSTemplate.java
1 package org.onap.portal.restTemplates;
2
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;
13
14 @Component
15 public class PortalWMSTemplate {
16
17     private final RestTemplate template = new RestTemplate();
18
19     private final WidgetMService widgetMService;
20
21     @Autowired
22     public PortalWMSTemplate(WidgetMService widgetMService) {
23         this.widgetMService = widgetMService;
24     }
25
26
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);
35     }
36 }