diff --git a/src/main/java/org/gcube/portlets/admin/accountingmanager/client/AccountingManagerController.java b/src/main/java/org/gcube/portlets/admin/accountingmanager/client/AccountingManagerController.java index 76f2546..bbd3298 100644 --- a/src/main/java/org/gcube/portlets/admin/accountingmanager/client/AccountingManagerController.java +++ b/src/main/java/org/gcube/portlets/admin/accountingmanager/client/AccountingManagerController.java @@ -570,10 +570,11 @@ public class AccountingManagerController { + Constants.EXPORT_SERVLET_ACCOUNTING_TYPE_PARAMETER + "=" + event.getAccountingType().name() + "&" + Constants.CURR_GROUP_ID + "=" - + GCubeClientContext.getCurrentContextId() - + "&" - + Constants.CURR_USER_ID + "=" - + GCubeClientContext.getCurrentUserId()); + + GCubeClientContext.getCurrentContextId()); + + //+ "&" + //+ Constants.CURR_USER_ID + "=" + //+ GCubeClientContext.getCurrentUserId()); Log.debug("Retrieved link: " + actionUrl); Window.open(actionUrl.toString(), event.getAccountingType().toString(), diff --git a/src/main/java/org/gcube/portlets/admin/accountingmanager/server/ExportServlet.java b/src/main/java/org/gcube/portlets/admin/accountingmanager/server/ExportServlet.java index 572f6ca..1a4323b 100644 --- a/src/main/java/org/gcube/portlets/admin/accountingmanager/server/ExportServlet.java +++ b/src/main/java/org/gcube/portlets/admin/accountingmanager/server/ExportServlet.java @@ -86,10 +86,13 @@ public class ExportServlet extends HttpServlet { String scopeGroupId = request .getParameter(Constants.CURR_GROUP_ID); - String currUserId = request - .getParameter(Constants.CURR_USER_ID); + //String currUserId = request + // .getParameter(Constants.CURR_USER_ID); + //serviceCredentials = SessionUtil.getServiceCredentials(request, + // scopeGroupId, currUserId); serviceCredentials = SessionUtil.getServiceCredentials(request, - scopeGroupId, currUserId); + scopeGroupId); + ScopeProvider.instance.set(serviceCredentials.getScope()); } catch (ServiceException e) { diff --git a/src/main/java/org/gcube/portlets/admin/accountingmanager/server/SessionUtil.java b/src/main/java/org/gcube/portlets/admin/accountingmanager/server/SessionUtil.java index d315d80..b544b27 100644 --- a/src/main/java/org/gcube/portlets/admin/accountingmanager/server/SessionUtil.java +++ b/src/main/java/org/gcube/portlets/admin/accountingmanager/server/SessionUtil.java @@ -20,7 +20,6 @@ import org.gcube.portlets.admin.accountingmanager.shared.data.Context; import org.gcube.portlets.admin.accountingmanager.shared.exception.ServiceException; import org.gcube.vomanagement.usermanagement.GroupManager; import org.gcube.vomanagement.usermanagement.impl.LiferayGroupManager; -import org.gcube.vomanagement.usermanagement.impl.LiferayUserManager; import org.gcube.vomanagement.usermanagement.model.GCubeGroup; import org.gcube.vomanagement.usermanagement.model.GCubeUser; import org.slf4j.Logger; @@ -38,12 +37,11 @@ public class SessionUtil { public static ServiceCredentials getServiceCredentials( HttpServletRequest httpServletRequest) throws ServiceException { - return getServiceCredentials(httpServletRequest, null, null); + return getServiceCredentials(httpServletRequest, null); } public static ServiceCredentials getServiceCredentials( - HttpServletRequest httpServletRequest, String scopeGroupId, - String currUserId) throws ServiceException { + HttpServletRequest httpServletRequest, String scopeGroupId) throws ServiceException { ServiceCredentials sCredentials = null; String userName = null; @@ -64,7 +62,7 @@ public class SessionUtil { logger.info("Retrieving credential in session!"); PortalContext pContext = PortalContext.getConfiguration(); boolean hasScopeGroupId = false; - boolean hasCurrUserId = false; + //boolean hasCurrUserId = false; if (scopeGroupId != null && !scopeGroupId.isEmpty()) { hasScopeGroupId = true; @@ -73,12 +71,12 @@ public class SessionUtil { hasScopeGroupId = false; } - if (currUserId != null && !currUserId.isEmpty()) { + /*if (currUserId != null && !currUserId.isEmpty()) { hasCurrUserId = true; } else { hasCurrUserId = false; - } + }*/ if (hasScopeGroupId) { scope = pContext.getCurrentScope(scopeGroupId); @@ -94,9 +92,9 @@ public class SessionUtil { throw new ServiceException(error); } - GCubeUser gCubeUser = null; + GCubeUser gCubeUser = pContext.getCurrentUser(httpServletRequest); - if (hasCurrUserId) { + /*if (hasCurrUserId) { try { gCubeUser = new LiferayUserManager().getUserById(Long .valueOf(currUserId)); @@ -108,7 +106,7 @@ public class SessionUtil { } } else { gCubeUser = pContext.getCurrentUser(httpServletRequest); - } + } */ if (gCubeUser == null) { String error = "Error retrieving gCubeUser in scope " + scope @@ -127,7 +125,9 @@ public class SessionUtil { throw new ServiceException(error); } - if (hasCurrUserId) { + token = pContext.getCurrentUserToken(scope,userName); + + /*if (hasCurrUserId) { try { token = pContext.getCurrentUserToken(scope, Long.valueOf(currUserId)); @@ -140,7 +140,7 @@ public class SessionUtil { } else { token = pContext.getCurrentUserToken(httpServletRequest); - } + }*/ logger.debug("Token: " + token); if (token == null || token.isEmpty()) { diff --git a/src/main/java/org/gcube/portlets/admin/accountingmanager/server/amservice/AccountingCaller.java b/src/main/java/org/gcube/portlets/admin/accountingmanager/server/amservice/AccountingCaller.java index 91a226d..8a4034e 100644 --- a/src/main/java/org/gcube/portlets/admin/accountingmanager/server/amservice/AccountingCaller.java +++ b/src/main/java/org/gcube/portlets/admin/accountingmanager/server/amservice/AccountingCaller.java @@ -72,7 +72,7 @@ public class AccountingCaller implements AccountingCallerInterface { director.constructAccountingQuery(); AccountingQuery query = director.getAccountingQuery(); - logger.debug("Query: " + query); + logger.info("AccountingQuery: " + query); if (query == null || query.getChartType() == null) { throw new ServiceException( diff --git a/src/main/java/org/gcube/portlets/admin/accountingmanager/server/portlet/AccountingManagerPortlet.java b/src/main/java/org/gcube/portlets/admin/accountingmanager/server/portlet/AccountingManagerPortlet.java index 2c07b08..f991af0 100644 --- a/src/main/java/org/gcube/portlets/admin/accountingmanager/server/portlet/AccountingManagerPortlet.java +++ b/src/main/java/org/gcube/portlets/admin/accountingmanager/server/portlet/AccountingManagerPortlet.java @@ -11,6 +11,7 @@ import javax.portlet.PortletRequestDispatcher; import javax.portlet.RenderRequest; import javax.portlet.RenderResponse; +import org.gcube.common.portal.PortalContext; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -44,9 +45,8 @@ public class AccountingManagerPortlet extends GenericPortlet { public void doView(RenderRequest request, RenderResponse response) throws PortletException, IOException { logger.trace("Loading from JSP: "+VIEW_JSP); - - //logger.trace("setting context using ScopeHelper"); - //ScopeHelper.setContext(request); + logger.trace("Setting user in session using PortalContext"); + PortalContext.setUserInSession(request); logger.trace("passing to the render"); PortletRequestDispatcher rd = getPortletContext().getRequestDispatcher(VIEW_JSP); diff --git a/src/main/java/org/gcube/portlets/admin/accountingmanager/shared/Constants.java b/src/main/java/org/gcube/portlets/admin/accountingmanager/shared/Constants.java index 6d3ea91..13b0fa8 100644 --- a/src/main/java/org/gcube/portlets/admin/accountingmanager/shared/Constants.java +++ b/src/main/java/org/gcube/portlets/admin/accountingmanager/shared/Constants.java @@ -13,7 +13,7 @@ public class Constants { public static final boolean TEST_ENABLE = false; public static final String CURR_GROUP_ID = "CURR_GROUP_ID"; - public static final String CURR_USER_ID = "CURR_USER_ID"; + //public static final String CURR_USER_ID = "CURR_USER_ID"; public static final String APPLICATION_ID = "org.gcube.portlets.admin.accountingmanager.server.portlet.AccountingManagerPortlet"; public static final String ACCOUNTING_MANAGER_ID = "AccountingManagerId";