refs 2521: Explore the possibility to port the StatMan interface onto Dataminer
https://support.d4science.org/issues/2521 Added Folder Download git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/data-miner-manager@128772 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
109423f1c0
commit
6193c8c1c8
|
@ -16,6 +16,7 @@ import org.gcube.portlets.user.dataminermanager.client.events.UIStateEvent;
|
||||||
import org.gcube.portlets.user.dataminermanager.client.rpc.DataMinerPortletServiceAsync;
|
import org.gcube.portlets.user.dataminermanager.client.rpc.DataMinerPortletServiceAsync;
|
||||||
import org.gcube.portlets.user.dataminermanager.client.type.DataMinerWorkAreaElementType;
|
import org.gcube.portlets.user.dataminermanager.client.type.DataMinerWorkAreaElementType;
|
||||||
import org.gcube.portlets.user.dataminermanager.client.util.UtilsGXT3;
|
import org.gcube.portlets.user.dataminermanager.client.util.UtilsGXT3;
|
||||||
|
import org.gcube.portlets.user.dataminermanager.shared.Constants;
|
||||||
import org.gcube.portlets.user.dataminermanager.shared.exception.ExpiredSessionServiceException;
|
import org.gcube.portlets.user.dataminermanager.shared.exception.ExpiredSessionServiceException;
|
||||||
import org.gcube.portlets.user.dataminermanager.shared.workspace.ItemDescription;
|
import org.gcube.portlets.user.dataminermanager.shared.workspace.ItemDescription;
|
||||||
import org.gcube.portlets.widgets.workspaceuploader.client.WorkspaceUploadNotification.WorskpaceUploadNotificationListener;
|
import org.gcube.portlets.widgets.workspaceuploader.client.WorkspaceUploadNotification.WorskpaceUploadNotificationListener;
|
||||||
|
@ -27,6 +28,7 @@ import org.gcube.portlets.widgets.wsexplorer.shared.FilterCriteria;
|
||||||
import org.gcube.portlets.widgets.wsexplorer.shared.Item;
|
import org.gcube.portlets.widgets.wsexplorer.shared.Item;
|
||||||
|
|
||||||
import com.allen_sauer.gwt.log.client.Log;
|
import com.allen_sauer.gwt.log.client.Log;
|
||||||
|
import com.google.gwt.core.client.GWT;
|
||||||
import com.google.gwt.user.client.Window;
|
import com.google.gwt.user.client.Window;
|
||||||
import com.google.gwt.user.client.rpc.AsyncCallback;
|
import com.google.gwt.user.client.rpc.AsyncCallback;
|
||||||
import com.sencha.gxt.cell.core.client.ButtonCell.ButtonScale;
|
import com.sencha.gxt.cell.core.client.ButtonCell.ButtonScale;
|
||||||
|
@ -144,7 +146,8 @@ public class ComputationsExecutedPanel extends FramedPanel {
|
||||||
|
|
||||||
private void manageDataMinerWorkAreaEvents(DataMinerWorkAreaEvent event) {
|
private void manageDataMinerWorkAreaEvents(DataMinerWorkAreaEvent event) {
|
||||||
|
|
||||||
Log.debug("ComputationsExecutedPanel recieved DataMinerWorkAreaEvent: " + event);
|
Log.debug("ComputationsExecutedPanel recieved DataMinerWorkAreaEvent: "
|
||||||
|
+ event);
|
||||||
if (event == null) {
|
if (event == null) {
|
||||||
Log.error("DataMinerWorkAreaEvent null");
|
Log.error("DataMinerWorkAreaEvent null");
|
||||||
return;
|
return;
|
||||||
|
@ -227,7 +230,8 @@ public class ComputationsExecutedPanel extends FramedPanel {
|
||||||
|
|
||||||
wsResourcesExplorerPanel = new WorkspaceResourcesExplorerPanel(
|
wsResourcesExplorerPanel = new WorkspaceResourcesExplorerPanel(
|
||||||
event.getDataMinerWorkArea().getComputations().getFolder()
|
event.getDataMinerWorkArea().getComputations().getFolder()
|
||||||
.getId(), false, showProperties, filterCriteria, true);
|
.getId(), false, showProperties, filterCriteria,
|
||||||
|
true);
|
||||||
WorskpaceExplorerSelectNotificationListener wsResourceExplorerListener = new WorskpaceExplorerSelectNotificationListener() {
|
WorskpaceExplorerSelectNotificationListener wsResourceExplorerListener = new WorskpaceExplorerSelectNotificationListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onSelectedItem(Item item) {
|
public void onSelectedItem(Item item) {
|
||||||
|
@ -462,39 +466,56 @@ public class ComputationsExecutedPanel extends FramedPanel {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void downloadFile() {
|
private void downloadFile() {
|
||||||
if (selectedItem != null && !selectedItem.isFolder()) {
|
if (selectedItem != null) {
|
||||||
|
if (selectedItem.isFolder()) {
|
||||||
|
StringBuilder actionUrl = new StringBuilder();
|
||||||
|
actionUrl.append(GWT.getModuleBaseURL());
|
||||||
|
actionUrl
|
||||||
|
.append(Constants.DOWNLOAD_FOLDER_SERVLET
|
||||||
|
+ "?"
|
||||||
|
+ Constants.DOWNLOAD_FOLDER_SERVLET_ITEM_ID_PARAMETER
|
||||||
|
+ "="
|
||||||
|
+ selectedItem.getId()
|
||||||
|
+ "&"
|
||||||
|
+ Constants.DOWNLOAD_FOLDER_SERVLET_FOLDER_NAME_PARAMETER
|
||||||
|
+ "=" + selectedItem.getName());
|
||||||
|
|
||||||
final ItemDescription itemDescription = new ItemDescription(
|
Log.debug("Retrieved link: " + actionUrl);
|
||||||
selectedItem.getId(), selectedItem.getName(),
|
Window.open(actionUrl.toString(), selectedItem.getName(), "");
|
||||||
selectedItem.getOwner(), selectedItem.getPath(),
|
|
||||||
selectedItem.getType().name());
|
|
||||||
|
|
||||||
DataMinerPortletServiceAsync.INSTANCE.getPublicLink(
|
} else {
|
||||||
itemDescription, new AsyncCallback<String>() {
|
|
||||||
|
final ItemDescription itemDescription = new ItemDescription(
|
||||||
|
selectedItem.getId(), selectedItem.getName(),
|
||||||
|
selectedItem.getOwner(), selectedItem.getPath(),
|
||||||
|
selectedItem.getType().name());
|
||||||
|
|
||||||
|
DataMinerPortletServiceAsync.INSTANCE.getPublicLink(
|
||||||
|
itemDescription, new AsyncCallback<String>() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onFailure(Throwable caught) {
|
||||||
|
if (caught instanceof ExpiredSessionServiceException) {
|
||||||
|
EventBusProvider.INSTANCE
|
||||||
|
.fireEvent(new SessionExpiredEvent());
|
||||||
|
} else {
|
||||||
|
Log.error("Error open file: "
|
||||||
|
+ caught.getLocalizedMessage());
|
||||||
|
UtilsGXT3.alert("Error",
|
||||||
|
caught.getLocalizedMessage());
|
||||||
|
}
|
||||||
|
caught.printStackTrace();
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onFailure(Throwable caught) {
|
|
||||||
if (caught instanceof ExpiredSessionServiceException) {
|
|
||||||
EventBusProvider.INSTANCE
|
|
||||||
.fireEvent(new SessionExpiredEvent());
|
|
||||||
} else {
|
|
||||||
Log.error("Error open file: "
|
|
||||||
+ caught.getLocalizedMessage());
|
|
||||||
UtilsGXT3.alert("Error",
|
|
||||||
caught.getLocalizedMessage());
|
|
||||||
}
|
}
|
||||||
caught.printStackTrace();
|
|
||||||
|
|
||||||
}
|
@Override
|
||||||
|
public void onSuccess(String link) {
|
||||||
@Override
|
Log.debug("Retrieved link: " + link);
|
||||||
public void onSuccess(String link) {
|
Window.open(link, itemDescription.getName(), "");
|
||||||
Log.debug("Retrieved link: " + link);
|
}
|
||||||
Window.open(link, itemDescription.getName(), "");
|
|
||||||
}
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
|
});
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
UtilsGXT3.info("Attention", "Select a file!");
|
UtilsGXT3.info("Attention", "Select a file!");
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,6 +14,7 @@ import org.gcube.portlets.user.dataminermanager.client.events.UIStateEvent;
|
||||||
import org.gcube.portlets.user.dataminermanager.client.rpc.DataMinerPortletServiceAsync;
|
import org.gcube.portlets.user.dataminermanager.client.rpc.DataMinerPortletServiceAsync;
|
||||||
import org.gcube.portlets.user.dataminermanager.client.type.DataMinerWorkAreaElementType;
|
import org.gcube.portlets.user.dataminermanager.client.type.DataMinerWorkAreaElementType;
|
||||||
import org.gcube.portlets.user.dataminermanager.client.util.UtilsGXT3;
|
import org.gcube.portlets.user.dataminermanager.client.util.UtilsGXT3;
|
||||||
|
import org.gcube.portlets.user.dataminermanager.shared.Constants;
|
||||||
import org.gcube.portlets.user.dataminermanager.shared.exception.ExpiredSessionServiceException;
|
import org.gcube.portlets.user.dataminermanager.shared.exception.ExpiredSessionServiceException;
|
||||||
import org.gcube.portlets.user.dataminermanager.shared.workspace.ItemDescription;
|
import org.gcube.portlets.user.dataminermanager.shared.workspace.ItemDescription;
|
||||||
import org.gcube.portlets.widgets.workspaceuploader.client.WorkspaceUploadNotification.WorskpaceUploadNotificationListener;
|
import org.gcube.portlets.widgets.workspaceuploader.client.WorkspaceUploadNotification.WorskpaceUploadNotificationListener;
|
||||||
|
@ -25,6 +26,7 @@ import org.gcube.portlets.widgets.wsexplorer.shared.FilterCriteria;
|
||||||
import org.gcube.portlets.widgets.wsexplorer.shared.Item;
|
import org.gcube.portlets.widgets.wsexplorer.shared.Item;
|
||||||
|
|
||||||
import com.allen_sauer.gwt.log.client.Log;
|
import com.allen_sauer.gwt.log.client.Log;
|
||||||
|
import com.google.gwt.core.client.GWT;
|
||||||
import com.google.gwt.user.client.Window;
|
import com.google.gwt.user.client.Window;
|
||||||
import com.google.gwt.user.client.rpc.AsyncCallback;
|
import com.google.gwt.user.client.rpc.AsyncCallback;
|
||||||
import com.sencha.gxt.cell.core.client.ButtonCell.ButtonScale;
|
import com.sencha.gxt.cell.core.client.ButtonCell.ButtonScale;
|
||||||
|
@ -221,7 +223,8 @@ public class InputDataSetsPanel extends FramedPanel {
|
||||||
|
|
||||||
wsResourcesExplorerPanel = new WorkspaceResourcesExplorerPanel(
|
wsResourcesExplorerPanel = new WorkspaceResourcesExplorerPanel(
|
||||||
event.getDataMinerWorkArea().getInputDataSets().getFolder()
|
event.getDataMinerWorkArea().getInputDataSets().getFolder()
|
||||||
.getId(), false, showProperties, filterCriteria, true);
|
.getId(), false, showProperties, filterCriteria,
|
||||||
|
true);
|
||||||
WorskpaceExplorerSelectNotificationListener wsResourceExplorerListener = new WorskpaceExplorerSelectNotificationListener() {
|
WorskpaceExplorerSelectNotificationListener wsResourceExplorerListener = new WorskpaceExplorerSelectNotificationListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onSelectedItem(Item item) {
|
public void onSelectedItem(Item item) {
|
||||||
|
@ -393,39 +396,55 @@ public class InputDataSetsPanel extends FramedPanel {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void downloadFile() {
|
private void downloadFile() {
|
||||||
if (selectedItem != null && !selectedItem.isFolder()) {
|
if (selectedItem != null) {
|
||||||
|
if (selectedItem.isFolder()) {
|
||||||
|
StringBuilder actionUrl = new StringBuilder();
|
||||||
|
actionUrl.append(GWT.getModuleBaseURL());
|
||||||
|
actionUrl
|
||||||
|
.append(Constants.DOWNLOAD_FOLDER_SERVLET
|
||||||
|
+ "?"
|
||||||
|
+ Constants.DOWNLOAD_FOLDER_SERVLET_ITEM_ID_PARAMETER
|
||||||
|
+ "="
|
||||||
|
+ selectedItem.getId()
|
||||||
|
+ "&"
|
||||||
|
+ Constants.DOWNLOAD_FOLDER_SERVLET_FOLDER_NAME_PARAMETER
|
||||||
|
+ "=" + selectedItem.getName());
|
||||||
|
|
||||||
final ItemDescription itemDescription = new ItemDescription(
|
Log.debug("Retrieved link: " + actionUrl);
|
||||||
selectedItem.getId(), selectedItem.getName(),
|
Window.open(actionUrl.toString(), selectedItem.getName(), "");
|
||||||
selectedItem.getOwner(), selectedItem.getPath(),
|
} else {
|
||||||
selectedItem.getType().name());
|
|
||||||
|
|
||||||
DataMinerPortletServiceAsync.INSTANCE.getPublicLink(
|
final ItemDescription itemDescription = new ItemDescription(
|
||||||
itemDescription, new AsyncCallback<String>() {
|
selectedItem.getId(), selectedItem.getName(),
|
||||||
|
selectedItem.getOwner(), selectedItem.getPath(),
|
||||||
|
selectedItem.getType().name());
|
||||||
|
|
||||||
|
DataMinerPortletServiceAsync.INSTANCE.getPublicLink(
|
||||||
|
itemDescription, new AsyncCallback<String>() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onFailure(Throwable caught) {
|
||||||
|
if (caught instanceof ExpiredSessionServiceException) {
|
||||||
|
EventBusProvider.INSTANCE
|
||||||
|
.fireEvent(new SessionExpiredEvent());
|
||||||
|
} else {
|
||||||
|
Log.error("Error open file: "
|
||||||
|
+ caught.getLocalizedMessage());
|
||||||
|
UtilsGXT3.alert("Error",
|
||||||
|
caught.getLocalizedMessage());
|
||||||
|
}
|
||||||
|
caught.printStackTrace();
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onFailure(Throwable caught) {
|
|
||||||
if (caught instanceof ExpiredSessionServiceException) {
|
|
||||||
EventBusProvider.INSTANCE
|
|
||||||
.fireEvent(new SessionExpiredEvent());
|
|
||||||
} else {
|
|
||||||
Log.error("Error open file: "
|
|
||||||
+ caught.getLocalizedMessage());
|
|
||||||
UtilsGXT3.alert("Error",
|
|
||||||
caught.getLocalizedMessage());
|
|
||||||
}
|
}
|
||||||
caught.printStackTrace();
|
|
||||||
|
|
||||||
}
|
@Override
|
||||||
|
public void onSuccess(String link) {
|
||||||
@Override
|
Log.debug("Retrieved link: " + link);
|
||||||
public void onSuccess(String link) {
|
Window.open(link, itemDescription.getName(), "");
|
||||||
Log.debug("Retrieved link: " + link);
|
}
|
||||||
Window.open(link, itemDescription.getName(), "");
|
|
||||||
}
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
|
});
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
UtilsGXT3.info("Attention", "Select a file!");
|
UtilsGXT3.info("Attention", "Select a file!");
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,6 +14,7 @@ import org.gcube.portlets.user.dataminermanager.client.events.UIStateEvent;
|
||||||
import org.gcube.portlets.user.dataminermanager.client.rpc.DataMinerPortletServiceAsync;
|
import org.gcube.portlets.user.dataminermanager.client.rpc.DataMinerPortletServiceAsync;
|
||||||
import org.gcube.portlets.user.dataminermanager.client.type.DataMinerWorkAreaElementType;
|
import org.gcube.portlets.user.dataminermanager.client.type.DataMinerWorkAreaElementType;
|
||||||
import org.gcube.portlets.user.dataminermanager.client.util.UtilsGXT3;
|
import org.gcube.portlets.user.dataminermanager.client.util.UtilsGXT3;
|
||||||
|
import org.gcube.portlets.user.dataminermanager.shared.Constants;
|
||||||
import org.gcube.portlets.user.dataminermanager.shared.exception.ExpiredSessionServiceException;
|
import org.gcube.portlets.user.dataminermanager.shared.exception.ExpiredSessionServiceException;
|
||||||
import org.gcube.portlets.user.dataminermanager.shared.workspace.ItemDescription;
|
import org.gcube.portlets.user.dataminermanager.shared.workspace.ItemDescription;
|
||||||
import org.gcube.portlets.widgets.workspaceuploader.client.WorkspaceUploadNotification.WorskpaceUploadNotificationListener;
|
import org.gcube.portlets.widgets.workspaceuploader.client.WorkspaceUploadNotification.WorskpaceUploadNotificationListener;
|
||||||
|
@ -25,6 +26,7 @@ import org.gcube.portlets.widgets.wsexplorer.shared.FilterCriteria;
|
||||||
import org.gcube.portlets.widgets.wsexplorer.shared.Item;
|
import org.gcube.portlets.widgets.wsexplorer.shared.Item;
|
||||||
|
|
||||||
import com.allen_sauer.gwt.log.client.Log;
|
import com.allen_sauer.gwt.log.client.Log;
|
||||||
|
import com.google.gwt.core.client.GWT;
|
||||||
import com.google.gwt.user.client.Window;
|
import com.google.gwt.user.client.Window;
|
||||||
import com.google.gwt.user.client.rpc.AsyncCallback;
|
import com.google.gwt.user.client.rpc.AsyncCallback;
|
||||||
import com.sencha.gxt.cell.core.client.ButtonCell.ButtonScale;
|
import com.sencha.gxt.cell.core.client.ButtonCell.ButtonScale;
|
||||||
|
@ -394,38 +396,54 @@ public class OutputDataSetsPanel extends FramedPanel {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void downloadFile() {
|
private void downloadFile() {
|
||||||
if (selectedItem != null && !selectedItem.isFolder()) {
|
if (selectedItem != null) {
|
||||||
|
if (selectedItem.isFolder()) {
|
||||||
|
StringBuilder actionUrl = new StringBuilder();
|
||||||
|
actionUrl.append(GWT.getModuleBaseURL());
|
||||||
|
actionUrl
|
||||||
|
.append(Constants.DOWNLOAD_FOLDER_SERVLET
|
||||||
|
+ "?"
|
||||||
|
+ Constants.DOWNLOAD_FOLDER_SERVLET_ITEM_ID_PARAMETER
|
||||||
|
+ "="
|
||||||
|
+ selectedItem.getId()
|
||||||
|
+ "&"
|
||||||
|
+ Constants.DOWNLOAD_FOLDER_SERVLET_FOLDER_NAME_PARAMETER
|
||||||
|
+ "=" + selectedItem.getName());
|
||||||
|
|
||||||
final ItemDescription itemDescription = new ItemDescription(
|
Log.debug("Retrieved link: " + actionUrl);
|
||||||
selectedItem.getId(), selectedItem.getName(),
|
Window.open(actionUrl.toString(), selectedItem.getName(), "");
|
||||||
selectedItem.getOwner(), selectedItem.getPath(),
|
} else {
|
||||||
selectedItem.getType().name());
|
final ItemDescription itemDescription = new ItemDescription(
|
||||||
|
selectedItem.getId(), selectedItem.getName(),
|
||||||
|
selectedItem.getOwner(), selectedItem.getPath(),
|
||||||
|
selectedItem.getType().name());
|
||||||
|
|
||||||
DataMinerPortletServiceAsync.INSTANCE.getPublicLink(
|
DataMinerPortletServiceAsync.INSTANCE.getPublicLink(
|
||||||
itemDescription, new AsyncCallback<String>() {
|
itemDescription, new AsyncCallback<String>() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onFailure(Throwable caught) {
|
||||||
|
if (caught instanceof ExpiredSessionServiceException) {
|
||||||
|
EventBusProvider.INSTANCE
|
||||||
|
.fireEvent(new SessionExpiredEvent());
|
||||||
|
} else {
|
||||||
|
Log.error("Error open file: "
|
||||||
|
+ caught.getLocalizedMessage());
|
||||||
|
UtilsGXT3.alert("Error",
|
||||||
|
caught.getLocalizedMessage());
|
||||||
|
}
|
||||||
|
caught.printStackTrace();
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onFailure(Throwable caught) {
|
|
||||||
if (caught instanceof ExpiredSessionServiceException) {
|
|
||||||
EventBusProvider.INSTANCE
|
|
||||||
.fireEvent(new SessionExpiredEvent());
|
|
||||||
} else {
|
|
||||||
Log.error("Error open file: "
|
|
||||||
+ caught.getLocalizedMessage());
|
|
||||||
UtilsGXT3.alert("Error",
|
|
||||||
caught.getLocalizedMessage());
|
|
||||||
}
|
}
|
||||||
caught.printStackTrace();
|
|
||||||
|
|
||||||
}
|
@Override
|
||||||
|
public void onSuccess(String link) {
|
||||||
|
Log.debug("Retrieved link: " + link);
|
||||||
|
Window.open(link, itemDescription.getName(), "");
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
});
|
||||||
public void onSuccess(String link) {
|
}
|
||||||
Log.debug("Retrieved link: " + link);
|
|
||||||
Window.open(link, itemDescription.getName(), "");
|
|
||||||
}
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
UtilsGXT3.info("Attention", "Select a file!");
|
UtilsGXT3.info("Attention", "Select a file!");
|
||||||
|
|
|
@ -1,67 +1,113 @@
|
||||||
package org.gcube.portlets.user.dataminermanager.server;
|
package org.gcube.portlets.user.dataminermanager.server;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileInputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.io.OutputStream;
|
||||||
|
|
||||||
import javax.servlet.ServletException;
|
import javax.servlet.ServletException;
|
||||||
import javax.servlet.annotation.WebServlet;
|
|
||||||
import javax.servlet.http.HttpServlet;
|
import javax.servlet.http.HttpServlet;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
import javax.servlet.http.HttpSession;
|
||||||
|
|
||||||
|
import org.apache.commons.io.IOUtils;
|
||||||
|
import org.gcube.application.framework.core.session.ASLSession;
|
||||||
|
import org.gcube.portlets.user.dataminermanager.server.storage.StorageUtil;
|
||||||
|
import org.gcube.portlets.user.dataminermanager.shared.Constants;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* DownloadFolder Servlet
|
*
|
||||||
|
* @author Giancarlo Panichi
|
||||||
|
* email: <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||||
|
*
|
||||||
|
* Download Folder Servlet
|
||||||
|
*
|
||||||
*/
|
*/
|
||||||
@WebServlet("/DownloadFolderServlet")
|
|
||||||
public class DownloadFolderServlet extends HttpServlet {
|
public class DownloadFolderServlet extends HttpServlet {
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = -1838255772767180518L;
|
||||||
|
private static Logger logger = LoggerFactory
|
||||||
/**
|
.getLogger(DownloadFolderServlet.class);
|
||||||
* @see HttpServlet#HttpServlet()
|
|
||||||
*/
|
|
||||||
public DownloadFolderServlet() {
|
|
||||||
super();
|
|
||||||
// TODO Auto-generated constructor stub
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
|
* @see HttpServlet#HttpServlet()
|
||||||
*/
|
*/
|
||||||
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
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);
|
createResponse(request, response);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
|
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse
|
||||||
|
* response)
|
||||||
*/
|
*/
|
||||||
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
protected void doPost(HttpServletRequest request,
|
||||||
|
HttpServletResponse response) throws ServletException, IOException {
|
||||||
createResponse(request, response);
|
createResponse(request, response);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void createResponse(HttpServletRequest request,
|
||||||
|
HttpServletResponse response) throws ServletException, IOException {
|
||||||
|
try {
|
||||||
|
logger.info("DownloadFolderServlet");
|
||||||
|
|
||||||
private void createResponse(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException{
|
HttpSession session = request.getSession();
|
||||||
/*try {
|
|
||||||
|
|
||||||
request.getParameter("c")
|
if (session == null) {
|
||||||
|
logger.error("Error getting the 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.debug("DownloadFolderServlet session id: " + session.getId());
|
||||||
|
|
||||||
File tmpZip = ZipUtil.zipFolder((WorkspaceFolder) item);
|
ASLSession aslSession = SessionUtil.getASLSession(session);
|
||||||
resp.setHeader( "Content-Disposition", "attachment; filename=\"" + item.getName() + ".zip\"" );
|
|
||||||
resp.setContentType("application/zip");
|
String itemId = request.getParameter(Constants.DOWNLOAD_FOLDER_SERVLET_ITEM_ID_PARAMETER);
|
||||||
resp = setContentLength(resp, tmpZip.length());
|
String folderName = request.getParameter(Constants.DOWNLOAD_FOLDER_SERVLET_FOLDER_NAME_PARAMETER);
|
||||||
OutputStream out = resp.getOutputStream();
|
logger.debug("Request: [itemId=" + itemId + ", folderName="
|
||||||
|
+ folderName + "]");
|
||||||
|
|
||||||
|
File tmpZip = StorageUtil.zipFolder(aslSession.getUsername(),
|
||||||
|
itemId);
|
||||||
|
response.setHeader("Content-Disposition", "attachment; filename=\""
|
||||||
|
+ folderName + ".zip\"");
|
||||||
|
response.setContentType("application/zip");
|
||||||
|
response.setHeader("Content-Length",
|
||||||
|
String.valueOf(tmpZip.length()));
|
||||||
|
|
||||||
|
OutputStream out = response.getOutputStream();
|
||||||
|
|
||||||
FileInputStream fileTmpZip = new FileInputStream(tmpZip);
|
FileInputStream fileTmpZip = new FileInputStream(tmpZip);
|
||||||
IOUtils.copy(fileTmpZip, resp.getOutputStream());
|
IOUtils.copy(fileTmpZip, response.getOutputStream());
|
||||||
fileTmpZip.close();
|
out.flush();
|
||||||
|
|
||||||
out.close();
|
out.close();
|
||||||
|
fileTmpZip.close();
|
||||||
tmpZip.delete();
|
tmpZip.delete();
|
||||||
return;
|
return;
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Throwable e) {
|
||||||
logger.error("Error during folder compression "+itemId,e);
|
logger.error("Error in DownloadFolderServlet: "
|
||||||
handleError(urlRedirectOnError, req, resp, itemId, HttpServletResponse.SC_INTERNAL_SERVER_ERROR +": Error during folder compression: "+e.getMessage());
|
+ e.getLocalizedMessage());
|
||||||
return;
|
e.printStackTrace();
|
||||||
|
throw new ServletException("Error:"
|
||||||
|
+ e.getLocalizedMessage(), e);
|
||||||
|
|
||||||
}
|
}
|
||||||
}*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -219,10 +219,18 @@ public class StorageUtil {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public File zipFolder(String user, String folderId)
|
/**
|
||||||
|
*
|
||||||
|
* @param user
|
||||||
|
* @param folderId
|
||||||
|
* @return
|
||||||
|
* @throws ServiceException
|
||||||
|
*/
|
||||||
|
public static File zipFolder(String user, String folderId)
|
||||||
throws ServiceException {
|
throws ServiceException {
|
||||||
Workspace ws;
|
Workspace ws;
|
||||||
try {
|
try {
|
||||||
|
logger.debug("zipFolder: [user="+user+", folderId="+folderId+"]");
|
||||||
ws = HomeLibrary.getUserWorkspace(user);
|
ws = HomeLibrary.getUserWorkspace(user);
|
||||||
|
|
||||||
WorkspaceItem workSpaceItem = ws.getItem(folderId);
|
WorkspaceItem workSpaceItem = ws.getItem(folderId);
|
||||||
|
|
|
@ -51,6 +51,11 @@ public class Constants {
|
||||||
//public static final String WPSToken = "45943442-74ef-408b-be64-d26b42cf4c08 ";
|
//public static final String WPSToken = "45943442-74ef-408b-be64-d26b42cf4c08 ";
|
||||||
//public static final String WPSUser = "statistical.manager@gmail.com";
|
//public static final String WPSUser = "statistical.manager@gmail.com";
|
||||||
|
|
||||||
|
//DownloadFolderServlet
|
||||||
|
public static final String DOWNLOAD_FOLDER_SERVLET= "DownloadFolderServlet";
|
||||||
|
public static final String DOWNLOAD_FOLDER_SERVLET_ITEM_ID_PARAMETER = "itemId";
|
||||||
|
public static final String DOWNLOAD_FOLDER_SERVLET_FOLDER_NAME_PARAMETER = "folderName";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,70 +1,81 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<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">
|
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
<servlet>
|
xmlns="http://java.sun.com/xml/ns/javaee"
|
||||||
<servlet-name>DataMinerManagerServlet</servlet-name>
|
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
|
||||||
<servlet-class>org.gcube.portlets.user.dataminermanager.server.DataMinerManagerServiceImpl</servlet-class>
|
version="3.0">
|
||||||
</servlet>
|
<servlet>
|
||||||
<servlet>
|
<servlet-name>DataMinerManagerServlet</servlet-name>
|
||||||
<servlet-name>jUnitHostImpl</servlet-name>
|
<servlet-class>org.gcube.portlets.user.dataminermanager.server.DataMinerManagerServiceImpl</servlet-class>
|
||||||
<servlet-class>com.google.gwt.junit.server.JUnitHostImpl</servlet-class>
|
</servlet>
|
||||||
</servlet>
|
<servlet>
|
||||||
<servlet>
|
<servlet-name>jUnitHostImpl</servlet-name>
|
||||||
<servlet-name>DownloadService</servlet-name>
|
<servlet-class>com.google.gwt.junit.server.JUnitHostImpl</servlet-class>
|
||||||
<servlet-class>org.gcube.portlets.user.dataminermanager.server.DownloadServlet</servlet-class>
|
</servlet>
|
||||||
</servlet>
|
<servlet>
|
||||||
<servlet>
|
<servlet-name>DownloadService</servlet-name>
|
||||||
<servlet-name>workspaceExplorer</servlet-name>
|
<servlet-class>org.gcube.portlets.user.dataminermanager.server.DownloadServlet</servlet-class>
|
||||||
<servlet-class>org.gcube.portlets.widgets.wsexplorer.server.WorkspaceExplorerServiceImpl</servlet-class>
|
</servlet>
|
||||||
</servlet>
|
<servlet>
|
||||||
<servlet>
|
<servlet-name>DownloadFolderServlet</servlet-name>
|
||||||
<servlet-name>workspaceUploaderService</servlet-name>
|
<servlet-class>org.gcube.portlets.user.dataminermanager.server.DownloadFolderServlet</servlet-class>
|
||||||
<servlet-class>org.gcube.portlets.widgets.workspaceuploader.server.WorkspaceUploaderServiceImpl</servlet-class>
|
</servlet>
|
||||||
</servlet>
|
<servlet>
|
||||||
<servlet>
|
<servlet-name>workspaceExplorer</servlet-name>
|
||||||
<servlet-name>workspaceUploadServletStream</servlet-name>
|
<servlet-class>org.gcube.portlets.widgets.wsexplorer.server.WorkspaceExplorerServiceImpl</servlet-class>
|
||||||
<servlet-class>org.gcube.portlets.widgets.workspaceuploader.server.WorkspaceUploadServletStream</servlet-class>
|
</servlet>
|
||||||
</servlet>
|
<servlet>
|
||||||
<servlet>
|
<servlet-name>workspaceUploaderService</servlet-name>
|
||||||
<servlet-name>checkServlet</servlet-name>
|
<servlet-class>org.gcube.portlets.widgets.workspaceuploader.server.WorkspaceUploaderServiceImpl</servlet-class>
|
||||||
<servlet-class>org.gcube.portlets.widgets.sessionchecker.server.SessionCheckerServiceImpl</servlet-class>
|
</servlet>
|
||||||
</servlet>
|
<servlet>
|
||||||
<servlet>
|
<servlet-name>workspaceUploadServletStream</servlet-name>
|
||||||
<servlet-name>scopeService</servlet-name>
|
<servlet-class>org.gcube.portlets.widgets.workspaceuploader.server.WorkspaceUploadServletStream</servlet-class>
|
||||||
<servlet-class>org.gcube.portlets.user.gcubewidgets.server.ScopeServiceImpl</servlet-class>
|
</servlet>
|
||||||
</servlet>
|
<servlet>
|
||||||
<servlet-mapping>
|
<servlet-name>checkServlet</servlet-name>
|
||||||
<servlet-name>DataMinerManagerServlet</servlet-name>
|
<servlet-class>org.gcube.portlets.widgets.sessionchecker.server.SessionCheckerServiceImpl</servlet-class>
|
||||||
<url-pattern>/dataminermanager/dataminerman</url-pattern>
|
</servlet>
|
||||||
</servlet-mapping>
|
<servlet>
|
||||||
<servlet-mapping>
|
<servlet-name>scopeService</servlet-name>
|
||||||
<servlet-name>jUnitHostImpl</servlet-name>
|
<servlet-class>org.gcube.portlets.user.gcubewidgets.server.ScopeServiceImpl</servlet-class>
|
||||||
<url-pattern>/dataminermanager/junithost/*</url-pattern>
|
</servlet>
|
||||||
</servlet-mapping>
|
<servlet-mapping>
|
||||||
<servlet-mapping>
|
<servlet-name>DataMinerManagerServlet</servlet-name>
|
||||||
<servlet-name>DownloadService</servlet-name>
|
<url-pattern>/dataminermanager/dataminerman</url-pattern>
|
||||||
<url-pattern>/dataminermanager/DownloadService</url-pattern>
|
</servlet-mapping>
|
||||||
</servlet-mapping>
|
<servlet-mapping>
|
||||||
<servlet-mapping>
|
<servlet-name>jUnitHostImpl</servlet-name>
|
||||||
<servlet-name>workspaceExplorer</servlet-name>
|
<url-pattern>/dataminermanager/junithost/*</url-pattern>
|
||||||
<url-pattern>/dataminermanager/WorkspaceExplorerService</url-pattern>
|
</servlet-mapping>
|
||||||
</servlet-mapping>
|
<servlet-mapping>
|
||||||
<servlet-mapping>
|
<servlet-name>DownloadService</servlet-name>
|
||||||
<servlet-name>workspaceUploaderService</servlet-name>
|
<url-pattern>/dataminermanager/DownloadService</url-pattern>
|
||||||
<url-pattern>/dataminermanager/workspaceUploaderService</url-pattern>
|
</servlet-mapping>
|
||||||
</servlet-mapping>
|
<servlet-mapping>
|
||||||
<servlet-mapping>
|
<servlet-name>DownloadFolderServlet</servlet-name>
|
||||||
<servlet-name>workspaceUploadServletStream</servlet-name>
|
<url-pattern>/dataminermanager/DownloadFolderServlet</url-pattern>
|
||||||
<url-pattern>/dataminermanager/workspaceUploadServletStream</url-pattern>
|
</servlet-mapping>
|
||||||
</servlet-mapping>
|
<servlet-mapping>
|
||||||
<servlet-mapping>
|
<servlet-name>workspaceExplorer</servlet-name>
|
||||||
<servlet-name>checkServlet</servlet-name>
|
<url-pattern>/dataminermanager/WorkspaceExplorerService</url-pattern>
|
||||||
<url-pattern>/dataminermanager/checksession</url-pattern>
|
</servlet-mapping>
|
||||||
</servlet-mapping>
|
<servlet-mapping>
|
||||||
<servlet-mapping>
|
<servlet-name>workspaceUploaderService</servlet-name>
|
||||||
<servlet-name>scopeService</servlet-name>
|
<url-pattern>/dataminermanager/workspaceUploaderService</url-pattern>
|
||||||
<url-pattern>/dataminermanager/scopeService</url-pattern>
|
</servlet-mapping>
|
||||||
</servlet-mapping>
|
<servlet-mapping>
|
||||||
<welcome-file-list>
|
<servlet-name>workspaceUploadServletStream</servlet-name>
|
||||||
<welcome-file>DataMinerManager.html</welcome-file>
|
<url-pattern>/dataminermanager/workspaceUploadServletStream</url-pattern>
|
||||||
</welcome-file-list>
|
</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>
|
</web-app>
|
Loading…
Reference in New Issue