X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=portal-BE%2Fsrc%2Fmain%2Fjava%2Forg%2Fonap%2Fportal%2FrestTemplates%2FPortalWMSTemplate.java;fp=portal-BE%2Fsrc%2Fmain%2Fjava%2Forg%2Fonap%2Fportal%2FrestTemplates%2FPortalWMSTemplate.java;h=74707445342567ad31140307592584e78e07a863;hb=6aa4d5e4b2792d7cd5037ec8f5a87bfbaa0b1ade;hp=0000000000000000000000000000000000000000;hpb=ba32fe77c7874fdfe7888d1c9b2e28005f1fa9a3;p=portal.git diff --git a/portal-BE/src/main/java/org/onap/portal/restTemplates/PortalWMSTemplate.java b/portal-BE/src/main/java/org/onap/portal/restTemplates/PortalWMSTemplate.java new file mode 100644 index 00000000..74707445 --- /dev/null +++ b/portal-BE/src/main/java/org/onap/portal/restTemplates/PortalWMSTemplate.java @@ -0,0 +1,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 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); + } +}