diff --git a/distro/changelog.xml b/distro/changelog.xml index f622824..211df04 100644 --- a/distro/changelog.xml +++ b/distro/changelog.xml @@ -1,4 +1,7 @@ + + Fixed ASLSession + Fixed SDMX Export no ExportMetadata is supported on service diff --git a/pom.xml b/pom.xml index e83344a..9bd37af 100644 --- a/pom.xml +++ b/pom.xml @@ -14,7 +14,7 @@ 4.0.0 org.gcube.portlets.user tabular-data-gwt-service - 2.10.0-SNAPSHOT + 2.11.0-SNAPSHOT tabular-data-gwt-service tabular-data-gwt-service allows communication between the GUI and services @@ -68,6 +68,17 @@ 1.0.1 runtime + @@ -115,6 +126,19 @@ custom-portal-handler provided + + diff --git a/src/main/java/org/gcube/portlets/user/td/gwtservice/server/SessionUtil.java b/src/main/java/org/gcube/portlets/user/td/gwtservice/server/SessionUtil.java index d43ed96..b0928ac 100644 --- a/src/main/java/org/gcube/portlets/user/td/gwtservice/server/SessionUtil.java +++ b/src/main/java/org/gcube/portlets/user/td/gwtservice/server/SessionUtil.java @@ -19,6 +19,7 @@ import org.gcube.portal.custom.scopemanager.scopehelper.ScopeHelper; import org.gcube.portlets.user.td.gwtservice.server.file.CSVFileUploadSession; import org.gcube.portlets.user.td.gwtservice.server.file.CodelistMappingFileUploadSession; import org.gcube.portlets.user.td.gwtservice.server.trservice.TRTasksManager; +import org.gcube.portlets.user.td.gwtservice.shared.Constants; import org.gcube.portlets.user.td.gwtservice.shared.chart.ChartTopRatingSession; import org.gcube.portlets.user.td.gwtservice.shared.codelisthelper.CodelistMappingSession; import org.gcube.portlets.user.td.gwtservice.shared.csv.CSVExportSession; @@ -91,63 +92,81 @@ public class SessionUtil { throws TDGWTSessionExpiredException { String username = (String) httpSession .getAttribute(ScopeHelper.USERNAME_ATTRIBUTE); - ASLSession session; + ASLSession aslSession; if (username == null) { - logger.warn("no user found in session, use test user"); - - InfoLocale infoLocale=getInfoLocale(httpSession); - Locale locale=new Locale(infoLocale.getLanguage()); - ResourceBundle messages=ResourceBundle.getBundle(TDGWTServiceMessagesConstants.TDGWTServiceMessages, locale); - throw new TDGWTSessionExpiredException(messages.getString(TDGWTServiceMessagesConstants.sessionExpired)); - - /* - // Remove comment for Test - username = Constants.DEFAULT_USER; - String scope = Constants.DEFAULT_SCOPE; + InfoLocale infoLocale = getInfoLocale(httpSession); + Locale locale = new Locale(infoLocale.getLanguage()); + ResourceBundle messages = ResourceBundle.getBundle( + TDGWTServiceMessagesConstants.TDGWTServiceMessages, locale); - httpSession.setAttribute(ScopeHelper.USERNAME_ATTRIBUTE, username); - session = SessionManager.getInstance().getASLSession( - httpSession.getId(), username); - session.setScope(scope); - */ + if (Constants.DEBUG_MODE) { + logger.info("no user found in session, use test user"); + // Remove comment for Test + username = Constants.DEFAULT_USER; + String scope = Constants.DEFAULT_SCOPE; + + httpSession.setAttribute(ScopeHelper.USERNAME_ATTRIBUTE, + username); + aslSession = SessionManager.getInstance().getASLSession( + httpSession.getId(), username); + aslSession.setScope(scope); + } else { + logger.info("no user found in session, use test user"); + throw new TDGWTSessionExpiredException( + messages.getString(TDGWTServiceMessagesConstants.sessionExpired)); + + } } else { - session = SessionManager.getInstance().getASLSession( + aslSession = SessionManager.getInstance().getASLSession( httpSession.getId(), username); } - logger.info("SessionUtil: aslSession " + session.getUsername() + " " - + session.getScope()); + logger.info("SessionUtil: aslSession " + aslSession.getUsername() + " " + + aslSession.getScope()); - return session; + return aslSession; + } + + public static String getToken(ASLSession aslSession) { + String token = null; + if (Constants.DEBUG_MODE) { + List userRoles = new ArrayList<>(); + userRoles.add(Constants.DEFAULT_ROLE); + + token = null;// authorizationService().build().generate( + // aslSession.getUsername(), userRoles); + + } else { + token = aslSession.getSecurityToken(); + } + logger.info("received token: " + token); + return token; } - - + // - public static InfoLocale getInfoLocale( - HttpSession httpSession) { + public static InfoLocale getInfoLocale(HttpSession httpSession) { InfoLocale infoLocale = (InfoLocale) httpSession .getAttribute(SessionConstants.INFO_LOCALE); if (infoLocale != null) { return infoLocale; } else { infoLocale = new InfoLocale("en"); - httpSession.setAttribute(SessionConstants.INFO_LOCALE, - infoLocale); + httpSession.setAttribute(SessionConstants.INFO_LOCALE, infoLocale); return infoLocale; } } - public static void setInfoLocale(HttpSession httpSession, InfoLocale infoLocale) { + public static void setInfoLocale(HttpSession httpSession, + InfoLocale infoLocale) { InfoLocale infoL = (InfoLocale) httpSession .getAttribute(SessionConstants.INFO_LOCALE); if (infoL != null) { httpSession.removeAttribute(SessionConstants.INFO_LOCALE); } - httpSession.setAttribute(SessionConstants.INFO_LOCALE, - infoLocale); - + httpSession.setAttribute(SessionConstants.INFO_LOCALE, infoLocale); + } /** @@ -1127,8 +1146,7 @@ public class SessionUtil { replaceColumnByExpressionSession); } - - + // public static ApplyAndDetachColumnRulesSession getRulesOnColumnApplyAndDetachSession( HttpSession httpSession) { @@ -1159,8 +1177,7 @@ public class SessionUtil { applyColumnRulesSession); } - - + // public static ApplyTableRuleSession getApplyTableRuleSession( HttpSession httpSession) { @@ -1177,8 +1194,7 @@ public class SessionUtil { } } - public static void setApplyTableRuleSession( - HttpSession httpSession, + public static void setApplyTableRuleSession(HttpSession httpSession, ApplyTableRuleSession applyTableRuleSession) { ApplyTableRuleSession atrs = (ApplyTableRuleSession) httpSession .getAttribute(SessionConstants.RULES_ON_TABLE_APPLY_SESSION); @@ -1186,12 +1202,11 @@ public class SessionUtil { httpSession .removeAttribute(SessionConstants.RULES_ON_TABLE_APPLY_SESSION); } - httpSession.setAttribute( - SessionConstants.RULES_ON_TABLE_APPLY_SESSION, + httpSession.setAttribute(SessionConstants.RULES_ON_TABLE_APPLY_SESSION, applyTableRuleSession); } - + // public static DetachColumnRulesSession getDetachColumnRulesSession( HttpSession httpSession) { @@ -1208,8 +1223,7 @@ public class SessionUtil { } } - public static void setDetachColumnRulesSession( - HttpSession httpSession, + public static void setDetachColumnRulesSession(HttpSession httpSession, DetachColumnRulesSession detachColumnRulesSession) { DetachColumnRulesSession rules = (DetachColumnRulesSession) httpSession .getAttribute(SessionConstants.RULES_ON_COLUMN_DETACH_SESSION); @@ -1222,8 +1236,7 @@ public class SessionUtil { detachColumnRulesSession); } - - + // public static DetachTableRulesSession getDetachTableRulesSession( HttpSession httpSession) { @@ -1240,8 +1253,7 @@ public class SessionUtil { } } - public static void setDetachTableRulesSession( - HttpSession httpSession, + public static void setDetachTableRulesSession(HttpSession httpSession, DetachTableRulesSession detachTableRulesSession) { DetachTableRulesSession rules = (DetachTableRulesSession) httpSession .getAttribute(SessionConstants.RULES_ON_TABLE_DETACH_SESSION); @@ -1254,7 +1266,6 @@ public class SessionUtil { detachTableRulesSession); } - // public static TaskResubmitSession getTaskResubmitSession( @@ -2741,10 +2752,4 @@ public class SessionUtil { } - - - - - - } diff --git a/src/main/java/org/gcube/portlets/user/td/gwtservice/shared/Constants.java b/src/main/java/org/gcube/portlets/user/td/gwtservice/shared/Constants.java index 1c37b32..8613f55 100644 --- a/src/main/java/org/gcube/portlets/user/td/gwtservice/shared/Constants.java +++ b/src/main/java/org/gcube/portlets/user/td/gwtservice/shared/Constants.java @@ -10,14 +10,15 @@ package org.gcube.portlets.user.td.gwtservice.shared; * */ public class Constants { - + public static final boolean DEBUG_MODE = false; + public static final boolean TEST_ENABLE = false; + public final static String DEFAULT_USER = "test.user"; public final static String DEFAULT_SCOPE = "/gcube/devsec/devVRE"; + public static final String DEFAULT_ROLE = "OrganizationMember"; public final static String FILE_XML_MIMETYPE = "application/xml"; public final static String FILE_CSV_MIMETYPE = "text/csv"; - - public static final String PARAMETER_ENCODING = "encoding"; public static final String PARAMETER_HASHEADER = "hasHeader"; @@ -129,6 +130,7 @@ public class Constants { public static final String PARAMETER_RESOURCE_NAME = "name"; public static final String PARAMETER_RESOURCE_DESCRIPTION = "description"; - + + }