Fixed download in case of multitab on different scopes

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/admin/accounting-manager@141550 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Giancarlo Panichi 2017-01-13 11:44:02 +00:00
parent 6a780cf843
commit adb6d8c4bc
7 changed files with 50 additions and 20 deletions

View File

@ -1,12 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" output="target/accounting-manager-1.5.0-SNAPSHOT/WEB-INF/classes" path="src/main/java">
<classpathentry kind="src" output="target/accounting-manager-1.6.0-SNAPSHOT/WEB-INF/classes" path="src/main/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry excluding="**" kind="src" output="target/accounting-manager-1.5.0-SNAPSHOT/WEB-INF/classes" path="src/main/resources">
<classpathentry excluding="**" kind="src" output="target/accounting-manager-1.6.0-SNAPSHOT/WEB-INF/classes" path="src/main/resources">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
@ -45,5 +45,5 @@
</classpathentry>
<classpathentry kind="lib" path="/home/giancarlo/gwt/gwt-2.6.1/validation-api-1.0.0.GA.jar" sourcepath="/home/giancarlo/gwt/gwt-2.6.1/validation-api-1.0.0.GA-sources.jar"/>
<classpathentry kind="lib" path="/home/giancarlo/gwt/gwt-2.6.1/validation-api-1.0.0.GA-sources.jar"/>
<classpathentry kind="output" path="target/accounting-manager-1.5.0-SNAPSHOT/WEB-INF/classes"/>
<classpathentry kind="output" path="target/accounting-manager-1.6.0-SNAPSHOT/WEB-INF/classes"/>
</classpath>

View File

@ -1,4 +1,8 @@
<ReleaseNotes>
<Changeset component="org.gcube.portlets.admin.accounting-manager.1-6-0"
date="2017-02-28">
<Change>Fixed download in case of multitab on different scopes</Change>
</Changeset>
<Changeset component="org.gcube.portlets.admin.accounting-manager.1-5-0"
date="2016-12-01">
<Change>Added Context Chart</Change>

View File

@ -13,7 +13,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>org.gcube.portlets.admin</groupId>
<artifactId>accounting-manager</artifactId>
<version>1.5.0-SNAPSHOT</version>
<version>1.6.0-SNAPSHOT</version>
<packaging>war</packaging>

View File

@ -168,8 +168,8 @@ public class AccountingManagerServiceImpl extends RemoteServiceServlet
AccountingStateData accountingStateData = new AccountingStateData(
accountingType, seriesRequest, seriesResponse);
SessionUtil.setAccountingStateData(session, accountingType,
accountingStateData);
SessionUtil.setAccountingStateData(session, serviceCredentials,
accountingType, accountingStateData);
return seriesResponse;
} catch (ServiceException e) {
@ -283,7 +283,7 @@ public class AccountingManagerServiceImpl extends RemoteServiceServlet
logger.debug("SaveDataOnWorkspace(): " + accountingType);
AccountingStateData accountingStateData = SessionUtil
.getAccountingStateData(session, accountingType);
.getAccountingStateData(session, serviceCredentials, accountingType);
if (accountingStateData == null) {
logger.error("No series present in session for thi accounting type: "
+ accountingType);

View File

@ -110,7 +110,7 @@ public class ExportServlet extends HttpServlet {
AccountingStateData accountingStateData = SessionUtil
.getAccountingStateData(session,
AccountingType.valueOf(accountingType));
serviceCredentials, AccountingType.valueOf(accountingType));
if (accountingStateData == null) {
logger.error("No series present in session for this accounting type: "
+ accountingType);

View File

@ -4,6 +4,7 @@
package org.gcube.portlets.admin.accountingmanager.server;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
@ -202,31 +203,56 @@ public class SessionUtil {
}
public static void setAccountingStateData(HttpSession httpSession,
ServiceCredentials serviceCredentials,
AccountingType accountingType,
AccountingStateData accountingStateData) {
AccountingState accountingState = (AccountingState) httpSession
.getAttribute(Constants.SESSION_ACCOUNTING_STATE);
@SuppressWarnings("unchecked")
HashMap<String, AccountingState> accountingStateMap = (HashMap<String, AccountingState>) httpSession
.getAttribute(Constants.SESSION_ACCOUNTING_STATE_MAP);
if (accountingState == null) {
accountingState = new AccountingState();
if (accountingStateMap == null) {
AccountingState accountingState = new AccountingState();
accountingState.setState(accountingType, accountingStateData);
httpSession.setAttribute(Constants.SESSION_ACCOUNTING_STATE,
accountingStateMap = new HashMap<>();
accountingStateMap.put(serviceCredentials.getScope(),
accountingState);
httpSession.setAttribute(Constants.SESSION_ACCOUNTING_STATE_MAP,
accountingStateMap);
} else {
accountingState.setState(accountingType, accountingStateData);
AccountingState accountingState = accountingStateMap
.get(serviceCredentials.getScope());
if (accountingState == null) {
accountingState = new AccountingState();
accountingState.setState(accountingType, accountingStateData);
accountingStateMap.put(serviceCredentials.getScope(),
accountingState);
} else {
accountingState.setState(accountingType, accountingStateData);
}
}
return;
}
public static AccountingStateData getAccountingStateData(
HttpSession httpSession, AccountingType accountingType) {
AccountingState accountingState = (AccountingState) httpSession
.getAttribute(Constants.SESSION_ACCOUNTING_STATE);
if (accountingState == null) {
HttpSession httpSession, ServiceCredentials serviceCredentials,
AccountingType accountingType) {
@SuppressWarnings("unchecked")
HashMap<String, AccountingState> accountingStateMap = (HashMap<String, AccountingState>) httpSession
.getAttribute(Constants.SESSION_ACCOUNTING_STATE_MAP);
if (accountingStateMap == null) {
return null;
} else {
return accountingState.getState(accountingType);
AccountingState accountingState = accountingStateMap
.get(serviceCredentials.getScope());
if (accountingState == null) {
return null;
} else {
return accountingState.getState(accountingType);
}
}
}

View File

@ -32,7 +32,7 @@ public class Constants {
public static final String EXPORT_SERVLET_TYPE_PARAMETER = "ExportServletType";
public static final String EXPORT_SERVLET_ACCOUNTING_TYPE_PARAMETER = "AccountingType";
public static final String SESSION_ACCOUNTING_STATE = "ACCOUNTING_STATE";
public static final String SESSION_ACCOUNTING_STATE_MAP = "ACCOUNTING_STATE_MAP";
public static final AccountingType[] DEFAULT_TABS = new AccountingType[] { AccountingType.STORAGE };;