Minor update

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-gwt-service@102199 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Giancarlo Panichi 2015-01-07 17:20:50 +00:00
parent 9b8e78ff1d
commit 6caecb641d
1 changed files with 45 additions and 36 deletions

View File

@ -83,16 +83,17 @@ public class SessionUtil {
ASLSession session;
if (username == null) {
logger.warn("no user found in session, using test one");
throw new TDGWTSessionExpiredException("Session Expired!");
throw new TDGWTSessionExpiredException("Session Expired!");
// Remove comment for Test
/*
username = Constants.DEFAULT_USER;
String scope = Constants.DEFAULT_SCOPE;
httpSession.setAttribute(ScopeHelper.USERNAME_ATTRIBUTE,
username); session = SessionManager.getInstance().getASLSession(
httpSession.getId(), username); session.setScope(scope);
username = Constants.DEFAULT_USER;
String scope = Constants.DEFAULT_SCOPE;
httpSession.setAttribute(ScopeHelper.USERNAME_ATTRIBUTE, username);
session = SessionManager.getInstance().getASLSession(
httpSession.getId(), username);
session.setScope(scope);
*/
} else {
session = SessionManager.getInstance().getASLSession(
@ -167,7 +168,7 @@ public class SessionUtil {
}
return id;
}
/**
*
* @param httpSession
@ -1863,7 +1864,7 @@ public class SessionUtil {
return taskWrapper;
}
/**
* Remove Task Started
*
@ -1913,7 +1914,7 @@ public class SessionUtil {
return;
}
/**
* Add Task Started
*
@ -1972,7 +1973,7 @@ public class SessionUtil {
return;
}
/**
* Retrieve Aborted Task Map
*
@ -2059,7 +2060,7 @@ public class SessionUtil {
return;
}
/**
* Retrive Hidden Task Map
*
@ -2085,7 +2086,7 @@ public class SessionUtil {
}
}
/**
*
* @param httpSession
@ -2146,7 +2147,7 @@ public class SessionUtil {
return;
}
/**
* Retrieve Tasks In Background
*
@ -2170,9 +2171,9 @@ public class SessionUtil {
return tasksInBackground;
}
}
/**
* Add Task In Background
*
@ -2184,20 +2185,21 @@ public class SessionUtil {
TaskWrapper taskWrapper) throws TDGWTSessionExpiredException {
ASLSession aslSession = getAslSession(httpSession);
ScopeProvider.instance.set(aslSession.getScope());
if (taskWrapper == null) {
logger.error("TaskWrapper is null");
return;
}
if (taskWrapper.getTask()==null||taskWrapper.getTask().getId() == null
if (taskWrapper.getTask() == null
|| taskWrapper.getTask().getId() == null
|| taskWrapper.getTask().getId().getValue() == null
|| taskWrapper.getTask().getId().getValue().isEmpty()) {
logger.error("TaskWrapper contains Task with invalid task id: "+taskWrapper);
logger.error("TaskWrapper contains Task with invalid task id: "
+ taskWrapper);
return;
}
@SuppressWarnings("unchecked")
HashMap<String, HashMap<String, TaskWrapper>> scopeToTasksInBackgroundMap = (HashMap<String, HashMap<String, TaskWrapper>>) httpSession
.getAttribute(SessionConstants.SCOPE_TO_OPERATIONS_TASKS_IN_BACKGROUND_MAP);
@ -2207,7 +2209,8 @@ public class SessionUtil {
HashMap<String, TaskWrapper> tasksInBackground = new HashMap<String, TaskWrapper>();
tasksInBackground.put(taskWrapper.getTask().getId().getValue(),
taskWrapper);
scopeToTasksInBackgroundMap.put(aslSession.getScope(), tasksInBackground);
scopeToTasksInBackgroundMap.put(aslSession.getScope(),
tasksInBackground);
} else {
HashMap<String, TaskWrapper> tasksInBackground = scopeToTasksInBackgroundMap
.get(aslSession.getScope());
@ -2216,11 +2219,13 @@ public class SessionUtil {
tasksInBackground = new HashMap<String, TaskWrapper>();
tasksInBackground.put(taskWrapper.getTask().getId().getValue(),
taskWrapper);
scopeToTasksInBackgroundMap.put(aslSession.getScope(), tasksInBackground);
scopeToTasksInBackgroundMap.put(aslSession.getScope(),
tasksInBackground);
} else {
tasksInBackground.put(taskWrapper.getTask().getId().getValue(),
taskWrapper);
scopeToTasksInBackgroundMap.put(aslSession.getScope(), tasksInBackground);
scopeToTasksInBackgroundMap.put(aslSession.getScope(),
tasksInBackground);
}
httpSession
@ -2242,23 +2247,24 @@ public class SessionUtil {
*/
public static void removeTaskInBackground(HttpSession httpSession,
TaskWrapper taskWrapper) throws TDGWTSessionExpiredException {
ASLSession aslSession = getAslSession(httpSession);
ScopeProvider.instance.set(aslSession.getScope());
if (taskWrapper == null) {
logger.error("TaskWrapper is null");
return;
}
if (taskWrapper.getTask()==null || taskWrapper.getTask().getId() == null
if (taskWrapper.getTask() == null
|| taskWrapper.getTask().getId() == null
|| taskWrapper.getTask().getId().getValue() == null
|| taskWrapper.getTask().getId().getValue().isEmpty()) {
logger.error("TaskWrapper contains Task with invalid task id: "+taskWrapper);
logger.error("TaskWrapper contains Task with invalid task id: "
+ taskWrapper);
return;
}
@SuppressWarnings("unchecked")
HashMap<String, HashMap<String, TaskWrapper>> scopeToTasksInBackgroundMap = (HashMap<String, HashMap<String, TaskWrapper>>) httpSession
.getAttribute(SessionConstants.SCOPE_TO_OPERATIONS_TASKS_IN_BACKGROUND_MAP);
@ -2271,17 +2277,20 @@ public class SessionUtil {
if (tasksInBackground == null) {
logger.debug("TaskWrapper was not acquired: " + taskWrapper);
} else {
tasksInBackground.remove(taskWrapper.getTask().getId().getValue());
scopeToTasksInBackgroundMap.put(aslSession.getScope(),tasksInBackground);
tasksInBackground.remove(taskWrapper.getTask().getId()
.getValue());
scopeToTasksInBackgroundMap.put(aslSession.getScope(),
tasksInBackground);
httpSession
.removeAttribute(SessionConstants.SCOPE_TO_OPERATIONS_TASKS_IN_BACKGROUND_MAP);
httpSession.setAttribute(
SessionConstants.SCOPE_TO_OPERATIONS_TASKS_IN_BACKGROUND_MAP,
scopeToTasksInBackgroundMap);
httpSession
.setAttribute(
SessionConstants.SCOPE_TO_OPERATIONS_TASKS_IN_BACKGROUND_MAP,
scopeToTasksInBackgroundMap);
}
}
return;
}
//