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"?> <?xml version="1.0" encoding="UTF-8"?>
<classpath> <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> <attributes>
<attribute name="optional" value="true"/> <attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/> <attribute name="maven.pomderived" value="true"/>
</attributes> </attributes>
</classpathentry> </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> <attributes>
<attribute name="maven.pomderived" value="true"/> <attribute name="maven.pomderived" value="true"/>
</attributes> </attributes>
@ -45,5 +45,5 @@
</classpathentry> </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.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="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> </classpath>

View File

@ -1,4 +1,8 @@
<ReleaseNotes> <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" <Changeset component="org.gcube.portlets.admin.accounting-manager.1-5-0"
date="2016-12-01"> date="2016-12-01">
<Change>Added Context Chart</Change> <Change>Added Context Chart</Change>

View File

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

View File

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

View File

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

View File

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