e36458fd9abc643ae94dbb12273d14e816493fe8
[portal/sdk.git] /
1 /*-
2  * ================================================================================
3  * ECOMP Portal SDK
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
10  * 
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  * 
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  * ================================================================================
19  */
20 package org.openecomp.portalapp.controller.sample;
21
22 import javax.servlet.http.HttpServletRequest;
23 import javax.servlet.http.HttpServletResponse;
24
25 import org.openecomp.portalsdk.core.controller.RestrictedBaseController;
26 import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate;
27 import org.openecomp.portalsdk.core.service.ElementLinkService;
28 import org.openecomp.portalsdk.core.service.ElementMapService;
29 import org.springframework.web.bind.annotation.RequestMapping;
30 import org.springframework.web.bind.annotation.RequestMethod;
31 import org.springframework.web.bind.annotation.RestController;
32
33 @RestController
34 @RequestMapping("/")
35 public class ElementModelController extends RestrictedBaseController {
36
37         private EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(ElementModelController.class);
38
39         @RequestMapping(value = { "/elementMapLayout" }, method = RequestMethod.GET, produces = "text/plain")
40         public String layout(HttpServletRequest request, HttpServletResponse response) throws Exception {
41
42                 String collapseDomains = request.getParameter("collapsedDomains");
43                 String expandDomains = request.getParameter("expandedDomains");
44
45                 String contentFileName = request.getParameter("contentFileName");
46                 String layoutFileName = request.getParameter("layoutFileName");
47
48                 final String realPath = request.getServletContext().getRealPath("/");
49                 logger.debug(EELFLoggerDelegate.debugLogger, "layout: servlet context real path: {}", realPath);
50
51                 ElementMapService eltMapSvc = new ElementMapService();
52                 String yamlString = eltMapSvc.buildElementMapYaml(
53                                 new String[] { collapseDomains, expandDomains, realPath, contentFileName, layoutFileName });
54
55                 return yamlString;
56         }
57
58         @RequestMapping(value = { "/elementMapLink" }, method = RequestMethod.GET, produces = "text/plain")
59         public String callflow(HttpServletRequest request, HttpServletResponse response) throws Exception {
60
61                 String callFlowName = request.getParameter("callFlowName");
62                 String callFlowStep = request.getParameter("callFlowStep");
63
64                 final String realPath = request.getServletContext().getRealPath("/");
65                 logger.debug(EELFLoggerDelegate.debugLogger, "callflow: servlet context real path: {}", realPath);
66
67                 ElementLinkService eltLinkSvc = new ElementLinkService();
68                 String yamlString = eltLinkSvc.buildElementLinkYaml(new String[] { realPath, callFlowName, callFlowStep });
69
70                 return yamlString;
71         }
72
73         /*
74         public ModelAndView callflowAdditional(HttpServletRequest request, HttpServletResponse response) throws Exception {
75
76                 Map<String, Object> model = new HashMap<String, Object>();
77                 String callFlowName = request.getParameter("callFlowName");
78                 String callFlowStep = request.getParameter("callFlowStep");
79
80                 ElementLinkService main = new ElementLinkService();
81                 String yamlString = main.main2(new String[] { callFlowName, callFlowStep });
82                 model.put("output_string", yamlString);
83                 return new ModelAndView("data_out", "model", model);
84         }
85         */
86
87 }