Workaround implemented see at

https://support.d4science.org/issues/19671#note-17
This commit is contained in:
Francesco Mangiacrapa 2020-09-25 11:04:18 +02:00
parent b2840cdc3d
commit ccb9edf22d
10 changed files with 88 additions and 68 deletions

View File

@ -1,12 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" output="target/workspace-explorer-app-1.3.1-SNAPSHOT/WEB-INF/classes" path="src/main/java">
<classpathentry kind="src" output="target/workspace-explorer-app-1.3.1/WEB-INF/classes" path="src/main/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry excluding="**" kind="src" output="target/workspace-explorer-app-1.3.1-SNAPSHOT/WEB-INF/classes" path="src/main/resources">
<classpathentry excluding="**" kind="src" output="target/workspace-explorer-app-1.3.1/WEB-INF/classes" path="src/main/resources">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
@ -35,5 +35,5 @@
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="target/workspace-explorer-app-1.3.1-SNAPSHOT/WEB-INF/classes"/>
<classpathentry kind="output" path="target/workspace-explorer-app-1.3.1/WEB-INF/classes"/>
</classpath>

View File

@ -1,6 +1,6 @@
eclipse.preferences.version=1
jarsExcludedFromWebInfLib=
lastWarOutDir=/home/francesco/git/workspace-explorer-app/target/workspace-explorer-app-1.3.1-SNAPSHOT
lastWarOutDir=/home/francesco-mangiacrapa/git/workspace-explorer-app/target/workspace-explorer-app-1.3.1
launchConfigExternalUrlPrefix=
warSrcDir=src/main/webapp
warSrcDirIsOutput=false

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?><project-modules id="moduleCoreId" project-version="1.5.0">
<wb-module deploy-name="workspace-explorer-app-1.3.1-SNAPSHOT">
<wb-module deploy-name="workspace-explorer-app-1.3.1">
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/resources"/>
<wb-resource deploy-path="/" source-path="/target/m2e-wtp/web-resources"/>

View File

@ -12,7 +12,7 @@
<groupId>org.gcube.portlets.user</groupId>
<artifactId>workspace-explorer-app</artifactId>
<version>1.3.1</version>
<version>1.3.1-SNAPSHOT</version>
<packaging>war</packaging>
<description>
@ -118,7 +118,7 @@
<dependency>
<groupId>org.gcube.common</groupId>
<artifactId>storagehub-client-wrapper</artifactId>
<version>[1.0.0, 2.0.0-SNAPSHOT)</version>
<version>[1.0.0-SNAPSHOT, 2.0.0-SNAPSHOT)</version>
<scope>compile</scope>
</dependency>

View File

@ -8,6 +8,7 @@ import java.util.List;
import org.gcube.portlets.user.workspaceexplorerapp.client.download.DownloadType;
import org.gcube.portlets.user.workspaceexplorerapp.client.event.DownloadItemEvent;
import org.gcube.portlets.user.workspaceexplorerapp.client.event.LoadFolderEvent;
import org.gcube.portlets.user.workspaceexplorerapp.client.grid.DisplayField;
import com.google.gwt.core.client.GWT;
@ -64,6 +65,9 @@ public class WorkspaceExplorerAppMainPanel extends Composite {
@UiField
MaterialNavSection we_nav_right;
@UiField
MaterialLink home_we;
@UiField
MaterialLink download_we;
@ -116,6 +120,18 @@ public class WorkspaceExplorerAppMainPanel extends Composite {
});
we_nav_right.add(order);
home_we.addClickHandler(new ClickHandler() {
/* (non-Javadoc)
* @see com.google.gwt.event.dom.client.ClickHandler#onClick(com.google.gwt.event.dom.client.ClickEvent)
*/
@Override
public void onClick(ClickEvent event) {
WorkspaceExplorerAppMainPanel.this.handlerManager.fireEvent(new LoadFolderEvent(null));
}
});
download_we.addClickHandler(new ClickHandler() {
/* (non-Javadoc)

View File

@ -63,6 +63,8 @@
<g:Image styleName="{style.navigation_explorer}" url="img/d4science_workspace_logo_180.png"
ui:field="d4science_workspace_logo_180" title="D4Science Workspace Folder Explorer"
altText="D4Science Workspace Folder Explorer" />
<m:MaterialLink iconType="HOME" iconPosition="LEFT"
textColor="blue" text="Home" ui:field="home_we" />
<m:MaterialLink iconType="OPEN_IN_NEW" iconPosition="LEFT"
textColor="blue" text="Open" ui:field="show_we" />
<m:MaterialLink iconType="INBOX" iconPosition="LEFT"

View File

@ -62,8 +62,8 @@ public class WorkspaceResourcesExplorerPanel extends DockPanel implements HasWor
private WorkspaceExplorer wsExplorer;
private ScrollPanel centerScrollable = new ScrollPanel();
// private ScrollPanel southPanel = new ScrollPanel();
private String folderId;
private String folderName;
private Item baseFolder;
public static final DisplayField[] displayFields = new DisplayField[]{DisplayField.ICON, DisplayField.NAME, DisplayField.OWNER, DisplayField.CREATION_DATE};
/**
@ -89,7 +89,6 @@ public class WorkspaceResourcesExplorerPanel extends DockPanel implements HasWor
* @throws Exception the exception
*/
private void initExplorer(HandlerManager eventBus, String folderId, String folderName, ItemType[] selectableTypes, ItemType[] showableTypes) throws Exception{
this.folderId = folderId;
this.folderName = folderName;
this.eventBus = eventBus;
this.breadcrumbs = new Breadcrumbs(eventBus);
@ -97,6 +96,8 @@ public class WorkspaceResourcesExplorerPanel extends DockPanel implements HasWor
wsExplorer = new WorkspaceExplorer(eventBus, showableTypes, selectableTypes, displayFields);
Item item = new Item(folderId, folderName, true);
this.baseFolder = item;
wsExplorer.setBaseFolder(item);
if(folderId!=null && !folderId.isEmpty())
wsExplorer.loadFolder(item);
initPanel("");
@ -152,10 +153,8 @@ public class WorkspaceResourcesExplorerPanel extends DockPanel implements HasWor
GWT.log("LoadFolderEvent fired");
if(loadFolderEvent.getTargetFolder()==null)
return;
Item item = loadFolderEvent.getTargetFolder()==null?baseFolder:loadFolderEvent.getTargetFolder();
Item item = loadFolderEvent.getTargetFolder();
if(item.isFolder()){
try {
wsExplorer.loadFolder(item);
@ -199,20 +198,6 @@ public class WorkspaceResourcesExplorerPanel extends DockPanel implements HasWor
PopupContextMenu popupCM = new PopupContextMenu(true, eventBus, rightClickItemEvent.getItem());
popupCM.showPopup(rightClickItemEvent.getXPos(), Window.getScrollTop()+rightClickItemEvent.getYPos());
/*final PopupPanel contextMenu = new PopupPanel(true);
contextMenu.getElement().getStyle().setBackgroundColor("#F5F5F5");
Navigation nav = new Navigation(eventBus, rightClickItemEvent.getItem());
nav.addCommandOnDownloadClick(new Command() {
@Override
public void execute() {
contextMenu.hide();
}
});
contextMenu.add(nav);
contextMenu.setPopupPosition(rightClickItemEvent.getXPos(), Window.getScrollTop()+rightClickItemEvent.getYPos());
contextMenu.show();*/
}
}
});
@ -259,26 +244,6 @@ public class WorkspaceResourcesExplorerPanel extends DockPanel implements HasWor
default:
break;
}
/*final NewBrowserWindow newBW = NewBrowserWindow.open("", "_self", "");
WorkspaceExplorerAppConstants.workspaceNavigatorService.getPublicLinkForItemId(itemId, new AsyncCallback<String>() {
@Override
public void onFailure(Throwable caught) {
Window.alert(caught.getMessage());
}
@Override
public void onSuccess(String url) {
if(url!=null){
newBW.setUrl(url);
}else
Window.alert("Sorry, the item selected is not available for download");
}
});*/
}
}
});
@ -311,12 +276,17 @@ public class WorkspaceResourcesExplorerPanel extends DockPanel implements HasWor
GWT.log("Reload Parent Breadcrumb: [Item id: "+itemIdentifier+"]");
WorkspaceExplorerAppConstants.workspaceNavigatorService.getBreadcrumbsByItemIdentifierToParentLimit(itemIdentifier, folderId, includeItemAsParent, new AsyncCallback<List<Item>>() {
WorkspaceExplorerAppConstants.workspaceNavigatorService.getBreadcrumbsByItemIdentifierToParentLimit(itemIdentifier, baseFolder.getId(), includeItemAsParent, new AsyncCallback<List<Item>>() {
@Override
public void onFailure(Throwable caught) {
GWT.log(caught.getMessage());
wsExplorer.setAlert(caught.getMessage(), AlertType.ERROR);
Item goToBaseFolder = null;
//I'm adding go to folder only if is a sub-folder of baseFolder
if(itemIdentifier!=baseFolder.getId())
goToBaseFolder = baseFolder;
//wsExplorer.setAlert(caught.getMessage(), AlertType.ERROR, goToBaseFolder);
}
@Override
@ -329,21 +299,14 @@ public class WorkspaceResourcesExplorerPanel extends DockPanel implements HasWor
});
}
/**
* Refresh root folder view.
*/
public void refreshRootFolderView(){
Item item = new Item(folderId, folderName, true);
eventBus.fireEvent(new LoadFolderEvent(item));
//Item item = new Item(baseFolder.getId(), folderName, true);
eventBus.fireEvent(new LoadFolderEvent(baseFolder));
}
// /**
// * Clear more info.
// */
// private void clearMoreInfo(){
// southPanel.clear();
// }
/**
* Inits the panel.

View File

@ -1,5 +1,4 @@
package org.gcube.portlets.user.workspaceexplorerapp.client.view;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
@ -8,6 +7,7 @@ import java.util.Set;
import org.gcube.portlets.user.workspaceexplorerapp.client.Util;
import org.gcube.portlets.user.workspaceexplorerapp.client.WorkspaceExplorerApp;
import org.gcube.portlets.user.workspaceexplorerapp.client.WorkspaceExplorerAppConstants;
import org.gcube.portlets.user.workspaceexplorerapp.client.event.LoadFolderEvent;
import org.gcube.portlets.user.workspaceexplorerapp.client.event.RootLoadedEvent;
import org.gcube.portlets.user.workspaceexplorerapp.client.grid.DisplayField;
import org.gcube.portlets.user.workspaceexplorerapp.client.grid.ItemsTable;
@ -17,11 +17,14 @@ import org.gcube.portlets.user.workspaceexplorerapp.shared.Item;
import org.gcube.portlets.user.workspaceexplorerapp.shared.ItemType;
import com.github.gwtbootstrap.client.ui.Alert;
import com.github.gwtbootstrap.client.ui.Button;
import com.github.gwtbootstrap.client.ui.constants.AlertType;
import com.github.gwtbootstrap.client.ui.constants.ButtonType;
import com.google.gwt.core.client.GWT;
import com.google.gwt.dom.client.Style.Unit;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.event.shared.HandlerManager;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.HorizontalPanel;
@ -60,6 +63,7 @@ public class WorkspaceExplorer implements ShowableTypes, SelectableTypes{
private ItemsTable itTables;
private DisplayField[] displayFields;
private HandlerManager eventBus;
private Item baseFolder;
/**
@ -100,11 +104,25 @@ public class WorkspaceExplorer implements ShowableTypes, SelectableTypes{
*
* @param html the html
* @param type the type
* @param goToFolder the go to folder
*/
public void setAlert(String html, AlertType type){
public void setAlert(String html, AlertType type, final Item goToFolder){
explorerPanel.clear();
alert.setHTML(html);
alert.setType(type);
if(goToFolder!=null) {
Button buttGoToHome = new Button("Go to Home");
buttGoToHome.setType(ButtonType.LINK);
buttGoToHome.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
eventBus.fireEvent(new LoadFolderEvent(goToFolder));
}
});
alert.add(buttGoToHome);
}
alert.setClose(false);
explorerPanel.add(alert);
}
@ -140,9 +158,9 @@ public class WorkspaceExplorer implements ShowableTypes, SelectableTypes{
WorkspaceExplorerAppConstants.workspaceNavigatorService.getRoot(showableTypesParam, purgeEmpyFolders, filterCriteria, new AsyncCallback<Item>() {
public void onFailure(Throwable caught) {
Window.alert(caught.getMessage());
setAlert(caught.getMessage(), AlertType.ERROR);
//Window.alert(caught.getMessage());
GWT.log("Error loading workspace tree from server",caught);
setAlert(caught.getMessage(), AlertType.ERROR, null);
}
public void onSuccess(Item item) {
@ -186,9 +204,9 @@ public class WorkspaceExplorer implements ShowableTypes, SelectableTypes{
@Override
public void onFailure(Throwable caught) {
Window.alert(caught.getMessage());
setAlert(caught.getMessage(), AlertType.ERROR);
//Window.alert(caught.getMessage());
GWT.log("Error loading workspace folder from server",caught);
setAlert(caught.getMessage(), AlertType.ERROR, null);
}
@Override
@ -226,9 +244,10 @@ public class WorkspaceExplorer implements ShowableTypes, SelectableTypes{
@Override
public void onFailure(Throwable caught) {
Window.alert(caught.getMessage());
setAlert(caught.getMessage(), AlertType.ERROR);
//Window.alert(caught.getMessage());
GWT.log("Error loading workspace folder from server",caught);
setAlert(caught.getMessage(), AlertType.ERROR, null);
}
@Override
@ -267,7 +286,18 @@ public class WorkspaceExplorer implements ShowableTypes, SelectableTypes{
// explorerPanel.add(itTables.getCellTable());
GWT.log("added item: "+item.getName() +", to Explorer");
}
/**
* Sets the base folder.
*
* @param item the new base folder
*/
public void setBaseFolder(Item baseFolder) {
this.baseFolder = baseFolder;
}
/**
* Gets the panel.
*
@ -358,4 +388,5 @@ public class WorkspaceExplorer implements ShowableTypes, SelectableTypes{
this.showableTypes.clear();
if (showableTypes!=null) for (ItemType type:showableTypes) this.showableTypes.add(type);
}
}

View File

@ -145,6 +145,13 @@ public class WorkspaceExplorerAppServiceImpl extends RemoteServiceServlet implem
} catch (Exception e) {
logger.error("Error during item retrieving", e);
if(e.getMessage()!=null && e.getMessage().startsWith("Insufficent Privileges")) {
String erroMsg = item.getName()!=null?"The folder '"+item.getName()+"'":"This folder";
erroMsg+= " is not accessible as an anonymous user!";
throw new WorkspaceNavigatorServiceException(erroMsg);
}
throw new WorkspaceNavigatorServiceException("Sorry, an error occurred when performing get folder. Does it still exist?");
}
@ -358,7 +365,7 @@ public class WorkspaceExplorerAppServiceImpl extends RemoteServiceServlet implem
} catch (Exception e) {
logger.error("Error in get List Parents By Item Identifier ", e);
throw new Exception("Sorry, an error occurred during path retrieving!");
throw new Exception("Sorry, I'm not able to load the location of the folder. Does it still exist?");
}
}

1
src/test/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
/resources/