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.controller.sample;
22 import javax.servlet.http.HttpServletRequest;
23 import javax.servlet.http.HttpServletResponse;
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;
35 public class ElementModelController extends RestrictedBaseController {
37 private EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(ElementModelController.class);
39 @RequestMapping(value = { "/elementMapLayout" }, method = RequestMethod.GET, produces = "text/plain")
40 public String layout(HttpServletRequest request, HttpServletResponse response) throws Exception {
42 String collapseDomains = request.getParameter("collapsedDomains");
43 String expandDomains = request.getParameter("expandedDomains");
45 String contentFileName = request.getParameter("contentFileName");
46 String layoutFileName = request.getParameter("layoutFileName");
48 final String realPath = request.getServletContext().getRealPath("/");
49 logger.debug(EELFLoggerDelegate.debugLogger, "layout: servlet context real path: {}", realPath);
51 ElementMapService eltMapSvc = new ElementMapService();
52 String yamlString = eltMapSvc.buildElementMapYaml(
53 new String[] { collapseDomains, expandDomains, realPath, contentFileName, layoutFileName });
58 @RequestMapping(value = { "/elementMapLink" }, method = RequestMethod.GET, produces = "text/plain")
59 public String callflow(HttpServletRequest request, HttpServletResponse response) throws Exception {
61 String callFlowName = request.getParameter("callFlowName");
62 String callFlowStep = request.getParameter("callFlowStep");
64 final String realPath = request.getServletContext().getRealPath("/");
65 logger.debug(EELFLoggerDelegate.debugLogger, "callflow: servlet context real path: {}", realPath);
67 ElementLinkService eltLinkSvc = new ElementLinkService();
68 String yamlString = eltLinkSvc.buildElementLinkYaml(new String[] { realPath, callFlowName, callFlowStep });
74 public ModelAndView callflowAdditional(HttpServletRequest request, HttpServletResponse response) throws Exception {
76 Map<String, Object> model = new HashMap<String, Object>();
77 String callFlowName = request.getParameter("callFlowName");
78 String callFlowStep = request.getParameter("callFlowStep");
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);