ref 6279:Statistical Algorithms Importer - getUserId doesn't work when session expires and Reload is performed
https://support.d4science.org/issues/6279 git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/statistical-algorithms-importer@142255 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
0f6d90b629
commit
e275a41f8b
|
@ -1,12 +1,12 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" output="target/statistical-algorithms-importer-1.4.0-SNAPSHOT/WEB-INF/classes" path="src/main/java">
|
||||
<classpathentry kind="src" output="target/statistical-algorithms-importer-1.5.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.4.0-SNAPSHOT/WEB-INF/classes" path="src/main/resources">
|
||||
<classpathentry excluding="**" kind="src" output="target/statistical-algorithms-importer-1.5.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.4.0-SNAPSHOT/WEB-INF/classes"/>
|
||||
<classpathentry kind="output" path="target/statistical-algorithms-importer-1.5.0-SNAPSHOT/WEB-INF/classes"/>
|
||||
</classpath>
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
<ReleaseNotes>
|
||||
<Changeset component="${groupId}.${artifactId}.1-5-0" date="2017-02-15">
|
||||
<Change>Updated PortalContext support[ticket #6279]</Change>
|
||||
</Changeset>
|
||||
<Changeset component="${groupId}.${artifactId}.1-4-0" date="2016-12-01">
|
||||
<Change>Updated Storage support</Change>
|
||||
<Change>Added PortalContext</Change>
|
||||
|
|
4
pom.xml
4
pom.xml
|
@ -13,7 +13,7 @@
|
|||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>org.gcube.portlets.user</groupId>
|
||||
<artifactId>statistical-algorithms-importer</artifactId>
|
||||
<version>1.4.0-SNAPSHOT</version>
|
||||
<version>1.5.0-SNAPSHOT</version>
|
||||
<packaging>war</packaging>
|
||||
|
||||
|
||||
|
@ -342,7 +342,7 @@
|
|||
<dependency>
|
||||
<groupId>org.n52.wps</groupId>
|
||||
<artifactId>52n-wps-r</artifactId>
|
||||
<version>(0.0.1,5.0.0)</version>
|
||||
<version>[3.0.0,3.7.0)</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>xerces</groupId>
|
||||
|
|
|
@ -6,6 +6,7 @@ package org.gcube.portlets.user.statisticalalgorithmsimporter.server;
|
|||
import java.io.IOException;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServlet;
|
||||
|
@ -23,7 +24,6 @@ import org.gcube.portlets.user.statisticalalgorithmsimporter.server.file.FileUpl
|
|||
import org.gcube.portlets.user.statisticalalgorithmsimporter.server.file.FileUtil;
|
||||
import org.gcube.portlets.user.statisticalalgorithmsimporter.server.util.ServiceCredentials;
|
||||
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.Constants;
|
||||
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;
|
||||
|
@ -89,18 +89,23 @@ public class LocalUploadServlet extends HttpServlet {
|
|||
e);
|
||||
throw new ServletException(e.getLocalizedMessage());
|
||||
}
|
||||
|
||||
|
||||
CodeFileUploadSession fileUploadSession = new CodeFileUploadSession();
|
||||
FileUploadMonitor fileUploadMonitor = new FileUploadMonitor();
|
||||
|
||||
fileUploadSession.setId(session.getId());
|
||||
|
||||
String id = UUID.randomUUID().toString();
|
||||
logger.info("Upload Id: " + id);
|
||||
fileUploadSession.setId(id);
|
||||
fileUploadSession.setFileUploadState(FileUploadState.STARTED);
|
||||
// fileUploadSession.setCsvImportMonitor(csvImportMonitor);
|
||||
SessionUtil.setFileUploadMonitor(session, fileUploadMonitor);
|
||||
SessionUtil.setFileUploadMonitor(request, serviceCredentials,
|
||||
fileUploadMonitor);
|
||||
|
||||
try {
|
||||
SessionUtil.setCodeFileUploadSession(session, fileUploadSession);
|
||||
} catch (StatAlgoImporterServiceException e) {
|
||||
SessionUtil.setCodeFileUploadSession(request, serviceCredentials,
|
||||
fileUploadSession);
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
e.printStackTrace();
|
||||
throw new ServletException(e.getLocalizedMessage());
|
||||
|
@ -127,17 +132,19 @@ public class LocalUploadServlet extends HttpServlet {
|
|||
}
|
||||
}
|
||||
} catch (FileUploadException 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 (StatAlgoImporterServiceException e1) {
|
||||
logger.error(e1.getLocalizedMessage());
|
||||
e1.printStackTrace();
|
||||
FileUploadMonitor fum = SessionUtil.getFileUploadMonitor(
|
||||
request, serviceCredentials);
|
||||
fum.setFailed("An error occured elaborating the HTTP request",
|
||||
FileUtil.exceptionDetailMessage(e));
|
||||
SessionUtil.setFileUploadMonitor(request, serviceCredentials,
|
||||
fum);
|
||||
fileUploadSession.setFileUploadState(FileUploadState.FAILED);
|
||||
|
||||
SessionUtil.setCodeFileUploadSession(request,
|
||||
serviceCredentials, fileUploadSession);
|
||||
} catch (Exception e1) {
|
||||
logger.error(e1.getLocalizedMessage(), e1);
|
||||
throw new ServletException(e1.getLocalizedMessage());
|
||||
}
|
||||
logger.error("Error processing request in upload servlet", e);
|
||||
|
@ -147,18 +154,20 @@ public class LocalUploadServlet extends HttpServlet {
|
|||
}
|
||||
|
||||
if (uploadItem == null) {
|
||||
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 (StatAlgoImporterServiceException e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
e.printStackTrace();
|
||||
FileUploadMonitor fum = SessionUtil.getFileUploadMonitor(
|
||||
request, serviceCredentials);
|
||||
fum.setFailed(
|
||||
"An error occured elaborating the HTTP request: No file found",
|
||||
"Upload request without file");
|
||||
SessionUtil.setFileUploadMonitor(request, serviceCredentials,
|
||||
fum);
|
||||
fileUploadSession.setFileUploadState(FileUploadState.FAILED);
|
||||
|
||||
SessionUtil.setCodeFileUploadSession(request,
|
||||
serviceCredentials, fileUploadSession);
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getLocalizedMessage(), e);
|
||||
throw new ServletException(e.getLocalizedMessage());
|
||||
}
|
||||
logger.error("Error processing request in upload servlet: No file to upload");
|
||||
|
@ -176,17 +185,19 @@ public class LocalUploadServlet extends HttpServlet {
|
|||
uploadItem.getInputStream(), uploadItem.getName(),
|
||||
contentType);
|
||||
} catch (Exception 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 (StatAlgoImporterServiceException e1) {
|
||||
logger.error(e1.getLocalizedMessage());
|
||||
e1.printStackTrace();
|
||||
FileUploadMonitor fum = SessionUtil.getFileUploadMonitor(
|
||||
request, serviceCredentials);
|
||||
fum.setFailed("An error occured elaborating the file",
|
||||
FileUtil.exceptionDetailMessage(e));
|
||||
SessionUtil.setFileUploadMonitor(request, serviceCredentials,
|
||||
fum);
|
||||
fileUploadSession.setFileUploadState(FileUploadState.FAILED);
|
||||
|
||||
SessionUtil.setCodeFileUploadSession(request,
|
||||
serviceCredentials, fileUploadSession);
|
||||
} catch (Exception e1) {
|
||||
logger.error(e1.getLocalizedMessage(), e1);
|
||||
throw new ServletException(e1.getLocalizedMessage());
|
||||
}
|
||||
logger.error("Error elaborating the stream", e);
|
||||
|
@ -198,14 +209,16 @@ public class LocalUploadServlet extends HttpServlet {
|
|||
uploadItem.delete();
|
||||
|
||||
logger.trace("changing state");
|
||||
FileUploadMonitor fum = SessionUtil.getFileUploadMonitor(session);
|
||||
fum.setState(FileUploadState.COMPLETED);
|
||||
SessionUtil.setFileUploadMonitor(session, fum);
|
||||
try {
|
||||
SessionUtil.setCodeFileUploadSession(session, fileUploadSession);
|
||||
} catch (StatAlgoImporterServiceException e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
e.printStackTrace();
|
||||
FileUploadMonitor fum = SessionUtil.getFileUploadMonitor(request,
|
||||
serviceCredentials);
|
||||
fum.setState(FileUploadState.COMPLETED);
|
||||
SessionUtil.setFileUploadMonitor(request, serviceCredentials, fum);
|
||||
|
||||
SessionUtil.setCodeFileUploadSession(request, serviceCredentials,
|
||||
fileUploadSession);
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getLocalizedMessage(), e);
|
||||
throw new ServletException(e.getLocalizedMessage());
|
||||
}
|
||||
response.getWriter().write("OK");
|
||||
|
|
|
@ -7,7 +7,6 @@ import java.util.ArrayList;
|
|||
|
||||
import javax.servlet.ServletContext;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpSession;
|
||||
|
||||
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
|
||||
import org.gcube.common.portal.PortalContext;
|
||||
|
@ -17,7 +16,6 @@ import org.gcube.portlets.user.statisticalalgorithmsimporter.server.social.Recip
|
|||
import org.gcube.portlets.user.statisticalalgorithmsimporter.server.util.ServiceCredentials;
|
||||
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;
|
||||
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.session.SessionConstants;
|
||||
|
@ -213,73 +211,63 @@ public class SessionUtil {
|
|||
}
|
||||
|
||||
//
|
||||
public static FileUploadMonitor getFileUploadMonitor(HttpSession httpSession) {
|
||||
FileUploadMonitor fileUploadMonitor = (FileUploadMonitor) httpSession
|
||||
.getAttribute(SessionConstants.FILE_UPLOAD_MONITOR);
|
||||
if (fileUploadMonitor != null) {
|
||||
return fileUploadMonitor;
|
||||
} else {
|
||||
fileUploadMonitor = new FileUploadMonitor();
|
||||
httpSession.setAttribute(SessionConstants.FILE_UPLOAD_MONITOR,
|
||||
fileUploadMonitor);
|
||||
return fileUploadMonitor;
|
||||
}
|
||||
public static FileUploadMonitor getFileUploadMonitor(HttpServletRequest httpRequest,
|
||||
ServiceCredentials serviceCredentials) throws Exception {
|
||||
SessionOp<FileUploadMonitor> sessionOp = new SessionOp<>();
|
||||
FileUploadMonitor fileUploadMonitor = sessionOp.get(httpRequest,
|
||||
serviceCredentials,
|
||||
SessionConstants.FILE_UPLOAD_MONITOR,FileUploadMonitor.class);
|
||||
return fileUploadMonitor;
|
||||
}
|
||||
|
||||
public static void setFileUploadMonitor(HttpSession httpSession,
|
||||
public static void setFileUploadMonitor(HttpServletRequest httpRequest,
|
||||
ServiceCredentials serviceCredentials,
|
||||
FileUploadMonitor fileUploadMonitor) {
|
||||
FileUploadMonitor fum = (FileUploadMonitor) httpSession
|
||||
.getAttribute(SessionConstants.FILE_UPLOAD_MONITOR);
|
||||
if (fum != null) {
|
||||
httpSession.removeAttribute(SessionConstants.FILE_UPLOAD_MONITOR);
|
||||
}
|
||||
httpSession.setAttribute(SessionConstants.FILE_UPLOAD_MONITOR,
|
||||
SessionOp<FileUploadMonitor> sessionOp = new SessionOp<>();
|
||||
sessionOp.set(httpRequest, serviceCredentials,
|
||||
SessionConstants.FILE_UPLOAD_MONITOR,
|
||||
fileUploadMonitor);
|
||||
|
||||
}
|
||||
|
||||
//
|
||||
public static void setCodeFileUploadSession(HttpSession httpSession,
|
||||
CodeFileUploadSession s) throws StatAlgoImporterServiceException {
|
||||
|
||||
CodeFileUploadSession session = (CodeFileUploadSession) httpSession
|
||||
.getAttribute(SessionConstants.IMPORT_CODE_FILE_UPLOAD_SESSION);
|
||||
if (session != null)
|
||||
httpSession
|
||||
.removeAttribute(SessionConstants.IMPORT_CODE_FILE_UPLOAD_SESSION);
|
||||
httpSession.setAttribute(
|
||||
SessionConstants.IMPORT_CODE_FILE_UPLOAD_SESSION, s);
|
||||
|
||||
}
|
||||
|
||||
public static CodeFileUploadSession getCodeFileUploadSession(
|
||||
HttpSession httpSession) {
|
||||
CodeFileUploadSession fileUploadSession = (CodeFileUploadSession) httpSession
|
||||
.getAttribute(SessionConstants.IMPORT_CODE_FILE_UPLOAD_SESSION);
|
||||
if (fileUploadSession == null) {
|
||||
logger.error("CodeFileUploadSession was not acquired");
|
||||
}
|
||||
HttpServletRequest httpRequest,
|
||||
ServiceCredentials serviceCredentials) {
|
||||
SessionOp<CodeFileUploadSession> sessionOp = new SessionOp<>();
|
||||
CodeFileUploadSession fileUploadSession = sessionOp.get(httpRequest,
|
||||
serviceCredentials,
|
||||
SessionConstants.IMPORT_CODE_FILE_UPLOAD_SESSION);
|
||||
return fileUploadSession;
|
||||
}
|
||||
|
||||
public static void setCodeFileUploadSession(HttpServletRequest httpRequest,
|
||||
ServiceCredentials serviceCredentials,
|
||||
CodeFileUploadSession codeFileUploadSession) {
|
||||
SessionOp<CodeFileUploadSession> sessionOp = new SessionOp<>();
|
||||
sessionOp.set(httpRequest, serviceCredentials,
|
||||
SessionConstants.IMPORT_CODE_FILE_UPLOAD_SESSION,
|
||||
codeFileUploadSession);
|
||||
}
|
||||
|
||||
|
||||
|
||||
//
|
||||
public static void setProjectSession(HttpSession httpSession,
|
||||
Project project) throws StatAlgoImporterSessionExpiredException {
|
||||
Project p = (Project) httpSession
|
||||
.getAttribute(SessionConstants.PROJECT);
|
||||
if (p != null)
|
||||
httpSession.removeAttribute(SessionConstants.PROJECT);
|
||||
httpSession.setAttribute(SessionConstants.PROJECT, project);
|
||||
|
||||
}
|
||||
|
||||
public static Project getProjectSession(HttpSession httpSession) {
|
||||
Project project = (Project) httpSession
|
||||
.getAttribute(SessionConstants.PROJECT);
|
||||
if (project == null) {
|
||||
logger.error("Project was not acquired");
|
||||
}
|
||||
public static Project getProjectSession(HttpServletRequest httpRequest,
|
||||
ServiceCredentials serviceCredentials) {
|
||||
SessionOp<Project> sessionOp = new SessionOp<>();
|
||||
Project project = sessionOp.get(httpRequest, serviceCredentials,
|
||||
SessionConstants.PROJECT);
|
||||
return project;
|
||||
}
|
||||
|
||||
public static void setProjectSession(HttpServletRequest httpRequest,
|
||||
ServiceCredentials serviceCredentials, Project project) {
|
||||
SessionOp<Project> sessionOp = new SessionOp<>();
|
||||
sessionOp.set(httpRequest, serviceCredentials,
|
||||
SessionConstants.PROJECT, project);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@ import java.nio.charset.StandardCharsets;
|
|||
import java.util.ArrayList;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpSession;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.gcube.portlets.user.statisticalalgorithmsimporter.client.rpc.StatAlgoImporterService;
|
||||
|
@ -123,11 +123,14 @@ public class StatAlgoImporterServiceImpl extends RemoteServiceServlet implements
|
|||
@Override
|
||||
public Project restoreUISession(String value)
|
||||
throws StatAlgoImporterServiceException {
|
||||
HttpServletRequest httpRequest = null;
|
||||
try {
|
||||
HttpSession session = this.getThreadLocalRequest().getSession();
|
||||
SessionUtil.getServiceCredentials(this.getThreadLocalRequest());
|
||||
httpRequest = this.getThreadLocalRequest();
|
||||
ServiceCredentials serviceCredentials = SessionUtil
|
||||
.getServiceCredentials(httpRequest);
|
||||
logger.debug("restoreUISession(): " + value);
|
||||
Project project = SessionUtil.getProjectSession(session);
|
||||
Project project = SessionUtil.getProjectSession(httpRequest,
|
||||
serviceCredentials);
|
||||
return project;
|
||||
} catch (StatAlgoImporterServiceException e) {
|
||||
e.printStackTrace();
|
||||
|
@ -149,11 +152,17 @@ public class StatAlgoImporterServiceImpl extends RemoteServiceServlet implements
|
|||
public FileUploadMonitor getFileUploadMonitor()
|
||||
throws StatAlgoImporterServiceException {
|
||||
|
||||
HttpSession session = this.getThreadLocalRequest().getSession();
|
||||
SessionUtil.getServiceCredentials(this.getThreadLocalRequest());
|
||||
HttpServletRequest httpRequest = this.getThreadLocalRequest();
|
||||
ServiceCredentials serviceCredentials = SessionUtil
|
||||
.getServiceCredentials(httpRequest);
|
||||
|
||||
FileUploadMonitor fileUploadMonitor = SessionUtil
|
||||
.getFileUploadMonitor(session);
|
||||
FileUploadMonitor fileUploadMonitor = null;
|
||||
try {
|
||||
fileUploadMonitor = SessionUtil.getFileUploadMonitor(httpRequest,
|
||||
serviceCredentials);
|
||||
} catch (Exception e) {
|
||||
logger.error("Error retrieving the fileUploadMonitor", e);
|
||||
}
|
||||
if (fileUploadMonitor == null) {
|
||||
throw new StatAlgoImporterServiceException(
|
||||
"Error retrieving the fileUploadMonitor: null");
|
||||
|
@ -172,13 +181,15 @@ public class StatAlgoImporterServiceImpl extends RemoteServiceServlet implements
|
|||
@Override
|
||||
public ArrayList<CodeData> getCode()
|
||||
throws StatAlgoImporterServiceException {
|
||||
|
||||
try {
|
||||
HttpSession session = this.getThreadLocalRequest().getSession();
|
||||
HttpServletRequest httpRequest = this.getThreadLocalRequest();
|
||||
ServiceCredentials serviceCredentials = SessionUtil
|
||||
.getServiceCredentials(this.getThreadLocalRequest());
|
||||
.getServiceCredentials(httpRequest);
|
||||
|
||||
logger.debug("getCode()");
|
||||
Project projectSession = SessionUtil.getProjectSession(session);
|
||||
Project projectSession = SessionUtil.getProjectSession(httpRequest,
|
||||
serviceCredentials);
|
||||
if (projectSession != null) {
|
||||
CodeReader codeFileReader = new CodeReader(projectSession,
|
||||
serviceCredentials);
|
||||
|
@ -211,9 +222,9 @@ public class StatAlgoImporterServiceImpl extends RemoteServiceServlet implements
|
|||
public void createProjectOnWorkspace(ItemDescription newProjectFolder)
|
||||
throws StatAlgoImporterServiceException {
|
||||
try {
|
||||
HttpSession session = this.getThreadLocalRequest().getSession();
|
||||
HttpServletRequest httpRequest = this.getThreadLocalRequest();
|
||||
ServiceCredentials serviceCredentials = SessionUtil
|
||||
.getServiceCredentials(this.getThreadLocalRequest());
|
||||
.getServiceCredentials(httpRequest);
|
||||
logger.debug("createProjectOnWorkspace(): " + newProjectFolder);
|
||||
if (ProjectArchiver.existProjectInFolder(newProjectFolder,
|
||||
serviceCredentials)) {
|
||||
|
@ -223,7 +234,8 @@ public class StatAlgoImporterServiceImpl extends RemoteServiceServlet implements
|
|||
ProjectFolder projectFolder = new ProjectFolder(
|
||||
newProjectFolder);
|
||||
Project projectSession = new Project(projectFolder);
|
||||
SessionUtil.setProjectSession(session, projectSession);
|
||||
SessionUtil.setProjectSession(httpRequest, serviceCredentials,
|
||||
projectSession);
|
||||
logger.debug("Create Project: " + projectSession);
|
||||
}
|
||||
|
||||
|
@ -243,14 +255,15 @@ public class StatAlgoImporterServiceImpl extends RemoteServiceServlet implements
|
|||
public Project openProjectOnWorkspace(ItemDescription newProjectFolder)
|
||||
throws StatAlgoImporterServiceException {
|
||||
try {
|
||||
HttpSession session = this.getThreadLocalRequest().getSession();
|
||||
HttpServletRequest httpRequest = this.getThreadLocalRequest();
|
||||
ServiceCredentials serviceCredentials = SessionUtil
|
||||
.getServiceCredentials(this.getThreadLocalRequest());
|
||||
.getServiceCredentials(httpRequest);
|
||||
logger.debug("openProjectOnWorkspace()");
|
||||
|
||||
Project project = ProjectArchiver.readProject(newProjectFolder,
|
||||
serviceCredentials);
|
||||
SessionUtil.setProjectSession(session, project);
|
||||
SessionUtil.setProjectSession(httpRequest, serviceCredentials,
|
||||
project);
|
||||
|
||||
return project;
|
||||
} catch (StatAlgoImporterServiceException e) {
|
||||
|
@ -269,11 +282,12 @@ public class StatAlgoImporterServiceImpl extends RemoteServiceServlet implements
|
|||
public Project setMainCode(ItemDescription itemDescription)
|
||||
throws StatAlgoImporterServiceException {
|
||||
try {
|
||||
HttpSession session = this.getThreadLocalRequest().getSession();
|
||||
HttpServletRequest httpRequest = this.getThreadLocalRequest();
|
||||
ServiceCredentials serviceCredentials = SessionUtil
|
||||
.getServiceCredentials(this.getThreadLocalRequest());
|
||||
.getServiceCredentials(httpRequest);
|
||||
logger.debug("SetMainCode(): " + itemDescription);
|
||||
Project project = SessionUtil.getProjectSession(session);
|
||||
Project project = SessionUtil.getProjectSession(httpRequest,
|
||||
serviceCredentials);
|
||||
if (project != null) {
|
||||
project.setMainCode(new MainCode(itemDescription));
|
||||
project.setInputData(null);
|
||||
|
@ -281,7 +295,8 @@ public class StatAlgoImporterServiceImpl extends RemoteServiceServlet implements
|
|||
WPS4RParser wps4Parser = new WPS4RParser(project,
|
||||
serviceCredentials);
|
||||
project = wps4Parser.parse();
|
||||
SessionUtil.setProjectSession(session, project);
|
||||
SessionUtil.setProjectSession(httpRequest, serviceCredentials,
|
||||
project);
|
||||
logger.debug("Project: " + project);
|
||||
} else {
|
||||
throw new StatAlgoImporterServiceException("No project open!");
|
||||
|
@ -303,9 +318,9 @@ public class StatAlgoImporterServiceImpl extends RemoteServiceServlet implements
|
|||
public void addResourceToProject(ItemDescription itemDescription)
|
||||
throws StatAlgoImporterServiceException {
|
||||
try {
|
||||
HttpSession session = this.getThreadLocalRequest().getSession();
|
||||
HttpServletRequest httpRequest = this.getThreadLocalRequest();
|
||||
ServiceCredentials serviceCredentials = SessionUtil
|
||||
.getServiceCredentials(this.getThreadLocalRequest());
|
||||
.getServiceCredentials(httpRequest);
|
||||
logger.debug("addResourceToProject(): " + itemDescription);
|
||||
if (itemDescription == null || itemDescription.getId() == null) {
|
||||
throw new StatAlgoImporterServiceException(
|
||||
|
@ -313,7 +328,8 @@ public class StatAlgoImporterServiceImpl extends RemoteServiceServlet implements
|
|||
+ itemDescription);
|
||||
}
|
||||
|
||||
Project project = SessionUtil.getProjectSession(session);
|
||||
Project project = SessionUtil.getProjectSession(httpRequest,
|
||||
serviceCredentials);
|
||||
if (project != null && project.getProjectFolder() != null
|
||||
&& project.getProjectFolder().getFolder() != null) {
|
||||
FilesStorage fileStorage = new FilesStorage();
|
||||
|
@ -341,9 +357,9 @@ public class StatAlgoImporterServiceImpl extends RemoteServiceServlet implements
|
|||
public Project deleteResourceOnProject(ItemDescription itemDescription)
|
||||
throws StatAlgoImporterServiceException {
|
||||
try {
|
||||
HttpSession session = this.getThreadLocalRequest().getSession();
|
||||
HttpServletRequest httpRequest = this.getThreadLocalRequest();
|
||||
ServiceCredentials serviceCredentials = SessionUtil
|
||||
.getServiceCredentials(this.getThreadLocalRequest());
|
||||
.getServiceCredentials(httpRequest);
|
||||
|
||||
logger.debug("deleteResourceOnProject(): " + itemDescription);
|
||||
if (itemDescription == null || itemDescription.getId() == null) {
|
||||
|
@ -352,9 +368,10 @@ public class StatAlgoImporterServiceImpl extends RemoteServiceServlet implements
|
|||
+ itemDescription);
|
||||
}
|
||||
|
||||
Project project = SessionUtil.getProjectSession(session);
|
||||
checkProjectInfoForDelete(itemDescription, serviceCredentials,
|
||||
session, project);
|
||||
Project project = SessionUtil.getProjectSession(httpRequest,
|
||||
serviceCredentials);
|
||||
checkProjectInfoForDelete(itemDescription, httpRequest,
|
||||
serviceCredentials, project);
|
||||
FilesStorage fileStorage = new FilesStorage();
|
||||
fileStorage.deleteItemOnFolder(serviceCredentials.getUserName(),
|
||||
itemDescription.getId());
|
||||
|
@ -373,8 +390,9 @@ public class StatAlgoImporterServiceImpl extends RemoteServiceServlet implements
|
|||
}
|
||||
|
||||
private void checkProjectInfoForDelete(ItemDescription itemDescription,
|
||||
ServiceCredentials serviceCredentials, HttpSession session,
|
||||
Project project) throws StatAlgoImporterSessionExpiredException,
|
||||
HttpServletRequest httpRequest,
|
||||
ServiceCredentials serviceCredentials, Project project)
|
||||
throws StatAlgoImporterSessionExpiredException,
|
||||
StatAlgoImporterServiceException {
|
||||
if (project != null) {
|
||||
if (project.getMainCode() != null
|
||||
|
@ -384,7 +402,8 @@ public class StatAlgoImporterServiceImpl extends RemoteServiceServlet implements
|
|||
project.setMainCode(null);
|
||||
project.setInputData(null);
|
||||
project.setProjectTarget(null);
|
||||
SessionUtil.setProjectSession(session, project);
|
||||
SessionUtil.setProjectSession(httpRequest, serviceCredentials,
|
||||
project);
|
||||
ProjectArchiver.archive(project, serviceCredentials);
|
||||
} else {
|
||||
if (project.getProjectTarget() != null
|
||||
|
@ -392,7 +411,8 @@ public class StatAlgoImporterServiceImpl extends RemoteServiceServlet implements
|
|||
&& project.getProjectTarget().getFolder().getId()
|
||||
.compareTo(itemDescription.getId()) == 0) {
|
||||
project.setProjectTarget(null);
|
||||
SessionUtil.setProjectSession(session, project);
|
||||
SessionUtil.setProjectSession(httpRequest,
|
||||
serviceCredentials, project);
|
||||
ProjectArchiver.archive(project, serviceCredentials);
|
||||
} else {
|
||||
if (project.getProjectTarget() != null
|
||||
|
@ -403,7 +423,8 @@ public class StatAlgoImporterServiceImpl extends RemoteServiceServlet implements
|
|||
.getFolder().getId()
|
||||
.compareTo(itemDescription.getId()) == 0) {
|
||||
project.getProjectTarget().setProjectCompile(null);
|
||||
SessionUtil.setProjectSession(session, project);
|
||||
SessionUtil.setProjectSession(httpRequest,
|
||||
serviceCredentials, project);
|
||||
ProjectArchiver.archive(project, serviceCredentials);
|
||||
} else {
|
||||
if (project.getProjectTarget() != null
|
||||
|
@ -415,7 +436,8 @@ public class StatAlgoImporterServiceImpl extends RemoteServiceServlet implements
|
|||
.getProjectDeploy().getFolder().getId()
|
||||
.compareTo(itemDescription.getId()) == 0) {
|
||||
project.getProjectTarget().setProjectDeploy(null);
|
||||
SessionUtil.setProjectSession(session, project);
|
||||
SessionUtil.setProjectSession(httpRequest,
|
||||
serviceCredentials, project);
|
||||
ProjectArchiver
|
||||
.archive(project, serviceCredentials);
|
||||
} else {
|
||||
|
@ -431,7 +453,8 @@ public class StatAlgoImporterServiceImpl extends RemoteServiceServlet implements
|
|||
.compareTo(itemDescription.getId()) == 0) {
|
||||
project.getProjectTarget().getProjectDeploy()
|
||||
.setPackageProject(null);
|
||||
SessionUtil.setProjectSession(session, project);
|
||||
SessionUtil.setProjectSession(httpRequest,
|
||||
serviceCredentials, project);
|
||||
ProjectArchiver.archive(project,
|
||||
serviceCredentials);
|
||||
} else {
|
||||
|
@ -450,15 +473,17 @@ public class StatAlgoImporterServiceImpl extends RemoteServiceServlet implements
|
|||
public void saveProject(InputData inputData)
|
||||
throws StatAlgoImporterServiceException {
|
||||
try {
|
||||
HttpSession session = this.getThreadLocalRequest().getSession();
|
||||
HttpServletRequest httpRequest = this.getThreadLocalRequest();
|
||||
ServiceCredentials serviceCredentials = SessionUtil
|
||||
.getServiceCredentials(this.getThreadLocalRequest());
|
||||
.getServiceCredentials(httpRequest);
|
||||
|
||||
logger.debug("saveProject():" + inputData);
|
||||
Project project = SessionUtil.getProjectSession(session);
|
||||
Project project = SessionUtil.getProjectSession(httpRequest,
|
||||
serviceCredentials);
|
||||
if (project != null) {
|
||||
project.setInputData(inputData);
|
||||
SessionUtil.setProjectSession(session, project);
|
||||
SessionUtil.setProjectSession(httpRequest, serviceCredentials,
|
||||
project);
|
||||
ProjectArchiver.archive(project, serviceCredentials);
|
||||
} else {
|
||||
throw new StatAlgoImporterServiceException("No project open!");
|
||||
|
@ -479,12 +504,13 @@ public class StatAlgoImporterServiceImpl extends RemoteServiceServlet implements
|
|||
@Override
|
||||
public void saveCode(String code) throws StatAlgoImporterServiceException {
|
||||
try {
|
||||
HttpSession session = this.getThreadLocalRequest().getSession();
|
||||
HttpServletRequest httpRequest = this.getThreadLocalRequest();
|
||||
ServiceCredentials serviceCredentials = SessionUtil
|
||||
.getServiceCredentials(this.getThreadLocalRequest());
|
||||
.getServiceCredentials(httpRequest);
|
||||
|
||||
logger.debug("saveCode():" + code);
|
||||
Project project = SessionUtil.getProjectSession(session);
|
||||
Project project = SessionUtil.getProjectSession(httpRequest,
|
||||
serviceCredentials);
|
||||
if (project != null) {
|
||||
MainCode mainCode = project.getMainCode();
|
||||
if (mainCode == null || mainCode.getItemDescription() == null) {
|
||||
|
@ -515,12 +541,13 @@ public class StatAlgoImporterServiceImpl extends RemoteServiceServlet implements
|
|||
public Project setNewMainCode(ItemDescription fileDescription, String code)
|
||||
throws StatAlgoImporterServiceException {
|
||||
try {
|
||||
HttpSession session = this.getThreadLocalRequest().getSession();
|
||||
HttpServletRequest httpRequest = this.getThreadLocalRequest();
|
||||
ServiceCredentials serviceCredentials = SessionUtil
|
||||
.getServiceCredentials(this.getThreadLocalRequest());
|
||||
.getServiceCredentials(httpRequest);
|
||||
logger.debug("saveCode(): itemDescription" + fileDescription
|
||||
+ ", code:" + code);
|
||||
Project project = SessionUtil.getProjectSession(session);
|
||||
Project project = SessionUtil.getProjectSession(httpRequest,
|
||||
serviceCredentials);
|
||||
if (project != null && project.getProjectFolder() != null
|
||||
&& project.getProjectFolder().getFolder() != null) {
|
||||
MainCodeSave mainCodeSave = new MainCodeSave();
|
||||
|
@ -533,7 +560,8 @@ public class StatAlgoImporterServiceImpl extends RemoteServiceServlet implements
|
|||
WPS4RParser wps4Parser = new WPS4RParser(project,
|
||||
serviceCredentials);
|
||||
project = wps4Parser.parse();
|
||||
SessionUtil.setProjectSession(session, project);
|
||||
SessionUtil.setProjectSession(httpRequest, serviceCredentials,
|
||||
project);
|
||||
return project;
|
||||
} else {
|
||||
throw new StatAlgoImporterServiceException("No project open!");
|
||||
|
@ -554,18 +582,21 @@ public class StatAlgoImporterServiceImpl extends RemoteServiceServlet implements
|
|||
public void createSoftware(InputData inputData)
|
||||
throws StatAlgoImporterServiceException {
|
||||
try {
|
||||
HttpSession session = this.getThreadLocalRequest().getSession();
|
||||
HttpServletRequest httpRequest = this.getThreadLocalRequest();
|
||||
ServiceCredentials serviceCredentials = SessionUtil
|
||||
.getServiceCredentials(this.getThreadLocalRequest());
|
||||
.getServiceCredentials(httpRequest);
|
||||
logger.debug("createSoftware(): " + inputData);
|
||||
Project project = SessionUtil.getProjectSession(session);
|
||||
Project project = SessionUtil.getProjectSession(httpRequest,
|
||||
serviceCredentials);
|
||||
if (project != null) {
|
||||
project.setInputData(inputData);
|
||||
SessionUtil.setProjectSession(session, project);
|
||||
SessionUtil.setProjectSession(httpRequest, serviceCredentials,
|
||||
project);
|
||||
ProjectBuilder projectBuilder = new ProjectBuilder(project,
|
||||
serviceCredentials);
|
||||
project = projectBuilder.buildTarget();
|
||||
SessionUtil.setProjectSession(session, project);
|
||||
SessionUtil.setProjectSession(httpRequest, serviceCredentials,
|
||||
project);
|
||||
ProjectArchiver.archive(project, serviceCredentials);
|
||||
} else {
|
||||
throw new StatAlgoImporterServiceException("No project open!");
|
||||
|
@ -587,12 +618,13 @@ public class StatAlgoImporterServiceImpl extends RemoteServiceServlet implements
|
|||
public String getPublicLink(ItemDescription itemDescription)
|
||||
throws StatAlgoImporterServiceException {
|
||||
try {
|
||||
HttpServletRequest httpRequest = this.getThreadLocalRequest();
|
||||
ServiceCredentials serviceCredentials = SessionUtil
|
||||
.getServiceCredentials(this.getThreadLocalRequest());
|
||||
.getServiceCredentials(httpRequest);
|
||||
logger.debug("GetPublicLink(): " + itemDescription);
|
||||
FilesStorage filesStorage = new FilesStorage();
|
||||
String link = filesStorage.getPublicLink(serviceCredentials.getUserName(),
|
||||
itemDescription.getId());
|
||||
String link = filesStorage.getPublicLink(
|
||||
serviceCredentials.getUserName(), itemDescription.getId());
|
||||
|
||||
return link;
|
||||
} catch (StatAlgoImporterServiceException e) {
|
||||
|
@ -608,18 +640,18 @@ public class StatAlgoImporterServiceImpl extends RemoteServiceServlet implements
|
|||
@Override
|
||||
public void publishSoftware() throws StatAlgoImporterServiceException {
|
||||
try {
|
||||
HttpSession session = this.getThreadLocalRequest().getSession();
|
||||
HttpServletRequest httpRequest = this.getThreadLocalRequest();
|
||||
ServiceCredentials serviceCredentials = SessionUtil
|
||||
.getServiceCredentials(this.getThreadLocalRequest());
|
||||
.getServiceCredentials(httpRequest);
|
||||
logger.debug("PublishSoftware()");
|
||||
ArrayList<Recipient> recipients = SessionUtil.getRecipients(session
|
||||
.getServletContext());
|
||||
Project project = SessionUtil.getProjectSession(session);
|
||||
ArrayList<Recipient> recipients = SessionUtil
|
||||
.getRecipients(httpRequest.getServletContext());
|
||||
Project project = SessionUtil.getProjectSession(httpRequest, serviceCredentials);
|
||||
if (project != null) {
|
||||
ProjectBuilder projectBuilder = new ProjectBuilder(project,
|
||||
serviceCredentials);
|
||||
project = projectBuilder.buildDeploy();
|
||||
SessionUtil.setProjectSession(session, project);
|
||||
SessionUtil.setProjectSession(httpRequest, serviceCredentials, project);
|
||||
ProjectArchiver.archive(project, serviceCredentials);
|
||||
AlgorithmNotification notify = new AlgorithmNotification(
|
||||
this.getThreadLocalRequest(), serviceCredentials,
|
||||
|
@ -645,16 +677,16 @@ public class StatAlgoImporterServiceImpl extends RemoteServiceServlet implements
|
|||
@Override
|
||||
public void repackageSoftware() throws StatAlgoImporterServiceException {
|
||||
try {
|
||||
HttpSession session = this.getThreadLocalRequest().getSession();
|
||||
HttpServletRequest httpRequest = this.getThreadLocalRequest();
|
||||
ServiceCredentials serviceCredentials = SessionUtil
|
||||
.getServiceCredentials(this.getThreadLocalRequest());
|
||||
.getServiceCredentials(httpRequest);
|
||||
logger.debug("RepackageSoftware()");
|
||||
Project project = SessionUtil.getProjectSession(session);
|
||||
Project project = SessionUtil.getProjectSession(httpRequest, serviceCredentials);
|
||||
if (project != null) {
|
||||
ProjectBuilder projectBuilder = new ProjectBuilder(project,
|
||||
serviceCredentials);
|
||||
project = projectBuilder.buildRepackage();
|
||||
SessionUtil.setProjectSession(session, project);
|
||||
SessionUtil.setProjectSession(httpRequest, serviceCredentials, project);
|
||||
ProjectArchiver.archive(project, serviceCredentials);
|
||||
} else {
|
||||
throw new StatAlgoImporterServiceException(
|
||||
|
|
Loading…
Reference in New Issue