[VID-3] Setting docker image tag
[vid.git] / vid / src / main / java / org / openecomp / vid / controller / SubscriberDetailsController.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * VID
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
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  * ============LICENSE_END=========================================================
19  */
20
21 package org.openecomp.vid.controller;
22
23 import java.io.File;
24 import java.io.UnsupportedEncodingException;
25 import java.text.DateFormat;
26 import java.text.SimpleDateFormat;
27 import java.util.HashMap;
28 import java.util.Map;
29
30 import javax.servlet.ServletContext;
31 import javax.servlet.http.HttpServletRequest;
32
33 import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate;
34
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;
42
43 import org.openecomp.portalsdk.core.controller.RestrictedBaseController;
44
45
46 /**
47  * The Class SubscriberDetailsController.
48  */
49 @RestController
50 public class SubscriberDetailsController extends RestrictedBaseController{
51         
52         /** The view name. */
53         String viewName;
54         
55         /** The logger. */
56         EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(SubscriberDetailsController.class);
57         
58         /** The Constant dateFormat. */
59         final static DateFormat dateFormat = new SimpleDateFormat("HH:mm:ss:SSSS");
60         
61         /** The trans id. */
62         protected String transId;
63         
64         /** The from app id. */
65         protected String fromAppId = "VID";
66         
67         /** The model. */
68         private Map<String, Object> model = new HashMap<String, Object>();
69         
70         /** The servlet context. */
71         private @Autowired ServletContext servletContext;
72         
73         /**
74          * Welcome.
75          *
76          * @param request the request
77          * @return the model and view
78          */
79         @RequestMapping(value = {"/subscriberdetails" }, method = RequestMethod.GET)
80         public ModelAndView welcome(HttpServletRequest request) {
81         
82                 return new ModelAndView("subscriberdetails","model", model);
83           //return new ModelAndView(getViewName());             
84         }
85         
86         /* (non-Javadoc)
87          * @see org.openecomp.portalsdk.core.controller.RestrictedBaseController#getViewName()
88          */
89         public String getViewName() {
90                 return viewName;
91         }
92         
93         /* (non-Javadoc)
94          * @see org.openecomp.portalsdk.core.controller.RestrictedBaseController#setViewName(java.lang.String)
95          */
96         public void setViewName(String viewName) {
97                 this.viewName = viewName;
98         }
99         
100         /**
101          * Gets the subscriber.
102          *
103          * @param subscriberId the subscriber id
104          */
105         @RequestMapping(value="/subscriberdetails/{subscriberId}", method = RequestMethod.GET)
106         public void GetSubscriber(@PathVariable("subscriberId") String subscriberId) throws UnsupportedEncodingException  {
107                  
108                 
109                    File certiPath = GetCertificatesPath();
110                    AAIRestInterface restContrller = new AAIRestInterface(certiPath.getAbsolutePath());
111                    try {
112                            subscriberId = restContrller.encodeURL(subscriberId);
113                    }
114                    catch (Exception e)
115                    {
116                            
117                    }
118                    String res1 = restContrller.RestGet(fromAppId, transId, "business/customers/customer/" + subscriberId, false);
119                model.put("customerInfo", res1);
120         
121         }
122         
123         /**
124          * Gets the certificates path.
125          *
126          * @return the file
127          */
128         private File GetCertificatesPath()
129         {
130                 if (servletContext != null)
131                         return new File( servletContext.getRealPath("/WEB-INF/cert/") );
132          
133                 
134                 return null;
135         }
136 }
137