Added a DELAY BEFOR UPLOAD RESULT NOTIFICATION IN ORDER TO WAIT REPOSITORY SYNCHRONIZATION
Fixed isOverwrite git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/widgets/workspace-uploader@169695 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
77322c453e
commit
a571b0bca9
|
@ -43,5 +43,14 @@ public class ConstantsWorkspaceUploader {
|
||||||
public static final String FOLDER_PARENT_ID = "FOLDER_PARENT_ID";
|
public static final String FOLDER_PARENT_ID = "FOLDER_PARENT_ID";
|
||||||
public static final String ITEM_NAME = "ITEM_NAME";
|
public static final String ITEM_NAME = "ITEM_NAME";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Log.
|
||||||
|
*
|
||||||
|
* @param txt the txt
|
||||||
|
*/
|
||||||
|
public static native void jslog(String txt) /*-{
|
||||||
|
console.log(txt)
|
||||||
|
}-*/;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,6 @@ import org.gcube.portlets.widgets.workspaceuploader.client.events.NotifyUploadEv
|
||||||
|
|
||||||
import com.google.gwt.core.shared.GWT;
|
import com.google.gwt.core.shared.GWT;
|
||||||
import com.google.gwt.event.shared.HandlerManager;
|
import com.google.gwt.event.shared.HandlerManager;
|
||||||
import com.google.gwt.user.client.Timer;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -52,17 +51,7 @@ public class WorkspaceUploaderListenerController {
|
||||||
|
|
||||||
case UPLOAD_COMPLETED:
|
case UPLOAD_COMPLETED:
|
||||||
GWT.log("NotifyUploadEvent Completed");
|
GWT.log("NotifyUploadEvent Completed");
|
||||||
|
notifyUploadCompleted(notifyUploadEvent.getParentId(), notifyUploadEvent.getItemId());
|
||||||
Timer timer = new Timer() {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
|
|
||||||
notifyUploadCompleted(notifyUploadEvent.getParentId(), notifyUploadEvent.getItemId());
|
|
||||||
}
|
|
||||||
};
|
|
||||||
//THIS IS A DELAY TO WAIT REPOSITORY SYNCHRONIZATION
|
|
||||||
timer.schedule(2000);
|
|
||||||
break;
|
break;
|
||||||
case ABORTED:
|
case ABORTED:
|
||||||
GWT.log("NotifyUploadEvent Aborted");
|
GWT.log("NotifyUploadEvent Aborted");
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
*/
|
*/
|
||||||
package org.gcube.portlets.widgets.workspaceuploader.client.uploader;
|
package org.gcube.portlets.widgets.workspaceuploader.client.uploader;
|
||||||
|
|
||||||
|
import org.gcube.portlets.widgets.workspaceuploader.client.ConstantsWorkspaceUploader;
|
||||||
import org.gcube.portlets.widgets.workspaceuploader.client.WorkspaceUploaderServiceAsync;
|
import org.gcube.portlets.widgets.workspaceuploader.client.WorkspaceUploaderServiceAsync;
|
||||||
import org.gcube.portlets.widgets.workspaceuploader.shared.WorkspaceUploaderItem;
|
import org.gcube.portlets.widgets.workspaceuploader.shared.WorkspaceUploaderItem;
|
||||||
import org.gcube.portlets.widgets.workspaceuploader.shared.WorkspaceUploaderItem.UPLOAD_STATUS;
|
import org.gcube.portlets.widgets.workspaceuploader.shared.WorkspaceUploaderItem.UPLOAD_STATUS;
|
||||||
|
@ -46,7 +47,7 @@ public class TimerUpload extends Timer{
|
||||||
WorkspaceUploaderServiceAsync.Util.getInstance().getUploadStatus(workspaceUploader.getClientUploadKey(), new AsyncCallback<WorkspaceUploaderItem>() {
|
WorkspaceUploaderServiceAsync.Util.getInstance().getUploadStatus(workspaceUploader.getClientUploadKey(), new AsyncCallback<WorkspaceUploaderItem>() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess(WorkspaceUploaderItem result) {
|
public void onSuccess(final WorkspaceUploaderItem result) {
|
||||||
try{
|
try{
|
||||||
synchronized(this){
|
synchronized(this){
|
||||||
// Timer tmn = queue.get(workspaceUploader.getClientUploadKey());
|
// Timer tmn = queue.get(workspaceUploader.getClientUploadKey());
|
||||||
|
@ -60,10 +61,21 @@ public class TimerUpload extends Timer{
|
||||||
// queue.remove(workspaceUploader.getClientUploadKey());
|
// queue.remove(workspaceUploader.getClientUploadKey());
|
||||||
// monitor.deleteUploaderByClientKey(workspaceUploader.getClientUploadKey());
|
// monitor.deleteUploaderByClientKey(workspaceUploader.getClientUploadKey());
|
||||||
|
|
||||||
if(!result.getIsOverwrite())
|
ConstantsWorkspaceUploader.jslog("Upload Completed "+result.getFile().getItemId() +" name: "+result.getFile().getFileName());
|
||||||
monitor.notifyUploadCompleted(result.getFile().getParentId(), result.getFile().getItemId());
|
|
||||||
else
|
Timer timer = new Timer() {
|
||||||
monitor.notifyOverwriteCompleted(result.getFile().getParentId(), result.getFile().getItemId());
|
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
ConstantsWorkspaceUploader.jslog("Upload Completed "+result.getFile().getItemId() +" name: "+result.getFile().getFileName());
|
||||||
|
if(!result.getIsOverwrite())
|
||||||
|
monitor.notifyUploadCompleted(result.getFile().getParentId(), result.getFile().getItemId());
|
||||||
|
else
|
||||||
|
monitor.notifyOverwriteCompleted(result.getFile().getParentId(), result.getFile().getItemId());
|
||||||
|
}
|
||||||
|
};
|
||||||
|
//THIS IS A DELAY TO WAIT REPOSITORY SYNCHRONIZATION
|
||||||
|
timer.schedule(1000);
|
||||||
|
|
||||||
cancel();
|
cancel();
|
||||||
monitor.goNextUploaderAfterKey(workspaceUploader.getClientUploadKey());
|
monitor.goNextUploaderAfterKey(workspaceUploader.getClientUploadKey());
|
||||||
|
|
|
@ -523,20 +523,23 @@ public class WorkspaceUploadServletStream extends HttpServlet implements Servlet
|
||||||
inputStream.addListener(uploadProgressListener);
|
inputStream.addListener(uploadProgressListener);
|
||||||
workspaceUploader.setUploadProgress(uploadProgressListener.getUploadProgress());
|
workspaceUploader.setUploadProgress(uploadProgressListener.getUploadProgress());
|
||||||
|
|
||||||
|
|
||||||
|
//USING isOverwrite to check if the file already exists
|
||||||
|
try {
|
||||||
|
isOverwrite = storageHubWrapper.getWorkspace().exists(itemName, destinationFolder.getId());
|
||||||
|
workspaceUploader.setIsOverwrite(isOverwrite);
|
||||||
|
logger.info("The file: "+itemName+ " exists in the folder? "+isOverwrite);
|
||||||
|
saveWorkspaceUploaderInSession(workspaceUploader, request.getSession());
|
||||||
|
}catch (ItemNotFoundException | WrongItemTypeException e) {
|
||||||
|
logger.warn("Error on checking if the file: "+itemName+" exists in the folder id: "+ destinationFolder.getId());
|
||||||
|
}
|
||||||
|
|
||||||
saveWorkspaceUploaderInSession(workspaceUploader, request.getSession());
|
saveWorkspaceUploaderInSession(workspaceUploader, request.getSession());
|
||||||
|
|
||||||
String contentType = null; //It's set into HL
|
String contentType = null; //It's set into HL
|
||||||
|
|
||||||
if(uploadType.compareTo(FILE)==0) {//IS FILE UPLOAD
|
if(uploadType.compareTo(FILE)==0) {//IS FILE UPLOAD
|
||||||
|
|
||||||
try {
|
|
||||||
//USING isOverwrite to check if the file already exists
|
|
||||||
isOverwrite = storageHubWrapper.getWorkspace().exists(itemName, destinationFolder.getId());
|
|
||||||
}
|
|
||||||
catch (ItemNotFoundException | WrongItemTypeException e) {
|
|
||||||
//silent
|
|
||||||
}
|
|
||||||
|
|
||||||
workspaceUploader = WorkspaceUploaderMng.uploadFile(storageHubWrapper, user, scopeGroupId, request, workspaceUploader, request.getSession(), itemName, inputStream, destinationFolder, contentType, isOverwrite, size);
|
workspaceUploader = WorkspaceUploaderMng.uploadFile(storageHubWrapper, user, scopeGroupId, request, workspaceUploader, request.getSession(), itemName, inputStream, destinationFolder, contentType, isOverwrite, size);
|
||||||
|
|
||||||
if(workspaceUploader==null)
|
if(workspaceUploader==null)
|
||||||
|
|
Loading…
Reference in New Issue