From 7ad857c0d315ffd3605447655a89468e73b6792d Mon Sep 17 00:00:00 2001 From: Giancarlo Panichi Date: Tue, 3 Jun 2014 12:38:17 +0000 Subject: [PATCH] Minor Update git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-gwt-service@96383 82a268e6-3cf1-43bd-a215-b396298e98cf --- .../td/gwtservice/server/SessionUtil.java | 7 +++--- .../server/trservice/TDTypeValueMap.java | 25 ++++++++++++++----- 2 files changed, 23 insertions(+), 9 deletions(-) diff --git a/src/main/java/org/gcube/portlets/user/td/gwtservice/server/SessionUtil.java b/src/main/java/org/gcube/portlets/user/td/gwtservice/server/SessionUtil.java index cceab0b..586c8c5 100644 --- a/src/main/java/org/gcube/portlets/user/td/gwtservice/server/SessionUtil.java +++ b/src/main/java/org/gcube/portlets/user/td/gwtservice/server/SessionUtil.java @@ -16,6 +16,7 @@ import org.gcube.data.analysis.tabulardata.service.tabular.TabularResource; import org.gcube.portal.custom.scopemanager.scopehelper.ScopeHelper; import org.gcube.portlets.user.td.gwtservice.server.file.FileUploadSession; import org.gcube.portlets.user.td.gwtservice.server.trservice.TRTasksManager; +import org.gcube.portlets.user.td.gwtservice.shared.Constants; import org.gcube.portlets.user.td.gwtservice.shared.csv.CSVExportSession; import org.gcube.portlets.user.td.gwtservice.shared.csv.CSVImportSession; import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTSessionExpiredException; @@ -82,15 +83,15 @@ public class SessionUtil { ASLSession session; if (username == null) { logger.warn("no user found in session, using test one"); - throw new TDGWTSessionExpiredException("Session Expired!"); - /* + /*throw new TDGWTSessionExpiredException("Session Expired!");*/ + username = Constants.DEFAULT_USER; String scope = Constants.DEFAULT_SCOPE; httpSession.setAttribute(ScopeHelper.USERNAME_ATTRIBUTE, username); session = SessionManager.getInstance().getASLSession( httpSession.getId(), username); - session.setScope(scope);*/ + session.setScope(scope); } else { session = SessionManager.getInstance().getASLSession( diff --git a/src/main/java/org/gcube/portlets/user/td/gwtservice/server/trservice/TDTypeValueMap.java b/src/main/java/org/gcube/portlets/user/td/gwtservice/server/trservice/TDTypeValueMap.java index 2658356..3cb4765 100644 --- a/src/main/java/org/gcube/portlets/user/td/gwtservice/server/trservice/TDTypeValueMap.java +++ b/src/main/java/org/gcube/portlets/user/td/gwtservice/server/trservice/TDTypeValueMap.java @@ -1,5 +1,6 @@ package org.gcube.portlets.user.td.gwtservice.server.trservice; +import java.text.SimpleDateFormat; import java.util.Date; import org.gcube.data.analysis.tabulardata.model.datatype.value.TDBoolean; @@ -23,6 +24,8 @@ public class TDTypeValueMap { protected static Logger logger = LoggerFactory .getLogger(TDTypeValueMap.class); + private static SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); + public static TDTypeValue map(String dataTypeName, String value) throws TDGWTServiceException { TDTypeValue tdTypeValue = null; @@ -33,9 +36,14 @@ public class TDTypeValueMap { tdTypeValue = new TDBoolean(b); break; case "Date": - Long d = new Long(value); - Date date = new Date(d); - tdTypeValue = new TDDate(date); + Date d; + try{ + d=sdf.parse(value); + }catch(Exception e){ + throw new TDGWTServiceException("Error in TDTypeValueMap: " + + e.getLocalizedMessage()); + } + tdTypeValue=new TDDate(d); break; case "Geometry": tdTypeValue = new TDText(value); @@ -75,9 +83,14 @@ public class TDTypeValueMap { tdTypeValue = new TDBoolean(b); break; case Date: - Long d = new Long(value); - Date date = new Date(d); - tdTypeValue = new TDDate(date); + Date d; + try{ + d=sdf.parse(value); + }catch(Exception e){ + throw new TDGWTServiceException("Error in TDTypeValueMap: " + + e.getLocalizedMessage()); + } + tdTypeValue=new TDDate(d); break; case Geometry: tdTypeValue = new TDText(value);