From b1f8bc624c726fc43d4d91396341cc32c18b7224 Mon Sep 17 00:00:00 2001 From: Giancarlo Panichi Date: Thu, 2 Oct 2014 17:07:33 +0000 Subject: [PATCH] Added Resume UI state git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-gwt-service@100397 82a268e6-3cf1-43bd-a215-b396298e98cf --- .../gwtservice/client/rpc/TDGWTService.java | 8 ++++ .../client/rpc/TDGWTServiceAsync.java | 4 +- .../gwtservice/server/TDGWTServiceImpl.java | 46 +++++++++++++++---- 3 files changed, 47 insertions(+), 11 deletions(-) diff --git a/src/main/java/org/gcube/portlets/user/td/gwtservice/client/rpc/TDGWTService.java b/src/main/java/org/gcube/portlets/user/td/gwtservice/client/rpc/TDGWTService.java index 2661f51..2bb7de3 100644 --- a/src/main/java/org/gcube/portlets/user/td/gwtservice/client/rpc/TDGWTService.java +++ b/src/main/java/org/gcube/portlets/user/td/gwtservice/client/rpc/TDGWTService.java @@ -213,6 +213,14 @@ public interface TDGWTService extends RemoteService { public ColumnData getConnection(RefColumn refColumn) throws TDGWTServiceException; + /** + * Close current tabular resource + * + * @param trId + * @throws TDGWTServiceException + */ + public void closeTabularResource() throws TDGWTServiceException; + // Task /** * Resubmit task diff --git a/src/main/java/org/gcube/portlets/user/td/gwtservice/client/rpc/TDGWTServiceAsync.java b/src/main/java/org/gcube/portlets/user/td/gwtservice/client/rpc/TDGWTServiceAsync.java index e393687..fd523d2 100644 --- a/src/main/java/org/gcube/portlets/user/td/gwtservice/client/rpc/TDGWTServiceAsync.java +++ b/src/main/java/org/gcube/portlets/user/td/gwtservice/client/rpc/TDGWTServiceAsync.java @@ -128,7 +128,9 @@ public interface TDGWTServiceAsync { AsyncCallback callback); void getConnection(RefColumn refColumn, AsyncCallback callback); - + + void closeTabularResource(AsyncCallback callback); + // Task void startTaskResubmit(TaskResubmitSession taskResubmitSession, AsyncCallback callback); diff --git a/src/main/java/org/gcube/portlets/user/td/gwtservice/server/TDGWTServiceImpl.java b/src/main/java/org/gcube/portlets/user/td/gwtservice/server/TDGWTServiceImpl.java index adafde0..245ea1c 100644 --- a/src/main/java/org/gcube/portlets/user/td/gwtservice/server/TDGWTServiceImpl.java +++ b/src/main/java/org/gcube/portlets/user/td/gwtservice/server/TDGWTServiceImpl.java @@ -321,22 +321,16 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements HttpSession session = this.getThreadLocalRequest().getSession(); SessionUtil.getAslSession(session); - TabResource currentTR = SessionUtil.getTabResource(session); + TRId trId = SessionUtil.getTRId(session); logger.debug("getCurrentTRId()"); - if (currentTR == null) { + if (trId == null) { logger.error("Current Tabular Resource is null"); throw new TDGWTServiceException( "Current Tabular Resource is null"); } - logger.debug("getCurrentTRId():" + currentTR.toString()); + logger.debug("getCurrentTRId():" + trId); - if (currentTR.getTrId() == null) { - logger.error("Current Tabular Resource has TRId null"); - throw new TDGWTServiceException( - "Current Tabular Resource has TRId null"); - } - logger.debug("getCurrentTRId():" + currentTR.getTrId()); - return currentTR.getTrId(); + return trId; } catch (TDGWTServiceException e) { throw e; @@ -351,11 +345,41 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements } } + + /** + * + * {@inheritDoc} + */ + @Override + public void closeTabularResource() throws TDGWTServiceException { + try { + HttpSession session = this.getThreadLocalRequest().getSession(); + SessionUtil.getAslSession(session); + + SessionUtil.setTabResource(session,null); + SessionUtil.setTRId(session, null); + return; + + } catch (TDGWTServiceException e) { + throw e; + } catch (SecurityException e) { + e.printStackTrace(); + throw new TDGWTServiceException( + "Security exception, you haven't rights!"); + } catch (Throwable e) { + logger.error("getCurrentTRID(): " + e.getLocalizedMessage(), e); + throw new TDGWTServiceException("Error retrieving TR id: " + + e.getLocalizedMessage()); + } + + } + /** * * {@inheritDoc} */ + @Override public TabResource getTabResourceInformation() throws TDGWTServiceException { try { HttpSession session = this.getThreadLocalRequest().getSession(); @@ -6675,4 +6699,6 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements } + + }