fixed #1333
git-svn-id: http://svn.d4science-ii.research-infrastructures.eu/gcube/trunk/portlets/user/workspace-tree-widget@122156 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
a6bb44e87c
commit
b6c28417e6
|
@ -986,75 +986,6 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
|
|||
uploadStream.center();
|
||||
}
|
||||
});
|
||||
|
||||
/*
|
||||
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;
|
||||
if (normalizedFileName.contains("\\")) {
|
||||
normalizedFileName = normalizedFileName.substring(normalizedFileName.lastIndexOf("\\")+1); //remove C:\fakepath\ if exists
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
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);
|
||||
}
|
||||
});*/
|
||||
|
||||
|
||||
|
||||
eventBus.addHandler(CompletedFileUploadEvent.TYPE, new CompletedFileUploadEventHandler() {
|
||||
|
||||
|
|
|
@ -1929,21 +1929,58 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
|
|||
workspaceLogger.debug("get List Parents By Item Identifier "+ itemIdentifier +", include Item As (Last) Parent: "+includeItemAsParent);
|
||||
|
||||
if(itemIdentifier==null)
|
||||
return new ArrayList<FileModel>();
|
||||
return new ArrayList<FileModel>(); //empty list
|
||||
|
||||
try {
|
||||
|
||||
Workspace workspace = getWorkspace();
|
||||
GWTWorkspaceBuilder builder = getGWTWorkspaceBuilder();
|
||||
List<WorkspaceItem> parents = workspace.getParentsById(itemIdentifier);
|
||||
WorkspaceItem lastItem = parents.get(parents.size()-1);
|
||||
workspaceLogger.debug("parents returned by HL, size: "+ parents.size());
|
||||
String nameSpecialFolder = getNameForSpecialFolder();
|
||||
|
||||
switch (parents.size()) {
|
||||
case 0: // itemIdentifier is ROOT
|
||||
workspaceLogger.trace("itemIdentifier isRoot...");
|
||||
if (includeItemAsParent) { //ADDIND ROOT
|
||||
WorkspaceFolder wsFolder =(WorkspaceFolder) workspace.getItem(itemIdentifier);
|
||||
FolderModel root = builder.buildGXTFolderModelItemHandleSpecialFolder(wsFolder, null, nameSpecialFolder);
|
||||
List<FileModel> listParents = new ArrayList<FileModel>(1);
|
||||
listParents.add(root);
|
||||
// workspaceLogger.trace("returning: "+listParents.toString());
|
||||
return listParents;
|
||||
}
|
||||
else{
|
||||
workspaceLogger.trace("returning empty list");
|
||||
return new ArrayList<FileModel>(); // empty list
|
||||
}
|
||||
|
||||
case 1: //itemIdentifier is first level from root
|
||||
workspaceLogger.trace("itemIdentifier is first level...");
|
||||
List<FileModel> listParents = new ArrayList<FileModel>();
|
||||
WorkspaceFolder wsRootFolder = (WorkspaceFolder) parents.get(0); //isRoot
|
||||
FolderModel root = builder.buildGXTFolderModelItemHandleSpecialFolder(wsRootFolder, null, nameSpecialFolder);
|
||||
FolderModel parent = null;
|
||||
if(includeItemAsParent){
|
||||
WorkspaceFolder wsFolder1 =(WorkspaceFolder) workspace.getItem(itemIdentifier); //root
|
||||
parent =builder.buildGXTFolderModelItemHandleSpecialFolder(wsFolder1, null, nameSpecialFolder);
|
||||
}
|
||||
listParents.add(root);
|
||||
if(parent!=null)
|
||||
listParents.add(parent);
|
||||
// workspaceLogger.trace("returning: "+listParents.toString());
|
||||
return listParents;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
WorkspaceItem lastItem = parents.get(parents.size()-1);
|
||||
FileModel[] arrayParents;
|
||||
|
||||
//CONVERTING LAST ELEMENT IF NECESSARY
|
||||
workspaceLogger.trace("converting last element..");
|
||||
if(includeItemAsParent==true && lastItem.isFolder()){ //FIX BUG #298
|
||||
if(includeItemAsParent && lastItem.isFolder()){ //FIX BUG #298
|
||||
arrayParents = new FileModel[parents.size()];
|
||||
workspaceLogger.debug("including last item into path: "+lastItem.getName());
|
||||
arrayParents[parents.size()-1] = builder.buildGXTFolderModelItemHandleSpecialFolder((WorkspaceFolder) lastItem, null, nameSpecialFolder);
|
||||
|
@ -1956,21 +1993,16 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
|
|||
WorkspaceFolder wsFolder = (WorkspaceFolder) parents.get(i);
|
||||
arrayParents[i] = builder.buildGXTFolderModelItemHandleSpecialFolder(wsFolder, null, nameSpecialFolder);
|
||||
}
|
||||
|
||||
// Collections.reverse(listParents);
|
||||
|
||||
|
||||
//SET PARENTS
|
||||
workspaceLogger.trace("setting parents..");
|
||||
for(int i=0; i<arrayParents.length-1; i++){
|
||||
|
||||
FileModel parent = arrayParents[i];
|
||||
FileModel fileModel = arrayParents[i+1];
|
||||
fileModel.setParentFileModel(parent);
|
||||
}
|
||||
|
||||
// workspaceLogger.trace("list parents returning size: "+arrayParents.length);
|
||||
// return new ArrayList<FileModel>(Arrays.asList(arrayParents));
|
||||
|
||||
workspaceLogger.trace("list parents returning size: "+arrayParents.length);
|
||||
if(arrayParents[0]==null){ //EXIT BY BREAK IN CASE OF SPECIAL FOLDER
|
||||
List<FileModel> breadcrumbs = new ArrayList<FileModel>(arrayParents.length-1);
|
||||
|
|
Loading…
Reference in New Issue