refs 6548: TDM - Migrate TabMan to new PortalContext
Task-Url: https://support.d4science.org/issues/6548 Updated to new PortalContext git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-expression-widget@141744 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
4a5027657c
commit
9db7271d3e
|
@ -1,12 +1,12 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" output="target/tabular-data-expression-widget-1.8.0-SNAPSHOT/WEB-INF/classes" path="src/main/java">
|
||||
<classpathentry kind="src" output="target/tabular-data-expression-widget-1.9.0-SNAPSHOT/WEB-INF/classes" path="src/main/java">
|
||||
<attributes>
|
||||
<attribute name="optional" value="true"/>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry excluding="**" kind="src" output="target/tabular-data-expression-widget-1.8.0-SNAPSHOT/WEB-INF/classes" path="src/main/resources">
|
||||
<classpathentry excluding="**" kind="src" output="target/tabular-data-expression-widget-1.9.0-SNAPSHOT/WEB-INF/classes" path="src/main/resources">
|
||||
<attributes>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
|
@ -32,5 +32,5 @@
|
|||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="output" path="target/tabular-data-expression-widget-1.8.0-SNAPSHOT/WEB-INF/classes"/>
|
||||
<classpathentry kind="output" path="target/tabular-data-expression-widget-1.9.0-SNAPSHOT/WEB-INF/classes"/>
|
||||
</classpath>
|
||||
|
|
|
@ -1,4 +1,8 @@
|
|||
<ReleaseNotes>
|
||||
<Changeset component="org.gcube.portlets-user.tabular-data-expression-widget.1-9-0"
|
||||
date="2017-02-15">
|
||||
<Change>Updated to new PortalContext [ticket #6548]</Change>
|
||||
</Changeset>
|
||||
<Changeset component="org.gcube.portlets-user.tabular-data-expression-widget.1-8-0"
|
||||
date="2016-07-15">
|
||||
<Change>Updated to Liferay 6.2</Change>
|
||||
|
|
28
pom.xml
28
pom.xml
|
@ -13,7 +13,7 @@
|
|||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>org.gcube.portlets.user</groupId>
|
||||
<artifactId>tabular-data-expression-widget</artifactId>
|
||||
<version>1.8.0-SNAPSHOT</version>
|
||||
<version>1.9.0-SNAPSHOT</version>
|
||||
|
||||
|
||||
<name>tabular-data-expression-widget</name>
|
||||
|
@ -108,32 +108,14 @@
|
|||
<version>${gxtVersion}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Portal -->
|
||||
<!-- PORTAL -->
|
||||
<dependency>
|
||||
<groupId>org.gcube.core</groupId>
|
||||
<artifactId>common-scope-maps</artifactId>
|
||||
<version>[1.0.2-SNAPSHOT,2.0.0-SNAPSHOT)</version>
|
||||
<scope>provided</scope>
|
||||
<!-- <version>[1.0.2-SNAPSHOT,2.0.0-SNAPSHOT)</version> -->
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.gcube.portal</groupId>
|
||||
<artifactId>custom-portal-handler</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.gcube.applicationsupportlayer</groupId>
|
||||
<artifactId>aslcore</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.gcube.applicationsupportlayer</groupId>
|
||||
<artifactId>accesslogger</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
|
||||
|
||||
<!-- service-client-impl -->
|
||||
<dependency>
|
||||
<groupId>org.gcube.data.analysis.tabulardata</groupId>
|
||||
|
|
|
@ -13,10 +13,12 @@ import javax.servlet.http.HttpServletRequest;
|
|||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.servlet.http.HttpSession;
|
||||
|
||||
import org.gcube.application.framework.core.session.ASLSession;
|
||||
import org.gcube.common.scope.api.ScopeProvider;
|
||||
import org.gcube.data.analysis.tabulardata.expression.Expression;
|
||||
import org.gcube.portlets.user.td.expressionwidget.shared.exception.ExpressionParserException;
|
||||
import org.gcube.portlets.user.td.gwtservice.server.SessionUtil;
|
||||
import org.gcube.portlets.user.td.gwtservice.server.util.ServiceCredentials;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.Constants;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTServiceException;
|
||||
import org.gcube.portlets.user.td.widgetcommonevent.shared.expression.C_Expression;
|
||||
import org.slf4j.Logger;
|
||||
|
@ -64,14 +66,19 @@ public class CExpressionMapServlet extends HttpServlet {
|
|||
logger.info("CExpressionMapServlet import session id: "
|
||||
+ session.getId());
|
||||
|
||||
ServiceCredentials serviceCredentials;
|
||||
|
||||
try {
|
||||
ASLSession aslSession = SessionUtil.getAslSession(session);
|
||||
String token = SessionUtil.getToken(aslSession);
|
||||
logger.debug("UserToken: " + token);
|
||||
String scopeGroupId = request.getParameter(Constants.CURR_GROUP_ID);
|
||||
serviceCredentials = SessionUtil.getServiceCredentials(request,
|
||||
scopeGroupId);
|
||||
|
||||
ScopeProvider.instance.set(serviceCredentials.getScope());
|
||||
|
||||
} catch (TDGWTServiceException e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
e.printStackTrace();
|
||||
logger.error(
|
||||
"Error retrieving credentials:" + e.getLocalizedMessage(),
|
||||
e);
|
||||
throw new ServletException(e.getLocalizedMessage());
|
||||
}
|
||||
|
||||
|
|
|
@ -4,12 +4,9 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
import java.util.ResourceBundle;
|
||||
|
||||
import javax.servlet.http.HttpSession;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.gcube.application.framework.core.session.ASLSession;
|
||||
import org.gcube.data.analysis.tabulardata.commons.rules.types.RuleType;
|
||||
import org.gcube.data.analysis.tabulardata.commons.utils.AuthorizationProvider;
|
||||
import org.gcube.data.analysis.tabulardata.commons.utils.AuthorizationToken;
|
||||
import org.gcube.data.analysis.tabulardata.commons.webservice.types.AppliedRulesResponse;
|
||||
import org.gcube.data.analysis.tabulardata.commons.webservice.types.RuleDescription;
|
||||
import org.gcube.data.analysis.tabulardata.expression.Expression;
|
||||
|
@ -29,6 +26,7 @@ import org.gcube.portlets.user.td.gwtservice.server.SessionUtil;
|
|||
import org.gcube.portlets.user.td.gwtservice.server.TDGWTServiceImpl;
|
||||
import org.gcube.portlets.user.td.gwtservice.server.TDGWTServiceMessagesConstants;
|
||||
import org.gcube.portlets.user.td.gwtservice.server.trservice.ColumnDataTypeMap;
|
||||
import org.gcube.portlets.user.td.gwtservice.server.util.ServiceCredentials;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTServiceException;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.rule.AppliedRulesResponseData;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.rule.ApplyAndDetachColumnRulesSession;
|
||||
|
@ -73,18 +71,21 @@ public class ExpressionServiceImpl extends TDGWTServiceImpl implements
|
|||
@Override
|
||||
public String startFilterColumn(FilterColumnSession filterColumnSession)
|
||||
throws TDGWTServiceException {
|
||||
HttpSession session=null;
|
||||
HttpServletRequest httpRequest = null;
|
||||
try {
|
||||
logger.debug("ExpressionService submitColumnFilter");
|
||||
session = this.getThreadLocalRequest().getSession();
|
||||
logger.debug("Session: " + session);
|
||||
httpRequest = this.getThreadLocalRequest();
|
||||
ServiceCredentials serviceCredentials = SessionUtil
|
||||
.getServiceCredentials(httpRequest);
|
||||
|
||||
if (filterColumnSession == null) {
|
||||
logger.error("FilterColumnSession is null");
|
||||
new ExpressionServiceException("FilterColumnSession is null");
|
||||
} else {
|
||||
logger.debug("FilterColumnSession: " + filterColumnSession);
|
||||
}
|
||||
ExpressionSession.setColumnFilterSession(session,
|
||||
filterColumnSession);
|
||||
|
||||
ExpressionSession.setColumnFilterSession(httpRequest,
|
||||
serviceCredentials, filterColumnSession);
|
||||
|
||||
C_ExpressionParser parser = new C_ExpressionParser();
|
||||
Expression expression = null;
|
||||
|
@ -99,7 +100,7 @@ public class ExpressionServiceImpl extends TDGWTServiceImpl implements
|
|||
// TDGWTServiceImpl gwtService = new TDGWTServiceImpl();
|
||||
|
||||
String taskId = startFilterColumn(filterColumnSession, expression,
|
||||
session);
|
||||
httpRequest);
|
||||
|
||||
return taskId;
|
||||
|
||||
|
@ -108,9 +109,9 @@ public class ExpressionServiceImpl extends TDGWTServiceImpl implements
|
|||
} catch (SecurityException e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
e.printStackTrace();
|
||||
ResourceBundle messages = getResourceBundle(session);
|
||||
ResourceBundle messages = getResourceBundle(httpRequest);
|
||||
throw new TDGWTServiceException(
|
||||
messages.getString(TDGWTServiceMessagesConstants.securityExceptionRights));
|
||||
messages.getString(TDGWTServiceMessagesConstants.securityExceptionRights));
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
throw new TDGWTServiceException(e.getLocalizedMessage());
|
||||
|
@ -124,15 +125,16 @@ public class ExpressionServiceImpl extends TDGWTServiceImpl implements
|
|||
|
||||
public String startAddColumn(AddColumnSession addColumnSession)
|
||||
throws TDGWTServiceException {
|
||||
HttpSession session=null;
|
||||
HttpServletRequest httpRequest = null;
|
||||
try {
|
||||
logger.debug("AddColumn");
|
||||
session = this.getThreadLocalRequest().getSession();
|
||||
logger.debug("Session: " + session);
|
||||
httpRequest = this.getThreadLocalRequest();
|
||||
|
||||
logger.debug("AddColumn");
|
||||
if (addColumnSession == null) {
|
||||
logger.error("AddColumnSession is null");
|
||||
new ExpressionServiceException("AddColumnSession is null");
|
||||
} else {
|
||||
logger.debug("AddColumnSession: " + addColumnSession);
|
||||
}
|
||||
|
||||
ColumnMockUp columnMockUp = addColumnSession.getColumnMockUp();
|
||||
|
@ -155,7 +157,7 @@ public class ExpressionServiceImpl extends TDGWTServiceImpl implements
|
|||
// TDGWTServiceImpl gwtService = new TDGWTServiceImpl();
|
||||
|
||||
String taskId = startAddColumn(addColumnSession, expression,
|
||||
session);
|
||||
httpRequest);
|
||||
|
||||
return taskId;
|
||||
|
||||
|
@ -164,10 +166,10 @@ public class ExpressionServiceImpl extends TDGWTServiceImpl implements
|
|||
} catch (SecurityException e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
e.printStackTrace();
|
||||
ResourceBundle messages = getResourceBundle(session);
|
||||
ResourceBundle messages = getResourceBundle(httpRequest);
|
||||
throw new TDGWTServiceException(
|
||||
messages.getString(TDGWTServiceMessagesConstants.securityExceptionRights));
|
||||
|
||||
messages.getString(TDGWTServiceMessagesConstants.securityExceptionRights));
|
||||
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
throw new TDGWTServiceException(e.getLocalizedMessage());
|
||||
|
@ -183,19 +185,25 @@ public class ExpressionServiceImpl extends TDGWTServiceImpl implements
|
|||
ReplaceColumnByExpressionSession replaceColumnByExpressionSession)
|
||||
throws TDGWTServiceException {
|
||||
|
||||
HttpSession session=null;
|
||||
HttpServletRequest httpRequest = null;
|
||||
try {
|
||||
httpRequest = this.getThreadLocalRequest();
|
||||
ServiceCredentials serviceCredentials = SessionUtil
|
||||
.getServiceCredentials(httpRequest);
|
||||
|
||||
logger.debug("ExpressionService submitReplaceColumnByExpression");
|
||||
session = this.getThreadLocalRequest().getSession();
|
||||
logger.debug("Session: " + session);
|
||||
|
||||
if (replaceColumnByExpressionSession == null) {
|
||||
logger.error("ReplaceColumnByExpressionSession is null");
|
||||
new ExpressionServiceException(
|
||||
"ReplaceColumnByExpressionSession is null");
|
||||
} else {
|
||||
logger.debug("ReplaceColumnByExpressionSession: "
|
||||
+ replaceColumnByExpressionSession);
|
||||
}
|
||||
ExpressionSession.setReplaceColumnByExpressionSession(session,
|
||||
replaceColumnByExpressionSession);
|
||||
|
||||
ExpressionSession.setReplaceColumnByExpressionSession(httpRequest,
|
||||
serviceCredentials, replaceColumnByExpressionSession);
|
||||
|
||||
C_ExpressionParser parser = new C_ExpressionParser();
|
||||
|
||||
|
@ -226,7 +234,7 @@ public class ExpressionServiceImpl extends TDGWTServiceImpl implements
|
|||
|
||||
String taskId = startReplaceColumnByExpression(
|
||||
replaceColumnByExpressionSession, conditionExpression,
|
||||
replaceExpression, session);
|
||||
replaceExpression, httpRequest);
|
||||
return taskId;
|
||||
|
||||
} catch (TDGWTServiceException e) {
|
||||
|
@ -234,9 +242,9 @@ public class ExpressionServiceImpl extends TDGWTServiceImpl implements
|
|||
} catch (SecurityException e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
e.printStackTrace();
|
||||
ResourceBundle messages = getResourceBundle(session);
|
||||
ResourceBundle messages = getResourceBundle(httpRequest);
|
||||
throw new TDGWTServiceException(
|
||||
messages.getString(TDGWTServiceMessagesConstants.securityExceptionRights));
|
||||
messages.getString(TDGWTServiceMessagesConstants.securityExceptionRights));
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
throw new TDGWTServiceException(e.getLocalizedMessage());
|
||||
|
@ -250,16 +258,12 @@ public class ExpressionServiceImpl extends TDGWTServiceImpl implements
|
|||
@Override
|
||||
public ArrayList<RuleDescriptionData> getRules()
|
||||
throws TDGWTServiceException {
|
||||
HttpSession session=null;
|
||||
HttpServletRequest httpRequest = null;
|
||||
try {
|
||||
session = this.getThreadLocalRequest().getSession();
|
||||
ASLSession aslSession = SessionUtil.getAslSession(session);
|
||||
String token = SessionUtil.getToken(aslSession);
|
||||
logger.debug("UserToken: " + token);
|
||||
|
||||
httpRequest = this.getThreadLocalRequest();
|
||||
SessionUtil.getServiceCredentials(httpRequest);
|
||||
|
||||
logger.debug("GetRules()");
|
||||
AuthorizationProvider.instance.set(new AuthorizationToken(
|
||||
aslSession.getUsername(), aslSession.getScope()));
|
||||
TabularDataService service = TabularDataServiceFactory.getService();
|
||||
|
||||
List<RuleDescription> rules = service.getRules();
|
||||
|
@ -284,10 +288,10 @@ public class ExpressionServiceImpl extends TDGWTServiceImpl implements
|
|||
} catch (SecurityException e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
e.printStackTrace();
|
||||
ResourceBundle messages = getResourceBundle(session);
|
||||
ResourceBundle messages = getResourceBundle(httpRequest);
|
||||
throw new TDGWTServiceException(
|
||||
messages.getString(TDGWTServiceMessagesConstants.securityExceptionRights));
|
||||
|
||||
|
||||
} catch (Throwable e) {
|
||||
logger.error("Error in getRules(): " + e.getLocalizedMessage());
|
||||
e.printStackTrace();
|
||||
|
@ -304,16 +308,11 @@ public class ExpressionServiceImpl extends TDGWTServiceImpl implements
|
|||
@Override
|
||||
public ArrayList<RuleDescriptionData> getRules(RuleScopeType scope)
|
||||
throws TDGWTServiceException {
|
||||
HttpSession session=null;
|
||||
HttpServletRequest httpRequest = null;
|
||||
try {
|
||||
session = this.getThreadLocalRequest().getSession();
|
||||
ASLSession aslSession = SessionUtil.getAslSession(session);
|
||||
String token = SessionUtil.getToken(aslSession);
|
||||
logger.debug("UserToken: " + token);
|
||||
|
||||
httpRequest = this.getThreadLocalRequest();
|
||||
SessionUtil.getServiceCredentials(httpRequest);
|
||||
logger.debug("GetRules(): " + scope);
|
||||
AuthorizationProvider.instance.set(new AuthorizationToken(
|
||||
aslSession.getUsername(), aslSession.getScope()));
|
||||
TabularDataService service = TabularDataServiceFactory.getService();
|
||||
|
||||
List<RuleDescription> rules = service.getRulesByScope(RuleScopeMap
|
||||
|
@ -339,7 +338,7 @@ public class ExpressionServiceImpl extends TDGWTServiceImpl implements
|
|||
} catch (SecurityException e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
e.printStackTrace();
|
||||
ResourceBundle messages = getResourceBundle(session);
|
||||
ResourceBundle messages = getResourceBundle(httpRequest);
|
||||
throw new TDGWTServiceException(
|
||||
messages.getString(TDGWTServiceMessagesConstants.securityExceptionRights));
|
||||
} catch (Throwable e) {
|
||||
|
@ -358,16 +357,12 @@ public class ExpressionServiceImpl extends TDGWTServiceImpl implements
|
|||
@Override
|
||||
public ArrayList<RuleDescriptionData> getApplicableBaseColumnRules(
|
||||
ColumnData columnData) throws TDGWTServiceException {
|
||||
HttpSession session=null;
|
||||
HttpServletRequest httpRequest = null;
|
||||
try {
|
||||
session = this.getThreadLocalRequest().getSession();
|
||||
ASLSession aslSession = SessionUtil.getAslSession(session);
|
||||
String token = SessionUtil.getToken(aslSession);
|
||||
logger.debug("UserToken: " + token);
|
||||
httpRequest = this.getThreadLocalRequest();
|
||||
SessionUtil.getServiceCredentials(httpRequest);
|
||||
|
||||
logger.debug("GetApplicableBaseColumnRules(): " + columnData);
|
||||
AuthorizationProvider.instance.set(new AuthorizationToken(
|
||||
aslSession.getUsername(), aslSession.getScope()));
|
||||
TabularDataService service = TabularDataServiceFactory.getService();
|
||||
|
||||
if (columnData == null) {
|
||||
|
@ -409,10 +404,10 @@ public class ExpressionServiceImpl extends TDGWTServiceImpl implements
|
|||
} catch (SecurityException e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
e.printStackTrace();
|
||||
ResourceBundle messages = getResourceBundle(session);
|
||||
ResourceBundle messages = getResourceBundle(httpRequest);
|
||||
throw new TDGWTServiceException(
|
||||
messages.getString(TDGWTServiceMessagesConstants.securityExceptionRights));
|
||||
|
||||
|
||||
} catch (Throwable e) {
|
||||
logger.error("Error in getApplicableBaseColumnRules(): "
|
||||
+ e.getLocalizedMessage());
|
||||
|
@ -430,16 +425,12 @@ public class ExpressionServiceImpl extends TDGWTServiceImpl implements
|
|||
@Override
|
||||
public AppliedRulesResponseData getActiveRulesByTabularResourceId(TRId trId)
|
||||
throws TDGWTServiceException {
|
||||
HttpSession session=null;
|
||||
HttpServletRequest httpRequest = null;
|
||||
try {
|
||||
session = this.getThreadLocalRequest().getSession();
|
||||
ASLSession aslSession = SessionUtil.getAslSession(session);
|
||||
String token = SessionUtil.getToken(aslSession);
|
||||
logger.debug("UserToken: " + token);
|
||||
httpRequest = this.getThreadLocalRequest();
|
||||
SessionUtil.getServiceCredentials(httpRequest);
|
||||
|
||||
logger.debug("GetAppliedRulesByTabularResourceId(): " + trId);
|
||||
AuthorizationProvider.instance.set(new AuthorizationToken(
|
||||
aslSession.getUsername(), aslSession.getScope()));
|
||||
TabularDataService service = TabularDataServiceFactory.getService();
|
||||
|
||||
if (trId == null || trId.getId() == null || trId.getId().isEmpty()) {
|
||||
|
@ -471,10 +462,10 @@ public class ExpressionServiceImpl extends TDGWTServiceImpl implements
|
|||
} catch (SecurityException e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
e.printStackTrace();
|
||||
ResourceBundle messages = getResourceBundle(session);
|
||||
ResourceBundle messages = getResourceBundle(httpRequest);
|
||||
throw new TDGWTServiceException(
|
||||
messages.getString(TDGWTServiceMessagesConstants.securityExceptionRights));
|
||||
|
||||
|
||||
} catch (Throwable e) {
|
||||
logger.error("Error in getActiveRulesByTabularResourceId(): "
|
||||
+ e.getLocalizedMessage());
|
||||
|
@ -490,19 +481,14 @@ public class ExpressionServiceImpl extends TDGWTServiceImpl implements
|
|||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public String saveRule(
|
||||
RuleDescriptionData ruleDescriptionData)
|
||||
public String saveRule(RuleDescriptionData ruleDescriptionData)
|
||||
throws TDGWTServiceException {
|
||||
HttpSession session=null;
|
||||
HttpServletRequest httpRequest = null;
|
||||
try {
|
||||
session = this.getThreadLocalRequest().getSession();
|
||||
ASLSession aslSession = SessionUtil.getAslSession(session);
|
||||
String token = SessionUtil.getToken(aslSession);
|
||||
logger.debug("UserToken: " + token);
|
||||
httpRequest = this.getThreadLocalRequest();
|
||||
SessionUtil.getServiceCredentials(httpRequest);
|
||||
|
||||
logger.debug("SaveRule() :" + ruleDescriptionData);
|
||||
AuthorizationProvider.instance.set(new AuthorizationToken(
|
||||
aslSession.getUsername(), aslSession.getScope()));
|
||||
TabularDataService service = TabularDataServiceFactory.getService();
|
||||
|
||||
C_ExpressionParser parser = new C_ExpressionParser();
|
||||
|
@ -519,25 +505,22 @@ public class ExpressionServiceImpl extends TDGWTServiceImpl implements
|
|||
|
||||
logger.debug("Service Condition Expression:" + conditionExpression);
|
||||
|
||||
RuleType ruleType = RuleTypeMap
|
||||
.map(ruleDescriptionData.getTdRuleType());
|
||||
RuleType ruleType = RuleTypeMap.map(ruleDescriptionData
|
||||
.getTdRuleType());
|
||||
if (ruleType == null) {
|
||||
logger.error("Error saving rule, rule type is null!");
|
||||
throw new TDGWTServiceException(
|
||||
"Error saving rule, rule type is null!");
|
||||
}
|
||||
|
||||
|
||||
|
||||
RuleId ruleId = service.saveRule(
|
||||
ruleDescriptionData.getName(),
|
||||
ruleDescriptionData.getDescription(),
|
||||
conditionExpression, ruleType);
|
||||
|
||||
RuleId ruleId = service.saveRule(ruleDescriptionData.getName(),
|
||||
ruleDescriptionData.getDescription(), conditionExpression,
|
||||
ruleType);
|
||||
|
||||
logger.debug("RuleId: " + ruleId);
|
||||
|
||||
|
||||
String ruleIdent = null;
|
||||
|
||||
|
||||
if (ruleId != null) {
|
||||
ruleIdent = String.valueOf(ruleId.getValue());
|
||||
}
|
||||
|
@ -550,13 +533,12 @@ public class ExpressionServiceImpl extends TDGWTServiceImpl implements
|
|||
} catch (SecurityException e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
e.printStackTrace();
|
||||
ResourceBundle messages = getResourceBundle(session);
|
||||
ResourceBundle messages = getResourceBundle(httpRequest);
|
||||
throw new TDGWTServiceException(
|
||||
messages.getString(TDGWTServiceMessagesConstants.securityExceptionRights));
|
||||
|
||||
|
||||
} catch (Throwable e) {
|
||||
logger.error("Error in save rule: "
|
||||
+ e.getLocalizedMessage());
|
||||
logger.error("Error in save rule: " + e.getLocalizedMessage());
|
||||
e.printStackTrace();
|
||||
throw new TDGWTServiceException("Error in save rule: "
|
||||
+ e.getLocalizedMessage());
|
||||
|
@ -564,7 +546,6 @@ public class ExpressionServiceImpl extends TDGWTServiceImpl implements
|
|||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* {@inheritDoc}
|
||||
|
@ -572,16 +553,12 @@ public class ExpressionServiceImpl extends TDGWTServiceImpl implements
|
|||
@Override
|
||||
public void updateColumnRule(RuleDescriptionData ruleDescriptionData)
|
||||
throws TDGWTServiceException {
|
||||
HttpSession session=null;
|
||||
HttpServletRequest httpRequest = null;
|
||||
try {
|
||||
session = this.getThreadLocalRequest().getSession();
|
||||
ASLSession aslSession = SessionUtil.getAslSession(session);
|
||||
String token = SessionUtil.getToken(aslSession);
|
||||
logger.debug("UserToken: " + token);
|
||||
httpRequest = this.getThreadLocalRequest();
|
||||
SessionUtil.getServiceCredentials(httpRequest);
|
||||
|
||||
logger.debug("UpdateColumnRule() :" + ruleDescriptionData);
|
||||
AuthorizationProvider.instance.set(new AuthorizationToken(
|
||||
aslSession.getUsername(), aslSession.getScope()));
|
||||
TabularDataService service = TabularDataServiceFactory.getService();
|
||||
|
||||
RuleDescription ruleDescription = RuleDescriptionMap
|
||||
|
@ -605,10 +582,10 @@ public class ExpressionServiceImpl extends TDGWTServiceImpl implements
|
|||
} catch (SecurityException e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
e.printStackTrace();
|
||||
ResourceBundle messages = getResourceBundle(session);
|
||||
ResourceBundle messages = getResourceBundle(httpRequest);
|
||||
throw new TDGWTServiceException(
|
||||
messages.getString(TDGWTServiceMessagesConstants.securityExceptionRights));
|
||||
|
||||
|
||||
} catch (Throwable e) {
|
||||
logger.error("Error in getRule(): " + e.getLocalizedMessage());
|
||||
e.printStackTrace();
|
||||
|
@ -625,12 +602,10 @@ public class ExpressionServiceImpl extends TDGWTServiceImpl implements
|
|||
@Override
|
||||
public void removeRulesById(ArrayList<RuleDescriptionData> rules)
|
||||
throws TDGWTServiceException {
|
||||
HttpSession session=null;
|
||||
HttpServletRequest httpRequest = null;
|
||||
try {
|
||||
session = this.getThreadLocalRequest().getSession();
|
||||
ASLSession aslSession = SessionUtil.getAslSession(session);
|
||||
String token = SessionUtil.getToken(aslSession);
|
||||
logger.debug("UserToken: " + token);
|
||||
httpRequest = this.getThreadLocalRequest();
|
||||
SessionUtil.getServiceCredentials(httpRequest);
|
||||
|
||||
logger.debug("RemoveRuleById() :" + rules);
|
||||
if (rules == null || !(rules.size() > 0)) {
|
||||
|
@ -638,8 +613,6 @@ public class ExpressionServiceImpl extends TDGWTServiceImpl implements
|
|||
"Error removing the rule, no rules selected");
|
||||
}
|
||||
|
||||
AuthorizationProvider.instance.set(new AuthorizationToken(
|
||||
aslSession.getUsername(), aslSession.getScope()));
|
||||
TabularDataService service = TabularDataServiceFactory.getService();
|
||||
|
||||
for (RuleDescriptionData ruleDescriptionData : rules) {
|
||||
|
@ -654,10 +627,10 @@ public class ExpressionServiceImpl extends TDGWTServiceImpl implements
|
|||
} catch (SecurityException e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
e.printStackTrace();
|
||||
ResourceBundle messages = getResourceBundle(session);
|
||||
ResourceBundle messages = getResourceBundle(httpRequest);
|
||||
throw new TDGWTServiceException(
|
||||
messages.getString(TDGWTServiceMessagesConstants.securityExceptionRights));
|
||||
|
||||
|
||||
} catch (Throwable e) {
|
||||
logger.error("Error in removeRuleById(): "
|
||||
+ e.getLocalizedMessage());
|
||||
|
@ -676,10 +649,12 @@ public class ExpressionServiceImpl extends TDGWTServiceImpl implements
|
|||
public String startApplyAndDetachColumnRules(
|
||||
ApplyAndDetachColumnRulesSession applyAndDetachColumnRulesSession)
|
||||
throws TDGWTServiceException {
|
||||
HttpServletRequest httpRequest = null;
|
||||
try {
|
||||
HttpSession session = this.getThreadLocalRequest().getSession();
|
||||
httpRequest = this.getThreadLocalRequest();
|
||||
|
||||
String taskId = startApplyAndDetachColumnnRules(
|
||||
applyAndDetachColumnRulesSession, session);
|
||||
applyAndDetachColumnRulesSession, httpRequest);
|
||||
return taskId;
|
||||
|
||||
} catch (TDGWTServiceException e) {
|
||||
|
@ -690,16 +665,16 @@ public class ExpressionServiceImpl extends TDGWTServiceImpl implements
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public String startApplyTableRule(
|
||||
ApplyTableRuleSession applyTableRuleSession)
|
||||
throws TDGWTServiceException {
|
||||
HttpServletRequest httpRequest = null;
|
||||
try {
|
||||
HttpSession session = this.getThreadLocalRequest().getSession();
|
||||
String taskId = startApplyTableRule(
|
||||
applyTableRuleSession, session);
|
||||
httpRequest = this.getThreadLocalRequest();
|
||||
String taskId = startApplyTableRule(applyTableRuleSession,
|
||||
httpRequest);
|
||||
return taskId;
|
||||
|
||||
} catch (TDGWTServiceException e) {
|
||||
|
@ -710,7 +685,6 @@ public class ExpressionServiceImpl extends TDGWTServiceImpl implements
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -720,9 +694,10 @@ public class ExpressionServiceImpl extends TDGWTServiceImpl implements
|
|||
public void setDetachColumnRules(
|
||||
DetachColumnRulesSession detachColumnRulesSession)
|
||||
throws TDGWTServiceException {
|
||||
HttpServletRequest httpRequest = null;
|
||||
try {
|
||||
HttpSession session = this.getThreadLocalRequest().getSession();
|
||||
setDetachColumnnRules(detachColumnRulesSession, session);
|
||||
httpRequest = this.getThreadLocalRequest();
|
||||
setDetachColumnnRules(detachColumnRulesSession, httpRequest);
|
||||
return;
|
||||
|
||||
} catch (TDGWTServiceException e) {
|
||||
|
@ -734,7 +709,6 @@ public class ExpressionServiceImpl extends TDGWTServiceImpl implements
|
|||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* {@inheritDoc}
|
||||
|
@ -743,9 +717,10 @@ public class ExpressionServiceImpl extends TDGWTServiceImpl implements
|
|||
public void setDetachTableRules(
|
||||
DetachTableRulesSession detachTableRulesSession)
|
||||
throws TDGWTServiceException {
|
||||
HttpServletRequest httpRequest = null;
|
||||
try {
|
||||
HttpSession session = this.getThreadLocalRequest().getSession();
|
||||
setDetachTableRules(detachTableRulesSession, session);
|
||||
httpRequest = this.getThreadLocalRequest();
|
||||
setDetachTableRules(detachTableRulesSession, httpRequest);
|
||||
return;
|
||||
|
||||
} catch (TDGWTServiceException e) {
|
||||
|
@ -757,5 +732,4 @@ public class ExpressionServiceImpl extends TDGWTServiceImpl implements
|
|||
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -3,13 +3,16 @@
|
|||
*/
|
||||
package org.gcube.portlets.user.td.expressionwidget.server;
|
||||
|
||||
import javax.servlet.http.HttpSession;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.gcube.common.scope.api.ScopeProvider;
|
||||
import org.gcube.data.analysis.tabulardata.service.operation.Task;
|
||||
import org.gcube.portlets.user.td.gwtservice.server.SessionConstants;
|
||||
import org.gcube.portlets.user.td.gwtservice.server.SessionOp;
|
||||
import org.gcube.portlets.user.td.gwtservice.server.util.ServiceCredentials;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTServiceException;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.tr.column.FilterColumnSession;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.tr.column.ReplaceColumnByExpressionSession;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -19,86 +22,62 @@ import org.slf4j.LoggerFactory;
|
|||
*/
|
||||
public class ExpressionSession {
|
||||
|
||||
|
||||
protected static final String COLUMN_FILTER_SESSION = "COLUMN_FILTER_SESSION";
|
||||
protected static final String COLUMN_FILTER_SESSION_TASK = "COLUMN_FILTER_SESSION_TASK";
|
||||
|
||||
protected static final String REPLACE_COLUMN_BY_EXPRESSION_SESSION = "REPLACE_COLUMN_BY_EXPRESSION_SESSION";
|
||||
|
||||
protected static Logger logger = LoggerFactory.getLogger(ExpressionSession.class);
|
||||
|
||||
|
||||
public static FilterColumnSession getColumnFilterSession(
|
||||
HttpSession httpSession) {
|
||||
FilterColumnSession columnFilterSession = (FilterColumnSession) httpSession
|
||||
.getAttribute(COLUMN_FILTER_SESSION);
|
||||
if (columnFilterSession != null) {
|
||||
return columnFilterSession;
|
||||
} else {
|
||||
columnFilterSession = new FilterColumnSession();
|
||||
httpSession.setAttribute(COLUMN_FILTER_SESSION,
|
||||
columnFilterSession);
|
||||
return columnFilterSession;
|
||||
}
|
||||
HttpServletRequest httpRequest,
|
||||
ServiceCredentials serviceCredentials) throws TDGWTServiceException {
|
||||
ScopeProvider.instance.set(serviceCredentials.getScope());
|
||||
SessionOp<FilterColumnSession> sessionOp = new SessionOp<>();
|
||||
FilterColumnSession columnFilterSession = sessionOp.get(httpRequest,
|
||||
serviceCredentials, SessionConstants.COLUMN_FILTER_SESSION,
|
||||
FilterColumnSession.class);
|
||||
return columnFilterSession;
|
||||
}
|
||||
|
||||
public static void setColumnFilterSession(HttpSession httpSession,
|
||||
public static void setColumnFilterSession(HttpServletRequest httpRequest,
|
||||
ServiceCredentials serviceCredentials,
|
||||
FilterColumnSession columnFilterSession) {
|
||||
FilterColumnSession cf = (FilterColumnSession) httpSession
|
||||
.getAttribute(COLUMN_FILTER_SESSION);
|
||||
if (cf != null) {
|
||||
httpSession.removeAttribute(COLUMN_FILTER_SESSION);
|
||||
}
|
||||
httpSession.setAttribute(COLUMN_FILTER_SESSION,
|
||||
columnFilterSession);
|
||||
|
||||
SessionOp<FilterColumnSession> sessionOp = new SessionOp<>();
|
||||
sessionOp.set(httpRequest, serviceCredentials,
|
||||
SessionConstants.COLUMN_FILTER_SESSION, columnFilterSession);
|
||||
}
|
||||
|
||||
|
||||
public static ReplaceColumnByExpressionSession getReplaceColumnByExpressionSession(
|
||||
HttpSession httpSession) {
|
||||
ReplaceColumnByExpressionSession replaceColumnByExpressionSession = (ReplaceColumnByExpressionSession) httpSession
|
||||
.getAttribute(REPLACE_COLUMN_BY_EXPRESSION_SESSION);
|
||||
if (replaceColumnByExpressionSession != null) {
|
||||
return replaceColumnByExpressionSession;
|
||||
} else {
|
||||
replaceColumnByExpressionSession = new ReplaceColumnByExpressionSession();
|
||||
httpSession.setAttribute(REPLACE_COLUMN_BY_EXPRESSION_SESSION,
|
||||
replaceColumnByExpressionSession);
|
||||
return replaceColumnByExpressionSession;
|
||||
}
|
||||
HttpServletRequest httpRequest,
|
||||
ServiceCredentials serviceCredentials) throws TDGWTServiceException {
|
||||
ScopeProvider.instance.set(serviceCredentials.getScope());
|
||||
SessionOp<ReplaceColumnByExpressionSession> sessionOp = new SessionOp<>();
|
||||
ReplaceColumnByExpressionSession replaceColumnByExpressionSession = sessionOp
|
||||
.get(httpRequest, serviceCredentials,
|
||||
SessionConstants.REPLACE_COLUMN_BY_EXPRESSION_SESSION,
|
||||
ReplaceColumnByExpressionSession.class);
|
||||
return replaceColumnByExpressionSession;
|
||||
}
|
||||
|
||||
public static void setReplaceColumnByExpressionSession(HttpSession httpSession,
|
||||
public static void setReplaceColumnByExpressionSession(
|
||||
HttpServletRequest httpRequest,
|
||||
ServiceCredentials serviceCredentials,
|
||||
ReplaceColumnByExpressionSession replaceColumnByExpressionSession) {
|
||||
ReplaceColumnByExpressionSession rce = (ReplaceColumnByExpressionSession) httpSession
|
||||
.getAttribute(REPLACE_COLUMN_BY_EXPRESSION_SESSION);
|
||||
if (rce != null) {
|
||||
httpSession.removeAttribute(REPLACE_COLUMN_BY_EXPRESSION_SESSION);
|
||||
}
|
||||
httpSession.setAttribute(REPLACE_COLUMN_BY_EXPRESSION_SESSION,
|
||||
SessionOp<ReplaceColumnByExpressionSession> sessionOp = new SessionOp<>();
|
||||
sessionOp.set(httpRequest, serviceCredentials,
|
||||
SessionConstants.REPLACE_COLUMN_BY_EXPRESSION_SESSION,
|
||||
replaceColumnByExpressionSession);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public static Task getColumnFilterTask(HttpSession httpSession) {
|
||||
Task monitor = (Task) httpSession.getAttribute(COLUMN_FILTER_SESSION_TASK);
|
||||
if (monitor == null) {
|
||||
logger.error("CHANGE_THE_COLUMN_LABEL_TASK was not acquired");
|
||||
}
|
||||
public static Task getColumnFilterTask(HttpServletRequest httpRequest,
|
||||
ServiceCredentials serviceCredentials) {
|
||||
ScopeProvider.instance.set(serviceCredentials.getScope());
|
||||
SessionOp<Task> sessionOp = new SessionOp<>();
|
||||
Task monitor = sessionOp.get(httpRequest, serviceCredentials,
|
||||
SessionConstants.COLUMN_FILTER_SESSION_TASK);
|
||||
return monitor;
|
||||
}
|
||||
|
||||
public static void setColumnFilterTask(HttpSession httpSession,
|
||||
Task task) {
|
||||
Task monitor = (Task) httpSession.getAttribute(COLUMN_FILTER_SESSION_TASK);
|
||||
if (monitor != null)
|
||||
httpSession.removeAttribute(COLUMN_FILTER_SESSION_TASK);
|
||||
httpSession.setAttribute(COLUMN_FILTER_SESSION_TASK, task);
|
||||
public static void setColumnFilterTask(HttpServletRequest httpRequest,
|
||||
ServiceCredentials serviceCredentials, Task task) {
|
||||
SessionOp<Task> sessionOp = new SessionOp<>();
|
||||
sessionOp.set(httpRequest, serviceCredentials,
|
||||
SessionConstants.COLUMN_FILTER_SESSION_TASK, task);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -23,4 +23,6 @@ public class Constants {
|
|||
public static final String PARAMETER_ID ="id";
|
||||
public static final String PARAMETER_VERSION ="version";
|
||||
|
||||
public static final String C_EXPRESSION_MAP_SERVLET="CExpressionMapServlet";
|
||||
|
||||
}
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
</servlet-mapping>
|
||||
<servlet-mapping>
|
||||
<servlet-name>CExpressionMapServlet</servlet-name>
|
||||
<url-pattern>/ExpressionWidget/CExpressionMap</url-pattern>
|
||||
<url-pattern>/ExpressionWidget/CExpressionMapServlet</url-pattern>
|
||||
</servlet-mapping>
|
||||
<servlet-mapping>
|
||||
<servlet-name>TDGWTService</servlet-name>
|
||||
|
|
|
@ -10,6 +10,7 @@ import java.net.MalformedURLException;
|
|||
import java.net.URL;
|
||||
|
||||
import org.gcube.data.analysis.tabulardata.expression.Expression;
|
||||
import org.gcube.portlets.user.td.expressionwidget.shared.Constants;
|
||||
import org.gcube.portlets.user.td.widgetcommonevent.shared.expression.C_Expression;
|
||||
import org.junit.Test;
|
||||
|
||||
|
@ -19,10 +20,10 @@ public class TestCExpressionServlet {
|
|||
public void test() {
|
||||
HttpURLConnection cs = null;
|
||||
|
||||
String path = "ExpressionWidget/CExpressionMap";
|
||||
String path = "ExpressionWidget/";
|
||||
URL url = null;
|
||||
try {
|
||||
url = new URL("http://127.0.0.1:8888/" + path);
|
||||
url = new URL("http://127.0.0.1:8888/" + path+Constants.C_EXPRESSION_MAP_SERVLET);
|
||||
} catch (MalformedURLException e1) {
|
||||
e1.printStackTrace();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue