Fixed enhancements: Workspace: integration of Progress Bar Widget for File Uploads
git-svn-id: http://svn.d4science-ii.research-infrastructures.eu/gcube/trunk/portlets/user/workspace-tree-widget@90305 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
ebae3cc0bc
commit
a6690e4f5c
7
pom.xml
7
pom.xml
|
@ -137,6 +137,13 @@
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<!-- FILE UPLOAD-progress-bar -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.gcube.portlets.widgets</groupId>
|
||||||
|
<artifactId>fileupload-progress-bar</artifactId>
|
||||||
|
<version>[1.0.0-SNAPSHOT, 2.0.0-SNAPSHOT)</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>commons-fileupload</groupId>
|
<groupId>commons-fileupload</groupId>
|
||||||
<artifactId>commons-fileupload</artifactId>
|
<artifactId>commons-fileupload</artifactId>
|
||||||
|
|
|
@ -17,7 +17,11 @@
|
||||||
<servlet path="/ImageService" class="org.gcube.portlets.user.workspace.server.ImageServlet" />
|
<servlet path="/ImageService" class="org.gcube.portlets.user.workspace.server.ImageServlet" />
|
||||||
<servlet path="/MetadataService" class="org.gcube.portlets.user.workspace.server.MetadataServlet" />
|
<servlet path="/MetadataService" class="org.gcube.portlets.user.workspace.server.MetadataServlet" />
|
||||||
-->
|
-->
|
||||||
|
|
||||||
|
<inherits name='org.gcube.portlets.widgets.fileupload.FileUpload' />
|
||||||
|
|
||||||
<servlet path="/UploadService" class="org.gcube.portlets.user.workspace.server.UploadServlet" />
|
<servlet path="/UploadService" class="org.gcube.portlets.user.workspace.server.UploadServlet" />
|
||||||
|
<servlet path="/LocalUploadService" class="org.gcube.portlets.user.workspace.server.LocalUploadServlet" />
|
||||||
<servlet path="/DownloadService" class="org.gcube.portlets.user.workspace.server.DownloadServlet" />
|
<servlet path="/DownloadService" class="org.gcube.portlets.user.workspace.server.DownloadServlet" />
|
||||||
<servlet path="/ImageService" class="org.gcube.portlets.user.workspace.server.ImageServlet" />
|
<servlet path="/ImageService" class="org.gcube.portlets.user.workspace.server.ImageServlet" />
|
||||||
|
|
||||||
|
|
|
@ -116,12 +116,13 @@ import org.gcube.portlets.user.workspace.client.view.windows.DialogGetInfo;
|
||||||
import org.gcube.portlets.user.workspace.client.view.windows.DialogPublicLink;
|
import org.gcube.portlets.user.workspace.client.view.windows.DialogPublicLink;
|
||||||
import org.gcube.portlets.user.workspace.client.view.windows.DialogShareLink;
|
import org.gcube.portlets.user.workspace.client.view.windows.DialogShareLink;
|
||||||
import org.gcube.portlets.user.workspace.client.view.windows.DialogText;
|
import org.gcube.portlets.user.workspace.client.view.windows.DialogText;
|
||||||
import org.gcube.portlets.user.workspace.client.view.windows.DialogUpload;
|
|
||||||
import org.gcube.portlets.user.workspace.client.view.windows.DialogWebDavUrl;
|
import org.gcube.portlets.user.workspace.client.view.windows.DialogWebDavUrl;
|
||||||
|
import org.gcube.portlets.user.workspace.client.view.windows.FileUploader;
|
||||||
import org.gcube.portlets.user.workspace.client.view.windows.InfoDisplay;
|
import org.gcube.portlets.user.workspace.client.view.windows.InfoDisplay;
|
||||||
import org.gcube.portlets.user.workspace.client.view.windows.InfoDisplayMessage;
|
import org.gcube.portlets.user.workspace.client.view.windows.InfoDisplayMessage;
|
||||||
import org.gcube.portlets.user.workspace.client.view.windows.MessageBoxAlert;
|
import org.gcube.portlets.user.workspace.client.view.windows.MessageBoxAlert;
|
||||||
import org.gcube.portlets.user.workspace.client.view.windows.MessageBoxConfirm;
|
import org.gcube.portlets.user.workspace.client.view.windows.MessageBoxConfirm;
|
||||||
|
import org.gcube.portlets.user.workspace.client.view.windows.UpdateServiceUploader;
|
||||||
import org.gcube.portlets.user.workspace.client.view.windows.WindowImagePreview;
|
import org.gcube.portlets.user.workspace.client.view.windows.WindowImagePreview;
|
||||||
import org.gcube.portlets.user.workspace.client.view.windows.WindowOpenUrl;
|
import org.gcube.portlets.user.workspace.client.view.windows.WindowOpenUrl;
|
||||||
import org.gcube.portlets.user.workspace.client.view.windows.accounting.WindowAccountingInfo;
|
import org.gcube.portlets.user.workspace.client.view.windows.accounting.WindowAccountingInfo;
|
||||||
|
@ -132,6 +133,11 @@ import org.gcube.portlets.user.workspace.client.workspace.folder.item.gcube.GWTI
|
||||||
import org.gcube.portlets.user.workspace.client.workspace.folder.item.gcube.GWTUrlDocument;
|
import org.gcube.portlets.user.workspace.client.workspace.folder.item.gcube.GWTUrlDocument;
|
||||||
import org.gcube.portlets.user.workspace.shared.SessionExpiredException;
|
import org.gcube.portlets.user.workspace.shared.SessionExpiredException;
|
||||||
import org.gcube.portlets.user.workspace.shared.accounting.GxtAccountingField;
|
import org.gcube.portlets.user.workspace.shared.accounting.GxtAccountingField;
|
||||||
|
import org.gcube.portlets.widgets.fileupload.client.events.FileUploadCompleteEvent;
|
||||||
|
import org.gcube.portlets.widgets.fileupload.client.events.FileUploadCompleteEventHandler;
|
||||||
|
import org.gcube.portlets.widgets.fileupload.client.events.FileUploadSelectedEvent;
|
||||||
|
import org.gcube.portlets.widgets.fileupload.client.events.FileUploadSelectedEventHandler;
|
||||||
|
import org.gcube.portlets.widgets.fileupload.client.view.UploadProgressDialog;
|
||||||
|
|
||||||
import com.extjs.gxt.ui.client.Registry;
|
import com.extjs.gxt.ui.client.Registry;
|
||||||
import com.extjs.gxt.ui.client.event.BaseEvent;
|
import com.extjs.gxt.ui.client.event.BaseEvent;
|
||||||
|
@ -145,6 +151,7 @@ import com.google.gwt.event.shared.EventHandler;
|
||||||
import com.google.gwt.event.shared.HandlerManager;
|
import com.google.gwt.event.shared.HandlerManager;
|
||||||
import com.google.gwt.http.client.RequestBuilder;
|
import com.google.gwt.http.client.RequestBuilder;
|
||||||
import com.google.gwt.user.client.Timer;
|
import com.google.gwt.user.client.Timer;
|
||||||
|
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.google.gwt.user.client.ui.HasWidgets;
|
import com.google.gwt.user.client.ui.HasWidgets;
|
||||||
|
|
||||||
|
@ -162,6 +169,7 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
|
||||||
private HashMap<EventsTypeEnum, ArrayList<SubscriberInterface>> subscribers = null;
|
private HashMap<EventsTypeEnum, ArrayList<SubscriberInterface>> subscribers = null;
|
||||||
|
|
||||||
private boolean selectRootItem;
|
private boolean selectRootItem;
|
||||||
|
private FileUploader fileUploader;
|
||||||
|
|
||||||
public AppControllerExplorer() {
|
public AppControllerExplorer() {
|
||||||
Registry.register(ConstantsExplorer.RPC_WORKSPACE_SERVICE, rpcWorkspaceService);
|
Registry.register(ConstantsExplorer.RPC_WORKSPACE_SERVICE, rpcWorkspaceService);
|
||||||
|
@ -337,11 +345,11 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
|
||||||
fileModel.setDescription(finalDialog.getDescription());
|
fileModel.setDescription(finalDialog.getDescription());
|
||||||
|
|
||||||
//DEBUG
|
//DEBUG
|
||||||
// System.out.println("FileModel id "+fileModel.getIdentifier() + " name: "+fileModel.getName() + " parent " + fileModel.getParentFileModel());
|
// System.out.println("FileModel id "+fileModel.getIdentifier() + " name: "+fileModel.getName() + " parent " + fileModel.getParentFileModel());
|
||||||
// for(InfoContactModel contact:finalDialog.getSharedListUsers() ){
|
// for(InfoContactModel contact:finalDialog.getSharedListUsers() ){
|
||||||
// System.out.println("Share with Contact "+contact) ;
|
// System.out.println("Share with Contact "+contact) ;
|
||||||
//
|
//
|
||||||
// }
|
// }
|
||||||
|
|
||||||
Info.display("Info", "An operation of sharing was submitted");
|
Info.display("Info", "An operation of sharing was submitted");
|
||||||
explorerPanel.mask("Submitting operation");
|
explorerPanel.mask("Submitting operation");
|
||||||
|
@ -432,7 +440,7 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess(String url) {
|
public void onSuccess(String url) {
|
||||||
// new MessageBoxInfo(ConstantsExplorer.URL_WEBDAV, url);
|
// new MessageBoxInfo(ConstantsExplorer.URL_WEBDAV, url);
|
||||||
DialogWebDavUrl diag = new DialogWebDavUrl(ConstantsExplorer.URL_WEBDAV +": "+ ConstantsExplorer.TITLEACCESSWEBDAV, "", url);
|
DialogWebDavUrl diag = new DialogWebDavUrl(ConstantsExplorer.URL_WEBDAV +": "+ ConstantsExplorer.TITLEACCESSWEBDAV, "", url);
|
||||||
diag.selectTxt();
|
diag.selectTxt();
|
||||||
|
|
||||||
|
@ -484,8 +492,8 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
|
||||||
|
|
||||||
currentUrl = lastChar>-1?currentUrl.substring(0, lastChar):currentUrl; //IF EXISTS - REMOVE STRING AFTER ? (? INLCUSE)
|
currentUrl = lastChar>-1?currentUrl.substring(0, lastChar):currentUrl; //IF EXISTS - REMOVE STRING AFTER ? (? INLCUSE)
|
||||||
|
|
||||||
// int last = currentUrl.lastIndexOf("/");
|
// int last = currentUrl.lastIndexOf("/");
|
||||||
// String shareLinkUrl = currentUrl.substring(0,last+1) + "?" +ConstantsExplorer.GET_ITEMID_PARAMETER+"="+getLinkEvent.getSourceFile().getIdentifier();
|
// String shareLinkUrl = currentUrl.substring(0,last+1) + "?" +ConstantsExplorer.GET_ITEMID_PARAMETER+"="+getLinkEvent.getSourceFile().getIdentifier();
|
||||||
String shareLinkUrl = currentUrl+ "?" +ConstantsExplorer.GET_ITEMID_PARAMETER+"="+getLinkEvent.getSourceFile().getIdentifier();
|
String shareLinkUrl = currentUrl+ "?" +ConstantsExplorer.GET_ITEMID_PARAMETER+"="+getLinkEvent.getSourceFile().getIdentifier();
|
||||||
shareLinkUrl+="&"+ConstantsExplorer.GET_OPEARATION_PARAMETER+"="+WsPortletInitOperation.gotofolder;
|
shareLinkUrl+="&"+ConstantsExplorer.GET_OPEARATION_PARAMETER+"="+WsPortletInitOperation.gotofolder;
|
||||||
|
|
||||||
|
@ -527,7 +535,7 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
|
||||||
if(target!=null)
|
if(target!=null)
|
||||||
explorerPanel.getAsycTreePanel().reloadTreeLevelAndExpandFolder(refreshItemEvent.getFolderTarget().getIdentifier(), refreshItemEvent.isExpandFolder());
|
explorerPanel.getAsycTreePanel().reloadTreeLevelAndExpandFolder(refreshItemEvent.getFolderTarget().getIdentifier(), refreshItemEvent.isExpandFolder());
|
||||||
}
|
}
|
||||||
// notifySubscriber(refreshtemEvent);
|
// notifySubscriber(refreshtemEvent);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
GWT.log("warn: escape refresh because item is null");
|
GWT.log("warn: escape refresh because item is null");
|
||||||
|
@ -696,8 +704,8 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess(MessageModel message) {
|
public void onSuccess(MessageModel message) {
|
||||||
|
|
||||||
// String headerTitle = ConstantsExplorer.MESSAGE_SENT_IN_DATE +": " +message.getDate() + " by "+ message.getFromLogin();
|
// String headerTitle = ConstantsExplorer.MESSAGE_SENT_IN_DATE +": " +message.getDate() + " by "+ message.getFromLogin();
|
||||||
// new SendMessage(result.getId(), headerTitle, result.getSubject(), result.getTextMessage(), result.getListAttachments(), result.getListContactsToString());
|
// new SendMessage(result.getId(), headerTitle, result.getSubject(), result.getTextMessage(), result.getListAttachments(), result.getListContactsToString());
|
||||||
|
|
||||||
previewMessageEvent.setMessage(message);
|
previewMessageEvent.setMessage(message);
|
||||||
notifySubscriber(previewMessageEvent);
|
notifySubscriber(previewMessageEvent);
|
||||||
|
@ -732,14 +740,14 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
|
||||||
public void onSuccess(MessageModel result) {
|
public void onSuccess(MessageModel result) {
|
||||||
|
|
||||||
//Commented for Massi
|
//Commented for Massi
|
||||||
// if(openMessageEvent.getOpenType().equals(OpenType.REPLY))
|
// if(openMessageEvent.getOpenType().equals(OpenType.REPLY))
|
||||||
//// new SendMessage(result, MessageOperationType.OPEN); //OPEN MESSAGE
|
//// new SendMessage(result, MessageOperationType.OPEN); //OPEN MESSAGE
|
||||||
//// notifySubscriber(openMessageEvent);
|
//// notifySubscriber(openMessageEvent);
|
||||||
// else{
|
// else{
|
||||||
// openMessageEvent.setMessage(result);
|
// openMessageEvent.setMessage(result);
|
||||||
//// notifySubscriber(openMessageEvent);
|
//// notifySubscriber(openMessageEvent);
|
||||||
//// new SendMessage(result, MessageOperationType.FORWARD);
|
//// new SendMessage(result, MessageOperationType.FORWARD);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
openMessageEvent.setMessage(result); //This fill item text and list contact
|
openMessageEvent.setMessage(result); //This fill item text and list contact
|
||||||
notifySubscriber(openMessageEvent);
|
notifySubscriber(openMessageEvent);
|
||||||
|
@ -871,13 +879,13 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
|
||||||
public void onFileDownloadEvent(FileDownloadEvent fileDownloadEvent) {
|
public void onFileDownloadEvent(FileDownloadEvent fileDownloadEvent) {
|
||||||
|
|
||||||
if(fileDownloadEvent.getItemIdentifier()!=null){
|
if(fileDownloadEvent.getItemIdentifier()!=null){
|
||||||
// if(fileDownloadEvent.getDownloadType().equals(DownloadType.SHOW)){
|
// if(fileDownloadEvent.getDownloadType().equals(DownloadType.SHOW)){
|
||||||
// if(fileDownloadEvent.getItemName()!= null)
|
// if(fileDownloadEvent.getItemName()!= null)
|
||||||
// com.google.gwt.user.client.Window.open(ConstantsExplorer.DOWNLOAD_WORKSPACE_SERVICE+"?id="+fileDownloadEvent.getItemIdentifier()+"&viewContent=true", fileDownloadEvent.getItemName(), "");
|
// com.google.gwt.user.client.Window.open(ConstantsExplorer.DOWNLOAD_WORKSPACE_SERVICE+"?id="+fileDownloadEvent.getItemIdentifier()+"&viewContent=true", fileDownloadEvent.getItemName(), "");
|
||||||
// }
|
// }
|
||||||
// else
|
// else
|
||||||
// com.google.gwt.user.client.Window.open(ConstantsExplorer.DOWNLOAD_WORKSPACE_SERVICE+"?id="+fileDownloadEvent.getItemIdentifier(), "_self", "");
|
// com.google.gwt.user.client.Window.open(ConstantsExplorer.DOWNLOAD_WORKSPACE_SERVICE+"?id="+fileDownloadEvent.getItemIdentifier(), "_self", "");
|
||||||
//
|
//
|
||||||
|
|
||||||
if(fileDownloadEvent.getDownloadType().equals(DownloadType.SHOW)){
|
if(fileDownloadEvent.getDownloadType().equals(DownloadType.SHOW)){
|
||||||
if(fileDownloadEvent.getItemName()!= null){
|
if(fileDownloadEvent.getItemName()!= null){
|
||||||
|
@ -892,7 +900,7 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
// com.google.gwt.user.client.Window.open(ConstantsExplorer.DOWNLOAD_WORKSPACE_SERVICE+"?id="+fileDownloadEvent.getItemIdentifier()+"&viewContent=true", fileDownloadEvent.getItemName(), "");
|
// com.google.gwt.user.client.Window.open(ConstantsExplorer.DOWNLOAD_WORKSPACE_SERVICE+"?id="+fileDownloadEvent.getItemIdentifier()+"&viewContent=true", fileDownloadEvent.getItemName(), "");
|
||||||
} else{
|
} else{
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -903,28 +911,28 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
|
||||||
explorerPanel.getAsycTreePanel().removeAllAndRecoveryRoot();
|
explorerPanel.getAsycTreePanel().removeAllAndRecoveryRoot();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// com.google.gwt.user.client.Window.open(ConstantsExplorer.DOWNLOAD_WORKSPACE_SERVICE+"?id="+fileDownloadEvent.getItemIdentifier(), "_self", "");
|
// com.google.gwt.user.client.Window.open(ConstantsExplorer.DOWNLOAD_WORKSPACE_SERVICE+"?id="+fileDownloadEvent.getItemIdentifier(), "_self", "");
|
||||||
|
|
||||||
// if(fileDownloadEvent.getDownloadType().equals(DownloadType.SHOW)){
|
// if(fileDownloadEvent.getDownloadType().equals(DownloadType.SHOW)){
|
||||||
// if(fileDownloadEvent.getItemName()!= null){
|
// if(fileDownloadEvent.getItemName()!= null){
|
||||||
//
|
//
|
||||||
// new DialogDownload(fileDownloadEvent.getItemName(), "_blank", fileDownloadEvent.getItemIdentifier(), true).submitForm();
|
// new DialogDownload(fileDownloadEvent.getItemName(), "_blank", fileDownloadEvent.getItemIdentifier(), true).submitForm();
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// }else{
|
// }else{
|
||||||
//
|
//
|
||||||
// new DialogDownload("", "_self", fileDownloadEvent.getItemIdentifier(), false).submitForm();
|
// new DialogDownload("", "_self", fileDownloadEvent.getItemIdentifier(), false).submitForm();
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
|
|
||||||
|
|
||||||
markItemInTreeAsRead(fileDownloadEvent.getItemIdentifier(), true);
|
markItemInTreeAsRead(fileDownloadEvent.getItemIdentifier(), true);
|
||||||
|
|
||||||
// FileModel file = explorerPanel.getAsycTreePanel().getFileModelByIdentifier(fileDownloadEvent.getItemIdentifier());
|
// FileModel file = explorerPanel.getAsycTreePanel().getFileModelByIdentifier(fileDownloadEvent.getItemIdentifier());
|
||||||
//
|
//
|
||||||
// if(file!=null){ //FILE CAN NOT LOADED IN TREE
|
// if(file!=null){ //FILE CAN NOT LOADED IN TREE
|
||||||
// file.setMarkAsRead(true);
|
// file.setMarkAsRead(true);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
notifySubscriber(fileDownloadEvent);
|
notifySubscriber(fileDownloadEvent);
|
||||||
}
|
}
|
||||||
|
@ -933,6 +941,7 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
eventBus.addHandler(FileUploadEvent.TYPE, new FileUploadEventHandler() {
|
eventBus.addHandler(FileUploadEvent.TYPE, new FileUploadEventHandler() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -945,14 +954,99 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
|
||||||
|
|
||||||
if(folder == null)
|
if(folder == null)
|
||||||
folder = explorerPanel.getAsycTreePanel().getRootItem();
|
folder = explorerPanel.getAsycTreePanel().getRootItem();
|
||||||
// folder = getSelectedFolderInTree();
|
|
||||||
|
|
||||||
if(fileUploadEvent.getUploadTypeToString().equals(UploadType.ARCHIVE.toString()))
|
if(fileUploadEvent.getUploadTypeToString().equals(UploadType.ARCHIVE.toString())){
|
||||||
new DialogUpload(ConstantsExplorer.ARCHIVEUPLOADHEADER, folder.getName(), folder, ConstantsExplorer.ARCHIVE);
|
// new DialogUpload(ConstantsExplorer.ARCHIVEUPLOADHEADER, folder.getName(), folder, ConstantsExplorer.ARCHIVE);
|
||||||
|
fileUploader = new FileUploader(eventBus, folder, ConstantsExplorer.ARCHIVE);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
new DialogUpload(ConstantsExplorer.FILEUPLOADHEADER, folder.getName(), folder, ConstantsExplorer.FILE);
|
fileUploader = new FileUploader(eventBus, folder, ConstantsExplorer.FILE);
|
||||||
|
|
||||||
// notifySubscriber(fileUploadEvent);
|
// new DialogUpload(ConstantsExplorer.FILEUPLOADHEADER, folder.getName(), folder, ConstantsExplorer.FILE);
|
||||||
|
|
||||||
|
// if(fileUploadEvent.getUploadTypeToString().equals(UploadType.ARCHIVE.toString()))
|
||||||
|
// new DialogUpload(ConstantsExplorer.ARCHIVEUPLOADHEADER, folder.getName(), folder, ConstantsExplorer.ARCHIVE);
|
||||||
|
// else
|
||||||
|
// new DialogUpload(ConstantsExplorer.FILEUPLOADHEADER, folder.getName(), folder, ConstantsExplorer.FILE);
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
eventBus.addHandler(FileUploadSelectedEvent.TYPE, new FileUploadSelectedEventHandler() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onFileSelected(FileUploadSelectedEvent event) {
|
||||||
|
String fileName = event.getSelectedFileName();
|
||||||
|
GWT.log("selected file name: " + fileName);
|
||||||
|
|
||||||
|
try {
|
||||||
|
|
||||||
|
String normalizedFileName = fileName;
|
||||||
|
|
||||||
|
// com.google.gwt.user.client.Window.alert("fileUploadField.getValue() "+fileUploadField.getValue());
|
||||||
|
if (normalizedFileName.contains("\\")) {
|
||||||
|
normalizedFileName = normalizedFileName.substring(normalizedFileName.lastIndexOf("\\")+1); //remove C:\fakepath\ if exists
|
||||||
|
// com.google.gwt.user.client.Window.alert("normalizedFileName= "+normalizedFileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
final String label = normalizedFileName;
|
||||||
|
|
||||||
|
GWT.log("normalizedFileName file name: "+normalizedFileName);
|
||||||
|
|
||||||
|
AppControllerExplorer.rpcWorkspaceService.itemExistsInWorkpaceFolder(fileUploader.getFolderParent().getIdentifier(), normalizedFileName, new AsyncCallback<String>() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onSuccess(final String itemId) {
|
||||||
|
|
||||||
|
if(itemId!=null){
|
||||||
|
|
||||||
|
boolean result = Window.confirm(label + " exists in folder "+fileUploader.getFolderParent().getName() + ". Overwrite?");
|
||||||
|
|
||||||
|
if(result){
|
||||||
|
|
||||||
|
fileUploader.overwrite();
|
||||||
|
fileUploader.submitForm();
|
||||||
|
}
|
||||||
|
|
||||||
|
}else
|
||||||
|
fileUploader.submitForm(); //ITEM does NOT EXIST SO SUBMIT FORM;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onFailure(Throwable caught) {
|
||||||
|
Info.display("Error", "Sorry an error occurred on the server "+caught.getLocalizedMessage() + ". Please try again later");
|
||||||
|
caught.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
Info.display("Error", "Sorry an error occurred on the server "+e.getLocalizedMessage() + ". Please try again later");
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* get the uploaded file result
|
||||||
|
*/
|
||||||
|
eventBus.addHandler(FileUploadCompleteEvent.TYPE, new FileUploadCompleteEventHandler() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onUploadComplete(FileUploadCompleteEvent event) {
|
||||||
|
|
||||||
|
//the filename and its path on server are returned to the client
|
||||||
|
String fileName = event.getUploadedFileInfo().getFilename();
|
||||||
|
String absolutePathOnServer = event.getUploadedFileInfo().getAbsolutePath();
|
||||||
|
GWT.log(fileName + " uploaded on Server here: " + absolutePathOnServer);
|
||||||
|
|
||||||
|
fileUploader.submitServletForm(absolutePathOnServer);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -966,7 +1060,7 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
|
||||||
|
|
||||||
private void doCompletedFileUploadEvent(CompletedFileUploadEvent completedFileUploadEvent) {
|
private void doCompletedFileUploadEvent(CompletedFileUploadEvent completedFileUploadEvent) {
|
||||||
|
|
||||||
// explorerPanel.getAsycTreePanel().reloadAndSelectTreeLevelFromWorkspaceForUplaod(completedFileUploadEvent.getParentFileModel().getIdentifier());
|
// explorerPanel.getAsycTreePanel().reloadAndSelectTreeLevelFromWorkspaceForUplaod(completedFileUploadEvent.getParentFileModel().getIdentifier());
|
||||||
boolean isLevelExpanded = treeLevelIsExpanded(completedFileUploadEvent.getTargetFolderModel().getIdentifier());
|
boolean isLevelExpanded = treeLevelIsExpanded(completedFileUploadEvent.getTargetFolderModel().getIdentifier());
|
||||||
//REFRESH TREE ONLY IF FOLDER PARENT EXISTS IN TREE
|
//REFRESH TREE ONLY IF FOLDER PARENT EXISTS IN TREE
|
||||||
if(explorerPanel.getAsycTreePanel().getFileModelByIdentifier(completedFileUploadEvent.getTargetFolderModel().getIdentifier())!=null){
|
if(explorerPanel.getAsycTreePanel().getFileModelByIdentifier(completedFileUploadEvent.getTargetFolderModel().getIdentifier())!=null){
|
||||||
|
@ -996,7 +1090,7 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
|
||||||
|
|
||||||
public void handleEvent(MessageBoxEvent be) {
|
public void handleEvent(MessageBoxEvent be) {
|
||||||
|
|
||||||
// eventBus.fireEvent(new DeleteItemEvent(sel));
|
// eventBus.fireEvent(new DeleteItemEvent(sel));
|
||||||
|
|
||||||
//IF NOT CANCELLED
|
//IF NOT CANCELLED
|
||||||
String clickedButton = be.getButtonClicked().getItemId();
|
String clickedButton = be.getButtonClicked().getItemId();
|
||||||
|
@ -1012,7 +1106,7 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onFailure(Throwable caught) {
|
public void onFailure(Throwable caught) {
|
||||||
// explorerPanel.getAsycTreePanel().unmask();
|
// explorerPanel.getAsycTreePanel().unmask();
|
||||||
new MessageBoxAlert("Error", ConstantsExplorer.SERVER_ERROR + " deleting smart folder.", null);
|
new MessageBoxAlert("Error", ConstantsExplorer.SERVER_ERROR + " deleting smart folder.", null);
|
||||||
explorerPanel.getAsycTreePanel().removeAllAndRecoveryRoot();
|
explorerPanel.getAsycTreePanel().removeAllAndRecoveryRoot();
|
||||||
|
|
||||||
|
@ -1136,7 +1230,7 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
|
||||||
public void onSuccess(Boolean result) {
|
public void onSuccess(Boolean result) {
|
||||||
explorerPanel.getAsycTreePanel().renameItem(target.getIdentifier(), newName, null);
|
explorerPanel.getAsycTreePanel().renameItem(target.getIdentifier(), newName, null);
|
||||||
event.setNewName(newName);
|
event.setNewName(newName);
|
||||||
// event.setExtension(extension);
|
// event.setExtension(extension);
|
||||||
notifySubscriber(event);
|
notifySubscriber(event);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1178,7 +1272,7 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
|
||||||
|
|
||||||
public void handleEvent(MessageBoxEvent be) {
|
public void handleEvent(MessageBoxEvent be) {
|
||||||
|
|
||||||
// eventBus.fireEvent(new DeleteItemEvent(sel));
|
// eventBus.fireEvent(new DeleteItemEvent(sel));
|
||||||
|
|
||||||
//IF NOT CANCELLED
|
//IF NOT CANCELLED
|
||||||
String clickedButton = be.getButtonClicked().getItemId();
|
String clickedButton = be.getButtonClicked().getItemId();
|
||||||
|
@ -1285,10 +1379,10 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
|
||||||
if(dialogAddFolder.isValidForm()){
|
if(dialogAddFolder.isValidForm()){
|
||||||
|
|
||||||
if(sourceFileModel.isDirectory()){
|
if(sourceFileModel.isDirectory()){
|
||||||
//
|
//
|
||||||
|
|
||||||
//TODO REMOVE
|
//TODO REMOVE
|
||||||
// System.out.println("description folder: "+dialogAddFolder.getDescription());
|
// System.out.println("description folder: "+dialogAddFolder.getDescription());
|
||||||
|
|
||||||
rpcWorkspaceService.createFolder(dialogAddFolder.getName(), dialogAddFolder.getDescription(), sourceFileModel, new AsyncCallback<FolderModel>(){
|
rpcWorkspaceService.createFolder(dialogAddFolder.getName(), dialogAddFolder.getDescription(), sourceFileModel, new AsyncCallback<FolderModel>(){
|
||||||
|
|
||||||
|
@ -1296,7 +1390,7 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
|
||||||
public void onFailure(Throwable caught) {
|
public void onFailure(Throwable caught) {
|
||||||
explorerPanel.getAsycTreePanel().unmask();
|
explorerPanel.getAsycTreePanel().unmask();
|
||||||
new MessageBoxAlert("Error", ConstantsExplorer.SERVER_ERROR +" adding item. " + ConstantsExplorer.TRY_AGAIN, null);
|
new MessageBoxAlert("Error", ConstantsExplorer.SERVER_ERROR +" adding item. " + ConstantsExplorer.TRY_AGAIN, null);
|
||||||
// explorerPanel.getAsycTreePanel().removeAllAndRecoveryRoot();
|
// explorerPanel.getAsycTreePanel().removeAllAndRecoveryRoot();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1317,7 +1411,7 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
|
||||||
public void onFailure(Throwable caught) {
|
public void onFailure(Throwable caught) {
|
||||||
explorerPanel.getAsycTreePanel().unmask();
|
explorerPanel.getAsycTreePanel().unmask();
|
||||||
new MessageBoxAlert("Error", ConstantsExplorer.SERVER_ERROR + " creating folder." + ConstantsExplorer.TRY_AGAIN, null);
|
new MessageBoxAlert("Error", ConstantsExplorer.SERVER_ERROR + " creating folder." + ConstantsExplorer.TRY_AGAIN, null);
|
||||||
// explorerPanel.getAsycTreePanel().removeAllAndRecoveryRoot();
|
// explorerPanel.getAsycTreePanel().removeAllAndRecoveryRoot();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1371,7 +1465,7 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
|
||||||
explorerPanel.getAsycTreePanel().reloadTreeLevelAndExpandFolder(event.getTargetParentFileModel().getIdentifier(), true);
|
explorerPanel.getAsycTreePanel().reloadTreeLevelAndExpandFolder(event.getTargetParentFileModel().getIdentifier(), true);
|
||||||
notifySubscriber(event);
|
notifySubscriber(event);
|
||||||
|
|
||||||
// explorerPanel.getAsycTreePanel().setExpandTreeLevel(event.getTargetParentFileModel(), true); //Expand level drop
|
// explorerPanel.getAsycTreePanel().setExpandTreeLevel(event.getTargetParentFileModel(), true); //Expand level drop
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -1384,7 +1478,7 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
|
||||||
@Override
|
@Override
|
||||||
public void onClickPreview(ImagePreviewEvent imagePreviewEvent) {
|
public void onClickPreview(ImagePreviewEvent imagePreviewEvent) {
|
||||||
|
|
||||||
// System.out.println("x e y " + imagePreviewEvent.getClientX() + " e " + imagePreviewEvent.getClientY());
|
// System.out.println("x e y " + imagePreviewEvent.getClientX() + " e " + imagePreviewEvent.getClientY());
|
||||||
|
|
||||||
if(imagePreviewEvent.getClientX() > 0 && imagePreviewEvent.getClientY() > 0)
|
if(imagePreviewEvent.getClientX() > 0 && imagePreviewEvent.getClientY() > 0)
|
||||||
doClickPreview(imagePreviewEvent, imagePreviewEvent.getClientX(), imagePreviewEvent.getClientY() );
|
doClickPreview(imagePreviewEvent, imagePreviewEvent.getClientX(), imagePreviewEvent.getClientY() );
|
||||||
|
@ -1396,7 +1490,7 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
|
||||||
if(imagePreviewEvent.getSourceFileModel()!=null){ //FILE CAN NOT LOADED IN TREE
|
if(imagePreviewEvent.getSourceFileModel()!=null){ //FILE CAN NOT LOADED IN TREE
|
||||||
|
|
||||||
markItemInTreeAsRead(imagePreviewEvent.getSourceFileModel().getIdentifier(), true);
|
markItemInTreeAsRead(imagePreviewEvent.getSourceFileModel().getIdentifier(), true);
|
||||||
// imagePreviewEvent.getSourceFileModel().setMarkAsRead(true);
|
// imagePreviewEvent.getSourceFileModel().setMarkAsRead(true);
|
||||||
notifySubscriber(new FileDownloadEvent(imagePreviewEvent.getSourceFileModel().getIdentifier(), imagePreviewEvent.getSourceFileModel().getName(), FileDownloadEvent.DownloadType.SHOW));
|
notifySubscriber(new FileDownloadEvent(imagePreviewEvent.getSourceFileModel().getIdentifier(), imagePreviewEvent.getSourceFileModel().getName(), FileDownloadEvent.DownloadType.SHOW));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1473,7 +1567,7 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// com.google.gwt.user.client.Window.open(ConstantsExplorer.DOWNLOAD_WORKSPACE_SERVICE+"?id="+fileModel.getIdentifier()+"&viewContent=true", fileModel.getName(), "");
|
// com.google.gwt.user.client.Window.open(ConstantsExplorer.DOWNLOAD_WORKSPACE_SERVICE+"?id="+fileModel.getIdentifier()+"&viewContent=true", fileModel.getName(), "");
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -1559,7 +1653,7 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
|
||||||
String currentUrl = portalURL();
|
String currentUrl = portalURL();
|
||||||
int last = currentUrl.lastIndexOf("/");
|
int last = currentUrl.lastIndexOf("/");
|
||||||
String reportUrl = currentUrl.substring(0,last+1) + ConstantsExplorer.REPORTGENERATION;
|
String reportUrl = currentUrl.substring(0,last+1) + ConstantsExplorer.REPORTGENERATION;
|
||||||
// Log.trace("Url: "+reportUrl);
|
// Log.trace("Url: "+reportUrl);
|
||||||
System.out.println("currentUrl " +currentUrl);
|
System.out.println("currentUrl " +currentUrl);
|
||||||
System.out.println("reportUrl " +reportUrl);
|
System.out.println("reportUrl " +reportUrl);
|
||||||
new WindowOpenUrl(reportUrl, "_self", "");
|
new WindowOpenUrl(reportUrl, "_self", "");
|
||||||
|
@ -1577,9 +1671,9 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
|
||||||
|
|
||||||
private void doClickOpenReportTemplate(OpenReportsEvent openReportTemplateEvent) {
|
private void doClickOpenReportTemplate(OpenReportsEvent openReportTemplateEvent) {
|
||||||
|
|
||||||
// System.out.println("IDTEMPLATE " + ConstantsExplorer.IDTEMPLATE);
|
// System.out.println("IDTEMPLATE " + ConstantsExplorer.IDTEMPLATE);
|
||||||
// System.out.println("id " +openReportTemplateEvent.getSourceFileModel().getIdentifier());
|
// System.out.println("id " +openReportTemplateEvent.getSourceFileModel().getIdentifier());
|
||||||
// System.out.println("name " +openReportTemplateEvent.getSourceFileModel().getName());
|
// System.out.println("name " +openReportTemplateEvent.getSourceFileModel().getName());
|
||||||
|
|
||||||
rpcWorkspaceService.getURLFromApplicationProfile(openReportTemplateEvent.getSourceFileModel().getIdentifier(), new AsyncCallback<String>() {
|
rpcWorkspaceService.getURLFromApplicationProfile(openReportTemplateEvent.getSourceFileModel().getIdentifier(), new AsyncCallback<String>() {
|
||||||
|
|
||||||
|
@ -1598,7 +1692,7 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
|
||||||
String currentUrl = portalURL();
|
String currentUrl = portalURL();
|
||||||
int last = currentUrl.lastIndexOf("/");
|
int last = currentUrl.lastIndexOf("/");
|
||||||
String templateUrl = currentUrl.substring(0,last+1) + ConstantsExplorer.TEMPLATECREATION;
|
String templateUrl = currentUrl.substring(0,last+1) + ConstantsExplorer.TEMPLATECREATION;
|
||||||
// Log.trace("Url: "+templateUrl);
|
// Log.trace("Url: "+templateUrl);
|
||||||
System.out.println("currentUrl " +currentUrl);
|
System.out.println("currentUrl " +currentUrl);
|
||||||
System.out.println("reportUrl " +templateUrl);
|
System.out.println("reportUrl " +templateUrl);
|
||||||
new WindowOpenUrl(templateUrl, "_self", "");
|
new WindowOpenUrl(templateUrl, "_self", "");
|
||||||
|
@ -1647,7 +1741,7 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
|
||||||
|
|
||||||
SelectedItemEvent selectedEvent = (SelectedItemEvent) event;
|
SelectedItemEvent selectedEvent = (SelectedItemEvent) event;
|
||||||
|
|
||||||
// ArrayList<FileModel> listFileModel = getListParentsByIdentifier(selectedEvent.getFileTarget().getIdentifier());
|
// ArrayList<FileModel> listFileModel = getListParentsByIdentifier(selectedEvent.getFileTarget().getIdentifier());
|
||||||
|
|
||||||
List<FileModel> listFileModel = new ArrayList<FileModel>();
|
List<FileModel> listFileModel = new ArrayList<FileModel>();
|
||||||
|
|
||||||
|
@ -1679,8 +1773,8 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
|
||||||
|
|
||||||
sub.setParentItemSelected(subTreeEvent.getPathParentsList());
|
sub.setParentItemSelected(subTreeEvent.getPathParentsList());
|
||||||
|
|
||||||
// if(openTreeMenuEvent && isShowTreeMenu==false)
|
// if(openTreeMenuEvent && isShowTreeMenu==false)
|
||||||
// eventBus.fireEvent(new O)
|
// eventBus.fireEvent(new O)
|
||||||
|
|
||||||
}else if(event instanceof SmartFolderSelectedEvent){
|
}else if(event instanceof SmartFolderSelectedEvent){
|
||||||
|
|
||||||
|
@ -1690,8 +1784,8 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
|
||||||
|
|
||||||
}else if(event instanceof FileUploadEvent){
|
}else if(event instanceof FileUploadEvent){
|
||||||
|
|
||||||
// FileUploadEvent fileUpEvent = (FileUploadEvent) event;
|
// FileUploadEvent fileUpEvent = (FileUploadEvent) event;
|
||||||
// sub.addedFile(fileUpEvent.getParentFileModel(), "");
|
// sub.addedFile(fileUpEvent.getParentFileModel(), "");
|
||||||
|
|
||||||
} else if(event instanceof CompletedFileUploadEvent){
|
} else if(event instanceof CompletedFileUploadEvent){
|
||||||
|
|
||||||
|
@ -1727,7 +1821,7 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
|
||||||
|
|
||||||
SendMessageEvent messageEvent = (SendMessageEvent) event;
|
SendMessageEvent messageEvent = (SendMessageEvent) event;
|
||||||
|
|
||||||
// sub.updatePrevieMessage(messageEvent.getMessage().getFromLogin(), messageEvent.getMessage().getSubject(), messageEvent.getMessage().getDate(), messageEvent.getMessage().getTextMessage(), messageEvent.getMessage().getListAttachments());
|
// sub.updatePrevieMessage(messageEvent.getMessage().getFromLogin(), messageEvent.getMessage().getSubject(), messageEvent.getMessage().getDate(), messageEvent.getMessage().getTextMessage(), messageEvent.getMessage().getListAttachments());
|
||||||
|
|
||||||
HashMap<String, String> hashFiles = new HashMap<String, String>();
|
HashMap<String, String> hashFiles = new HashMap<String, String>();
|
||||||
|
|
||||||
|
@ -1795,7 +1889,7 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
|
||||||
private void getParents(List<FileModel> listParents, FileModel item){
|
private void getParents(List<FileModel> listParents, FileModel item){
|
||||||
|
|
||||||
if(item==null || item.getParentFileModel()==null){
|
if(item==null || item.getParentFileModel()==null){
|
||||||
// listParents.add(item);
|
// listParents.add(item);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1893,9 +1987,9 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
|
||||||
|
|
||||||
this.explorerPanel = new ExplorerPanel(true, true);
|
this.explorerPanel = new ExplorerPanel(true, true);
|
||||||
|
|
||||||
// PollingWorkspace.pollReceivedMessages(-1, 20000); //the parameter -1 force (first) synchronization with HL
|
// PollingWorkspace.pollReceivedMessages(-1, 20000); //the parameter -1 force (first) synchronization with HL
|
||||||
|
|
||||||
// PollingWorkspace.pollBulkCreator(15000);
|
// PollingWorkspace.pollBulkCreator(15000);
|
||||||
|
|
||||||
return this.explorerPanel;
|
return this.explorerPanel;
|
||||||
}
|
}
|
||||||
|
@ -1914,11 +2008,11 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
|
||||||
this.selectRootItem=selectRootItem;
|
this.selectRootItem=selectRootItem;
|
||||||
|
|
||||||
|
|
||||||
// if(instancingMessages)
|
// if(instancingMessages)
|
||||||
// PollingWorkspace.pollReceivedMessages(-1, 20000); //the parameter -1 force (first) synchronization with HL
|
// PollingWorkspace.pollReceivedMessages(-1, 20000); //the parameter -1 force (first) synchronization with HL
|
||||||
|
|
||||||
|
|
||||||
// PollingWorkspace.pollBulkCreator(ConstantsExplorer.TIME_BULK_CREATOR_POLLING);
|
// PollingWorkspace.pollBulkCreator(ConstantsExplorer.TIME_BULK_CREATOR_POLLING);
|
||||||
|
|
||||||
return this.explorerPanel;
|
return this.explorerPanel;
|
||||||
}
|
}
|
||||||
|
@ -2024,8 +2118,8 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
|
||||||
FileModel item = this.explorerPanel.getAsycTreePanel().getFileModelByIdentifier(itemIdentifier);
|
FileModel item = this.explorerPanel.getAsycTreePanel().getFileModelByIdentifier(itemIdentifier);
|
||||||
|
|
||||||
if(item==null){
|
if(item==null){
|
||||||
// System.out.println(" LOAD****");
|
// System.out.println(" LOAD****");
|
||||||
// selectedItemInTree(itemIdentifier); //Load from HL
|
// selectedItemInTree(itemIdentifier); //Load from HL
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
|
@ -2160,7 +2254,7 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
|
||||||
windowOpenParam.getBrowserWindow().setUrl(ConstantsExplorer.DOWNLOAD_WORKSPACE_SERVICE+params);
|
windowOpenParam.getBrowserWindow().setUrl(ConstantsExplorer.DOWNLOAD_WORKSPACE_SERVICE+params);
|
||||||
|
|
||||||
|
|
||||||
// com.google.gwt.user.client.Window.open(ConstantsExplorer.DOWNLOAD_WORKSPACE_SERVICE+params, windowOpenParam.getOption(), "");
|
// com.google.gwt.user.client.Window.open(ConstantsExplorer.DOWNLOAD_WORKSPACE_SERVICE+params, windowOpenParam.getOption(), "");
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -2184,7 +2278,7 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void searching(boolean isSearch){
|
public void searching(boolean isSearch){
|
||||||
// deselecteCurrentSelection();
|
// deselecteCurrentSelection();
|
||||||
explorerPanel.getAsycTreePanel().setSearch(isSearch);
|
explorerPanel.getAsycTreePanel().setSearch(isSearch);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,6 +15,7 @@ public class ConstantsExplorer {
|
||||||
// public static final String FILE_SERVICE = GWT.getModuleBaseURL() + "fileservice";
|
// public static final String FILE_SERVICE = GWT.getModuleBaseURL() + "fileservice";
|
||||||
public static final String RPC_WORKSPACE_SERVICE = GWT.getModuleBaseURL() + "rpcWorkspace";
|
public static final String RPC_WORKSPACE_SERVICE = GWT.getModuleBaseURL() + "rpcWorkspace";
|
||||||
public static final String UPLOAD_WORKSPACE_SERVICE = GWT.getModuleBaseURL() + "UploadService";
|
public static final String UPLOAD_WORKSPACE_SERVICE = GWT.getModuleBaseURL() + "UploadService";
|
||||||
|
public static final String LOCAL_UPLOAD_WORKSPACE_SERVICE = GWT.getModuleBaseURL() + "LocalUploadService";
|
||||||
public static final String DOWNLOAD_WORKSPACE_SERVICE = GWT.getModuleBaseURL() + "DownloadService";
|
public static final String DOWNLOAD_WORKSPACE_SERVICE = GWT.getModuleBaseURL() + "DownloadService";
|
||||||
|
|
||||||
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";
|
||||||
|
|
|
@ -170,7 +170,7 @@ public class DialogUpload extends Window {
|
||||||
this.setAutoWidth(true);
|
this.setAutoWidth(true);
|
||||||
this.setAutoHeight(true);
|
this.setAutoHeight(true);
|
||||||
|
|
||||||
this.show();
|
// this.show();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,93 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package org.gcube.portlets.user.workspace.client.view.windows;
|
||||||
|
|
||||||
|
import org.gcube.portlets.user.workspace.client.model.FileModel;
|
||||||
|
import org.gcube.portlets.widgets.fileupload.client.view.UploadProgressDialog;
|
||||||
|
|
||||||
|
import com.extjs.gxt.ui.client.widget.Info;
|
||||||
|
import com.google.gwt.event.shared.HandlerManager;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
||||||
|
* @Jan 20, 2014
|
||||||
|
*
|
||||||
|
* This class calls the widget file uploader
|
||||||
|
*/
|
||||||
|
public class FileUploader {
|
||||||
|
|
||||||
|
|
||||||
|
private final UploadProgressDialog dlg;
|
||||||
|
private FileModel folderParent;
|
||||||
|
private UpdateServiceUploader updateServiceUploader;
|
||||||
|
private FileUploader INSTANCE = this;
|
||||||
|
private String uploadType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public FileUploader(HandlerManager eventBus, FileModel folderParent, String uploadType) {
|
||||||
|
this.folderParent = folderParent;
|
||||||
|
this.uploadType = uploadType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Prepare new servlet uploader
|
||||||
|
*/
|
||||||
|
updateServiceUploader = new UpdateServiceUploader(INSTANCE, folderParent, uploadType);
|
||||||
|
|
||||||
|
this.dlg = new UploadProgressDialog("Upload File in: "+folderParent.getName(), eventBus, true);
|
||||||
|
dlg.center();
|
||||||
|
dlg.show();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void submitForm() {
|
||||||
|
|
||||||
|
try {
|
||||||
|
|
||||||
|
dlg.submitForm();
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
Info.display("Error", "Sorry an error occurred on the server "+e.getLocalizedMessage() + ". Please try again later");
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void overwrite(){
|
||||||
|
updateServiceUploader.setOverwrite();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void submitServletForm(String absolutePathOnServer){
|
||||||
|
|
||||||
|
updateServiceUploader.setFileName(absolutePathOnServer);
|
||||||
|
|
||||||
|
try {
|
||||||
|
|
||||||
|
updateServiceUploader.submitForm();
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
|
||||||
|
dlg.showRegisteringResult(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public FileModel getFolderParent() {
|
||||||
|
return folderParent;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getUploadType() {
|
||||||
|
return uploadType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public UpdateServiceUploader getUpdateServiceUploader() {
|
||||||
|
return updateServiceUploader;
|
||||||
|
}
|
||||||
|
|
||||||
|
public UploadProgressDialog getDlg() {
|
||||||
|
return dlg;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,166 @@
|
||||||
|
package org.gcube.portlets.user.workspace.client.view.windows;
|
||||||
|
|
||||||
|
|
||||||
|
import org.gcube.portlets.user.workspace.client.AppControllerExplorer;
|
||||||
|
import org.gcube.portlets.user.workspace.client.ConstantsExplorer;
|
||||||
|
import org.gcube.portlets.user.workspace.client.event.CompletedFileUploadEvent;
|
||||||
|
import org.gcube.portlets.user.workspace.client.model.FileModel;
|
||||||
|
import org.gcube.portlets.user.workspace.shared.HandlerResultMessage;
|
||||||
|
|
||||||
|
import com.extjs.gxt.ui.client.widget.Window;
|
||||||
|
import com.google.gwt.core.client.GWT;
|
||||||
|
import com.google.gwt.http.client.Request;
|
||||||
|
import com.google.gwt.http.client.RequestBuilder;
|
||||||
|
import com.google.gwt.http.client.RequestCallback;
|
||||||
|
import com.google.gwt.http.client.RequestException;
|
||||||
|
import com.google.gwt.http.client.Response;
|
||||||
|
import com.google.gwt.user.client.Timer;
|
||||||
|
import com.google.gwt.user.client.ui.HTML;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
||||||
|
* @Jan 20, 2014
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class UpdateServiceUploader extends Window{
|
||||||
|
|
||||||
|
private FileUploader fileUploaderDlg = null;
|
||||||
|
private String fileName = "";
|
||||||
|
private boolean overwrite = false;
|
||||||
|
private FileModel parent;
|
||||||
|
private String uploadType;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param fileUploader
|
||||||
|
* @param parent
|
||||||
|
* @param uploadType
|
||||||
|
*
|
||||||
|
* By default overwrite paramameter is false
|
||||||
|
*/
|
||||||
|
public UpdateServiceUploader(final FileUploader fileUploader, final FileModel parent, String uploadType){
|
||||||
|
|
||||||
|
this.fileUploaderDlg = fileUploader;
|
||||||
|
this.parent = parent;
|
||||||
|
this.uploadType = uploadType;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void submitForm() throws Exception{
|
||||||
|
|
||||||
|
if(fileName == null || fileName.isEmpty())
|
||||||
|
throw new Exception("File absolute path on server is null");
|
||||||
|
|
||||||
|
String parameters = "";
|
||||||
|
|
||||||
|
parameters+=ConstantsExplorer.UPLOAD_FORM_ELEMENT+"="+fileName+"&";
|
||||||
|
|
||||||
|
|
||||||
|
if(parent.getIdentifier()!=null && !parent.getIdentifier().isEmpty())
|
||||||
|
parameters+=ConstantsExplorer.ID_FOLDER+"="+parent.getIdentifier()+"&";
|
||||||
|
else
|
||||||
|
throw new Exception("Parent Folder ID parameter is null or empty");
|
||||||
|
|
||||||
|
if(uploadType!=null && !uploadType.isEmpty())
|
||||||
|
parameters+=ConstantsExplorer.UPLOAD_TYPE+"="+uploadType+"&";
|
||||||
|
else
|
||||||
|
throw new Exception("UploadType parameter is null or empty");
|
||||||
|
|
||||||
|
parameters+=ConstantsExplorer.IS_OVERWRITE+"="+overwrite;
|
||||||
|
|
||||||
|
// String urlRequest = ConstantsExplorer.LOCAL_UPLOAD_WORKSPACE_SERVICE+"?"+URL.encodeQueryString(parameters);
|
||||||
|
|
||||||
|
String urlRequest = ConstantsExplorer.LOCAL_UPLOAD_WORKSPACE_SERVICE+"?"+parameters;
|
||||||
|
|
||||||
|
GWT.log("Encoded url request is: "+urlRequest);
|
||||||
|
|
||||||
|
|
||||||
|
RequestBuilder requestBuilder = new RequestBuilder(RequestBuilder.POST, urlRequest);
|
||||||
|
// requestBuilder.setHeader("Content-Type", "application/x-www-form-urlencoded");
|
||||||
|
try {
|
||||||
|
|
||||||
|
requestBuilder.sendRequest("", new RequestCallback() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onResponseReceived(Request request, Response response) {
|
||||||
|
|
||||||
|
// int status = response.getStatusCode();
|
||||||
|
|
||||||
|
//expected <pre>200:Upload complete</pre>
|
||||||
|
/*we strip tags added by webserver,
|
||||||
|
*
|
||||||
|
* Massi fix because webkit returns
|
||||||
|
* <pre style="word-wrap: break-word; white-space: pre-wrap;">OK:File france_flag.png(0) imported correctly in /Workspace</pre>
|
||||||
|
*
|
||||||
|
* TODO: recall it next time
|
||||||
|
*/
|
||||||
|
//String strippedResult = result.replace("<pre>", "").replace("</pre>", ""); //this won't work for webkit
|
||||||
|
//replaced by new HTML(result).getText()
|
||||||
|
String strippedResult = new HTML(response.getText()).getText();
|
||||||
|
|
||||||
|
final HandlerResultMessage resultMessage = HandlerResultMessage.parseResult(strippedResult);
|
||||||
|
|
||||||
|
switch (resultMessage.getStatus()) {
|
||||||
|
case ERROR:
|
||||||
|
// new MessageBoxAlert("Error during upload", resultMessage.getMessage(), null);
|
||||||
|
GWT.log("Error during upload: "+resultMessage.getMessage());
|
||||||
|
fileUploaderDlg.getDlg().showRegisteringResult(false);
|
||||||
|
break;
|
||||||
|
case UNKNOWN:
|
||||||
|
// new MessageBoxAlert("Error during upload", resultMessage.getMessage(), null);
|
||||||
|
GWT.log("Error during upload: "+resultMessage.getMessage());
|
||||||
|
fileUploaderDlg.getDlg().showRegisteringResult(false);
|
||||||
|
break;
|
||||||
|
case WARN: {
|
||||||
|
// new MessageBoxAlert("Upload completed with warnings", resultMessage.getMessage(), null);
|
||||||
|
GWT.log("Upload completed with warnings: "+resultMessage.getMessage());
|
||||||
|
fileUploaderDlg.getDlg().showRegisteringResult(false);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case OK: {
|
||||||
|
Timer t = new Timer() {
|
||||||
|
public void run() {
|
||||||
|
AppControllerExplorer.getEventBus().fireEvent(new CompletedFileUploadEvent(parent, null));
|
||||||
|
fileUploaderDlg.getDlg().showRegisteringResult(true);
|
||||||
|
// new InfoDisplayMessage("Upload completed successfully", resultMessage.getMessage());
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
t.schedule(250);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onError(Request request, Throwable exception) {
|
||||||
|
// MessageUtil.showErrorMessage("Error during upload", "An error occurred during file upload.");
|
||||||
|
|
||||||
|
fileUploaderDlg.getDlg().showRegisteringResult(false);
|
||||||
|
// new MessageBoxAlert("Error during upload", "An error occurred during file upload.", null);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
} catch (RequestException e) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setOverwrite(){
|
||||||
|
overwrite = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getFileName() {
|
||||||
|
return fileName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFileName(String fileName) {
|
||||||
|
this.fileName = fileName;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,474 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package org.gcube.portlets.user.workspace.server;
|
||||||
|
|
||||||
|
import java.io.BufferedInputStream;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileInputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.net.URLDecoder;
|
||||||
|
import java.util.Calendar;
|
||||||
|
|
||||||
|
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.apache.commons.fileupload.FileUploadException;
|
||||||
|
import org.apache.commons.io.FileUtils;
|
||||||
|
import org.apache.commons.io.FilenameUtils;
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
import org.gcube.common.homelibrary.home.exceptions.InternalErrorException;
|
||||||
|
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.WorkspaceItemType;
|
||||||
|
import org.gcube.common.homelibrary.home.workspace.exceptions.InsufficientPrivilegesException;
|
||||||
|
import org.gcube.common.homelibrary.home.workspace.exceptions.ItemAlreadyExistException;
|
||||||
|
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.WrongDestinationException;
|
||||||
|
import org.gcube.common.homelibrary.home.workspace.exceptions.WrongItemTypeException;
|
||||||
|
import org.gcube.common.homelibrary.home.workspace.folder.FolderItem;
|
||||||
|
import org.gcube.common.homelibrary.home.workspace.folder.items.Report;
|
||||||
|
import org.gcube.common.homelibrary.home.workspace.folder.items.ReportTemplate;
|
||||||
|
import org.gcube.common.homelibrary.util.Extensions;
|
||||||
|
import org.gcube.common.homelibrary.util.MimeTypeUtil;
|
||||||
|
import org.gcube.common.homelibrary.util.WorkspaceUtil;
|
||||||
|
import org.gcube.common.homelibrary.util.zip.UnzipUtil;
|
||||||
|
import org.gcube.portlets.user.workspace.client.ConstantsExplorer;
|
||||||
|
import org.gcube.portlets.user.workspace.server.notifications.NotificationsUtil;
|
||||||
|
import org.gcube.portlets.user.workspace.server.util.WsUtil;
|
||||||
|
import org.gcube.portlets.user.workspace.shared.HandlerResultMessage;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
||||||
|
* @Jan 21, 2014
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class LocalUploadServlet extends HttpServlet {
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
protected static final String UTF_8 = "UTF-8";
|
||||||
|
|
||||||
|
public static final String UPLOAD_TYPE = ConstantsExplorer.UPLOAD_TYPE;
|
||||||
|
|
||||||
|
public static final String ID_FOLDER = ConstantsExplorer.ID_FOLDER;
|
||||||
|
|
||||||
|
public static final String UPLOAD_FORM_ELEMENT = ConstantsExplorer.UPLOAD_FORM_ELEMENT;
|
||||||
|
|
||||||
|
public static final String IS_OVERWRITE = ConstantsExplorer.IS_OVERWRITE;
|
||||||
|
|
||||||
|
public static final String FILE = "File";
|
||||||
|
|
||||||
|
protected static Logger logger = Logger.getLogger(LocalUploadServlet.class);
|
||||||
|
|
||||||
|
public static final String D4ST = Extensions.REPORT_TEMPLATE.getName(); //extension of Report Template type
|
||||||
|
public static final String D4SR = Extensions.REPORT.getName(); //extension of Report type
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private static final long serialVersionUID = -4197748678713054285L;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void init() throws ServletException {
|
||||||
|
super.init();
|
||||||
|
|
||||||
|
logger.trace("Workspace "+LocalUploadServlet.class+" ready.");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||||
|
// System.out.println("GET on LocalUploadServlet");
|
||||||
|
logger.trace("GET on LocalUploadServlet");
|
||||||
|
String absolutePathFile = URLDecoder.decode(request.getParameter(UPLOAD_FORM_ELEMENT), UTF_8);
|
||||||
|
String destinationId = URLDecoder.decode(request.getParameter(ID_FOLDER), UTF_8);
|
||||||
|
String uploadType = URLDecoder.decode(request.getParameter(UPLOAD_TYPE), UTF_8);
|
||||||
|
boolean isOverwrite = Boolean.parseBoolean(URLDecoder.decode(request.getParameter(IS_OVERWRITE), UTF_8));
|
||||||
|
uploadData(request, response, absolutePathFile, destinationId, uploadType, isOverwrite);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
@SuppressWarnings("rawtypes")
|
||||||
|
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||||
|
// System.out.println("POST on LocalUploadServlet");
|
||||||
|
logger.trace("POST on LocalUploadServlet");
|
||||||
|
String absolutePathFile = request.getParameter(UPLOAD_FORM_ELEMENT);
|
||||||
|
String destinationId = request.getParameter(ID_FOLDER);
|
||||||
|
String uploadType = request.getParameter(UPLOAD_TYPE);
|
||||||
|
boolean isOverwrite = Boolean.parseBoolean(request.getParameter(IS_OVERWRITE));
|
||||||
|
uploadData(request, response, absolutePathFile, destinationId, uploadType, isOverwrite);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private void uploadData(HttpServletRequest request, HttpServletResponse response, String absolutePathFile,String destinationId,String uploadType,boolean isOverwrite) throws ServletException, IOException{
|
||||||
|
|
||||||
|
File file = null;
|
||||||
|
InputStream fileUploadIS = null;
|
||||||
|
|
||||||
|
try {
|
||||||
|
|
||||||
|
if(absolutePathFile==null || absolutePathFile.isEmpty())
|
||||||
|
throw new FileUploadException("Absolute path is null or empty");
|
||||||
|
|
||||||
|
|
||||||
|
file = new File(absolutePathFile);
|
||||||
|
|
||||||
|
if(!file.exists())
|
||||||
|
throw new FileUploadException("File dosn't exists");
|
||||||
|
|
||||||
|
fileUploadIS = FileUtils.openInputStream(file);
|
||||||
|
|
||||||
|
logger.trace("Upload servlet parameters: [uploadItem: "+file.getAbsolutePath() +", destinationId: "+destinationId +", uploadType: "+uploadType+", isOverwrite: "+isOverwrite+"]");
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error("Error processing request in upload servlet", e);
|
||||||
|
sendError(response, "Internal error: Error during request processing");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
if (file == null) {
|
||||||
|
logger.error("Error processing request in upload servlet: No file to upload");
|
||||||
|
sendError(response, "Internal error: No file to upload");
|
||||||
|
return;
|
||||||
|
}*/
|
||||||
|
|
||||||
|
if (destinationId == null) {
|
||||||
|
logger.error("Error processing request in upload servlet: No destination folder id found");
|
||||||
|
sendError(response, "Internal error: No destination folder id found");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
logger.trace("destination folder id: "+destinationId);
|
||||||
|
logger.trace("uploadType: "+uploadType);
|
||||||
|
|
||||||
|
Workspace wa = null;
|
||||||
|
try {
|
||||||
|
wa = WsUtil.getWorkspace(request.getSession());
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error("Error during workspace retrieving", e);
|
||||||
|
response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "Error processing request in upload servlet");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (wa == null) {
|
||||||
|
logger.error("Now workspace found in session");
|
||||||
|
sendError(response, "Internal error: No workspace in session");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
WorkspaceItem item;
|
||||||
|
try {
|
||||||
|
item = wa.getItem(destinationId);
|
||||||
|
} catch (ItemNotFoundException e) {
|
||||||
|
logger.error("Error, no destination folder found", e);
|
||||||
|
sendError(response, "Internal error: No destination folder found");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (item.getType() != WorkspaceItemType.FOLDER && item.getType() != WorkspaceItemType.SHARED_FOLDER) {
|
||||||
|
logger.error("Error processing request in upload servlet: Wrong destination item");
|
||||||
|
sendError(response, "Internal error: Wrong destination item");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
WorkspaceFolder destinationFolder = (WorkspaceFolder) item;
|
||||||
|
|
||||||
|
try {
|
||||||
|
//we calculate an unique name for the current destination
|
||||||
|
String itemName = "";
|
||||||
|
|
||||||
|
if(!isOverwrite)
|
||||||
|
itemName = WorkspaceUtil.getUniqueName(file.getName(), destinationFolder);
|
||||||
|
else
|
||||||
|
itemName = file.getName();
|
||||||
|
|
||||||
|
String contentType = MimeTypeUtil.getMimeType(new BufferedInputStream(fileUploadIS));
|
||||||
|
logger.trace("Content type (mime type): "+contentType + " unique name: "+itemName);
|
||||||
|
|
||||||
|
// System.out.println("Content type: "+contentType + " unique name: "+itemName);
|
||||||
|
|
||||||
|
String extension = FilenameUtils.getExtension(itemName);
|
||||||
|
logger.trace("extension: "+extension);
|
||||||
|
|
||||||
|
// System.out.println("extension: "+extension);
|
||||||
|
|
||||||
|
if(uploadType.compareTo(FILE)==0) {//IS FILE UPLOAD
|
||||||
|
|
||||||
|
boolean isZipFile = MimeTypeUtil.isZipContentType(contentType);
|
||||||
|
|
||||||
|
if(isZipFile && (extension.compareToIgnoreCase(D4ST)==0)){ //Create REPORT TEMPLATE
|
||||||
|
|
||||||
|
// String newItemName = "";
|
||||||
|
//
|
||||||
|
// if(!isOverwrite)
|
||||||
|
// newItemName = itemName.substring(0,itemName.lastIndexOf(D4ST)-1); //remove extension
|
||||||
|
// else
|
||||||
|
// newItemName = item.getName();
|
||||||
|
|
||||||
|
// System.out.println("itemwithoutext " +itemwithoutext);
|
||||||
|
|
||||||
|
String newItemName = itemName;
|
||||||
|
|
||||||
|
logger.trace("createTemplate: "+newItemName);
|
||||||
|
createTemplate(request.getSession(), wa, newItemName, FileUtils.openInputStream(file), destinationFolder, response, isOverwrite);
|
||||||
|
|
||||||
|
}else if(isZipFile && (extension.compareToIgnoreCase(D4SR)==0)){ //Create REPORT
|
||||||
|
|
||||||
|
// String newItemName = "";
|
||||||
|
//
|
||||||
|
// if(!isOverwrite)
|
||||||
|
// newItemName = itemName.substring(0,itemName.lastIndexOf(D4SR)-1); //remove extension
|
||||||
|
// else
|
||||||
|
// newItemName = item.getName();
|
||||||
|
|
||||||
|
// System.out.println("itemwithoutext " +itemwithoutext);
|
||||||
|
String newItemName = itemName;
|
||||||
|
logger.trace("createReport: "+newItemName);
|
||||||
|
createReport(request.getSession(), wa, newItemName, FileUtils.openInputStream(file), destinationFolder, response, isOverwrite);
|
||||||
|
|
||||||
|
}else{ //CREATE AN EXTERNAL FILE
|
||||||
|
|
||||||
|
createExternalFile(request.getSession(), wa, itemName, FileUtils.openInputStream(file), destinationFolder, contentType, response, isOverwrite);
|
||||||
|
}
|
||||||
|
|
||||||
|
}else {//IS ARCHIVE UPLOAD
|
||||||
|
|
||||||
|
if (MimeTypeUtil.isZipContentType(contentType)){
|
||||||
|
logger.trace("Unziping content");
|
||||||
|
UnzipUtil.unzip(destinationFolder, FileUtils.openInputStream(file), itemName);
|
||||||
|
|
||||||
|
//TODO NOTIFY UPLOAD ARCHIVE
|
||||||
|
sendMessage(response, "Archive "+absolutePathFile+" imported correctly in "+destinationFolder.getPath());
|
||||||
|
} else
|
||||||
|
createExternalFile(request.getSession(), wa, itemName, FileUtils.openInputStream(file), destinationFolder, contentType, response, isOverwrite);
|
||||||
|
}
|
||||||
|
|
||||||
|
file.delete();
|
||||||
|
} catch (InsufficientPrivilegesException e) {
|
||||||
|
logger.error("Error creating elements", e);
|
||||||
|
sendError(response, "Internal error: Insufficient privileges");
|
||||||
|
return;
|
||||||
|
} catch (InternalErrorException e) {
|
||||||
|
logger.error("Error creating elements", e);
|
||||||
|
sendError(response, "Internal error: "+e.getMessage());
|
||||||
|
return;
|
||||||
|
} catch (ItemAlreadyExistException e) {
|
||||||
|
logger.error("Error creating elements", e);
|
||||||
|
sendError(response, "Internal error: An item with that name already exists");
|
||||||
|
return;
|
||||||
|
}catch (Exception e) {
|
||||||
|
logger.error("Error creating elements", e);
|
||||||
|
sendError(response, "Internal error: An error occurred on uploading the file, try again later");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param httpSession
|
||||||
|
* @param workspace
|
||||||
|
* @param itemId
|
||||||
|
* @param destinationFolderId
|
||||||
|
*/
|
||||||
|
private void notifyUploadInSharedFolder(final HttpSession httpSession, final Workspace workspace, final String itemId, final String destinationFolderId, final boolean isOverwrite){
|
||||||
|
|
||||||
|
new Thread(){
|
||||||
|
|
||||||
|
public void run() {
|
||||||
|
|
||||||
|
WorkspaceItem sourceItem;
|
||||||
|
try {
|
||||||
|
sourceItem = workspace.getItem(itemId);
|
||||||
|
String sourceSharedId = sourceItem.getIdSharedFolder();
|
||||||
|
WorkspaceItem folderDestinationItem = workspace.getItem(destinationFolderId);
|
||||||
|
|
||||||
|
NotificationsUtil.checkSendNotifyChangedItemToShare(httpSession, sourceItem, sourceSharedId, folderDestinationItem,isOverwrite);
|
||||||
|
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error("Error in notifyUploadInSharedFolder", e);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
}.start();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void createExternalFile(HttpSession httpSession, Workspace wa, String itemName, InputStream uploadItem, WorkspaceFolder destinationFolder, String contentType, HttpServletResponse response, boolean isOverwrite) throws InternalErrorException, InsufficientPrivilegesException, ItemAlreadyExistException, IOException {
|
||||||
|
|
||||||
|
FolderItem createdItem = null;
|
||||||
|
|
||||||
|
if(!isOverwrite){
|
||||||
|
//we need to recalculate the item name
|
||||||
|
itemName = WorkspaceUtil.getUniqueName(itemName, destinationFolder);
|
||||||
|
createdItem = WorkspaceUtil.createExternalFile(destinationFolder, itemName, "", contentType, uploadItem);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
createdItem = overwriteItem(wa, itemName, uploadItem, destinationFolder); //CASE OVERWRITE
|
||||||
|
|
||||||
|
if(createdItem!=null){
|
||||||
|
notifyUploadInSharedFolder(httpSession,wa,createdItem.getId(),destinationFolder.getId(), isOverwrite);
|
||||||
|
|
||||||
|
sendMessage(response, "File "+createdItem.getName()+" imported correctly in "+destinationFolder.getPath());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
sendError(response,"Internal error: Workspace Item Not Found");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private FolderItem overwriteItem(Workspace wa, String itemName, InputStream fileData, WorkspaceFolder destinationFolder){
|
||||||
|
|
||||||
|
FolderItem overwriteItem = null;
|
||||||
|
|
||||||
|
try {
|
||||||
|
logger.trace("case overwriting item.. "+itemName);
|
||||||
|
overwriteItem = (FolderItem) wa.find(itemName, destinationFolder.getId());
|
||||||
|
logger.trace("overwriteItem item was found, id is: "+overwriteItem.getId());
|
||||||
|
wa.updateItem(overwriteItem.getId(), fileData);
|
||||||
|
logger.trace("updateItem with id: "+overwriteItem.getId()+ ", is completed");
|
||||||
|
} catch (ItemNotFoundException e) {
|
||||||
|
logger.error("Error in createExternalFile, ItemNotFoundException", e);
|
||||||
|
} catch (WrongItemTypeException e) {
|
||||||
|
logger.error("Error in createExternalFile, WrongItemTypeException", e);
|
||||||
|
} catch (WorkspaceFolderNotFoundException e) {
|
||||||
|
logger.error("Error in createExternalFile, WorkspaceFolderNotFoundException", e);
|
||||||
|
} catch (WrongDestinationException e) {
|
||||||
|
logger.error("Error in createExternalFile, WrongDestinationException", e);
|
||||||
|
} catch (InsufficientPrivilegesException e) {
|
||||||
|
logger.error("Error in createExternalFile, InsufficientPrivilegesException", e);
|
||||||
|
} catch (ItemAlreadyExistException e) {
|
||||||
|
logger.error("Error in createExternalFile, ItemAlreadyExistException", e);
|
||||||
|
} catch (InternalErrorException e) {
|
||||||
|
logger.error("Error in createExternalFile, InternalErrorException", e);
|
||||||
|
}catch (Exception e) {
|
||||||
|
logger.error("Error in createExternalFile, Exception", e);
|
||||||
|
}
|
||||||
|
|
||||||
|
return overwriteItem;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void createReport(HttpSession httpSession, Workspace wa, String itemName, InputStream stream, WorkspaceFolder destinationFolder, HttpServletResponse response, boolean isOverwrite) throws InsufficientPrivilegesException, ItemAlreadyExistException, InternalErrorException, IOException{
|
||||||
|
|
||||||
|
try {
|
||||||
|
|
||||||
|
Report report = null;
|
||||||
|
|
||||||
|
if(!isOverwrite){
|
||||||
|
itemName = WorkspaceUtil.getUniqueName(itemName, destinationFolder);
|
||||||
|
report = wa.createReport(itemName, "", Calendar.getInstance(), Calendar.getInstance(), "", "", "", 0, "", stream, destinationFolder.getId());
|
||||||
|
|
||||||
|
notifyUploadInSharedFolder(httpSession,wa,report.getId(),destinationFolder.getId(), isOverwrite);
|
||||||
|
|
||||||
|
sendMessage(response, "File "+report.getName()+" imported correctly in "+destinationFolder.getPath());
|
||||||
|
}
|
||||||
|
else{ //CASE OVERWRITE
|
||||||
|
FolderItem rep = overwriteItem(wa, itemName, stream, destinationFolder);
|
||||||
|
|
||||||
|
if(rep!=null){
|
||||||
|
|
||||||
|
notifyUploadInSharedFolder(httpSession,wa,rep.getId(),destinationFolder.getId(), isOverwrite);
|
||||||
|
|
||||||
|
sendMessage(response, "File "+rep.getName()+" imported correctly in "+destinationFolder.getPath());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
sendError(response,"Internal error: Workspace Item Not Found");
|
||||||
|
|
||||||
|
}
|
||||||
|
} catch (WrongDestinationException e) {
|
||||||
|
logger.error("Error creating elements", e);
|
||||||
|
sendError(response, "Internal error: Wrong Destination");
|
||||||
|
} catch (WorkspaceFolderNotFoundException e) {
|
||||||
|
logger.error("Error creating elements", e);
|
||||||
|
sendError(response, "Internal error: Workspace Folder Not Found");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void createTemplate(HttpSession httpSession, Workspace wa, String itemName, InputStream stream, WorkspaceFolder destinationFolder, HttpServletResponse response, boolean isOverwrite) throws InsufficientPrivilegesException, ItemAlreadyExistException, InternalErrorException, IOException{
|
||||||
|
|
||||||
|
try {
|
||||||
|
|
||||||
|
ReportTemplate template = null;
|
||||||
|
|
||||||
|
if(!isOverwrite){
|
||||||
|
itemName = WorkspaceUtil.getUniqueName(itemName, destinationFolder);
|
||||||
|
template = wa.createReportTemplate(itemName, "", Calendar.getInstance(), Calendar.getInstance(), "", "", 0, "", stream, destinationFolder.getId());
|
||||||
|
|
||||||
|
notifyUploadInSharedFolder(httpSession,wa,template.getId(),destinationFolder.getId(), isOverwrite);
|
||||||
|
|
||||||
|
sendMessage(response, "File "+template.getName()+" imported correctly in "+destinationFolder.getPath());
|
||||||
|
|
||||||
|
}else{ //CASE OVERWRITE
|
||||||
|
FolderItem rep = overwriteItem(wa, itemName, stream, destinationFolder);
|
||||||
|
|
||||||
|
if(rep!=null){
|
||||||
|
|
||||||
|
notifyUploadInSharedFolder(httpSession,wa,rep.getId(),destinationFolder.getId(), isOverwrite);
|
||||||
|
|
||||||
|
sendMessage(response, "File "+rep.getName()+" imported correctly in "+destinationFolder.getPath());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
sendError(response,"Internal error: Workspace Item Not Found");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (WrongDestinationException e) {
|
||||||
|
logger.error("Error creating elements", e);
|
||||||
|
sendError(response, "Internal error: Wrong Destination");
|
||||||
|
} catch (WorkspaceFolderNotFoundException e) {
|
||||||
|
logger.error("Error creating elements", e);
|
||||||
|
sendError(response, "Internal error: Workspace Folder Not Found");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
protected void sendError(HttpServletResponse response, String message) throws IOException
|
||||||
|
{
|
||||||
|
response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
|
||||||
|
HandlerResultMessage resultMessage = HandlerResultMessage.errorResult(message);
|
||||||
|
response.getWriter().write(resultMessage.toString());
|
||||||
|
response.flushBuffer();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void sendMessage(HttpServletResponse response, String message) throws IOException
|
||||||
|
{
|
||||||
|
response.setStatus(HttpServletResponse.SC_ACCEPTED);
|
||||||
|
HandlerResultMessage resultMessage = HandlerResultMessage.okResult(message);
|
||||||
|
response.getWriter().write(resultMessage.toString());
|
||||||
|
response.flushBuffer();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void sendWarnMessage(HttpServletResponse response, String message) throws IOException
|
||||||
|
{
|
||||||
|
response.setStatus(HttpServletResponse.SC_ACCEPTED);
|
||||||
|
HandlerResultMessage resultMessage = HandlerResultMessage.warnResult(message);
|
||||||
|
response.getWriter().write(resultMessage.toString());
|
||||||
|
response.flushBuffer();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -116,7 +116,7 @@ public class UploadServlet extends HttpServlet {
|
||||||
while (it.hasNext()) {
|
while (it.hasNext()) {
|
||||||
FileItem item = (FileItem) it.next();
|
FileItem item = (FileItem) it.next();
|
||||||
|
|
||||||
if (!item.isFormField() && UPLOAD_FORM_ELEMENT.equals(item.getFieldName())) {
|
if (UPLOAD_FORM_ELEMENT.equals(item.getFieldName())) {
|
||||||
uploadItem = item;
|
uploadItem = item;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -74,10 +74,10 @@ public class WsUtil {
|
||||||
|
|
||||||
/*USE ANOTHER ACCOUNT (OTHERWHISE BY TEST_USER) FOR RUNNING
|
/*USE ANOTHER ACCOUNT (OTHERWHISE BY TEST_USER) FOR RUNNING
|
||||||
* COMMENT THIS IN DEVELOP ENVIROMENT (UNCOMMENT IN PRODUCTION)*/
|
* COMMENT THIS IN DEVELOP ENVIROMENT (UNCOMMENT IN PRODUCTION)*/
|
||||||
user=TEST_USER;
|
// user=TEST_USER;
|
||||||
|
|
||||||
//UNCOMMENT THIS IN DEVELOP ENVIROMENT
|
//UNCOMMENT THIS IN DEVELOP ENVIROMENT
|
||||||
// user = "francesco.mangiacrapa";
|
user = "francesco.mangiacrapa";
|
||||||
|
|
||||||
logger.warn("WORKSPACE PORTLET STARTING IN TEST MODE - NO USER FOUND - PORTLETS STARTING WITH FOLLOWING SETTINGS:");
|
logger.warn("WORKSPACE PORTLET STARTING IN TEST MODE - NO USER FOUND - PORTLETS STARTING WITH FOLLOWING SETTINGS:");
|
||||||
logger.warn("session id: "+sessionID);
|
logger.warn("session id: "+sessionID);
|
||||||
|
|
Loading…
Reference in New Issue