From b454b07d2d89282ce547a759e24410454dba7e2d Mon Sep 17 00:00:00 2001 From: Giancarlo Panichi Date: Mon, 15 Jun 2015 16:27:31 +0000 Subject: [PATCH] 209: TDM - Show the resources through a ListView widget Task-Url: https://support.d4science.org/issues/209 Updated name of resources support git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-gwt-service@115403 82a268e6-3cf1-43bd-a215-b396298e98cf --- .../gwtservice/server/TDGWTServiceImpl.java | 35 ++++++++++++++++--- .../opexecution/OpExecution4CSVExport.java | 29 +++++++-------- .../opexecution/OpExecution4JSONExport.java | 4 +++ .../server/social/TDMNotifications.java | 22 +++++++----- .../user/td/gwtservice/shared/Constants.java | 3 ++ .../BackgroundOperationMonitorCreator.java | 4 +-- .../monitor/OperationMonitorCreator.java | 4 +-- 7 files changed, 70 insertions(+), 31 deletions(-) diff --git a/src/main/java/org/gcube/portlets/user/td/gwtservice/server/TDGWTServiceImpl.java b/src/main/java/org/gcube/portlets/user/td/gwtservice/server/TDGWTServiceImpl.java index 41130ed..88a4152 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 @@ -9073,16 +9073,29 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements "This resource does not have valid storage id: " + storageId); } + + MimeTypeSupport mime=saveResourceSession.getMime(); + String fileName=""; + + if(mime==null|| mime.compareTo(MimeTypeSupport._unknow)==0){ + fileName=saveResourceSession.getFileName(); + } else { + fileName=saveResourceSession.getFileName()+ + mime.getExtension(); + } + + logger.debug("Create Item On Workspace: [storageId=" + storageId + " ,user: " + aslSession.getUsername() + " ,fileName: " - + saveResourceSession.getFileName() + " ,fileDescription: " + + fileName + " ,fileDescription: " + saveResourceSession.getFileDescription() + " ,mimetype:" + mimeType + " ,folder: " + saveResourceSession.getItemId() + "]"); - + + FilesStorage storage = new FilesStorage(); storage.createItemOnWorkspaceByStorageId(storageId, - aslSession.getUsername(), saveResourceSession.getFileName(), + aslSession.getUsername(), fileName, saveResourceSession.getFileDescription(), mimeType, saveResourceSession.getItemId()); } @@ -9125,16 +9138,28 @@ public class TDGWTServiceImpl extends RemoteServiceServlet implements throw new TDGWTServiceException( "This resource does not have valid link: " + link); } + + MimeTypeSupport mime=saveResourceSession.getMime(); + String fileName=""; + + if(mime==null|| mime.compareTo(MimeTypeSupport._unknow)==0){ + fileName=saveResourceSession.getFileName(); + } else { + fileName=saveResourceSession.getFileName()+ + mime.getExtension(); + } + + logger.debug("Create Item On Workspace: [uri=" + link + " ,user: " + aslSession.getUsername() + " ,fileName: " - + saveResourceSession.getFileName() + " ,fileDescription: " + + fileName + " ,fileDescription: " + saveResourceSession.getFileDescription() + " ,mimetype:" + mimeType + " ,folder: " + saveResourceSession.getItemId() + "]"); FilesStorage storage = new FilesStorage(); storage.createItemOnWorkspace(link, aslSession.getUsername(), - saveResourceSession.getFileName(), + fileName, saveResourceSession.getFileDescription(), mimeType, saveResourceSession.getItemId()); } diff --git a/src/main/java/org/gcube/portlets/user/td/gwtservice/server/opexecution/OpExecution4CSVExport.java b/src/main/java/org/gcube/portlets/user/td/gwtservice/server/opexecution/OpExecution4CSVExport.java index 7d070ea..90b31a7 100644 --- a/src/main/java/org/gcube/portlets/user/td/gwtservice/server/opexecution/OpExecution4CSVExport.java +++ b/src/main/java/org/gcube/portlets/user/td/gwtservice/server/opexecution/OpExecution4CSVExport.java @@ -32,37 +32,38 @@ public class OpExecution4CSVExport extends OpExecutionBuilder { private TabularDataService service; private CSVExportSession csvExportSession; - - public OpExecution4CSVExport(HttpSession session, TabularDataService service, - CSVExportSession csvExportSession) { + public OpExecution4CSVExport(HttpSession session, + TabularDataService service, CSVExportSession csvExportSession) { this.service = service; this.csvExportSession = csvExportSession; - this.session=session; + this.session = session; } @Override public void buildOpEx() throws TDGWTServiceException { - logger.debug("CSV Export: "+csvExportSession); - + logger.debug("CSV Export: " + csvExportSession); + SessionUtil.setCSVExportEnd(session, false); - + OperationDefinition operationDefinition; operationDefinition = OperationDefinitionMap.map( OperationsId.CSVExport.toString(), service); Map map = new HashMap(); - - map.put(Constants.PARAMETER_ENCODING, - csvExportSession.getEncoding()); - map.put(Constants.PARAMETER_SEPARATOR, - csvExportSession.getSeparator()); + + map.put(Constants.PARAMETER_RESOURCE_NAME, + csvExportSession.getFileName()); + map.put(Constants.PARAMETER_RESOURCE_DESCRIPTION, + csvExportSession.getFileDescription()); + map.put(Constants.PARAMETER_ENCODING, csvExportSession.getEncoding()); + map.put(Constants.PARAMETER_SEPARATOR, csvExportSession.getSeparator()); map.put(Constants.PARAMETER_VIEW_COLUMNS, csvExportSession.isExportViewColumns()); map.put(Constants.PARAMETER_COLUMNS, csvExportSession.getColumnsAsString()); - + OperationExecution invocation = new OperationExecution( operationDefinition.getOperationId(), map); - + operationExecutionSpec.setOp(invocation); } diff --git a/src/main/java/org/gcube/portlets/user/td/gwtservice/server/opexecution/OpExecution4JSONExport.java b/src/main/java/org/gcube/portlets/user/td/gwtservice/server/opexecution/OpExecution4JSONExport.java index 7d0669a..0d78e8a 100644 --- a/src/main/java/org/gcube/portlets/user/td/gwtservice/server/opexecution/OpExecution4JSONExport.java +++ b/src/main/java/org/gcube/portlets/user/td/gwtservice/server/opexecution/OpExecution4JSONExport.java @@ -51,6 +51,10 @@ public class OpExecution4JSONExport extends OpExecutionBuilder { OperationsId.JSONExport.toString(), service); Map map = new HashMap(); + map.put(Constants.PARAMETER_RESOURCE_NAME, jsonExportSession.getFileName()); + + map.put(Constants.PARAMETER_RESOURCE_DESCRIPTION, jsonExportSession.getFileDescription()); + map.put(Constants.PARAMETER_VIEW_COLUMNS, jsonExportSession.isExportViewColumns()); map.put(Constants.PARAMETER_COLUMNS, diff --git a/src/main/java/org/gcube/portlets/user/td/gwtservice/server/social/TDMNotifications.java b/src/main/java/org/gcube/portlets/user/td/gwtservice/server/social/TDMNotifications.java index dbeb6f8..8662802 100644 --- a/src/main/java/org/gcube/portlets/user/td/gwtservice/server/social/TDMNotifications.java +++ b/src/main/java/org/gcube/portlets/user/td/gwtservice/server/social/TDMNotifications.java @@ -16,7 +16,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** - * TDMNotification notification sharing TR, templates or rules + * TDMNotification notification sharing TR, templates or rules * * @author giancarlo email: g.panichi@isti.cnr.it @@ -44,7 +44,7 @@ public class TDMNotifications extends Thread { this.notificationType = NotificationType.TDM_TAB_RESOURCE_SHARE; } - + /** * * @param aslSession @@ -107,7 +107,8 @@ public class TDMNotifications extends Thread { .getTrId().getId())); } catch (Exception e) { - logger.error("Error in the notification(" + logger.error("Error in the notification(Type: " + + notificationType + " - " + aslSession.getUsername() + " share tabular resource id=" + shareTabularResource.getTabResource() @@ -135,7 +136,8 @@ public class TDMNotifications extends Thread { .getTrId().getId())); } catch (Exception e) { - logger.error("Error in the notification(" + logger.error("Error in the notification(Type: " + + notificationType + " - " + aslSession.getUsername() + " share tabular resource id=" + shareTabularResource.getTabResource().getTrId() @@ -165,7 +167,8 @@ public class TDMNotifications extends Thread { .getName(), null); } catch (Exception e) { - logger.error("Error in the notification(" + logger.error("Error in the notification(Type: " + + notificationType + " - " + aslSession.getUsername() + " share rule id=" + shareRule.getRuleDescriptionData() @@ -190,7 +193,8 @@ public class TDMNotifications extends Thread { .getRuleDescriptionData().getName(), null); } catch (Exception e) { - logger.error("Error in the notification(" + logger.error("Error in the notification(Type: " + + notificationType + " - " + aslSession.getUsername() + " share rule id=" + shareRule.getRuleDescriptionData().getId() + " with " + contact.getLogin() + "): " @@ -220,7 +224,8 @@ public class TDMNotifications extends Thread { null); } catch (Exception e) { - logger.error("Error in the notification(" + logger.error("Error in the notification(Type: " + + notificationType + " - " + aslSession.getUsername() + " share template id=" + shareTemplate.getTemplateData().getId() @@ -245,7 +250,8 @@ public class TDMNotifications extends Thread { .getName(), null); } catch (Exception e) { - logger.error("Error in the notification(" + logger.error("Error in the notification(Type: " + + notificationType + " - " + aslSession.getUsername() + " share template id=" + shareTemplate.getTemplateData().getId() + " with " + contact.getLogin() + "): " diff --git a/src/main/java/org/gcube/portlets/user/td/gwtservice/shared/Constants.java b/src/main/java/org/gcube/portlets/user/td/gwtservice/shared/Constants.java index abffefa..28dbab1 100644 --- a/src/main/java/org/gcube/portlets/user/td/gwtservice/shared/Constants.java +++ b/src/main/java/org/gcube/portlets/user/td/gwtservice/shared/Constants.java @@ -124,5 +124,8 @@ public class Constants { public static final String PARAMETER_EXPRESSION_VALIDATION_TITLE = "title"; public static final String PARAMETER_CHANGE_COLUMN_POSITION_ORDER = "order"; + + public static final String PARAMETER_RESOURCE_NAME = "name"; + public static final String PARAMETER_RESOURCE_DESCRIPTION = "description"; } diff --git a/src/main/java/org/gcube/portlets/user/td/gwtservice/shared/monitor/BackgroundOperationMonitorCreator.java b/src/main/java/org/gcube/portlets/user/td/gwtservice/shared/monitor/BackgroundOperationMonitorCreator.java index ef28435..1654fa4 100644 --- a/src/main/java/org/gcube/portlets/user/td/gwtservice/shared/monitor/BackgroundOperationMonitorCreator.java +++ b/src/main/java/org/gcube/portlets/user/td/gwtservice/shared/monitor/BackgroundOperationMonitorCreator.java @@ -422,7 +422,7 @@ public class BackgroundOperationMonitorCreator { FilesStorage storage = new FilesStorage(); storage.createItemOnWorkspaceByStorageId(exportMetadata.getUri(), user, - exportSession.getFileName(), + exportSession.getFileName()+".csv", exportSession.getFileDescription(), "text/csv", exportSession.getItemId()); @@ -471,7 +471,7 @@ public class BackgroundOperationMonitorCreator { FilesStorage storage = new FilesStorage(); storage.createItemOnWorkspaceByStorageId(exportMetadata.getUri(), user, - exportSession.getFileName(), + exportSession.getFileName()+".json", exportSession.getFileDescription(), "application/json", exportSession.getItemId()); diff --git a/src/main/java/org/gcube/portlets/user/td/gwtservice/shared/monitor/OperationMonitorCreator.java b/src/main/java/org/gcube/portlets/user/td/gwtservice/shared/monitor/OperationMonitorCreator.java index fa52e24..daa0bb5 100644 --- a/src/main/java/org/gcube/portlets/user/td/gwtservice/shared/monitor/OperationMonitorCreator.java +++ b/src/main/java/org/gcube/portlets/user/td/gwtservice/shared/monitor/OperationMonitorCreator.java @@ -477,7 +477,7 @@ public class OperationMonitorCreator { FilesStorage storage = new FilesStorage(); storage.createItemOnWorkspaceByStorageId(exportMetadata.getUri(), user, - exportSession.getFileName(), + exportSession.getFileName()+".csv", exportSession.getFileDescription(), "text/csv", exportSession.getItemId()); @@ -526,7 +526,7 @@ public class OperationMonitorCreator { FilesStorage storage = new FilesStorage(); storage.createItemOnWorkspaceByStorageId(exportMetadata.getUri(), user, - exportSession.getFileName(), + exportSession.getFileName()+".json", exportSession.getFileDescription(), "application/json", exportSession.getItemId());