Fixed Registry Source

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-gwt-service@86533 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Giancarlo Panichi 2013-12-04 11:17:48 +00:00
parent fb8f581f32
commit ef27461516
5 changed files with 156 additions and 134 deletions

View File

@ -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<TabMetadata> getTableMetadata(TRId trId) throws TDGWTServiceException;
/**
public ArrayList<TabMetadata> getTableMetadata(TRId trId)
throws TDGWTServiceException;
/**
* Return Metadata of Tabular Resources
*
* @param trId
* @return
* @throws TDGWTServiceException
*/
public ArrayList<TRMetadata> getTRMetadata(TRId trId) throws TDGWTServiceException;
public ArrayList<TRMetadata> getTRMetadata(TRId trId)
throws TDGWTServiceException;
// Open
/**
@ -119,7 +118,8 @@ public interface TDGWTService extends RemoteService {
* @return
* @throws TDGWTServiceException
*/
public ArrayList<TabResource> getTabularResources() throws TDGWTServiceException;
public ArrayList<TabResource> 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<ColumnData> 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<Agencies> 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;
}

View File

@ -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<Void> callback);
//Import SDMX
//SDMX
void getCodelists(AsyncCallback<ArrayList<Codelist>> callback);
void getDatasets(AsyncCallback<ArrayList<Dataset>> callback);
void getAgencies(AsyncCallback<ArrayList<Agencies>> callback);
void setSDMXSession(SDMXImportSession sdmxImportSession, AsyncCallback<Void> callback);
void setSDMXRegistrySource(SDMXRegistrySource sdmxRegistrySource, AsyncCallback<Void> callback);
//Import SDMX
void getSDMXImportMonitor(AsyncCallback<SDMXImportMonitor> callback);
void startSDMXImport(SDMXImportSession sdmxImportSession,AsyncCallback<Void> callback);

View File

@ -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" <a
@ -42,32 +40,30 @@ import org.slf4j.LoggerFactory;
public class SessionUtil {
protected static final String CURRENT_TABULAR_RESOURCE = "CURRENT_TABULAR_RESOURCE";
protected static final String CURRENT_TR_ID= "CURRENT_TR_ID";
protected static final String CURRENT_TR_ID = "CURRENT_TR_ID";
protected static final String TDOPEN_SESSION = "TDOPEN_SESSION";
protected static final String TABULAR_RESOURCE_LIST = "TABULAR_RESOURCE_LIST";
protected static final String TR_TASK_MANAGER= "TR_TASK_MANAGER";
protected static final String TR_TASK_MANAGER = "TR_TASK_MANAGER";
protected static final String SDMX_REGISTRY_SOURCE = "SDMX_REGISTRY_SOURCE";
protected static final String SDMX_CLIENT_ATTRIBUTE = "SDMX_CLIENT";
protected static final String SDMX_IMPORT_SESSION = "SDMX_IMPORT";
protected static final String SDMX_IMPORT_TABULAR_RESOURCE = "SDMX_IMPORT_TABULAR_RESOURCE";
protected static final String SDMX_IMPORT_TASK="SDMX_IMPORT_TASK";
protected static final String SDMX_IMPORT_TASK = "SDMX_IMPORT_TASK";
protected static final String SDMX_EXPORT_SESSION = "SDMX_EXPORT_SESSION";
protected static final String SDMX_EXPORT_TASK="SDMX_EXPORT_TASK";
protected static final String SDMX_EXPORT_TASK = "SDMX_EXPORT_TASK";
protected static final String CSV_IMPORT_SESSION = "CSV_IMPORT";
protected static final String CSV_IMPORT_FILE_UPLOAD_SESSION = "CSV_IMPORT_FILE_UPLOAD";
protected static final String CSV_IMPORT_TASK="CSV_IMPORT_TASK";
protected static final String CSV_IMPORT_TASK = "CSV_IMPORT_TASK";
protected static final String CSV_IMPORT_TABULAR_RESOURCE = "CSV_IMPORT_TABULAR_RESOURCE";
protected static final String CSV_EXPORT_SESSION = "CSV_EXPORT_SESSION";
protected static final String CSV_EXPORT_TASK="CSV_EXPORT_TASK";
protected static final String CSV_EXPORT_TASK = "CSV_EXPORT_TASK";
protected static Logger logger = LoggerFactory.getLogger(SessionUtil.class);
protected static ASLSession getAslSession(HttpSession httpSession) {
@ -85,16 +81,15 @@ public class SessionUtil {
session.setScope(scope);
} else {
session= SessionManager.getInstance().getASLSession(
session = SessionManager.getInstance().getASLSession(
httpSession.getId(), username);
}
logger.info("SessionUtil: aslSession "+session.getUsername()+" "+session.getScope());
logger.info("SessionUtil: aslSession " + session.getUsername() + " "
+ session.getScope());
return session;
}
public static void setTDOpenSession(HttpSession httpSession, TDOpenSession s) {
@ -109,7 +104,6 @@ public class SessionUtil {
}
public static void retrieveResources(HttpSession httpSession)
throws Exception {
@ -187,9 +181,8 @@ public class SessionUtil {
ASLSession aslSession = getAslSession(httpSession);
ScopeProvider.instance.set(aslSession.getScope().toString());
}
////
// //
public static TabResource getCSVImportTabResource(HttpSession httpSession) {
TabResource tabResource = (TabResource) httpSession
.getAttribute(CSV_IMPORT_TABULAR_RESOURCE);
@ -209,9 +202,8 @@ public class SessionUtil {
ASLSession aslSession = getAslSession(httpSession);
ScopeProvider.instance.set(aslSession.getScope().toString());
}
////
// //
public static void setSDMXImportSession(HttpSession httpSession,
SDMXImportSession s) {
@ -254,8 +246,7 @@ public class SessionUtil {
}
return importSession;
}
public static void setCSVExportSession(HttpSession httpSession,
CSVExportSession s) {
@ -276,7 +267,7 @@ public class SessionUtil {
}
return exportSession;
}
public static void setSDMXExportSession(HttpSession httpSession,
SDMXExportSession s) {
@ -297,8 +288,7 @@ public class SessionUtil {
}
return exportSession;
}
public static void setFileUploadSession(HttpSession httpSession,
FileUploadSession s) {
@ -311,7 +301,6 @@ public class SessionUtil {
ScopeProvider.instance.set(aslSession.getScope().toString());
}
public static FileUploadSession getFileUploadSession(HttpSession httpSession) {
FileUploadSession fileUploadSession = (FileUploadSession) httpSession
.getAttribute(CSV_IMPORT_FILE_UPLOAD_SESSION);
@ -320,8 +309,7 @@ public class SessionUtil {
}
return fileUploadSession;
}
public static ArrayList<Codelist> 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);
}
}

View File

@ -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());
}

View File

@ -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 + "]";
}