refs:3772: SAI - Create a github project importer
https://support.d4science.org/issues/3772 Updated SAI to liferay 6.2 git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/statistical-algorithms-importer@129242 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
0dc91f41e0
commit
cd983e2180
|
@ -1,12 +1,12 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" output="target/statistical-algorithms-importer-1.1.0-SNAPSHOT/WEB-INF/classes" path="src/main/java">
|
||||
<classpathentry kind="src" output="target/statistical-algorithms-importer-1.2.0-SNAPSHOT/WEB-INF/classes" path="src/main/java">
|
||||
<attributes>
|
||||
<attribute name="optional" value="true"/>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry excluding="**" kind="src" output="target/statistical-algorithms-importer-1.1.0-SNAPSHOT/WEB-INF/classes" path="src/main/resources">
|
||||
<classpathentry excluding="**" kind="src" output="target/statistical-algorithms-importer-1.2.0-SNAPSHOT/WEB-INF/classes" path="src/main/resources">
|
||||
<attributes>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
|
@ -45,5 +45,5 @@
|
|||
</classpathentry>
|
||||
<classpathentry kind="lib" path="/home/giancarlo/gwt/gwt-2.6.1/validation-api-1.0.0.GA.jar" sourcepath="/home/giancarlo/gwt/gwt-2.6.1/validation-api-1.0.0.GA-sources.jar"/>
|
||||
<classpathentry kind="lib" path="/home/giancarlo/gwt/gwt-2.6.1/validation-api-1.0.0.GA-sources.jar"/>
|
||||
<classpathentry kind="output" path="target/statistical-algorithms-importer-1.1.0-SNAPSHOT/WEB-INF/classes"/>
|
||||
<classpathentry kind="output" path="target/statistical-algorithms-importer-1.2.0-SNAPSHOT/WEB-INF/classes"/>
|
||||
</classpath>
|
||||
|
|
177
pom.xml
177
pom.xml
|
@ -13,7 +13,7 @@
|
|||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>org.gcube.portlets.user</groupId>
|
||||
<artifactId>statistical-algorithms-importer</artifactId>
|
||||
<version>1.1.0-SNAPSHOT</version>
|
||||
<version>1.2.0-SNAPSHOT</version>
|
||||
<packaging>war</packaging>
|
||||
|
||||
|
||||
|
@ -60,12 +60,7 @@
|
|||
<profile>
|
||||
<id>localRun</id>
|
||||
<dependencies>
|
||||
<!-- Xerces -->
|
||||
<dependency>
|
||||
<groupId>xerces</groupId>
|
||||
<artifactId>xercesImpl</artifactId>
|
||||
<version>2.11.0</version>
|
||||
</dependency>
|
||||
<!-- Logger -->
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-api</artifactId>
|
||||
|
@ -76,24 +71,55 @@
|
|||
<artifactId>slf4j-log4j12</artifactId>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>xerces</groupId>
|
||||
<artifactId>xerces</artifactId>
|
||||
<version>2.4.0</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Storage -->
|
||||
<dependency>
|
||||
<groupId>org.gcube.contentmanagement</groupId>
|
||||
<artifactId>storage-manager-core</artifactId>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.gcube.contentmanagement</groupId>
|
||||
<artifactId>storage-manager-wrapper</artifactId>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
|
||||
<!-- Home Library -->
|
||||
<dependency>
|
||||
<groupId>org.gcube.common</groupId>
|
||||
<artifactId>home-library</artifactId>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.gcube.common</groupId>
|
||||
<artifactId>home-library-jcr</artifactId>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.gcube.common</groupId>
|
||||
<artifactId>home-library-model</artifactId>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
|
||||
<!-- Authorization -->
|
||||
<dependency>
|
||||
<groupId>org.gcube.common</groupId>
|
||||
<artifactId>common-authorization</artifactId>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.gcube.common</groupId>
|
||||
<artifactId>authorization-client</artifactId>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.thoughtworks.xstream</groupId>
|
||||
<artifactId>xstream</artifactId>
|
||||
|
@ -120,11 +146,7 @@
|
|||
<artifactId>gwt-servlet</artifactId>
|
||||
<version>${gwtVersion}</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
|
||||
<!-- <dependency> <groupId>com.google.gwt</groupId> <artifactId>gwt-dev</artifactId>
|
||||
<version>${gwtVersion}</version> </dependency> -->
|
||||
|
||||
|
||||
<!-- GXT 3 -->
|
||||
<dependency>
|
||||
|
@ -146,23 +168,15 @@
|
|||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
|
||||
<!-- GXT-Theme-Neptune -->
|
||||
<!-- <dependency> <groupId>com.sencha.gxt</groupId> <artifactId>gxt-theme-neptune</artifactId>
|
||||
<version>${gxtVersion}</version> </dependency> -->
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- Portlet -->
|
||||
<dependency>
|
||||
<groupId>javax.portlet</groupId>
|
||||
<artifactId>portlet-api</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
|
||||
|
||||
<!-- PORTAL -->
|
||||
<dependency>
|
||||
<groupId>org.gcube.core</groupId>
|
||||
|
@ -178,14 +192,78 @@
|
|||
<dependency>
|
||||
<groupId>org.gcube.applicationsupportlayer</groupId>
|
||||
<artifactId>aslcore</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.gcube.applicationsupportlayer</groupId>
|
||||
<artifactId>accesslogger</artifactId>
|
||||
<groupId>org.gcube.dvos</groupId>
|
||||
<artifactId>usermanagement-core</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
|
||||
<!-- Authorization -->
|
||||
<dependency>
|
||||
<groupId>org.gcube.common</groupId>
|
||||
<artifactId>common-authorization</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.gcube.common</groupId>
|
||||
<artifactId>authorization-client</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<!-- GCube Widgets -->
|
||||
<dependency>
|
||||
<groupId>org.gcube.portlets.user</groupId>
|
||||
<artifactId>gcube-widgets</artifactId>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
<!-- Session Checker -->
|
||||
<dependency>
|
||||
<groupId>org.gcube.portlets.widgets</groupId>
|
||||
<artifactId>session-checker</artifactId>
|
||||
<version>[0.0.0-SNAPSHOT,1.0.0-SNAPSHOT)</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
<!-- Storage -->
|
||||
<dependency>
|
||||
<groupId>org.gcube.contentmanagement</groupId>
|
||||
<artifactId>storage-manager-core</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.gcube.contentmanagement</groupId>
|
||||
<artifactId>storage-manager-wrapper</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<!-- Home Library -->
|
||||
<dependency>
|
||||
<groupId>org.gcube.common</groupId>
|
||||
<artifactId>home-library</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.gcube.common</groupId>
|
||||
<artifactId>home-library-jcr</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.gcube.common</groupId>
|
||||
<artifactId>home-library-model</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
|
||||
|
||||
<!-- Social -->
|
||||
<!-- <dependency> <groupId>org.gcube.portal</groupId> <artifactId>social-networking-library</artifactId>
|
||||
<scope>provided</scope> </dependency> -->
|
||||
|
@ -204,27 +282,6 @@
|
|||
</dependency>
|
||||
|
||||
|
||||
<!-- GCube Widgets -->
|
||||
<dependency>
|
||||
<groupId>org.gcube.portlets.user</groupId>
|
||||
<artifactId>gcube-widgets</artifactId>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
|
||||
<!-- WSLT dependencies <dependency> <groupId>org.gcube.portlets.widgets</groupId>
|
||||
<artifactId>workspace-light-tree</artifactId> <version>[2.13.1-SNAPSHOT,
|
||||
3.0.0-SNAPSHOT)</version> </dependency> <dependency> <groupId>org.gcube.common</groupId>
|
||||
<artifactId>home-library</artifactId> <version>[2.0.0-SNAPSHOT, 3.0.0-SNAPSHOT)</version>
|
||||
<scope>provided</scope> </dependency> -->
|
||||
|
||||
<!-- Session Checker -->
|
||||
<dependency>
|
||||
<groupId>org.gcube.portlets.widgets</groupId>
|
||||
<artifactId>session-checker</artifactId>
|
||||
<version>[0.2.0-SNAPSHOT,1.0.0-SNAPSHOT)</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Apache Common Library -->
|
||||
<dependency>
|
||||
<groupId>commons-io</groupId>
|
||||
|
@ -270,28 +327,6 @@
|
|||
<version>[1.0.0-SNAPSHOT,2.0.0-SNAPSHOT)</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Home Library -->
|
||||
<dependency>
|
||||
<groupId>org.gcube.common</groupId>
|
||||
<artifactId>home-library</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.gcube.common</groupId>
|
||||
<artifactId>home-library-jcr</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.gcube.common</groupId>
|
||||
<artifactId>home-library-model</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<!-- Uri Resolver Manager -->
|
||||
<!-- <dependency> <groupId>org.gcube.portlets.user</groupId> <artifactId>uri-resolver-manager</artifactId>
|
||||
<version>[1.0.0-SNAPSHOT,2.0.0-SNAPSHOT)</version> </dependency> -->
|
||||
|
||||
<!-- 52n-wps-client -->
|
||||
<dependency>
|
||||
|
@ -339,12 +374,6 @@
|
|||
<artifactId>slf4j-log4j12</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<!-- <dependency> <groupId>log4j</groupId> <artifactId>log4j</artifactId>
|
||||
<scope>provided</scope> </dependency> -->
|
||||
|
||||
<!-- <dependency> <groupId>ch.qos.logback</groupId> <artifactId>logback-classic</artifactId>
|
||||
<version>1.0.1</version> <scope>runtime</scope> </dependency> -->
|
||||
|
||||
|
||||
|
||||
<!-- JUnit TEST -->
|
||||
|
|
|
@ -18,85 +18,89 @@ 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.application.framework.core.session.ASLSession;
|
||||
import org.gcube.common.scope.api.ScopeProvider;
|
||||
import org.gcube.portlets.user.statisticalalgorithmsimporter.server.file.CodeFileUploadSession;
|
||||
import org.gcube.portlets.user.statisticalalgorithmsimporter.server.file.FileUploadListener;
|
||||
import org.gcube.portlets.user.statisticalalgorithmsimporter.server.file.FileUtil;
|
||||
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.Constants;
|
||||
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.exception.StatAlgoImporterSessionExpiredException;
|
||||
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.exception.StatAlgoImporterServiceException;
|
||||
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.file.FileUploadMonitor;
|
||||
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.file.FileUploadState;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
import com.allen_sauer.gwt.log.client.Log;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @author "Giancarlo Panichi"
|
||||
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
* @author "Giancarlo Panichi" <a
|
||||
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public class LocalUploadServlet extends HttpServlet {
|
||||
|
||||
protected static Logger logger = LoggerFactory.getLogger(LocalUploadServlet.class);
|
||||
|
||||
|
||||
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 {
|
||||
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 ;
|
||||
|
||||
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("Code Import session id: "+session.getId());
|
||||
logger.info("Code Import session id: " + session.getId());
|
||||
|
||||
CodeFileUploadSession fileUploadSession=new CodeFileUploadSession();
|
||||
FileUploadMonitor fileUploadMonitor=new FileUploadMonitor();
|
||||
|
||||
fileUploadSession.setId(session.getId());
|
||||
fileUploadSession.setFileUploadState(FileUploadState.STARTED);
|
||||
//fileUploadSession.setCsvImportMonitor(csvImportMonitor);
|
||||
SessionUtil.setFileUploadMonitor(session, fileUploadMonitor);
|
||||
|
||||
|
||||
try {
|
||||
SessionUtil.setCodeFileUploadSession(session,fileUploadSession);
|
||||
} catch (StatAlgoImporterSessionExpiredException e) {
|
||||
ASLSession aslSession = SessionUtil.getASLSession(session);
|
||||
String token=SessionUtil.getToken(aslSession);
|
||||
logger.debug("UserToken: "+token);
|
||||
ScopeProvider.instance.set(aslSession.getScope().toString());
|
||||
|
||||
} catch (StatAlgoImporterServiceException e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
e.printStackTrace();
|
||||
throw new ServletException(e.getLocalizedMessage());
|
||||
}
|
||||
|
||||
CodeFileUploadSession fileUploadSession = new CodeFileUploadSession();
|
||||
FileUploadMonitor fileUploadMonitor = new FileUploadMonitor();
|
||||
|
||||
fileUploadSession.setId(session.getId());
|
||||
fileUploadSession.setFileUploadState(FileUploadState.STARTED);
|
||||
// fileUploadSession.setCsvImportMonitor(csvImportMonitor);
|
||||
SessionUtil.setFileUploadMonitor(session, fileUploadMonitor);
|
||||
|
||||
try {
|
||||
SessionUtil.setCodeFileUploadSession(session, fileUploadSession);
|
||||
} catch (StatAlgoImporterServiceException e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
e.printStackTrace();
|
||||
throw new ServletException(e.getLocalizedMessage());
|
||||
}
|
||||
|
||||
|
||||
FileItemFactory factory = new DiskFileItemFactory();
|
||||
ServletFileUpload upload = new ServletFileUpload(factory);
|
||||
|
||||
|
||||
FileUploadListener uploadListener = new FileUploadListener(fileUploadMonitor);
|
||||
|
||||
FileUploadListener uploadListener = new FileUploadListener(
|
||||
fileUploadMonitor);
|
||||
upload.setProgressListener(uploadListener);
|
||||
|
||||
|
||||
FileItem uploadItem = null;
|
||||
Log.info("Start upload file ");
|
||||
try {
|
||||
|
@ -104,78 +108,90 @@ public class LocalUploadServlet extends HttpServlet {
|
|||
Iterator it = items.iterator();
|
||||
while (it.hasNext()) {
|
||||
FileItem item = (FileItem) it.next();
|
||||
if (!item.isFormField() && Constants.FILE_UPLOADED_FIELD.equals(item.getFieldName())) {
|
||||
if (!item.isFormField()
|
||||
&& Constants.FILE_UPLOADED_FIELD.equals(item
|
||||
.getFieldName())) {
|
||||
uploadItem = item;
|
||||
}
|
||||
}
|
||||
} catch (FileUploadException e) {
|
||||
FileUploadMonitor fum=SessionUtil.getFileUploadMonitor(session);
|
||||
fum.setFailed("An error occured elaborating the HTTP request", FileUtil.exceptionDetailMessage(e));
|
||||
FileUploadMonitor fum = SessionUtil.getFileUploadMonitor(session);
|
||||
fum.setFailed("An error occured elaborating the HTTP request",
|
||||
FileUtil.exceptionDetailMessage(e));
|
||||
SessionUtil.setFileUploadMonitor(session, fum);
|
||||
fileUploadSession.setFileUploadState(FileUploadState.FAILED);
|
||||
try {
|
||||
SessionUtil.setCodeFileUploadSession(session, fileUploadSession);
|
||||
} catch (StatAlgoImporterSessionExpiredException e1) {
|
||||
SessionUtil
|
||||
.setCodeFileUploadSession(session, fileUploadSession);
|
||||
} catch (StatAlgoImporterServiceException e1) {
|
||||
logger.error(e1.getLocalizedMessage());
|
||||
e1.printStackTrace();
|
||||
throw new ServletException(e1.getLocalizedMessage());
|
||||
}
|
||||
logger.error("Error processing request in upload servlet", e);
|
||||
response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "ERROR-Error during request processing: "+e.getMessage());
|
||||
response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR,
|
||||
"ERROR-Error during request processing: " + e.getMessage());
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (uploadItem == null) {
|
||||
FileUploadMonitor fum=SessionUtil.getFileUploadMonitor(session);
|
||||
fum.setFailed("An error occured elaborating the HTTP request: No file found", "Upload request without file");
|
||||
FileUploadMonitor fum = SessionUtil.getFileUploadMonitor(session);
|
||||
fum.setFailed(
|
||||
"An error occured elaborating the HTTP request: No file found",
|
||||
"Upload request without file");
|
||||
SessionUtil.setFileUploadMonitor(session, fum);
|
||||
fileUploadSession.setFileUploadState(FileUploadState.FAILED);
|
||||
try {
|
||||
SessionUtil.setCodeFileUploadSession(session, fileUploadSession);
|
||||
} catch (StatAlgoImporterSessionExpiredException e) {
|
||||
SessionUtil
|
||||
.setCodeFileUploadSession(session, fileUploadSession);
|
||||
} catch (StatAlgoImporterServiceException e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
e.printStackTrace();
|
||||
throw new ServletException(e.getLocalizedMessage());
|
||||
}
|
||||
logger.error("Error processing request in upload servlet: No file to upload");
|
||||
response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "No file to upload");
|
||||
response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR,
|
||||
"No file to upload");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
String contentType = uploadItem.getContentType();
|
||||
|
||||
logger.trace("ContentType: "+contentType);
|
||||
|
||||
|
||||
|
||||
logger.trace("ContentType: " + contentType);
|
||||
|
||||
try {
|
||||
FileUtil.setImportCodeFile(fileUploadSession, uploadItem.getInputStream(), uploadItem.getName(), contentType);
|
||||
FileUtil.setImportCodeFile(fileUploadSession,
|
||||
uploadItem.getInputStream(), uploadItem.getName(),
|
||||
contentType);
|
||||
} catch (Exception e) {
|
||||
FileUploadMonitor fum=SessionUtil.getFileUploadMonitor(session);
|
||||
fum.setFailed("An error occured elaborating the file", FileUtil.exceptionDetailMessage(e));
|
||||
FileUploadMonitor fum = SessionUtil.getFileUploadMonitor(session);
|
||||
fum.setFailed("An error occured elaborating the file",
|
||||
FileUtil.exceptionDetailMessage(e));
|
||||
SessionUtil.setFileUploadMonitor(session, fum);
|
||||
fileUploadSession.setFileUploadState(FileUploadState.FAILED);
|
||||
try {
|
||||
SessionUtil.setCodeFileUploadSession(session, fileUploadSession);
|
||||
} catch (StatAlgoImporterSessionExpiredException e1) {
|
||||
SessionUtil
|
||||
.setCodeFileUploadSession(session, fileUploadSession);
|
||||
} catch (StatAlgoImporterServiceException e1) {
|
||||
logger.error(e1.getLocalizedMessage());
|
||||
e1.printStackTrace();
|
||||
throw new ServletException(e1.getLocalizedMessage());
|
||||
}
|
||||
logger.error("Error elaborating the stream", e);
|
||||
uploadItem.delete();
|
||||
response.getWriter().write("ERROR-"+e.getMessage());
|
||||
response.getWriter().write("ERROR-" + e.getMessage());
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
uploadItem.delete();
|
||||
|
||||
|
||||
logger.trace("changing state");
|
||||
FileUploadMonitor fum=SessionUtil.getFileUploadMonitor(session);
|
||||
FileUploadMonitor fum = SessionUtil.getFileUploadMonitor(session);
|
||||
fum.setState(FileUploadState.COMPLETED);
|
||||
SessionUtil.setFileUploadMonitor(session, fum);
|
||||
try {
|
||||
SessionUtil.setCodeFileUploadSession(session, fileUploadSession);
|
||||
} catch (StatAlgoImporterSessionExpiredException e) {
|
||||
} catch (StatAlgoImporterServiceException e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
e.printStackTrace();
|
||||
throw new ServletException(e.getLocalizedMessage());
|
||||
|
|
|
@ -3,18 +3,21 @@
|
|||
*/
|
||||
package org.gcube.portlets.user.statisticalalgorithmsimporter.server;
|
||||
|
||||
import static org.gcube.common.authorization.client.Constants.authorizationService;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.servlet.ServletContext;
|
||||
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.portal.custom.scopemanager.scopehelper.ScopeHelper;
|
||||
import org.gcube.portlets.user.statisticalalgorithmsimporter.server.file.CodeFileUploadSession;
|
||||
import org.gcube.portlets.user.statisticalalgorithmsimporter.server.social.Recipient;
|
||||
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.Constants;
|
||||
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.exception.StatAlgoImporterServiceException;
|
||||
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.exception.StatAlgoImporterSessionExpiredException;
|
||||
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.file.FileUploadMonitor;
|
||||
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.project.Project;
|
||||
|
@ -32,54 +35,77 @@ public class SessionUtil {
|
|||
|
||||
private static Logger logger = LoggerFactory.getLogger(SessionUtil.class);
|
||||
|
||||
public static ASLSession getAslSession(HttpSession httpSession)
|
||||
throws StatAlgoImporterSessionExpiredException {
|
||||
public static ASLSession getASLSession(HttpSession httpSession)
|
||||
throws StatAlgoImporterServiceException {
|
||||
String username = (String) httpSession
|
||||
.getAttribute(ScopeHelper.USERNAME_ATTRIBUTE);
|
||||
ASLSession session;
|
||||
ASLSession aslSession;
|
||||
if (username == null) {
|
||||
logger.warn("no user found in session, use test user");
|
||||
/*throw new AccountingManagerSessionExpiredException("Session Expired!");*/
|
||||
|
||||
|
||||
// Remove comment for Test
|
||||
username = Constants.DEFAULT_USER;
|
||||
String scope = Constants.DEFAULT_SCOPE;
|
||||
if (Constants.DEBUG_MODE) {
|
||||
logger.info("no user found in session, use test user");
|
||||
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);
|
||||
|
||||
httpSession.setAttribute(ScopeHelper.USERNAME_ATTRIBUTE,
|
||||
username);
|
||||
aslSession = SessionManager.getInstance().getASLSession(
|
||||
httpSession.getId(), username);
|
||||
aslSession.setScope(scope);
|
||||
} else {
|
||||
logger.info("no user found in session!");
|
||||
throw new StatAlgoImporterSessionExpiredException(
|
||||
"Session Expired!");
|
||||
|
||||
}
|
||||
} else {
|
||||
session = SessionManager.getInstance().getASLSession(
|
||||
aslSession = SessionManager.getInstance().getASLSession(
|
||||
httpSession.getId(), username);
|
||||
|
||||
}
|
||||
|
||||
logger.info("SessionUtil: aslSession " + session.getUsername() + " "
|
||||
+ session.getScope());
|
||||
logger.info("SessionUtil: aslSession " + aslSession.getUsername() + " "
|
||||
+ aslSession.getScope());
|
||||
|
||||
return session;
|
||||
return aslSession;
|
||||
}
|
||||
|
||||
public static String getToken(ASLSession aslSession) {
|
||||
String token = null;
|
||||
if (Constants.DEBUG_MODE) {
|
||||
List<String> userRoles = new ArrayList<>();
|
||||
userRoles.add(Constants.DEFAULT_ROLE);
|
||||
/*
|
||||
* if (aslSession.getUsername().compareTo("lucio.lelii") == 0)
|
||||
* userRoles.add("VRE-Manager");
|
||||
*/
|
||||
token = authorizationService().build().generate(
|
||||
aslSession.getUsername(), userRoles);
|
||||
|
||||
} else {
|
||||
token = aslSession.getSecurityToken();
|
||||
}
|
||||
logger.info("received token: " + token);
|
||||
return token;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
//
|
||||
public static ArrayList<Recipient> getRecipients(ServletContext servletContest) {
|
||||
public static ArrayList<Recipient> getRecipients(
|
||||
ServletContext servletContest) {
|
||||
@SuppressWarnings("unchecked")
|
||||
ArrayList<Recipient> recipients=(ArrayList<Recipient>)servletContest.getAttribute(Constants.RECIPIENTS);
|
||||
ArrayList<Recipient> recipients = (ArrayList<Recipient>) servletContest
|
||||
.getAttribute(Constants.RECIPIENTS);
|
||||
return recipients;
|
||||
|
||||
|
||||
}
|
||||
|
||||
public static ArrayList<Recipient> setRecipients(ServletContext servletContest, ArrayList<Recipient> recipients) {
|
||||
servletContest.setAttribute(Constants.RECIPIENTS,recipients);
|
||||
|
||||
public static ArrayList<Recipient> setRecipients(
|
||||
ServletContext servletContest, ArrayList<Recipient> recipients) {
|
||||
servletContest.setAttribute(Constants.RECIPIENTS, recipients);
|
||||
return recipients;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
//
|
||||
public static FileUploadMonitor getFileUploadMonitor(HttpSession httpSession) {
|
||||
FileUploadMonitor fileUploadMonitor = (FileUploadMonitor) httpSession
|
||||
|
@ -105,10 +131,11 @@ public class SessionUtil {
|
|||
fileUploadMonitor);
|
||||
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
public static void setCodeFileUploadSession(HttpSession httpSession,
|
||||
CodeFileUploadSession s) throws StatAlgoImporterSessionExpiredException {
|
||||
CodeFileUploadSession s)
|
||||
throws StatAlgoImporterServiceException {
|
||||
|
||||
CodeFileUploadSession session = (CodeFileUploadSession) httpSession
|
||||
.getAttribute(SessionConstants.IMPORT_CODE_FILE_UPLOAD_SESSION);
|
||||
|
@ -117,8 +144,7 @@ public class SessionUtil {
|
|||
.removeAttribute(SessionConstants.IMPORT_CODE_FILE_UPLOAD_SESSION);
|
||||
httpSession.setAttribute(
|
||||
SessionConstants.IMPORT_CODE_FILE_UPLOAD_SESSION, s);
|
||||
ASLSession aslSession = getAslSession(httpSession);
|
||||
ScopeProvider.instance.set(aslSession.getScope().toString());
|
||||
|
||||
}
|
||||
|
||||
public static CodeFileUploadSession getCodeFileUploadSession(
|
||||
|
@ -137,15 +163,12 @@ public class SessionUtil {
|
|||
Project p = (Project) httpSession
|
||||
.getAttribute(SessionConstants.PROJECT);
|
||||
if (p != null)
|
||||
httpSession
|
||||
.removeAttribute(SessionConstants.PROJECT);
|
||||
httpSession.setAttribute(
|
||||
SessionConstants.PROJECT, project);
|
||||
|
||||
httpSession.removeAttribute(SessionConstants.PROJECT);
|
||||
httpSession.setAttribute(SessionConstants.PROJECT, project);
|
||||
|
||||
}
|
||||
|
||||
public static Project getProjectSession(
|
||||
HttpSession httpSession) {
|
||||
public static Project getProjectSession(HttpSession httpSession) {
|
||||
Project project = (Project) httpSession
|
||||
.getAttribute(SessionConstants.PROJECT);
|
||||
if (project == null) {
|
||||
|
@ -154,7 +177,4 @@ public class SessionUtil {
|
|||
return project;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -99,13 +99,15 @@ public class StatAlgoImporterServiceImpl extends RemoteServiceServlet implements
|
|||
public UserInfo hello() throws StatAlgoImporterServiceException {
|
||||
try {
|
||||
HttpSession session = this.getThreadLocalRequest().getSession();
|
||||
ASLSession aslSession = SessionUtil.getAslSession(session);
|
||||
ASLSession aslSession = SessionUtil.getASLSession(session);
|
||||
String token = SessionUtil.getToken(aslSession);
|
||||
UserInfo userInfo = new UserInfo(aslSession.getUsername(),
|
||||
aslSession.getGroupId(), aslSession.getGroupName(),
|
||||
aslSession.getScope(), aslSession.getScopeName(),
|
||||
aslSession.getUserEmailAddress(),
|
||||
aslSession.getUserFullName());
|
||||
logger.debug("UserInfo: " + userInfo);
|
||||
logger.debug("UserToken: " + token);
|
||||
return userInfo;
|
||||
} catch (StatAlgoImporterServiceException e) {
|
||||
e.printStackTrace();
|
||||
|
@ -123,7 +125,9 @@ public class StatAlgoImporterServiceImpl extends RemoteServiceServlet implements
|
|||
throws StatAlgoImporterServiceException {
|
||||
try {
|
||||
HttpSession session = this.getThreadLocalRequest().getSession();
|
||||
SessionUtil.getAslSession(session);
|
||||
ASLSession aslSession = SessionUtil.getASLSession(session);
|
||||
String token = SessionUtil.getToken(aslSession);
|
||||
logger.debug("UserToken: " + token);
|
||||
logger.debug("restoreUISession(): " + value);
|
||||
Project project = SessionUtil.getProjectSession(session);
|
||||
return project;
|
||||
|
@ -148,10 +152,9 @@ public class StatAlgoImporterServiceImpl extends RemoteServiceServlet implements
|
|||
throws StatAlgoImporterServiceException {
|
||||
|
||||
HttpSession session = this.getThreadLocalRequest().getSession();
|
||||
if (session == null) {
|
||||
throw new StatAlgoImporterServiceException(
|
||||
"Error retrieving the session: null");
|
||||
}
|
||||
ASLSession aslSession = SessionUtil.getASLSession(session);
|
||||
String token = SessionUtil.getToken(aslSession);
|
||||
logger.debug("UserToken: " + token);
|
||||
|
||||
FileUploadMonitor fileUploadMonitor = SessionUtil
|
||||
.getFileUploadMonitor(session);
|
||||
|
@ -175,7 +178,9 @@ public class StatAlgoImporterServiceImpl extends RemoteServiceServlet implements
|
|||
throws StatAlgoImporterServiceException {
|
||||
try {
|
||||
HttpSession session = this.getThreadLocalRequest().getSession();
|
||||
ASLSession aslSession = SessionUtil.getAslSession(session);
|
||||
ASLSession aslSession = SessionUtil.getASLSession(session);
|
||||
String token = SessionUtil.getToken(aslSession);
|
||||
logger.debug("UserToken: " + token);
|
||||
logger.debug("getCode()");
|
||||
Project projectSession = SessionUtil.getProjectSession(session);
|
||||
if (projectSession != null) {
|
||||
|
@ -211,8 +216,10 @@ public class StatAlgoImporterServiceImpl extends RemoteServiceServlet implements
|
|||
throws StatAlgoImporterServiceException {
|
||||
try {
|
||||
HttpSession session = this.getThreadLocalRequest().getSession();
|
||||
ASLSession aslSession = SessionUtil.getAslSession(session);
|
||||
logger.debug("createProjectOnWorkspace(): "+newProjectFolder);
|
||||
ASLSession aslSession = SessionUtil.getASLSession(session);
|
||||
String token = SessionUtil.getToken(aslSession);
|
||||
logger.debug("UserToken: " + token);
|
||||
logger.debug("createProjectOnWorkspace(): " + newProjectFolder);
|
||||
if (ProjectArchiver.existProjectInFolder(newProjectFolder,
|
||||
aslSession)) {
|
||||
throw new StatAlgoImporterServiceException(
|
||||
|
@ -222,9 +229,9 @@ public class StatAlgoImporterServiceImpl extends RemoteServiceServlet implements
|
|||
newProjectFolder);
|
||||
Project projectSession = new Project(projectFolder);
|
||||
SessionUtil.setProjectSession(session, projectSession);
|
||||
logger.debug("Create Project: "+projectSession);
|
||||
logger.debug("Create Project: " + projectSession);
|
||||
}
|
||||
|
||||
|
||||
return;
|
||||
} catch (StatAlgoImporterServiceException e) {
|
||||
e.printStackTrace();
|
||||
|
@ -242,7 +249,9 @@ public class StatAlgoImporterServiceImpl extends RemoteServiceServlet implements
|
|||
throws StatAlgoImporterServiceException {
|
||||
try {
|
||||
HttpSession session = this.getThreadLocalRequest().getSession();
|
||||
ASLSession aslSession = SessionUtil.getAslSession(session);
|
||||
ASLSession aslSession = SessionUtil.getASLSession(session);
|
||||
String token = SessionUtil.getToken(aslSession);
|
||||
logger.debug("UserToken: " + token);
|
||||
logger.debug("openProjectOnWorkspace()");
|
||||
|
||||
Project project = ProjectArchiver.readProject(newProjectFolder,
|
||||
|
@ -267,17 +276,19 @@ public class StatAlgoImporterServiceImpl extends RemoteServiceServlet implements
|
|||
throws StatAlgoImporterServiceException {
|
||||
try {
|
||||
HttpSession session = this.getThreadLocalRequest().getSession();
|
||||
ASLSession aslSession=SessionUtil.getAslSession(session);
|
||||
logger.debug("SetMainCode(): "+itemDescription);
|
||||
ASLSession aslSession = SessionUtil.getASLSession(session);
|
||||
String token = SessionUtil.getToken(aslSession);
|
||||
logger.debug("UserToken: " + token);
|
||||
logger.debug("SetMainCode(): " + itemDescription);
|
||||
Project project = SessionUtil.getProjectSession(session);
|
||||
if (project != null) {
|
||||
project.setMainCode(new MainCode(itemDescription));
|
||||
project.setInputData(null);
|
||||
project.setProjectTarget(null);
|
||||
WPS4RParser wps4Parser=new WPS4RParser(project, aslSession);
|
||||
project=wps4Parser.parse();
|
||||
WPS4RParser wps4Parser = new WPS4RParser(project, aslSession);
|
||||
project = wps4Parser.parse();
|
||||
SessionUtil.setProjectSession(session, project);
|
||||
logger.debug("Project: "+project);
|
||||
logger.debug("Project: " + project);
|
||||
} else {
|
||||
throw new StatAlgoImporterServiceException("No project open!");
|
||||
}
|
||||
|
@ -299,7 +310,9 @@ public class StatAlgoImporterServiceImpl extends RemoteServiceServlet implements
|
|||
throws StatAlgoImporterServiceException {
|
||||
try {
|
||||
HttpSession session = this.getThreadLocalRequest().getSession();
|
||||
ASLSession aslSession = SessionUtil.getAslSession(session);
|
||||
ASLSession aslSession = SessionUtil.getASLSession(session);
|
||||
String token = SessionUtil.getToken(aslSession);
|
||||
logger.debug("UserToken: " + token);
|
||||
logger.debug("addResourceToProject(): " + itemDescription);
|
||||
if (itemDescription == null || itemDescription.getId() == null) {
|
||||
throw new StatAlgoImporterServiceException(
|
||||
|
@ -336,7 +349,9 @@ public class StatAlgoImporterServiceImpl extends RemoteServiceServlet implements
|
|||
throws StatAlgoImporterServiceException {
|
||||
try {
|
||||
HttpSession session = this.getThreadLocalRequest().getSession();
|
||||
ASLSession aslSession = SessionUtil.getAslSession(session);
|
||||
ASLSession aslSession = SessionUtil.getASLSession(session);
|
||||
String token = SessionUtil.getToken(aslSession);
|
||||
logger.debug("UserToken: " + token);
|
||||
logger.debug("deleteResourceOnProject(): " + itemDescription);
|
||||
if (itemDescription == null || itemDescription.getId() == null) {
|
||||
throw new StatAlgoImporterServiceException(
|
||||
|
@ -345,10 +360,10 @@ public class StatAlgoImporterServiceImpl extends RemoteServiceServlet implements
|
|||
}
|
||||
|
||||
Project project = SessionUtil.getProjectSession(session);
|
||||
checkProjectInfoForDelete(itemDescription,aslSession, session, project);
|
||||
checkProjectInfoForDelete(itemDescription, aslSession, session,
|
||||
project);
|
||||
FilesStorage fileStorage = new FilesStorage();
|
||||
fileStorage.deleteItemOnFolder(
|
||||
aslSession.getUsername(),
|
||||
fileStorage.deleteItemOnFolder(aslSession.getUsername(),
|
||||
itemDescription.getId());
|
||||
return project;
|
||||
|
||||
|
@ -388,13 +403,11 @@ public class StatAlgoImporterServiceImpl extends RemoteServiceServlet implements
|
|||
ProjectArchiver.archive(project, aslSession);
|
||||
} else {
|
||||
if (project.getProjectTarget() != null
|
||||
&& project.getProjectTarget()
|
||||
.getProjectCompile() != null
|
||||
&& project.getProjectTarget()
|
||||
.getProjectCompile().getFolder() != null
|
||||
&& project.getProjectTarget()
|
||||
.getProjectCompile().getFolder()
|
||||
.getId()
|
||||
&& project.getProjectTarget().getProjectCompile() != null
|
||||
&& project.getProjectTarget().getProjectCompile()
|
||||
.getFolder() != null
|
||||
&& project.getProjectTarget().getProjectCompile()
|
||||
.getFolder().getId()
|
||||
.compareTo(itemDescription.getId()) == 0) {
|
||||
project.getProjectTarget().setProjectCompile(null);
|
||||
SessionUtil.setProjectSession(session, project);
|
||||
|
@ -406,11 +419,9 @@ public class StatAlgoImporterServiceImpl extends RemoteServiceServlet implements
|
|||
&& project.getProjectTarget()
|
||||
.getProjectDeploy().getFolder() != null
|
||||
&& project.getProjectTarget()
|
||||
.getProjectDeploy().getFolder()
|
||||
.getId()
|
||||
.getProjectDeploy().getFolder().getId()
|
||||
.compareTo(itemDescription.getId()) == 0) {
|
||||
project.getProjectTarget().setProjectDeploy(
|
||||
null);
|
||||
project.getProjectTarget().setProjectDeploy(null);
|
||||
SessionUtil.setProjectSession(session, project);
|
||||
ProjectArchiver.archive(project, aslSession);
|
||||
} else {
|
||||
|
@ -420,20 +431,16 @@ public class StatAlgoImporterServiceImpl extends RemoteServiceServlet implements
|
|||
&& project.getProjectTarget()
|
||||
.getProjectDeploy()
|
||||
.getPackageProject() != null
|
||||
&& project
|
||||
.getProjectTarget()
|
||||
&& project.getProjectTarget()
|
||||
.getProjectDeploy()
|
||||
.getPackageProject()
|
||||
.getId()
|
||||
.compareTo(
|
||||
itemDescription.getId()) == 0) {
|
||||
project.getProjectTarget()
|
||||
.getProjectDeploy()
|
||||
.getPackageProject().getId()
|
||||
.compareTo(itemDescription.getId()) == 0) {
|
||||
project.getProjectTarget().getProjectDeploy()
|
||||
.setPackageProject(null);
|
||||
SessionUtil.setProjectSession(session, project);
|
||||
ProjectArchiver.archive(project, aslSession);
|
||||
} else {
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -449,7 +456,9 @@ public class StatAlgoImporterServiceImpl extends RemoteServiceServlet implements
|
|||
throws StatAlgoImporterServiceException {
|
||||
try {
|
||||
HttpSession session = this.getThreadLocalRequest().getSession();
|
||||
ASLSession aslSession = SessionUtil.getAslSession(session);
|
||||
ASLSession aslSession = SessionUtil.getASLSession(session);
|
||||
String token = SessionUtil.getToken(aslSession);
|
||||
logger.debug("UserToken: " + token);
|
||||
logger.debug("saveProject():" + inputData);
|
||||
Project project = SessionUtil.getProjectSession(session);
|
||||
if (project != null) {
|
||||
|
@ -476,7 +485,9 @@ public class StatAlgoImporterServiceImpl extends RemoteServiceServlet implements
|
|||
public void saveCode(String code) throws StatAlgoImporterServiceException {
|
||||
try {
|
||||
HttpSession session = this.getThreadLocalRequest().getSession();
|
||||
ASLSession aslSession = SessionUtil.getAslSession(session);
|
||||
ASLSession aslSession = SessionUtil.getASLSession(session);
|
||||
String token = SessionUtil.getToken(aslSession);
|
||||
logger.debug("UserToken: " + token);
|
||||
logger.debug("saveCode():" + code);
|
||||
Project project = SessionUtil.getProjectSession(session);
|
||||
if (project != null) {
|
||||
|
@ -506,11 +517,13 @@ public class StatAlgoImporterServiceImpl extends RemoteServiceServlet implements
|
|||
}
|
||||
|
||||
@Override
|
||||
public Project setNewMainCode(ItemDescription fileDescription,
|
||||
String code) throws StatAlgoImporterServiceException {
|
||||
public Project setNewMainCode(ItemDescription fileDescription, String code)
|
||||
throws StatAlgoImporterServiceException {
|
||||
try {
|
||||
HttpSession session = this.getThreadLocalRequest().getSession();
|
||||
ASLSession aslSession = SessionUtil.getAslSession(session);
|
||||
ASLSession aslSession = SessionUtil.getASLSession(session);
|
||||
String token = SessionUtil.getToken(aslSession);
|
||||
logger.debug("UserToken: " + token);
|
||||
logger.debug("saveCode(): itemDescription" + fileDescription
|
||||
+ ", code:" + code);
|
||||
Project project = SessionUtil.getProjectSession(session);
|
||||
|
@ -523,8 +536,8 @@ public class StatAlgoImporterServiceImpl extends RemoteServiceServlet implements
|
|||
project.setMainCode(mainCode);
|
||||
project.setInputData(null);
|
||||
project.setProjectTarget(null);
|
||||
WPS4RParser wps4Parser=new WPS4RParser(project, aslSession);
|
||||
project=wps4Parser.parse();
|
||||
WPS4RParser wps4Parser = new WPS4RParser(project, aslSession);
|
||||
project = wps4Parser.parse();
|
||||
SessionUtil.setProjectSession(session, project);
|
||||
return project;
|
||||
} else {
|
||||
|
@ -547,7 +560,9 @@ public class StatAlgoImporterServiceImpl extends RemoteServiceServlet implements
|
|||
throws StatAlgoImporterServiceException {
|
||||
try {
|
||||
HttpSession session = this.getThreadLocalRequest().getSession();
|
||||
ASLSession aslSession = SessionUtil.getAslSession(session);
|
||||
ASLSession aslSession = SessionUtil.getASLSession(session);
|
||||
String token = SessionUtil.getToken(aslSession);
|
||||
logger.debug("UserToken: " + token);
|
||||
logger.debug("createSoftware(): " + inputData);
|
||||
Project project = SessionUtil.getProjectSession(session);
|
||||
if (project != null) {
|
||||
|
@ -579,7 +594,9 @@ public class StatAlgoImporterServiceImpl extends RemoteServiceServlet implements
|
|||
throws StatAlgoImporterServiceException {
|
||||
try {
|
||||
HttpSession session = this.getThreadLocalRequest().getSession();
|
||||
ASLSession aslSession = SessionUtil.getAslSession(session);
|
||||
ASLSession aslSession = SessionUtil.getASLSession(session);
|
||||
String token = SessionUtil.getToken(aslSession);
|
||||
logger.debug("UserToken: " + token);
|
||||
logger.debug("GetPublicLink(): " + itemDescription);
|
||||
FilesStorage filesStorage = new FilesStorage();
|
||||
String link = filesStorage.getPublicLink(aslSession.getUsername(),
|
||||
|
@ -600,7 +617,10 @@ public class StatAlgoImporterServiceImpl extends RemoteServiceServlet implements
|
|||
public void publishSoftware() throws StatAlgoImporterServiceException {
|
||||
try {
|
||||
HttpSession session = this.getThreadLocalRequest().getSession();
|
||||
ASLSession aslSession = SessionUtil.getAslSession(session);
|
||||
|
||||
ASLSession aslSession = SessionUtil.getASLSession(session);
|
||||
String token = SessionUtil.getToken(aslSession);
|
||||
logger.debug("UserToken: " + token);
|
||||
logger.debug("PublishSoftware()");
|
||||
ArrayList<Recipient> recipients = SessionUtil.getRecipients(session
|
||||
.getServletContext());
|
||||
|
@ -612,7 +632,8 @@ public class StatAlgoImporterServiceImpl extends RemoteServiceServlet implements
|
|||
SessionUtil.setProjectSession(session, project);
|
||||
ProjectArchiver.archive(project, aslSession);
|
||||
AlgorithmNotification notify = new AlgorithmNotification(
|
||||
aslSession, project, recipients);
|
||||
this.getThreadLocalRequest(), token, aslSession,
|
||||
project, recipients);
|
||||
notify.run();
|
||||
} else {
|
||||
throw new StatAlgoImporterServiceException(
|
||||
|
@ -635,7 +656,9 @@ public class StatAlgoImporterServiceImpl extends RemoteServiceServlet implements
|
|||
public void repackageSoftware() throws StatAlgoImporterServiceException {
|
||||
try {
|
||||
HttpSession session = this.getThreadLocalRequest().getSession();
|
||||
ASLSession aslSession = SessionUtil.getAslSession(session);
|
||||
ASLSession aslSession = SessionUtil.getASLSession(session);
|
||||
String token = SessionUtil.getToken(aslSession);
|
||||
logger.debug("UserToken: " + token);
|
||||
logger.debug("RepackageSoftware()");
|
||||
Project project = SessionUtil.getProjectSession(session);
|
||||
if (project != null) {
|
||||
|
|
|
@ -3,9 +3,13 @@ package org.gcube.portlets.user.statisticalalgorithmsimporter.server.social;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.gcube.application.framework.core.session.ASLSession;
|
||||
import org.gcube.applicationsupportlayer.social.ApplicationNotificationsManager;
|
||||
import org.gcube.applicationsupportlayer.social.NotificationsManager;
|
||||
import org.gcube.applicationsupportlayer.social.shared.SocialNetworkingSite;
|
||||
import org.gcube.applicationsupportlayer.social.shared.SocialNetworkingUser;
|
||||
import org.gcube.common.homelibrary.home.HomeLibrary;
|
||||
import org.gcube.common.homelibrary.home.exceptions.HomeNotFoundException;
|
||||
import org.gcube.common.homelibrary.home.exceptions.InternalErrorException;
|
||||
|
@ -27,16 +31,20 @@ import org.slf4j.LoggerFactory;
|
|||
public class AlgorithmNotification extends Thread {
|
||||
private static Logger logger = LoggerFactory
|
||||
.getLogger(AlgorithmNotification.class);
|
||||
private HttpServletRequest httpServletRequest;
|
||||
private ASLSession aslSession;
|
||||
|
||||
// private NotificationType notificationType;
|
||||
private Project project;
|
||||
private ArrayList<Recipient> recipients;
|
||||
|
||||
public AlgorithmNotification(ASLSession aslSession, Project project,
|
||||
public AlgorithmNotification(HttpServletRequest httpServletRequest,
|
||||
String token, ASLSession aslSession, Project project,
|
||||
ArrayList<Recipient> recipients) {
|
||||
this.aslSession = aslSession;
|
||||
this.project = project;
|
||||
this.recipients = recipients;
|
||||
this.httpServletRequest = httpServletRequest;
|
||||
// this.notificationType = NotificationType.SAI_ALGORITHM_PUBLICATION;
|
||||
|
||||
}
|
||||
|
@ -80,8 +88,10 @@ public class AlgorithmNotification extends Thread {
|
|||
+ aslSession.getUserFullName()
|
||||
+ "\n\n has requested to publish the algorithm "
|
||||
+ project.getInputData().getProjectInfo()
|
||||
.getAlgorithmName() + " with the following jar "
|
||||
+ project.getProjectTarget().getProjectDeploy().getCodeJar().getPublicLink();
|
||||
.getAlgorithmName()
|
||||
+ " with the following jar "
|
||||
+ project.getProjectTarget().getProjectDeploy()
|
||||
.getCodeJar().getPublicLink();
|
||||
|
||||
String messageId;
|
||||
|
||||
|
@ -91,8 +101,15 @@ public class AlgorithmNotification extends Thread {
|
|||
|
||||
logger.debug("Sending message notification to: "
|
||||
+ recipientIds.toString());
|
||||
NotificationsManager nm = new ApplicationNotificationsManager(
|
||||
aslSession);
|
||||
|
||||
SocialNetworkingSite site = new SocialNetworkingSite(
|
||||
httpServletRequest);
|
||||
SocialNetworkingUser user = new SocialNetworkingUser(
|
||||
aslSession.getUsername(), aslSession.getUserEmailAddress(),
|
||||
aslSession.getUserFullName(), aslSession.getUserAvatarId());
|
||||
NotificationsManager nm = new ApplicationNotificationsManager(site,
|
||||
aslSession.getScope(), user);
|
||||
|
||||
Thread thread = new Thread(new MessageNotificationsThread(
|
||||
recipients, messageId, subject, body, nm));
|
||||
thread.start();
|
||||
|
|
|
@ -8,18 +8,21 @@ package org.gcube.portlets.user.statisticalalgorithmsimporter.shared;
|
|||
*/
|
||||
public class Constants {
|
||||
|
||||
public static final boolean DEBUG_MODE = false;
|
||||
public static final boolean TEST_ENABLE = false;
|
||||
|
||||
public static final String APPLICATION_ID = "org.gcube.portlets.user.statisticalalgorithmsimporter.server.portlet.StatAlgoImporterPortlet";
|
||||
public static final String STATISTICAL_ALGORITHMS_IMPORTER_ID = "SAIId";
|
||||
public static final String STATISTICAL_ALGORITHMS_IMPORTER_COOKIE = "SAILangCookie";
|
||||
public static final String STATISTICAL_ALGORITHMS_IMPORTER_LANG = "SAILang";
|
||||
public final static String DEFAULT_USER = "giancarlo.panichi";
|
||||
//public final static String DEFAULT_SCOPE = "/gcube/devNext";
|
||||
public final static String DEFAULT_SCOPE = "/gcube/devsec/devVRE";
|
||||
public static final String DEFAULT_ROLE = "OrganizationMember";
|
||||
|
||||
|
||||
public static final String FILE_UPLOADED_FIELD = "FileUploadedField";
|
||||
public static final String STATISTICAL_ALGORITHMS_IMPORTER_JAR_PUBLIC_LINK = "JarPublicLink";
|
||||
public static final String RECIPIENTS = "Recipients";
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -1,10 +1,13 @@
|
|||
/** Add css rules here for your application. */
|
||||
/*table {
|
||||
border-spacing: 1px !important;
|
||||
top: 0px !important;
|
||||
}*/
|
||||
|
||||
|
||||
/* Workspace Explorer */
|
||||
#drop_target_inner {
|
||||
background-image: url("statalgoimporter/images/upload_128.png") !important;
|
||||
}
|
||||
}
|
||||
|
||||
/* FIX FOR Portal Theme */
|
||||
.aui input[type="text"], .aui select, .aui textarea, .aui .uneditable-input {
|
||||
margin-bottom: 0px !important;
|
||||
}
|
||||
|
||||
.aui img {
|
||||
vertical-align: baseline !important;
|
||||
}
|
||||
|
|
|
@ -1,3 +1,7 @@
|
|||
<?xml version="1.0"?>
|
||||
<!DOCTYPE display PUBLIC "-//Liferay//DTD Display 6.2.0//EN"
|
||||
"http://www.liferay.com/dtd/liferay-display_6_2_0.dtd">
|
||||
|
||||
<display>
|
||||
<category name="gCube Applications">
|
||||
<portlet id="StatisticalAlgorithmsImporter" />
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
<?xml version="1.0"?>
|
||||
<!DOCTYPE liferay-portlet-app PUBLIC "-//Liferay//DTD Portlet Application 5.2.0//EN" "http://www.liferay.com/dtd/liferay-portlet-app_5_2_0.dtd">
|
||||
|
||||
<!DOCTYPE liferay-portlet-app PUBLIC "-//Liferay//DTD Portlet Application 6.2.0//EN"
|
||||
"http://www.liferay.com/dtd/liferay-portlet-app_6_2_0.dtd">
|
||||
|
||||
<liferay-portlet-app>
|
||||
<portlet>
|
||||
<portlet-name>StatisticalAlgorithmsImporter</portlet-name>
|
||||
|
|
|
@ -1,9 +1,8 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE web-app
|
||||
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
|
||||
"http://java.sun.com/dtd/web-app_2_3.dtd">
|
||||
|
||||
<web-app>
|
||||
<web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
|
||||
http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
|
||||
version="3.0">
|
||||
|
||||
<!-- Servlets -->
|
||||
<!-- JUnit -->
|
||||
|
|
Loading…
Reference in New Issue