refs 3483: TDM - improve the quality of the error messages for Rules

Task-Url: https://support.d4science.org/issues/3483

Fixed ASLSession

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-gwt-service@128125 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Giancarlo Panichi 2016-04-18 16:16:46 +00:00
parent 942454d69e
commit c9ce3ca7fa
4 changed files with 92 additions and 58 deletions

View File

@ -1,4 +1,7 @@
<ReleaseNotes>
<Changeset component="org.gcube.portlets-user.tabular-data-gwt-service.2-11-0" date="2016-05-01">
<Change>Fixed ASLSession</Change>
</Changeset>
<Changeset component="org.gcube.portlets-user.tabular-data-gwt-service.2-10-0" date="2016-01-31">
<Change>Fixed SDMX Export no ExportMetadata is supported on service</Change>
</Changeset>

26
pom.xml
View File

@ -14,7 +14,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>org.gcube.portlets.user</groupId>
<artifactId>tabular-data-gwt-service</artifactId>
<version>2.10.0-SNAPSHOT</version>
<version>2.11.0-SNAPSHOT</version>
<name>tabular-data-gwt-service</name>
<description>tabular-data-gwt-service allows communication between the GUI and services</description>
@ -68,6 +68,17 @@
<version>1.0.1</version>
<scope>runtime</scope>
</dependency>
<!--
<dependency>
<groupId>org.gcube.common</groupId>
<artifactId>common-authorization</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.gcube.common</groupId>
<artifactId>authorization-client</artifactId>
<scope>runtime</scope>
</dependency> -->
</dependencies>
</profile>
@ -116,6 +127,19 @@
<scope>provided</scope>
</dependency>
<!-- Authorization
<dependency>
<groupId>org.gcube.common</groupId>
<artifactId>common-authorization</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.gcube.common</groupId>
<artifactId>authorization-client</artifactId>
<scope>provided</scope>
</dependency> -->
<!-- Social -->
<dependency>
<groupId>org.gcube.portal</groupId>

View File

@ -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,62 +92,80 @@ 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));
ResourceBundle messages = ResourceBundle.getBundle(
TDGWTServiceMessagesConstants.TDGWTServiceMessages, locale);
/*
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);
session = SessionManager.getInstance().getASLSession(
httpSession.setAttribute(ScopeHelper.USERNAME_ATTRIBUTE,
username);
aslSession = SessionManager.getInstance().getASLSession(
httpSession.getId(), username);
session.setScope(scope);
*/
aslSession.setScope(scope);
} else {
session = SessionManager.getInstance().getASLSession(
logger.info("no user found in session, use test user");
throw new TDGWTSessionExpiredException(
messages.getString(TDGWTServiceMessagesConstants.sessionExpired));
}
} else {
aslSession = SessionManager.getInstance().getASLSession(
httpSession.getId(), username);
}
logger.info("SessionUtil: aslSession " + session.getUsername() + " "
+ session.getScope());
return session;
logger.info("SessionUtil: aslSession " + aslSession.getUsername() + " "
+ aslSession.getScope());
return aslSession;
}
public static String getToken(ASLSession aslSession) {
String token = null;
if (Constants.DEBUG_MODE) {
List<String> 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);
}
@ -1128,7 +1147,6 @@ public class SessionUtil {
}
//
public static ApplyAndDetachColumnRulesSession getRulesOnColumnApplyAndDetachSession(
HttpSession httpSession) {
@ -1160,7 +1178,6 @@ public class SessionUtil {
}
//
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,8 +1202,7 @@ 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);
}
@ -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);
@ -1223,7 +1237,6 @@ public class SessionUtil {
}
//
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);
@ -1255,7 +1267,6 @@ public class SessionUtil {
}
//
public static TaskResubmitSession getTaskResubmitSession(
HttpSession httpSession) {
@ -2741,10 +2752,4 @@ public class SessionUtil {
}
}

View File

@ -10,15 +10,16 @@ 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";
public static final String PARAMETER_FIELDMASK = "fieldMask";
@ -131,4 +132,5 @@ public class Constants {
public static final String PARAMETER_RESOURCE_DESCRIPTION = "description";
}