fixed #1333
updated pom version at 1.1.0 updated distro files git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/widgets/workspace-uploader@122155 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
91deff581b
commit
05e4751a71
|
@ -16,7 +16,7 @@ Authors
|
||||||
Version and Release Date
|
Version and Release Date
|
||||||
------------------------
|
------------------------
|
||||||
|
|
||||||
v. 1.0.1 December 2015
|
v. 1.1.0 January 2016
|
||||||
|
|
||||||
|
|
||||||
Description
|
Description
|
||||||
|
|
|
@ -1,4 +1,8 @@
|
||||||
<ReleaseNotes>
|
<ReleaseNotes>
|
||||||
|
<Changeset component="org.gcube.portlets-widgets.workspace-uploader.1-1-0"
|
||||||
|
date="2016-01-08">
|
||||||
|
<Change>Bug Fixed #1333</Change>
|
||||||
|
</Changeset>
|
||||||
<Changeset component="org.gcube.portlets-widgets.workspace-uploader.1-0-1"
|
<Changeset component="org.gcube.portlets-widgets.workspace-uploader.1-0-1"
|
||||||
date="2015-12-16">
|
date="2015-12-16">
|
||||||
<Change>Bug Fixed - https://support.d4science.org/issues/1824</Change>
|
<Change>Bug Fixed - https://support.d4science.org/issues/1824</Change>
|
||||||
|
|
2
pom.xml
2
pom.xml
|
@ -12,7 +12,7 @@
|
||||||
<groupId>org.gcube.portlets.widgets</groupId>
|
<groupId>org.gcube.portlets.widgets</groupId>
|
||||||
<artifactId>workspace-uploader</artifactId>
|
<artifactId>workspace-uploader</artifactId>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
<version>1.0.1-SNAPSHOT</version>
|
<version>1.1.0-SNAPSHOT</version>
|
||||||
<name>Workspace Uploader Widget</name>
|
<name>Workspace Uploader Widget</name>
|
||||||
<scm>
|
<scm>
|
||||||
<connection>scm:svn:http://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/widgets/${project.artifactId}</connection>
|
<connection>scm:svn:http://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/widgets/${project.artifactId}</connection>
|
||||||
|
|
|
@ -17,6 +17,7 @@ public class ConstantsWorkspaceUploader {
|
||||||
|
|
||||||
public static final String WORKSPACE_UPLOADER_SERVICE = GWT.getModuleBaseURL() + "workspaceUploaderService";
|
public static final String WORKSPACE_UPLOADER_SERVICE = GWT.getModuleBaseURL() + "workspaceUploaderService";
|
||||||
|
|
||||||
|
public static final String WORKSPACE_UPLOADER_WS_UTIL = GWT.getModuleBaseURL() + "workspaceUploaderWsUtil";
|
||||||
|
|
||||||
public static final String SERVER_ERROR = "Sorry, an error has occurred on the server when";
|
public static final String SERVER_ERROR = "Sorry, an error has occurred on the server when";
|
||||||
public static final String TRY_AGAIN = "Try again";
|
public static final String TRY_AGAIN = "Try again";
|
||||||
|
@ -34,4 +35,8 @@ public class ConstantsWorkspaceUploader {
|
||||||
public static final String MY_UPLOADS = "My Uploads";
|
public static final String MY_UPLOADS = "My Uploads";
|
||||||
|
|
||||||
public static final int LIMIT_UPLOADS = 50;
|
public static final int LIMIT_UPLOADS = 50;
|
||||||
|
|
||||||
|
|
||||||
|
public static final String FOLDER_PARENT_ID = "FOLDER_PARENT_ID";
|
||||||
|
public static final String ITEM_NAME = "ITEM_NAME";
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,8 +37,6 @@ public class WorkspaceUploader implements EntryPoint {
|
||||||
.inject();
|
.inject();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// ScriptInjector.fromUrl("http://ajax.googleapis.com/ajax/libs/jquery/1.8.1/jquery.min.js")
|
// ScriptInjector.fromUrl("http://ajax.googleapis.com/ajax/libs/jquery/1.8.1/jquery.min.js")
|
||||||
// .setWindow(ScriptInjector.TOP_WINDOW)
|
// .setWindow(ScriptInjector.TOP_WINDOW)
|
||||||
// .inject();
|
// .inject();
|
||||||
|
@ -69,18 +67,6 @@ public class WorkspaceUploader implements EntryPoint {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
// buttonUploader.addClickHandler(new ClickHandler() {
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public void onClick(ClickEvent event) {
|
|
||||||
// DialogUpload uploader = new DialogUpload(headerTitle, parentId, UPLOAD_TYPE.File);
|
|
||||||
// uploader.center();
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
buttonDirect.addClickHandler(new ClickHandler() {
|
buttonDirect.addClickHandler(new ClickHandler() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -107,19 +93,6 @@ public class WorkspaceUploader implements EntryPoint {
|
||||||
});
|
});
|
||||||
|
|
||||||
RootPanel.get("workspace-uploader").add(dnd);
|
RootPanel.get("workspace-uploader").add(dnd);
|
||||||
|
|
||||||
|
|
||||||
// Scheduler.get().scheduleDeferred(new ScheduledCommand() {
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public void execute() {
|
|
||||||
// dnd.initFileReader();
|
|
||||||
//
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
|
|
||||||
|
|
||||||
// RootPanel.get("workspace-uploader").add(buttonUploader);
|
|
||||||
RootPanel.get("workspace-uploader").add(buttonDirect);
|
RootPanel.get("workspace-uploader").add(buttonDirect);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -36,6 +36,10 @@ public class MultipleDNDUpload extends LayoutPanel implements
|
||||||
// private String jsonKeys;
|
// private String jsonKeys;
|
||||||
private String servlet = ConstantsWorkspaceUploader.WORKSPACE_UPLOADER_SERVLET_STREAM;
|
private String servlet = ConstantsWorkspaceUploader.WORKSPACE_UPLOADER_SERVLET_STREAM;
|
||||||
private String service = ConstantsWorkspaceUploader.WORKSPACE_UPLOADER_SERVICE;
|
private String service = ConstantsWorkspaceUploader.WORKSPACE_UPLOADER_SERVICE;
|
||||||
|
private String workspaceUtil = ConstantsWorkspaceUploader.WORKSPACE_UPLOADER_WS_UTIL;
|
||||||
|
|
||||||
|
private String folder_parent_id = ConstantsWorkspaceUploader.FOLDER_PARENT_ID;
|
||||||
|
private String item_name = ConstantsWorkspaceUploader.ITEM_NAME;
|
||||||
|
|
||||||
public static final String FILE_DELEMITER = ";";
|
public static final String FILE_DELEMITER = ";";
|
||||||
private Widget onlyChild;
|
private Widget onlyChild;
|
||||||
|
@ -304,6 +308,20 @@ public class MultipleDNDUpload extends LayoutPanel implements
|
||||||
|
|
||||||
console.log("initW3CFileReader");
|
console.log("initW3CFileReader");
|
||||||
|
|
||||||
|
function makeSyncAjaxCall(url, params, msgText, conType){
|
||||||
|
var xhReq = new XMLHttpRequest();
|
||||||
|
xhReq.open(conType, url+"?"+params, false);
|
||||||
|
if (conType == "POST")
|
||||||
|
xhReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
|
||||||
|
|
||||||
|
xhReq.send(msgText);
|
||||||
|
if(xhReq.status==200){
|
||||||
|
console.log(xhReq.responseText);
|
||||||
|
return xhReq.responseText;
|
||||||
|
}else
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
function generateUUID() {
|
function generateUUID() {
|
||||||
var d = new Date().getTime();
|
var d = new Date().getTime();
|
||||||
var uuid = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g,
|
var uuid = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g,
|
||||||
|
@ -512,29 +530,17 @@ public class MultipleDNDUpload extends LayoutPanel implements
|
||||||
var filesSelected = files[i].name + fileDelimiter;
|
var filesSelected = files[i].name + fileDelimiter;
|
||||||
if (!isFolder(file)) {
|
if (!isFolder(file)) {
|
||||||
|
|
||||||
|
|
||||||
console.log("filesSelected: " + filesSelected);
|
console.log("filesSelected: " + filesSelected);
|
||||||
|
|
||||||
// var files = filese
|
|
||||||
// var files = filesSelected.split(fileDelimiter);
|
|
||||||
console.log("files: " + files);
|
console.log("files: " + files);
|
||||||
|
|
||||||
instance.@org.gcube.portlets.widgets.workspaceuploader.client.uploader.dragdrop.MultipleDNDUpload::generateFakeUploaders(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)(filesSelected,idfolder,uploadUUID);
|
instance.@org.gcube.portlets.widgets.workspaceuploader.client.uploader.dragdrop.MultipleDNDUpload::generateFakeUploaders(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)(filesSelected,idfolder,uploadUUID);
|
||||||
|
|
||||||
instance.@org.gcube.portlets.widgets.workspaceuploader.client.uploader.dragdrop.MultipleDNDUpload::createJsonKeyForFiles(Ljava/lang/String;)(uploadUUID);
|
instance.@org.gcube.portlets.widgets.workspaceuploader.client.uploader.dragdrop.MultipleDNDUpload::createJsonKeyForFiles(Ljava/lang/String;)(uploadUUID);
|
||||||
|
|
||||||
instance.@org.gcube.portlets.widgets.workspaceuploader.client.uploader.dragdrop.MultipleDNDUpload::updateJsonKeys(Ljava/lang/String;)(uploadUUID);
|
instance.@org.gcube.portlets.widgets.workspaceuploader.client.uploader.dragdrop.MultipleDNDUpload::updateJsonKeys(Ljava/lang/String;)(uploadUUID);
|
||||||
|
|
||||||
var jsonKeysMap = instance.@org.gcube.portlets.widgets.workspaceuploader.client.uploader.dragdrop.MultipleDNDUpload::jsonKeys;
|
var jsonKeysMap = instance.@org.gcube.portlets.widgets.workspaceuploader.client.uploader.dragdrop.MultipleDNDUpload::jsonKeys;
|
||||||
|
|
||||||
console.log("jsonKeysMap: " + jsonKeysMap);
|
console.log("jsonKeysMap: " + jsonKeysMap);
|
||||||
|
|
||||||
instance.@org.gcube.portlets.widgets.workspaceuploader.client.uploader.dragdrop.MultipleDNDUpload::setCurrentJsonKeValue(Ljava/lang/String;)(uploadUUID);
|
instance.@org.gcube.portlets.widgets.workspaceuploader.client.uploader.dragdrop.MultipleDNDUpload::setCurrentJsonKeValue(Ljava/lang/String;)(uploadUUID);
|
||||||
|
|
||||||
var keyVal = instance.@org.gcube.portlets.widgets.workspaceuploader.client.uploader.dragdrop.MultipleDNDUpload::currentJsonKey;
|
var keyVal = instance.@org.gcube.portlets.widgets.workspaceuploader.client.uploader.dragdrop.MultipleDNDUpload::currentJsonKey;
|
||||||
|
|
||||||
console.log("keyVal: " + keyVal);
|
console.log("keyVal: " + keyVal);
|
||||||
|
|
||||||
var xhr = new XMLHttpRequest();
|
var xhr = new XMLHttpRequest();
|
||||||
// var upload = xhr.upload;
|
// var upload = xhr.upload;
|
||||||
|
|
||||||
|
@ -558,24 +564,37 @@ public class MultipleDNDUpload extends LayoutPanel implements
|
||||||
// Use native function(Chrome 5+ ,Safari 5+ and Firefox 4+), for dealing
|
// Use native function(Chrome 5+ ,Safari 5+ and Firefox 4+), for dealing
|
||||||
// with multipart/form-data and boundray generation
|
// with multipart/form-data and boundray generation
|
||||||
|
|
||||||
var formdata = new FormData(); // see
|
var formdata = new FormData();
|
||||||
// https://developer.mozilla.org/En/XMLHttpRequest/Using_XMLHttpRequest#Using_FormData_objects
|
|
||||||
// 'file' can be any string which you would like to associte with
|
|
||||||
// uploaded file even for example file.type eg:
|
|
||||||
// formdata.append(file.type, file);
|
|
||||||
// formdata.append(file.fileName, file);
|
|
||||||
|
|
||||||
formdata.append("isOverwrite", "false");
|
|
||||||
|
|
||||||
// $wnd.exportCreateJsonKeyForFiles();
|
|
||||||
//
|
|
||||||
// $wnd.exportAddNewSubmitToMonitor();
|
|
||||||
|
|
||||||
formdata.append("client_upload_keys", keyVal);
|
formdata.append("client_upload_keys", keyVal);
|
||||||
formdata.append("uploadType", uploadType);
|
formdata.append("uploadType", uploadType);
|
||||||
formdata.append("idFolder", idfolder);
|
formdata.append("idFolder", idfolder);
|
||||||
formdata.append('uploadFormElement', file);
|
//OVERWRITE??
|
||||||
|
var overwrite = false;
|
||||||
|
if(files.length == 1){
|
||||||
|
console.log("one drag, overwrite?");
|
||||||
|
var wsUtil = instance.@org.gcube.portlets.widgets.workspaceuploader.client.uploader.dragdrop.MultipleDNDUpload::workspaceUtil;
|
||||||
|
var folder_parent_id = instance.@org.gcube.portlets.widgets.workspaceuploader.client.uploader.dragdrop.MultipleDNDUpload::folder_parent_id;
|
||||||
|
var item_name = instance.@org.gcube.portlets.widgets.workspaceuploader.client.uploader.dragdrop.MultipleDNDUpload::item_name;
|
||||||
|
console.log("item_name: " + item_name);
|
||||||
|
var params = folder_parent_id+"="+idfolder+"&"+item_name+"="+files[i].name
|
||||||
|
console.log("params: " + params);
|
||||||
|
var response = makeSyncAjaxCall(wsUtil, params, "", "GET");
|
||||||
|
console.log("response: " + response);
|
||||||
|
if(response!=null && response!=undefined){
|
||||||
|
console.log("overwrite confirm?");
|
||||||
|
if($wnd.confirm(files[i].name+" exists in folder. Overwrite?")){
|
||||||
|
overwrite = true;
|
||||||
|
console.log("overwrite confirmed!");
|
||||||
|
}else{
|
||||||
|
instance.@org.gcube.portlets.widgets.workspaceuploader.client.uploader.dragdrop.MultipleDNDUpload::reset()();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
formdata.append("isOverwrite", overwrite);
|
||||||
|
//*********uploadFormElement MUST BE THE LAST!!!
|
||||||
|
formdata.append('uploadFormElement', file);
|
||||||
xhr.send(formdata);
|
xhr.send(formdata);
|
||||||
instance.@org.gcube.portlets.widgets.workspaceuploader.client.uploader.dragdrop.MultipleDNDUpload::addNewSubmitToMonitor(Ljava/lang/String;)(uploadUUID);
|
instance.@org.gcube.portlets.widgets.workspaceuploader.client.uploader.dragdrop.MultipleDNDUpload::addNewSubmitToMonitor(Ljava/lang/String;)(uploadUUID);
|
||||||
|
|
||||||
|
@ -609,7 +628,12 @@ public class MultipleDNDUpload extends LayoutPanel implements
|
||||||
}
|
}
|
||||||
}-*/;
|
}-*/;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test.
|
||||||
|
*
|
||||||
|
* @param parentIdentifier the parent identifier
|
||||||
|
* @param name the name
|
||||||
|
*/
|
||||||
public static native void test(String parentIdentifier, String name)/*-{
|
public static native void test(String parentIdentifier, String name)/*-{
|
||||||
var servlet = instance.@org.gcube.portlets.widgets.workspaceuploader.client.uploader.dragdrop.MultipleDNDUpload::service;
|
var servlet = instance.@org.gcube.portlets.widgets.workspaceuploader.client.uploader.dragdrop.MultipleDNDUpload::service;
|
||||||
|
|
||||||
|
|
|
@ -212,7 +212,7 @@ public class WorkspaceUploadServletStream extends HttpServlet implements Servlet
|
||||||
removeListenersIfDone(session, listClientUploadKeys);
|
removeListenersIfDone(session, listClientUploadKeys);
|
||||||
for (String clientUploadKey : listClientUploadKeys) {
|
for (String clientUploadKey : listClientUploadKeys) {
|
||||||
String fileName = mapKeys.get(clientUploadKey);
|
String fileName = mapKeys.get(clientUploadKey);
|
||||||
WorkspaceUploaderItem workspaceUploader = createNewWorkspaceUploader(clientUploadKey,destinationId,mapKeys.get(clientUploadKey));
|
WorkspaceUploaderItem workspaceUploader = createNewWorkspaceUploader(clientUploadKey,destinationId,mapKeys.get(clientUploadKey),isOverwrite);
|
||||||
logger.debug("created "+workspaceUploader);
|
logger.debug("created "+workspaceUploader);
|
||||||
saveWorkspaceUploaderStatus(workspaceUploader, UPLOAD_STATUS.WAIT, "Uploading "+fileName+" at 0%", request.getSession());
|
saveWorkspaceUploaderStatus(workspaceUploader, UPLOAD_STATUS.WAIT, "Uploading "+fileName+" at 0%", request.getSession());
|
||||||
}
|
}
|
||||||
|
@ -544,13 +544,14 @@ public class WorkspaceUploadServletStream extends HttpServlet implements Servlet
|
||||||
* @param fileName the file name
|
* @param fileName the file name
|
||||||
* @return the workspace uploader item
|
* @return the workspace uploader item
|
||||||
*/
|
*/
|
||||||
private WorkspaceUploaderItem createNewWorkspaceUploader(String clientUploadKey, String folderParentId, String fileName){
|
private WorkspaceUploaderItem createNewWorkspaceUploader(String clientUploadKey, String folderParentId, String fileName, boolean isOverwrite){
|
||||||
//CLIENT UPLOAD IS THE KEY
|
//CLIENT UPLOAD IS THE KEY
|
||||||
WorkspaceUploaderItem workspaceUploader = new WorkspaceUploaderItem(clientUploadKey);
|
WorkspaceUploaderItem workspaceUploader = new WorkspaceUploaderItem(clientUploadKey);
|
||||||
workspaceUploader.setClientUploadKey(clientUploadKey);
|
workspaceUploader.setClientUploadKey(clientUploadKey);
|
||||||
//Create File
|
//Create File
|
||||||
WorkspaceUploadFile wsUploadFile = new WorkspaceUploadFile(folderParentId, null, fileName);
|
WorkspaceUploadFile wsUploadFile = new WorkspaceUploadFile(folderParentId, null, fileName);
|
||||||
workspaceUploader.setFile(wsUploadFile);
|
workspaceUploader.setFile(wsUploadFile);
|
||||||
|
workspaceUploader.setIsOverwrite(isOverwrite);
|
||||||
return workspaceUploader;
|
return workspaceUploader;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,137 @@
|
||||||
|
package org.gcube.portlets.widgets.workspaceuploader.server;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
import javax.servlet.ServletException;
|
||||||
|
import javax.servlet.http.HttpServlet;
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
import javax.servlet.http.HttpSession;
|
||||||
|
|
||||||
|
import org.gcube.common.homelibary.model.items.type.WorkspaceItemType;
|
||||||
|
import org.gcube.common.homelibrary.home.workspace.Workspace;
|
||||||
|
import org.gcube.common.homelibrary.home.workspace.WorkspaceItem;
|
||||||
|
import org.gcube.portlets.widgets.workspaceuploader.client.ConstantsWorkspaceUploader;
|
||||||
|
import org.gcube.portlets.widgets.workspaceuploader.server.util.WsUtil;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The server side implementation of the RPC service.
|
||||||
|
*
|
||||||
|
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
||||||
|
* Jan 7, 2016
|
||||||
|
*/
|
||||||
|
@SuppressWarnings("serial")
|
||||||
|
public class WorkspaceUploaderWsUtil extends HttpServlet {
|
||||||
|
|
||||||
|
public static Logger logger = LoggerFactory.getLogger(WorkspaceUploaderWsUtil.class);
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see javax.servlet.http.HttpServlet#doGet(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
protected void doGet(HttpServletRequest req, HttpServletResponse resp)
|
||||||
|
throws ServletException, IOException {
|
||||||
|
String folderParentId = req.getParameter(ConstantsWorkspaceUploader.FOLDER_PARENT_ID);
|
||||||
|
String itemName = req.getParameter(ConstantsWorkspaceUploader.ITEM_NAME);
|
||||||
|
logger.debug("folderParentId: "+folderParentId);
|
||||||
|
logger.debug("itemName: "+itemName);
|
||||||
|
try {
|
||||||
|
String itemId = itemExistsInWorkpaceFolder(req, folderParentId, itemName);
|
||||||
|
sendOKMessage(resp, itemId);
|
||||||
|
}
|
||||||
|
catch (Exception e) {
|
||||||
|
logger.error("An error occurred during item exists check",e);
|
||||||
|
sendError(resp, "An error occurred during item exists check");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.gcube.portlets.user.workspace.client.rpc.GWTWorkspaceService#itemExistsInWorkpaceFolder(java.lang.String, java.lang.String)
|
||||||
|
*/
|
||||||
|
//@Override
|
||||||
|
/**
|
||||||
|
* Item exists in workpace folder.
|
||||||
|
*
|
||||||
|
* @param req the req
|
||||||
|
* @param parentId the parent id
|
||||||
|
* @param itemName the item name
|
||||||
|
* @return the string
|
||||||
|
* @throws Exception the exception
|
||||||
|
*/
|
||||||
|
public String itemExistsInWorkpaceFolder(HttpServletRequest req, String parentId, String itemName) throws Exception {
|
||||||
|
logger.trace("get itemExistsInWorkpace for name: "+itemName+", by parentId: "+parentId);
|
||||||
|
try {
|
||||||
|
HttpSession session = req.getSession();
|
||||||
|
Workspace workspace = WsUtil.getWorkspace(session);
|
||||||
|
WorkspaceItem wsItem = workspace.getItem(parentId); //GET PARENT
|
||||||
|
|
||||||
|
if(wsItem.getType().equals(WorkspaceItemType.FOLDER) || wsItem.getType().equals(WorkspaceItemType.SHARED_FOLDER)){
|
||||||
|
WorkspaceItem itemFound = workspace.find(itemName, parentId);
|
||||||
|
if(itemFound==null){
|
||||||
|
logger.trace("item: "+itemName+", not exists in parentId: "+parentId);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
logger.trace("item: "+itemName+", exists in parentId: "+parentId +", returning id:" +itemFound.getId());
|
||||||
|
return itemFound.getId();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
throw new Exception("Invalid Folder parent");
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
String error = "Sorry an error occurred when searching item id, please refresh and try again";
|
||||||
|
logger.error(error, e);
|
||||||
|
throw new Exception(e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Send error.
|
||||||
|
*
|
||||||
|
* @param response the response
|
||||||
|
* @param message the message
|
||||||
|
* @throws IOException Signals that an I/O exception has occurred.
|
||||||
|
*/
|
||||||
|
protected void sendError(HttpServletResponse response, String message) throws IOException{
|
||||||
|
try {
|
||||||
|
response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
|
||||||
|
response.getWriter().write(message);
|
||||||
|
//5.6 Closure of Response Object:
|
||||||
|
//When a response is closed, the container must immediately flush all remaining content in the response buffer to the client
|
||||||
|
// response.flushBuffer();
|
||||||
|
} catch (IOException e){
|
||||||
|
logger.warn("IOException class name: "+e.getClass().getSimpleName());
|
||||||
|
if (e.getClass().getSimpleName().equals("ClientAbortException"))
|
||||||
|
logger.warn("Skipping ClientAbortException: "+e.getMessage());
|
||||||
|
else
|
||||||
|
throw e; //Sending Exceptions
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Send message.
|
||||||
|
*
|
||||||
|
* @param response the response
|
||||||
|
* @param message the message
|
||||||
|
* @throws IOException Signals that an I/O exception has occurred.
|
||||||
|
*/
|
||||||
|
protected void sendOKMessage(HttpServletResponse response, String message) throws IOException{
|
||||||
|
try {
|
||||||
|
response.setStatus(HttpServletResponse.SC_OK);
|
||||||
|
response.getWriter().write(message);
|
||||||
|
//5.6 Closure of Response Object:
|
||||||
|
//When a response is closed, the container must immediately flush all remaining content in the response buffer to the client
|
||||||
|
// response.flushBuffer();
|
||||||
|
} catch (IOException e){
|
||||||
|
logger.warn("IOException class name: "+e.getClass().getSimpleName());
|
||||||
|
if (e.getClass().getSimpleName().equals("ClientAbortException"))
|
||||||
|
logger.warn("Skipping ClientAbortException: "+e.getMessage());
|
||||||
|
else
|
||||||
|
throw e; //Sending Exceptions
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -17,13 +17,18 @@
|
||||||
<servlet-class>org.gcube.portlets.widgets.workspaceuploader.server.WorkspaceUploadServlet</servlet-class>
|
<servlet-class>org.gcube.portlets.widgets.workspaceuploader.server.WorkspaceUploadServlet</servlet-class>
|
||||||
</servlet>
|
</servlet>
|
||||||
|
|
||||||
|
|
||||||
<!-- Servlets -->
|
<!-- Servlets -->
|
||||||
<servlet>
|
<servlet>
|
||||||
<servlet-name>workspaceUploadServletStream</servlet-name>
|
<servlet-name>workspaceUploadServletStream</servlet-name>
|
||||||
<servlet-class>org.gcube.portlets.widgets.workspaceuploader.server.WorkspaceUploadServletStream</servlet-class>
|
<servlet-class>org.gcube.portlets.widgets.workspaceuploader.server.WorkspaceUploadServletStream</servlet-class>
|
||||||
</servlet>
|
</servlet>
|
||||||
|
|
||||||
|
<!-- Servlets -->
|
||||||
|
<servlet>
|
||||||
|
<servlet-name>workspaceUploaderWsUtil</servlet-name>
|
||||||
|
<servlet-class>org.gcube.portlets.widgets.workspaceuploader.server.WorkspaceUploaderWsUtil</servlet-class>
|
||||||
|
</servlet>
|
||||||
|
|
||||||
<servlet-mapping>
|
<servlet-mapping>
|
||||||
<servlet-name>workspaceUploaderService</servlet-name>
|
<servlet-name>workspaceUploaderService</servlet-name>
|
||||||
<url-pattern>/workspaceuploader/workspaceUploaderService</url-pattern>
|
<url-pattern>/workspaceuploader/workspaceUploaderService</url-pattern>
|
||||||
|
@ -39,6 +44,11 @@
|
||||||
<url-pattern>/workspaceuploader/workspaceUploadServletStream</url-pattern>
|
<url-pattern>/workspaceuploader/workspaceUploadServletStream</url-pattern>
|
||||||
</servlet-mapping>
|
</servlet-mapping>
|
||||||
|
|
||||||
|
<servlet-mapping>
|
||||||
|
<servlet-name>workspaceUploaderWsUtil</servlet-name>
|
||||||
|
<url-pattern>/workspaceuploader/workspaceUploaderWsUtil</url-pattern>
|
||||||
|
</servlet-mapping>
|
||||||
|
|
||||||
<!-- Default page to serve -->
|
<!-- Default page to serve -->
|
||||||
<welcome-file-list>
|
<welcome-file-list>
|
||||||
<welcome-file>workspaceuploader.html</welcome-file>
|
<welcome-file>workspaceuploader.html</welcome-file>
|
||||||
|
|
Loading…
Reference in New Issue