From 4c4beffdf1cec67439156769de83f42d5aa2dda0 Mon Sep 17 00:00:00 2001 From: Giancarlo Panichi Date: Thu, 24 Oct 2013 10:21:28 +0000 Subject: [PATCH] Change Component Name on SVN git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-gwt-service@83962 82a268e6-3cf1-43bd-a215-b396298e98cf --- GXTServiceTest-dev.launch | 22 + GXTServiceTest-prod.launch | 22 + pom.xml | 354 ++++++++ .../td/gxtservice/client/GXTServiceEntry.java | 13 + .../gxtservice/client/rpc/TDGXTService.java | 80 ++ .../client/rpc/TDGXTServiceAsync.java | 79 ++ .../server/CSVImportFileServlet.java | 87 ++ .../gxtservice/server/LocalUploadServlet.java | 152 ++++ .../user/td/gxtservice/server/SDMXClient.java | 83 ++ .../td/gxtservice/server/SessionUtil.java | 365 ++++++++ .../gxtservice/server/TDGXTServiceImpl.java | 791 ++++++++++++++++++ .../server/file/FileUploadListener.java | 31 + .../server/file/FileUploadSession.java | 103 +++ .../td/gxtservice/server/file/FileUtil.java | 119 +++ .../server/storage/FilesStorage.java | 20 + .../server/trservice/OperationsId.java | 93 ++ .../server/trservice/TRTasksManager.java | 27 + .../user/td/gxtservice/shared/Agencies.java | 83 ++ .../user/td/gxtservice/shared/Codelist.java | 95 +++ .../user/td/gxtservice/shared/Constants.java | 16 + .../gxtservice/shared/ConstantsWorkspace.java | 23 + .../user/td/gxtservice/shared/Dataset.java | 93 ++ .../td/gxtservice/shared/FieldVerifier.java | 42 + .../shared/TDGXTServiceException.java | 30 + .../td/gxtservice/shared/TDOpenSession.java | 49 ++ .../user/td/gxtservice/shared/TRId.java | 76 ++ .../td/gxtservice/shared/TabResource.java | 104 +++ .../shared/csv/AvailableCharsetList.java | 45 + .../td/gxtservice/shared/csv/CSVFileUtil.java | 191 +++++ .../shared/csv/CSVImportMonitor.java | 105 +++ .../shared/csv/CSVImportSession.java | 137 +++ .../gxtservice/shared/csv/CSVImportState.java | 32 + .../shared/csv/CSVParserConfiguration.java | 91 ++ .../td/gxtservice/shared/csv/CSVRowError.java | 80 ++ .../shared/document/CodelistDocument.java | 59 ++ .../shared/document/DatasetDocument.java | 60 ++ .../shared/document/SDMXDocument.java | 38 + .../shared/file/FileUploadMonitor.java | 116 +++ .../shared/file/FileUploadState.java | 28 + .../shared/file/HeaderPresence.java | 39 + .../shared/sdmx/SDMXImportMonitor.java | 77 ++ .../shared/sdmx/SDMXImportSession.java | 75 ++ .../user/td/gxtservice/shared/sdmx/State.java | 15 + .../gxtservice/shared/source/FileSource.java | 55 ++ .../shared/source/SDMXRegistrySource.java | 70 ++ .../td/gxtservice/shared/source/Source.java | 27 + .../shared/source/WorkspaceSource.java | 56 ++ .../user/td/gxtservice/GXTService.gwt.xml | 29 + .../td/gxtservice/client/Messages.properties | 2 + .../gxtservice/client/Messages_fr.properties | 2 + src/main/webapp/GXTService.css | 34 + src/main/webapp/GXTService.html | 50 ++ src/main/webapp/WEB-INF/web.xml | 58 ++ .../gxtservice/client/GwtTestGXTService.java | 76 ++ .../td/gxtservice/GXTServiceJUnit.gwt.xml | 14 + templates/INSTALL | 0 templates/LICENSE | 6 + templates/MAINTAINERS | 1 + templates/README | 40 + templates/changelog.xml | 6 + templates/descriptor.xml | 39 + templates/profile.xml | 29 + templates/svnpath.txt | 1 + 63 files changed, 4835 insertions(+) create mode 100644 GXTServiceTest-dev.launch create mode 100644 GXTServiceTest-prod.launch create mode 100644 pom.xml create mode 100644 src/main/java/org/gcube/portlets/user/td/gxtservice/client/GXTServiceEntry.java create mode 100644 src/main/java/org/gcube/portlets/user/td/gxtservice/client/rpc/TDGXTService.java create mode 100644 src/main/java/org/gcube/portlets/user/td/gxtservice/client/rpc/TDGXTServiceAsync.java create mode 100644 src/main/java/org/gcube/portlets/user/td/gxtservice/server/CSVImportFileServlet.java create mode 100644 src/main/java/org/gcube/portlets/user/td/gxtservice/server/LocalUploadServlet.java create mode 100644 src/main/java/org/gcube/portlets/user/td/gxtservice/server/SDMXClient.java create mode 100644 src/main/java/org/gcube/portlets/user/td/gxtservice/server/SessionUtil.java create mode 100644 src/main/java/org/gcube/portlets/user/td/gxtservice/server/TDGXTServiceImpl.java create mode 100644 src/main/java/org/gcube/portlets/user/td/gxtservice/server/file/FileUploadListener.java create mode 100644 src/main/java/org/gcube/portlets/user/td/gxtservice/server/file/FileUploadSession.java create mode 100644 src/main/java/org/gcube/portlets/user/td/gxtservice/server/file/FileUtil.java create mode 100644 src/main/java/org/gcube/portlets/user/td/gxtservice/server/storage/FilesStorage.java create mode 100644 src/main/java/org/gcube/portlets/user/td/gxtservice/server/trservice/OperationsId.java create mode 100644 src/main/java/org/gcube/portlets/user/td/gxtservice/server/trservice/TRTasksManager.java create mode 100644 src/main/java/org/gcube/portlets/user/td/gxtservice/shared/Agencies.java create mode 100644 src/main/java/org/gcube/portlets/user/td/gxtservice/shared/Codelist.java create mode 100644 src/main/java/org/gcube/portlets/user/td/gxtservice/shared/Constants.java create mode 100644 src/main/java/org/gcube/portlets/user/td/gxtservice/shared/ConstantsWorkspace.java create mode 100644 src/main/java/org/gcube/portlets/user/td/gxtservice/shared/Dataset.java create mode 100644 src/main/java/org/gcube/portlets/user/td/gxtservice/shared/FieldVerifier.java create mode 100644 src/main/java/org/gcube/portlets/user/td/gxtservice/shared/TDGXTServiceException.java create mode 100644 src/main/java/org/gcube/portlets/user/td/gxtservice/shared/TDOpenSession.java create mode 100644 src/main/java/org/gcube/portlets/user/td/gxtservice/shared/TRId.java create mode 100644 src/main/java/org/gcube/portlets/user/td/gxtservice/shared/TabResource.java create mode 100644 src/main/java/org/gcube/portlets/user/td/gxtservice/shared/csv/AvailableCharsetList.java create mode 100644 src/main/java/org/gcube/portlets/user/td/gxtservice/shared/csv/CSVFileUtil.java create mode 100644 src/main/java/org/gcube/portlets/user/td/gxtservice/shared/csv/CSVImportMonitor.java create mode 100644 src/main/java/org/gcube/portlets/user/td/gxtservice/shared/csv/CSVImportSession.java create mode 100644 src/main/java/org/gcube/portlets/user/td/gxtservice/shared/csv/CSVImportState.java create mode 100644 src/main/java/org/gcube/portlets/user/td/gxtservice/shared/csv/CSVParserConfiguration.java create mode 100644 src/main/java/org/gcube/portlets/user/td/gxtservice/shared/csv/CSVRowError.java create mode 100644 src/main/java/org/gcube/portlets/user/td/gxtservice/shared/document/CodelistDocument.java create mode 100644 src/main/java/org/gcube/portlets/user/td/gxtservice/shared/document/DatasetDocument.java create mode 100644 src/main/java/org/gcube/portlets/user/td/gxtservice/shared/document/SDMXDocument.java create mode 100644 src/main/java/org/gcube/portlets/user/td/gxtservice/shared/file/FileUploadMonitor.java create mode 100644 src/main/java/org/gcube/portlets/user/td/gxtservice/shared/file/FileUploadState.java create mode 100644 src/main/java/org/gcube/portlets/user/td/gxtservice/shared/file/HeaderPresence.java create mode 100644 src/main/java/org/gcube/portlets/user/td/gxtservice/shared/sdmx/SDMXImportMonitor.java create mode 100644 src/main/java/org/gcube/portlets/user/td/gxtservice/shared/sdmx/SDMXImportSession.java create mode 100644 src/main/java/org/gcube/portlets/user/td/gxtservice/shared/sdmx/State.java create mode 100644 src/main/java/org/gcube/portlets/user/td/gxtservice/shared/source/FileSource.java create mode 100644 src/main/java/org/gcube/portlets/user/td/gxtservice/shared/source/SDMXRegistrySource.java create mode 100644 src/main/java/org/gcube/portlets/user/td/gxtservice/shared/source/Source.java create mode 100644 src/main/java/org/gcube/portlets/user/td/gxtservice/shared/source/WorkspaceSource.java create mode 100644 src/main/resources/org/gcube/portlets/user/td/gxtservice/GXTService.gwt.xml create mode 100644 src/main/resources/org/gcube/portlets/user/td/gxtservice/client/Messages.properties create mode 100644 src/main/resources/org/gcube/portlets/user/td/gxtservice/client/Messages_fr.properties create mode 100644 src/main/webapp/GXTService.css create mode 100644 src/main/webapp/GXTService.html create mode 100644 src/main/webapp/WEB-INF/web.xml create mode 100644 src/test/java/org/gcube/portlets/user/td/gxtservice/client/GwtTestGXTService.java create mode 100644 src/test/resources/org/gcube/portlets/user/td/gxtservice/GXTServiceJUnit.gwt.xml create mode 100644 templates/INSTALL create mode 100644 templates/LICENSE create mode 100644 templates/MAINTAINERS create mode 100644 templates/README create mode 100644 templates/changelog.xml create mode 100644 templates/descriptor.xml create mode 100644 templates/profile.xml create mode 100644 templates/svnpath.txt diff --git a/GXTServiceTest-dev.launch b/GXTServiceTest-dev.launch new file mode 100644 index 0000000..4b40850 --- /dev/null +++ b/GXTServiceTest-dev.launch @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/GXTServiceTest-prod.launch b/GXTServiceTest-prod.launch new file mode 100644 index 0000000..9147bd8 --- /dev/null +++ b/GXTServiceTest-prod.launch @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..24f07f3 --- /dev/null +++ b/pom.xml @@ -0,0 +1,354 @@ + + + + + maven-parent + org.gcube.tools + 1.0.0 + + + + + + 4.0.0 + org.gcube.portlets.user + tabular-data-gwt-service + 1.0.0-SNAPSHOT + + tabular-data-gwt-service + tabular-data-gwt-service allows communication between the GUI and services + + + https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-gxtservice + + + + + Giancarlo Panichi + g.panichi@isti.cnr.it + CNR Pisa, Istituto di Scienza e Tecnologie dell'Informazione "A. Faedo" + + architect + developer + + + + + + ${project.basedir}/distro + ${project.build.directory}/${project.build.finalName} + 2013-10-18 + templates + distro + config + + + 2.5.1 + + ${env.GLOBUS_LOCATION} + + UTF-8 + UTF-8 + + + + + + + localRun + + + org.slf4j + slf4j-api + compile + + + ch.qos.logback + logback-classic + 1.0.1 + runtime + + + + + + + + com.google.gwt + gwt-servlet + + + com.google.gwt + gwt-user + + + + junit + junit + 4.7 + test + + + javax.validation + validation-api + 1.0.0.GA + test + + + javax.validation + validation-api + 1.0.0.GA + sources + test + + + + com.sencha.gxt + gxt + 3.0.1 + + + + org.gcube.data.publishing + sdmx-registry-client-gcube + [3.0.0-SNAPSHOT,4.0.0-SNAPSHOT) + + + + org.gcube.applicationsupportlayer + aslcore + provided + + + + org.gcube.portal + custom-portal-handler + + + + + + commons-io + commons-io + + + commons-fileupload + commons-fileupload + + + + com.googlecode.juniversalchardet + juniversalchardet + 1.0.3 + + + + + org.gcube.common + csv4j + [1.2.0-SNAPSHOT, 2.0.0-common) + + + + + org.gcube.data.analysis.tabulardata + service-client-mock + [1.0.0-SNAPSHOT,2.0.0-SNAPSHOT) + + + + + + + org.gcube.contentmanagement + storage-manager-core + [2.0.0-SNAPSHOT, 3.0.0-SNAPSHOT) + + + org.gcube.contentmanagement + storage-manager-wrapper + [2.0.0-SNAPSHOT, 3.0.0-SNAPSHOT) + + + + + com.allen-sauer.gwt.log + gwt-log + + + + org.slf4j + slf4j-api + + + + + + + junit + junit + 4.8.1 + test + + + + + + + + + ${webappDirectory}/WEB-INF/classes + + + + org.apache.maven.plugins + maven-surefire-plugin + 2.16 + + true + + + + + org.apache.maven.surefire + surefire-junit47 + 2.16 + + + + + + + org.codehaus.mojo + gwt-maven-plugin + ${gwtVersion} + + + + resources + + + + + GXTService.html + ${webappDirectory} + org.gcube.portlets.user.td.gxtservice.GXTService + + + + + + maven-resources-plugin + 2.6 + + + copy-profile + process-resources + + copy-resources + + + ${configDirectory} + + + ${templatesDirectory} + + profile.xml + + true + + + + + + copy-distro-resources + process-resources + + copy-resources + + + ${distroDirectory} + + + ${templatesDirectory} + + profile.xml + descriptor.xml + + true + + + + + + + + maven-clean-plugin + 2.5 + + + + ${distroDirectory} + + ** + + false + + + ${configDirectory} + + ** + + false + + + + + + org.apache.maven.plugins + maven-assembly-plugin + 2.2 + + + ${templatesDirectory}/descriptor.xml + + + + + servicearchive + package + + single + + + + + + + + + + + + + org.gcube.distribution + maven-portal-bom + LATEST + pom + import + + + + diff --git a/src/main/java/org/gcube/portlets/user/td/gxtservice/client/GXTServiceEntry.java b/src/main/java/org/gcube/portlets/user/td/gxtservice/client/GXTServiceEntry.java new file mode 100644 index 0000000..bcd8991 --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/td/gxtservice/client/GXTServiceEntry.java @@ -0,0 +1,13 @@ +package org.gcube.portlets.user.td.gxtservice.client; + +import com.google.gwt.core.client.EntryPoint; + +public class GXTServiceEntry implements EntryPoint { + + @Override + public void onModuleLoad() { + + + + } +} diff --git a/src/main/java/org/gcube/portlets/user/td/gxtservice/client/rpc/TDGXTService.java b/src/main/java/org/gcube/portlets/user/td/gxtservice/client/rpc/TDGXTService.java new file mode 100644 index 0000000..27079f1 --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/td/gxtservice/client/rpc/TDGXTService.java @@ -0,0 +1,80 @@ +/** + * + */ +package org.gcube.portlets.user.td.gxtservice.client.rpc; + + + +import java.util.ArrayList; +import java.util.List; + + + +import org.gcube.portlets.user.td.gxtservice.shared.Agencies; +import org.gcube.portlets.user.td.gxtservice.shared.Codelist; +import org.gcube.portlets.user.td.gxtservice.shared.Dataset; +import org.gcube.portlets.user.td.gxtservice.shared.csv.AvailableCharsetList; +import org.gcube.portlets.user.td.gxtservice.shared.csv.CSVImportMonitor; +import org.gcube.portlets.user.td.gxtservice.shared.csv.CSVImportSession; +import org.gcube.portlets.user.td.gxtservice.shared.csv.CSVRowError; +import org.gcube.portlets.user.td.gxtservice.shared.file.FileUploadMonitor; +import org.gcube.portlets.user.td.gxtservice.shared.file.HeaderPresence; +import org.gcube.portlets.user.td.gxtservice.shared.sdmx.SDMXImportMonitor; +import org.gcube.portlets.user.td.gxtservice.shared.sdmx.SDMXImportSession; +import org.gcube.portlets.user.td.gxtservice.shared.TDGXTServiceException; +import org.gcube.portlets.user.td.gxtservice.shared.TDOpenSession; +import org.gcube.portlets.user.td.gxtservice.shared.TabResource; + +import com.google.gwt.user.client.rpc.RemoteService; +import com.google.gwt.user.client.rpc.RemoteServiceRelativePath; + +/** + * + * @author "Giancarlo Panichi" g.panichi@isti.cnr.it + * + */ +@RemoteServiceRelativePath("TDGXTService") +public interface TDGXTService extends RemoteService { + + public TabResource getTabResource() throws TDGXTServiceException; + + public void setTabResource(TabResource tr) throws TDGXTServiceException; + + public List getTabularResources() throws TDGXTServiceException; + + public TabResource createTabularResource(TabResource tabResource) throws TDGXTServiceException; + + //Open + public void setTDOpenSession(TDOpenSession s) throws TDGXTServiceException; + + //Import SDMX + public ArrayList getCodelists() throws TDGXTServiceException; + + public ArrayList getDatasets() throws TDGXTServiceException; + + public ArrayList getAgencies() throws TDGXTServiceException; + + public void setSDMXSession(SDMXImportSession s) throws TDGXTServiceException; + + public SDMXImportMonitor getSDMXImportMonitor() throws TDGXTServiceException; + + public void importSDMXClientLibraryRequest(SDMXImportSession s) throws TDGXTServiceException; + + //Import CSV + public FileUploadMonitor getFileUploadMonitor() throws TDGXTServiceException; + + public CSVImportMonitor getCSVImportMonitor() throws TDGXTServiceException; + + public void setCSVSession(CSVImportSession s) throws TDGXTServiceException; + + + public AvailableCharsetList getAvailableCharset() throws TDGXTServiceException; + + public ArrayList configureCSVParser(String encoding, HeaderPresence headerPresence, char delimiter, char comment) throws TDGXTServiceException; + + public ArrayList checkCSV(long errorsLimit) throws TDGXTServiceException; + + public void startCSVImport(boolean[] columnToImportMask) throws TDGXTServiceException; + +} diff --git a/src/main/java/org/gcube/portlets/user/td/gxtservice/client/rpc/TDGXTServiceAsync.java b/src/main/java/org/gcube/portlets/user/td/gxtservice/client/rpc/TDGXTServiceAsync.java new file mode 100644 index 0000000..1ef8a7f --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/td/gxtservice/client/rpc/TDGXTServiceAsync.java @@ -0,0 +1,79 @@ +/** + * + */ +package org.gcube.portlets.user.td.gxtservice.client.rpc; + +import java.util.ArrayList; +import java.util.List; + +import org.gcube.portlets.user.td.gxtservice.shared.Agencies; +import org.gcube.portlets.user.td.gxtservice.shared.Codelist; +import org.gcube.portlets.user.td.gxtservice.shared.Dataset; +import org.gcube.portlets.user.td.gxtservice.shared.TDOpenSession; +import org.gcube.portlets.user.td.gxtservice.shared.TabResource; +import org.gcube.portlets.user.td.gxtservice.shared.csv.AvailableCharsetList; +import org.gcube.portlets.user.td.gxtservice.shared.csv.CSVImportMonitor; +import org.gcube.portlets.user.td.gxtservice.shared.csv.CSVImportSession; +import org.gcube.portlets.user.td.gxtservice.shared.csv.CSVRowError; +import org.gcube.portlets.user.td.gxtservice.shared.file.FileUploadMonitor; +import org.gcube.portlets.user.td.gxtservice.shared.file.HeaderPresence; +import org.gcube.portlets.user.td.gxtservice.shared.sdmx.SDMXImportMonitor; +import org.gcube.portlets.user.td.gxtservice.shared.sdmx.SDMXImportSession; + +import com.google.gwt.core.client.GWT; +import com.google.gwt.user.client.rpc.AsyncCallback; + +/** + * + * @author "Giancarlo Panichi" g.panichi@isti.cnr.it + * + */ + +public interface TDGXTServiceAsync { + + public TDGXTServiceAsync INSTANCE = GWT + .create(TDGXTService.class); + + void createTabularResource(TabResource tabResource,AsyncCallback callback); + + void getTabResource(AsyncCallback callback); + + void setTabResource(TabResource tabResource, AsyncCallback callback); + + void getTabularResources(AsyncCallback> callback); + + //Open + void setTDOpenSession(TDOpenSession s, AsyncCallback callback); + + //Import SDMX + void getCodelists(AsyncCallback> callback); + + void getDatasets(AsyncCallback> callback); + + void getAgencies(AsyncCallback> callback); + + void setSDMXSession(SDMXImportSession s, AsyncCallback callback); + + void getSDMXImportMonitor(AsyncCallback callback); + + void importSDMXClientLibraryRequest(SDMXImportSession s,AsyncCallback callback); + + //Import CSV + void getFileUploadMonitor(AsyncCallback callback); + + void getCSVImportMonitor(AsyncCallback callback); + + void setCSVSession(CSVImportSession s, AsyncCallback callback); + + + void getAvailableCharset(AsyncCallback callback); + + void configureCSVParser(String encoding, HeaderPresence headerPresence, char delimiter, char comment, AsyncCallback> callback); + + void checkCSV(long errorsLimit, AsyncCallback > callback); + + void startCSVImport(boolean[] columnToImportMask, AsyncCallback callback); + + +} diff --git a/src/main/java/org/gcube/portlets/user/td/gxtservice/server/CSVImportFileServlet.java b/src/main/java/org/gcube/portlets/user/td/gxtservice/server/CSVImportFileServlet.java new file mode 100644 index 0000000..1fd73f0 --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/td/gxtservice/server/CSVImportFileServlet.java @@ -0,0 +1,87 @@ +/** + * + */ +package org.gcube.portlets.user.td.gxtservice.server; + +import java.io.ByteArrayOutputStream; +import java.io.FileInputStream; +import java.io.IOException; +import java.nio.charset.Charset; + +import javax.servlet.ServletException; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.servlet.http.HttpSession; + + +import org.gcube.portlets.user.td.gxtservice.server.file.FileUploadSession; +import org.gcube.portlets.user.td.gxtservice.shared.csv.CSVFileUtil; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + + +/** + * + * @author "Giancarlo Panichi" + * g.panichi@isti.cnr.it + * + */ +public class CSVImportFileServlet extends HttpServlet { + + protected static Logger logger = LoggerFactory.getLogger(CSVImportFileServlet.class); + + /** + * + */ + private static final long serialVersionUID = -4197748678713054285L; + + protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { + handleRequest(req, resp); + } + + protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { + handleRequest(req, resp); + } + + protected void handleRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { + + logger.info("CSVImportFileServlet"); + long startTime = System.currentTimeMillis(); + + + HttpSession session = request.getSession(); + + if(session==null){ + logger.error("Error getting the upload session, no session valid found: "+session); + response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "ERROR-Error getting the user session, no session found"+session); + return ; + } + logger.info("CSVImportFileServlet import session id: "+session.getId()); + + FileUploadSession fileUploadSession=SessionUtil.getFileUploadSession(session); + + if (fileUploadSession == null) + { + logger.error("Error getting the upload session, no fileUploadSession found: "+fileUploadSession); + response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "ERROR-Error getting the user session, no fileUploadSession found: "+fileUploadSession); + return ; + } + + response.setContentType("application/json; charset=utf-8"); + Charset outputCharset = Charset.forName("Utf-8"); + + ByteArrayOutputStream os = new ByteArrayOutputStream(); + CSVFileUtil.toJson(new FileInputStream(fileUploadSession.getCsvFile()), os, outputCharset, fileUploadSession.getParserConfiguration(), 100); + + logger.trace("json: "+os.toString()); + System.out.println("json: "+os.toString()); + response.getOutputStream().write(os.toByteArray()); + + //CSVFileUtil.toJson(new FileInputStream(importSession.getCsvFile()), response.getOutputStream(), outputCharset, importSession.getParserConfiguration(), 100); + + response.setStatus(HttpServletResponse.SC_OK); + logger.trace("Response in "+(System.currentTimeMillis()-startTime)); + } + +} diff --git a/src/main/java/org/gcube/portlets/user/td/gxtservice/server/LocalUploadServlet.java b/src/main/java/org/gcube/portlets/user/td/gxtservice/server/LocalUploadServlet.java new file mode 100644 index 0000000..fe8d83b --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/td/gxtservice/server/LocalUploadServlet.java @@ -0,0 +1,152 @@ +/** + * + */ +package org.gcube.portlets.user.td.gxtservice.server; + +import java.io.IOException; +import java.util.Iterator; +import java.util.List; + +import javax.servlet.ServletException; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.servlet.http.HttpSession; + +import org.apache.commons.fileupload.FileItem; +import org.apache.commons.fileupload.FileItemFactory; +import org.apache.commons.fileupload.FileUploadException; +import org.apache.commons.fileupload.disk.DiskFileItemFactory; +import org.apache.commons.fileupload.servlet.ServletFileUpload; +import org.gcube.portlets.user.td.gxtservice.server.file.FileUploadListener; +import org.gcube.portlets.user.td.gxtservice.server.file.FileUploadSession; +import org.gcube.portlets.user.td.gxtservice.server.file.FileUtil; +import org.gcube.portlets.user.td.gxtservice.shared.csv.CSVImportMonitor; +import org.gcube.portlets.user.td.gxtservice.shared.csv.CSVParserConfiguration; +import org.gcube.portlets.user.td.gxtservice.shared.file.FileUploadMonitor; +import org.gcube.portlets.user.td.gxtservice.shared.file.FileUploadState; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import com.allen_sauer.gwt.log.client.Log; + + +/** + * + * @author "Giancarlo Panichi" + * g.panichi@isti.cnr.it + * + */ +public class LocalUploadServlet extends HttpServlet { + + protected static Logger logger = LoggerFactory.getLogger(LocalUploadServlet.class); + + + /** + * + */ + private static final long serialVersionUID = -4197748678713054285L; + + @SuppressWarnings("rawtypes") + protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { + + logger.trace("Post"); + + HttpSession session = request.getSession(); + + if(session==null){ + logger.error("Error getting the upload session, no session valid found: "+session); + response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "ERROR-Error getting the user session, no session found"+session); + return ; + } + logger.info("CSV Import session id: "+session.getId()); + + FileUploadSession fileUploadSession=new FileUploadSession(); + CSVImportMonitor csvImportMonitor=new CSVImportMonitor(); + FileUploadMonitor fileUploadMonitor=new FileUploadMonitor(); + + fileUploadSession.setId(session.getId()); + fileUploadSession.setFileUploadState(FileUploadState.STARTED); + fileUploadSession.setCsvImportMonitor(csvImportMonitor); + fileUploadSession.setFileUploadMonitor(fileUploadMonitor); + + SessionUtil.setFileUploadSession(session,fileUploadSession); + + + FileItemFactory factory = new DiskFileItemFactory(); + ServletFileUpload upload = new ServletFileUpload(factory); + + + FileUploadListener uploadListener = new FileUploadListener(fileUploadSession.getFileUploadMonitor()); + upload.setProgressListener(uploadListener); + + FileItem uploadItem = null; + Log.info("Start upload file "); + try { + List items = upload.parseRequest(request); + Iterator it = items.iterator(); + while (it.hasNext()) { + FileItem item = (FileItem) it.next(); + if (!item.isFormField() && "uploadFormElement".equals(item.getFieldName())) { + uploadItem = item; + } + } + } catch (FileUploadException e) { + fileUploadSession.getFileUploadMonitor().setFailed("An error occured elaborating the HTTP request", FileUtil.exceptionDetailMessage(e)); + fileUploadSession.setFileUploadState(FileUploadState.FAILED); + SessionUtil.setFileUploadSession(session, fileUploadSession); + logger.error("Error processing request in upload servlet", e); + response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "ERROR-Error during request processing: "+e.getMessage()); + return; + } + + if (uploadItem == null) { + fileUploadSession.getFileUploadMonitor().setFailed("An error occured elaborating the HTTP request: No file found", "Upload request without file"); + fileUploadSession.setFileUploadState(FileUploadState.FAILED); + SessionUtil.setFileUploadSession(session, fileUploadSession); + logger.error("Error processing request in upload servlet: No file to upload"); + response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "No file to upload"); + return; + } + + String contentType = uploadItem.getContentType(); + + logger.trace("ContentType: "+contentType); + + /* TODO is necessary? + if (contentType.equals("application/octet-stream")){ + + logger.trace("We try to guess the content using the extension"); + String name = uploadItem.getName(); + + int lastIndex = name.lastIndexOf('.'); + if (lastIndex>=0){ + String extension = name.substring(lastIndex+1); + logger.trace("extension "+extension); + contentType = MimeTypeUtil.getMimeType(extension); + logger.trace("new contenttype: "+contentType); + } else logger.trace("No extensions found"); + } + */ + + try { + FileUtil.setImportFile(fileUploadSession, uploadItem.getInputStream(), uploadItem.getName(), contentType); + } catch (Exception e) { + fileUploadSession.getFileUploadMonitor().setFailed("An error occured elaborating the file", FileUtil.exceptionDetailMessage(e)); + fileUploadSession.setFileUploadState(FileUploadState.FAILED); + SessionUtil.setFileUploadSession(session, fileUploadSession); + logger.error("Error elaborating the stream", e); + uploadItem.delete(); + response.getWriter().write("ERROR-"+e.getMessage()); + return; + } + + uploadItem.delete(); + + logger.trace("changing state"); + fileUploadSession.getFileUploadMonitor().setState(FileUploadState.COMPLETED); + SessionUtil.setFileUploadSession(session, fileUploadSession); + response.getWriter().write("OK"); + } + +} diff --git a/src/main/java/org/gcube/portlets/user/td/gxtservice/server/SDMXClient.java b/src/main/java/org/gcube/portlets/user/td/gxtservice/server/SDMXClient.java new file mode 100644 index 0000000..ec6b3ec --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/td/gxtservice/server/SDMXClient.java @@ -0,0 +1,83 @@ +/** + * + */ +package org.gcube.portlets.user.td.gxtservice.server; + +import java.util.ArrayList; +import java.util.List; + +import org.gcube.datapublishing.sdmx.api.model.SDMXRegistryDescriptor; +import org.gcube.datapublishing.sdmx.api.model.SDMXRegistryInterfaceType; +import org.gcube.datapublishing.sdmx.api.registry.SDMXRegistryClient; +import org.gcube.datapublishing.sdmx.api.registry.SDMXRegistryClient.Detail; +import org.gcube.datapublishing.sdmx.api.registry.SDMXRegistryClient.References; +import org.gcube.datapublishing.sdmx.impl.model.GCubeSDMXRegistryDescriptor; +import org.gcube.datapublishing.sdmx.impl.model.SDMXRegistryDescriptorImpl; +import org.gcube.datapublishing.sdmx.impl.registry.FusionRegistryClient; +import org.gcube.portlets.user.td.gxtservice.shared.Agencies; +import org.gcube.portlets.user.td.gxtservice.shared.Codelist; +import org.gcube.portlets.user.td.gxtservice.shared.Dataset; +import org.sdmxsource.sdmx.api.model.beans.SdmxBeans; +import org.sdmxsource.sdmx.api.model.beans.base.AgencyBean; +import org.sdmxsource.sdmx.api.model.beans.codelist.CodelistBean; +import org.sdmxsource.sdmx.api.model.beans.datastructure.DataflowBean; + +/** + * + * @author "Giancarlo Panichi" + * g.panichi@isti.cnr.it + * + */ +public class SDMXClient { + + public static enum TYPE { INTERNAL, ANOTHER } + + protected SDMXRegistryClient client; + protected TYPE type; + protected String url; + + public SDMXClient(){ + type=TYPE.INTERNAL; + url=null; + SDMXRegistryDescriptor descriptor = new GCubeSDMXRegistryDescriptor(); + client = new FusionRegistryClient(descriptor); + + } + + public SDMXClient(String url){ + type=TYPE.ANOTHER; + this.url=url; + SDMXRegistryDescriptorImpl descriptor = new SDMXRegistryDescriptorImpl(); + descriptor.setUrl(SDMXRegistryInterfaceType.RESTV2_1, url); + client = new FusionRegistryClient(descriptor); + } + + + public ArrayList getAllCodelists() throws Exception + { + SdmxBeans beans = client.getCodelist("all", "all", "all", Detail.allstubs, References.none); + ArrayList codelists = new ArrayList(); + for (CodelistBean codelist:beans.getCodelists()) codelists.add(new Codelist(codelist.getId(), codelist.getName(), codelist.getAgencyId(), codelist.getVersion(), codelist.getDescription())); + return codelists; + } + + public ArrayList getAllDatasets() throws Exception + { + SdmxBeans beans = client.getProvisionAgreement("all", "all", "latest", Detail.full, References.children); + ArrayList datasets = new ArrayList(); + for (DataflowBean dataflowBean:beans.getDataflows()) { + datasets.add(new Dataset(dataflowBean.getId(), dataflowBean.getName(), dataflowBean.getAgencyId(),dataflowBean.getVersion(),dataflowBean.getDescription())); + } + return datasets; + } + + public ArrayList getAllAgencies() throws Exception + { + SdmxBeans beans = client.getAgencyScheme("SDMX", "AGENCIES", "1.0", Detail.full, References.none); + ArrayList agenciesList = new ArrayList(); + for (AgencyBean agency:beans.getAgencies()) agenciesList.add(new Agencies(agency.getId(), agency.getName(), agency.getDescription())); + return agenciesList; + } + + +} diff --git a/src/main/java/org/gcube/portlets/user/td/gxtservice/server/SessionUtil.java b/src/main/java/org/gcube/portlets/user/td/gxtservice/server/SessionUtil.java new file mode 100644 index 0000000..8510440 --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/td/gxtservice/server/SessionUtil.java @@ -0,0 +1,365 @@ +/** + * + */ +package org.gcube.portlets.user.td.gxtservice.server; + +import java.util.ArrayList; +import java.util.List; + +import javax.servlet.http.HttpSession; + +import org.gcube.application.framework.core.session.ASLSession; +import org.gcube.application.framework.core.session.SessionManager; +import org.gcube.common.scope.api.ScopeProvider; +import org.gcube.data.analysis.tabulardata.service.operation.Task; +import org.gcube.data.analysis.tabulardata.service.tabular.TabularResource; +import org.gcube.portal.custom.scopemanager.scopehelper.ScopeHelper; +import org.gcube.portlets.user.td.gxtservice.server.file.FileUploadSession; +import org.gcube.portlets.user.td.gxtservice.server.trservice.TRTasksManager; +import org.gcube.portlets.user.td.gxtservice.shared.Agencies; +import org.gcube.portlets.user.td.gxtservice.shared.Codelist; +import org.gcube.portlets.user.td.gxtservice.shared.Constants; +import org.gcube.portlets.user.td.gxtservice.shared.Dataset; +import org.gcube.portlets.user.td.gxtservice.shared.TDOpenSession; +import org.gcube.portlets.user.td.gxtservice.shared.TRId; +import org.gcube.portlets.user.td.gxtservice.shared.TabResource; +import org.gcube.portlets.user.td.gxtservice.shared.csv.CSVImportSession; +import org.gcube.portlets.user.td.gxtservice.shared.sdmx.SDMXImportSession; +import org.gcube.portlets.user.td.gxtservice.shared.source.SDMXRegistrySource; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import com.allen_sauer.gwt.log.client.Log; + +/** + * + * @author "Giancarlo Panichi" g.panichi@isti.cnr.it + * + */ +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 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 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 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 Logger logger = LoggerFactory.getLogger(SessionUtil.class); + + protected static ASLSession getAslSession(HttpSession httpSession) { + String username = (String) httpSession + .getAttribute(ScopeHelper.USERNAME_ATTRIBUTE); + ASLSession session; + if (username == null) { + logger.warn("no user found in session, using test one"); + username = Constants.DEFAULT_USER; + String scope = Constants.DEFAULT_SCOPE; + + httpSession.setAttribute(ScopeHelper.USERNAME_ATTRIBUTE, username); + session = SessionManager.getInstance().getASLSession( + httpSession.getId(), username); + session.setScope(scope); + + } else { + session= SessionManager.getInstance().getASLSession( + httpSession.getId(), username); + + } + + Log.info("SessionUtil: aslSession "+session.getUsername()+" "+session.getScope()); + return session; + + + + } + + public static void setTDOpenSession(HttpSession httpSession, TDOpenSession s) { + + TDOpenSession session = (TDOpenSession) httpSession + .getAttribute(TDOPEN_SESSION); + if (session != null) + httpSession.removeAttribute(TDOPEN_SESSION); + httpSession.setAttribute(TDOPEN_SESSION, s); + ASLSession aslSession = getAslSession(httpSession); + ScopeProvider.instance.set(aslSession.getScope().toString()); + + } + + + public static void retrieveResources(HttpSession httpSession) + throws Exception { + + ASLSession aslSession = getAslSession(httpSession); + ScopeProvider.instance.set(aslSession.getScope().toString()); + return; + } + + public static void setTabularResources(HttpSession httpSession, + List trs) { + + @SuppressWarnings("unchecked") + List tabularResources = (List) httpSession + .getAttribute(TABULAR_RESOURCE_LIST); + if (tabularResources != null) + httpSession.removeAttribute(TABULAR_RESOURCE_LIST); + httpSession.setAttribute(TABULAR_RESOURCE_LIST, trs); + ASLSession aslSession = getAslSession(httpSession); + ScopeProvider.instance.set(aslSession.getScope().toString()); + } + + public static TRId getTRId(HttpSession httpSession) { + TRId id = (TRId) httpSession.getAttribute(CURRENT_TR_ID); + if (id == null) { + Log.error("SDMX_TR_ID was not acquired"); + } + return id; + } + + public static void setTRId(HttpSession httpSession, TRId trId) { + TRId id = (TRId) httpSession.getAttribute(CURRENT_TR_ID); + if (id != null) + httpSession.removeAttribute(CURRENT_TR_ID); + httpSession.setAttribute(CURRENT_TR_ID, trId); + ASLSession aslSession = getAslSession(httpSession); + ScopeProvider.instance.set(aslSession.getScope().toString()); + } + + public static TabResource getTabResource(HttpSession httpSession) { + TabResource tabResource = (TabResource) httpSession + .getAttribute(CURRENT_TABULAR_RESOURCE); + if (tabResource == null) { + Log.error("CURRENT_TABULAR_RESOURCE was not acquired"); + } + return tabResource; + } + + public static void setTabResource(HttpSession httpSession, + TabResource tabResource) { + TabResource t = (TabResource) httpSession + .getAttribute(CURRENT_TABULAR_RESOURCE); + if (t != null) + httpSession.removeAttribute(CURRENT_TABULAR_RESOURCE); + httpSession.setAttribute(CURRENT_TABULAR_RESOURCE, tabResource); + ASLSession aslSession = getAslSession(httpSession); + ScopeProvider.instance.set(aslSession.getScope().toString()); + } + + public static TabResource getSDMXImportTabResource(HttpSession httpSession) { + TabResource tabResource = (TabResource) httpSession + .getAttribute(SDMX_IMPORT_TABULAR_RESOURCE); + if (tabResource == null) { + Log.error("SDMX_IMPORT_TABULAR_RESOURCE was not acquired"); + } + return tabResource; + } + + public static void setSDMXImportTabResource(HttpSession httpSession, + TabResource tabResource) { + TabResource t = (TabResource) httpSession + .getAttribute(SDMX_IMPORT_TABULAR_RESOURCE); + if (t != null) + httpSession.removeAttribute(SDMX_IMPORT_TABULAR_RESOURCE); + httpSession.setAttribute(SDMX_IMPORT_TABULAR_RESOURCE, tabResource); + ASLSession aslSession = getAslSession(httpSession); + ScopeProvider.instance.set(aslSession.getScope().toString()); + } + + public static void setSDMXImportSession(HttpSession httpSession, + SDMXImportSession s) { + + SDMXImportSession session = (SDMXImportSession) httpSession + .getAttribute(SDMX_IMPORT_SESSION); + if (session != null) + httpSession.removeAttribute(SDMX_IMPORT_SESSION); + httpSession.setAttribute(SDMX_IMPORT_SESSION, s); + ASLSession aslSession = getAslSession(httpSession); + ScopeProvider.instance.set(aslSession.getScope().toString()); + } + + public static SDMXImportSession getSDMXImportSession(HttpSession httpSession) { + SDMXImportSession importSession = (SDMXImportSession) httpSession + .getAttribute(SDMX_IMPORT_SESSION); + if (importSession == null) { + logger.error("SDMXImportSession was not acquired"); + } + return importSession; + } + + public static void setCSVImportSession(HttpSession httpSession, + CSVImportSession s) { + + CSVImportSession session = (CSVImportSession) httpSession + .getAttribute(CSV_IMPORT_SESSION); + if (session != null) + httpSession.removeAttribute(CSV_IMPORT_SESSION); + httpSession.setAttribute(CSV_IMPORT_SESSION, s); + ASLSession aslSession = getAslSession(httpSession); + ScopeProvider.instance.set(aslSession.getScope().toString()); + } + + public static CSVImportSession getCSVImportSession(HttpSession httpSession) { + CSVImportSession importSession = (CSVImportSession) httpSession + .getAttribute(CSV_IMPORT_SESSION); + if (importSession == null) { + logger.error("CSVImportSession was not acquired"); + } + return importSession; + } + + + public static void setFileUploadSession(HttpSession httpSession, + FileUploadSession s) { + + FileUploadSession session = (FileUploadSession) httpSession + .getAttribute(CSV_IMPORT_FILE_UPLOAD_SESSION); + if (session != null) + httpSession.removeAttribute(CSV_IMPORT_FILE_UPLOAD_SESSION); + httpSession.setAttribute(CSV_IMPORT_FILE_UPLOAD_SESSION, s); + ASLSession aslSession = getAslSession(httpSession); + ScopeProvider.instance.set(aslSession.getScope().toString()); + } + + + public static FileUploadSession getFileUploadSession(HttpSession httpSession) { + FileUploadSession fileUploadSession = (FileUploadSession) httpSession + .getAttribute(CSV_IMPORT_FILE_UPLOAD_SESSION); + if (fileUploadSession == null) { + logger.error("FileUploadSession was not acquired"); + } + return fileUploadSession; + } + + + public static ArrayList retrieveCodelists(HttpSession httpSession) + throws Exception { + logger.info("SessionUtil retriveCodelists"); + SDMXClient client = getSdmxClient(httpSession); + ASLSession aslSession = getAslSession(httpSession); + ScopeProvider.instance.set(aslSession.getScope().toString()); + return client.getAllCodelists(); + } + + public static ArrayList retrieveDatasets(HttpSession httpSession) + throws Exception { + logger.info("SessionUtil retriveDatasets"); + SDMXClient client = getSdmxClient(httpSession); + ASLSession aslSession = getAslSession(httpSession); + ScopeProvider.instance.set(aslSession.getScope().toString()); + return client.getAllDatasets(); + } + + public static ArrayList retrieveAgencies(HttpSession httpSession) + throws Exception { + logger.info("SessionUtil retriveAgencies"); + SDMXClient client = getSdmxClient(httpSession); + ASLSession aslSession = getAslSession(httpSession); + ScopeProvider.instance.set(aslSession.getScope().toString()); + return client.getAllAgencies(); + } + + 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"); + } 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(); + } + } + } else { + if (sdmxClient == null) { + sdmxClient = new SDMXClient(url); + } else { + if (sdmxClient.type.compareTo(SDMXClient.TYPE.INTERNAL) == 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"); + } + } + + return sdmxClient; + } + + public static Task getSDMXImportTask(HttpSession httpSession) { + Task monitor = (Task) httpSession.getAttribute(SDMX_IMPORT_TASK); + if (monitor == null) { + logger.error("SDMX_IMPORT_TASK was not acquired"); + } + return monitor; + } + + public static void setSDMXImportTask(HttpSession httpSession, Task task) { + Task monitor = (Task) httpSession.getAttribute(SDMX_IMPORT_TASK); + if (monitor != null) + 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) { + logger.error("CSV_IMPORT_TASK was not acquired"); + } + return monitor; + } + + public static void setCSVImportFileTask(HttpSession httpSession, Task task) { + Task monitor = (Task) httpSession.getAttribute(CSV_IMPORT_TASK); + if (monitor != null) + httpSession.removeAttribute(CSV_IMPORT_TASK); + httpSession.setAttribute(CSV_IMPORT_TASK, task); + } + + + public static TRTasksManager getTRTasksManager(HttpSession httpSession) { + TRTasksManager tasksManager = (TRTasksManager) httpSession.getAttribute(TR_TASK_MANAGER); + if (tasksManager != null) { + return tasksManager; + } else { + 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); + 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/gxtservice/server/TDGXTServiceImpl.java b/src/main/java/org/gcube/portlets/user/td/gxtservice/server/TDGXTServiceImpl.java new file mode 100644 index 0000000..1bec0c7 --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/td/gxtservice/server/TDGXTServiceImpl.java @@ -0,0 +1,791 @@ +/** + * + */ +package org.gcube.portlets.user.td.gxtservice.server; + +import java.nio.charset.Charset; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import javax.servlet.http.HttpSession; + +import org.gcube.application.framework.core.session.ASLSession; +import org.gcube.data.analysis.tabulardata.metadata.NoSuchMetadataException; +import org.gcube.data.analysis.tabulardata.model.table.Table; +import org.gcube.data.analysis.tabulardata.model.table.TableId; +import org.gcube.data.analysis.tabulardata.operation.worker.ActivityStatus; +import org.gcube.data.analysis.tabulardata.operation.worker.EligibleOperation; +import org.gcube.data.analysis.tabulardata.operation.worker.JobResult; +import org.gcube.data.analysis.tabulardata.operation.worker.OperationInvocation; +import org.gcube.data.analysis.tabulardata.service.TabularDataService; +import org.gcube.data.analysis.tabulardata.service.TabularDataServiceMock; +import org.gcube.data.analysis.tabulardata.service.operation.OperationInterface; +import org.gcube.data.analysis.tabulardata.service.operation.Task; +import org.gcube.data.analysis.tabulardata.service.tabular.TabularResource; +import org.gcube.data.analysis.tabulardata.service.tabular.TabularResourceId; +import org.gcube.data.analysis.tabulardata.service.tabular.TabularResourceInterface; +import org.gcube.data.analysis.tabulardata.service.tabular.metadata.AgencyMetadata; +import org.gcube.data.analysis.tabulardata.service.tabular.metadata.CreationDateMetadata; +import org.gcube.data.analysis.tabulardata.service.tabular.metadata.DescriptionMetadata; +import org.gcube.data.analysis.tabulardata.service.tabular.metadata.NameMetadata; +import org.gcube.data.analysis.tabulardata.service.tabular.metadata.RightsMetadata; +import org.gcube.portlets.user.td.gxtservice.client.rpc.TDGXTService; +import org.gcube.portlets.user.td.gxtservice.server.file.FileUploadSession; +import org.gcube.portlets.user.td.gxtservice.server.storage.FilesStorage; +import org.gcube.portlets.user.td.gxtservice.server.trservice.OperationsId; +import org.gcube.portlets.user.td.gxtservice.shared.Agencies; +import org.gcube.portlets.user.td.gxtservice.shared.Codelist; +import org.gcube.portlets.user.td.gxtservice.shared.Dataset; +import org.gcube.portlets.user.td.gxtservice.shared.TDGXTServiceException; +import org.gcube.portlets.user.td.gxtservice.shared.TDOpenSession; +import org.gcube.portlets.user.td.gxtservice.shared.TRId; +import org.gcube.portlets.user.td.gxtservice.shared.TabResource; +import org.gcube.portlets.user.td.gxtservice.shared.csv.AvailableCharsetList; +import org.gcube.portlets.user.td.gxtservice.shared.csv.CSVFileUtil; +import org.gcube.portlets.user.td.gxtservice.shared.csv.CSVImportMonitor; +import org.gcube.portlets.user.td.gxtservice.shared.csv.CSVImportSession; +import org.gcube.portlets.user.td.gxtservice.shared.csv.CSVParserConfiguration; +import org.gcube.portlets.user.td.gxtservice.shared.csv.CSVRowError; +import org.gcube.portlets.user.td.gxtservice.shared.file.FileUploadMonitor; +import org.gcube.portlets.user.td.gxtservice.shared.file.HeaderPresence; +import org.gcube.portlets.user.td.gxtservice.shared.sdmx.SDMXImportMonitor; +import org.gcube.portlets.user.td.gxtservice.shared.sdmx.SDMXImportSession; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import com.google.gwt.user.server.rpc.RemoteServiceServlet; + +/** + * + * @author "Giancarlo Panichi" g.panichi@isti.cnr.it + * + */ +public class TDGXTServiceImpl extends RemoteServiceServlet implements + TDGXTService { + + private static final long serialVersionUID = -5707400086333186368L; + protected static Logger logger = LoggerFactory + .getLogger(TDGXTServiceImpl.class); + + protected static SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd"); + protected TabularDataService service; + protected HttpSession session; + protected ASLSession aslSession; + + public void setTabResource(TabResource tabResource) + throws TDGXTServiceException { + try { + session = this.getThreadLocalRequest().getSession(); + SessionUtil.setTabResource(session, tabResource); + return; + + } catch (Exception e) { + logger.error( + "Error setting TabResource parameter: " + + e.getLocalizedMessage(), e); + throw new TDGXTServiceException( + "Error setting TabResource parameter: " + + e.getLocalizedMessage()); + } + + } + + /** + * + */ + public TabResource getTabResource() throws TDGXTServiceException { + try { + session = this.getThreadLocalRequest().getSession(); + return SessionUtil.getTabResource(session); + + } catch (Exception e) { + logger.error( + "Error setting TabResource parameter: " + + e.getLocalizedMessage(), e); + throw new TDGXTServiceException( + "Error setting TabResource parameter: " + + e.getLocalizedMessage()); + } + } + + /** + * Retrieves the properties of the specified tabular resource + */ + /* + * @Override public TRProperties getTaularResourceProperties(TRId trId) + * throws TDGXTServiceException { try { HttpSession session = + * this.getThreadLocalRequest().getSession(); + * + * SessionUtil.setTRId(session, trId); TabularResourceId id = new + * TabularResourceId(Long.valueOf(trId .getId())); TabularDataService + * service = new TabularDataServiceMock(); + * + * TabularResource tr = service.getTabularResource(id); + * + * NameMetadata nameMeta = tr.getMetadata(NameMetadata.class); + * CreationDateMetadata creationDateMeta = tr + * .getMetadata(CreationDateMetadata.class); AgencyMetadata agencyMeta = + * tr.getMetadata(AgencyMetadata.class); + * + * String nameTR = nameMeta.getValue(); String agencyTR = + * agencyMeta.getValue(); Date dateTR = creationDateMeta.getValue(); TableId + * tableId = tr.getHistory().get(tr.getHistory().size() - 1) + * .getResultTable().getId(); + * + * HashMap properties = new HashMap(); + * + * properties.put("Id", String.valueOf(tr.getId().getValue())); + * properties.put("Table id", String.valueOf(tableId.getValue())); + * properties.put("Name", nameTR); properties.put("Agency", agencyTR); + * properties.put("Creation Date", sdf.format(dateTR)); + * + * logger.info("Tabular Resources retrived: " + properties); + * + * TRProperties trProperties = new TRProperties(); + * trProperties.setProperties(properties); + * + * return trProperties; return null; } catch (Exception e) { + * logger.error("Error retrieving TabularResources: " + + * e.getLocalizedMessage()); throw new TDGXTServiceException( + * "Error retrieving Tabular Resources Properties: " + + * e.getLocalizedMessage()); } + * + * } + */ + + @Override + public void setTDOpenSession(TDOpenSession s) throws TDGXTServiceException { + try { + session = this.getThreadLocalRequest().getSession(); + SessionUtil.setTDOpenSession(session, s); + return; + + } catch (Exception e) { + logger.error("Error setting TDOpenSession parameter: " + + e.getLocalizedMessage()); + throw new TDGXTServiceException( + "Error setting TDOpenSession parameter: " + + e.getLocalizedMessage()); + } + } + + protected TabResource retriveTRMetadataFromService(TabularResource tr, int i) + throws TDGXTServiceException { + SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd"); + NameMetadata nameMeta; + RightsMetadata rightsMeta; + CreationDateMetadata creationDateMeta; + AgencyMetadata agencyMeta; + DescriptionMetadata descriptionMeta; + try { + nameMeta = tr.getMetadata(NameMetadata.class); + creationDateMeta = tr.getMetadata(CreationDateMetadata.class); + agencyMeta = tr.getMetadata(AgencyMetadata.class); + descriptionMeta = tr.getMetadata(DescriptionMetadata.class); + rightsMeta = tr.getMetadata(RightsMetadata.class); + } catch (NoSuchMetadataException e) { + e.printStackTrace(); + throw new TDGXTServiceException( + "Error retriving metadata from service: " + + e.getLocalizedMessage()); + } + + if (nameMeta == null) { + throw new TDGXTServiceException( + "Error retriving metadata from service: TR nameMeta is null"); + } + String nameTR = nameMeta.getValue(); + String descriptionTR = ""; + String agencyTR = ""; + String rightsTR = ""; + String dateS = ""; + + if (descriptionMeta != null) { + descriptionTR = descriptionMeta.getValue(); + } + if (agencyMeta != null) { + agencyTR = agencyMeta.getValue(); + } + if (rightsMeta != null) { + rightsTR = rightsMeta.getValue(); + } + if (creationDateMeta != null) { + Date dateTR = creationDateMeta.getValue(); + dateS = sdf.format(dateTR); + } + + TableId tableId = tr.getHistory().get(tr.getHistory().size() - 1) + .getResultTable().getId(); + TRId trId = new TRId(String.valueOf(tr.getId().getValue()), + String.valueOf(tableId.getValue())); + TabResource t = new TabResource(i, nameTR, descriptionTR, agencyTR, + dateS, rightsTR, trId); + return t; + } + + @Override + public ArrayList getTabularResources() + throws TDGXTServiceException { + try { + session = this.getThreadLocalRequest().getSession(); + aslSession = SessionUtil.getAslSession(session); + service = new TabularDataServiceMock(); + + List trs = service.getTabularResources(); + SessionUtil.setTabularResources(session, trs); + + ArrayList ltr = new ArrayList(); + + int i; + for (i = 0; i < trs.size(); i++) { + TabularResource tr = trs.get(i); + TabResource t = retriveTRMetadataFromService(tr, i); + ltr.add(t); + } + + logger.debug("Tabular Resources retrived: " + ltr); + return ltr; + } catch (Exception e) { + logger.error("Error retrieving TabularResources: " + + e.getLocalizedMessage()); + throw new TDGXTServiceException( + "Error retrieving TabularResources: " + + e.getLocalizedMessage()); + } + + } + + + /** + * + * @param tabResource + * @throws TDGXTServiceException + */ + + public void removeTabularResource(TabResource tabResource) + throws TDGXTServiceException { + try { + session = this.getThreadLocalRequest().getSession(); + aslSession = SessionUtil.getAslSession(session); + + if (tabResource == null) { + logger.error("Error removing TabularResource: tabResource is null"); + throw new TDGXTServiceException( + "Error removing TabularResource no parameters set"); + } + TabularDataService service = new TabularDataServiceMock(); + TabularResourceId id = new TabularResourceId( + Long.valueOf(tabResource.getTrId().getId())); + service.removeTabularResource(id); + return; + } catch (Exception e) { + logger.error( + "Error removing TabularResource: " + + e.getLocalizedMessage(), e); + throw new TDGXTServiceException("Error removing TabularResource: " + + e.getLocalizedMessage()); + } + } + + protected void setTabularResourceMetaData(TabResource tabResource, + TabularResource serviceTR) { + + } + + @Override + public TabResource createTabularResource(TabResource tabResource) + throws TDGXTServiceException { + try { + session = this.getThreadLocalRequest().getSession(); + aslSession = SessionUtil.getAslSession(session); + + if (tabResource == null) { + logger.error("Error creating new TabularResource: tabResource is null"); + throw new TDGXTServiceException( + "Error creating new TabularResource no parameters set"); + } + service = new TabularDataServiceMock(); + TabularResource serviceTR = service.createTabularResource(); + Table table = service.getLastTable(serviceTR.getId()); + + TRId trId = new TRId(String.valueOf(serviceTR.getId().getValue()), + String.valueOf(table.getId().getValue())); + tabResource.setTrId(trId); + setTabularResourceMetaData(tabResource, serviceTR); + return tabResource; + } catch (Exception e) { + logger.error( + "Error creating new TabularResource: " + + e.getLocalizedMessage(), e); + throw new TDGXTServiceException( + "Error creating new TabularResource: " + + e.getLocalizedMessage()); + } + + } + + /** + * jar {@inheritDoc} + */ + @Override + public ArrayList getCodelists() throws TDGXTServiceException { + try { + session = this.getThreadLocalRequest().getSession(); + return SessionUtil.retrieveCodelists(session); + } catch (Exception e) { + e.printStackTrace(); + throw new TDGXTServiceException("Error retrieving codelists: " + + e.getLocalizedMessage()); + } + + } + + /** + * {@inheritDoc} + */ + @Override + public ArrayList getDatasets() throws TDGXTServiceException { + try { + session = this.getThreadLocalRequest().getSession(); + return SessionUtil.retrieveDatasets(session); + } catch (Exception e) { + e.printStackTrace(); + throw new TDGXTServiceException("Error retrieving datasets: " + + e.getLocalizedMessage()); + } + + } + + /** + * {@inheritDoc} + */ + @Override + public ArrayList getAgencies() throws TDGXTServiceException { + try { + session = this.getThreadLocalRequest().getSession(); + return SessionUtil.retrieveAgencies(session); + } catch (Exception e) { + e.printStackTrace(); + throw new TDGXTServiceException("Error retrieving datasets: " + + e.getLocalizedMessage()); + } + + } + + + + /** + * SDMX Import + * + */ + protected Map retrieveOperationParameters( + SDMXImportSession sdmxImportSession) { + + Map map = new HashMap(); + + Codelist codelist = sdmxImportSession.getSelectedCodelist(); + + map.put("Agency", codelist.getAgencyId()); + map.put("Id", codelist.getId()); + map.put("Version", codelist.getVersion()); + + return map; + + } + + @Override + public void importSDMXClientLibraryRequest( + SDMXImportSession sdmxImportSession) throws TDGXTServiceException { + + try { + session = this.getThreadLocalRequest().getSession(); + SessionUtil.setSDMXImportSession(session, sdmxImportSession); + aslSession = SessionUtil.getAslSession(session); + + service = new TabularDataServiceMock(); + OperationInterface oService = service; + TabularResourceInterface trService = service; + + List capabilities = service.getCapabilities(); + + // Import SDMX Codelist takes id 200 + EligibleOperation importSDMXCodelistOperation = getEligibleOperationWithId( + OperationsId.SDMXCodelistImport.toString(), capabilities); + + TabResource importSDMXTabResource = sdmxImportSession + .getTabResource(); + + TabularResource serviceTR = trService.createTabularResource(); + // Table table=trService.getLastTable(serviceTRId); + + TRId trId = new TRId(String.valueOf(serviceTR.getId().getValue())); + importSDMXTabResource.setTrId(trId); + SessionUtil + .setSDMXImportTabResource(session, importSDMXTabResource); + + Map parameterInstances = retrieveOperationParameters(sdmxImportSession); + + OperationInvocation invocation = importSDMXCodelistOperation + .createOperationInvocation(parameterInstances); + + Task trTask = oService.execute(invocation, serviceTR.getId()); + + SessionUtil.setSDMXImportTask(session, trTask); + return; + } catch (Exception e) { + e.printStackTrace(); + throw new TDGXTServiceException("Error in Client Library Request: " + + e.getLocalizedMessage()); + } + } + + protected EligibleOperation getEligibleOperationWithId(String op, + List capabilities) throws TDGXTServiceException { + for (EligibleOperation operation : capabilities) { + if (Long.valueOf(op) == operation.getOperationDescriptor() + .getOperationId().getValue()) { + return operation; + } + ; + + } + throw new TDGXTServiceException("ElegibleOperation not found"); + + } + + @Override + public SDMXImportMonitor getSDMXImportMonitor() + throws TDGXTServiceException { + try { + session = this.getThreadLocalRequest().getSession(); + aslSession = SessionUtil.getAslSession(session); + Task task = SessionUtil.getSDMXImportTask(session); + TabResource sdmxImportTabResource = SessionUtil + .getSDMXImportTabResource(session); + TRId trId = sdmxImportTabResource.getTrId(); + + SDMXImportMonitor importMonitor = new SDMXImportMonitor(); + if (trId == null) { + throw new TDGXTServiceException( + "Error in importSDMX TabularResource Id null"); + } else { + if (task == null) { + throw new TDGXTServiceException( + "Error in importSDMX task null"); + } else { + ActivityStatus status = task.getStatus(); + if (status == null) { + throw new TDGXTServiceException( + "Error in importSDMX Status null"); + } else { + importMonitor.setStatus(task.getStatus().ordinal()); + importMonitor.setProgress(task.getProgress()); + JobResult result = task.getResult(); + if (result == null) { + logger.info("Task Result: " + task.getResult()); + } else { + importMonitor.setError(task.getResult() + .getException()); + if (task.getResult().getOutput() == null) { + logger.info("Task Result Output: " + + task.getResult().getOutput()); + } else { + if (task.getResult().getOutput().getId() == null) { + logger.info("Task Result Output Id: " + + task.getResult().getOutput() + .getId()); + } else { + logger.info("Task TableId: " + + task.getResult().getOutput() + .getId().getValue()); + + trId.setTableId(String.valueOf(task + .getResult().getOutput().getId() + .getValue())); + sdmxImportTabResource.setTrId(trId); + SessionUtil.setSDMXImportTabResource( + session, sdmxImportTabResource); + + SessionUtil.setTRId(session, trId); + + } + } + } + + } + SessionUtil.setSDMXImportTask(session, task); + } + + importMonitor.setTrId(trId); + } + logger.info("getImportMonitor(): " + importMonitor); + return importMonitor; + } catch (Exception e) { + e.printStackTrace(); + throw new TDGXTServiceException( + "Error in importSDMX ImportMonitor: " + + e.getLocalizedMessage()); + + } + + } + + @Override + public void setSDMXSession(SDMXImportSession sdmxImportSession) + throws TDGXTServiceException { + try { + session = this.getThreadLocalRequest().getSession(); + SessionUtil.setSDMXImportSession(session, sdmxImportSession); + return; + + } catch (Exception e) { + logger.error( + "Error setting SDMXImportSession parameter: " + + e.getLocalizedMessage(), e); + throw new TDGXTServiceException( + "Error setting SDMXImportSession parameter: " + + e.getLocalizedMessage()); + } + + } + + /** + * CSV Import + * + */ + + @Override + public void setCSVSession(CSVImportSession importSession) + throws TDGXTServiceException { + try { + session = this.getThreadLocalRequest().getSession(); + SessionUtil.setCSVImportSession(session, importSession); + return; + + } catch (Exception e) { + logger.error( + "Error setting SDMXImportSession parameter: " + + e.getLocalizedMessage(), e); + throw new TDGXTServiceException( + "Error setting SDMXImportSession parameter: " + + e.getLocalizedMessage()); + } + + } + + @Override + public FileUploadMonitor getFileUploadMonitor() + throws TDGXTServiceException { + + session = this.getThreadLocalRequest().getSession(); + if (session == null) { + throw new TDGXTServiceException( + "Error retrieving the session: null"); + } + FileUploadSession fileUploadSession = SessionUtil + .getFileUploadSession(session); + if (fileUploadSession == null) { + throw new TDGXTServiceException( + "Error retrieving the fileUploadSession: null"); + } + return fileUploadSession.getFileUploadMonitor(); + } + + @Override + public CSVImportMonitor getCSVImportMonitor() throws TDGXTServiceException { + session = this.getThreadLocalRequest().getSession(); + if (session == null) { + throw new TDGXTServiceException( + "Error retrieving the session: null"); + } + logger.info("Session:" + session.getId()); + + FileUploadSession importSession = SessionUtil + .getFileUploadSession(session); + if (importSession == null) { + throw new TDGXTServiceException( + "Error retrieving the fileUploadSession: null"); + } + return importSession.getCsvImportMonitor(); + } + + @Override + public AvailableCharsetList getAvailableCharset() + throws TDGXTServiceException { + session = this.getThreadLocalRequest().getSession(); + if (session == null) { + throw new TDGXTServiceException( + "Error retrieving the session: null"); + } + logger.info("Session:" + session.getId()); + String defaultEncoding = Charset.defaultCharset().displayName(); + ArrayList charsetList = new ArrayList(Charset + .availableCharsets().keySet()); + return new AvailableCharsetList(charsetList, defaultEncoding); + } + + @Override + public ArrayList configureCSVParser(String encoding, + HeaderPresence headerPresence, char delimiter, char comment) + throws TDGXTServiceException { + session = this.getThreadLocalRequest().getSession(); + if (session == null) { + throw new TDGXTServiceException( + "Error retrieving the session: null"); + } + logger.info("Session:" + session.getId()); + logger.info("configureCSVParser encoding: " + encoding + + " headerPresence: " + headerPresence + " delimiter: " + + delimiter + " comment: " + comment); + + FileUploadSession fileUploadSession = SessionUtil + .getFileUploadSession(session); + if (fileUploadSession == null) { + throw new TDGXTServiceException( + "Error retrieving the fileUploadSession: null"); + } + CSVParserConfiguration parserConfiguration = fileUploadSession + .getParserConfiguration(); + if (parserConfiguration == null) { + parserConfiguration = new CSVParserConfiguration( + Charset.forName(encoding), delimiter, comment, + headerPresence); + fileUploadSession.setParserConfiguration(parserConfiguration); + } else { + parserConfiguration.update(encoding, delimiter, comment, + headerPresence); + } + SessionUtil.setFileUploadSession(session, fileUploadSession); + try { + return CSVFileUtil.getHeader(fileUploadSession.getCsvFile(), + fileUploadSession.getParserConfiguration()); + } catch (Exception e) { + logger.error("Error retrieving the CSV header", e); + throw new TDGXTServiceException( + "Error calculating the CSV header: " + + e.getLocalizedMessage()); + } + } + + @Override + public ArrayList checkCSV(long errorsLimit) + throws TDGXTServiceException { + + session = this.getThreadLocalRequest().getSession(); + if (session == null) { + throw new TDGXTServiceException( + "Error retrieving the session: null"); + } + logger.info("Session:" + session.getId()); + FileUploadSession fileUploadSession = SessionUtil + .getFileUploadSession(session); + if (fileUploadSession == null) { + throw new TDGXTServiceException( + "Error retrieving the fileUploadSession: null"); + } + + try { + return CSVFileUtil.checkCSV(fileUploadSession.getCsvFile(), + fileUploadSession.getParserConfiguration(), errorsLimit); + } catch (Exception e) { + logger.error("Error checking the CSV file", e); + throw new TDGXTServiceException("Error checking the CSV file: " + + e.getLocalizedMessage()); + } + + } + + @Override + public void startCSVImport(boolean[] columnToImportMask) + throws TDGXTServiceException { + session = this.getThreadLocalRequest().getSession(); + if (session == null) { + throw new TDGXTServiceException( + "Error retrieving the session: null"); + } + logger.info("Session:" + session.getId()); + + ASLSession aslSession = SessionUtil.getAslSession(session); + if (aslSession == null) { + throw new TDGXTServiceException( + "Error retrieving the asl session: null"); + } + String user = aslSession.getUsername(); + logger.info("Session User:" + user); + + FileUploadSession fileUploadSession = SessionUtil + .getFileUploadSession(session); + if (fileUploadSession == null) { + throw new TDGXTServiceException( + "Error retrieving the fileUploadSession: null"); + } + + importCSVFileOnService(user, fileUploadSession, columnToImportMask); + + + } + + protected Map csvImportFileParameter( + String fileUrlOnStorage, FileUploadSession fileUploadSession, + boolean[] columnToImportMask) { + final String ENCODING = "encoding"; + final String HASHEADER = "hasHeader"; + final String SEPARATOR = "separator"; + final String URL = "url"; + + Map parameterInstances = new HashMap(); + parameterInstances.put(URL, fileUrlOnStorage); + parameterInstances.put(SEPARATOR, fileUploadSession + .getParserConfiguration().getDelimiter());// ',' + parameterInstances.put(ENCODING, fileUploadSession + .getParserConfiguration().getCharset());// "UTF-8" + boolean hasHeader = true; + if (fileUploadSession.getParserConfiguration().getHeaderPresence() == HeaderPresence.NONE) { + hasHeader = false; + } + parameterInstances.put(HASHEADER, hasHeader);// true + return parameterInstances; + } + + protected void importCSVFileOnService(String user, + FileUploadSession fileUploadSession, boolean[] columnToImportMask) + throws TDGXTServiceException { + FilesStorage filesStorage = new FilesStorage(); + + String fileUrlOnStorage = filesStorage.storageCSVTempFile(user, + fileUploadSession.getCsvFile()); + + Map parameterInstance = csvImportFileParameter( + fileUrlOnStorage, fileUploadSession, columnToImportMask); + + service = new TabularDataServiceMock(); + + List capabilities = service.getCapabilities(); + + // Import CSV file + EligibleOperation importCSVFileOperation = getEligibleOperationWithId( + OperationsId.CSVImport.toString(), capabilities); + + OperationInvocation oi = importCSVFileOperation + .createOperationInvocation(parameterInstance); + TabularResource tabularResource = service.createTabularResource(); + + Task trTask; + try { + trTask = service.execute(oi, tabularResource.getId()); + } catch (Exception e) { + e.printStackTrace(); + throw new TDGXTServiceException( + "Tabular Data Service error creating TabularResource: " + + e.getLocalizedMessage()); + } + + SessionUtil.setCSVImportFileTask(session, trTask); + + } +} diff --git a/src/main/java/org/gcube/portlets/user/td/gxtservice/server/file/FileUploadListener.java b/src/main/java/org/gcube/portlets/user/td/gxtservice/server/file/FileUploadListener.java new file mode 100644 index 0000000..23c4c01 --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/td/gxtservice/server/file/FileUploadListener.java @@ -0,0 +1,31 @@ +/** + * + */ +package org.gcube.portlets.user.td.gxtservice.server.file; + +import org.apache.commons.fileupload.ProgressListener; +import org.gcube.portlets.user.td.gxtservice.shared.file.FileUploadMonitor; + +/** + * + * @author "Giancarlo Panichi" + * g.panichi@isti.cnr.it + * + */ +public class FileUploadListener implements ProgressListener { + + protected FileUploadMonitor fileUploadMonitor; + + public FileUploadListener(FileUploadMonitor fileUploadMonitor) { + this.fileUploadMonitor = fileUploadMonitor; + } + + /** + * {@inheritDoc} + */ + public void update(long pBytesRead, long pContentLength, int pItems) { + fileUploadMonitor.setTotalLenght(pContentLength); + fileUploadMonitor.setElaboratedLenght(pBytesRead); + } + +} diff --git a/src/main/java/org/gcube/portlets/user/td/gxtservice/server/file/FileUploadSession.java b/src/main/java/org/gcube/portlets/user/td/gxtservice/server/file/FileUploadSession.java new file mode 100644 index 0000000..ebf9a0c --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/td/gxtservice/server/file/FileUploadSession.java @@ -0,0 +1,103 @@ +package org.gcube.portlets.user.td.gxtservice.server.file; + +import java.io.File; +import java.io.Serializable; + + +import org.gcube.portlets.user.td.gxtservice.shared.csv.CSVImportMonitor; +import org.gcube.portlets.user.td.gxtservice.shared.csv.CSVParserConfiguration; +import org.gcube.portlets.user.td.gxtservice.shared.file.FileUploadMonitor; +import org.gcube.portlets.user.td.gxtservice.shared.file.FileUploadState; + +/** + * + * @author "Giancarlo Panichi" + * g.panichi@isti.cnr.it + * + */ +public class FileUploadSession implements Serializable { + + private static final long serialVersionUID = -7906477664944910362L; + + protected String id; + + protected FileUploadState fileUploadState; + + protected File csvFile; + protected String csvName; + + protected FileUploadMonitor fileUploadMonitor; + + protected CSVParserConfiguration parserConfiguration; + + protected CSVImportMonitor csvImportMonitor; + + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public FileUploadState getFileUploadState() { + return fileUploadState; + } + + public void setFileUploadState(FileUploadState fileUploadState) { + this.fileUploadState = fileUploadState; + } + + public File getCsvFile() { + return csvFile; + } + + public void setCsvFile(File csvFile) { + this.csvFile = csvFile; + } + + public String getCsvName() { + return csvName; + } + + public void setCsvName(String csvName) { + this.csvName = csvName; + } + + public FileUploadMonitor getFileUploadMonitor() { + return fileUploadMonitor; + } + + public void setFileUploadMonitor(FileUploadMonitor fileUploadMonitor) { + this.fileUploadMonitor = fileUploadMonitor; + } + + public CSVParserConfiguration getParserConfiguration() { + return parserConfiguration; + } + + public void setParserConfiguration(CSVParserConfiguration parserConfiguration) { + this.parserConfiguration = parserConfiguration; + } + + public CSVImportMonitor getCsvImportMonitor() { + return csvImportMonitor; + } + + public void setCsvImportMonitor(CSVImportMonitor csvImportMonitor) { + this.csvImportMonitor = csvImportMonitor; + } + + @Override + public String toString() { + return "FileUploadSession [id=" + id + ", fileUploadState=" + fileUploadState + + ", csvFile=" + csvFile + ", csvName=" + csvName + + ", fileUploadMonitor=" + fileUploadMonitor + + ", parserConfiguration=" + parserConfiguration + + ", csvImportMonitor=" + csvImportMonitor +"]"; + } + + + +} diff --git a/src/main/java/org/gcube/portlets/user/td/gxtservice/server/file/FileUtil.java b/src/main/java/org/gcube/portlets/user/td/gxtservice/server/file/FileUtil.java new file mode 100644 index 0000000..eaa0f50 --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/td/gxtservice/server/file/FileUtil.java @@ -0,0 +1,119 @@ +/** + * + */ +package org.gcube.portlets.user.td.gxtservice.server.file; + +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.io.PrintWriter; +import java.io.StringWriter; +import java.util.zip.ZipEntry; +import java.util.zip.ZipInputStream; + +import org.apache.commons.io.IOUtils; + +import org.gcube.portlets.user.td.gxtservice.server.SessionUtil; +import org.gcube.portlets.user.td.gxtservice.shared.csv.CSVImportSession; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + + +public class FileUtil { + + protected static final Logger logger = LoggerFactory.getLogger(FileUtil.class); + + public static final String[] ZIP_MIMETYPES = new String[]{ + "application/x-compress", + "application/x-compressed", + "application/x-gzip", + "application/x-winzip", + "application/x-zip", + "application/zip", + "multipart/x-zip"}; + + /** + * Check if the content type is a zip type. + * @param contentType the content type to check. + * @return true if is a zip file, false otherwise. + */ + public static boolean isZipContentType(String contentType) + { + for (String zip_mimetype:ZIP_MIMETYPES) if (zip_mimetype.equals(contentType)) return true; + return false; + } + + + /** + * Unzip the specified stream + * @param is the zip stream. + * @param os the output stream. + * @throws Exception + */ + public static String unZip(InputStream is, OutputStream os) throws Exception + { + try { + ZipInputStream zis = new ZipInputStream(is); + ZipEntry entry; + + while ((entry = zis.getNextEntry())!=null && !entry.isDirectory()); + + if (entry == null || entry.isDirectory()) { + zis.close(); + os.close(); + throw new Exception("Unzip error: No file entry found"); + } + IOUtils.copy(zis, os); + zis.closeEntry(); + zis.close(); + os.close(); + return entry.getName(); + + + } catch(IOException e) + { + throw new Exception("Unzip error: "+e.getMessage(), e); + } + + } + + public static String exceptionDetailMessage(Throwable t) + { + StringWriter out = new StringWriter(); + PrintWriter writer = new PrintWriter(out); + t.printStackTrace(writer); + + StringBuilder message = new StringBuilder("Error message:\n"); + message.append(out.toString()); + + return message.toString(); + } + + public static void setImportFile(FileUploadSession fileUploadSession, InputStream is, String name, String mimeType) throws Exception + { + File csvTmp = File.createTempFile("import", "csv"); + + //FIXME manage it + csvTmp.deleteOnExit(); + + logger.trace("mimeType: "+mimeType); + if (isZipContentType(mimeType)){ + //we need to unzip + logger.trace("is a zip file"); + name = unZip(is, new FileOutputStream(csvTmp)); + } else { + logger.trace("is a text file"); + IOUtils.copy(is, new FileOutputStream(csvTmp)); + } + + logger.trace("upload completed"); + + fileUploadSession.setCsvName(name); + fileUploadSession.setCsvFile(csvTmp); + + + } + +} diff --git a/src/main/java/org/gcube/portlets/user/td/gxtservice/server/storage/FilesStorage.java b/src/main/java/org/gcube/portlets/user/td/gxtservice/server/storage/FilesStorage.java new file mode 100644 index 0000000..1ab7886 --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/td/gxtservice/server/storage/FilesStorage.java @@ -0,0 +1,20 @@ +package org.gcube.portlets.user.td.gxtservice.server.storage; + +import java.io.File; + +import org.gcube.contentmanagement.blobstorage.service.IClient; +import org.gcube.contentmanager.storageclient.wrapper.AccessType; +import org.gcube.contentmanager.storageclient.wrapper.MemoryType; +import org.gcube.contentmanager.storageclient.wrapper.StorageClient; + +public class FilesStorage { + + public String storageCSVTempFile(String user, File file) { + IClient client = new StorageClient(user, AccessType.PUBLIC, + MemoryType.VOLATILE).getClient(); + String remotePath = "/CSVimport/" + file.getName(); + client.put(true).LFile(file.getAbsolutePath()).RFile(remotePath); + String url=client.getUrl().RFile(remotePath); + return url; + } +} diff --git a/src/main/java/org/gcube/portlets/user/td/gxtservice/server/trservice/OperationsId.java b/src/main/java/org/gcube/portlets/user/td/gxtservice/server/trservice/OperationsId.java new file mode 100644 index 0000000..7584ccc --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/td/gxtservice/server/trservice/OperationsId.java @@ -0,0 +1,93 @@ +package org.gcube.portlets.user.td.gxtservice.server.trservice; + + +/** + * + * @author "Giancarlo Panichi" + * g.panichi@isti.cnr.it + * + * Tabular Data Service Operations Id + * + * 100 CSVImport + * 101 CSVExport + * 200 SDMXCodelistImport + * 201 SDMXCodelistExport + * 202 SDMXDatasetImport + * 203 SDMXDatasetExport + * 300 JSONImport + * 301 JSONExport + * 1000 ValidateCodelist + * 1001 ValidateDataset + * 1002 ChangeTableType + * 1003 CreateDatasetView + * 1004 RemoveColumn + * 1005 ChangeLabel + * 1006 AddLabel + * 1007 RemoveLabel + * 2000 ChangeToAnnotationColumn + * 2001 ChangeToAttributeColumn + * 2002 ChangeToMeasureColumn + * 2003 ChangeToCodeColumn + * 2004 ChangeToCodeName + * 2005 ChangeToCodeDescription + * 2006 ChangeToDimensionColumn + * 2007 ChangeToTimeDimensionColumn + * 3000 ModifyTuplesValues + * 3001 ModifyColumnValueOnCondition + * 3002 NewAnnotationColumn + * 3003 Filter + * 3004 Union + * 3005 Denormalize + * 3006 Aggregate + * + */ +public enum OperationsId { + CSVImport("100"), + CSVExport("101"), + SDMXCodelistImport("200"), + SDMXCodelistExport("201"), + SDMXDatasetImport("202"), + SDMXDatasetExport("203"), + JSONImport("300"), + JSONExport("301"), + ValidateCodelist("1000"), + ValidateDataset("1001"), + ChangeTableType("1002"), + CreateDatasetView("1003"), + RemoveColumn("1004"), + ChangeLabel("1005"), + AddLabel("1006"), + RemoveLabel("1007"), + ChangeToAnnotationColumn("2000"), + ChangeToAttributeColumn("2001"), + ChangeToMeasureColumn("2002"), + ChangeToCodeColumn("2003"), + ChangeToCodeName("2004"), + ChangeToCodeDescription("2005"), + ChangeToDimensionColumn("2006"), + ChangeToTimeDimensionColumn("2007"), + ModifyTuplesValues("3000"), + ModifyColumnValueOnCondition("3001"), + NewAnnotationColumn("3002"), + Filter("3003"), + Union("3004"), + Denormalize("3005"), + Aggregate("3006"); + + /** + * @param text + */ + private OperationsId(final String id) { + this.id = id; + } + + private final String id; + + @Override + public String toString() { + return id; + } + +} + + diff --git a/src/main/java/org/gcube/portlets/user/td/gxtservice/server/trservice/TRTasksManager.java b/src/main/java/org/gcube/portlets/user/td/gxtservice/server/trservice/TRTasksManager.java new file mode 100644 index 0000000..6237edb --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/td/gxtservice/server/trservice/TRTasksManager.java @@ -0,0 +1,27 @@ +package org.gcube.portlets.user.td.gxtservice.server.trservice; + +import java.io.Serializable; +import java.util.HashMap; + +import org.gcube.data.analysis.tabulardata.service.operation.Task; + +public class TRTasksManager implements Serializable { + + + private static final long serialVersionUID = 4517156156005181775L; + + protected HashMap trTasksMap=new HashMap(); + + public void add(Task trTask){ + trTasksMap.put(trTask.getId().getValue(),trTask); + }; + + public Task get(Long id){ + return trTasksMap.get(id); + }; + + public void remove(Long id){ + trTasksMap.remove(id); + }; + +} diff --git a/src/main/java/org/gcube/portlets/user/td/gxtservice/shared/Agencies.java b/src/main/java/org/gcube/portlets/user/td/gxtservice/shared/Agencies.java new file mode 100644 index 0000000..28ff91e --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/td/gxtservice/shared/Agencies.java @@ -0,0 +1,83 @@ +/** + * + */ +package org.gcube.portlets.user.td.gxtservice.shared; + +import java.io.Serializable; + +/** + * + * @author "Giancarlo Panichi" + * g.panichi@isti.cnr.it + * + */ +public class Agencies implements Serializable { + + private static final long serialVersionUID = -8353499109124097114L; + + protected String id; + protected String name; + protected String description; + protected String nameLabel; + + + public Agencies(){} + + /** + * @param id + * @param name + * @param agencyId + */ + public Agencies(String id, String name, String description) { + this.id = id; + this.name = name; + this.description = description; + this.nameLabel=id; + } + + /** + * @return the id + */ + public String getId() { + return id; + } + + /** + * @return the name + */ + public String getName() { + return name; + } + + /** + * @return the description + */ + public String getDescription() { + return description; + } + + /** + * + * @return label + */ + public String getNameLabel() { + return nameLabel; + } + + + /** + * {@inheritDoc} + */ + @Override + public String toString() { + StringBuilder builder = new StringBuilder(); + builder.append("Agency [id="); + builder.append(id); + builder.append(", name="); + builder.append(name); + builder.append(", description="); + builder.append(description); + builder.append("]"); + return builder.toString(); + } +} diff --git a/src/main/java/org/gcube/portlets/user/td/gxtservice/shared/Codelist.java b/src/main/java/org/gcube/portlets/user/td/gxtservice/shared/Codelist.java new file mode 100644 index 0000000..c2d4324 --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/td/gxtservice/shared/Codelist.java @@ -0,0 +1,95 @@ +/** + * + */ +package org.gcube.portlets.user.td.gxtservice.shared; + +import java.io.Serializable; + +/** + * @author "Federico De Faveri defaveri@isti.cnr.it" + * + */ +public class Codelist implements Serializable { + + private static final long serialVersionUID = -8353499109124097114L; + + protected String id; + protected String name; + protected String agencyId; + protected String version; + protected String description; + + + public Codelist(){} + + /** + * @param id + * @param name + * @param agencyId + */ + public Codelist(String id, String name, String agencyId,String version, String description) { + this.id = id; + this.name = name; + this.agencyId = agencyId; + this.version = version; + this.description = description; + } + + /** + * @return the id + */ + public String getId() { + return id; + } + + /** + * @return the name + */ + public String getName() { + return name; + } + + /** + * @return the agencyId + */ + public String getAgencyId() { + return agencyId; + } + + + /** + * @return the version + */ + public String getVersion() { + return version; + } + + + /** + * @return the version + */ + public String getDescription() { + return description; + } + + /** + * {@inheritDoc} + */ + @Override + public String toString() { + StringBuilder builder = new StringBuilder(); + builder.append("Codelist [id="); + builder.append(id); + builder.append(", name="); + builder.append(name); + builder.append(", agencyId="); + builder.append(agencyId); + builder.append(", version="); + builder.append(version); + builder.append(", description="); + builder.append(description); + builder.append("]"); + + return builder.toString(); + } +} diff --git a/src/main/java/org/gcube/portlets/user/td/gxtservice/shared/Constants.java b/src/main/java/org/gcube/portlets/user/td/gxtservice/shared/Constants.java new file mode 100644 index 0000000..cda2cfc --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/td/gxtservice/shared/Constants.java @@ -0,0 +1,16 @@ +/** + * + */ +package org.gcube.portlets.user.td.gxtservice.shared; + + +/** + */ +public class Constants { + + public final static String VERSION = "1.0.0"; + public final static String DEFAULT_USER = "giancarlo.panichi"; + public final static String DEFAULT_SCOPE = "/gcube/devsec"; + + +} diff --git a/src/main/java/org/gcube/portlets/user/td/gxtservice/shared/ConstantsWorkspace.java b/src/main/java/org/gcube/portlets/user/td/gxtservice/shared/ConstantsWorkspace.java new file mode 100644 index 0000000..d58dade --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/td/gxtservice/shared/ConstantsWorkspace.java @@ -0,0 +1,23 @@ +/** + * + */ +package org.gcube.portlets.user.td.gxtservice.shared; + + +/** + */ +public class ConstantsWorkspace { + + + public static final String APPLICATION_NAME = "TabularData"; + public static final String ITEM_TYPE_GENERIC = "TabularResource"; + public static final String ITEM_TYPE_CODELIST = "TabularResourceCodelist"; + + public static final String[] ITEM_TYPES = new String[]{ITEM_TYPE_GENERIC, ITEM_TYPE_CODELIST}; + + public static final String ID_KEY = "Id"; + public static final String LAST_TABLE_KEY = "TableId"; + public static final String AGENCY_KEY = "Agency"; + public static final String ITEM_RIGHT ="Right"; + +} diff --git a/src/main/java/org/gcube/portlets/user/td/gxtservice/shared/Dataset.java b/src/main/java/org/gcube/portlets/user/td/gxtservice/shared/Dataset.java new file mode 100644 index 0000000..c6462e1 --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/td/gxtservice/shared/Dataset.java @@ -0,0 +1,93 @@ +/** + * + */ +package org.gcube.portlets.user.td.gxtservice.shared; + +import java.io.Serializable; + +/** + * @author "Federico De Faveri defaveri@isti.cnr.it" + * + */ +public class Dataset implements Serializable { + + private static final long serialVersionUID = -8353499109124097114L; + + protected String id; + protected String name; + protected String agencyId; + protected String version; + protected String description; + + + public Dataset(){} + + /** + * @param id + * @param name + * @param agencyId + */ + public Dataset(String id, String name, String agencyId, String version, String description) { + this.id = id; + this.name = name; + this.agencyId = agencyId; + this.version = version; + this.description = description; + } + + /** + * @return the id + */ + public String getId() { + return id; + } + + /** + * @return the name + */ + public String getName() { + return name; + } + + /** + * @return the agencyId + */ + public String getAgencyId() { + return agencyId; + } + + /** + * @return the version + */ + public String getVersion() { + return version; + } + + + /** + * @return the version + */ + public String getDescription() { + return description; + } + + /** + * {@inheritDoc} + */ + @Override + public String toString() { + StringBuilder builder = new StringBuilder(); + builder.append("Codelist [id="); + builder.append(id); + builder.append(", name="); + builder.append(name); + builder.append(", agencyId="); + builder.append(agencyId); + builder.append(", version="); + builder.append(version); + builder.append(", description="); + builder.append(description); + builder.append("]"); + return builder.toString(); + } +} diff --git a/src/main/java/org/gcube/portlets/user/td/gxtservice/shared/FieldVerifier.java b/src/main/java/org/gcube/portlets/user/td/gxtservice/shared/FieldVerifier.java new file mode 100644 index 0000000..1263ecd --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/td/gxtservice/shared/FieldVerifier.java @@ -0,0 +1,42 @@ +package org.gcube.portlets.user.td.gxtservice.shared; + +/** + *

+ * FieldVerifier validates that the name the user enters is valid. + *

+ *

+ * This class is in the shared packing because we use it in both + * the client code and on the server. On the client, we verify that the name is + * valid before sending an RPC request so the user doesn't have to wait for a + * network round trip to get feedback. On the server, we verify that the name is + * correct to ensure that the input is correct regardless of where the RPC + * originates. + *

+ *

+ * When creating a class that is used on both the client and the server, be sure + * that all code is translatable and does not use native JavaScript. Code that + * is note translatable (such as code that interacts with a database or the file + * system) cannot be compiled into client side JavaScript. Code that uses native + * JavaScript (such as Widgets) cannot be run on the server. + *

+ */ +public class FieldVerifier { + + /** + * Verifies that the specified name is valid for our service. + * + * In this example, we only require that the name is at least four + * characters. In your application, you can use more complex checks to ensure + * that usernames, passwords, email addresses, URLs, and other fields have the + * proper syntax. + * + * @param name the name to validate + * @return true if valid, false if invalid + */ + public static boolean isValidName(String name) { + if (name == null) { + return false; + } + return name.length() > 3; + } +} diff --git a/src/main/java/org/gcube/portlets/user/td/gxtservice/shared/TDGXTServiceException.java b/src/main/java/org/gcube/portlets/user/td/gxtservice/shared/TDGXTServiceException.java new file mode 100644 index 0000000..2c1ff69 --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/td/gxtservice/shared/TDGXTServiceException.java @@ -0,0 +1,30 @@ +/** + * + */ +package org.gcube.portlets.user.td.gxtservice.shared; + +/** + * @author "Federico De Faveri defaveri@isti.cnr.it" + * + */ +public class TDGXTServiceException extends Exception { + + private static final long serialVersionUID = -9066034060104406559L; + + /** + * + */ + public TDGXTServiceException() { + super(); + } + + /** + * @param message + */ + public TDGXTServiceException(String message) { + super(message); + } + + + +} diff --git a/src/main/java/org/gcube/portlets/user/td/gxtservice/shared/TDOpenSession.java b/src/main/java/org/gcube/portlets/user/td/gxtservice/shared/TDOpenSession.java new file mode 100644 index 0000000..970177e --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/td/gxtservice/shared/TDOpenSession.java @@ -0,0 +1,49 @@ +/** + * + */ +package org.gcube.portlets.user.td.gxtservice.shared; + +import java.io.Serializable; + + +/** + * + * @author "Giancarlo Panichi" + * g.panichi@isti.cnr.it + * + */ +public class TDOpenSession implements Serializable { + + private static final long serialVersionUID = 4176034045408445284L; + + protected String id; + + protected TabResource selectedTabResource; + + public String getId() { + return id; + } + public void setId(String id) { + this.id = id; + } + + + public TabResource getSelectedTabResource() { + return selectedTabResource; + } + public void setSelectedTabResource(TabResource selectedTabResource) { + this.selectedTabResource = selectedTabResource; + } + + + public String toString(){ + StringBuilder builder = new StringBuilder(); + builder.append("TDOpenSession [getId()="); + builder.append(getId()); + builder.append(", getSelectedTabResource()="); + builder.append(getSelectedTabResource()); + builder.append("]"); + return builder.toString(); + + } +} diff --git a/src/main/java/org/gcube/portlets/user/td/gxtservice/shared/TRId.java b/src/main/java/org/gcube/portlets/user/td/gxtservice/shared/TRId.java new file mode 100644 index 0000000..df47da8 --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/td/gxtservice/shared/TRId.java @@ -0,0 +1,76 @@ +package org.gcube.portlets.user.td.gxtservice.shared; + +import java.io.Serializable; + +/** + * + * @author "Giancarlo Panichi" + * g.panichi@isti.cnr.it + * + */ +public class TRId implements Serializable{ + + private static final long serialVersionUID = 192846115142001630L; + + /** + * Last table id of tabular resource + */ + String tableId; + + /** + * Tabular resource id + */ + String id; + + /** + * Item on Workspace + */ + String itemId; + + public TRId(){ + + } + + public TRId(String id){ + this.id=id; + this.tableId=null; + } + + + public TRId(String id, String tableId){ + this.id=id; + this.tableId=tableId; + this.itemId=null; + } + + + public String getTableId() { + return tableId; + } + public void setTableId(String tableId) { + this.tableId = tableId; + } + public String getId() { + return id; + } + public void setId(String id) { + this.id = id; + } + + public String getItemId() { + return itemId; + } + + public void setItemId(String itemId) { + this.itemId = itemId; + } + + @Override + public String toString() { + return "TRId [tableId=" + tableId + ", id=" + id + ", itemId=" + itemId + + "]"; + } + + + +} diff --git a/src/main/java/org/gcube/portlets/user/td/gxtservice/shared/TabResource.java b/src/main/java/org/gcube/portlets/user/td/gxtservice/shared/TabResource.java new file mode 100644 index 0000000..5fccc2b --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/td/gxtservice/shared/TabResource.java @@ -0,0 +1,104 @@ +package org.gcube.portlets.user.td.gxtservice.shared; + +import java.io.Serializable; + +import org.gcube.portlets.user.td.gxtservice.shared.TRId; + + +/** + * + * @author "Giancarlo Panichi" + * g.panichi@isti.cnr.it + * + */ +public class TabResource implements Serializable { + + + + private static final long serialVersionUID = -8353499109124097114L; + + protected int id; + protected String name; + protected String description; + protected String agency; + protected String date; + protected String right; + protected TRId trId; + + public TabResource(){} + + public TabResource(int id, String name, String description,String agency, String date, String right, TRId trId){ + this.id=id; + this.name=name; + this.description=description; + this.agency=agency; + this.date=date; + this.right=right; + this.trId=trId; + } + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getAgency() { + return agency; + } + + public void setAgency(String agency) { + this.agency = agency; + } + + public String getDate() { + return date; + } + + public void setDate(String date) { + this.date = date; + } + + public String getRight() { + return right; + } + + public void setRight(String right) { + this.right = right; + } + + public TRId getTrId() { + return trId; + } + + public void setTrId(TRId trId) { + this.trId = trId; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + @Override + public String toString() { + return "TabResource [id=" + id + ", name=" + name + ", description=" + + description + ", agency=" + agency + ", date=" + date + + ", right=" + right + ", trId=" + trId + "]"; + } + + +} diff --git a/src/main/java/org/gcube/portlets/user/td/gxtservice/shared/csv/AvailableCharsetList.java b/src/main/java/org/gcube/portlets/user/td/gxtservice/shared/csv/AvailableCharsetList.java new file mode 100644 index 0000000..398ffca --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/td/gxtservice/shared/csv/AvailableCharsetList.java @@ -0,0 +1,45 @@ +/** + * + */ +package org.gcube.portlets.user.td.gxtservice.shared.csv; + +import java.io.Serializable; +import java.util.ArrayList; + +/** + * @author Federico De Faveri defaveri@isti.cnr.it + * + */ +public class AvailableCharsetList implements Serializable { + + private static final long serialVersionUID = -1635081144303522534L; + + protected ArrayList charsetList; + protected String defaultCharset; + + protected AvailableCharsetList() + {} + + /** + * @param charsetList + * @param defaultCharset + */ + public AvailableCharsetList(ArrayList charsetList, String defaultCharset) { + this.charsetList = charsetList; + this.defaultCharset = defaultCharset; + } + + /** + * @return the charsetList + */ + public ArrayList getCharsetList() { + return charsetList; + } + + /** + * @return the defaultCharset + */ + public String getDefaultCharset() { + return defaultCharset; + } +} diff --git a/src/main/java/org/gcube/portlets/user/td/gxtservice/shared/csv/CSVFileUtil.java b/src/main/java/org/gcube/portlets/user/td/gxtservice/shared/csv/CSVFileUtil.java new file mode 100644 index 0000000..2dbd94a --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/td/gxtservice/shared/csv/CSVFileUtil.java @@ -0,0 +1,191 @@ +/** + * + */ +package org.gcube.portlets.user.td.gxtservice.shared.csv; + +import java.io.BufferedWriter; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.OutputStream; +import java.io.OutputStreamWriter; +import java.io.Reader; +import java.io.Writer; +import java.nio.charset.Charset; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + + + +import org.gcube.portlets.user.td.gxtservice.shared.file.HeaderPresence; +import org.mozilla.universalchardet.UniversalDetector; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import net.sf.csv4j.CSVReader; +import net.sf.csv4j.ParseException; + +/** + * + * @author "Giancarlo Panichi" + * g.panichi@isti.cnr.it + * + */ +public class CSVFileUtil { + + protected static Logger logger = LoggerFactory.getLogger(CSVFileUtil.class); + + public static ArrayList getHeader(File csvFile, CSVParserConfiguration parserConfiguration) throws ParseException, IOException + { + + CSVReader csvReader = createCSVReader(csvFile, parserConfiguration); + switch (parserConfiguration.getHeaderPresence()) { + case FIRST_LINE_COMMENTED_INCLUDED: { + List firstLine = getFirstLine(csvReader, true); + return new ArrayList(firstLine); + } + case FIRST_LINE: { + List firstLine = getFirstLine(csvReader, false); + return new ArrayList(firstLine); + } + case NONE: break; + } + + int fieldCount = (int) csvReader.countFields(); + ArrayList fakeHeaders = new ArrayList(); + for (int i = 0; i getFirstLine(CSVReader csvReader, boolean includeComment) throws ParseException, IOException + { + logger.trace("getFirstLine includeComment: "+includeComment); + + List header = csvReader.readLine(includeComment); + return header==null?Collections.emptyList():header; + } + + protected static CSVReader createCSVReader(File csvFile, CSVParserConfiguration parserConfiguration) throws FileNotFoundException + { + logger.trace("createCSVReader csvFile: "+csvFile+" parserConfiguration: "+parserConfiguration); + Reader fileReader = new InputStreamReader(new FileInputStream(csvFile), parserConfiguration.getCharset()); + CSVReader csvReader = new CSVReader(fileReader, parserConfiguration.getDelimiter(), parserConfiguration.getComment()); + return csvReader; + } + + public static ArrayList checkCSV(File csvFile, CSVParserConfiguration config, long errorsLimit) throws ParseException, IOException + { + return checkCSV(csvFile, config.getCharset(), config.getDelimiter(), config.getComment(), errorsLimit); + } + + public static ArrayList checkCSV(File csvFile, Charset charset, char delimiter, char comment, long errorsLimit) throws IOException + { + logger.trace("checkCSV charset: "+charset+" delimiter: "+delimiter+" comment: "+comment); + ArrayList errors = new ArrayList(); + + Reader fileReader = new InputStreamReader(new FileInputStream(csvFile), charset); + CSVReader csvReader = new CSVReader(fileReader, delimiter, comment); + long count = -1; + long fields = -1; + + do{ + try{ + count = csvReader.countFields(); + }catch(ParseException exception) + { + StringBuilder errorMessage = new StringBuilder(); + errorMessage.append("Error parsing the file "); + errorMessage.append(exception.getMessage()); + + CSVRowError error = new CSVRowError(csvReader.getLineNumber(), csvReader.getCurrentLine(), errorMessage.toString()); + errors.add(error); + logger.trace(error.getErrorDescription()); + continue; + } + + if (count>=0){ + if (fields<0 ) fields = count; + else if (fields != count) { + StringBuilder errorMessage = new StringBuilder(); + errorMessage.append("Expected "); + errorMessage.append(fields); + errorMessage.append(" fields, found "); + errorMessage.append(count); + errorMessage.append(" fields. Check the format of your input file."); + CSVRowError error = new CSVRowError(csvReader.getLineNumber(), csvReader.getCurrentLine(), errorMessage.toString()); + errors.add(error); + logger.trace(error.getErrorDescription()); + } + } + + }while(count >=0 && errors.size()0) writer.write(","); + writer.write(jsonLine); + count++; + + if (count>limit) break; + } + + writer.write("]}"); + + csvReader.close(); + writer.close(); + + } + + public static String guessEncoding(File file) throws IOException + { + FileInputStream fis = new FileInputStream(file); + UniversalDetector detector = new UniversalDetector(null); + byte[] buf = new byte[4096]; + + int nread; + while ((nread = fis.read(buf)) > 0 && !detector.isDone()) { + detector.handleData(buf, 0, nread); + } + + detector.dataEnd(); + String encoding = detector.getDetectedCharset(); + detector.reset(); + fis.close(); + + return encoding; + } + +} diff --git a/src/main/java/org/gcube/portlets/user/td/gxtservice/shared/csv/CSVImportMonitor.java b/src/main/java/org/gcube/portlets/user/td/gxtservice/shared/csv/CSVImportMonitor.java new file mode 100644 index 0000000..d8084da --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/td/gxtservice/shared/csv/CSVImportMonitor.java @@ -0,0 +1,105 @@ +/** + * + */ +package org.gcube.portlets.user.td.gxtservice.shared.csv; + +import java.io.Serializable; + +/** + * + * @author "Giancarlo Panichi" + * g.panichi@isti.cnr.it + * + */ +public class CSVImportMonitor implements Serializable { + + private static final long serialVersionUID = -1150111422206443617L; + + protected long totalLenght; + protected long elaboratedLenght; + protected CSVImportState state; + protected String failureReason; + protected String failureDetails; + + public CSVImportMonitor(){ + state = CSVImportState.STARTED; + } + + public CSVImportMonitor(long totalLenght, long elaboratedLenght, CSVImportState state, String failureReason) { + this.totalLenght = totalLenght; + this.elaboratedLenght = elaboratedLenght; + this.state = state; + this.failureReason = failureReason; + } + + /** + * @return the totalLenght + */ + public long getTotalLenght() { + return totalLenght; + } + + /** + * @return the elaboratedLenght + */ + public long getElaboratedLenght() { + return elaboratedLenght; + } + + + public CSVImportState getState(){ + return state; + } + + /** + * @return the failureDetails + */ + public String getFailureDetails() { + return failureDetails; + } + + public void setState(CSVImportState state) + { + this.state = state; + } + + /** + * @return the reason + */ + public String getFailureReason() { + return failureReason; + } + + /** + * @param totalLenght the totalLenght to set + */ + public void setTotalLenght(long totalLenght) { + this.totalLenght = totalLenght; + } + + /** + * @param elaboratedLenght the elaboratedLenght to set + */ + public void setElaboratedLenght(long elaboratedLenght) { + this.elaboratedLenght = elaboratedLenght; + } + + /** + * @param failed the failed to set + */ + public void setFailed(String failureReason, String failureDetails) { + this.state = CSVImportState.FAILED; + this.failureReason = failureReason; + this.failureDetails = failureDetails; + } + + + @Override + public String toString() { + return "CSVImportMonitor [totalLenght=" + totalLenght + + ", elaboratedLenght=" + elaboratedLenght + ", state=" + state + + ", failureReason=" + failureReason + ", failureDetails=" + + failureDetails + "]"; + } + +} diff --git a/src/main/java/org/gcube/portlets/user/td/gxtservice/shared/csv/CSVImportSession.java b/src/main/java/org/gcube/portlets/user/td/gxtservice/shared/csv/CSVImportSession.java new file mode 100644 index 0000000..bb506c1 --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/td/gxtservice/shared/csv/CSVImportSession.java @@ -0,0 +1,137 @@ +/** + * + */ +package org.gcube.portlets.user.td.gxtservice.shared.csv; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.Arrays; + +import org.gcube.portlets.user.td.gxtservice.shared.TabResource; +import org.gcube.portlets.user.td.gxtservice.shared.source.Source; + + + +/** + * + * @author "Giancarlo Panichi" + * g.panichi@isti.cnr.it + * + */ +public class CSVImportSession implements Serializable { + + private static final long serialVersionUID = 4176034045408445284L; + + protected String id; + protected Source source; + + protected TabResource tabResource; + + protected ArrayList headers = new ArrayList(); + + protected boolean skipInvalidLines = false; + + protected boolean[] columnToImportMask; + + protected String localFileName; + protected long fileLenght; + protected String serverlFileName; + + protected String csvTitle; + protected String csvDescription; + protected String csvSource; + protected String csvRights; + + public String getId() { + return id; + } + public void setId(String id) { + this.id = id; + } + public Source getSource() { + return source; + } + public void setSource(Source source) { + this.source = source; + } + public TabResource getTabResource() { + return tabResource; + } + public void setTabResource(TabResource tabResource) { + this.tabResource = tabResource; + } + public ArrayList getHeaders() { + return headers; + } + public void setHeaders(ArrayList headers) { + this.headers = headers; + } + public boolean isSkipInvalidLines() { + return skipInvalidLines; + } + public void setSkipInvalidLines(boolean skipInvalidLines) { + this.skipInvalidLines = skipInvalidLines; + } + public boolean[] getColumnToImportMask() { + return columnToImportMask; + } + public void setColumnToImportMask(boolean[] columnToImportMask) { + this.columnToImportMask = columnToImportMask; + } + public String getLocalFileName() { + return localFileName; + } + public void setLocalFileName(String localFileName) { + this.localFileName = localFileName; + } + public long getFileLenght() { + return fileLenght; + } + public void setFileLenght(long fileLenght) { + this.fileLenght = fileLenght; + } + public String getServerlFileName() { + return serverlFileName; + } + public void setServerlFileName(String serverlFileName) { + this.serverlFileName = serverlFileName; + } + public String getCsvTitle() { + return csvTitle; + } + public void setCsvTitle(String csvTitle) { + this.csvTitle = csvTitle; + } + public String getCsvDescription() { + return csvDescription; + } + public void setCsvDescription(String csvDescription) { + this.csvDescription = csvDescription; + } + public String getCsvSource() { + return csvSource; + } + public void setCsvSource(String csvSource) { + this.csvSource = csvSource; + } + public String getCsvRights() { + return csvRights; + } + public void setCsvRights(String csvRights) { + this.csvRights = csvRights; + } + @Override + public String toString() { + return "CSVImportSession [id=" + id + ", source=" + source + + ", tabResource=" + tabResource + ", headers=" + headers + + ", skipInvalidLines=" + skipInvalidLines + + ", columnToImportMask=" + Arrays.toString(columnToImportMask) + + ", localFileName=" + localFileName + ", fileLenght=" + + fileLenght + ", serverlFileName=" + serverlFileName + + ", csvTitle=" + csvTitle + ", csvDescription=" + + csvDescription + ", csvSource=" + csvSource + ", csvRights=" + + csvRights + "]"; + } + + +} diff --git a/src/main/java/org/gcube/portlets/user/td/gxtservice/shared/csv/CSVImportState.java b/src/main/java/org/gcube/portlets/user/td/gxtservice/shared/csv/CSVImportState.java new file mode 100644 index 0000000..a5015d0 --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/td/gxtservice/shared/csv/CSVImportState.java @@ -0,0 +1,32 @@ +/** + * + */ +package org.gcube.portlets.user.td.gxtservice.shared.csv; + +/** + * + * @author "Giancarlo Panichi" + * g.panichi@isti.cnr.it + * + */ +public enum CSVImportState { + + /** + * The operation is in progress. + */ + STARTED, + /** + * The operation is in progress. + */ + INPROGRESS, + + /** + * The operation is completed. + */ + COMPLETED, + + /** + * The operation is failed. + */ + FAILED; +} diff --git a/src/main/java/org/gcube/portlets/user/td/gxtservice/shared/csv/CSVParserConfiguration.java b/src/main/java/org/gcube/portlets/user/td/gxtservice/shared/csv/CSVParserConfiguration.java new file mode 100644 index 0000000..fcad4a0 --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/td/gxtservice/shared/csv/CSVParserConfiguration.java @@ -0,0 +1,91 @@ +/** + * + */ +package org.gcube.portlets.user.td.gxtservice.shared.csv; + +import java.nio.charset.Charset; + +import org.gcube.portlets.user.td.gxtservice.shared.file.HeaderPresence; + + + +/** + * @author Federico De Faveri defaveri@isti.cnr.it + * + */ +public class CSVParserConfiguration { + + protected Charset charset; + protected char delimiter; + protected char comment; + protected HeaderPresence headerPresence; + + public CSVParserConfiguration() { + } + + /** + * @param charset + * @param delimiter + * @param comment + * @param hasHeader + */ + public CSVParserConfiguration(Charset charset, char delimiter, char comment, HeaderPresence headerPresence) { + this.charset = charset; + this.delimiter = delimiter; + this.comment = comment; + this.headerPresence = headerPresence; + } + + public void update(String charset, char delimiter, char comment, HeaderPresence headerPresence) { + this.charset = Charset.forName(charset); + this.delimiter = delimiter; + this.comment = comment; + this.headerPresence = headerPresence; + } + + /** + * @return the charset + */ + public Charset getCharset() { + return charset; + } + + /** + * @return the delimiter + */ + public char getDelimiter() { + return delimiter; + } + + /** + * @return the comment + */ + public char getComment() { + return comment; + } + + /** + * @return the headerPresence + */ + public HeaderPresence getHeaderPresence() { + return headerPresence; + } + + /** + * {@inheritDoc} + */ + @Override + public String toString() { + StringBuilder builder = new StringBuilder(); + builder.append("CSVParsingConfig [charset="); + builder.append(charset); + builder.append(", delimiter="); + builder.append(delimiter); + builder.append(", comment="); + builder.append(comment); + builder.append(", headerPresence="); + builder.append(headerPresence); + builder.append("]"); + return builder.toString(); + } +} diff --git a/src/main/java/org/gcube/portlets/user/td/gxtservice/shared/csv/CSVRowError.java b/src/main/java/org/gcube/portlets/user/td/gxtservice/shared/csv/CSVRowError.java new file mode 100644 index 0000000..5278e16 --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/td/gxtservice/shared/csv/CSVRowError.java @@ -0,0 +1,80 @@ +/** + * + */ +package org.gcube.portlets.user.td.gxtservice.shared.csv; + +import java.io.Serializable; + +/** + * An error for a row in the CSV. + * @author Federico De Faveri defaveri@isti.cnr.it + */ +public class CSVRowError implements Serializable { + + private static final long serialVersionUID = 4680781887858741657L; + + protected static int seed; + + protected int id; + protected int lineNumber; + protected String lineValue; + protected String errorDescription; + + public CSVRowError(){} + + /** + * @param lineNumber the row number. + * @param lineValue the line value. + * @param errorDescription the error description. + */ + public CSVRowError(int lineNumber, String lineValue, String errorDescription) { + this.id = seed++; + this.lineNumber = lineNumber; + this.lineValue = lineValue; + this.errorDescription = errorDescription; + } + + /** + * @return the id + */ + public int getId() { + return id; + } + + /** + * @return the lineNumber + */ + public int getLineNumber() { + return lineNumber; + } + + /** + * @return the line value + */ + public String getLineValue() { + return lineValue; + } + + /** + * @return the error description. + */ + public String getErrorDescription() { + return errorDescription; + } + + /** + * {@inheritDoc} + */ + @Override + public String toString() { + StringBuilder builder = new StringBuilder(); + builder.append("CSVRowError [lineNumber="); + builder.append(lineNumber); + builder.append(", lineValue="); + builder.append(lineValue); + builder.append(", errorDescription="); + builder.append(errorDescription); + builder.append("]"); + return builder.toString(); + } +} diff --git a/src/main/java/org/gcube/portlets/user/td/gxtservice/shared/document/CodelistDocument.java b/src/main/java/org/gcube/portlets/user/td/gxtservice/shared/document/CodelistDocument.java new file mode 100644 index 0000000..5c45b40 --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/td/gxtservice/shared/document/CodelistDocument.java @@ -0,0 +1,59 @@ +package org.gcube.portlets.user.td.gxtservice.shared.document; + + +/** + * + * @author "Giancarlo Panichi" + * g.panichi@isti.cnr.it + * + */ +public class CodelistDocument implements SDMXDocument { + + private static final long serialVersionUID = 8732679674877915333L; + + public static final CodelistDocument INSTANCE = new CodelistDocument(); + + + /** + * {@inheritDoc} + */ + @Override + public String getId() { + return "codelist"; + } + + /** + * {@inheritDoc} + */ + @Override + public String getName() { + return "Codelist document"; + } + + /** + * {@inheritDoc} + */ + @Override + public String getDescription() { + return "Select this document if you want to retrive codelist"; + } + + /** + * {@inheritDoc} + */ + @Override + public String toString() { + StringBuilder builder = new StringBuilder(); + builder.append("Codelist Document [getId()="); + builder.append(getId()); + builder.append(", getName()="); + builder.append(getName()); + builder.append(", getDescription()="); + builder.append(getDescription()); + builder.append("]"); + return builder.toString(); + } + + + +} diff --git a/src/main/java/org/gcube/portlets/user/td/gxtservice/shared/document/DatasetDocument.java b/src/main/java/org/gcube/portlets/user/td/gxtservice/shared/document/DatasetDocument.java new file mode 100644 index 0000000..e152326 --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/td/gxtservice/shared/document/DatasetDocument.java @@ -0,0 +1,60 @@ +package org.gcube.portlets.user.td.gxtservice.shared.document; + + +/** + * + * @author "Giancarlo Panichi" + * g.panichi@isti.cnr.it + * + */ +public class DatasetDocument implements SDMXDocument { + + + private static final long serialVersionUID = 6134053739629827095L; + + public static final DatasetDocument INSTANCE = new DatasetDocument(); + + + /** + * {@inheritDoc} + */ + @Override + public String getId() { + return "dataset"; + } + + /** + * {@inheritDoc} + */ + @Override + public String getName() { + return "Dataset document"; + } + + /** + * {@inheritDoc} + */ + @Override + public String getDescription() { + return "Select this document if you want to retrive dataset"; + } + + /** + * {@inheritDoc} + */ + @Override + public String toString() { + StringBuilder builder = new StringBuilder(); + builder.append("DataSet Document [getId()="); + builder.append(getId()); + builder.append(", getName()="); + builder.append(getName()); + builder.append(", getDescription()="); + builder.append(getDescription()); + builder.append("]"); + return builder.toString(); + } + + + +} diff --git a/src/main/java/org/gcube/portlets/user/td/gxtservice/shared/document/SDMXDocument.java b/src/main/java/org/gcube/portlets/user/td/gxtservice/shared/document/SDMXDocument.java new file mode 100644 index 0000000..8ace083 --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/td/gxtservice/shared/document/SDMXDocument.java @@ -0,0 +1,38 @@ +/** + * + */ +package org.gcube.portlets.user.td.gxtservice.shared.document; + +import java.io.Serializable; + + + + +/** + * SDMX document type interface. All SDMX document type have to implement this interface. + * @author "Giancarlo Panichi" + * g.panichi@isti.cnr.it + * + */ +public interface SDMXDocument extends Serializable { + + /** + * Returns the document id. + * @return the document id. + */ + public String getId(); + + /** + * Returns the document name. + * @return the document name. + */ + public String getName(); + + /** + * Returns the document description. + * @return the document description. + */ + public String getDescription(); + + +} diff --git a/src/main/java/org/gcube/portlets/user/td/gxtservice/shared/file/FileUploadMonitor.java b/src/main/java/org/gcube/portlets/user/td/gxtservice/shared/file/FileUploadMonitor.java new file mode 100644 index 0000000..a9eabec --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/td/gxtservice/shared/file/FileUploadMonitor.java @@ -0,0 +1,116 @@ +/** + * + */ +package org.gcube.portlets.user.td.gxtservice.shared.file; + +import java.io.Serializable; + +/** + * + * @author "Giancarlo Panichi" + * g.panichi@isti.cnr.it + * + */ +public class FileUploadMonitor implements Serializable { + + private static final long serialVersionUID = -1150111422206443617L; + + protected long totalLenght; + protected long elaboratedLenght; + protected FileUploadState state; + protected String failureReason; + protected String failureDetails; + + public FileUploadMonitor(){ + state = FileUploadState.INPROGRESS; + } + + public FileUploadMonitor(long totalLenght, long elaboratedLenght, FileUploadState state, String failureReason) { + this.totalLenght = totalLenght; + this.elaboratedLenght = elaboratedLenght; + this.state = state; + this.failureReason = failureReason; + } + + /** + * @return the totalLenght + */ + public long getTotalLenght() { + return totalLenght; + } + + /** + * @return the elaboratedLenght + */ + public long getElaboratedLenght() { + return elaboratedLenght; + } + + + public FileUploadState getState(){ + return state; + } + + /** + * @return the failureDetails + */ + public String getFailureDetails() { + return failureDetails; + } + + public void setState(FileUploadState state) + { + this.state = state; + } + + /** + * @return the reason + */ + public String getFailureReason() { + return failureReason; + } + + /** + * @param totalLenght the totalLenght to set + */ + public void setTotalLenght(long totalLenght) { + this.totalLenght = totalLenght; + } + + /** + * @param elaboratedLenght the elaboratedLenght to set + */ + public void setElaboratedLenght(long elaboratedLenght) { + this.elaboratedLenght = elaboratedLenght; + } + + /** + * @param failed the failed to set + */ + public void setFailed(String failureReason, String failureDetails) { + this.state = FileUploadState.FAILED; + this.failureReason = failureReason; + this.failureDetails = failureDetails; + } + + /** + * {@inheritDoc} + */ + @Override + public String toString() { + StringBuilder builder = new StringBuilder(); + builder.append("OperationProgress [totalLenght="); + builder.append(totalLenght); + builder.append(", elaboratedLenght="); + builder.append(elaboratedLenght); + builder.append(", state="); + builder.append(state); + builder.append(", failureReason="); + builder.append(failureReason); + builder.append(", failureDetails="); + builder.append(failureDetails); + builder.append("]"); + return builder.toString(); + } + +} diff --git a/src/main/java/org/gcube/portlets/user/td/gxtservice/shared/file/FileUploadState.java b/src/main/java/org/gcube/portlets/user/td/gxtservice/shared/file/FileUploadState.java new file mode 100644 index 0000000..0979df8 --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/td/gxtservice/shared/file/FileUploadState.java @@ -0,0 +1,28 @@ +/** + * + */ +package org.gcube.portlets.user.td.gxtservice.shared.file; + +/** + * @author Federico De Faveri defaveri@isti.cnr.it + * + */ +public enum FileUploadState { + + STARTED, + + /** + * The operation is in progress. + */ + INPROGRESS, + + /** + * The operation is completed. + */ + COMPLETED, + + /** + * The operation is failed. + */ + FAILED; +} diff --git a/src/main/java/org/gcube/portlets/user/td/gxtservice/shared/file/HeaderPresence.java b/src/main/java/org/gcube/portlets/user/td/gxtservice/shared/file/HeaderPresence.java new file mode 100644 index 0000000..60bc393 --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/td/gxtservice/shared/file/HeaderPresence.java @@ -0,0 +1,39 @@ +/** + * + */ +package org.gcube.portlets.user.td.gxtservice.shared.file; + +/** + * + * @author "Giancarlo Panichi" + * g.panichi@isti.cnr.it + * + */ +public enum HeaderPresence { + + NONE("None"), + FIRST_LINE("First line"), + FIRST_LINE_COMMENTED_INCLUDED("First line, include commented"); + + protected String label; + + private HeaderPresence(String label) + { + this.label = label; + } + + /** + * @return the label + */ + public String getLabel() { + return label; + } + + public static HeaderPresence fromLabel(String label) + { + for (HeaderPresence headerPresence:HeaderPresence.values()) { + if (headerPresence.label.equals(label)) return headerPresence; + } + throw new IllegalArgumentException("Unknown label value \""+label+"\""); + } +} diff --git a/src/main/java/org/gcube/portlets/user/td/gxtservice/shared/sdmx/SDMXImportMonitor.java b/src/main/java/org/gcube/portlets/user/td/gxtservice/shared/sdmx/SDMXImportMonitor.java new file mode 100644 index 0000000..b59270c --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/td/gxtservice/shared/sdmx/SDMXImportMonitor.java @@ -0,0 +1,77 @@ +package org.gcube.portlets.user.td.gxtservice.shared.sdmx; + +import java.io.Serializable; + +import org.gcube.portlets.user.td.gxtservice.shared.TRId; + + +/** + * + * @author "Giancarlo Panichi" + * g.panichi@isti.cnr.it + * + */ +public class SDMXImportMonitor implements Serializable { + + private static final long serialVersionUID = -5998841163159590481L; + + protected float progress; + protected State status; + protected String statusDescription; + protected Throwable error; + protected TRId trId; + + public float getProgress(){ + return progress; + }; + + public State getStatus(){ + return status; + } + + public String getStatusDescription(){ + return statusDescription; + } + + public void setProgress(float progress) { + this.progress = progress; + } + + public void setStatus(State status) { + this.status = status; + } + + public void setStatus(int status) { + this.status = State.values()[status]; + } + + public void setStatusDescription(String statusDescription) { + this.statusDescription = statusDescription; + } + + public Throwable getError() { + return error; + } + + public void setError(Throwable error) { + this.error = error; + } + + public TRId getTrId() { + return trId; + } + + public void setTrId(TRId trId) { + this.trId = trId; + } + + + @Override + public String toString() { + return "SDMXImportMonitor [progress=" + progress + ", status=" + status + + ", statusDescription=" + statusDescription + ", error=" + + error + ", trId=" + trId + "]"; + } + + +} diff --git a/src/main/java/org/gcube/portlets/user/td/gxtservice/shared/sdmx/SDMXImportSession.java b/src/main/java/org/gcube/portlets/user/td/gxtservice/shared/sdmx/SDMXImportSession.java new file mode 100644 index 0000000..ab752ae --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/td/gxtservice/shared/sdmx/SDMXImportSession.java @@ -0,0 +1,75 @@ +/** + * + */ +package org.gcube.portlets.user.td.gxtservice.shared.sdmx; + +import java.io.Serializable; + +import org.gcube.portlets.user.td.gxtservice.shared.Codelist; +import org.gcube.portlets.user.td.gxtservice.shared.TabResource; +import org.gcube.portlets.user.td.gxtservice.shared.document.SDMXDocument; +import org.gcube.portlets.user.td.gxtservice.shared.source.Source; + + + +/** + * + * @author "Giancarlo Panichi" + * g.panichi@isti.cnr.it + * + */ +public class SDMXImportSession implements Serializable { + + private static final long serialVersionUID = 4176034045408445284L; + + protected String id; + protected SDMXDocument sdmxDocument;//operationID + protected Source source; + protected Codelist selectedCodelist; + protected TabResource tabResource; + + + public void setId(String id) { + this.id = id; + } + public SDMXDocument getSDMXDocument() { + return sdmxDocument; + } + public void setSDMXDocument(SDMXDocument document) { + this.sdmxDocument = document; + } + public Source getSource() { + return source; + } + public void setSource(Source source) { + this.source = source; + } + + + public Codelist getSelectedCodelist() { + return selectedCodelist; + } + public void setSelectedCodelist(Codelist selectedCodelist) { + this.selectedCodelist = selectedCodelist; + } + + + public TabResource getTabResource() { + return tabResource; + } + public void setTabResource(TabResource tabResource) { + this.tabResource = tabResource; + } + public String getId() { + return id; + } + @Override + public String toString() { + return "SDMXImportSession [id=" + id + ", sdmxDocument=" + sdmxDocument + + ", source=" + source + ", selectedCodelist=" + + selectedCodelist + ", tabResource=" + tabResource + "]"; + } + + + +} diff --git a/src/main/java/org/gcube/portlets/user/td/gxtservice/shared/sdmx/State.java b/src/main/java/org/gcube/portlets/user/td/gxtservice/shared/sdmx/State.java new file mode 100644 index 0000000..e38cd7c --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/td/gxtservice/shared/sdmx/State.java @@ -0,0 +1,15 @@ +package org.gcube.portlets.user.td.gxtservice.shared.sdmx; + +import java.io.Serializable; + + +public enum State implements Serializable{ + + WAITING, + INITIALIZING, + IN_PROGRESS, + SUCCEDED, + FAILED, + ABORTED; + +} diff --git a/src/main/java/org/gcube/portlets/user/td/gxtservice/shared/source/FileSource.java b/src/main/java/org/gcube/portlets/user/td/gxtservice/shared/source/FileSource.java new file mode 100644 index 0000000..26f4c82 --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/td/gxtservice/shared/source/FileSource.java @@ -0,0 +1,55 @@ +package org.gcube.portlets.user.td.gxtservice.shared.source; + + + +public class FileSource implements Source { + + + private static final long serialVersionUID = -5990408094142286488L; + + public static final FileSource INSTANCE = new FileSource(); + + + /** + * {@inheritDoc} + */ + @Override + public String getId() { + return "File"; + } + + /** + * {@inheritDoc} + */ + @Override + public String getName() { + return "File source"; + } + + /** + * {@inheritDoc} + */ + @Override + public String getDescription() { + return "Select this source if you want to retrive document from File"; + } + + /** + * {@inheritDoc} + */ + @Override + public String toString() { + StringBuilder builder = new StringBuilder(); + builder.append("File source [getId()="); + builder.append(getId()); + builder.append(", getName()="); + builder.append(getName()); + builder.append(", getDescription()="); + builder.append(getDescription()); + builder.append("]"); + return builder.toString(); + } + + + +} \ No newline at end of file diff --git a/src/main/java/org/gcube/portlets/user/td/gxtservice/shared/source/SDMXRegistrySource.java b/src/main/java/org/gcube/portlets/user/td/gxtservice/shared/source/SDMXRegistrySource.java new file mode 100644 index 0000000..e33d44e --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/td/gxtservice/shared/source/SDMXRegistrySource.java @@ -0,0 +1,70 @@ +package org.gcube.portlets.user.td.gxtservice.shared.source; + +import org.gcube.portlets.user.td.gxtservice.shared.source.Source; + + + + +public class SDMXRegistrySource implements Source { + + + private static final long serialVersionUID = 3254879141340681969L; + + public static final SDMXRegistrySource INSTANCE = new SDMXRegistrySource(); + + protected String url; + + + /** + * {@inheritDoc} + */ + @Override + public String getId() { + return "SDMXRegistry"; + } + + /** + * {@inheritDoc} + */ + @Override + public String getName() { + return "SDMX Registry source"; + } + + /** + * {@inheritDoc} + */ + @Override + public String getDescription() { + return "Select this source if you want to retrive document from SDMX Registry"; + } + + public String getUrl() { + return url; + } + + public void setUrl(String url) { + this.url = url; + } + + /** + * {@inheritDoc} + */ + @Override + public String toString() { + StringBuilder builder = new StringBuilder(); + builder.append("SDMXRegistry source [getId()="); + builder.append(getId()); + builder.append(", getName()="); + builder.append(getName()); + builder.append(", getDescription()="); + builder.append(getDescription()); + builder.append(", getUrl()="); + builder.append(getUrl()); + builder.append("]"); + return builder.toString(); + } + + + +} \ No newline at end of file diff --git a/src/main/java/org/gcube/portlets/user/td/gxtservice/shared/source/Source.java b/src/main/java/org/gcube/portlets/user/td/gxtservice/shared/source/Source.java new file mode 100644 index 0000000..b9042a6 --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/td/gxtservice/shared/source/Source.java @@ -0,0 +1,27 @@ +package org.gcube.portlets.user.td.gxtservice.shared.source; + +import java.io.Serializable; + + +public interface Source extends Serializable { + + /** + * Returns the document type id. + * @return the document type id. + */ + public String getId(); + + /** + * Returns the document type name. + * @return the document type name. + */ + public String getName(); + + /** + * Returns the document type description. + * @return the document type description. + */ + public String getDescription(); + + +} diff --git a/src/main/java/org/gcube/portlets/user/td/gxtservice/shared/source/WorkspaceSource.java b/src/main/java/org/gcube/portlets/user/td/gxtservice/shared/source/WorkspaceSource.java new file mode 100644 index 0000000..2e6a78b --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/td/gxtservice/shared/source/WorkspaceSource.java @@ -0,0 +1,56 @@ +package org.gcube.portlets.user.td.gxtservice.shared.source; + + + + +public class WorkspaceSource implements Source { + + + private static final long serialVersionUID = 2826706131664617270L; + + public static final WorkspaceSource INSTANCE = new WorkspaceSource(); + + + /** + * {@inheritDoc} + */ + @Override + public String getId() { + return "Workspace"; + } + + /** + * {@inheritDoc} + */ + @Override + public String getName() { + return "Workspace source"; + } + + /** + * {@inheritDoc} + */ + @Override + public String getDescription() { + return "Select this source if you want to retrive document from Workspace"; + } + + /** + * {@inheritDoc} + */ + @Override + public String toString() { + StringBuilder builder = new StringBuilder(); + builder.append("Workspace source [getId()="); + builder.append(getId()); + builder.append(", getName()="); + builder.append(getName()); + builder.append(", getDescription()="); + builder.append(getDescription()); + builder.append("]"); + return builder.toString(); + } + + + +} \ No newline at end of file diff --git a/src/main/resources/org/gcube/portlets/user/td/gxtservice/GXTService.gwt.xml b/src/main/resources/org/gcube/portlets/user/td/gxtservice/GXTService.gwt.xml new file mode 100644 index 0000000..90f3a23 --- /dev/null +++ b/src/main/resources/org/gcube/portlets/user/td/gxtservice/GXTService.gwt.xml @@ -0,0 +1,29 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/resources/org/gcube/portlets/user/td/gxtservice/client/Messages.properties b/src/main/resources/org/gcube/portlets/user/td/gxtservice/client/Messages.properties new file mode 100644 index 0000000..c222555 --- /dev/null +++ b/src/main/resources/org/gcube/portlets/user/td/gxtservice/client/Messages.properties @@ -0,0 +1,2 @@ +sendButton = Send +nameField = Enter your name \ No newline at end of file diff --git a/src/main/resources/org/gcube/portlets/user/td/gxtservice/client/Messages_fr.properties b/src/main/resources/org/gcube/portlets/user/td/gxtservice/client/Messages_fr.properties new file mode 100644 index 0000000..b4a7627 --- /dev/null +++ b/src/main/resources/org/gcube/portlets/user/td/gxtservice/client/Messages_fr.properties @@ -0,0 +1,2 @@ +sendButton = Envoyer +nameField = Entrez votre nom \ No newline at end of file diff --git a/src/main/webapp/GXTService.css b/src/main/webapp/GXTService.css new file mode 100644 index 0000000..7aca7ac --- /dev/null +++ b/src/main/webapp/GXTService.css @@ -0,0 +1,34 @@ +/** Add css rules here for your application. */ + + +/** Example rules used by the template application (remove for your app) */ +h1 { + font-size: 2em; + font-weight: bold; + color: #777777; + margin: 40px 0px 70px; + text-align: center; +} + +.sendButton { + display: block; + font-size: 16pt; +} + +/** Most GWT widgets already have a style name defined */ +.gwt-DialogBox { + width: 400px; +} + +.dialogVPanel { + margin: 5px; +} + +.serverResponseLabelError { + color: red; +} + +/** Set ids using widget.getElement().setId("idOfElement") */ +#closeButton { + margin: 15px 6px 6px; +} diff --git a/src/main/webapp/GXTService.html b/src/main/webapp/GXTService.html new file mode 100644 index 0000000..e07c383 --- /dev/null +++ b/src/main/webapp/GXTService.html @@ -0,0 +1,50 @@ + + + + + + + + + + + + + + + + + + + + Web Application Starter Project + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/webapp/WEB-INF/web.xml b/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 0000000..ff23467 --- /dev/null +++ b/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,58 @@ + + + + + + + + TDGXTService + org.gcube.portlets.user.td.gxtservice.server.TDGXTServiceImpl + + + + CSVImportFileServlet + org.gcube.portlets.user.td.gxtservice.server.CSVImportFileServlet + + + + LocalUploadServlet + org.gcube.portlets.user.td.gxtservice.server.LocalUploadServlet + + + + jUnitHostImpl + com.google.gwt.junit.server.JUnitHostImpl + + + + + + + TDGXTService + /tdgxtservice/TDGXTService + + + + CSVImportFileServlet + /tdgxtservice/CSVImportFileServlet + + + + LocalUploadServlet + /tdgxtservice/LocalUploadServlet + + + + jUnitHostImpl + TDServiceManagerWidgets/junithost/* + + + + + + Service.html + + + diff --git a/src/test/java/org/gcube/portlets/user/td/gxtservice/client/GwtTestGXTService.java b/src/test/java/org/gcube/portlets/user/td/gxtservice/client/GwtTestGXTService.java new file mode 100644 index 0000000..acc19c6 --- /dev/null +++ b/src/test/java/org/gcube/portlets/user/td/gxtservice/client/GwtTestGXTService.java @@ -0,0 +1,76 @@ +package org.gcube.portlets.user.td.gxtservice.client; + +import org.gcube.portlets.user.td.gxtservice.client.rpc.TDGXTService; +import org.gcube.portlets.user.td.gxtservice.client.rpc.TDGXTServiceAsync; +import org.gcube.portlets.user.td.gxtservice.shared.TabResource; + +import com.google.gwt.core.client.GWT; +import com.google.gwt.junit.client.GWTTestCase; +import com.google.gwt.user.client.rpc.AsyncCallback; +import com.google.gwt.user.client.rpc.ServiceDefTarget; + +/** + * GWT JUnit integration tests must extend GWTTestCase. Using + * "GwtTest*" naming pattern exclude them from running with + * surefire during the test phase. + * + * If you run the tests using the Maven command line, you will have to navigate + * with your browser to a specific url given by Maven. See + * http://mojo.codehaus.org/gwt-maven-plugin/user-guide/testing.html for + * details. + */ +public class GwtTestGXTService extends GWTTestCase { + + /** + * Must refer to a valid module that sources this class. + */ + public String getModuleName() { + return "org.gcube.portlets.user.td.gxtservice.GXTServiceJUnit"; + } + + /** + * This test will send a request to the server + */ + public void testCreateTabResource() { + // Create the service that we will test. + TDGXTServiceAsync tdGXTService = GWT.create(TDGXTService.class); + ServiceDefTarget target = (ServiceDefTarget) tdGXTService; + System.out.println(GWT.getModuleBaseURL() + "TDGXTService"); + target.setServiceEntryPoint(GWT.getModuleBaseURL() + "TDGXTService"); + + // Since RPC calls are asynchronous, we will need to wait for a response + // after this test method returns. This line tells the test runner to + // wait + // up to 7 seconds before timing out. + delayTestFinish(7000); + TabResource tabResource=new TabResource(); + tabResource.setName("TestTabularResource"); + tabResource.setAgency("FAO"); + tabResource.setDescription("Tabular Resource Test"); + tabResource.setRight(""); + + // Send a request to the server. + TDGXTServiceAsync.INSTANCE.createTabularResource(tabResource,new AsyncCallback() { + + @Override + public void onFailure(Throwable caught) { + // The request resulted in an unexpected error. + fail("Request failure: " + caught.getMessage()); + + } + + @Override + public void onSuccess(TabResource result) { + assertTrue(result != null); + System.out.println(result); + finishTest(); + + } + + }); + + } + +} + + diff --git a/src/test/resources/org/gcube/portlets/user/td/gxtservice/GXTServiceJUnit.gwt.xml b/src/test/resources/org/gcube/portlets/user/td/gxtservice/GXTServiceJUnit.gwt.xml new file mode 100644 index 0000000..c901782 --- /dev/null +++ b/src/test/resources/org/gcube/portlets/user/td/gxtservice/GXTServiceJUnit.gwt.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + diff --git a/templates/INSTALL b/templates/INSTALL new file mode 100644 index 0000000..e69de29 diff --git a/templates/LICENSE b/templates/LICENSE new file mode 100644 index 0000000..cc51139 --- /dev/null +++ b/templates/LICENSE @@ -0,0 +1,6 @@ +gCube System - License +------------------------------------------------------------ + +The gCube/gCore software is licensed as Free Open Source software conveying to the EUPL (http://ec.europa.eu/idabc/eupl). +The software and documentation is provided by its authors/distributors "as is" and no expressed or +implied warranty is given for its use, quality or fitness for a particular case. \ No newline at end of file diff --git a/templates/MAINTAINERS b/templates/MAINTAINERS new file mode 100644 index 0000000..0bc9be3 --- /dev/null +++ b/templates/MAINTAINERS @@ -0,0 +1 @@ +Giancarlo Panichi (giancarlo.panichi@isti.cnr.it), CNR Pisa, Istituto di Scienza e Tecnologie dell'Informazione "A. Faedo" diff --git a/templates/README b/templates/README new file mode 100644 index 0000000..e81341a --- /dev/null +++ b/templates/README @@ -0,0 +1,40 @@ +The gCube System - ${name} +------------------------------------------------------------ + +This work has been supported by the following European projects: iMarine (FP7-INFRASTRUCTURES-2011-2) + +Authors +------- + +Giancarlo Panichi (giancarlo.panichi@isti.cnr.it), CNR Pisa, +Istituto di Scienza e Tecnologie dell'Informazione "A. Faedo" + + +Version and Release Date +------------------------ + +v. ${version} (${release.date}) + +Description +----------- + +${project.description} + +Download information +-------------------- +Source code URL: ${scm.url} + + +Documentation +------------- + +${project.description} + + +Licensing +--------- + +This software is licensed under the terms you may find in the file named "LICENSE" in this directory. + + + diff --git a/templates/changelog.xml b/templates/changelog.xml new file mode 100644 index 0000000..02e8e63 --- /dev/null +++ b/templates/changelog.xml @@ -0,0 +1,6 @@ + + + First Release + + \ No newline at end of file diff --git a/templates/descriptor.xml b/templates/descriptor.xml new file mode 100644 index 0000000..b978636 --- /dev/null +++ b/templates/descriptor.xml @@ -0,0 +1,39 @@ + + servicearchive + + tar.gz + + / + + + ${distroDirectory} + / + true + + README + LICENSE + INSTALL + MAINTAINERS + changelog.xml + + 755 + + + + + ${distroDirectory}/svnpath.txt + /${artifactId} + + + ${configDirectory}/profile.xml + / + + + target/${build.finalName}.${packaging} + /${artifactId} + + + \ No newline at end of file diff --git a/templates/profile.xml b/templates/profile.xml new file mode 100644 index 0000000..ffa3274 --- /dev/null +++ b/templates/profile.xml @@ -0,0 +1,29 @@ + + + + Service + + ${project.description} + PortletsUser + ${project.name} + 1.0.0 + + + ${project.description} + ${project.name} + ${version} + + ${project.groupId} + ${project.artifactId} + ${project.version} + + library + + ${project.build.finalName}.${project.packaging} + + + + + + + diff --git a/templates/svnpath.txt b/templates/svnpath.txt new file mode 100644 index 0000000..dcd0d22 --- /dev/null +++ b/templates/svnpath.txt @@ -0,0 +1 @@ +${scm.url} \ No newline at end of file