@Test public void testGetLoginInfo() throws Exception { String result = controller.getLoginInfo(request, response); SimpleObject loginInfo = SimpleObject.parseJson(result); Assert.assertEquals("ba1b19c2-3ed6-4f63-b8c0-f762dc8d7562", loginInfo.get("personUuid")); }
@RequestMapping(method = RequestMethod.GET) @WSDoc("Get Login information") @ResponseBody() public String getLoginInfo(HttpServletRequest request, HttpServletResponse response) throws ResponseException { SimpleObject obj = new SimpleObject(); if (Context.isAuthenticated()) { User u = Context.getAuthenticatedUser(); Person p = Context.getPersonService().getPersonByUuid(u.getPerson().getUuid()); Provider provider = Context.getProviderService().getProvidersByPerson(p).iterator().next(); obj.add("personUuid", p.getUuid()); if (provider != null) { obj.add("providerUuid", provider.getUuid()); ArrayList attributesObj = new ArrayList(); Iterator<ProviderAttribute> attributesIterator = provider.getActiveAttributes().iterator(); while (attributesIterator.hasNext()) { SimpleObject attributeObj = new SimpleObject(); ProviderAttribute pAttribute = attributesIterator.next(); attributeObj.add("attributeType", pAttribute.getAttributeType().getName()); attributeObj.add("value", pAttribute.getValue()); attributesObj.add(attributeObj); } obj.add("providerAttributes", attributesObj); } obj.add("display", p.getPersonName().getFullName()); if (p.getAttribute("Health Center") != null) { obj.add("location", Context.getLocationService().getLocation( Integer.parseInt(p.getAttribute("Health Center").getValue())).getUuid()); } obj.add("roles", u.getAllRoles()); obj.add("privileges", u.getPrivileges()); obj.add("serverTime", Calendar.getInstance().getTime()); return gson.toJson(obj); } else { throw new ResponseException( "Not Authenticated") {}; } }
RaxaLoginController extends BaseRestController { @RequestMapping(method = RequestMethod.GET) @WSDoc("Get Login information") @ResponseBody() public String getLoginInfo(HttpServletRequest request, HttpServletResponse response) throws ResponseException { SimpleObject obj = new SimpleObject(); if (Context.isAuthenticated()) { User u = Context.getAuthenticatedUser(); Person p = Context.getPersonService().getPersonByUuid(u.getPerson().getUuid()); Provider provider = Context.getProviderService().getProvidersByPerson(p).iterator().next(); obj.add("personUuid", p.getUuid()); if (provider != null) { obj.add("providerUuid", provider.getUuid()); ArrayList attributesObj = new ArrayList(); Iterator<ProviderAttribute> attributesIterator = provider.getActiveAttributes().iterator(); while (attributesIterator.hasNext()) { SimpleObject attributeObj = new SimpleObject(); ProviderAttribute pAttribute = attributesIterator.next(); attributeObj.add("attributeType", pAttribute.getAttributeType().getName()); attributeObj.add("value", pAttribute.getValue()); attributesObj.add(attributeObj); } obj.add("providerAttributes", attributesObj); } obj.add("display", p.getPersonName().getFullName()); if (p.getAttribute("Health Center") != null) { obj.add("location", Context.getLocationService().getLocation( Integer.parseInt(p.getAttribute("Health Center").getValue())).getUuid()); } obj.add("roles", u.getAllRoles()); obj.add("privileges", u.getPrivileges()); obj.add("serverTime", Calendar.getInstance().getTime()); return gson.toJson(obj); } else { throw new ResponseException( "Not Authenticated") {}; } } }
RaxaLoginController extends BaseRestController { @RequestMapping(method = RequestMethod.GET) @WSDoc("Get Login information") @ResponseBody() public String getLoginInfo(HttpServletRequest request, HttpServletResponse response) throws ResponseException { SimpleObject obj = new SimpleObject(); if (Context.isAuthenticated()) { User u = Context.getAuthenticatedUser(); Person p = Context.getPersonService().getPersonByUuid(u.getPerson().getUuid()); Provider provider = Context.getProviderService().getProvidersByPerson(p).iterator().next(); obj.add("personUuid", p.getUuid()); if (provider != null) { obj.add("providerUuid", provider.getUuid()); ArrayList attributesObj = new ArrayList(); Iterator<ProviderAttribute> attributesIterator = provider.getActiveAttributes().iterator(); while (attributesIterator.hasNext()) { SimpleObject attributeObj = new SimpleObject(); ProviderAttribute pAttribute = attributesIterator.next(); attributeObj.add("attributeType", pAttribute.getAttributeType().getName()); attributeObj.add("value", pAttribute.getValue()); attributesObj.add(attributeObj); } obj.add("providerAttributes", attributesObj); } obj.add("display", p.getPersonName().getFullName()); if (p.getAttribute("Health Center") != null) { obj.add("location", Context.getLocationService().getLocation( Integer.parseInt(p.getAttribute("Health Center").getValue())).getUuid()); } obj.add("roles", u.getAllRoles()); obj.add("privileges", u.getPrivileges()); obj.add("serverTime", Calendar.getInstance().getTime()); return gson.toJson(obj); } else { throw new ResponseException( "Not Authenticated") {}; } }  }
RaxaLoginController extends BaseRestController { @RequestMapping(method = RequestMethod.GET) @WSDoc("Get Login information") @ResponseBody() public String getLoginInfo(HttpServletRequest request, HttpServletResponse response) throws ResponseException { SimpleObject obj = new SimpleObject(); if (Context.isAuthenticated()) { User u = Context.getAuthenticatedUser(); Person p = Context.getPersonService().getPersonByUuid(u.getPerson().getUuid()); Provider provider = Context.getProviderService().getProvidersByPerson(p).iterator().next(); obj.add("personUuid", p.getUuid()); if (provider != null) { obj.add("providerUuid", provider.getUuid()); ArrayList attributesObj = new ArrayList(); Iterator<ProviderAttribute> attributesIterator = provider.getActiveAttributes().iterator(); while (attributesIterator.hasNext()) { SimpleObject attributeObj = new SimpleObject(); ProviderAttribute pAttribute = attributesIterator.next(); attributeObj.add("attributeType", pAttribute.getAttributeType().getName()); attributeObj.add("value", pAttribute.getValue()); attributesObj.add(attributeObj); } obj.add("providerAttributes", attributesObj); } obj.add("display", p.getPersonName().getFullName()); if (p.getAttribute("Health Center") != null) { obj.add("location", Context.getLocationService().getLocation( Integer.parseInt(p.getAttribute("Health Center").getValue())).getUuid()); } obj.add("roles", u.getAllRoles()); obj.add("privileges", u.getPrivileges()); obj.add("serverTime", Calendar.getInstance().getTime()); return gson.toJson(obj); } else { throw new ResponseException( "Not Authenticated") {}; } }  @RequestMapping(method = RequestMethod.GET) @WSDoc("Get Login information") @ResponseBody() String getLoginInfo(HttpServletRequest request, HttpServletResponse response); }
RaxaLoginController extends BaseRestController { @RequestMapping(method = RequestMethod.GET) @WSDoc("Get Login information") @ResponseBody() public String getLoginInfo(HttpServletRequest request, HttpServletResponse response) throws ResponseException { SimpleObject obj = new SimpleObject(); if (Context.isAuthenticated()) { User u = Context.getAuthenticatedUser(); Person p = Context.getPersonService().getPersonByUuid(u.getPerson().getUuid()); Provider provider = Context.getProviderService().getProvidersByPerson(p).iterator().next(); obj.add("personUuid", p.getUuid()); if (provider != null) { obj.add("providerUuid", provider.getUuid()); ArrayList attributesObj = new ArrayList(); Iterator<ProviderAttribute> attributesIterator = provider.getActiveAttributes().iterator(); while (attributesIterator.hasNext()) { SimpleObject attributeObj = new SimpleObject(); ProviderAttribute pAttribute = attributesIterator.next(); attributeObj.add("attributeType", pAttribute.getAttributeType().getName()); attributeObj.add("value", pAttribute.getValue()); attributesObj.add(attributeObj); } obj.add("providerAttributes", attributesObj); } obj.add("display", p.getPersonName().getFullName()); if (p.getAttribute("Health Center") != null) { obj.add("location", Context.getLocationService().getLocation( Integer.parseInt(p.getAttribute("Health Center").getValue())).getUuid()); } obj.add("roles", u.getAllRoles()); obj.add("privileges", u.getPrivileges()); obj.add("serverTime", Calendar.getInstance().getTime()); return gson.toJson(obj); } else { throw new ResponseException( "Not Authenticated") {}; } }  @RequestMapping(method = RequestMethod.GET) @WSDoc("Get Login information") @ResponseBody() String getLoginInfo(HttpServletRequest request, HttpServletResponse response);  }