2 * ================================================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ================================================================================
20 package org.openecomp.portalapp.portal.controller;
22 import javax.servlet.http.HttpServletRequest;
23 import javax.servlet.http.HttpServletResponse;
25 import org.openecomp.portalapp.controller.EPUnRestrictedBaseController;
26 import org.openecomp.portalapp.portal.domain.WidgetServiceHeaders;
27 import org.openecomp.portalapp.portal.logging.aop.EPAuditLog;
28 import org.openecomp.portalapp.portal.service.ConsulHealthService;
29 import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate;
30 import org.openecomp.portalsdk.core.util.SystemProperties;
31 import org.springframework.beans.factory.annotation.Autowired;
32 import org.springframework.context.annotation.Bean;
33 import org.springframework.context.annotation.EnableAspectJAutoProxy;
34 import org.springframework.web.bind.annotation.PathVariable;
35 import org.springframework.web.bind.annotation.RequestMapping;
36 import org.springframework.web.bind.annotation.RequestMethod;
37 import org.springframework.web.bind.annotation.RestController;
38 import org.springframework.web.client.RestClientException;
39 import org.springframework.web.client.RestTemplate;
40 import org.springframework.web.multipart.commons.CommonsMultipartResolver;
43 @org.springframework.context.annotation.Configuration
44 @EnableAspectJAutoProxy
46 public class WidgetsCatalogMarkupController extends EPUnRestrictedBaseController {
48 private EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(WidgetsCatalogMarkupController.class);
50 private RestTemplate template = new RestTemplate();
52 private final String whatService = "widgets-service";
55 private ConsulHealthService consulHealthService;
58 public CommonsMultipartResolver multipartResolver() {
59 return new CommonsMultipartResolver();
63 // for localhost testing only
64 javax.net.ssl.HttpsURLConnection.setDefaultHostnameVerifier(new javax.net.ssl.HostnameVerifier() {
66 public boolean verify(String hostname, javax.net.ssl.SSLSession sslSession) {
67 if (hostname.equals("localhost")) {
75 @RequestMapping(value = "/portalApi/microservices/markup/{widgetId}", method = RequestMethod.GET)
76 public String getWidgetMarkup(HttpServletRequest request, HttpServletResponse response,
77 @PathVariable("widgetId") long widgetId) throws RestClientException, Exception {
81 + consulHealthService.getServiceLocation(whatService,
82 SystemProperties.getProperty("microservices.widget.local.port"))
83 + "/widget/microservices/markup/" + widgetId,
84 String.class, WidgetServiceHeaders.getInstance());