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 c43c381..eb330ef 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 @@ -18,6 +18,7 @@ import org.gcube.portlets.user.td.gwtservice.shared.sdmx.SDMXExportMonitor; import org.gcube.portlets.user.td.gwtservice.shared.sdmx.SDMXExportSession; import org.gcube.portlets.user.td.gwtservice.shared.sdmx.SDMXImportMonitor; import org.gcube.portlets.user.td.gwtservice.shared.sdmx.SDMXImportSession; +import org.gcube.portlets.user.td.gwtservice.shared.source.SDMXRegistrySource; import org.gcube.portlets.user.td.gwtservice.shared.tr.ColumnData; import org.gcube.portlets.user.td.gwtservice.shared.tr.TRId; import org.gcube.portlets.user.td.gwtservice.shared.tr.TabResource; @@ -67,7 +68,8 @@ public interface TDGWTService extends RemoteService { * @param tr * @throws TDGWTServiceException */ - public void setTabResource(TabResource tabResource) throws TDGWTServiceException; + public void setTabResource(TabResource tabResource) + throws TDGWTServiceException; /** * Creates a TabResource on Service @@ -79,7 +81,6 @@ public interface TDGWTService extends RemoteService { public TabResource createTabularResource(TabResource tabResource) throws TDGWTServiceException; - /** * Return Last Table * @@ -88,29 +89,27 @@ public interface TDGWTService extends RemoteService { * @throws TDGWTServiceException */ public TableData getLastTable(TRId trId) throws TDGWTServiceException; - - + /** - * Return Metadata of Table + * Return Metadata of Table * * @param trId * @return * @throws TDGWTServiceException */ - public ArrayList getTableMetadata(TRId trId) throws TDGWTServiceException; - - - /** + public ArrayList getTableMetadata(TRId trId) + throws TDGWTServiceException; + + /** * Return Metadata of Tabular Resources * * @param trId * @return * @throws TDGWTServiceException */ - public ArrayList getTRMetadata(TRId trId) throws TDGWTServiceException; - - - + public ArrayList getTRMetadata(TRId trId) + throws TDGWTServiceException; + // Open /** @@ -119,7 +118,8 @@ public interface TDGWTService extends RemoteService { * @return * @throws TDGWTServiceException */ - public ArrayList getTabularResources() throws TDGWTServiceException; + public ArrayList getTabularResources() + throws TDGWTServiceException; /** * Set open session for return all tabular resource of a user @@ -127,16 +127,17 @@ public interface TDGWTService extends RemoteService { * @param s * @throws TDGWTServiceException */ - public void startTDOpen(TDOpenSession tdOpenSession) throws TDGWTServiceException; + public void startTDOpen(TDOpenSession tdOpenSession) + throws TDGWTServiceException; /** * Retrieves the list of columns in the current table * - * @return + * @return * @throws TDGWTServiceException */ public ArrayList getColumns() throws TDGWTServiceException; - + /** * Remove Tabular Resource From Service * @@ -144,8 +145,8 @@ public interface TDGWTService extends RemoteService { * @throws TDGWTServiceException */ public void removeTabularResource(TRId trId) throws TDGWTServiceException; - - // Import SDMX + + // SDMX /** * Get Codelist on a registry @@ -172,16 +173,16 @@ public interface TDGWTService extends RemoteService { public ArrayList getAgencies() throws TDGWTServiceException; /** - * Set SDMXImportSession for SDMX Import + * Set SDMX Registry Source * * @param s * @throws TDGWTServiceException */ - public void setSDMXSession(SDMXImportSession sdmxImportSession) + public void setSDMXRegistrySource(SDMXRegistrySource sdmxRegistrySource) throws TDGWTServiceException; - + // Import SDMX /** * Start SDMX Import and invokes the client library * @@ -191,7 +192,6 @@ public interface TDGWTService extends RemoteService { public void startSDMXImport(SDMXImportSession sdmxImportSession) throws TDGWTServiceException; - /** * Get Operation Monitor during the SDMX Import operation * @@ -200,7 +200,7 @@ public interface TDGWTService extends RemoteService { */ public SDMXImportMonitor getSDMXImportMonitor() throws TDGWTServiceException; - + // Import CSV /** * Get File Upload Monitor during the file upload operation in Import CSV @@ -210,23 +210,23 @@ public interface TDGWTService extends RemoteService { */ public FileUploadMonitor getFileUploadMonitor() throws TDGWTServiceException; - - /** - * - * @param s - * @throws TDGWTServiceException - */ - public void setCSVSession(CSVImportSession csvImportSession) throws TDGWTServiceException; - /** * * @param s * @throws TDGWTServiceException */ - public void getFileFromWorkspace(CSVImportSession csvImportSession) throws TDGWTServiceException; + public void setCSVSession(CSVImportSession csvImportSession) + throws TDGWTServiceException; + + /** + * + * @param s + * @throws TDGWTServiceException + */ + public void getFileFromWorkspace(CSVImportSession csvImportSession) + throws TDGWTServiceException; - /** * * @return @@ -263,7 +263,8 @@ public interface TDGWTService extends RemoteService { * @param s * @throws TDGWTServiceException */ - public void startCSVImport(CSVImportSession csvImportSession) throws TDGWTServiceException; + public void startCSVImport(CSVImportSession csvImportSession) + throws TDGWTServiceException; /** * Get Operation Monitor during the CSV Import operation @@ -273,8 +274,7 @@ public interface TDGWTService extends RemoteService { */ public CSVImportMonitor getCSVImportMonitor() throws TDGWTServiceException; - - //Export CSV + // Export CSV /** * Get Operation Monitor during the CSV Export operation * @@ -282,36 +282,33 @@ public interface TDGWTService extends RemoteService { * @throws TDGWTServiceException */ public CSVExportMonitor getCSVExportMonitor() throws TDGWTServiceException; - - + /** * Start CSV Export and invokes the client library * * @param csvExportSession * @throws TDGWTServiceException */ - public void startCSVExport(CSVExportSession csvExportSession) throws TDGWTServiceException; - - - - //Export SDMX + public void startCSVExport(CSVExportSession csvExportSession) + throws TDGWTServiceException; + + // Export SDMX /** * Get Operation Monitor during the SDMX Export operation * * @return * @throws TDGWTServiceException */ - public SDMXExportMonitor getSDMXExportMonitor() throws TDGWTServiceException; - - - + public SDMXExportMonitor getSDMXExportMonitor() + throws TDGWTServiceException; + /** * Start SDMX Export and invokes the client library * * @param sdmxExportSession * @throws TDGWTServiceException */ - public void startSDMXExport(SDMXExportSession exportSession) throws TDGWTServiceException; - - + public void startSDMXExport(SDMXExportSession exportSession) + throws TDGWTServiceException; + } 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 6eaa665..ede238b 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 @@ -17,6 +17,7 @@ import org.gcube.portlets.user.td.gwtservice.shared.sdmx.SDMXExportMonitor; import org.gcube.portlets.user.td.gwtservice.shared.sdmx.SDMXExportSession; import org.gcube.portlets.user.td.gwtservice.shared.sdmx.SDMXImportMonitor; import org.gcube.portlets.user.td.gwtservice.shared.sdmx.SDMXImportSession; +import org.gcube.portlets.user.td.gwtservice.shared.source.SDMXRegistrySource; import org.gcube.portlets.user.td.gwtservice.shared.tr.ColumnData; import org.gcube.portlets.user.td.gwtservice.shared.tr.TRId; import org.gcube.portlets.user.td.gwtservice.shared.tr.TabResource; @@ -64,15 +65,16 @@ public interface TDGWTServiceAsync { //Open void startTDOpen(TDOpenSession tdOpenSession, AsyncCallback callback); - //Import SDMX + //SDMX void getCodelists(AsyncCallback> callback); void getDatasets(AsyncCallback> callback); void getAgencies(AsyncCallback> callback); - void setSDMXSession(SDMXImportSession sdmxImportSession, AsyncCallback callback); + void setSDMXRegistrySource(SDMXRegistrySource sdmxRegistrySource, AsyncCallback callback); + //Import SDMX void getSDMXImportMonitor(AsyncCallback callback); void startSDMXImport(SDMXImportSession sdmxImportSession,AsyncCallback callback); 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 eb92081..8bd32ed 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 @@ -31,8 +31,6 @@ import org.gcube.portlets.user.td.gwtservice.shared.tr.type.Dataset; import org.slf4j.Logger; import org.slf4j.LoggerFactory; - - /** * * @author "Giancarlo Panichi" retrieveCodelists(HttpSession httpSession) throws Exception { logger.info("SessionUtil retriveCodelists"); @@ -349,42 +337,62 @@ public class SessionUtil { return client.getAllAgencies(); } + + public static void setSDMXRegistrySource(HttpSession httpSession, + SDMXRegistrySource sdmxRegistrySource) { + + SDMXRegistrySource source = (SDMXRegistrySource) httpSession + .getAttribute(SDMX_REGISTRY_SOURCE); + if (source != null) + httpSession.removeAttribute(SDMX_REGISTRY_SOURCE); + httpSession.setAttribute(SDMX_REGISTRY_SOURCE, sdmxRegistrySource); + ASLSession aslSession = getAslSession(httpSession); + ScopeProvider.instance.set(aslSession.getScope().toString()); + } + + public static SDMXRegistrySource getSDMXRegistrySource(HttpSession httpSession) { + SDMXRegistrySource sdmxRegistrySource = (SDMXRegistrySource) httpSession + .getAttribute(SDMX_REGISTRY_SOURCE); + if (sdmxRegistrySource == null) { + logger.error("SDMXRegistrySource was not acquired"); + } + return sdmxRegistrySource; + } + + public static SDMXClient getSdmxClient(HttpSession httpSession) { SDMXClient sdmxClient = (SDMXClient) httpSession .getAttribute(SDMX_CLIENT_ATTRIBUTE); - SDMXImportSession sdmxImportSession = (SDMXImportSession) httpSession - .getAttribute(SDMX_IMPORT_SESSION); - if (sdmxImportSession == null) { - logger.error("SDMXImportSession was not acquired"); + SDMXRegistrySource sdmxRegistrySource = (SDMXRegistrySource) httpSession + .getAttribute(SDMX_REGISTRY_SOURCE); + if (sdmxRegistrySource == null) { + logger.error("SDMXRegistrySource was not acquired"); } else { - if (sdmxImportSession.getSource() instanceof SDMXRegistrySource) { - String url = ((SDMXRegistrySource) sdmxImportSession - .getSource()).getUrl(); - if (url == null || url.isEmpty()) { - if (sdmxClient == null) { - sdmxClient = new SDMXClient(); - } else { - if (sdmxClient.type.compareTo(SDMXClient.TYPE.ANOTHER) == 0) { - sdmxClient = new SDMXClient(); - } - } + String url = sdmxRegistrySource + .getUrl(); + if (url == null || url.isEmpty()) { + if (sdmxClient == null) { + sdmxClient = new SDMXClient(); } else { - if (sdmxClient == null) { + if (sdmxClient.type.compareTo(SDMXClient.TYPE.ANOTHER) == 0) { + sdmxClient = new SDMXClient(); + } + } + } else { + if (sdmxClient == null) { + sdmxClient = new SDMXClient(url); + } else { + if (sdmxClient.type.compareTo(SDMXClient.TYPE.INTERNAL) == 0) { sdmxClient = new SDMXClient(url); } else { - if (sdmxClient.type.compareTo(SDMXClient.TYPE.INTERNAL) == 0) { + if (sdmxClient.url.compareTo(url) != 0) { sdmxClient = new SDMXClient(url); - } else { - if (sdmxClient.url.compareTo(url) != 0) { - sdmxClient = new SDMXClient(url); - } } } } - httpSession.setAttribute(SDMX_CLIENT_ATTRIBUTE, sdmxClient); - } else { - logger.error("SDMXImportSession does not have a SDMXRegistrySource"); } + httpSession.setAttribute(SDMX_CLIENT_ATTRIBUTE, sdmxClient); + } return sdmxClient; @@ -404,8 +412,7 @@ public class SessionUtil { httpSession.removeAttribute(SDMX_IMPORT_TASK); httpSession.setAttribute(SDMX_IMPORT_TASK, task); } - - + public static Task getCSVImportFileTask(HttpSession httpSession) { Task monitor = (Task) httpSession.getAttribute(CSV_IMPORT_TASK); if (monitor == null) { @@ -420,7 +427,7 @@ public class SessionUtil { httpSession.removeAttribute(CSV_IMPORT_TASK); httpSession.setAttribute(CSV_IMPORT_TASK, task); } - + public static Task getCSVExportTask(HttpSession httpSession) { Task monitor = (Task) httpSession.getAttribute(CSV_EXPORT_TASK); if (monitor == null) { @@ -435,7 +442,7 @@ public class SessionUtil { httpSession.removeAttribute(CSV_EXPORT_TASK); httpSession.setAttribute(CSV_EXPORT_TASK, task); } - + public static Task getSDMXExportTask(HttpSession httpSession) { Task monitor = (Task) httpSession.getAttribute(SDMX_EXPORT_TASK); if (monitor == null) { @@ -452,23 +459,26 @@ public class SessionUtil { } public static TRTasksManager getTRTasksManager(HttpSession httpSession) { - TRTasksManager tasksManager = (TRTasksManager) httpSession.getAttribute(TR_TASK_MANAGER); + TRTasksManager tasksManager = (TRTasksManager) httpSession + .getAttribute(TR_TASK_MANAGER); if (tasksManager != null) { return tasksManager; } else { - tasksManager=new TRTasksManager(); + tasksManager = new TRTasksManager(); httpSession.setAttribute(TR_TASK_MANAGER, tasksManager); return tasksManager; } } - public static void setTRTasksManager(HttpSession httpSession,TRTasksManager trTasksManager) { - TRTasksManager tm = (TRTasksManager) httpSession.getAttribute(TR_TASK_MANAGER); + public static void setTRTasksManager(HttpSession httpSession, + TRTasksManager trTasksManager) { + TRTasksManager tm = (TRTasksManager) httpSession + .getAttribute(TR_TASK_MANAGER); if (tm != null) { httpSession.removeAttribute(TR_TASK_MANAGER); } httpSession.setAttribute(TR_TASK_MANAGER, trTasksManager); - + } } 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 385ec5f..92a3d1a 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 @@ -81,6 +81,7 @@ import org.gcube.portlets.user.td.gwtservice.shared.sdmx.SDMXExportMonitor; import org.gcube.portlets.user.td.gwtservice.shared.sdmx.SDMXExportSession; import org.gcube.portlets.user.td.gwtservice.shared.sdmx.SDMXImportMonitor; import org.gcube.portlets.user.td.gwtservice.shared.sdmx.SDMXImportSession; +import org.gcube.portlets.user.td.gwtservice.shared.source.SDMXRegistrySource; import org.gcube.portlets.user.td.gwtservice.shared.task.State; import org.gcube.portlets.user.td.gwtservice.shared.tr.ColumnData; import org.gcube.portlets.user.td.gwtservice.shared.tr.TRId; @@ -850,23 +851,25 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements } + + /** * {@inheritDoc} */ @Override - public void setSDMXSession(SDMXImportSession sdmxImportSession) + public void setSDMXRegistrySource(SDMXRegistrySource sdmxRegistrySource) throws TDGWTServiceException { try { session = this.getThreadLocalRequest().getSession(); - SessionUtil.setSDMXImportSession(session, sdmxImportSession); + SessionUtil.setSDMXRegistrySource(session, sdmxRegistrySource); return; } catch (Exception e) { logger.error( - "Error setting SDMXImportSession parameter: " + "Error setting SDMXRegistrySource parameter: " + e.getLocalizedMessage(), e); throw new TDGWTServiceException( - "Error setting SDMXImportSession parameter: " + "Error setting SDMXRegistrySource parameter: " + e.getLocalizedMessage()); } diff --git a/src/main/java/org/gcube/portlets/user/td/gwtservice/shared/sdmx/SDMXExportSession.java b/src/main/java/org/gcube/portlets/user/td/gwtservice/shared/sdmx/SDMXExportSession.java index de9cae2..2bdee50 100644 --- a/src/main/java/org/gcube/portlets/user/td/gwtservice/shared/sdmx/SDMXExportSession.java +++ b/src/main/java/org/gcube/portlets/user/td/gwtservice/shared/sdmx/SDMXExportSession.java @@ -5,6 +5,7 @@ package org.gcube.portlets.user.td.gwtservice.shared.sdmx; import java.io.Serializable; +import org.gcube.portlets.user.td.gwtservice.shared.source.Source; import org.gcube.portlets.user.td.gwtservice.shared.tr.TabResource; import org.gcube.portlets.user.td.gwtservice.shared.tr.type.Agencies; @@ -23,11 +24,10 @@ public class SDMXExportSession implements Serializable { protected String id; protected TabResource tabResource; protected Agencies agency; + protected Source source; - public String getId() { - return id; - } + public void setId(String id) { this.id = id; } @@ -44,12 +44,22 @@ public class SDMXExportSession implements Serializable { this.agency = agency; } + public Source getSource() { + return source; + } + public void setSource(Source source) { + this.source = source; + } + public String getId() { + return id; + } @Override public String toString() { return "SDMXExportSession [id=" + id + ", tabResource=" + tabResource - + ", agency=" + agency + "]"; + + ", agency=" + agency + ", source=" + source + "]"; } - + +