summaryrefslogtreecommitdiffstats
path: root/portal-BE/src/main/java/org/onap/portal/restTemplates/PortalWMSTemplate.java
blob: 74707445342567ad31140307592584e78e07a863 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package org.onap.portal.restTemplates;

import org.onap.portal.domain.dto.ecomp.WidgetServiceHeaders;
import org.onap.portal.service.WidgetMService;
import org.onap.portal.utils.EcompPortalUtils;
import org.onap.portalsdk.core.util.SystemProperties;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpMethod;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Component;
import org.springframework.web.client.RestTemplate;

@Component
public class PortalWMSTemplate {

    private final RestTemplate template = new RestTemplate();

    private final WidgetMService widgetMService;

    @Autowired
    public PortalWMSTemplate(WidgetMService widgetMService) {
        this.widgetMService = widgetMService;
    }


    @SuppressWarnings("rawtypes")
    public ResponseEntity<Long> proxyToDestinationByWidgetId(long widgetId) throws Exception {
        return template.exchange(
            EcompPortalUtils.widgetMsProtocol() + "://"
                + widgetMService.getServiceLocation("widgets-service",
                SystemProperties.getProperty("microservices.widget.local.port"))
                + "/widget/microservices/widgetCatalog/parameters/" + widgetId,
            HttpMethod.GET, new HttpEntity(WidgetServiceHeaders.getInstance()), Long.class);
    }
}