From 17f7b3a7748650c40da387236d63c5b3bc207b5a Mon Sep 17 00:00:00 2001 From: Giancarlo Panichi Date: Fri, 23 May 2014 09:49:33 +0000 Subject: [PATCH] Minor Update git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-gwt-service@96012 82a268e6-3cf1-43bd-a215-b396298e98cf --- .../gwtservice/server/TDGWTServiceImpl.java | 59 +++++++++++++++++-- .../td/gwtservice/shared/tr/TabResource.java | 25 ++++++-- 2 files changed, 74 insertions(+), 10 deletions(-) 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 33d2225..4eef743 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 @@ -307,7 +307,7 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements try { HttpSession session = this.getThreadLocalRequest().getSession(); - // ASLSession aslSession = SessionUtil.getAslSession(session); + ASLSession aslSession = SessionUtil.getAslSession(session); TabResource currentTR = SessionUtil.getTabResource(session); if (currentTR == null) { @@ -326,8 +326,20 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements ArrayList trMetadatas = getTRMetadata(currentTR .getTrId()); updateTabResourceInformation(currentTR, trMetadatas); - currentTR.setDate(getTRCreationDate(currentTR.getTrId())); - currentTR.setValid(isTabularResourceValid(currentTR.getTrId())); + + + AuthorizationProvider.instance.set(new AuthorizationToken( + aslSession.getUsername())); + TabularDataService service = TabularDataServiceFactory.getService(); + + TabularResource tr = service + .getTabularResource(new TabularResourceId(Long.valueOf(currentTR + .getId()))); + + currentTR.setDate(sdf.format(tr.getCreationDate().getTime())); + currentTR.setValid(tr.isValid()); + currentTR.setFinalized(tr.isFinalized()); + SessionUtil.setTabResource(session, currentTR); logger.debug("GetTabResourceInformation() updated information:" + currentTR.toString()); @@ -2960,6 +2972,44 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements + e.getLocalizedMessage()); } } + + + + /** + * Check finalized status of a tabular resource + * + * @param trId + * @return + * @throws TDGWTServiceException + */ + public Boolean isTabularResourceFinalized(TRId trId) + throws TDGWTServiceException { + try { + HttpSession session = this.getThreadLocalRequest().getSession(); + ASLSession aslSession = SessionUtil.getAslSession(session); + + logger.debug("IsTabularResourceFinalized: " + trId.toString()); + + AuthorizationProvider.instance.set(new AuthorizationToken( + aslSession.getUsername())); + TabularDataService service = TabularDataServiceFactory.getService(); + + TabularResource tr = service + .getTabularResource(new TabularResourceId(Long.valueOf(trId + .getId()))); + logger.debug("IsTabularResourceFinalized: " + tr.isFinalized()); + return tr.isFinalized(); + } catch (TDGWTSessionExpiredException e) { + throw e; + } catch (Throwable e) { + logger.error("Error checking if it is a finalized tabular resource: " + + e.getLocalizedMessage(), e); + throw new TDGWTServiceException( + "Error checking if it is a finalized tabular resource: " + + e.getLocalizedMessage()); + } + } + /** * @@ -5364,7 +5414,8 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements new Long(tabResource.getTrId().getId())); TabularResource tr = service.getTabularResource(tabularResourceId); - + tr.finalize(tabResource.isFinalized()); + if (tabResource.getName() != null) { NameMetadata name = new NameMetadata(tabResource.getName()); tr.setMetadata(name); diff --git a/src/main/java/org/gcube/portlets/user/td/gwtservice/shared/tr/TabResource.java b/src/main/java/org/gcube/portlets/user/td/gwtservice/shared/tr/TabResource.java index ced3f06..7899183 100644 --- a/src/main/java/org/gcube/portlets/user/td/gwtservice/shared/tr/TabResource.java +++ b/src/main/java/org/gcube/portlets/user/td/gwtservice/shared/tr/TabResource.java @@ -17,14 +17,16 @@ public class TabResource implements Serializable { private static final long serialVersionUID = -8353499109124097114L; - protected String id; + protected TRId trId; + protected String id;//For grid only protected String name; protected String description; protected String agency; protected String date; protected String right; protected boolean valid; - protected TRId trId; + protected boolean finalized; + public TabResource(){} @@ -110,14 +112,25 @@ public class TabResource implements Serializable { this.valid = valid; } + public boolean isFinalized() { + return finalized; + } + + public void setFinalized(boolean finalized) { + this.finalized = finalized; + } + @Override public String toString() { - return "TabResource [id=" + id + ", name=" + name + ", description=" - + description + ", agency=" + agency + ", date=" + date - + ", right=" + right + ", valid=" + valid + ", trId=" + trId - + "]"; + return "TabResource [trId=" + trId + ", id=" + id + ", name=" + name + + ", description=" + description + ", agency=" + agency + + ", date=" + date + ", right=" + right + ", valid=" + valid + + ", finalized=" + finalized + "]"; } + + + }