Added remove task in background when TR is deleted
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-gwt-service@111443 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
56ad7253e8
commit
d4c5e6488e
|
@ -17,7 +17,6 @@ import org.gcube.portal.custom.scopemanager.scopehelper.ScopeHelper;
|
|||
import org.gcube.portlets.user.td.gwtservice.server.file.CSVFileUploadSession;
|
||||
import org.gcube.portlets.user.td.gwtservice.server.file.CodelistMappingFileUploadSession;
|
||||
import org.gcube.portlets.user.td.gwtservice.server.trservice.TRTasksManager;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.Constants;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.chart.ChartTopRatingSession;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.codelisthelper.CodelistMappingSession;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.csv.CSVExportSession;
|
||||
|
@ -509,7 +508,8 @@ public class SessionUtil {
|
|||
if (openList == null || openList.isEmpty()) {
|
||||
logger.info("No open tr in session");
|
||||
} else {
|
||||
logger.debug("Current Tabular Open In session: "+aslSession.getScope()+", trList: "+openList);
|
||||
logger.debug("Current Tabular Open In session: "
|
||||
+ aslSession.getScope() + ", trList: " + openList);
|
||||
for (TabResource tabResource : openList) {
|
||||
if (tabResource != null
|
||||
&& tabResource.getTrId() != null
|
||||
|
@ -2295,6 +2295,69 @@ public class SessionUtil {
|
|||
|
||||
}
|
||||
|
||||
/**
|
||||
* Reomove Task on specific tabular resource from Tasks In Background
|
||||
*
|
||||
* @param httpSession
|
||||
* @param taskWrapper
|
||||
* @throws TDGWTSessionExpiredException
|
||||
*/
|
||||
public static void removeTaskInBackgroundOnTRId(HttpSession httpSession,
|
||||
TRId trId) throws TDGWTSessionExpiredException {
|
||||
|
||||
ASLSession aslSession = getAslSession(httpSession);
|
||||
ScopeProvider.instance.set(aslSession.getScope());
|
||||
|
||||
if (trId == null) {
|
||||
logger.error("TRId is null");
|
||||
return;
|
||||
}
|
||||
|
||||
if (trId.getId() == null || trId.getId().isEmpty()) {
|
||||
logger.error("TRId contains Id invalid: " + trId);
|
||||
return;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
HashMap<String, HashMap<String, TaskWrapper>> scopeToTasksInBackgroundMap = (HashMap<String, HashMap<String, TaskWrapper>>) httpSession
|
||||
.getAttribute(SessionConstants.SCOPE_TO_OPERATIONS_TASKS_IN_BACKGROUND_MAP);
|
||||
|
||||
if (scopeToTasksInBackgroundMap == null) {
|
||||
logger.debug("No Background task in Session for TRId: " + trId);
|
||||
} else {
|
||||
HashMap<String, TaskWrapper> tasksInBackground = scopeToTasksInBackgroundMap
|
||||
.get(aslSession.getScope());
|
||||
if (tasksInBackground == null) {
|
||||
logger.debug("No Background task for TRId: " + trId);
|
||||
} else {
|
||||
ArrayList<String> removableKeys = new ArrayList<String>();
|
||||
for (String key : tasksInBackground.keySet()) {
|
||||
TaskWrapper taskWrapper = tasksInBackground.get(key);
|
||||
if (taskWrapper.getTrId() != null
|
||||
&& taskWrapper.getTrId().getId() != null
|
||||
&& taskWrapper.getTrId().getId()
|
||||
.compareTo(trId.getId()) == 0) {
|
||||
removableKeys.add(key);
|
||||
}
|
||||
}
|
||||
|
||||
for (String key : removableKeys) {
|
||||
tasksInBackground.remove(key);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
public static FileUploadMonitor getFileUploadMonitor(HttpSession httpSession) {
|
||||
FileUploadMonitor fileUploadMonitor = (FileUploadMonitor) httpSession
|
||||
|
|
|
@ -2966,6 +2966,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
|||
String owner = tabularResource.getOwner();
|
||||
if (owner != null && owner.compareTo(aslSession.getUsername()) == 0) {
|
||||
service.removeTabularResource(tabResourceId);
|
||||
SessionUtil.removeTaskInBackgroundOnTRId(session, trId);
|
||||
} else {
|
||||
throw new TDGWTServiceException(
|
||||
"You are not the owner of this tabular resource (owner: "
|
||||
|
@ -2988,6 +2989,9 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* {@inheritDoc}
|
||||
|
|
Loading…
Reference in New Issue