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 + "="
+ 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(),

View File

@ -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) {

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.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()) {

View File

@ -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(

View File

@ -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);

View File

@ -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";