diff --git a/src/main/java/org/gcube/portlets/user/td/expressionwidget/client/ColumnExpressionDialog.java b/src/main/java/org/gcube/portlets/user/td/expressionwidget/client/ColumnExpressionDialog.java index f8a725e..f6b2477 100644 --- a/src/main/java/org/gcube/portlets/user/td/expressionwidget/client/ColumnExpressionDialog.java +++ b/src/main/java/org/gcube/portlets/user/td/expressionwidget/client/ColumnExpressionDialog.java @@ -1,10 +1,16 @@ package org.gcube.portlets.user.td.expressionwidget.client; + import org.gcube.portlets.user.td.expressionwidget.client.resources.ExpressionResources; +import org.gcube.portlets.user.td.expressionwidget.client.utils.UtilsGXT3; import org.gcube.portlets.user.td.gwtservice.client.rpc.TDGWTServiceAsync; +import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTIsLockedException; +import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTSessionExpiredException; import org.gcube.portlets.user.td.gwtservice.shared.tr.ColumnData; import org.gcube.portlets.user.td.widgetcommonevent.client.event.ExpressionEvent; +import org.gcube.portlets.user.td.widgetcommonevent.client.event.SessionExpiredEvent; import org.gcube.portlets.user.td.widgetcommonevent.client.type.ExpressionType; +import org.gcube.portlets.user.td.widgetcommonevent.client.type.SessionExpiredType; import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId; import org.gcube.portlets.user.td.widgetcommonevent.shared.expression.C_Expression; import org.gcube.portlets.user.td.widgetcommonevent.shared.tr.column.ColumnDataType; @@ -17,8 +23,8 @@ import com.google.web.bindery.event.shared.EventBus; import com.sencha.gxt.widget.core.client.Window; import com.sencha.gxt.widget.core.client.box.AlertMessageBox; import com.sencha.gxt.widget.core.client.event.HideEvent; -import com.sencha.gxt.widget.core.client.event.SelectEvent; import com.sencha.gxt.widget.core.client.event.HideEvent.HideHandler; +import com.sencha.gxt.widget.core.client.event.SelectEvent; import com.sencha.gxt.widget.core.client.event.SelectEvent.SelectHandler; /** @@ -145,8 +151,21 @@ public class ColumnExpressionDialog extends Window { new AsyncCallback() { public void onFailure(Throwable caught) { - Log.error("Error retrieving column: " - + caught.getMessage()); + if (caught instanceof TDGWTSessionExpiredException) { + eventBus.fireEvent(new SessionExpiredEvent( + SessionExpiredType.EXPIREDONSERVER)); + } else { + if (caught instanceof TDGWTIsLockedException) { + Log.error(caught.getLocalizedMessage()); + UtilsGXT3.alert("Error Locked", + caught.getLocalizedMessage()); + } else { + Log.error("Error retrieving column: " + + caught.getMessage()); + UtilsGXT3.alert("Error","Error retrieving column: " + + caught.getMessage()); + } + } } diff --git a/src/main/java/org/gcube/portlets/user/td/expressionwidget/client/ColumnFilterDialog.java b/src/main/java/org/gcube/portlets/user/td/expressionwidget/client/ColumnFilterDialog.java index e52630d..fd4ba48 100644 --- a/src/main/java/org/gcube/portlets/user/td/expressionwidget/client/ColumnFilterDialog.java +++ b/src/main/java/org/gcube/portlets/user/td/expressionwidget/client/ColumnFilterDialog.java @@ -4,6 +4,8 @@ import org.gcube.portlets.user.td.expressionwidget.client.resources.ExpressionRe import org.gcube.portlets.user.td.expressionwidget.client.rpc.ExpressionServiceAsync; import org.gcube.portlets.user.td.expressionwidget.client.utils.UtilsGXT3; import org.gcube.portlets.user.td.gwtservice.client.rpc.TDGWTServiceAsync; +import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTIsFinalException; +import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTIsLockedException; import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTSessionExpiredException; import org.gcube.portlets.user.td.gwtservice.shared.tr.ColumnData; import org.gcube.portlets.user.td.gwtservice.shared.tr.column.FilterColumnSession; @@ -137,10 +139,22 @@ public class ColumnFilterDialog extends Window implements MonitorDialogListener new AsyncCallback() { public void onFailure(Throwable caught) { - Log.error("Error retrieving column: " - + caught.getMessage()); - UtilsGXT3.alert("Error retrieving column", - caught.getMessage()); + if (caught instanceof TDGWTSessionExpiredException) { + eventBus.fireEvent(new SessionExpiredEvent( + SessionExpiredType.EXPIREDONSERVER)); + } else { + if (caught instanceof TDGWTIsLockedException) { + Log.error(caught.getLocalizedMessage()); + UtilsGXT3.alert("Error Locked", + caught.getLocalizedMessage()); + + } else { + Log.error("Error retrieving column: " + + caught.getMessage()); + UtilsGXT3.alert("Error retrieving column", + caught.getMessage()); + } + } } public void onSuccess(ColumnData result) { @@ -180,12 +194,24 @@ public class ColumnFilterDialog extends Window implements MonitorDialogListener eventBus.fireEvent(new SessionExpiredEvent( SessionExpiredType.EXPIREDONSERVER)); } else { - Log.error("Error submitting the column filter: " - + caught.getLocalizedMessage()); - caught.printStackTrace(); - UtilsGXT3.alert( - "Error submitting the column filter", - caught.getLocalizedMessage()); + if (caught instanceof TDGWTIsLockedException) { + Log.error(caught.getLocalizedMessage()); + UtilsGXT3.alert("Error Locked", + caught.getLocalizedMessage()); + } else { + if (caught instanceof TDGWTIsFinalException) { + Log.error(caught.getLocalizedMessage()); + UtilsGXT3.alert("Error Final", + caught.getLocalizedMessage()); + } else { + Log.error("Error submitting the column filter: " + + caught.getLocalizedMessage()); + caught.printStackTrace(); + UtilsGXT3 + .alert("Error submitting the column filter", + caught.getLocalizedMessage()); + } + } } } diff --git a/src/main/java/org/gcube/portlets/user/td/expressionwidget/client/MultiColumnFilterPanel.java b/src/main/java/org/gcube/portlets/user/td/expressionwidget/client/MultiColumnFilterPanel.java index 13f901f..0aeb2e6 100644 --- a/src/main/java/org/gcube/portlets/user/td/expressionwidget/client/MultiColumnFilterPanel.java +++ b/src/main/java/org/gcube/portlets/user/td/expressionwidget/client/MultiColumnFilterPanel.java @@ -4,7 +4,11 @@ import java.util.ArrayList; import org.gcube.portlets.user.td.expressionwidget.client.utils.UtilsGXT3; import org.gcube.portlets.user.td.gwtservice.client.rpc.TDGWTServiceAsync; +import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTIsLockedException; +import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTSessionExpiredException; import org.gcube.portlets.user.td.gwtservice.shared.tr.ColumnData; +import org.gcube.portlets.user.td.widgetcommonevent.client.event.SessionExpiredEvent; +import org.gcube.portlets.user.td.widgetcommonevent.client.type.SessionExpiredType; import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId; import com.allen_sauer.gwt.log.client.Log; @@ -12,18 +16,15 @@ import com.google.gwt.user.client.rpc.AsyncCallback; import com.google.gwt.user.client.ui.HTML; import com.google.gwt.user.client.ui.SimplePanel; import com.google.web.bindery.event.shared.EventBus; -import com.sencha.gxt.widget.core.client.box.AlertMessageBox; import com.sencha.gxt.widget.core.client.container.VerticalLayoutContainer; import com.sencha.gxt.widget.core.client.event.BeforeShowEvent; import com.sencha.gxt.widget.core.client.event.BeforeShowEvent.BeforeShowHandler; -import com.sencha.gxt.widget.core.client.event.HideEvent; -import com.sencha.gxt.widget.core.client.event.HideEvent.HideHandler; /** * - * @author "Giancarlo Panichi" - * g.panichi@isti.cnr.it - * + * @author "Giancarlo Panichi" g.panichi@isti.cnr.it + * */ public class MultiColumnFilterPanel extends SimplePanel { protected String WIDTH = "648px"; @@ -31,69 +32,70 @@ public class MultiColumnFilterPanel extends SimplePanel { protected TRId trId; protected ArrayList columns; - + protected EventBus eventBus; protected MultiColumnFilterDialog multiColumnFilterDialog; - + public MultiColumnFilterPanel( - MultiColumnFilterDialog multiColumnFilterDialog, - TRId trId, EventBus eventBus) { + MultiColumnFilterDialog multiColumnFilterDialog, TRId trId, + EventBus eventBus) { super(); Log.debug("Create MultiColumnFilterPanel"); setHeight(HEIGHT); setWidth(WIDTH); - this.multiColumnFilterDialog=multiColumnFilterDialog; - this.trId=trId; + this.multiColumnFilterDialog = multiColumnFilterDialog; + this.trId = trId; this.eventBus = eventBus; - UtilsGXT3.mask(this.getElement()); + UtilsGXT3.mask(this.getElement()); load(trId); } - - - protected void create(){ + + protected void create() { UtilsGXT3.umask(this.getElement()); - - VerticalLayoutContainer vl=new VerticalLayoutContainer(); + + VerticalLayoutContainer vl = new VerticalLayoutContainer(); vl.setBorders(false); - - final MultiColumnFilterTabPanel mcfTabPanel=new MultiColumnFilterTabPanel(this,eventBus); + + final MultiColumnFilterTabPanel mcfTabPanel = new MultiColumnFilterTabPanel( + this, eventBus); vl.add(mcfTabPanel); - + mcfTabPanel.addBeforeShowHandler(new BeforeShowHandler() { - + public void onBeforeShow(BeforeShowEvent event) { mcfTabPanel.forceLayout(); - + } }); - - final SimplePanel bo=new SimplePanel(); + + final SimplePanel bo = new SimplePanel(); bo.add(new HTML("Expression")); vl.add(bo); - + add(vl); } - - - - + protected void load(TRId trId) { TDGWTServiceAsync.INSTANCE.getColumns(trId, new AsyncCallback>() { @Override public void onFailure(Throwable caught) { - Log.error("Error retrieving columns: " - + caught.getMessage()); - AlertMessageBox d = new AlertMessageBox( - "Error retrieving columns", caught.getMessage()); - d.addHideHandler(new HideHandler() { - public void onHide(HideEvent event) { - multiColumnFilterDialog.hide(); + if (caught instanceof TDGWTSessionExpiredException) { + eventBus.fireEvent(new SessionExpiredEvent( + SessionExpiredType.EXPIREDONSERVER)); + } else { + if (caught instanceof TDGWTIsLockedException) { + Log.error(caught.getLocalizedMessage()); + UtilsGXT3.alert("Error Locked", + caught.getLocalizedMessage()); + } else { + Log.error("Error retrieving columns: " + + caught.getMessage()); + UtilsGXT3.alert("Error", + "Error retrieving columns: "+caught.getMessage()); } - }); - d.show(); - + } } @Override diff --git a/src/main/java/org/gcube/portlets/user/td/expressionwidget/client/ReplaceColumnByExpressionDialog.java b/src/main/java/org/gcube/portlets/user/td/expressionwidget/client/ReplaceColumnByExpressionDialog.java index 0732ef8..f8337bf 100644 --- a/src/main/java/org/gcube/portlets/user/td/expressionwidget/client/ReplaceColumnByExpressionDialog.java +++ b/src/main/java/org/gcube/portlets/user/td/expressionwidget/client/ReplaceColumnByExpressionDialog.java @@ -4,6 +4,8 @@ import org.gcube.portlets.user.td.expressionwidget.client.resources.ExpressionRe import org.gcube.portlets.user.td.expressionwidget.client.rpc.ExpressionServiceAsync; import org.gcube.portlets.user.td.expressionwidget.client.utils.UtilsGXT3; import org.gcube.portlets.user.td.gwtservice.client.rpc.TDGWTServiceAsync; +import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTIsFinalException; +import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTIsLockedException; import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTSessionExpiredException; import org.gcube.portlets.user.td.gwtservice.shared.tr.ColumnData; import org.gcube.portlets.user.td.gwtservice.shared.tr.column.ReplaceColumnByExpressionSession; @@ -102,12 +104,12 @@ public class ReplaceColumnByExpressionDialog extends Window implements protected void create() { if (column != null && column.getDataTypeName().compareTo( - ColumnDataType.Text.toString())==0) { + ColumnDataType.Text.toString()) == 0) { setHeight(HEIGHT); } else { setHeight(HEIGHT_REDUCE); } - + if (column.getTypeCode() .compareTo(ColumnTypeCode.ANNOTATION.toString()) == 0 || column.getTypeCode().compareTo( @@ -166,10 +168,21 @@ public class ReplaceColumnByExpressionDialog extends Window implements new AsyncCallback() { public void onFailure(Throwable caught) { - Log.error("Error retrieving column: " - + caught.getMessage()); - UtilsGXT3.alert("Error retrieving column", - caught.getMessage()); + if (caught instanceof TDGWTSessionExpiredException) { + eventBus.fireEvent(new SessionExpiredEvent( + SessionExpiredType.EXPIREDONSERVER)); + } else { + if (caught instanceof TDGWTIsLockedException) { + Log.error(caught.getLocalizedMessage()); + UtilsGXT3.alert("Error Locked", + caught.getLocalizedMessage()); + } else { + Log.error("Error retrieving column: " + + caught.getMessage()); + UtilsGXT3.alert("Error retrieving column", + caught.getMessage()); + } + } } public void onSuccess(ColumnData result) { @@ -210,12 +223,24 @@ public class ReplaceColumnByExpressionDialog extends Window implements eventBus.fireEvent(new SessionExpiredEvent( SessionExpiredType.EXPIREDONSERVER)); } else { - Log.error("Error submitting replace column by expression: " - + caught.getLocalizedMessage()); - caught.printStackTrace(); - UtilsGXT3 - .alert("Error submitting replace column by expression", + if (caught instanceof TDGWTIsLockedException) { + Log.error(caught.getLocalizedMessage()); + UtilsGXT3.alert("Error Locked", + caught.getLocalizedMessage()); + } else { + if (caught instanceof TDGWTIsFinalException) { + Log.error(caught.getLocalizedMessage()); + UtilsGXT3.alert("Error Final", caught.getLocalizedMessage()); + } else { + Log.error("Error submitting replace column by expression: " + + caught.getLocalizedMessage()); + caught.printStackTrace(); + UtilsGXT3 + .alert("Error submitting replace column by expression", + caught.getLocalizedMessage()); + } + } } } 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 f6434f6..836daef 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 @@ -19,7 +19,6 @@ import org.gcube.portlets.user.td.expressionwidget.shared.exception.ExpressionSe 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.shared.exception.TDGWTServiceException; -import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTSessionExpiredException; import org.gcube.portlets.user.td.gwtservice.shared.tr.column.FilterColumnSession; import org.gcube.portlets.user.td.gwtservice.shared.tr.column.ReplaceColumnByExpressionSession; import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId; @@ -71,7 +70,7 @@ public class ExpressionServiceImpl extends RemoteServiceServlet implements return taskId; - } catch (TDGWTSessionExpiredException e) { + } catch (TDGWTServiceException e) { throw e; } catch (Throwable e) { e.printStackTrace(); @@ -124,7 +123,7 @@ public class ExpressionServiceImpl extends RemoteServiceServlet implements replaceExpression, session); return taskId; - } catch (TDGWTSessionExpiredException e) { + } catch (TDGWTServiceException e) { throw e; } catch (Throwable e) { e.printStackTrace(); @@ -187,7 +186,7 @@ public class ExpressionServiceImpl extends RemoteServiceServlet implements logger.debug("Retrieved TRId basic info:" + newTRId.toString()); return newTRId; - } catch (TDGWTSessionExpiredException e) { + } catch (TDGWTServiceException e) { throw e; } catch (SecurityException e) { e.printStackTrace();