Skip to content

Commit

Permalink
Merge pull request #20 from himanshu1587/master
Browse files Browse the repository at this point in the history
 Removed caching of roles which was implemented for FormValidationServlet
  • Loading branch information
Himanshu Mishra committed Feb 27, 2013
2 parents dfc2dd8 + 453065e commit bc58356
Showing 1 changed file with 0 additions and 30 deletions.
Expand Up @@ -370,32 +370,6 @@ public void executePost(PostMethod post) {
}
}

public void sendUserAndRolesToPopulateCache(User user, String serverUrl) {
String url = serverUrl + "/gi/populaterolescache";
String userName = user.getName();
String[] userRoles = user.getRoles();
String userRolesAsString = arrayToString(userRoles, ",");
PostMethod post = new PostMethod(url);
post.addParameter("username", userName);
post.addParameter("roles", userRolesAsString);
LOG.debug("Sending post request to: " + url);
executePost(post);
}

public void sendUserToInvalidateCache(String userName, String serverUrl) {
String url = serverUrl + "/gi/invalidaterolescache";
PostMethod post = new PostMethod(url);
post.addParameter("username", userName);
LOG.debug("Sending post request to: " + url);
executePost(post);
}

public String getServerUrl(HttpServletRequest request) {
String serverUrl = "http://" + request.getServerName() + ":" + request.getServerPort();
LOG.debug("Server url is: " + serverUrl);
return serverUrl;
}

// @note(alex) Called by reflection - see UIController
@SuppressWarnings("unchecked")
public ModelAndView logIn(HttpServletRequest request, HttpServletResponse response, LoginCommand login,
Expand All @@ -411,8 +385,6 @@ public ModelAndView logIn(HttpServletRequest request, HttpServletResponse respon
User user = authenticate(login.getUsername(), login.getPassword(), errors);
if (user != null) {
state.setCurrentUser(user);
String serverUrl = getServerUrl(request);
sendUserAndRolesToPopulateCache(user, serverUrl);
if (login.isAutoLogin()) {
// set autoLogin
setAutoLoginCookie(response, user.getToken());
Expand Down Expand Up @@ -440,10 +412,8 @@ public ModelAndView logOut(HttpServletRequest request, HttpServletResponse respo
BindException errors) throws Exception {
ApplicationState state = getApplicationState(request);
if (state != null) {
String serverUrl = getServerUrl(request);
if (state.getCurrentUser() != null){
String userName = state.getCurrentUser().getName();
sendUserToInvalidateCache(userName, serverUrl);
LOG.debug("Logout: user=" + userName);
}
state.setCurrentUser(null);
Expand Down

0 comments on commit bc58356

Please sign in to comment.