refs 2521: Explore the possibility to port the StatMan interface onto Dataminer
https://support.d4science.org/issues/2521 Fixed time delay on Show Computation git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/data-miner-manager@128758 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
7309dd2a8f
commit
109423f1c0
|
@ -328,7 +328,7 @@ public class ComputationsExecutedPanel extends FramedPanel {
|
|||
|
||||
@Override
|
||||
public void onSelect(SelectEvent event) {
|
||||
openFile();
|
||||
downloadFile();
|
||||
}
|
||||
|
||||
});
|
||||
|
@ -461,7 +461,7 @@ public class ComputationsExecutedPanel extends FramedPanel {
|
|||
|
||||
}
|
||||
|
||||
private void openFile() {
|
||||
private void downloadFile() {
|
||||
if (selectedItem != null && !selectedItem.isFolder()) {
|
||||
|
||||
final ItemDescription itemDescription = new ItemDescription(
|
||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 6.1 KiB After Width: | Height: | Size: 4.1 KiB |
Binary file not shown.
Before Width: | Height: | Size: 7.7 KiB After Width: | Height: | Size: 4.2 KiB |
|
@ -93,9 +93,9 @@ public class DataMinerManagerServiceImpl extends RemoteServiceServlet implements
|
|||
try {
|
||||
HttpSession session = this.getThreadLocalRequest().getSession();
|
||||
ASLSession aslSession = SessionUtil.getASLSession(session);
|
||||
SClient smClient = SessionUtil.getSClient(session, aslSession);
|
||||
SClient smClient = SessionUtil.getSClient(aslSession);
|
||||
List<OperatorsClassification> list= smClient.getOperatorsClassifications();
|
||||
SessionUtil.putSClient(session, smClient);
|
||||
//SessionUtil.putSClient(session, smClient);
|
||||
return list;
|
||||
} catch (ServiceException e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
|
@ -117,9 +117,9 @@ public class DataMinerManagerServiceImpl extends RemoteServiceServlet implements
|
|||
HttpSession session = this.getThreadLocalRequest().getSession();
|
||||
ASLSession aslSession = SessionUtil.getASLSession(session);
|
||||
|
||||
SClient smClient = SessionUtil.getSClient(session, aslSession);
|
||||
SClient smClient = SessionUtil.getSClient(aslSession);
|
||||
List<Parameter> list=smClient.getInputParameters(operator);
|
||||
SessionUtil.putSClient(session, smClient);
|
||||
//SessionUtil.putSClient(session, smClient);
|
||||
return list;
|
||||
} catch (ServiceException e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
|
@ -139,9 +139,9 @@ public class DataMinerManagerServiceImpl extends RemoteServiceServlet implements
|
|||
HttpSession session = this.getThreadLocalRequest().getSession();
|
||||
ASLSession aslSession = SessionUtil.getASLSession(session);
|
||||
logger.debug("StartComputation(): [ operator=" + operator + "]");
|
||||
SClient smClient = SessionUtil.getSClient(session, aslSession);
|
||||
SClient smClient = SessionUtil.getSClient(aslSession);
|
||||
ComputationId computationId= smClient.startComputation(operator);
|
||||
SessionUtil.putSClient(session, smClient);
|
||||
//SessionUtil.putSClient(session, smClient);
|
||||
return computationId;
|
||||
} catch (ServiceException e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
|
@ -164,9 +164,9 @@ public class DataMinerManagerServiceImpl extends RemoteServiceServlet implements
|
|||
Map<String, String> properties = StorageUtil.getProperties(
|
||||
aslSession.getUsername(), itemDescription.getId());
|
||||
logger.debug("Properties: " + properties);
|
||||
SClient smClient = SessionUtil.getSClient(session, aslSession);
|
||||
SClient smClient = SessionUtil.getSClient(aslSession);
|
||||
ComputationId computationId= smClient.resubmitComputation(properties);
|
||||
SessionUtil.putSClient(session, smClient);
|
||||
//SessionUtil.putSClient(session, smClient);
|
||||
return computationId;
|
||||
} catch (ServiceException e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
|
@ -186,9 +186,9 @@ public class DataMinerManagerServiceImpl extends RemoteServiceServlet implements
|
|||
HttpSession session = this.getThreadLocalRequest().getSession();
|
||||
ASLSession aslSession = SessionUtil.getASLSession(session);
|
||||
|
||||
SClient smClient = SessionUtil.getSClient(session, aslSession);
|
||||
SClient smClient = SessionUtil.getSClient(aslSession);
|
||||
ComputationStatus computationStatus= smClient.getComputationStatus(computationId);
|
||||
SessionUtil.putSClient(session, smClient);
|
||||
//SessionUtil.putSClient(session, smClient);
|
||||
return computationStatus;
|
||||
|
||||
} catch (ServiceException e) {
|
||||
|
@ -293,9 +293,9 @@ public class DataMinerManagerServiceImpl extends RemoteServiceServlet implements
|
|||
HttpSession session = this.getThreadLocalRequest().getSession();
|
||||
ASLSession aslSession = SessionUtil.getASLSession(session);
|
||||
logger.debug("CancelComputation(): " + computationId);
|
||||
SClient smClient = SessionUtil.getSClient(session, aslSession);
|
||||
SClient smClient = SessionUtil.getSClient(aslSession);
|
||||
String result = smClient.cancelComputation(computationId);
|
||||
SessionUtil.putSClient(session, smClient);
|
||||
//SessionUtil.putSClient(session, smClient);
|
||||
return result;
|
||||
} catch (ServiceException e) {
|
||||
logger.error(e.getLocalizedMessage());
|
||||
|
@ -315,10 +315,10 @@ public class DataMinerManagerServiceImpl extends RemoteServiceServlet implements
|
|||
HttpSession session = this.getThreadLocalRequest().getSession();
|
||||
ASLSession aslSession = SessionUtil.getASLSession(session);
|
||||
|
||||
SClient smClient = SessionUtil.getSClient(session, aslSession);
|
||||
SClient smClient = SessionUtil.getSClient(aslSession);
|
||||
OutputData outputData = smClient
|
||||
.getOutputDataByComputationId(computationId);
|
||||
SessionUtil.putSClient(session, smClient);
|
||||
//SessionUtil.putSClient(session, smClient);
|
||||
Log.debug("OutputData: " + outputData);
|
||||
return outputData;
|
||||
} catch (ServiceException e) {
|
||||
|
@ -344,9 +344,9 @@ public class DataMinerManagerServiceImpl extends RemoteServiceServlet implements
|
|||
Map<String, String> properties = StorageUtil.getProperties(
|
||||
aslSession.getUsername(), itemDescription.getId());
|
||||
logger.debug("Properties: " + properties);
|
||||
SClient smClient = SessionUtil.getSClient(session, aslSession);
|
||||
SClient smClient = SessionUtil.getSClient(aslSession);
|
||||
ComputationData computationData= smClient.getComputationDataByComputationProperties(properties);
|
||||
SessionUtil.putSClient(session, smClient);
|
||||
//SessionUtil.putSClient(session, smClient);
|
||||
return computationData;
|
||||
|
||||
|
||||
|
|
|
@ -0,0 +1,67 @@
|
|||
package org.gcube.portlets.user.dataminermanager.server;
|
||||
|
||||
import java.io.IOException;
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.annotation.WebServlet;
|
||||
import javax.servlet.http.HttpServlet;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
/**
|
||||
* DownloadFolder Servlet
|
||||
*/
|
||||
@WebServlet("/DownloadFolderServlet")
|
||||
public class DownloadFolderServlet extends HttpServlet {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* @see HttpServlet#HttpServlet()
|
||||
*/
|
||||
public DownloadFolderServlet() {
|
||||
super();
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
/**
|
||||
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
|
||||
*/
|
||||
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||
createResponse(request, response);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
|
||||
*/
|
||||
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||
createResponse(request, response);
|
||||
}
|
||||
|
||||
|
||||
private void createResponse(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException{
|
||||
/*try {
|
||||
|
||||
request.getParameter("c")
|
||||
|
||||
File tmpZip = ZipUtil.zipFolder((WorkspaceFolder) item);
|
||||
resp.setHeader( "Content-Disposition", "attachment; filename=\"" + item.getName() + ".zip\"" );
|
||||
resp.setContentType("application/zip");
|
||||
resp = setContentLength(resp, tmpZip.length());
|
||||
OutputStream out = resp.getOutputStream();
|
||||
|
||||
FileInputStream fileTmpZip = new FileInputStream(tmpZip);
|
||||
IOUtils.copy(fileTmpZip, resp.getOutputStream());
|
||||
fileTmpZip.close();
|
||||
|
||||
out.close();
|
||||
tmpZip.delete();
|
||||
return;
|
||||
|
||||
} catch (Exception e) {
|
||||
logger.error("Error during folder compression "+itemId,e);
|
||||
handleError(urlRedirectOnError, req, resp, itemId, HttpServletResponse.SC_INTERNAL_SERVER_ERROR +": Error during folder compression: "+e.getMessage());
|
||||
return;
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
}
|
|
@ -89,7 +89,7 @@ public class SessionUtil {
|
|||
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
public static void putSClient(HttpSession session, SClient sClient)
|
||||
throws Exception {
|
||||
SClient sc = (SClient) session.getAttribute(Constants.SClient);
|
||||
|
@ -99,15 +99,20 @@ public class SessionUtil {
|
|||
session.removeAttribute(Constants.SClient);
|
||||
session.setAttribute(Constants.SClient, sClient);
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
|
||||
|
||||
|
||||
public static SClient getSClient(HttpSession session, ASLSession aslSession)
|
||||
public static SClient getSClient(ASLSession aslSession)
|
||||
throws Exception {
|
||||
|
||||
SClient sClient = (SClient) session.getAttribute(Constants.SClient);
|
||||
if(aslSession==null){
|
||||
logger.error("ASLSession is null!");
|
||||
throw new ExpiredSessionServiceException("Session Expired!");
|
||||
}
|
||||
|
||||
SClient sClient = (SClient) aslSession.getAttribute(Constants.SClient);
|
||||
if (sClient == null) {
|
||||
logger.info("Created new SClient");
|
||||
ServiceCredential serviceCredential=new ServiceCredential(aslSession.getUsername(), aslSession.getScope(),
|
||||
|
@ -118,7 +123,7 @@ public class SessionUtil {
|
|||
director.setSClientBuilder(sBuilder);
|
||||
director.constructSClient();
|
||||
sClient = director.getSClient();
|
||||
session.setAttribute(Constants.SClient, sClient);
|
||||
aslSession.setAttribute(Constants.SClient, sClient);
|
||||
} else {
|
||||
logger.info("Use SClient in session");
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package org.gcube.portlets.user.dataminermanager.server.smservice.wps.computationsvalue;
|
||||
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
|
@ -73,37 +73,13 @@ public class ComputationValueBuilder {
|
|||
}
|
||||
|
||||
private ComputationValue retrieveFileName(final String value) {
|
||||
HttpURLConnection conn = null;
|
||||
|
||||
URLConnection conn = null;
|
||||
logger.debug("Retrieve File Header from Storage for value: "+value);
|
||||
try {
|
||||
//Use URL connection because in internal network is more fast
|
||||
URL url = new URL(value);
|
||||
int attempts = 0;
|
||||
do {
|
||||
conn = (HttpURLConnection) url.openConnection();
|
||||
conn.setConnectTimeout(30000);
|
||||
conn.setReadTimeout(30000);
|
||||
conn.setRequestMethod("HEAD");
|
||||
conn.setAllowUserInteraction(false);
|
||||
conn.setDoInput(true);
|
||||
conn.setDoOutput(true);
|
||||
conn.connect();
|
||||
if (conn.getResponseCode() != 200) {
|
||||
logger.error("Retrieve File Name Response Code: "
|
||||
+ conn.getResponseCode());
|
||||
try {
|
||||
Thread.sleep(5000);
|
||||
} catch (InterruptedException e) {
|
||||
|
||||
}
|
||||
}
|
||||
attempts++;
|
||||
} while (attempts <= 5 || conn.getResponseCode() != 200);
|
||||
|
||||
if (conn.getResponseCode() == 200) {
|
||||
conn = url.openConnection();
|
||||
return extractFileName(conn, value);
|
||||
} else {
|
||||
return new ComputationValueFile(value, null, null);
|
||||
}
|
||||
|
||||
} catch (Throwable e) {
|
||||
logger.error("Retrieve File Name: " + e.getLocalizedMessage());
|
||||
|
@ -112,7 +88,47 @@ public class ComputationValueBuilder {
|
|||
}
|
||||
}
|
||||
|
||||
private ComputationValue extractFileName(HttpURLConnection conn,
|
||||
/*
|
||||
int attempts = 0;
|
||||
|
||||
|
||||
do {
|
||||
logger.debug("Attempts: "+attempts);
|
||||
|
||||
conn = (HttpURLConnection) url.openConnection();
|
||||
conn.setConnectTimeout(30000);
|
||||
conn.setReadTimeout(30000);
|
||||
conn.setRequestMethod("HEAD");
|
||||
conn.setAllowUserInteraction(false);
|
||||
conn.setDoInput(false);
|
||||
conn.setDoOutput(false);
|
||||
|
||||
conn.connect();
|
||||
|
||||
if (conn.getResponseCode() != 200) {
|
||||
logger.error("Retrieve File Name Response Code: "
|
||||
+ conn.getResponseCode());
|
||||
try {
|
||||
logger.debug("Sleep time: 5000");
|
||||
Thread.sleep(5000);
|
||||
} catch (InterruptedException e) {
|
||||
|
||||
}
|
||||
}
|
||||
attempts++;
|
||||
|
||||
} while (attempts <= 5 || conn.getResponseCode() != 200);
|
||||
|
||||
if (conn.getResponseCode() == 200) {
|
||||
logger.debug("Retrived Header");
|
||||
return extractFileName(conn, value);
|
||||
} else {
|
||||
logger.debug("Header not retrieved use default");
|
||||
return new ComputationValueFile(value, null, null);
|
||||
}
|
||||
*/
|
||||
|
||||
private ComputationValue extractFileName(URLConnection conn,
|
||||
String value) {
|
||||
ComputationValue computationValue = null;
|
||||
String fileName = null;
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package org.gcube.portlets.user.dataminermanager.server.storage;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.URL;
|
||||
|
@ -15,11 +16,13 @@ import org.gcube.common.homelibrary.home.exceptions.HomeNotFoundException;
|
|||
import org.gcube.common.homelibrary.home.exceptions.InternalErrorException;
|
||||
import org.gcube.common.homelibrary.home.workspace.Properties;
|
||||
import org.gcube.common.homelibrary.home.workspace.Workspace;
|
||||
import org.gcube.common.homelibrary.home.workspace.WorkspaceFolder;
|
||||
import org.gcube.common.homelibrary.home.workspace.WorkspaceItem;
|
||||
import org.gcube.common.homelibrary.home.workspace.exceptions.InsufficientPrivilegesException;
|
||||
import org.gcube.common.homelibrary.home.workspace.exceptions.ItemNotFoundException;
|
||||
import org.gcube.common.homelibrary.home.workspace.exceptions.WorkspaceFolderNotFoundException;
|
||||
import org.gcube.common.homelibrary.home.workspace.exceptions.WrongItemTypeException;
|
||||
import org.gcube.common.homelibrary.util.zip.ZipUtil;
|
||||
import org.gcube.contentmanagement.blobstorage.service.IClient;
|
||||
import org.gcube.contentmanager.storageclient.model.protocol.smp.SMPURLConnection;
|
||||
import org.gcube.contentmanager.storageclient.wrapper.AccessType;
|
||||
|
@ -216,6 +219,33 @@ public class StorageUtil {
|
|||
}
|
||||
}
|
||||
|
||||
public File zipFolder(String user, String folderId)
|
||||
throws ServiceException {
|
||||
Workspace ws;
|
||||
try {
|
||||
ws = HomeLibrary.getUserWorkspace(user);
|
||||
|
||||
WorkspaceItem workSpaceItem = ws.getItem(folderId);
|
||||
if (!workSpaceItem.isFolder()) {
|
||||
throw new ServiceException(
|
||||
"Item is not valid folder!");
|
||||
}
|
||||
|
||||
WorkspaceFolder folder = (WorkspaceFolder) workSpaceItem;
|
||||
|
||||
File fileZip = ZipUtil.zipFolder(folder);
|
||||
|
||||
return fileZip;
|
||||
|
||||
} catch (IOException | InternalErrorException
|
||||
| WorkspaceFolderNotFoundException | HomeNotFoundException
|
||||
| ItemNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
throw new ServiceException(e.getLocalizedMessage());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param user
|
||||
|
|
|
@ -1,8 +1,5 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<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">
|
||||
|
||||
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" version="3.0">
|
||||
<servlet>
|
||||
<servlet-name>DataMinerManagerServlet</servlet-name>
|
||||
<servlet-class>org.gcube.portlets.user.dataminermanager.server.DataMinerManagerServiceImpl</servlet-class>
|
||||
|
@ -15,40 +12,30 @@
|
|||
<servlet-name>DownloadService</servlet-name>
|
||||
<servlet-class>org.gcube.portlets.user.dataminermanager.server.DownloadServlet</servlet-class>
|
||||
</servlet>
|
||||
|
||||
<!-- Workspace Explorer -->
|
||||
<servlet>
|
||||
<servlet-name>workspaceExplorer</servlet-name>
|
||||
<servlet-class>org.gcube.portlets.widgets.wsexplorer.server.WorkspaceExplorerServiceImpl</servlet-class>
|
||||
</servlet>
|
||||
|
||||
<!-- Workspace Uploader -->
|
||||
<servlet>
|
||||
<servlet-name>workspaceUploaderService</servlet-name>
|
||||
<servlet-class>org.gcube.portlets.widgets.workspaceuploader.server.WorkspaceUploaderServiceImpl</servlet-class>
|
||||
</servlet>
|
||||
|
||||
<servlet>
|
||||
<servlet-name>workspaceUploadServletStream</servlet-name>
|
||||
<servlet-class>org.gcube.portlets.widgets.workspaceuploader.server.WorkspaceUploadServletStream</servlet-class>
|
||||
</servlet>
|
||||
|
||||
<servlet>
|
||||
<servlet-name>checkServlet</servlet-name>
|
||||
<servlet-class>org.gcube.portlets.widgets.sessionchecker.server.SessionCheckerServiceImpl</servlet-class>
|
||||
</servlet>
|
||||
|
||||
<servlet>
|
||||
<servlet-name>scopeService</servlet-name>
|
||||
<servlet-class>org.gcube.portlets.user.gcubewidgets.server.ScopeServiceImpl</servlet-class>
|
||||
</servlet>
|
||||
|
||||
<!-- Mapping -->
|
||||
<servlet-mapping>
|
||||
<servlet-name>DataMinerManagerServlet</servlet-name>
|
||||
<url-pattern>/dataminermanager/dataminerman</url-pattern>
|
||||
</servlet-mapping>
|
||||
|
||||
<servlet-mapping>
|
||||
<servlet-name>jUnitHostImpl</servlet-name>
|
||||
<url-pattern>/dataminermanager/junithost/*</url-pattern>
|
||||
|
@ -57,40 +44,27 @@
|
|||
<servlet-name>DownloadService</servlet-name>
|
||||
<url-pattern>/dataminermanager/DownloadService</url-pattern>
|
||||
</servlet-mapping>
|
||||
|
||||
<servlet-mapping>
|
||||
<servlet-name>workspaceExplorer</servlet-name>
|
||||
<url-pattern>/dataminermanager/WorkspaceExplorerService</url-pattern>
|
||||
</servlet-mapping>
|
||||
|
||||
<servlet-mapping>
|
||||
<servlet-name>workspaceUploaderService</servlet-name>
|
||||
<url-pattern>/dataminermanager/workspaceUploaderService</url-pattern>
|
||||
</servlet-mapping>
|
||||
|
||||
|
||||
<servlet-mapping>
|
||||
<servlet-name>workspaceUploadServletStream</servlet-name>
|
||||
<url-pattern>/dataminermanager/workspaceUploadServletStream</url-pattern>
|
||||
</servlet-mapping>
|
||||
|
||||
|
||||
<servlet-mapping>
|
||||
<servlet-name>checkServlet</servlet-name>
|
||||
<url-pattern>/dataminermanager/checksession</url-pattern>
|
||||
</servlet-mapping>
|
||||
|
||||
|
||||
|
||||
<servlet-mapping>
|
||||
<servlet-name>scopeService</servlet-name>
|
||||
<url-pattern>/dataminermanager/scopeService</url-pattern>
|
||||
</servlet-mapping>
|
||||
|
||||
|
||||
<welcome-file-list>
|
||||
<welcome-file>DataMinerManager.html</welcome-file>
|
||||
</welcome-file-list>
|
||||
|
||||
|
||||
</web-app>
|
Loading…
Reference in New Issue