|
|
|
@ -2,6 +2,8 @@ package org.gcube.portlets.user.accountingdashboard.server;
|
|
|
|
|
|
|
|
|
|
import javax.servlet.ServletException;
|
|
|
|
|
|
|
|
|
|
import org.gcube.common.scope.impl.ScopeBean;
|
|
|
|
|
import org.gcube.common.scope.impl.ScopeBean.Type;
|
|
|
|
|
import org.gcube.portlets.user.accountingdashboard.client.rpc.AccountingDashboardService;
|
|
|
|
|
import org.gcube.portlets.user.accountingdashboard.server.accounting.AccountingService;
|
|
|
|
|
import org.gcube.portlets.user.accountingdashboard.server.accounting.AccountingServiceType;
|
|
|
|
@ -66,9 +68,8 @@ public class AccountingDashboardServiceImpl extends RemoteServiceServlet impleme
|
|
|
|
|
public ScopeData getScopeData() throws ServiceException {
|
|
|
|
|
try {
|
|
|
|
|
logger.debug("AccountingDashboardServiceImpl getScopeData()");
|
|
|
|
|
@SuppressWarnings("unused")
|
|
|
|
|
ServiceCredentials serviceCredentials = SessionUtil.getServiceCredentials(this.getThreadLocalRequest());
|
|
|
|
|
AccountingService as = new AccountingService(AccountingServiceType.PortalContex);
|
|
|
|
|
AccountingService as = new AccountingService(getAccountingContext(serviceCredentials.getScope()));
|
|
|
|
|
ScopeData scopeData = as.getTree(this.getThreadLocalRequest());
|
|
|
|
|
return scopeData;
|
|
|
|
|
} catch (ServiceException e) {
|
|
|
|
@ -85,9 +86,8 @@ public class AccountingDashboardServiceImpl extends RemoteServiceServlet impleme
|
|
|
|
|
public ReportData getReport(RequestReportData requestReportData) throws ServiceException {
|
|
|
|
|
try {
|
|
|
|
|
logger.debug("AccountingDashboardServiceImpl getReport(): " + requestReportData);
|
|
|
|
|
@SuppressWarnings("unused")
|
|
|
|
|
ServiceCredentials serviceCredentials = SessionUtil.getServiceCredentials(this.getThreadLocalRequest());
|
|
|
|
|
AccountingService as = new AccountingService(AccountingServiceType.PortalContex);
|
|
|
|
|
AccountingService as = new AccountingService(getAccountingContext(serviceCredentials.getScope()));
|
|
|
|
|
ReportData reportData = as.getReport(this.getThreadLocalRequest(), requestReportData);
|
|
|
|
|
return reportData;
|
|
|
|
|
} catch (ServiceException e) {
|
|
|
|
@ -99,4 +99,18 @@ public class AccountingDashboardServiceImpl extends RemoteServiceServlet impleme
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private AccountingServiceType getAccountingContext(String scope) {
|
|
|
|
|
try {
|
|
|
|
|
ScopeBean scopeBean = new ScopeBean(scope);
|
|
|
|
|
if (scopeBean.is(Type.VRE)) {
|
|
|
|
|
return AccountingServiceType.CurrentScope;
|
|
|
|
|
} else {
|
|
|
|
|
return AccountingServiceType.PortalContex;
|
|
|
|
|
}
|
|
|
|
|
} catch (Throwable e) {
|
|
|
|
|
logger.error("getAccountingContext(): " + e.getLocalizedMessage(), e);
|
|
|
|
|
return AccountingServiceType.CurrentScope;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|