2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
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 * ============LICENSE_END=========================================================
21 package org.openecomp.vid.controller;
24 import java.io.UnsupportedEncodingException;
25 import java.text.DateFormat;
26 import java.text.SimpleDateFormat;
27 import java.util.HashMap;
30 import javax.servlet.ServletContext;
31 import javax.servlet.http.HttpServletRequest;
33 import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate;
35 import org.openecomp.aai.util.AAIRestInterface;
36 import org.springframework.beans.factory.annotation.Autowired;
37 import org.springframework.web.bind.annotation.PathVariable;
38 import org.springframework.web.bind.annotation.RequestMapping;
39 import org.springframework.web.bind.annotation.RequestMethod;
40 import org.springframework.web.bind.annotation.RestController;
41 import org.springframework.web.servlet.ModelAndView;
43 import org.openecomp.portalsdk.core.controller.RestrictedBaseController;
47 * The Class SubscriberDetailsController.
50 public class SubscriberDetailsController extends RestrictedBaseController{
56 EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(SubscriberDetailsController.class);
58 /** The Constant dateFormat. */
59 final static DateFormat dateFormat = new SimpleDateFormat("HH:mm:ss:SSSS");
62 protected String transId;
64 /** The from app id. */
65 protected String fromAppId = "VID";
68 private Map<String, Object> model = new HashMap<String, Object>();
70 /** The servlet context. */
71 private @Autowired ServletContext servletContext;
76 * @param request the request
77 * @return the model and view
79 @RequestMapping(value = {"/subscriberdetails" }, method = RequestMethod.GET)
80 public ModelAndView welcome(HttpServletRequest request) {
82 return new ModelAndView("subscriberdetails","model", model);
83 //return new ModelAndView(getViewName());
87 * @see org.openecomp.portalsdk.core.controller.RestrictedBaseController#getViewName()
89 public String getViewName() {
94 * @see org.openecomp.portalsdk.core.controller.RestrictedBaseController#setViewName(java.lang.String)
96 public void setViewName(String viewName) {
97 this.viewName = viewName;
101 * Gets the subscriber.
103 * @param subscriberId the subscriber id
105 @RequestMapping(value="/subscriberdetails/{subscriberId}", method = RequestMethod.GET)
106 public void GetSubscriber(@PathVariable("subscriberId") String subscriberId) throws UnsupportedEncodingException {
109 File certiPath = GetCertificatesPath();
110 AAIRestInterface restContrller = new AAIRestInterface(certiPath.getAbsolutePath());
112 subscriberId = restContrller.encodeURL(subscriberId);
118 String res1 = restContrller.RestGet(fromAppId, transId, "business/customers/customer/" + subscriberId, false);
119 model.put("customerInfo", res1);
124 * Gets the certificates path.
128 private File GetCertificatesPath()
130 if (servletContext != null)
131 return new File( servletContext.getRealPath("/WEB-INF/cert/") );