ref 9056:TabMan - Improve resource management in TabMan

https://support.d4science.org/issues/9056

Improve resources management

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-gwt-service@151397 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Giancarlo Panichi 2017-07-27 15:43:00 +00:00
parent a4f31ec3e6
commit d9e5320f64
9 changed files with 280 additions and 295 deletions

View File

@ -1469,4 +1469,14 @@ public interface TDGWTService extends RemoteService {
public String startGeometryCreatePoint(GeometryCreatePointSession geometryCreatePointSession) public String startGeometryCreatePoint(GeometryCreatePointSession geometryCreatePointSession)
throws TDGWTServiceException; throws TDGWTServiceException;
/**
* Retrieve the URL of default SDMX Registry
*
*
* @return URL of the default SDMX Registry
* @throws TDGWTServiceException
* Exception
*/
public String getDefaultSDMXRegistryURL() throws TDGWTServiceException;
} }

View File

@ -97,8 +97,7 @@ import com.google.gwt.user.client.rpc.AsyncCallback;
public interface TDGWTServiceAsync { public interface TDGWTServiceAsync {
public static TDGWTServiceAsync INSTANCE = (TDGWTServiceAsync) GWT public static TDGWTServiceAsync INSTANCE = (TDGWTServiceAsync) GWT.create(TDGWTService.class);
.create(TDGWTService.class);
void hello(AsyncCallback<UserInfo> callback); void hello(AsyncCallback<UserInfo> callback);
@ -108,21 +107,18 @@ public interface TDGWTServiceAsync {
void restoreUISession(TRId startTRId, AsyncCallback<TRId> callback); void restoreUISession(TRId startTRId, AsyncCallback<TRId> callback);
void getUriFromResolver(UriResolverSession uriResolverSession, void getUriFromResolver(UriResolverSession uriResolverSession, AsyncCallback<String> callback);
AsyncCallback<String> callback);
void getVREFolderIdByScope(AsyncCallback<String> callback); void getVREFolderIdByScope(AsyncCallback<String> callback);
// PeriodDataType // PeriodDataType
void getPeriodDataTypes(AsyncCallback<ArrayList<PeriodDataType>> callback); void getPeriodDataTypes(AsyncCallback<ArrayList<PeriodDataType>> callback);
void getHierarchicalRelationshipForPeriodDataTypes( void getHierarchicalRelationshipForPeriodDataTypes(PeriodDataType periodDataType,
PeriodDataType periodDataType,
AsyncCallback<ArrayList<PeriodDataType>> callback); AsyncCallback<ArrayList<PeriodDataType>> callback);
// ValueDataFormat // ValueDataFormat
void getValueDataFormatsMap( void getValueDataFormatsMap(AsyncCallback<HashMap<ColumnDataType, ArrayList<ValueDataFormat>>> callback);
AsyncCallback<HashMap<ColumnDataType, ArrayList<ValueDataFormat>>> callback);
void getValueDataFormatsOfColumnDataType(ColumnDataType columnDataType, void getValueDataFormatsOfColumnDataType(ColumnDataType columnDataType,
AsyncCallback<ArrayList<ValueDataFormat>> callback); AsyncCallback<ArrayList<ValueDataFormat>> callback);
@ -130,8 +126,7 @@ public interface TDGWTServiceAsync {
// TabularResource // TabularResource
void getCurrentTRId(AsyncCallback<TRId> callback); void getCurrentTRId(AsyncCallback<TRId> callback);
void createTabularResource(TabResource tabResource, void createTabularResource(TabResource tabResource, AsyncCallback<TabResource> callback);
AsyncCallback<TabResource> callback);
void removeTabularResource(TRId trId, AsyncCallback<Void> callback); void removeTabularResource(TRId trId, AsyncCallback<Void> callback);
@ -141,11 +136,9 @@ public interface TDGWTServiceAsync {
void getTabResourceInformation(AsyncCallback<TabResource> callback); void getTabResourceInformation(AsyncCallback<TabResource> callback);
void getTabResourceInformation(TRId trId, void getTabResourceInformation(TRId trId, AsyncCallback<TabResource> callback);
AsyncCallback<TabResource> callback);
void setTabResourceInformation(TabResource tabResource, void setTabResourceInformation(TabResource tabResource, AsyncCallback<Void> callback);
AsyncCallback<Void> callback);
void setTabResourceToFinal(TRId trId, AsyncCallback<Void> callback); void setTabResourceToFinal(TRId trId, AsyncCallback<Void> callback);
@ -155,103 +148,83 @@ public interface TDGWTServiceAsync {
void getTabularResources(AsyncCallback<ArrayList<TabResource>> callback); void getTabularResources(AsyncCallback<ArrayList<TabResource>> callback);
void getTabularResourcesAndLastTables( void getTabularResourcesAndLastTables(AsyncCallback<ArrayList<TabResource>> callback);
AsyncCallback<ArrayList<TabResource>> callback);
void getLastTable(TRId trId, AsyncCallback<TableData> callback); void getLastTable(TRId trId, AsyncCallback<TableData> callback);
void getTable(TRId trId, AsyncCallback<TableData> callback); void getTable(TRId trId, AsyncCallback<TableData> callback);
void getTableMetadata(TRId trId, void getTableMetadata(TRId trId, AsyncCallback<ArrayList<TabMetadata>> callback);
AsyncCallback<ArrayList<TabMetadata>> callback);
void getTRMetadata(TRId trId, AsyncCallback<ArrayList<TRMetadata>> callback); void getTRMetadata(TRId trId, AsyncCallback<ArrayList<TRMetadata>> callback);
void getTimeTableId(PeriodDataType periodDataType, void getTimeTableId(PeriodDataType periodDataType, AsyncCallback<Long> callback);
AsyncCallback<Long> callback);
void getColumns(AsyncCallback<ArrayList<ColumnData>> callback); void getColumns(AsyncCallback<ArrayList<ColumnData>> callback);
void getColumns(TRId trId, AsyncCallback<ArrayList<ColumnData>> callback); void getColumns(TRId trId, AsyncCallback<ArrayList<ColumnData>> callback);
void getColumnWithViewColumnIncluded(TRId trId, void getColumnWithViewColumnIncluded(TRId trId, AsyncCallback<ArrayList<ColumnData>> callback);
AsyncCallback<ArrayList<ColumnData>> callback);
void getColumnWithOnlyViewColumnInRel(TRId trId, void getColumnWithOnlyViewColumnInRel(TRId trId, AsyncCallback<ArrayList<ColumnData>> callback);
AsyncCallback<ArrayList<ColumnData>> callback);
void getColumnsForStatistical(TRId trId, void getColumnsForStatistical(TRId trId, AsyncCallback<ArrayList<ColumnData>> callback);
AsyncCallback<ArrayList<ColumnData>> callback);
void getColumnsForDimension(TRId trId, void getColumnsForDimension(TRId trId, AsyncCallback<ArrayList<ColumnData>> callback);
AsyncCallback<ArrayList<ColumnData>> callback);
void getColumn(TRId trId, String columnName, void getColumn(TRId trId, String columnName, AsyncCallback<ColumnData> callback);
AsyncCallback<ColumnData> callback);
void getColumn(String columnLocalId, TRId trId, void getColumn(String columnLocalId, TRId trId, AsyncCallback<ColumnData> callback);
AsyncCallback<ColumnData> callback);
void getConnection(RefColumn refColumn, AsyncCallback<ColumnData> callback); void getConnection(RefColumn refColumn, AsyncCallback<ColumnData> callback);
void closeAllTabularResources(AsyncCallback<Void> callback); void closeAllTabularResources(AsyncCallback<Void> callback);
void closeTabularResourceAndOpen(TRId openTRId, TRId closeTRId, void closeTabularResourceAndOpen(TRId openTRId, TRId closeTRId, AsyncCallback<Void> callback);
AsyncCallback<Void> callback);
void closeTabularResource(TRId closeTRId, AsyncCallback<Void> callback); void closeTabularResource(TRId closeTRId, AsyncCallback<Void> callback);
void setActiveTabularResource(TRId activeTRId, AsyncCallback<TRId> callback); void setActiveTabularResource(TRId activeTRId, AsyncCallback<TRId> callback);
// Task // Task
void startTaskResubmit(TaskResubmitSession taskResubmitSession, void startTaskResubmit(TaskResubmitSession taskResubmitSession, AsyncCallback<String> callback);
AsyncCallback<String> callback);
void startTaskResume(TaskResumeSession taskResumeSession, void startTaskResume(TaskResumeSession taskResumeSession, AsyncCallback<String> callback);
AsyncCallback<String> callback);
// Validations // Validations
void getValidationsTasksMetadata(TRId trId, void getValidationsTasksMetadata(TRId trId, AsyncCallback<ValidationsTasksMetadata> callback);
AsyncCallback<ValidationsTasksMetadata> callback);
void getTableValidationsMetadata(TRId trId, void getTableValidationsMetadata(TRId trId, AsyncCallback<TabValidationsMetadata> callback);
AsyncCallback<TabValidationsMetadata> callback);
void getValidationColumns(TRId trId, String columnName, void getValidationColumns(TRId trId, String columnName, AsyncCallback<ArrayList<ColumnData>> callback);
AsyncCallback<ArrayList<ColumnData>> callback);
void getValidationColumns(String columnLocalId, TRId trId, void getValidationColumns(String columnLocalId, TRId trId, AsyncCallback<ArrayList<ColumnData>> callback);
AsyncCallback<ArrayList<ColumnData>> callback);
void startValidationsDelete(TRId trId, AsyncCallback<String> callback); void startValidationsDelete(TRId trId, AsyncCallback<String> callback);
// RollBack // RollBack
void startRollBack(RollBackSession rollBackSession, void startRollBack(RollBackSession rollBackSession, AsyncCallback<String> callback);
AsyncCallback<String> callback);
void startDiscard(TRId trId, AsyncCallback<String> callback); void startDiscard(TRId trId, AsyncCallback<String> callback);
// Share // Share
void setShare(ShareTabResource shareInfo, AsyncCallback<Void> callback); void setShare(ShareTabResource shareInfo, AsyncCallback<Void> callback);
void setShareTemplate(ShareTemplate shareTemplate, void setShareTemplate(ShareTemplate shareTemplate, AsyncCallback<Void> callback);
AsyncCallback<Void> callback);
void setShareRule(ShareRule shareRule, AsyncCallback<Void> callback); void setShareRule(ShareRule shareRule, AsyncCallback<Void> callback);
// CodelistPagingLoaded // CodelistPagingLoaded
void setCodelistsPagingLoader(AsyncCallback<Void> callback); void setCodelistsPagingLoader(AsyncCallback<Void> callback);
void getCodelistsPagingLoader( void getCodelistsPagingLoader(CodelistPagingLoadConfig codelistPagingLoadConfig,
CodelistPagingLoadConfig codelistPagingLoadConfig,
AsyncCallback<CodelistPagingLoadResult> callback); AsyncCallback<CodelistPagingLoadResult> callback);
// Open // Open
void tdOpen(TDOpenSession tdOpenSession, AsyncCallback<Void> callback); void tdOpen(TDOpenSession tdOpenSession, AsyncCallback<Void> callback);
// Clone // Clone
void startCloneTabularResource( void startCloneTabularResource(CloneTabularResourceSession cloneTabularResourceSession,
CloneTabularResourceSession cloneTabularResourceSession,
AsyncCallback<String> callback); AsyncCallback<String> callback);
// SDMX // SDMX
@ -261,82 +234,61 @@ public interface TDGWTServiceAsync {
void getAgencies(AsyncCallback<ArrayList<Agencies>> callback); void getAgencies(AsyncCallback<ArrayList<Agencies>> callback);
void setSDMXRegistrySource(SDMXRegistrySource sdmxRegistrySource, void setSDMXRegistrySource(SDMXRegistrySource sdmxRegistrySource, AsyncCallback<Void> callback);
AsyncCallback<Void> callback);
// Import SDMX // Import SDMX
void startSDMXImport(SDMXImportSession sdmxImportSession, void startSDMXImport(SDMXImportSession sdmxImportSession, AsyncCallback<String> callback);
AsyncCallback<String> callback);
// Import CSV // Import CSV
void setCSVSession(CSVImportSession csvImportSession, void setCSVSession(CSVImportSession csvImportSession, AsyncCallback<Void> callback);
AsyncCallback<Void> callback);
void getFileFromWorkspace(CSVImportSession csvImportSession, void getFileFromWorkspace(CSVImportSession csvImportSession, AsyncCallback<Void> callback);
AsyncCallback<Void> callback);
void getAvailableCharset(AsyncCallback<AvailableCharsetList> callback); void getAvailableCharset(AsyncCallback<AvailableCharsetList> callback);
void configureCSVParser(String encoding, HeaderPresence headerPresence, void configureCSVParser(String encoding, HeaderPresence headerPresence, char delimiter, char comment,
char delimiter, char comment,
AsyncCallback<ArrayList<String>> callback); AsyncCallback<ArrayList<String>> callback);
void checkCSV(long errorsLimit, AsyncCallback<CheckCSVSession> callback); void checkCSV(long errorsLimit, AsyncCallback<CheckCSVSession> callback);
void startCSVImport(CSVImportSession csvImportSession, void startCSVImport(CSVImportSession csvImportSession, AsyncCallback<String> callback);
AsyncCallback<String> callback);
// Export CSV // Export CSV
void getAvailableCharsetForExport( void getAvailableCharsetForExport(AsyncCallback<AvailableCharsetList> callback);
AsyncCallback<AvailableCharsetList> callback);
void startCSVExport(CSVExportSession csvExportSession, void startCSVExport(CSVExportSession csvExportSession, AsyncCallback<String> callback);
AsyncCallback<String> callback);
// Export SDMX // Export SDMX
void startSDMXExport(SDMXExportSession exportSession, void startSDMXExport(SDMXExportSession exportSession, AsyncCallback<String> callback);
AsyncCallback<String> callback);
// Export Template SDMX // Export Template SDMX
void startSDMXTemplateExport( void startSDMXTemplateExport(SDMXTemplateExportSession sdmxTemplateExportSession, AsyncCallback<String> callback);
SDMXTemplateExportSession sdmxTemplateExportSession,
AsyncCallback<String> callback);
// Export JSON // Export JSON
void startJSONExport(JSONExportSession jsonExportSession, void startJSONExport(JSONExportSession jsonExportSession, AsyncCallback<String> callback);
AsyncCallback<String> callback);
// Table Operation // Table Operation
void startChangeTableType(ChangeTableTypeSession changeTableTypeSession, void startChangeTableType(ChangeTableTypeSession changeTableTypeSession, AsyncCallback<String> callback);
AsyncCallback<String> callback);
void startUnion(UnionSession unionSession, AsyncCallback<String> callback); void startUnion(UnionSession unionSession, AsyncCallback<String> callback);
// Rows Operation // Rows Operation
void startEditRow(EditRowSession editRowSession, void startEditRow(EditRowSession editRowSession, AsyncCallback<String> callback);
AsyncCallback<String> callback);
void startDeleteRows(DeleteRowsSession deleteRowsSession, void startDeleteRows(DeleteRowsSession deleteRowsSession, AsyncCallback<String> callback);
AsyncCallback<String> callback);
void startDuplicates(DuplicatesSession duplicatesSession, void startDuplicates(DuplicatesSession duplicatesSession, AsyncCallback<String> callback);
AsyncCallback<String> callback);
// Column Operation // Column Operation
void startChangeColumnType(ChangeColumnTypeSession changeColumnTypeSession, void startChangeColumnType(ChangeColumnTypeSession changeColumnTypeSession, AsyncCallback<String> callback);
AsyncCallback<String> callback);
void startAddColumn(AddColumnSession addColumnSession, void startAddColumn(AddColumnSession addColumnSession, AsyncCallback<String> callback);
AsyncCallback<String> callback);
void startDeleteColumn(DeleteColumnSession deleteColumnSession, void startDeleteColumn(DeleteColumnSession deleteColumnSession, AsyncCallback<String> callback);
AsyncCallback<String> callback);
void startLabelColumn(LabelColumnSession labelColumnSession, void startLabelColumn(LabelColumnSession labelColumnSession, AsyncCallback<String> callback);
AsyncCallback<String> callback);
void startChangeColumnsPosition( void startChangeColumnsPosition(ChangeColumnsPositionSession changeColumnsPositionSession,
ChangeColumnsPositionSession changeColumnsPositionSession,
AsyncCallback<Void> callback); AsyncCallback<Void> callback);
/* /*
@ -353,36 +305,26 @@ public interface TDGWTServiceAsync {
*/ */
// BatchReplace Operation // BatchReplace Operation
void getOccurrencesForBatchReplace( void getOccurrencesForBatchReplace(OccurrencesForReplaceBatchColumnSession occurrencesForReplaceBatchColumnSession,
OccurrencesForReplaceBatchColumnSession occurrencesForReplaceBatchColumnSession,
AsyncCallback<ArrayList<Occurrences>> callback); AsyncCallback<ArrayList<Occurrences>> callback);
void startReplaceBatchColumn( void startReplaceBatchColumn(ReplaceBatchColumnSession replaceBatchColumnSession, AsyncCallback<String> callback);
ReplaceBatchColumnSession replaceBatchColumnSession,
AsyncCallback<String> callback);
// Replace Operation // Replace Operation
void startReplaceColumn(ReplaceColumnSession replaceColumnSession, void startReplaceColumn(ReplaceColumnSession replaceColumnSession, AsyncCallback<String> callback);
AsyncCallback<String> callback);
void startReplaceByExternal( void startReplaceByExternal(ReplaceByExternalSession replaceByExternalSession, AsyncCallback<String> callback);
ReplaceByExternalSession replaceByExternalSession,
AsyncCallback<String> callback);
// Templates // Templates
void getTemplates(AsyncCallback<ArrayList<TemplateData>> callback); void getTemplates(AsyncCallback<ArrayList<TemplateData>> callback);
void getTemplatesForDSDExport( void getTemplatesForDSDExport(AsyncCallback<ArrayList<TemplateData>> callback);
AsyncCallback<ArrayList<TemplateData>> callback);
void getTemplateColumnsData(String templateId, void getTemplateColumnsData(String templateId, AsyncCallback<ArrayList<TemplateColumnData>> callback);
AsyncCallback<ArrayList<TemplateColumnData>> callback);
void startTemplateApply(TemplateApplySession templateDeleteSession, void startTemplateApply(TemplateApplySession templateDeleteSession, AsyncCallback<String> callback);
AsyncCallback<String> callback);
void templateDelete(TemplateDeleteSession templateDeleteSession, void templateDelete(TemplateDeleteSession templateDeleteSession, AsyncCallback<Void> callback);
AsyncCallback<Void> callback);
// Locales // Locales
void getLocales(AsyncCallback<ArrayList<String>> callback); void getLocales(AsyncCallback<ArrayList<String>> callback);
@ -400,82 +342,64 @@ public interface TDGWTServiceAsync {
void getLastOperationInfo(TRId trId, AsyncCallback<OpHistory> callback); void getLastOperationInfo(TRId trId, AsyncCallback<OpHistory> callback);
// Helper Extract Codelist // Helper Extract Codelist
void startExtractCodelist(ExtractCodelistSession extractCodelistSession, void startExtractCodelist(ExtractCodelistSession extractCodelistSession, AsyncCallback<String> callback);
AsyncCallback<String> callback);
// Helper Codelist Mapping Import // Helper Codelist Mapping Import
void setCodelistMappingSession( void setCodelistMappingSession(CodelistMappingSession codelistMappingSession, AsyncCallback<Void> callback);
CodelistMappingSession codelistMappingSession,
AsyncCallback<Void> callback);
void getFileFromWorkspace(CodelistMappingSession codelistMappingSession, void getFileFromWorkspace(CodelistMappingSession codelistMappingSession, AsyncCallback<Void> callback);
AsyncCallback<Void> callback);
void startCodelistMappingImport( void startCodelistMappingImport(CodelistMappingSession codelistMappingSession, AsyncCallback<String> callback);
CodelistMappingSession codelistMappingSession,
AsyncCallback<String> callback);
// Normalization // Normalization
void startNormalization(NormalizationSession normalizationSession, void startNormalization(NormalizationSession normalizationSession, AsyncCallback<String> callback);
AsyncCallback<String> callback);
// Denormalization // Denormalization
void startDenormalization(DenormalizationSession denormalizationSession, void startDenormalization(DenormalizationSession denormalizationSession, AsyncCallback<String> callback);
AsyncCallback<String> callback);
// Operation Monitor // Operation Monitor
void getOperationMonitor(OperationMonitorSession operationMonitorSession, void getOperationMonitor(OperationMonitorSession operationMonitorSession, AsyncCallback<OperationMonitor> callback);
AsyncCallback<OperationMonitor> callback);
void getBackgroundOperationMonitor( void getBackgroundOperationMonitor(BackgroundOperationMonitorSession backgroundOperationMonitorSession,
BackgroundOperationMonitorSession backgroundOperationMonitorSession,
AsyncCallback<ArrayList<BackgroundOperationMonitor>> callback); AsyncCallback<ArrayList<BackgroundOperationMonitor>> callback);
void getBackgroundOperationMonitorForSpecificTask( void getBackgroundOperationMonitorForSpecificTask(OperationMonitorSession operationMonitorSession,
OperationMonitorSession operationMonitorSession,
AsyncCallback<OperationMonitor> callback); AsyncCallback<OperationMonitor> callback);
// File Upload Monitor // File Upload Monitor
void getFileUploadMonitor(AsyncCallback<FileUploadMonitor> callback); void getFileUploadMonitor(AsyncCallback<FileUploadMonitor> callback);
// ResourceTD // ResourceTD
void getResourcesTD(TRId trId, void getResourcesTD(TRId trId, AsyncCallback<ArrayList<ResourceTDDescriptor>> callback);
AsyncCallback<ArrayList<ResourceTDDescriptor>> callback);
void getResourcesTDByType(TRId trId, ResourceTDType reourceTDType, void getResourcesTDByType(TRId trId, ResourceTDType reourceTDType,
AsyncCallback<ArrayList<ResourceTDDescriptor>> callback); AsyncCallback<ArrayList<ResourceTDDescriptor>> callback);
void removeResource(RemoveResourceSession removeResourceSession, void removeResource(RemoveResourceSession removeResourceSession, AsyncCallback<Void> callback);
AsyncCallback<Void> callback);
void saveResource(SaveResourceSession saveResourceSession, void saveResource(SaveResourceSession saveResourceSession, AsyncCallback<Void> callback);
AsyncCallback<Void> callback);
// GIS MAP // GIS MAP
void startMapCreation(MapCreationSession mapCreationSession, void startMapCreation(MapCreationSession mapCreationSession, AsyncCallback<String> callback);
AsyncCallback<String> callback);
// DataMiner // DataMiner
void startDataMinerOperation( void startDataMinerOperation(DataMinerOperationSession dataMinerOperationSession, AsyncCallback<String> callback);
DataMinerOperationSession dataMinerOperationSession,
AsyncCallback<String> callback);
// Chart // Chart
void startChartTopRating(ChartTopRatingSession chartTopRatingSession, void startChartTopRating(ChartTopRatingSession chartTopRatingSession, AsyncCallback<String> callback);
AsyncCallback<String> callback);
// Geospatial // Geospatial
void startGeospatialCreateCoordinates( void startGeospatialCreateCoordinates(GeospatialCreateCoordinatesSession geospatialCreateCoordinatesSession,
GeospatialCreateCoordinatesSession geospatialCreateCoordinatesSession,
AsyncCallback<String> callback); AsyncCallback<String> callback);
void startGeospatialDownscaleCSquare( void startGeospatialDownscaleCSquare(GeospatialDownscaleCSquareSession geospatialDownscaleCSquareSession,
GeospatialDownscaleCSquareSession geospatialDownscaleCSquareSession,
AsyncCallback<String> callback); AsyncCallback<String> callback);
// Geometry // Geometry
void startGeometryCreatePoint( void startGeometryCreatePoint(GeometryCreatePointSession geometryCreatePointSession,
GeometryCreatePointSession geometryCreatePointSession,
AsyncCallback<String> callback); AsyncCallback<String> callback);
// Retrieve the URL of default SDMX Registry
void getDefaultSDMXRegistryURL(AsyncCallback<String> callback);
} }

View File

@ -26,6 +26,8 @@ public class SessionConstants {
public static final String TR_TASK_MANAGER = "TR_TASK_MANAGER"; public static final String TR_TASK_MANAGER = "TR_TASK_MANAGER";
public static final String SDMX_INTERNAL_REGISTRY_URL = "SDMX_INTERNAL_REGISTRY_URL";
public static final String SDMX_REGISTRY_SOURCE = "SDMX_REGISTRY_SOURCE"; public static final String SDMX_REGISTRY_SOURCE = "SDMX_REGISTRY_SOURCE";
public static final String SDMX_CLIENT_ATTRIBUTE = "SDMX_CLIENT"; public static final String SDMX_CLIENT_ATTRIBUTE = "SDMX_CLIENT";
@ -133,4 +135,6 @@ public class SessionConstants {
public static final String COLUMN_FILTER_SESSION_TASK = "COLUMN_FILTER_SESSION_TASK"; public static final String COLUMN_FILTER_SESSION_TASK = "COLUMN_FILTER_SESSION_TASK";
} }

View File

@ -536,6 +536,22 @@ public class SessionUtil {
} }
public static void setInternalSDMXRegistryURLSession(HttpServletRequest httpRequest, ServiceCredentials serviceCredentials,
String defaultSDMXRegistryUrl) {
SessionOp<String> sessionOp = new SessionOp<>();
sessionOp.set(httpRequest, serviceCredentials, SessionConstants.SDMX_INTERNAL_REGISTRY_URL, defaultSDMXRegistryUrl);
}
public static String getInternalSDMXRegistryURLSession(HttpServletRequest httpRequest,
ServiceCredentials serviceCredentials) {
SessionOp<String> sessionOp = new SessionOp<>();
String defaultSDMXRegistryURL = sessionOp.get(httpRequest, serviceCredentials,
SessionConstants.SDMX_INTERNAL_REGISTRY_URL);
return defaultSDMXRegistryURL;
}
public static void setSDMXExportSession(HttpServletRequest httpRequest, ServiceCredentials serviceCredentials, public static void setSDMXExportSession(HttpServletRequest httpRequest, ServiceCredentials serviceCredentials,
SDMXExportSession sdmxExportSession) { SDMXExportSession sdmxExportSession) {
SessionOp<SDMXExportSession> sessionOp = new SessionOp<>(); SessionOp<SDMXExportSession> sessionOp = new SessionOp<>();

View File

@ -111,6 +111,7 @@ import org.gcube.portlets.user.td.gwtservice.server.encoding.EncodingPGSupported
import org.gcube.portlets.user.td.gwtservice.server.file.CSVFileUploadSession; import org.gcube.portlets.user.td.gwtservice.server.file.CSVFileUploadSession;
import org.gcube.portlets.user.td.gwtservice.server.file.CodelistMappingFileUploadSession; import org.gcube.portlets.user.td.gwtservice.server.file.CodelistMappingFileUploadSession;
import org.gcube.portlets.user.td.gwtservice.server.file.FileUtil; import org.gcube.portlets.user.td.gwtservice.server.file.FileUtil;
import org.gcube.portlets.user.td.gwtservice.server.is.ISUtils;
import org.gcube.portlets.user.td.gwtservice.server.opexecution.OpExecution4AddColumn; import org.gcube.portlets.user.td.gwtservice.server.opexecution.OpExecution4AddColumn;
import org.gcube.portlets.user.td.gwtservice.server.opexecution.OpExecution4CSVExport; import org.gcube.portlets.user.td.gwtservice.server.opexecution.OpExecution4CSVExport;
import org.gcube.portlets.user.td.gwtservice.server.opexecution.OpExecution4CSVImport; import org.gcube.portlets.user.td.gwtservice.server.opexecution.OpExecution4CSVImport;
@ -4429,11 +4430,13 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements TDGWTServi
// / // /
switch (exportSession.getExportType()) { switch (exportSession.getExportType()) {
case CODELIST: case CODELIST:
OpExecution4SDMXCodelistExport opExC = new OpExecution4SDMXCodelistExport(service, exportSession); OpExecution4SDMXCodelistExport opExC = new OpExecution4SDMXCodelistExport(httpRequest,
serviceCredentials, service, exportSession);
director.setOperationExecutionBuilder(opExC); director.setOperationExecutionBuilder(opExC);
break; break;
case DATASET: case DATASET:
OpExecution4SDMXDatasetExport opExD = new OpExecution4SDMXDatasetExport(service, exportSession); OpExecution4SDMXDatasetExport opExD = new OpExecution4SDMXDatasetExport(httpRequest, serviceCredentials,
service, exportSession);
director.setOperationExecutionBuilder(opExD); director.setOperationExecutionBuilder(opExD);
break; break;
case GENERIC: case GENERIC:
@ -4496,8 +4499,8 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements TDGWTServi
OpExecutionDirector director = new OpExecutionDirector(); OpExecutionDirector director = new OpExecutionDirector();
// / // /
OpExecution4SDMXTemplateExport opExD = new OpExecution4SDMXTemplateExport(service, OpExecution4SDMXTemplateExport opExD = new OpExecution4SDMXTemplateExport(httpRequest, serviceCredentials,
sdmxTemplateExportSession); service, sdmxTemplateExportSession);
director.setOperationExecutionBuilder(opExD); director.setOperationExecutionBuilder(opExD);
director.constructOperationExecution(); director.constructOperationExecution();
@ -8940,4 +8943,43 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements TDGWTServi
} }
@Override
public String getDefaultSDMXRegistryURL() throws TDGWTServiceException {
HttpServletRequest httpRequest = null;
try {
httpRequest = this.getThreadLocalRequest();
ServiceCredentials serviceCredentials = SessionUtil.getServiceCredentials(httpRequest);
String defaultSDMXRegistryURL = SessionUtil.getInternalSDMXRegistryURLSession(httpRequest,
serviceCredentials);
if (defaultSDMXRegistryURL == null || defaultSDMXRegistryURL.isEmpty()) {
defaultSDMXRegistryURL = ISUtils.retrieveInternalSDMXRegistryURL();
if (defaultSDMXRegistryURL != null && !defaultSDMXRegistryURL.isEmpty()) {
SessionUtil.setInternalSDMXRegistryURLSession(httpRequest, serviceCredentials,
defaultSDMXRegistryURL);
int pos = defaultSDMXRegistryURL.indexOf("FusionRegistry");
defaultSDMXRegistryURL = defaultSDMXRegistryURL.substring(0, pos + 15);
}
} else {
int pos = defaultSDMXRegistryURL.indexOf("FusionRegistry");
defaultSDMXRegistryURL = defaultSDMXRegistryURL.substring(0, pos + 15);
}
logger.debug("Default SDMXRegistry URL: " + defaultSDMXRegistryURL);
return defaultSDMXRegistryURL;
} catch (TDGWTServiceException e) {
throw e;
} catch (SecurityException e) {
e.printStackTrace();
ResourceBundle messages = getResourceBundle(httpRequest);
throw new TDGWTServiceException(messages.getString(TDGWTServiceMessagesConstants.securityExceptionRights));
} catch (Throwable e) {
logger.error("getDefaultSDMXRegistryURL(): " + e.getLocalizedMessage(), e);
throw new TDGWTServiceException("Error retrieving default SDMX Regitry URL: " + e.getLocalizedMessage());
}
}
} }

View File

@ -0,0 +1,56 @@
package org.gcube.portlets.user.td.gwtservice.server.is;
import static org.gcube.resources.discovery.icclient.ICFactory.clientFor;
import static org.gcube.resources.discovery.icclient.ICFactory.queryFor;
import java.util.List;
import org.gcube.common.resources.gcore.ServiceEndpoint;
import org.gcube.common.resources.gcore.ServiceEndpoint.AccessPoint;
import org.gcube.common.resources.gcore.ServiceEndpoint.Profile;
import org.gcube.common.resources.gcore.utils.Group;
import org.gcube.resources.discovery.client.api.DiscoveryClient;
import org.gcube.resources.discovery.client.queries.api.SimpleQuery;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
*
* @author Giancarlo Panichi
*
*
*/
public class ISUtils {
private static Logger logger = LoggerFactory.getLogger(ISUtils.class);
public static String retrieveInternalSDMXRegistryURL() {
String sdmxRegistryURL = null;
SimpleQuery query = queryFor(ServiceEndpoint.class);
query.addCondition("$resource/Profile/Category/text() eq 'SDMX'")
.addCondition("$resource/Profile/Name/text() eq 'SDMXRegistry'");
DiscoveryClient<ServiceEndpoint> client = clientFor(ServiceEndpoint.class);
List<ServiceEndpoint> listService = client.submit(query);
if (listService.size() > 0) {
ServiceEndpoint serviceEnd = listService.get(0);
if (serviceEnd != null) {
Profile prof = serviceEnd.profile();
Group<AccessPoint> groupA = prof.accessPoints();
for (AccessPoint acc : groupA) {
if (acc.description().compareTo("REST Interface v2.1") == 0) {
sdmxRegistryURL = acc.address();
break;
}
}
} else {
}
} else {
}
logger.debug("Retrieved URL of the default SDMX Registry: " + sdmxRegistryURL);
return sdmxRegistryURL;
}
}

View File

@ -1,26 +1,21 @@
package org.gcube.portlets.user.td.gwtservice.server.opexecution; package org.gcube.portlets.user.td.gwtservice.server.opexecution;
import static org.gcube.resources.discovery.icclient.ICFactory.clientFor;
import static org.gcube.resources.discovery.icclient.ICFactory.queryFor;
import java.util.HashMap; import java.util.HashMap;
import java.util.List;
import java.util.Map; import java.util.Map;
import org.gcube.common.resources.gcore.ServiceEndpoint; import javax.servlet.http.HttpServletRequest;
import org.gcube.common.resources.gcore.ServiceEndpoint.AccessPoint;
import org.gcube.common.resources.gcore.ServiceEndpoint.Profile;
import org.gcube.common.resources.gcore.utils.Group;
import org.gcube.data.analysis.tabulardata.commons.webservice.types.operations.OperationDefinition; import org.gcube.data.analysis.tabulardata.commons.webservice.types.operations.OperationDefinition;
import org.gcube.data.analysis.tabulardata.commons.webservice.types.operations.OperationExecution; import org.gcube.data.analysis.tabulardata.commons.webservice.types.operations.OperationExecution;
import org.gcube.data.analysis.tabulardata.service.TabularDataService; import org.gcube.data.analysis.tabulardata.service.TabularDataService;
import org.gcube.portlets.user.td.gwtservice.server.SessionUtil;
import org.gcube.portlets.user.td.gwtservice.server.is.ISUtils;
import org.gcube.portlets.user.td.gwtservice.server.trservice.OperationDefinitionMap; import org.gcube.portlets.user.td.gwtservice.server.trservice.OperationDefinitionMap;
import org.gcube.portlets.user.td.gwtservice.server.util.ServiceCredentials;
import org.gcube.portlets.user.td.gwtservice.shared.Constants; import org.gcube.portlets.user.td.gwtservice.shared.Constants;
import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTServiceException; import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTServiceException;
import org.gcube.portlets.user.td.gwtservice.shared.sdmx.SDMXExportSession; import org.gcube.portlets.user.td.gwtservice.shared.sdmx.SDMXExportSession;
import org.gcube.portlets.user.td.widgetcommonevent.shared.operations.OperationsId; import org.gcube.portlets.user.td.widgetcommonevent.shared.operations.OperationsId;
import org.gcube.resources.discovery.client.api.DiscoveryClient;
import org.gcube.resources.discovery.client.queries.api.SimpleQuery;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@ -32,14 +27,17 @@ import org.slf4j.LoggerFactory;
* *
*/ */
public class OpExecution4SDMXCodelistExport extends OpExecutionBuilder { public class OpExecution4SDMXCodelistExport extends OpExecutionBuilder {
private static Logger logger = LoggerFactory private static Logger logger = LoggerFactory.getLogger(OpExecution4SDMXCodelistExport.class);
.getLogger(OpExecution4SDMXCodelistExport.class);
private HttpServletRequest httpRequest;
private ServiceCredentials serviceCredentials;
private TabularDataService service; private TabularDataService service;
private SDMXExportSession sdmxExportSession; private SDMXExportSession sdmxExportSession;
public OpExecution4SDMXCodelistExport(TabularDataService service, public OpExecution4SDMXCodelistExport(HttpServletRequest httpRequest, ServiceCredentials serviceCredentials,
SDMXExportSession sdmxExportSession) { TabularDataService service, SDMXExportSession sdmxExportSession) {
this.httpRequest = httpRequest;
this.serviceCredentials = serviceCredentials;
this.service = service; this.service = service;
this.sdmxExportSession = sdmxExportSession; this.sdmxExportSession = sdmxExportSession;
} }
@ -52,8 +50,7 @@ public class OpExecution4SDMXCodelistExport extends OpExecutionBuilder {
// http://pc-fortunati.isti.cnr.it:8080/FusionRegistry/ws/rest/ // http://pc-fortunati.isti.cnr.it:8080/FusionRegistry/ws/rest/
if (sdmxExportSession != null) { if (sdmxExportSession != null) {
if (sdmxExportSession.getRegistryBaseUrl() != null if (sdmxExportSession.getRegistryBaseUrl() != null && !sdmxExportSession.getRegistryBaseUrl().isEmpty()) {
&& !sdmxExportSession.getRegistryBaseUrl().isEmpty()) {
destination = sdmxExportSession.getRegistryBaseUrl(); destination = sdmxExportSession.getRegistryBaseUrl();
} else { } else {
internalRegistry = true; internalRegistry = true;
@ -63,37 +60,22 @@ public class OpExecution4SDMXCodelistExport extends OpExecutionBuilder {
} }
if (internalRegistry) { if (internalRegistry) {
SimpleQuery query = queryFor(ServiceEndpoint.class); destination = SessionUtil.getInternalSDMXRegistryURLSession(httpRequest, serviceCredentials);
query.addCondition("$resource/Profile/Category/text() eq 'SDMX'") if (destination == null || destination.isEmpty()) {
.addCondition( destination = ISUtils.retrieveInternalSDMXRegistryURL();
"$resource/Profile/Name/text() eq 'SDMXRegistry'"); if(destination!=null&&!destination.isEmpty()){
DiscoveryClient<ServiceEndpoint> client = clientFor(ServiceEndpoint.class); SessionUtil.setInternalSDMXRegistryURLSession(httpRequest, serviceCredentials, destination);
List<ServiceEndpoint> listService = client.submit(query);
if (listService.size() > 0) {
ServiceEndpoint serviceEnd = listService.get(0);
if (serviceEnd != null) {
Profile prof = serviceEnd.profile();
Group<AccessPoint> groupA = prof.accessPoints();
for (AccessPoint acc : groupA) {
if (acc.description().compareTo("REST Interface v2.1") == 0) {
destination = acc.address();
break;
}
}
} else {
} }
} else {
} }
} }
if (destination == null) { if (destination == null) {
logger.debug("Destination: " + destination); logger.debug("Destination: " + destination);
throw new TDGWTServiceException("SDMX Service not discovered"); throw new TDGWTServiceException("SDMX Service not discovered");
} }
OperationDefinition operationDefinition = OperationDefinitionMap.map( OperationDefinition operationDefinition = OperationDefinitionMap.map(OperationsId.SDMXCodelistExport.toString(),
OperationsId.SDMXCodelistExport.toString(), service); service);
Map<String, Object> map = new HashMap<String, Object>(); Map<String, Object> map = new HashMap<String, Object>();
@ -102,8 +84,7 @@ public class OpExecution4SDMXCodelistExport extends OpExecutionBuilder {
map.put(Constants.PARAMETER_ID, sdmxExportSession.getId()); map.put(Constants.PARAMETER_ID, sdmxExportSession.getId());
map.put(Constants.PARAMETER_VERSION, sdmxExportSession.getVersion()); map.put(Constants.PARAMETER_VERSION, sdmxExportSession.getVersion());
OperationExecution invocation = new OperationExecution( OperationExecution invocation = new OperationExecution(operationDefinition.getOperationId(), map);
operationDefinition.getOperationId(), map);
operationExecutionSpec.setOp(invocation); operationExecutionSpec.setOp(invocation);
} }

View File

@ -1,26 +1,21 @@
package org.gcube.portlets.user.td.gwtservice.server.opexecution; package org.gcube.portlets.user.td.gwtservice.server.opexecution;
import static org.gcube.resources.discovery.icclient.ICFactory.clientFor;
import static org.gcube.resources.discovery.icclient.ICFactory.queryFor;
import java.util.HashMap; import java.util.HashMap;
import java.util.List;
import java.util.Map; import java.util.Map;
import org.gcube.common.resources.gcore.ServiceEndpoint; import javax.servlet.http.HttpServletRequest;
import org.gcube.common.resources.gcore.ServiceEndpoint.AccessPoint;
import org.gcube.common.resources.gcore.ServiceEndpoint.Profile;
import org.gcube.common.resources.gcore.utils.Group;
import org.gcube.data.analysis.tabulardata.commons.webservice.types.operations.OperationDefinition; import org.gcube.data.analysis.tabulardata.commons.webservice.types.operations.OperationDefinition;
import org.gcube.data.analysis.tabulardata.commons.webservice.types.operations.OperationExecution; import org.gcube.data.analysis.tabulardata.commons.webservice.types.operations.OperationExecution;
import org.gcube.data.analysis.tabulardata.service.TabularDataService; import org.gcube.data.analysis.tabulardata.service.TabularDataService;
import org.gcube.portlets.user.td.gwtservice.server.SessionUtil;
import org.gcube.portlets.user.td.gwtservice.server.is.ISUtils;
import org.gcube.portlets.user.td.gwtservice.server.trservice.OperationDefinitionMap; import org.gcube.portlets.user.td.gwtservice.server.trservice.OperationDefinitionMap;
import org.gcube.portlets.user.td.gwtservice.server.util.ServiceCredentials;
import org.gcube.portlets.user.td.gwtservice.shared.Constants; import org.gcube.portlets.user.td.gwtservice.shared.Constants;
import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTServiceException; import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTServiceException;
import org.gcube.portlets.user.td.gwtservice.shared.sdmx.SDMXExportSession; import org.gcube.portlets.user.td.gwtservice.shared.sdmx.SDMXExportSession;
import org.gcube.portlets.user.td.widgetcommonevent.shared.operations.OperationsId; import org.gcube.portlets.user.td.widgetcommonevent.shared.operations.OperationsId;
import org.gcube.resources.discovery.client.api.DiscoveryClient;
import org.gcube.resources.discovery.client.queries.api.SimpleQuery;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@ -32,14 +27,15 @@ import org.slf4j.LoggerFactory;
* *
*/ */
public class OpExecution4SDMXDatasetExport extends OpExecutionBuilder { public class OpExecution4SDMXDatasetExport extends OpExecutionBuilder {
private static Logger logger = LoggerFactory private static Logger logger = LoggerFactory.getLogger(OpExecution4SDMXDatasetExport.class);
.getLogger(OpExecution4SDMXDatasetExport.class);
private HttpServletRequest httpRequest;
private ServiceCredentials serviceCredentials;
private TabularDataService service; private TabularDataService service;
private SDMXExportSession sdmxExportSession; private SDMXExportSession sdmxExportSession;
public OpExecution4SDMXDatasetExport(TabularDataService service, public OpExecution4SDMXDatasetExport(HttpServletRequest httpRequest, ServiceCredentials serviceCredentials,
SDMXExportSession sdmxExportSession) { TabularDataService service, SDMXExportSession sdmxExportSession) {
this.service = service; this.service = service;
this.sdmxExportSession = sdmxExportSession; this.sdmxExportSession = sdmxExportSession;
} }
@ -52,8 +48,7 @@ public class OpExecution4SDMXDatasetExport extends OpExecutionBuilder {
// http://pc-fortunati.isti.cnr.it:8080/FusionRegistry/ws/rest/ // http://pc-fortunati.isti.cnr.it:8080/FusionRegistry/ws/rest/
if (sdmxExportSession != null) { if (sdmxExportSession != null) {
if (sdmxExportSession.getRegistryBaseUrl() != null if (sdmxExportSession.getRegistryBaseUrl() != null && !sdmxExportSession.getRegistryBaseUrl().isEmpty()) {
&& !sdmxExportSession.getRegistryBaseUrl().isEmpty()) {
destination = sdmxExportSession.getRegistryBaseUrl(); destination = sdmxExportSession.getRegistryBaseUrl();
} else { } else {
internalRegistry = true; internalRegistry = true;
@ -63,28 +58,12 @@ public class OpExecution4SDMXDatasetExport extends OpExecutionBuilder {
} }
if (internalRegistry) { if (internalRegistry) {
SimpleQuery query = queryFor(ServiceEndpoint.class); destination = SessionUtil.getInternalSDMXRegistryURLSession(httpRequest, serviceCredentials);
query.addCondition("$resource/Profile/Category/text() eq 'SDMX'") if (destination == null || destination.isEmpty()) {
.addCondition( destination = ISUtils.retrieveInternalSDMXRegistryURL();
"$resource/Profile/Name/text() eq 'SDMXRegistry'"); if(destination!=null&&!destination.isEmpty()){
DiscoveryClient<ServiceEndpoint> client = clientFor(ServiceEndpoint.class); SessionUtil.setInternalSDMXRegistryURLSession(httpRequest, serviceCredentials, destination);
List<ServiceEndpoint> listService = client.submit(query);
if (listService.size() > 0) {
ServiceEndpoint serviceEnd = listService.get(0);
if (serviceEnd != null) {
Profile prof = serviceEnd.profile();
Group<AccessPoint> groupA = prof.accessPoints();
for (AccessPoint acc : groupA) {
if (acc.description().compareTo("REST Interface v2.1") == 0) {
destination = acc.address();
break;
}
}
} else {
} }
} else {
} }
} }
if (destination == null) { if (destination == null) {
@ -92,8 +71,8 @@ public class OpExecution4SDMXDatasetExport extends OpExecutionBuilder {
throw new TDGWTServiceException("SDMX Service not discovered"); throw new TDGWTServiceException("SDMX Service not discovered");
} }
OperationDefinition operationDefinition = OperationDefinitionMap.map( OperationDefinition operationDefinition = OperationDefinitionMap.map(OperationsId.SDMXDatasetExport.toString(),
OperationsId.SDMXDatasetExport.toString(), service); service);
Map<String, Object> map = new HashMap<String, Object>(); Map<String, Object> map = new HashMap<String, Object>();
@ -103,8 +82,7 @@ public class OpExecution4SDMXDatasetExport extends OpExecutionBuilder {
map.put(Constants.PARAMETER_VERSION, sdmxExportSession.getVersion()); map.put(Constants.PARAMETER_VERSION, sdmxExportSession.getVersion());
map.put(Constants.PARAMETER_OBSVALUECOLUMN, sdmxExportSession.getObsValueColumn().getColumnId()); map.put(Constants.PARAMETER_OBSVALUECOLUMN, sdmxExportSession.getObsValueColumn().getColumnId());
map.put(Constants.PARAMETER_EXCEL, sdmxExportSession.isExcel()); map.put(Constants.PARAMETER_EXCEL, sdmxExportSession.isExcel());
OperationExecution invocation = new OperationExecution( OperationExecution invocation = new OperationExecution(operationDefinition.getOperationId(), map);
operationDefinition.getOperationId(), map);
operationExecutionSpec.setOp(invocation); operationExecutionSpec.setOp(invocation);
} }

View File

@ -1,16 +1,10 @@
package org.gcube.portlets.user.td.gwtservice.server.opexecution; package org.gcube.portlets.user.td.gwtservice.server.opexecution;
import static org.gcube.resources.discovery.icclient.ICFactory.clientFor;
import static org.gcube.resources.discovery.icclient.ICFactory.queryFor;
import java.util.HashMap; import java.util.HashMap;
import java.util.List;
import java.util.Map; import java.util.Map;
import org.gcube.common.resources.gcore.ServiceEndpoint; import javax.servlet.http.HttpServletRequest;
import org.gcube.common.resources.gcore.ServiceEndpoint.AccessPoint;
import org.gcube.common.resources.gcore.ServiceEndpoint.Profile;
import org.gcube.common.resources.gcore.utils.Group;
import org.gcube.data.analysis.tabulardata.commons.templates.model.Template; import org.gcube.data.analysis.tabulardata.commons.templates.model.Template;
import org.gcube.data.analysis.tabulardata.commons.webservice.exception.NoSuchTemplateException; import org.gcube.data.analysis.tabulardata.commons.webservice.exception.NoSuchTemplateException;
import org.gcube.data.analysis.tabulardata.commons.webservice.types.TemplateDescription; import org.gcube.data.analysis.tabulardata.commons.webservice.types.TemplateDescription;
@ -18,13 +12,14 @@ import org.gcube.data.analysis.tabulardata.commons.webservice.types.operations.O
import org.gcube.data.analysis.tabulardata.commons.webservice.types.operations.OperationExecution; import org.gcube.data.analysis.tabulardata.commons.webservice.types.operations.OperationExecution;
import org.gcube.data.analysis.tabulardata.service.TabularDataService; import org.gcube.data.analysis.tabulardata.service.TabularDataService;
import org.gcube.data.analysis.tabulardata.service.template.TemplateId; import org.gcube.data.analysis.tabulardata.service.template.TemplateId;
import org.gcube.portlets.user.td.gwtservice.server.SessionUtil;
import org.gcube.portlets.user.td.gwtservice.server.is.ISUtils;
import org.gcube.portlets.user.td.gwtservice.server.trservice.OperationDefinitionMap; import org.gcube.portlets.user.td.gwtservice.server.trservice.OperationDefinitionMap;
import org.gcube.portlets.user.td.gwtservice.server.util.ServiceCredentials;
import org.gcube.portlets.user.td.gwtservice.shared.Constants; import org.gcube.portlets.user.td.gwtservice.shared.Constants;
import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTServiceException; import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTServiceException;
import org.gcube.portlets.user.td.gwtservice.shared.sdmx.SDMXTemplateExportSession; import org.gcube.portlets.user.td.gwtservice.shared.sdmx.SDMXTemplateExportSession;
import org.gcube.portlets.user.td.widgetcommonevent.shared.operations.OperationsId; import org.gcube.portlets.user.td.widgetcommonevent.shared.operations.OperationsId;
import org.gcube.resources.discovery.client.api.DiscoveryClient;
import org.gcube.resources.discovery.client.queries.api.SimpleQuery;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@ -36,14 +31,15 @@ import org.slf4j.LoggerFactory;
* *
*/ */
public class OpExecution4SDMXTemplateExport extends OpExecutionBuilder { public class OpExecution4SDMXTemplateExport extends OpExecutionBuilder {
private static Logger logger = LoggerFactory private static Logger logger = LoggerFactory.getLogger(OpExecution4SDMXTemplateExport.class);
.getLogger(OpExecution4SDMXTemplateExport.class);
private HttpServletRequest httpRequest;
private ServiceCredentials serviceCredentials;
private TabularDataService service; private TabularDataService service;
private SDMXTemplateExportSession sdmxTemplateExportSession; private SDMXTemplateExportSession sdmxTemplateExportSession;
public OpExecution4SDMXTemplateExport(TabularDataService service, public OpExecution4SDMXTemplateExport(HttpServletRequest httpRequest, ServiceCredentials serviceCredentials,
SDMXTemplateExportSession sdmxTemplateExportSession) { TabularDataService service, SDMXTemplateExportSession sdmxTemplateExportSession) {
this.service = service; this.service = service;
this.sdmxTemplateExportSession = sdmxTemplateExportSession; this.sdmxTemplateExportSession = sdmxTemplateExportSession;
} }
@ -57,8 +53,7 @@ public class OpExecution4SDMXTemplateExport extends OpExecutionBuilder {
if (sdmxTemplateExportSession != null) { if (sdmxTemplateExportSession != null) {
if (sdmxTemplateExportSession.getRegistryBaseUrl() != null if (sdmxTemplateExportSession.getRegistryBaseUrl() != null
&& !sdmxTemplateExportSession.getRegistryBaseUrl() && !sdmxTemplateExportSession.getRegistryBaseUrl().isEmpty()) {
.isEmpty()) {
destination = sdmxTemplateExportSession.getRegistryBaseUrl(); destination = sdmxTemplateExportSession.getRegistryBaseUrl();
} else { } else {
internalRegistry = true; internalRegistry = true;
@ -68,30 +63,15 @@ public class OpExecution4SDMXTemplateExport extends OpExecutionBuilder {
} }
if (internalRegistry) { if (internalRegistry) {
SimpleQuery query = queryFor(ServiceEndpoint.class); destination = SessionUtil.getInternalSDMXRegistryURLSession(httpRequest, serviceCredentials);
query.addCondition("$resource/Profile/Category/text() eq 'SDMX'") if (destination == null || destination.isEmpty()) {
.addCondition( destination = ISUtils.retrieveInternalSDMXRegistryURL();
"$resource/Profile/Name/text() eq 'SDMXRegistry'"); if(destination!=null&&!destination.isEmpty()){
DiscoveryClient<ServiceEndpoint> client = clientFor(ServiceEndpoint.class); SessionUtil.setInternalSDMXRegistryURLSession(httpRequest, serviceCredentials, destination);
List<ServiceEndpoint> listService = client.submit(query);
if (listService.size() > 0) {
ServiceEndpoint serviceEnd = listService.get(0);
if (serviceEnd != null) {
Profile prof = serviceEnd.profile();
Group<AccessPoint> groupA = prof.accessPoints();
for (AccessPoint acc : groupA) {
if (acc.description().compareTo("REST Interface v2.1") == 0) {
destination = acc.address();
break;
}
}
} else {
} }
} else {
} }
} }
if (destination == null) { if (destination == null) {
logger.debug("Destination: " + destination); logger.debug("Destination: " + destination);
throw new TDGWTServiceException("SDMX Service not discovered"); throw new TDGWTServiceException("SDMX Service not discovered");
@ -99,35 +79,29 @@ public class OpExecution4SDMXTemplateExport extends OpExecutionBuilder {
TemplateDescription templateDescriptor; TemplateDescription templateDescriptor;
try { try {
templateDescriptor = service.getTemplate(new TemplateId( templateDescriptor = service
sdmxTemplateExportSession.getTemplateData().getId())); .getTemplate(new TemplateId(sdmxTemplateExportSession.getTemplateData().getId()));
} catch (NoSuchTemplateException e) { } catch (NoSuchTemplateException e) {
logger.debug( logger.debug("Error retrieving template: " + e.getLocalizedMessage(), e);
"Error retrieving template: " + e.getLocalizedMessage(), e); throw new TDGWTServiceException("Error retrieving template: " + e.getLocalizedMessage());
throw new TDGWTServiceException("Error retrieving template: "
+ e.getLocalizedMessage());
} }
OperationDefinition operationDefinition = OperationDefinitionMap.map( OperationDefinition operationDefinition = OperationDefinitionMap.map(OperationsId.SDMXTemplateExport.toString(),
OperationsId.SDMXTemplateExport.toString(), service); service);
HashMap<String,Template> templateMap=new HashMap<String,Template>(); HashMap<String, Template> templateMap = new HashMap<String, Template>();
templateMap.put(Constants.PARAMETER_TEMPLATE,templateDescriptor.getTemplate()); templateMap.put(Constants.PARAMETER_TEMPLATE, templateDescriptor.getTemplate());
Map<String, Object> map = new HashMap<String, Object>(); Map<String, Object> map = new HashMap<String, Object>();
map.put(Constants.PARAMETER_REGISTRYBASEURL, destination); map.put(Constants.PARAMETER_REGISTRYBASEURL, destination);
map.put(Constants.PARAMETER_AGENCY, map.put(Constants.PARAMETER_AGENCY, sdmxTemplateExportSession.getAgencyId());
sdmxTemplateExportSession.getAgencyId());
map.put(Constants.PARAMETER_ID, sdmxTemplateExportSession.getId()); map.put(Constants.PARAMETER_ID, sdmxTemplateExportSession.getId());
map.put(Constants.PARAMETER_VERSION, map.put(Constants.PARAMETER_VERSION, sdmxTemplateExportSession.getVersion());
sdmxTemplateExportSession.getVersion()); map.put(Constants.PARAMETER_OBSVALUECOLUMN, sdmxTemplateExportSession.getObsValueColumn().getColumnId());
map.put(Constants.PARAMETER_OBSVALUECOLUMN, sdmxTemplateExportSession
.getObsValueColumn().getColumnId());
map.put(Constants.PARAMETER_EXCEL, sdmxTemplateExportSession.isExcel()); map.put(Constants.PARAMETER_EXCEL, sdmxTemplateExportSession.isExcel());
map.put(Constants.PARAMETER_TEMPLATE, templateMap); map.put(Constants.PARAMETER_TEMPLATE, templateMap);
OperationExecution invocation = new OperationExecution( OperationExecution invocation = new OperationExecution(operationDefinition.getOperationId(), map);
operationDefinition.getOperationId(), map);
operationExecutionSpec.setOp(invocation); operationExecutionSpec.setOp(invocation);
} }