1 package org.openecomp.portalapp.widget.controller;
3 import java.io.UnsupportedEncodingException;
5 import javax.servlet.http.HttpServletRequest;
6 import javax.servlet.http.HttpServletResponse;
8 import org.openecomp.portalapp.widget.service.StorageService;
9 import org.slf4j.Logger;
10 import org.slf4j.LoggerFactory;
11 import org.springframework.beans.factory.annotation.Autowired;
12 import org.springframework.stereotype.Controller;
13 import org.springframework.web.bind.annotation.PathVariable;
14 import org.springframework.web.bind.annotation.RequestMapping;
15 import org.springframework.web.bind.annotation.RequestMethod;
16 import org.springframework.web.bind.annotation.ResponseBody;
19 public class DatabaseFileUploadController {
22 private StorageService storageService;
24 private static final Logger logger = LoggerFactory.getLogger(DatabaseFileUploadController.class);
27 @RequestMapping(value = "/microservices/markup/{widgetId}", method = RequestMethod.GET)
28 public String getWidgetMarkup(HttpServletRequest request, HttpServletResponse response, @PathVariable("widgetId") long widgetId){
31 logger.debug("DatabaseFileUploadController.getWidgetMarkup: getting markup.html for widget with widgetId = {}" , widgetId);
32 markup = storageService.getWidgetMarkup(widgetId);
34 logger.error("Exception occurred while performing DatabaseFileUploadController.getWidgetMarkup in widget microservices. Details:" + e.getMessage());
40 @RequestMapping(value = "/microservices/{widgetId}/controller.js", method = RequestMethod.GET)
41 public String getWidgetController(HttpServletRequest request, HttpServletResponse response, @PathVariable("widgetId") long widgetId){
42 String controller = null;
44 logger.debug("DatabaseFileUploadController.getWidgetController: getting controller.js for widget with widgetId = {}" , widgetId);
45 controller = storageService.getWidgetController(widgetId);
47 logger.error("Exception occurred while performing DatabaseFileUploadController.getWidgetController in widget microservices. Details:" + e.getMessage());
53 @RequestMapping(value = "/microservices/{widgetId}/framework.js", method = RequestMethod.GET)
54 public String getWidgetFramework(HttpServletRequest request, HttpServletResponse response,
55 @PathVariable("widgetId") long widgetId){
56 String framework = null;
58 logger.debug("DatabaseFileUploadController.getWidgetFramework: getting framework.js for widget with widgetId = {}" , widgetId);
59 framework = storageService.getWidgetFramework(widgetId);
61 logger.error("Exception occurred while performing DatabaseFileUploadController.getWidgetFramework in widget microservices. Details:" + e.getMessage());
67 @RequestMapping(value = "/microservices/{widgetId}/styles.css", method = RequestMethod.GET)
68 public String getWidgetCSS(HttpServletRequest request, HttpServletResponse response,
69 @PathVariable("widgetId") long widgetId){
72 logger.debug("DatabaseFileUploadController.getWidgetCSS: getting styles.css for widget with widgetId = {}" , widgetId);
73 css = storageService.getWidgetCSS(widgetId);
74 } catch (UnsupportedEncodingException e) {
75 logger.error("Exception occurred while performing DatabaseFileUploadController.getWidgetCSS in widget microservices. Details:" + e.getMessage());