4c31dee54225f0350bb3568ddea671ec787571fa
[controller.git] / opendaylight / web / devices / src / main / java / org / opendaylight / controller / devices / web / Devices.java
1 /*
2  * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8
9 package org.opendaylight.controller.devices.web;
10
11 import java.util.ArrayList;
12 import java.util.HashMap;
13 import java.util.List;
14 import java.util.Map;
15 import java.util.Map.Entry;
16 import java.util.Set;
17 import java.util.TreeMap;
18 import java.util.concurrent.ConcurrentMap;
19 import javax.servlet.http.HttpServletRequest;
20 import javax.servlet.http.HttpServletResponse;
21
22 import org.codehaus.jackson.map.ObjectMapper;
23 import org.opendaylight.controller.usermanager.IUserManager;
24 import org.opendaylight.controller.web.IDaylightWeb;
25 import org.springframework.stereotype.Controller;
26 import org.springframework.web.bind.annotation.RequestMapping;
27 import org.springframework.web.bind.annotation.RequestMethod;
28 import org.springframework.web.bind.annotation.RequestParam;
29 import org.springframework.web.bind.annotation.ResponseBody;
30 import org.opendaylight.controller.forwarding.staticrouting.IForwardingStaticRouting;
31 import org.opendaylight.controller.forwarding.staticrouting.StaticRouteConfig;
32 import org.opendaylight.controller.sal.authorization.UserLevel;
33 import org.opendaylight.controller.sal.core.Config;
34 import org.opendaylight.controller.sal.core.Name;
35 import org.opendaylight.controller.sal.core.Node;
36 import org.opendaylight.controller.sal.core.NodeConnector;
37 import org.opendaylight.controller.sal.core.Tier;
38 import org.opendaylight.controller.sal.utils.GlobalConstants;
39 import org.opendaylight.controller.sal.utils.HexEncode;
40 import org.opendaylight.controller.sal.utils.ServiceHelper;
41 import org.opendaylight.controller.sal.utils.Status;
42 import org.opendaylight.controller.sal.utils.TierHelper;
43 import org.opendaylight.controller.switchmanager.ISwitchManager;
44 import org.opendaylight.controller.switchmanager.SpanConfig;
45 import org.opendaylight.controller.switchmanager.SubnetConfig;
46 import org.opendaylight.controller.switchmanager.Switch;
47 import org.opendaylight.controller.switchmanager.SwitchConfig;
48
49 import com.google.gson.Gson;
50
51 @Controller
52 @RequestMapping("/")
53 public class Devices implements IDaylightWeb {
54     private static final UserLevel AUTH_LEVEL = UserLevel.CONTAINERUSER;
55     private final String WEB_NAME = "Devices";
56     private final String WEB_ID = "devices";
57     private final short WEB_ORDER = 1;
58     private final String containerName = GlobalConstants.DEFAULT.toString();
59
60     public Devices() {
61         ServiceHelper.registerGlobalService(IDaylightWeb.class, this, null);
62     }
63
64     @Override
65     public String getWebName() {
66         return WEB_NAME;
67     }
68
69     @Override
70     public String getWebId() {
71         return WEB_ID;
72     }
73
74     @Override
75     public short getWebOrder() {
76         return WEB_ORDER;
77     }
78
79     @Override
80     public boolean isAuthorized(UserLevel userLevel) {
81         return userLevel.ordinal() <= AUTH_LEVEL.ordinal();
82     }
83
84     @RequestMapping(value = "/nodesLearnt", method = RequestMethod.GET)
85     @ResponseBody
86     public DevicesJsonBean getNodesLearnt() {
87         Gson gson = new Gson();
88         ISwitchManager switchManager = (ISwitchManager) ServiceHelper
89                 .getInstance(ISwitchManager.class, containerName, this);
90         List<Map<String, String>> nodeData = new ArrayList<Map<String, String>>();
91         for (Switch device : switchManager.getNetworkDevices()) {
92             HashMap<String, String> nodeDatum = new HashMap<String, String>();
93             Node node = device.getNode();
94             Tier tier = (Tier) switchManager.getNodeProp(node,
95                     Tier.TierPropName);
96
97             nodeDatum.put("containerName", containerName);
98             nodeDatum.put("nodeName", switchManager.getNodeDescription(node));
99             nodeDatum.put("nodeId", node.toString());
100             int tierNumber = (tier == null) ? TierHelper.unknownTierNumber
101                     : tier.getValue();
102             nodeDatum.put("tierName", TierHelper.getTierName(tierNumber)
103                     + " (Tier-" + tierNumber + ")");
104             nodeDatum.put("tier", tierNumber + "");
105             SwitchConfig sc = switchManager.getSwitchConfig(device.getNode()
106                     .toString());
107             String modeStr = (sc != null) ? sc.getMode() : "0";
108             nodeDatum.put("mode", modeStr);
109
110             nodeDatum.put("json", gson.toJson(nodeDatum));
111             nodeDatum.put("mac",
112                     HexEncode.bytesToHexString(device.getDataLayerAddress()));
113             StringBuffer sb1 = new StringBuffer();
114             Set<NodeConnector> nodeConnectorSet = device.getNodeConnectors();
115             if (nodeConnectorSet != null && nodeConnectorSet.size() > 0) {
116                 Map<Short, String> portList = new HashMap<Short, String>();
117                 for (NodeConnector nodeConnector : nodeConnectorSet) {
118                     String nodeConnectorNumberToStr = nodeConnector.getID().toString();
119                     Name ncName = ((Name) switchManager.getNodeConnectorProp(
120                             nodeConnector, Name.NamePropName));
121                     Config portStatus = ((Config) switchManager
122                             .getNodeConnectorProp(nodeConnector,
123                                     Config.ConfigPropName));
124                     
125                     String nodeConnectorName = (ncName != null) ? ncName.getValue()
126                             : "";
127                     nodeConnectorName += " ("+nodeConnector.getID()+")";
128                     if (portStatus.getValue() == Config.ADMIN_UP) {
129                         nodeConnectorName = "<span style='color:green;'>"+nodeConnectorName+"</span>";
130                     } else if (portStatus.getValue() == Config.ADMIN_DOWN) {
131                         nodeConnectorName = "<span style='color:red;'>"+nodeConnectorName+"</span>";
132                     }
133                     
134                     portList.put(Short.parseShort(nodeConnectorNumberToStr),
135                             nodeConnectorName);
136                 }
137
138                 Map<Short, String> sortedPortList = new TreeMap<Short, String>(portList);
139
140                 for (Entry<Short, String> e : sortedPortList.entrySet()) {
141                     sb1.append(e.getValue());
142                     sb1.append("<br>");
143                 }
144             }
145             nodeDatum.put("ports", sb1.toString());
146             nodeData.add(nodeDatum);
147         }
148         DevicesJsonBean result = new DevicesJsonBean();
149         result.setNodeData(nodeData);
150         List<String> columnNames = new ArrayList<String>();
151         columnNames.add("Node ID");
152         columnNames.add("Node Name");
153         columnNames.add("Tier");
154         columnNames.add("Mac Address");
155         columnNames.add("Ports");
156         columnNames.add("Port Status");
157
158         result.setColumnNames(columnNames);
159         return result;
160     }
161
162     @RequestMapping(value = "/tiers", method = RequestMethod.GET)
163     @ResponseBody
164     public List<String> getTiers() {
165         return TierHelper.getTiers();
166     }
167
168     @RequestMapping(value = "/nodesLearnt/update", method = RequestMethod.GET)
169     @ResponseBody
170     public StatusJsonBean updateLearntNode(
171             @RequestParam("nodeName") String nodeName,
172             @RequestParam("nodeId") String nodeId,
173             @RequestParam("tier") String tier,
174             @RequestParam("operationMode") String operationMode,
175             HttpServletRequest request) {
176         if (!authorize(UserLevel.NETWORKADMIN, request)) {
177             return unauthorizedMessage();
178         }
179
180         StatusJsonBean resultBean = new StatusJsonBean();
181         try {
182             ISwitchManager switchManager = (ISwitchManager) ServiceHelper
183                     .getInstance(ISwitchManager.class, containerName, this);
184             SwitchConfig cfg = new SwitchConfig(nodeId, nodeName, tier,
185                     operationMode);
186             switchManager.updateSwitchConfig(cfg);
187             resultBean.setStatus(true);
188             resultBean.setMessage("Updated node information successfully");
189         } catch (Exception e) {
190             resultBean.setStatus(false);
191             resultBean.setMessage("Error updating node information. "
192                     + e.getMessage());
193         }
194         return resultBean;
195     }
196
197     @RequestMapping(value = "/staticRoutes", method = RequestMethod.GET)
198     @ResponseBody
199     public DevicesJsonBean getStaticRoutes() {
200         Gson gson = new Gson();
201         IForwardingStaticRouting staticRouting = (IForwardingStaticRouting) ServiceHelper
202                 .getInstance(IForwardingStaticRouting.class, containerName,
203                         this);
204         List<Map<String, String>> staticRoutes = new ArrayList<Map<String, String>>();
205         ConcurrentMap<String, StaticRouteConfig> routeConfigs = staticRouting
206                 .getStaticRouteConfigs();
207         if (routeConfigs == null) {
208             return null;
209         }
210         for (StaticRouteConfig conf : routeConfigs.values()) {
211             Map<String, String> staticRoute = new HashMap<String, String>();
212             staticRoute.put("name", conf.getName());
213             staticRoute.put("staticRoute", conf.getStaticRoute());
214             staticRoute.put("nextHopType", conf.getNextHopType());
215             staticRoute.put("nextHop", conf.getNextHop());
216             staticRoute.put("json", gson.toJson(conf));
217             staticRoutes.add(staticRoute);
218         }
219         DevicesJsonBean result = new DevicesJsonBean();
220         result.setColumnNames(StaticRouteConfig.getGuiFieldsNames());
221         result.setNodeData(staticRoutes);
222         return result;
223     }
224
225     @RequestMapping(value = "/staticRoute/add", method = RequestMethod.GET)
226     @ResponseBody
227     public StatusJsonBean addStaticRoute(
228             @RequestParam("routeName") String routeName,
229             @RequestParam("staticRoute") String staticRoute,
230             @RequestParam("nextHop") String nextHop, HttpServletRequest request) {
231         if (!authorize(UserLevel.NETWORKADMIN, request)) {
232             return unauthorizedMessage();
233         }
234
235         StatusJsonBean result = new StatusJsonBean();
236         try {
237             IForwardingStaticRouting staticRouting = (IForwardingStaticRouting) ServiceHelper
238                     .getInstance(IForwardingStaticRouting.class, containerName,
239                             this);
240             StaticRouteConfig config = new StaticRouteConfig();
241             config.setName(routeName);
242             config.setStaticRoute(staticRoute);
243             config.setNextHop(nextHop);
244             Status addStaticRouteResult = staticRouting.addStaticRoute(config);
245             if (addStaticRouteResult.isSuccess()) {
246                 result.setStatus(true);
247                 result.setMessage("Static Route saved successfully");
248             } else {
249                 result.setStatus(false);
250                 result.setMessage(addStaticRouteResult.getDescription());
251             }
252         } catch (Exception e) {
253             result.setStatus(false);
254             result.setMessage("Error - " + e.getMessage());
255         }
256         return result;
257     }
258
259     @RequestMapping(value = "/staticRoute/delete", method = RequestMethod.GET)
260     @ResponseBody
261     public StatusJsonBean deleteStaticRoute(
262             @RequestParam("routesToDelete") String routesToDelete,
263             HttpServletRequest request) {
264         if (!authorize(UserLevel.NETWORKADMIN, request)) {
265             return unauthorizedMessage();
266         }
267
268         StatusJsonBean resultBean = new StatusJsonBean();
269         try {
270             IForwardingStaticRouting staticRouting = (IForwardingStaticRouting) ServiceHelper
271                     .getInstance(IForwardingStaticRouting.class, containerName,
272                             this);
273             String[] routes = routesToDelete.split(",");
274             Status result;
275             resultBean.setStatus(true);
276             resultBean
277                     .setMessage("Successfully deleted selected static routes");
278             for (String route : routes) {
279                 result = staticRouting.removeStaticRoute(route);
280                 if (!result.isSuccess()) {
281                     resultBean.setStatus(false);
282                     resultBean.setMessage(result.getDescription());
283                     break;
284                 }
285             }
286         } catch (Exception e) {
287             resultBean.setStatus(false);
288             resultBean
289                     .setMessage("Error occurred while deleting static routes. "
290                             + e.getMessage());
291         }
292         return resultBean;
293     }
294
295     @RequestMapping(value = "/subnets", method = RequestMethod.GET)
296     @ResponseBody
297     public DevicesJsonBean getSubnetGateways() {
298         Gson gson = new Gson();
299         List<Map<String, String>> subnets = new ArrayList<Map<String, String>>();
300         ISwitchManager switchManager = (ISwitchManager) ServiceHelper
301                 .getInstance(ISwitchManager.class, containerName, this);
302         for (SubnetConfig conf : switchManager.getSubnetsConfigList()) {
303             Map<String, String> subnet = new HashMap<String, String>();
304             subnet.put("name", conf.getName());
305             subnet.put("subnet", conf.getSubnet());
306             subnet.put("json", gson.toJson(conf));
307             subnets.add(subnet);
308         }
309         DevicesJsonBean result = new DevicesJsonBean();
310         result.setColumnNames(SubnetConfig.getGuiFieldsNames());
311         result.setNodeData(subnets);
312         return result;
313     }
314
315     @RequestMapping(value = "/subnetGateway/add", method = RequestMethod.GET)
316     @ResponseBody
317     public StatusJsonBean addSubnetGateways(
318             @RequestParam("gatewayName") String gatewayName,
319             @RequestParam("gatewayIPAddress") String gatewayIPAddress,
320             HttpServletRequest request) {
321         if (!authorize(UserLevel.NETWORKADMIN, request)) {
322             return unauthorizedMessage();
323         }
324
325         StatusJsonBean resultBean = new StatusJsonBean();
326         try {
327             ISwitchManager switchManager = (ISwitchManager) ServiceHelper
328                     .getInstance(ISwitchManager.class, containerName, this);
329             SubnetConfig cfgObject = new SubnetConfig(gatewayName,
330                     gatewayIPAddress, new ArrayList<String>());
331             Status result = switchManager.addSubnet(cfgObject);
332             if (result.isSuccess()) {
333                 resultBean.setStatus(true);
334                 resultBean.setMessage("Added gateway address successfully");
335             } else {
336                 resultBean.setStatus(false);
337                 resultBean.setMessage(result.getDescription());
338             }
339         } catch (Exception e) {
340             resultBean.setStatus(false);
341             resultBean.setMessage(e.getMessage());
342         }
343         return resultBean;
344     }
345
346     @RequestMapping(value = "/subnetGateway/delete", method = RequestMethod.GET)
347     @ResponseBody
348     public StatusJsonBean deleteSubnetGateways(
349             @RequestParam("gatewaysToDelete") String gatewaysToDelete,
350             HttpServletRequest request) {
351         if (!authorize(UserLevel.NETWORKADMIN, request)) {
352             return unauthorizedMessage();
353         }
354
355         StatusJsonBean resultBean = new StatusJsonBean();
356         try {
357             ISwitchManager switchManager = (ISwitchManager) ServiceHelper
358                     .getInstance(ISwitchManager.class, containerName, this);
359             String[] subnets = gatewaysToDelete.split(",");
360             resultBean.setStatus(true);
361             resultBean.setMessage("Added gateway address successfully");
362             for (String subnet : subnets) {
363                 Status result = switchManager.removeSubnet(subnet);
364                 if (!result.isSuccess()) {
365                     resultBean.setStatus(false);
366                     resultBean.setMessage(result.getDescription());
367                     break;
368                 }
369             }
370         } catch (Exception e) {
371             resultBean.setStatus(false);
372             resultBean.setMessage(e.getMessage());
373         }
374         return resultBean;
375     }
376
377     @RequestMapping(value = "/subnetGateway/ports/add", method = RequestMethod.GET)
378     @ResponseBody
379     public StatusJsonBean addSubnetGatewayPort(
380             @RequestParam("portsName") String portsName,
381             @RequestParam("ports") String ports,
382             @RequestParam("nodeId") String nodeId, HttpServletRequest request) {
383         if (!authorize(UserLevel.NETWORKADMIN, request)) {
384             return unauthorizedMessage();
385         }
386
387         StatusJsonBean resultBean = new StatusJsonBean();
388         try {
389             ISwitchManager switchManager = (ISwitchManager) ServiceHelper
390                     .getInstance(ISwitchManager.class, containerName, this);
391             Status result = switchManager.addPortsToSubnet(portsName, nodeId
392                     + "/" + ports);
393
394             if (result.isSuccess()) {
395                 resultBean.setStatus(true);
396                 resultBean
397                         .setMessage("Added ports to subnet gateway address successfully");
398             } else {
399                 resultBean.setStatus(false);
400                 resultBean.setMessage(result.getDescription());
401             }
402         } catch (Exception e) {
403             resultBean.setStatus(false);
404             resultBean.setMessage(e.getMessage());
405         }
406         return resultBean;
407     }
408
409     @RequestMapping(value = "/subnetGateway/ports/delete", method = RequestMethod.GET)
410     @ResponseBody
411     public StatusJsonBean deleteSubnetGatewayPort(
412             @RequestParam("gatewayName") String gatewayName,
413             @RequestParam("nodePort") String nodePort,
414             HttpServletRequest request) {
415         if (!authorize(UserLevel.NETWORKADMIN, request)) {
416             return unauthorizedMessage();
417         }
418
419         StatusJsonBean resultBean = new StatusJsonBean();
420         try {
421             ISwitchManager switchManager = (ISwitchManager) ServiceHelper
422                     .getInstance(ISwitchManager.class, containerName, this);
423             Status result = switchManager.removePortsFromSubnet(gatewayName,
424                     nodePort);
425
426             if (result.isSuccess()) {
427                 resultBean.setStatus(true);
428                 resultBean
429                         .setMessage("Deleted port from subnet gateway address successfully");
430             } else {
431                 resultBean.setStatus(false);
432                 resultBean.setMessage(result.getDescription());
433             }
434         } catch (Exception e) {
435             resultBean.setStatus(false);
436             resultBean.setMessage(e.getMessage());
437         }
438         return resultBean;
439     }
440
441     @RequestMapping(value = "/spanPorts", method = RequestMethod.GET)
442     @ResponseBody
443     public DevicesJsonBean getSpanPorts() {
444         Gson gson = new Gson();
445         List<String> spanConfigs_json = new ArrayList<String>();
446         ISwitchManager switchManager = (ISwitchManager) ServiceHelper
447                 .getInstance(ISwitchManager.class, containerName, this);
448         for (SpanConfig conf : switchManager.getSpanConfigList()) {
449             spanConfigs_json.add(gson.toJson(conf));
450         }
451         ObjectMapper mapper = new ObjectMapper();
452         List<Map<String, String>> spanConfigs = new ArrayList<Map<String, String>>();
453         for (String config_json : spanConfigs_json) {
454             try {
455                 @SuppressWarnings("unchecked")
456                 Map<String, String> config_data = mapper.readValue(config_json,
457                         HashMap.class);
458                 Map<String, String> config = new HashMap<String, String>();
459                 for (String name : config_data.keySet()) {
460                     config.put(name, config_data.get(name));
461                     // Add switch name value (non-configuration field)
462                     config.put("nodeName",
463                             getNodeDesc(config_data.get("nodeId")));
464                 }
465                 config.put("json", config_json);
466                 spanConfigs.add(config);
467             } catch (Exception e) {
468                 // TODO: Handle the exception.
469             }
470         }
471         DevicesJsonBean result = new DevicesJsonBean();
472         result.setColumnNames(SpanConfig.getGuiFieldsNames());
473         result.setNodeData(spanConfigs);
474         return result;
475     }
476
477     @RequestMapping(value = "/nodeports")
478     @ResponseBody
479     public Map<String, Object> getNodePorts() {
480         ISwitchManager switchManager = (ISwitchManager) ServiceHelper
481                 .getInstance(ISwitchManager.class, containerName, this);
482         if (switchManager == null)
483             return null;
484
485         Map<String, Object> nodes = new HashMap<String, Object>();
486         Map<Short, String> port;
487
488         for (Switch node : switchManager.getNetworkDevices()) {
489             port = new HashMap<Short, String>(); // new port
490             Set<NodeConnector> nodeConnectorSet = node.getNodeConnectors();
491
492             if (nodeConnectorSet != null)
493                 for (NodeConnector nodeConnector : nodeConnectorSet) {
494                     String nodeConnectorName = ((Name) switchManager
495                             .getNodeConnectorProp(nodeConnector,
496                                     Name.NamePropName)).getValue();
497                     port.put((Short) nodeConnector.getID(), nodeConnectorName
498                             + "(" + nodeConnector.getID() + ")");
499                 }
500
501             nodes.put(node.getNode().toString(), port);
502         }
503
504         return nodes;
505     }
506
507     @RequestMapping(value = "/spanPorts/add", method = RequestMethod.GET)
508     @ResponseBody
509     public StatusJsonBean addSpanPort(
510             @RequestParam("jsonData") String jsonData,
511             HttpServletRequest request) {
512         if (!authorize(UserLevel.NETWORKADMIN, request)) {
513             return unauthorizedMessage();
514         }
515
516         StatusJsonBean resultBean = new StatusJsonBean();
517         try {
518             Gson gson = new Gson();
519             ISwitchManager switchManager = (ISwitchManager) ServiceHelper
520                     .getInstance(ISwitchManager.class, containerName, this);
521             SpanConfig cfgObject = gson.fromJson(jsonData, SpanConfig.class);
522             Status result = switchManager.addSpanConfig(cfgObject);
523             if (result.isSuccess()) {
524                 resultBean.setStatus(true);
525                 resultBean.setMessage("SPAN Port added successfully");
526             } else {
527                 resultBean.setStatus(false);
528                 resultBean.setMessage(result.getDescription());
529             }
530         } catch (Exception e) {
531             resultBean.setStatus(false);
532             resultBean.setMessage("Error occurred while adding span port. "
533                     + e.getMessage());
534         }
535         return resultBean;
536     }
537
538     @RequestMapping(value = "/spanPorts/delete", method = RequestMethod.GET)
539     @ResponseBody
540     public StatusJsonBean deleteSpanPorts(
541             @RequestParam("spanPortsToDelete") String spanPortsToDelete,
542             HttpServletRequest request) {
543         if (!authorize(UserLevel.NETWORKADMIN, request)) {
544             return unauthorizedMessage();
545         }
546
547         StatusJsonBean resultBean = new StatusJsonBean();
548         try {
549             Gson gson = new Gson();
550             ISwitchManager switchManager = (ISwitchManager) ServiceHelper
551                     .getInstance(ISwitchManager.class, containerName, this);
552             String[] spans = spanPortsToDelete.split("###");
553             resultBean.setStatus(true);
554             resultBean.setMessage("SPAN Port(s) deleted successfully");
555             for (String span : spans) {
556                 if (!span.isEmpty()) {
557                     SpanConfig cfgObject = gson
558                             .fromJson(span, SpanConfig.class);
559                     Status result = switchManager.removeSpanConfig(cfgObject);
560                     if (!result.isSuccess()) {
561                         resultBean.setStatus(false);
562                         resultBean.setMessage(result.getDescription());
563                         break;
564                     }
565                 }
566             }
567         } catch (Exception e) {
568             resultBean.setStatus(false);
569             resultBean.setMessage("Error occurred while deleting span port. "
570                     + e.getMessage());
571         }
572         return resultBean;
573     }
574
575     private String getNodeDesc(String nodeId) {
576         ISwitchManager switchManager = (ISwitchManager) ServiceHelper
577                 .getInstance(ISwitchManager.class, containerName, this);
578         String description = "";
579         if (switchManager != null) {
580             description = switchManager.getNodeDescription(Node
581                     .fromString(nodeId));
582         }
583         return (description.isEmpty() || description.equalsIgnoreCase("none")) ? nodeId
584                 : description;
585     }
586
587     /**
588      * Is the operation permitted for the given level
589      * 
590      * @param level
591      */
592     private boolean authorize(UserLevel level, HttpServletRequest request) {
593         IUserManager userManager = (IUserManager) ServiceHelper
594                 .getGlobalInstance(IUserManager.class, this);
595         if (userManager == null) {
596             return false;
597         }
598
599         String username = request.getUserPrincipal().getName();
600         UserLevel userLevel = userManager.getUserLevel(username);
601         if (userLevel.toNumber() <= level.toNumber()) {
602             return true;
603         }
604         return false;
605     }
606
607     private StatusJsonBean unauthorizedMessage() {
608         StatusJsonBean message = new StatusJsonBean();
609         message.setStatus(false);
610         message.setMessage("Operation not authorized");
611         return message;
612     }
613
614     @RequestMapping(value = "login")
615     public String login(final HttpServletRequest request,
616             final HttpServletResponse response) {
617         // response.setHeader("X-Page-Location", "/login");
618         /*
619          * IUserManager userManager = (IUserManager) ServiceHelper
620          * .getGlobalInstance(IUserManager.class, this); if (userManager ==
621          * null) { return "User Manager is not available"; }
622          * 
623          * String username = request.getUserPrincipal().getName();
624          * 
625          * 
626          * model.addAttribute("username", username); model.addAttribute("role",
627          * userManager.getUserLevel(username).toNumber());
628          */
629         return "forward:" + "/";
630     }
631
632 }