diff --git a/src/main/java/org/gcube/portlets/user/td/expressionwidget/server/ExpressionServiceImpl.java b/src/main/java/org/gcube/portlets/user/td/expressionwidget/server/ExpressionServiceImpl.java index c90fde5..662317d 100644 --- a/src/main/java/org/gcube/portlets/user/td/expressionwidget/server/ExpressionServiceImpl.java +++ b/src/main/java/org/gcube/portlets/user/td/expressionwidget/server/ExpressionServiceImpl.java @@ -2,6 +2,7 @@ package org.gcube.portlets.user.td.expressionwidget.server; import java.util.ArrayList; import java.util.List; +import java.util.ResourceBundle; import javax.servlet.http.HttpSession; @@ -26,6 +27,7 @@ import org.gcube.portlets.user.td.expressionwidget.shared.exception.ExpressionPa import org.gcube.portlets.user.td.expressionwidget.shared.exception.ExpressionServiceException; 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.shared.exception.TDGWTServiceException; import org.gcube.portlets.user.td.gwtservice.shared.rule.AppliedRulesResponseData; @@ -71,10 +73,10 @@ public class ExpressionServiceImpl extends TDGWTServiceImpl implements @Override public String startFilterColumn(FilterColumnSession filterColumnSession) throws TDGWTServiceException { - + HttpSession session=null; try { logger.debug("ExpressionService submitColumnFilter"); - HttpSession session = this.getThreadLocalRequest().getSession(); + session = this.getThreadLocalRequest().getSession(); logger.debug("Session: " + session); if (filterColumnSession == null) { @@ -103,6 +105,12 @@ public class ExpressionServiceImpl extends TDGWTServiceImpl implements } catch (TDGWTServiceException e) { throw e; + } catch (SecurityException e) { + logger.error(e.getLocalizedMessage()); + e.printStackTrace(); + ResourceBundle messages = getResourceBundle(session); + throw new TDGWTServiceException( + messages.getString(TDGWTServiceMessagesConstants.securityExceptionRights)); } catch (Throwable e) { e.printStackTrace(); throw new TDGWTServiceException(e.getLocalizedMessage()); @@ -116,10 +124,10 @@ public class ExpressionServiceImpl extends TDGWTServiceImpl implements public String startAddColumn(AddColumnSession addColumnSession) throws TDGWTServiceException { - + HttpSession session=null; try { logger.debug("AddColumn"); - HttpSession session = this.getThreadLocalRequest().getSession(); + session = this.getThreadLocalRequest().getSession(); logger.debug("Session: " + session); if (addColumnSession == null) { @@ -153,6 +161,13 @@ public class ExpressionServiceImpl extends TDGWTServiceImpl implements } catch (TDGWTServiceException e) { throw e; + } catch (SecurityException e) { + logger.error(e.getLocalizedMessage()); + e.printStackTrace(); + ResourceBundle messages = getResourceBundle(session); + throw new TDGWTServiceException( + messages.getString(TDGWTServiceMessagesConstants.securityExceptionRights)); + } catch (Throwable e) { e.printStackTrace(); throw new TDGWTServiceException(e.getLocalizedMessage()); @@ -168,9 +183,10 @@ public class ExpressionServiceImpl extends TDGWTServiceImpl implements ReplaceColumnByExpressionSession replaceColumnByExpressionSession) throws TDGWTServiceException { + HttpSession session=null; try { logger.debug("ExpressionService submitReplaceColumnByExpression"); - HttpSession session = this.getThreadLocalRequest().getSession(); + session = this.getThreadLocalRequest().getSession(); logger.debug("Session: " + session); if (replaceColumnByExpressionSession == null) { @@ -215,6 +231,12 @@ public class ExpressionServiceImpl extends TDGWTServiceImpl implements } catch (TDGWTServiceException e) { throw e; + } catch (SecurityException e) { + logger.error(e.getLocalizedMessage()); + e.printStackTrace(); + ResourceBundle messages = getResourceBundle(session); + throw new TDGWTServiceException( + messages.getString(TDGWTServiceMessagesConstants.securityExceptionRights)); } catch (Throwable e) { e.printStackTrace(); throw new TDGWTServiceException(e.getLocalizedMessage()); @@ -228,8 +250,9 @@ public class ExpressionServiceImpl extends TDGWTServiceImpl implements @Override public ArrayList getRules() throws TDGWTServiceException { + HttpSession session=null; try { - HttpSession session = this.getThreadLocalRequest().getSession(); + session = this.getThreadLocalRequest().getSession(); ASLSession aslSession = SessionUtil.getAslSession(session); logger.debug("GetRules()"); @@ -259,7 +282,10 @@ public class ExpressionServiceImpl extends TDGWTServiceImpl implements } catch (SecurityException e) { logger.error(e.getLocalizedMessage()); e.printStackTrace(); - throw e; + ResourceBundle messages = getResourceBundle(session); + throw new TDGWTServiceException( + messages.getString(TDGWTServiceMessagesConstants.securityExceptionRights)); + } catch (Throwable e) { logger.error("Error in getRules(): " + e.getLocalizedMessage()); e.printStackTrace(); @@ -276,8 +302,9 @@ public class ExpressionServiceImpl extends TDGWTServiceImpl implements @Override public ArrayList getRules(RuleScopeType scope) throws TDGWTServiceException { + HttpSession session=null; try { - HttpSession session = this.getThreadLocalRequest().getSession(); + session = this.getThreadLocalRequest().getSession(); ASLSession aslSession = SessionUtil.getAslSession(session); logger.debug("GetRules(): " + scope); @@ -308,7 +335,9 @@ public class ExpressionServiceImpl extends TDGWTServiceImpl implements } catch (SecurityException e) { logger.error(e.getLocalizedMessage()); e.printStackTrace(); - throw e; + ResourceBundle messages = getResourceBundle(session); + throw new TDGWTServiceException( + messages.getString(TDGWTServiceMessagesConstants.securityExceptionRights)); } catch (Throwable e) { logger.error("Error in getRules(): " + e.getLocalizedMessage()); e.printStackTrace(); @@ -325,8 +354,9 @@ public class ExpressionServiceImpl extends TDGWTServiceImpl implements @Override public ArrayList getApplicableBaseColumnRules( ColumnData columnData) throws TDGWTServiceException { + HttpSession session=null; try { - HttpSession session = this.getThreadLocalRequest().getSession(); + session = this.getThreadLocalRequest().getSession(); ASLSession aslSession = SessionUtil.getAslSession(session); logger.debug("GetApplicableBaseColumnRules(): " + columnData); @@ -373,7 +403,10 @@ public class ExpressionServiceImpl extends TDGWTServiceImpl implements } catch (SecurityException e) { logger.error(e.getLocalizedMessage()); e.printStackTrace(); - throw e; + ResourceBundle messages = getResourceBundle(session); + throw new TDGWTServiceException( + messages.getString(TDGWTServiceMessagesConstants.securityExceptionRights)); + } catch (Throwable e) { logger.error("Error in getApplicableBaseColumnRules(): " + e.getLocalizedMessage()); @@ -391,8 +424,9 @@ public class ExpressionServiceImpl extends TDGWTServiceImpl implements @Override public AppliedRulesResponseData getActiveRulesByTabularResourceId(TRId trId) throws TDGWTServiceException { + HttpSession session=null; try { - HttpSession session = this.getThreadLocalRequest().getSession(); + session = this.getThreadLocalRequest().getSession(); ASLSession aslSession = SessionUtil.getAslSession(session); logger.debug("GetAppliedRulesByTabularResourceId(): " + trId); @@ -429,7 +463,10 @@ public class ExpressionServiceImpl extends TDGWTServiceImpl implements } catch (SecurityException e) { logger.error(e.getLocalizedMessage()); e.printStackTrace(); - throw e; + ResourceBundle messages = getResourceBundle(session); + throw new TDGWTServiceException( + messages.getString(TDGWTServiceMessagesConstants.securityExceptionRights)); + } catch (Throwable e) { logger.error("Error in getActiveRulesByTabularResourceId(): " + e.getLocalizedMessage()); @@ -448,8 +485,9 @@ public class ExpressionServiceImpl extends TDGWTServiceImpl implements public String saveRule( RuleDescriptionData ruleDescriptionData) throws TDGWTServiceException { + HttpSession session=null; try { - HttpSession session = this.getThreadLocalRequest().getSession(); + session = this.getThreadLocalRequest().getSession(); ASLSession aslSession = SessionUtil.getAslSession(session); logger.debug("SaveRule() :" + ruleDescriptionData); @@ -502,7 +540,10 @@ public class ExpressionServiceImpl extends TDGWTServiceImpl implements } catch (SecurityException e) { logger.error(e.getLocalizedMessage()); e.printStackTrace(); - throw e; + ResourceBundle messages = getResourceBundle(session); + throw new TDGWTServiceException( + messages.getString(TDGWTServiceMessagesConstants.securityExceptionRights)); + } catch (Throwable e) { logger.error("Error in save rule: " + e.getLocalizedMessage()); @@ -521,8 +562,9 @@ public class ExpressionServiceImpl extends TDGWTServiceImpl implements @Override public void updateColumnRule(RuleDescriptionData ruleDescriptionData) throws TDGWTServiceException { + HttpSession session=null; try { - HttpSession session = this.getThreadLocalRequest().getSession(); + session = this.getThreadLocalRequest().getSession(); ASLSession aslSession = SessionUtil.getAslSession(session); logger.debug("UpdateColumnRule() :" + ruleDescriptionData); @@ -551,7 +593,10 @@ public class ExpressionServiceImpl extends TDGWTServiceImpl implements } catch (SecurityException e) { logger.error(e.getLocalizedMessage()); e.printStackTrace(); - throw e; + ResourceBundle messages = getResourceBundle(session); + throw new TDGWTServiceException( + messages.getString(TDGWTServiceMessagesConstants.securityExceptionRights)); + } catch (Throwable e) { logger.error("Error in getRule(): " + e.getLocalizedMessage()); e.printStackTrace(); @@ -568,8 +613,9 @@ public class ExpressionServiceImpl extends TDGWTServiceImpl implements @Override public void removeRulesById(ArrayList rules) throws TDGWTServiceException { + HttpSession session=null; try { - HttpSession session = this.getThreadLocalRequest().getSession(); + session = this.getThreadLocalRequest().getSession(); ASLSession aslSession = SessionUtil.getAslSession(session); logger.debug("RemoveRuleById() :" + rules); @@ -594,7 +640,10 @@ public class ExpressionServiceImpl extends TDGWTServiceImpl implements } catch (SecurityException e) { logger.error(e.getLocalizedMessage()); e.printStackTrace(); - throw e; + ResourceBundle messages = getResourceBundle(session); + throw new TDGWTServiceException( + messages.getString(TDGWTServiceMessagesConstants.securityExceptionRights)); + } catch (Throwable e) { logger.error("Error in removeRuleById(): " + e.getLocalizedMessage());