Updated to new PortalContext

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/admin/accounting-manager@141653 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Giancarlo Panichi 2017-01-19 17:47:04 +00:00
parent adb6d8c4bc
commit 53c1dce591
6 changed files with 28 additions and 24 deletions

View File

@ -570,10 +570,11 @@ public class AccountingManagerController {
+ Constants.EXPORT_SERVLET_ACCOUNTING_TYPE_PARAMETER + "=" + Constants.EXPORT_SERVLET_ACCOUNTING_TYPE_PARAMETER + "="
+ event.getAccountingType().name() + "&" + event.getAccountingType().name() + "&"
+ Constants.CURR_GROUP_ID + "=" + Constants.CURR_GROUP_ID + "="
+ GCubeClientContext.getCurrentContextId() + GCubeClientContext.getCurrentContextId());
+ "&"
+ Constants.CURR_USER_ID + "=" //+ "&"
+ GCubeClientContext.getCurrentUserId()); //+ Constants.CURR_USER_ID + "="
//+ GCubeClientContext.getCurrentUserId());
Log.debug("Retrieved link: " + actionUrl); Log.debug("Retrieved link: " + actionUrl);
Window.open(actionUrl.toString(), event.getAccountingType().toString(), Window.open(actionUrl.toString(), event.getAccountingType().toString(),

View File

@ -86,10 +86,13 @@ public class ExportServlet extends HttpServlet {
String scopeGroupId = request String scopeGroupId = request
.getParameter(Constants.CURR_GROUP_ID); .getParameter(Constants.CURR_GROUP_ID);
String currUserId = request //String currUserId = request
.getParameter(Constants.CURR_USER_ID); // .getParameter(Constants.CURR_USER_ID);
//serviceCredentials = SessionUtil.getServiceCredentials(request,
// scopeGroupId, currUserId);
serviceCredentials = SessionUtil.getServiceCredentials(request, serviceCredentials = SessionUtil.getServiceCredentials(request,
scopeGroupId, currUserId); scopeGroupId);
ScopeProvider.instance.set(serviceCredentials.getScope()); ScopeProvider.instance.set(serviceCredentials.getScope());
} catch (ServiceException e) { } catch (ServiceException e) {

View File

@ -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.portlets.admin.accountingmanager.shared.exception.ServiceException;
import org.gcube.vomanagement.usermanagement.GroupManager; import org.gcube.vomanagement.usermanagement.GroupManager;
import org.gcube.vomanagement.usermanagement.impl.LiferayGroupManager; 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.GCubeGroup;
import org.gcube.vomanagement.usermanagement.model.GCubeUser; import org.gcube.vomanagement.usermanagement.model.GCubeUser;
import org.slf4j.Logger; import org.slf4j.Logger;
@ -38,12 +37,11 @@ public class SessionUtil {
public static ServiceCredentials getServiceCredentials( public static ServiceCredentials getServiceCredentials(
HttpServletRequest httpServletRequest) throws ServiceException { HttpServletRequest httpServletRequest) throws ServiceException {
return getServiceCredentials(httpServletRequest, null, null); return getServiceCredentials(httpServletRequest, null);
} }
public static ServiceCredentials getServiceCredentials( public static ServiceCredentials getServiceCredentials(
HttpServletRequest httpServletRequest, String scopeGroupId, HttpServletRequest httpServletRequest, String scopeGroupId) throws ServiceException {
String currUserId) throws ServiceException {
ServiceCredentials sCredentials = null; ServiceCredentials sCredentials = null;
String userName = null; String userName = null;
@ -64,7 +62,7 @@ public class SessionUtil {
logger.info("Retrieving credential in session!"); logger.info("Retrieving credential in session!");
PortalContext pContext = PortalContext.getConfiguration(); PortalContext pContext = PortalContext.getConfiguration();
boolean hasScopeGroupId = false; boolean hasScopeGroupId = false;
boolean hasCurrUserId = false; //boolean hasCurrUserId = false;
if (scopeGroupId != null && !scopeGroupId.isEmpty()) { if (scopeGroupId != null && !scopeGroupId.isEmpty()) {
hasScopeGroupId = true; hasScopeGroupId = true;
@ -73,12 +71,12 @@ public class SessionUtil {
hasScopeGroupId = false; hasScopeGroupId = false;
} }
if (currUserId != null && !currUserId.isEmpty()) { /*if (currUserId != null && !currUserId.isEmpty()) {
hasCurrUserId = true; hasCurrUserId = true;
} else { } else {
hasCurrUserId = false; hasCurrUserId = false;
} }*/
if (hasScopeGroupId) { if (hasScopeGroupId) {
scope = pContext.getCurrentScope(scopeGroupId); scope = pContext.getCurrentScope(scopeGroupId);
@ -94,9 +92,9 @@ public class SessionUtil {
throw new ServiceException(error); throw new ServiceException(error);
} }
GCubeUser gCubeUser = null; GCubeUser gCubeUser = pContext.getCurrentUser(httpServletRequest);
if (hasCurrUserId) { /*if (hasCurrUserId) {
try { try {
gCubeUser = new LiferayUserManager().getUserById(Long gCubeUser = new LiferayUserManager().getUserById(Long
.valueOf(currUserId)); .valueOf(currUserId));
@ -108,7 +106,7 @@ public class SessionUtil {
} }
} else { } else {
gCubeUser = pContext.getCurrentUser(httpServletRequest); gCubeUser = pContext.getCurrentUser(httpServletRequest);
} } */
if (gCubeUser == null) { if (gCubeUser == null) {
String error = "Error retrieving gCubeUser in scope " + scope String error = "Error retrieving gCubeUser in scope " + scope
@ -127,7 +125,9 @@ public class SessionUtil {
throw new ServiceException(error); throw new ServiceException(error);
} }
if (hasCurrUserId) { token = pContext.getCurrentUserToken(scope,userName);
/*if (hasCurrUserId) {
try { try {
token = pContext.getCurrentUserToken(scope, token = pContext.getCurrentUserToken(scope,
Long.valueOf(currUserId)); Long.valueOf(currUserId));
@ -140,7 +140,7 @@ public class SessionUtil {
} else { } else {
token = pContext.getCurrentUserToken(httpServletRequest); token = pContext.getCurrentUserToken(httpServletRequest);
} }*/
logger.debug("Token: " + token); logger.debug("Token: " + token);
if (token == null || token.isEmpty()) { if (token == null || token.isEmpty()) {

View File

@ -72,7 +72,7 @@ public class AccountingCaller implements AccountingCallerInterface {
director.constructAccountingQuery(); director.constructAccountingQuery();
AccountingQuery query = director.getAccountingQuery(); AccountingQuery query = director.getAccountingQuery();
logger.debug("Query: " + query); logger.info("AccountingQuery: " + query);
if (query == null || query.getChartType() == null) { if (query == null || query.getChartType() == null) {
throw new ServiceException( throw new ServiceException(

View File

@ -11,6 +11,7 @@ import javax.portlet.PortletRequestDispatcher;
import javax.portlet.RenderRequest; import javax.portlet.RenderRequest;
import javax.portlet.RenderResponse; import javax.portlet.RenderResponse;
import org.gcube.common.portal.PortalContext;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@ -44,9 +45,8 @@ public class AccountingManagerPortlet extends GenericPortlet {
public void doView(RenderRequest request, RenderResponse response) throws PortletException, IOException { public void doView(RenderRequest request, RenderResponse response) throws PortletException, IOException {
logger.trace("Loading from JSP: "+VIEW_JSP); logger.trace("Loading from JSP: "+VIEW_JSP);
logger.trace("Setting user in session using PortalContext");
//logger.trace("setting context using ScopeHelper"); PortalContext.setUserInSession(request);
//ScopeHelper.setContext(request);
logger.trace("passing to the render"); logger.trace("passing to the render");
PortletRequestDispatcher rd = getPortletContext().getRequestDispatcher(VIEW_JSP); PortletRequestDispatcher rd = getPortletContext().getRequestDispatcher(VIEW_JSP);

View File

@ -13,7 +13,7 @@ public class Constants {
public static final boolean TEST_ENABLE = false; public static final boolean TEST_ENABLE = false;
public static final String CURR_GROUP_ID = "CURR_GROUP_ID"; 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 APPLICATION_ID = "org.gcube.portlets.admin.accountingmanager.server.portlet.AccountingManagerPortlet";
public static final String ACCOUNTING_MANAGER_ID = "AccountingManagerId"; public static final String ACCOUNTING_MANAGER_ID = "AccountingManagerId";