merged with private version at 174223
git-svn-id: http://svn.d4science-ii.research-infrastructures.eu/gcube/trunk/portlets/user/workspace-tree-widget@174458 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
e90cb8f26d
commit
da556014ae
|
@ -1,9 +1,37 @@
|
||||||
<ReleaseNotes>
|
<ReleaseNotes>
|
||||||
|
<Changeset component="org.gcube.portlets-user.workspace-portlet-tree.6-23-0"
|
||||||
|
date="${buildDate}">
|
||||||
|
<Change>[Task #12521] Migrate the tree view
|
||||||
|
</Change>
|
||||||
|
<Change>[Task #12504] Migrate the Grid View to StorageHub
|
||||||
|
</Change>
|
||||||
|
<Change>[Task #12556] Migrate the Download facility to Storage Hub
|
||||||
|
</Change>
|
||||||
|
<Change>[Task #12504] Migrate Create folder facility and its
|
||||||
|
notifications to StorageHub
|
||||||
|
</Change>
|
||||||
|
<Change>[Task #12601] Migrate Download Folder facility to StorageHub
|
||||||
|
</Change>
|
||||||
|
<Change>[Task #12604] Migrated Move operation to StorageHub</Change>
|
||||||
|
<Change>[Task #12603] Migrated Copy operation to StorageHub</Change>
|
||||||
|
<Change>[Task #12603] Migrated Rename facility to StorageHub</Change>
|
||||||
|
<Change>[Task #12603] Migrated Public Link facility to StorageHub
|
||||||
|
</Change>
|
||||||
|
<Change>[Task #12664] Migrated Versions facility to StorageHub
|
||||||
|
</Change>
|
||||||
|
<Change>[Incident #12923] Workspace public folders are shown as
|
||||||
|
regular shared folders
|
||||||
|
</Change>
|
||||||
|
<Change>[Incident #12922] Workspace get link not working
|
||||||
|
</Change>
|
||||||
|
</Changeset>
|
||||||
<Changeset component="org.gcube.portlets-user.workspace-portlet-tree.6-22-0"
|
<Changeset component="org.gcube.portlets-user.workspace-portlet-tree.6-22-0"
|
||||||
date="2018-09-14">
|
date="2018-09-14">
|
||||||
<Change>[Task #12489] Migrate delete operation to StorageHub
|
<Change>[Task #12489] Migrate delete operation to StorageHub
|
||||||
</Change>
|
</Change>
|
||||||
<Change>integrated CLARIN Switchboard with service endpoint query for Switchboard service discovery</Change>
|
<Change>integrated CLARIN Switchboard with service endpoint query for
|
||||||
|
Switchboard service discovery
|
||||||
|
</Change>
|
||||||
</Changeset>
|
</Changeset>
|
||||||
<Changeset component="org.gcube.portlets-user.workspace-portlet-tree.6-21-1"
|
<Changeset component="org.gcube.portlets-user.workspace-portlet-tree.6-21-1"
|
||||||
date="2018-07-02">
|
date="2018-07-02">
|
||||||
|
|
4
pom.xml
4
pom.xml
|
@ -10,7 +10,7 @@
|
||||||
|
|
||||||
<groupId>org.gcube.portlets.user</groupId>
|
<groupId>org.gcube.portlets.user</groupId>
|
||||||
<artifactId>workspace-tree-widget</artifactId>
|
<artifactId>workspace-tree-widget</artifactId>
|
||||||
<version>6.22.0-SNAPSHOT</version>
|
<version>6.23.0-SNAPSHOT</version>
|
||||||
<name>gCube Workspace Tree Widget</name>
|
<name>gCube Workspace Tree Widget</name>
|
||||||
<description>
|
<description>
|
||||||
gCube Workspace Tree Widget is a widget to navigate and interact with gCube Workspace
|
gCube Workspace Tree Widget is a widget to navigate and interact with gCube Workspace
|
||||||
|
@ -188,7 +188,7 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.gcube.portlets.widgets</groupId>
|
<groupId>org.gcube.portlets.widgets</groupId>
|
||||||
<artifactId>workspace-explorer</artifactId>
|
<artifactId>workspace-explorer</artifactId>
|
||||||
<version>[1.6.0-SNAPSHOT,2.0.0-SNAPSHOT)</version>
|
<version>[2.0.0-SNAPSHOT, 3.0.0-SNAPSHOT)</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- HOME LIBRARY -->
|
<!-- HOME LIBRARY -->
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package org.gcube.portlets.user.workspace.client;
|
package org.gcube.portlets.user.workspace.client;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -24,8 +25,8 @@ import org.gcube.portlets.user.workspace.client.event.CheckItemLockedBySyncEvent
|
||||||
import org.gcube.portlets.user.workspace.client.event.CheckItemLockedBySyncEventHandler;
|
import org.gcube.portlets.user.workspace.client.event.CheckItemLockedBySyncEventHandler;
|
||||||
import org.gcube.portlets.user.workspace.client.event.CompletedFileUploadEvent;
|
import org.gcube.portlets.user.workspace.client.event.CompletedFileUploadEvent;
|
||||||
import org.gcube.portlets.user.workspace.client.event.CompletedFileUploadEventHandler;
|
import org.gcube.portlets.user.workspace.client.event.CompletedFileUploadEventHandler;
|
||||||
import org.gcube.portlets.user.workspace.client.event.CopytemEvent;
|
import org.gcube.portlets.user.workspace.client.event.CopyItemsEvent;
|
||||||
import org.gcube.portlets.user.workspace.client.event.CopytemEventHandler;
|
import org.gcube.portlets.user.workspace.client.event.CopyItemsEventHandler;
|
||||||
import org.gcube.portlets.user.workspace.client.event.CreateSharedFolderEvent;
|
import org.gcube.portlets.user.workspace.client.event.CreateSharedFolderEvent;
|
||||||
import org.gcube.portlets.user.workspace.client.event.CreateSharedFolderEventHandler;
|
import org.gcube.portlets.user.workspace.client.event.CreateSharedFolderEventHandler;
|
||||||
import org.gcube.portlets.user.workspace.client.event.CreateUrlEvent;
|
import org.gcube.portlets.user.workspace.client.event.CreateUrlEvent;
|
||||||
|
@ -34,6 +35,8 @@ import org.gcube.portlets.user.workspace.client.event.DeleteItemEvent;
|
||||||
import org.gcube.portlets.user.workspace.client.event.DeleteItemEventHandler;
|
import org.gcube.portlets.user.workspace.client.event.DeleteItemEventHandler;
|
||||||
import org.gcube.portlets.user.workspace.client.event.DeleteSmartFolderEvent;
|
import org.gcube.portlets.user.workspace.client.event.DeleteSmartFolderEvent;
|
||||||
import org.gcube.portlets.user.workspace.client.event.DeleteSmartFolderEventHandler;
|
import org.gcube.portlets.user.workspace.client.event.DeleteSmartFolderEventHandler;
|
||||||
|
import org.gcube.portlets.user.workspace.client.event.DragOnTreeMoveItemEvent;
|
||||||
|
import org.gcube.portlets.user.workspace.client.event.DragOnTreeMoveItemEventHandler;
|
||||||
import org.gcube.portlets.user.workspace.client.event.EditUserPermissionEvent;
|
import org.gcube.portlets.user.workspace.client.event.EditUserPermissionEvent;
|
||||||
import org.gcube.portlets.user.workspace.client.event.EditUserPermissionEventHandler;
|
import org.gcube.portlets.user.workspace.client.event.EditUserPermissionEventHandler;
|
||||||
import org.gcube.portlets.user.workspace.client.event.ExecuteDataMinerTaskEvent;
|
import org.gcube.portlets.user.workspace.client.event.ExecuteDataMinerTaskEvent;
|
||||||
|
@ -57,16 +60,15 @@ import org.gcube.portlets.user.workspace.client.event.GetShareLinkEvent;
|
||||||
import org.gcube.portlets.user.workspace.client.event.GetSharedLinkEventHandler;
|
import org.gcube.portlets.user.workspace.client.event.GetSharedLinkEventHandler;
|
||||||
import org.gcube.portlets.user.workspace.client.event.ImagePreviewEvent;
|
import org.gcube.portlets.user.workspace.client.event.ImagePreviewEvent;
|
||||||
import org.gcube.portlets.user.workspace.client.event.ImagePreviewEventHandler;
|
import org.gcube.portlets.user.workspace.client.event.ImagePreviewEventHandler;
|
||||||
import org.gcube.portlets.user.workspace.client.event.MoveItemEvent;
|
import org.gcube.portlets.user.workspace.client.event.LoadFolderEvent;
|
||||||
import org.gcube.portlets.user.workspace.client.event.MoveItemEventHandler;
|
import org.gcube.portlets.user.workspace.client.event.MoveItemsEvent;
|
||||||
|
import org.gcube.portlets.user.workspace.client.event.MoveItemsEventHandler;
|
||||||
import org.gcube.portlets.user.workspace.client.event.OpenContextMenuTreeEvent;
|
import org.gcube.portlets.user.workspace.client.event.OpenContextMenuTreeEvent;
|
||||||
import org.gcube.portlets.user.workspace.client.event.OpenContextMenuTreeEventHandler;
|
import org.gcube.portlets.user.workspace.client.event.OpenContextMenuTreeEventHandler;
|
||||||
import org.gcube.portlets.user.workspace.client.event.OpenReportsEvent;
|
import org.gcube.portlets.user.workspace.client.event.OpenReportsEvent;
|
||||||
import org.gcube.portlets.user.workspace.client.event.OpenReportsEventHandler;
|
import org.gcube.portlets.user.workspace.client.event.OpenReportsEventHandler;
|
||||||
import org.gcube.portlets.user.workspace.client.event.OpenUrlEvent;
|
import org.gcube.portlets.user.workspace.client.event.OpenUrlEvent;
|
||||||
import org.gcube.portlets.user.workspace.client.event.OpenUrlEventHandler;
|
import org.gcube.portlets.user.workspace.client.event.OpenUrlEventHandler;
|
||||||
import org.gcube.portlets.user.workspace.client.event.PasteItemEvent;
|
|
||||||
import org.gcube.portlets.user.workspace.client.event.PasteItemEventHandler;
|
|
||||||
import org.gcube.portlets.user.workspace.client.event.PublishOnDataCatalogueEvent;
|
import org.gcube.portlets.user.workspace.client.event.PublishOnDataCatalogueEvent;
|
||||||
import org.gcube.portlets.user.workspace.client.event.PublishOnDataCatalogueEventHandler;
|
import org.gcube.portlets.user.workspace.client.event.PublishOnDataCatalogueEventHandler;
|
||||||
import org.gcube.portlets.user.workspace.client.event.RefreshFolderEvent;
|
import org.gcube.portlets.user.workspace.client.event.RefreshFolderEvent;
|
||||||
|
@ -113,7 +115,6 @@ import org.gcube.portlets.user.workspace.client.model.SmartFolderModel;
|
||||||
import org.gcube.portlets.user.workspace.client.model.SubTree;
|
import org.gcube.portlets.user.workspace.client.model.SubTree;
|
||||||
import org.gcube.portlets.user.workspace.client.rpc.GWTWorkspaceService;
|
import org.gcube.portlets.user.workspace.client.rpc.GWTWorkspaceService;
|
||||||
import org.gcube.portlets.user.workspace.client.rpc.GWTWorkspaceServiceAsync;
|
import org.gcube.portlets.user.workspace.client.rpc.GWTWorkspaceServiceAsync;
|
||||||
import org.gcube.portlets.user.workspace.client.util.FolderDownloadDialog;
|
|
||||||
import org.gcube.portlets.user.workspace.client.util.RequestBuilderWorkspaceValidateItem;
|
import org.gcube.portlets.user.workspace.client.util.RequestBuilderWorkspaceValidateItem;
|
||||||
import org.gcube.portlets.user.workspace.client.util.WindowOpenParameter;
|
import org.gcube.portlets.user.workspace.client.util.WindowOpenParameter;
|
||||||
import org.gcube.portlets.user.workspace.client.view.ExplorerPanel;
|
import org.gcube.portlets.user.workspace.client.view.ExplorerPanel;
|
||||||
|
@ -144,6 +145,7 @@ import org.gcube.portlets.user.workspace.client.workspace.folder.item.gcube.GWTU
|
||||||
import org.gcube.portlets.user.workspace.shared.ReportAssignmentACL;
|
import org.gcube.portlets.user.workspace.shared.ReportAssignmentACL;
|
||||||
import org.gcube.portlets.user.workspace.shared.SessionExpiredException;
|
import org.gcube.portlets.user.workspace.shared.SessionExpiredException;
|
||||||
import org.gcube.portlets.user.workspace.shared.UserBean;
|
import org.gcube.portlets.user.workspace.shared.UserBean;
|
||||||
|
import org.gcube.portlets.user.workspace.shared.WorkspaceOperationResult;
|
||||||
import org.gcube.portlets.user.workspace.shared.accounting.GxtAccountingField;
|
import org.gcube.portlets.user.workspace.shared.accounting.GxtAccountingField;
|
||||||
import org.gcube.portlets.widgets.ckandatapublisherwidget.client.events.CloseCreationFormEvent;
|
import org.gcube.portlets.widgets.ckandatapublisherwidget.client.events.CloseCreationFormEvent;
|
||||||
import org.gcube.portlets.widgets.ckandatapublisherwidget.client.ui.form.CreateDatasetForm;
|
import org.gcube.portlets.widgets.ckandatapublisherwidget.client.ui.form.CreateDatasetForm;
|
||||||
|
@ -155,6 +157,11 @@ import org.gcube.portlets.widgets.workspacesharingwidget.client.view.sharing.mul
|
||||||
import org.gcube.portlets.widgets.workspaceuploader.client.WorkspaceUploadNotification.WorskpaceUploadNotificationListener;
|
import org.gcube.portlets.widgets.workspaceuploader.client.WorkspaceUploadNotification.WorskpaceUploadNotificationListener;
|
||||||
import org.gcube.portlets.widgets.workspaceuploader.client.uploader.DialogUpload.UPLOAD_TYPE;
|
import org.gcube.portlets.widgets.workspaceuploader.client.uploader.DialogUpload.UPLOAD_TYPE;
|
||||||
import org.gcube.portlets.widgets.workspaceuploader.client.uploader.MultipleDilaogUpload;
|
import org.gcube.portlets.widgets.workspaceuploader.client.uploader.MultipleDilaogUpload;
|
||||||
|
import org.gcube.portlets.widgets.wsexplorer.client.WorkspaceExplorerConstants;
|
||||||
|
import org.gcube.portlets.widgets.wsexplorer.client.notification.WorkspaceExplorerSelectNotification.WorskpaceExplorerSelectNotificationListener;
|
||||||
|
import org.gcube.portlets.widgets.wsexplorer.client.select.WorkspaceExplorerSelectDialog;
|
||||||
|
import org.gcube.portlets.widgets.wsexplorer.client.view.grid.ItemsTable.DISPLAY_FIELD;
|
||||||
|
import org.gcube.portlets.widgets.wsexplorer.shared.Item;
|
||||||
import org.gcube.portlets.widgets.wstaskexecutor.client.WsTaskExecutorWidget;
|
import org.gcube.portlets.widgets.wstaskexecutor.client.WsTaskExecutorWidget;
|
||||||
import org.gcube.portlets.widgets.wstaskexecutor.shared.SelectableOperator;
|
import org.gcube.portlets.widgets.wstaskexecutor.shared.SelectableOperator;
|
||||||
import org.gcube.portlets.widgets.wstaskexecutor.shared.WSItem;
|
import org.gcube.portlets.widgets.wstaskexecutor.shared.WSItem;
|
||||||
|
@ -912,46 +919,33 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
|
||||||
@Override
|
@Override
|
||||||
public void onOpenContextMenuTree(OpenContextMenuTreeEvent openContextMenuTreeEvent) {
|
public void onOpenContextMenuTree(OpenContextMenuTreeEvent openContextMenuTreeEvent) {
|
||||||
|
|
||||||
explorerPanel.getAsycTreePanel().getContextMenuTree().openContextMenuOnItem(openContextMenuTreeEvent.getTargetFileModel(), openContextMenuTreeEvent.getClientX(), openContextMenuTreeEvent.getClientY());
|
explorerPanel.getAsycTreePanel().getContextMenuTree().openContextMenuOnItem(openContextMenuTreeEvent.getSelectedItems(), openContextMenuTreeEvent.getClientX(), openContextMenuTreeEvent.getClientY());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
eventBus.addHandler(CopytemEvent.TYPE, new CopytemEventHandler() {
|
// eventBus.addHandler(CopyItemsEvent.TYPE, new CopyItemsEventHandler() {
|
||||||
|
//
|
||||||
|
// @Override
|
||||||
|
// public void onCopyItems(CopyItemsEvent copytemEvent) {
|
||||||
|
// notifySubscriber(copytemEvent);
|
||||||
|
// }
|
||||||
|
// });
|
||||||
|
|
||||||
|
eventBus.addHandler(CopyItemsEvent.TYPE, new CopyItemsEventHandler() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCopyItem(CopytemEvent copytemEvent) {
|
public void onCopyItems(final CopyItemsEvent copytemEvent) {
|
||||||
notifySubscriber(copytemEvent);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
eventBus.addHandler(PasteItemEvent.TYPE, new PasteItemEventHandler() {
|
|
||||||
|
if(copytemEvent.getIds()!=null && copytemEvent.getIds().size()>0){
|
||||||
|
|
||||||
|
explorerPanel.mask("Copying...", ConstantsExplorer.LOADINGSTYLE);
|
||||||
|
rpcWorkspaceService.copyItems(copytemEvent.getIds(), copytemEvent.getDestinationFolderId(), new AsyncCallback<WorkspaceOperationResult>() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCutCopyAndPaste(PasteItemEvent pasteItemEvent) {
|
|
||||||
|
|
||||||
GWT.log("PasteItemEvent is fired on : "+pasteItemEvent.getIds().size()+ "items, DestinationId: "+pasteItemEvent.getFolderDestinationId());
|
|
||||||
doCutCopyAndPaste(pasteItemEvent);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void doCutCopyAndPaste(final PasteItemEvent pasteItemEvent) {
|
|
||||||
|
|
||||||
if(pasteItemEvent.getIds()==null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
Info.display("Info", "Paste working...");
|
|
||||||
|
|
||||||
switch(pasteItemEvent.getOperationType()){
|
|
||||||
|
|
||||||
case CUT:
|
|
||||||
|
|
||||||
//TODO remove this comments
|
|
||||||
// if(pasteItemEvent.getFolderSourceId()==null || pasteItemEvent.getFolderSourceId().isEmpty())
|
|
||||||
// return;
|
|
||||||
|
|
||||||
rpcWorkspaceService.moveItems(pasteItemEvent.getIds(), pasteItemEvent.getFolderDestinationId(), new AsyncCallback<Boolean>() {
|
|
||||||
|
|
||||||
public void onFailure(Throwable caught) {
|
public void onFailure(Throwable caught) {
|
||||||
|
|
||||||
|
explorerPanel.unmask();
|
||||||
if(caught instanceof SessionExpiredException){
|
if(caught instanceof SessionExpiredException){
|
||||||
GWT.log("Session expired");
|
GWT.log("Session expired");
|
||||||
eventBus.fireEvent(new SessionExpiredEvent());
|
eventBus.fireEvent(new SessionExpiredEvent());
|
||||||
|
@ -959,74 +953,189 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
|
||||||
}
|
}
|
||||||
|
|
||||||
new MessageBoxAlert("Error", caught.getMessage()+"." , null);
|
new MessageBoxAlert("Error", caught.getMessage()+"." , null);
|
||||||
// System.out.println(caught.getMessage());
|
explorerPanel.getAsycTreePanel().reloadTreeLevelAndExpandFolder(copytemEvent.getDestinationFolderId(), false);
|
||||||
explorerPanel.getAsycTreePanel().reloadTreeLevelAndExpandFolder(pasteItemEvent.getFolderDestinationId(), false);
|
notifySubscriber(copytemEvent);
|
||||||
explorerPanel.getAsycTreePanel().reloadTreeLevelAndExpandFolder(pasteItemEvent.getFolderSourceId(), true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess(Boolean result) {
|
public void onSuccess(WorkspaceOperationResult result) {
|
||||||
|
|
||||||
FileModel fileInTree = explorerPanel.getAsycTreePanel().getFileModelByIdentifier(pasteItemEvent.getFolderDestinationId());
|
explorerPanel.unmask();
|
||||||
|
GWT.log("Copy terminated without error? "+result);
|
||||||
|
FileModel folderDestionationInTree = explorerPanel.getAsycTreePanel().getFileModelByIdentifier(copytemEvent.getDestinationFolderId());
|
||||||
|
GWT.log("Destination Folder: "+copytemEvent.getDestinationFolderId() +" is in Tree: "+folderDestionationInTree);
|
||||||
|
|
||||||
if(result){
|
if(result.getError()!=null)
|
||||||
eventBus.fireEvent(new RefreshFolderEvent(fileInTree, false, false, false));
|
new MessageBoxAlert("Error", result.getError(), null);
|
||||||
//explorerPanel.getAsycTreePanel().setExpandTreeLevel(event.getTargetParentFileModel(), true); //Expand level drop
|
|
||||||
|
if(folderDestionationInTree!=null)
|
||||||
|
eventBus.fireEvent(new RefreshFolderEvent(folderDestionationInTree, true, false, false));
|
||||||
|
|
||||||
|
notifySubscriber(copytemEvent);
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if(fileInTree!=null)
|
|
||||||
pasteItemEvent.setTreeRefreshable(true);
|
|
||||||
else
|
|
||||||
pasteItemEvent.setTreeRefreshable(false);
|
|
||||||
|
|
||||||
notifySubscriber(pasteItemEvent);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
break;
|
eventBus.addHandler(MoveItemsEvent.TYPE, new MoveItemsEventHandler() {
|
||||||
|
|
||||||
case COPY:
|
|
||||||
|
|
||||||
rpcWorkspaceService.copyItems(pasteItemEvent.getIds(), pasteItemEvent.getFolderDestinationId(), new AsyncCallback<Boolean>() {
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onFailure(Throwable caught) {
|
public void onMoveItems(MoveItemsEvent moveItemEvent) {
|
||||||
|
|
||||||
|
GWT.log("MoveItemEvent is fired on : "+moveItemEvent.getIds().size()+ "items, DestinationId: "+moveItemEvent.getDestionationFolderId());
|
||||||
|
doMoveItems(moveItemEvent);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void doMoveItems(final MoveItemsEvent moveItemsEvent) {
|
||||||
|
|
||||||
|
if(moveItemsEvent.getIds()==null || moveItemsEvent.getIds().size()==0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
WorkspaceExplorerConstants.SELECT = "Move";
|
||||||
|
DISPLAY_FIELD[] displayFields = new DISPLAY_FIELD[]{DISPLAY_FIELD.ICON, DISPLAY_FIELD.NAME, DISPLAY_FIELD.OWNER};
|
||||||
|
final WorkspaceExplorerSelectDialog navigator = new WorkspaceExplorerSelectDialog("Move to...", true, moveItemsEvent.getSourceParentFolder().getIdentifier(), "", displayFields);
|
||||||
|
|
||||||
|
WorskpaceExplorerSelectNotificationListener listener = new WorskpaceExplorerSelectNotificationListener() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onSelectedItem(Item item) {
|
||||||
|
navigator.hide();
|
||||||
|
|
||||||
|
if(item==null)
|
||||||
|
new MessageBoxAlert("Error", "No folder selected" , null);
|
||||||
|
|
||||||
|
GWT.log("destionation folder is: "+item);
|
||||||
|
final String destinationFolderId = item.getId();
|
||||||
|
moveItemsEvent.setDestionationFolderId(destinationFolderId); //do not remove this set
|
||||||
|
|
||||||
|
explorerPanel.mask("Moving...", ConstantsExplorer.LOADINGSTYLE);
|
||||||
|
rpcWorkspaceService.moveItems(moveItemsEvent.getIds(), destinationFolderId, new AsyncCallback<WorkspaceOperationResult>() {
|
||||||
|
|
||||||
|
public void onFailure(Throwable caught) {
|
||||||
|
explorerPanel.unmask();
|
||||||
if(caught instanceof SessionExpiredException){
|
if(caught instanceof SessionExpiredException){
|
||||||
GWT.log("Session expired");
|
GWT.log("Session expired");
|
||||||
eventBus.fireEvent(new SessionExpiredEvent());
|
eventBus.fireEvent(new SessionExpiredEvent());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
new MessageBoxAlert("Error", caught.getMessage(), null);
|
|
||||||
|
|
||||||
eventBus.fireEvent(new RefreshFolderEvent(explorerPanel.getAsycTreePanel().getFileModelByIdentifier(pasteItemEvent.getFolderDestinationId()), false, true, false));
|
new MessageBoxAlert("Error", caught.getMessage()+"." , null);
|
||||||
|
explorerPanel.getAsycTreePanel().reloadTreeLevelAndExpandFolder(destinationFolderId, false);
|
||||||
notifySubscriber(pasteItemEvent);
|
String sourceParentId = moveItemsEvent.getSourceParentFolder()!=null?moveItemsEvent.getSourceParentFolder().getIdentifier():null;
|
||||||
|
explorerPanel.getAsycTreePanel().reloadTreeLevelAndExpandFolder(sourceParentId, true);
|
||||||
|
notifySubscriber(moveItemsEvent); //WE MISSING THE PARENT OF destinationFolderId
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess(Boolean result) {
|
public void onSuccess(WorkspaceOperationResult result) {
|
||||||
|
explorerPanel.unmask();
|
||||||
|
GWT.log("Move terminated without error? "+result);
|
||||||
|
|
||||||
FileModel fileInTree = explorerPanel.getAsycTreePanel().getFileModelByIdentifier(pasteItemEvent.getFolderDestinationId());
|
//NO ERROR
|
||||||
if(result)
|
if(result.getError()==null){
|
||||||
eventBus.fireEvent(new RefreshFolderEvent(fileInTree, false, false, false));
|
//REFRESHING SOURCE PARENT FOLDER
|
||||||
|
eventBus.fireEvent(new RefreshFolderEvent(moveItemsEvent.getSourceParentFolder(), true, false, false));
|
||||||
if(fileInTree!=null)
|
}else{
|
||||||
pasteItemEvent.setTreeRefreshable(true);
|
//WITH ERROR
|
||||||
else
|
new MessageBoxAlert("Error", result.getError(), null);
|
||||||
pasteItemEvent.setTreeRefreshable(false);
|
|
||||||
|
|
||||||
notifySubscriber(pasteItemEvent);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//GETTING DESTINATION FOLDER
|
||||||
|
FileModel folderDestionationInTree = explorerPanel.getAsycTreePanel().getFileModelByIdentifier(destinationFolderId);
|
||||||
|
GWT.log("Destination Folder: "+destinationFolderId +" is in Tree: "+folderDestionationInTree);
|
||||||
|
|
||||||
|
//IF DESTINATION FOLDER IS IN THE TREE, REFRESH IT
|
||||||
|
if(folderDestionationInTree!=null)
|
||||||
|
eventBus.fireEvent(new RefreshFolderEvent(folderDestionationInTree, true, false, false));
|
||||||
|
|
||||||
|
// if(folderDestionationInTree!=null)
|
||||||
|
// moveItemsEvent.setTreeRefreshable(true);
|
||||||
|
// else
|
||||||
|
// moveItemsEvent.setTreeRefreshable(false);
|
||||||
|
|
||||||
|
moveItemsEvent.setTreeRefreshable(false); //forcing grid refresh
|
||||||
|
notifySubscriber(moveItemsEvent);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onFailed(Throwable throwable) {
|
||||||
|
GWT.log("onFailed..");
|
||||||
|
navigator.hide();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onAborted() {
|
||||||
|
GWT.log("onAborted..");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onNotValidSelection() {
|
||||||
|
GWT.log("onNotValidSelection..");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
navigator.addWorkspaceExplorerSelectNotificationListener(listener);
|
||||||
|
navigator.show();
|
||||||
|
|
||||||
|
|
||||||
|
// break;
|
||||||
|
|
||||||
|
// case COPY:
|
||||||
|
//
|
||||||
|
// rpcWorkspaceService.copyItems(pasteItemEvent.getIds(), pasteItemEvent.getFolderDestinationId(), new AsyncCallback<Boolean>() {
|
||||||
|
//
|
||||||
|
// @Override
|
||||||
|
// public void onFailure(Throwable caught) {
|
||||||
|
//
|
||||||
|
// if(caught instanceof SessionExpiredException){
|
||||||
|
// GWT.log("Session expired");
|
||||||
|
// eventBus.fireEvent(new SessionExpiredEvent());
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// new MessageBoxAlert("Error", caught.getMessage(), null);
|
||||||
|
//
|
||||||
|
// eventBus.fireEvent(new RefreshFolderEvent(explorerPanel.getAsycTreePanel().getFileModelByIdentifier(pasteItemEvent.getFolderDestinationId()), false, true, false));
|
||||||
|
//
|
||||||
|
// notifySubscriber(pasteItemEvent);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// @Override
|
||||||
|
// public void onSuccess(Boolean result) {
|
||||||
|
//
|
||||||
|
// FileModel fileInTree = explorerPanel.getAsycTreePanel().getFileModelByIdentifier(pasteItemEvent.getFolderDestinationId());
|
||||||
|
// if(result)
|
||||||
|
// eventBus.fireEvent(new RefreshFolderEvent(fileInTree, false, false, false));
|
||||||
|
//
|
||||||
|
// if(fileInTree!=null)
|
||||||
|
// pasteItemEvent.setTreeRefreshable(true);
|
||||||
|
// else
|
||||||
|
// pasteItemEvent.setTreeRefreshable(false);
|
||||||
|
//
|
||||||
|
// notifySubscriber(pasteItemEvent);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// });
|
||||||
|
|
||||||
|
// break;
|
||||||
|
|
||||||
|
// default:
|
||||||
|
//
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -1052,7 +1161,7 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
|
||||||
|
|
||||||
private void doChangeScope(String scopeId) {
|
private void doChangeScope(String scopeId) {
|
||||||
|
|
||||||
explorerPanel.getAsycTreePanel().loadRootItem(scopeId,selectRootItem); // RELOAD ROOT BY SCOPE
|
explorerPanel.getAsycTreePanel().loadRootItem(selectRootItem); // RELOAD ROOT BY SCOPE
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1160,7 +1269,9 @@ 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{
|
||||||
if (fileDownloadEvent.isFolder()) {
|
|
||||||
|
//Task #12601 - Migrated to StorageHub
|
||||||
|
/*if (fileDownloadEvent.isFolder()) {
|
||||||
FolderDownloadDialog dlg = new FolderDownloadDialog(fileDownloadEvent, myLogin);
|
FolderDownloadDialog dlg = new FolderDownloadDialog(fileDownloadEvent, myLogin);
|
||||||
dlg.setPopupPosition(Window.getClientWidth() - (FolderDownloadDialog.WIDTH + 50), Window.getClientHeight() - (FolderDownloadDialog.HEIGHT + 120));
|
dlg.setPopupPosition(Window.getClientWidth() - (FolderDownloadDialog.WIDTH + 50), Window.getClientHeight() - (FolderDownloadDialog.HEIGHT + 120));
|
||||||
dlg.show();
|
dlg.show();
|
||||||
|
@ -1178,7 +1289,21 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
|
||||||
new MessageBoxAlert("Error", e.getMessage(), null);
|
new MessageBoxAlert("Error", e.getMessage(), null);
|
||||||
explorerPanel.getAsycTreePanel().removeAllAndRecoveryRoot();
|
explorerPanel.getAsycTreePanel().removeAllAndRecoveryRoot();
|
||||||
}
|
}
|
||||||
|
}*/
|
||||||
|
|
||||||
|
|
||||||
|
try {
|
||||||
|
//String currentUserId = GCubeClientContext.getCurrentUserId();
|
||||||
|
String queryString = "id="+fileDownloadEvent.getItemIdentifier()+"&"+ConstantsExplorer.CURRENT_CONTEXT_ID+"="+currentContextId;
|
||||||
|
if(fileDownloadEvent.getVersionId()!=null)
|
||||||
|
queryString+="&"+ConstantsExplorer.FILE_VERSION_ID+"="+fileDownloadEvent.getVersionId();
|
||||||
|
new RequestBuilderWorkspaceValidateItem(RequestBuilder.GET,ConstantsExplorer.DOWNLOAD_WORKSPACE_SERVICE, queryString, "_self", downloadHandlerCallback);
|
||||||
|
} catch (Exception e) {
|
||||||
|
explorerPanel.getAsycTreePanel().unmask();
|
||||||
|
new MessageBoxAlert("Error", e.getMessage(), null);
|
||||||
|
explorerPanel.getAsycTreePanel().removeAllAndRecoveryRoot();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
notifySubscriber(fileDownloadEvent);
|
notifySubscriber(fileDownloadEvent);
|
||||||
}
|
}
|
||||||
|
@ -1402,6 +1527,7 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
|
||||||
|
|
||||||
if(dgt.isValidForm()){
|
if(dgt.isValidForm()){
|
||||||
dgt.mask("Renaming...");
|
dgt.mask("Renaming...");
|
||||||
|
GWT.log("Renaming on id: "+target.getIdentifier());
|
||||||
rpcWorkspaceService.renameItem(target.getIdentifier(), newName, target.getName(), new AsyncCallback<Boolean>(){
|
rpcWorkspaceService.renameItem(target.getIdentifier(), newName, target.getName(), new AsyncCallback<Boolean>(){
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1624,13 +1750,14 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
eventBus.addHandler(MoveItemEvent.TYPE, new MoveItemEventHandler() {
|
eventBus.addHandler(DragOnTreeMoveItemEvent.TYPE, new DragOnTreeMoveItemEventHandler() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onMoveItem(final MoveItemEvent event) {
|
public void onMoveItem(final DragOnTreeMoveItemEvent event) {
|
||||||
|
|
||||||
explorerPanel.getAsycTreePanel().mask(ConstantsExplorer.MOVING,ConstantsExplorer.LOADINGSTYLE);
|
explorerPanel.getAsycTreePanel().mask(ConstantsExplorer.MOVING,ConstantsExplorer.LOADINGSTYLE);
|
||||||
rpcWorkspaceService.moveItem(event.getFileSourceModel().getIdentifier(), event.getTargetParentFileModel().getIdentifier(), new AsyncCallback<Boolean>() {
|
|
||||||
|
rpcWorkspaceService.moveItems(Arrays.asList(event.getFileSourceModel().getIdentifier()), event.getTargetParentFileModel().getIdentifier(), new AsyncCallback<WorkspaceOperationResult>() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onFailure(Throwable caught) {
|
public void onFailure(Throwable caught) {
|
||||||
|
@ -1648,9 +1775,13 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess(Boolean result) {
|
public void onSuccess(WorkspaceOperationResult result) {
|
||||||
explorerPanel.getAsycTreePanel().unmask();
|
explorerPanel.getAsycTreePanel().unmask();
|
||||||
if(result){
|
if(result!=null){
|
||||||
|
|
||||||
|
if(result.getError()!=null)
|
||||||
|
new MessageBoxAlert("Error",result.getError(), null);
|
||||||
|
|
||||||
explorerPanel.getAsycTreePanel().reloadTreeLevelAndExpandFolder(event.getTargetParentFileModel().getIdentifier(), true);
|
explorerPanel.getAsycTreePanel().reloadTreeLevelAndExpandFolder(event.getTargetParentFileModel().getIdentifier(), true);
|
||||||
notifySubscriber(event);
|
notifySubscriber(event);
|
||||||
}
|
}
|
||||||
|
@ -1687,14 +1818,14 @@ 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 + " imaging preview.", null);
|
new MessageBoxAlert("Error", ConstantsExplorer.SERVER_ERROR + " getting the image preview", null);
|
||||||
explorerPanel.getAsycTreePanel().removeAllAndRecoveryRoot();
|
explorerPanel.getAsycTreePanel().removeAllAndRecoveryRoot();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess(GWTWorkspaceItem item) {
|
public void onSuccess(GWTWorkspaceItem item) {
|
||||||
GWT.log("Image loaded: "+item.getName() + " label: "+item.getLabel());
|
GWT.log("Image loaded: "+item.getName() + " label: "+item.getLabel() +" type: "+fileModel.getGXTFolderItemType());
|
||||||
if(fileModel.getGXTFolderItemType().equals(GXTFolderItemTypeEnum.IMAGE_DOCUMENT))
|
if(fileModel.getGXTFolderItemType().equals(GXTFolderItemTypeEnum.IMAGE_DOCUMENT))
|
||||||
new ImagesPreviewController(fileModel.getName(), fileModel.getParentFileModel(), (GWTImageDocument) item, positionX, positionY);
|
new ImagesPreviewController(fileModel.getName(), fileModel.getParentFileModel(), (GWTImageDocument) item, positionX, positionY);
|
||||||
else
|
else
|
||||||
|
@ -1788,7 +1919,6 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
eventBus.addHandler(OpenReportsEvent.TYPE, new OpenReportsEventHandler() {
|
eventBus.addHandler(OpenReportsEvent.TYPE, new OpenReportsEventHandler() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1979,9 +2109,9 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
|
||||||
|
|
||||||
sub.addedFile(createUrlEvent.getItemIdentifier(), createUrlEvent.getParentFileModel().getIdentifier(), WS_UPLOAD_TYPE.File, false);
|
sub.addedFile(createUrlEvent.getItemIdentifier(), createUrlEvent.getParentFileModel().getIdentifier(), WS_UPLOAD_TYPE.File, false);
|
||||||
|
|
||||||
}else if(event instanceof MoveItemEvent){
|
}else if(event instanceof DragOnTreeMoveItemEvent){
|
||||||
|
|
||||||
MoveItemEvent moveItemEvent = (MoveItemEvent) event;
|
DragOnTreeMoveItemEvent moveItemEvent = (DragOnTreeMoveItemEvent) event;
|
||||||
|
|
||||||
sub.movedItems(moveItemEvent.getFileSourceModel().getIdentifier(), moveItemEvent.getTargetParentFileModel());
|
sub.movedItems(moveItemEvent.getFileSourceModel().getIdentifier(), moveItemEvent.getTargetParentFileModel());
|
||||||
|
|
||||||
|
@ -2007,14 +2137,14 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
|
||||||
|
|
||||||
sub.viewSessionExpiredPanel();
|
sub.viewSessionExpiredPanel();
|
||||||
|
|
||||||
}else if(event instanceof PasteItemEvent){
|
}else if(event instanceof MoveItemsEvent){
|
||||||
|
|
||||||
PasteItemEvent pasteEvent = (PasteItemEvent) event;
|
MoveItemsEvent moveEvent = (MoveItemsEvent) event;
|
||||||
sub.pasteEventIsCompleted(pasteEvent.isTreeRefreshable(), pasteEvent.getFolderDestinationId());
|
sub.moveEventIsCompleted(moveEvent.isTreeRefreshable(), moveEvent.getDestionationFolderId());
|
||||||
|
|
||||||
}else if(event instanceof CopytemEvent){
|
}else if(event instanceof CopyItemsEvent){
|
||||||
|
CopyItemsEvent copyEvent = (CopyItemsEvent) event;
|
||||||
sub.copyEventIsCompleted();
|
sub.copyEventIsCompleted(copyEvent.getDestinationFolderId());
|
||||||
|
|
||||||
}else if(event instanceof TrashEvent){
|
}else if(event instanceof TrashEvent){
|
||||||
TrashEvent trashEvent = (TrashEvent) event;
|
TrashEvent trashEvent = (TrashEvent) event;
|
||||||
|
@ -2029,6 +2159,9 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
|
||||||
}else if(event instanceof VersioningHistoryShowEvent){
|
}else if(event instanceof VersioningHistoryShowEvent){
|
||||||
VersioningHistoryShowEvent historyVers = (VersioningHistoryShowEvent) event;
|
VersioningHistoryShowEvent historyVers = (VersioningHistoryShowEvent) event;
|
||||||
sub.versioningHistory(historyVers.getTargetFileModel());
|
sub.versioningHistory(historyVers.getTargetFileModel());
|
||||||
|
}else if(event instanceof LoadFolderEvent){
|
||||||
|
LoadFolderEvent loadFolderEvent = (LoadFolderEvent) event;
|
||||||
|
sub.loadFolder(loadFolderEvent.getTargetFolder());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -28,7 +28,6 @@ public class ConstantsExplorer {
|
||||||
public static final String LOCAL_UPLOAD_WORKSPACE_SERVICE = GWT.getModuleBaseURL() + "LocalUploadService";
|
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 IMAGE_SERVLET = GWT.getModuleBaseURL() + "ImageService";
|
public static final String IMAGE_SERVLET = GWT.getModuleBaseURL() + "ImageService";
|
||||||
public static final String DOWNLOAD_WORKSPACE_FOLDER_SERVLET = GWT.getModuleBaseURL() + "DownloadFolderServlet";
|
|
||||||
public static final String DOWNLOAD_WORKSPACE_FOLDER_SERVICE = "downloadfolder";
|
public static final String DOWNLOAD_WORKSPACE_FOLDER_SERVICE = "downloadfolder";
|
||||||
public static final String DOWNLOAD_WORKSPACE_FOLDER_PROTOCOL_DO_ZIP = "ZIP";
|
public static final String DOWNLOAD_WORKSPACE_FOLDER_PROTOCOL_DO_ZIP = "ZIP";
|
||||||
public static final String DOWNLOAD_WORKSPACE_FOLDER_PROTOCOL_ZIPPING = "ZIPPING";
|
public static final String DOWNLOAD_WORKSPACE_FOLDER_PROTOCOL_ZIPPING = "ZIPPING";
|
||||||
|
@ -38,7 +37,7 @@ public class ConstantsExplorer {
|
||||||
public static final String DOWNLOAD_WORKSPACE_FOLDER_PROTOCOL_ERROR_SESSION_EXPIRED = "ERROR_SESSION_EXPIRED";
|
public static final String DOWNLOAD_WORKSPACE_FOLDER_PROTOCOL_ERROR_SESSION_EXPIRED = "ERROR_SESSION_EXPIRED";
|
||||||
|
|
||||||
|
|
||||||
public static final String SERVER_ERROR = "Sorry, an error has occurred on the server when";
|
public static final String SERVER_ERROR = "Error on";
|
||||||
public static final String TRY_AGAIN = "Try again";
|
public static final String TRY_AGAIN = "Try again";
|
||||||
|
|
||||||
public static final int TIME_BULK_CREATOR_POLLING = 300*1000; //in milliseconds
|
public static final int TIME_BULK_CREATOR_POLLING = 300*1000; //in milliseconds
|
||||||
|
@ -84,8 +83,9 @@ public class ConstantsExplorer {
|
||||||
public static final String INFO = "Info";
|
public static final String INFO = "Info";
|
||||||
public static final String MESSAGE_SEND_TO_OK = "Your message has been successfully delivered";
|
public static final String MESSAGE_SEND_TO_OK = "Your message has been successfully delivered";
|
||||||
public static final String MESSAGE_SHARE_LINK = "Get Link";
|
public static final String MESSAGE_SHARE_LINK = "Get Link";
|
||||||
public static final String COPYITEM = "Copy";
|
public static final String MOVE = "Move";
|
||||||
public static final String PASTEITEM = "Paste";
|
public static final String COPY = "Make a Copy";
|
||||||
|
//public static final String PASTEITEM = "Paste";
|
||||||
public static final String MESSAGE_REFRESH_FOLDER = "Refresh Folder";
|
public static final String MESSAGE_REFRESH_FOLDER = "Refresh Folder";
|
||||||
public static final String MESSAGE_GET_INFO = "Get Info";
|
public static final String MESSAGE_GET_INFO = "Get Info";
|
||||||
public static final String FILE_VERSIONS = "Versions";
|
public static final String FILE_VERSIONS = "Versions";
|
||||||
|
@ -117,9 +117,9 @@ public class ConstantsExplorer {
|
||||||
public static final String FILEUPLOADHEADER = "File upload in: ";
|
public static final String FILEUPLOADHEADER = "File upload in: ";
|
||||||
|
|
||||||
public static final String REGEX_TO_WSITEM_NAME = "[^\\[\\]<>\\|?/*%$\\\\:]*$";
|
public static final String REGEX_TO_WSITEM_NAME = "[^\\[\\]<>\\|?/*%$\\\\:]*$";
|
||||||
public static final String REGEX_TO_WSFOLDER_NAME = "[^.\\[\\]<>\\|?/*%$\\\\:]*$";
|
public static final String REGEX_TO_WSFOLDER_NAME = "[^\\[\\]<>\\|?/*%$\\\\:]*$";
|
||||||
public static final String REGEX_WSITEM_NAME_ALERT_MSG = "Field name must not contain: <>[]:\\|?/*%$ or contains / or \\";
|
public static final String REGEX_WSITEM_NAME_ALERT_MSG = "Field name must not contain: <>[]:\\|?/*%$ or contains / or \\";
|
||||||
public static final String REGEX_WSFOLDER_NAME_ALERT_MSG = "Folder name must not contain: .<>[]:\\|?/*%$ or contains / or \\";
|
public static final String REGEX_WSFOLDER_NAME_ALERT_MSG = "Folder name must not contain: <>[]:\\|?/*%$ or contains / or \\";
|
||||||
|
|
||||||
// public static final String FILE = "File";
|
// public static final String FILE = "File";
|
||||||
// public static final String ARCHIVE = "Archive";
|
// public static final String ARCHIVE = "Archive";
|
||||||
|
@ -268,6 +268,7 @@ public static enum WS_UPLOAD_TYPE {File, Archive};
|
||||||
public static final String MSG_FOLDER_LOCKED_BY_SYNC= "is under synchronization process.\nPlease be aware that some operations are not currently available and that the content might change during this process.";
|
public static final String MSG_FOLDER_LOCKED_BY_SYNC= "is under synchronization process.\nPlease be aware that some operations are not currently available and that the content might change during this process.";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Log.
|
* Log.
|
||||||
*
|
*
|
||||||
|
|
|
@ -21,10 +21,10 @@ public enum WorkspaceOperation {
|
||||||
MARK_AS_UNREAD("MKNR", "MKNR"), // Mark as not read
|
MARK_AS_UNREAD("MKNR", "MKNR"), // Mark as not read
|
||||||
DELETE_MESSAGE("DLM", "DLM"), // Delete message
|
DELETE_MESSAGE("DLM", "DLM"), // Delete message
|
||||||
FORWARD_MESSAGE("FWM", "FWM"), // Forward message
|
FORWARD_MESSAGE("FWM", "FWM"), // Forward message
|
||||||
COPY("CPI", "CPI"), // copy item
|
MOVE("MOV", "MOV"), // MOVE item
|
||||||
PASTE("PSI", "PSI"), // paste
|
//PASTE("PSI", "PSI"), // paste
|
||||||
REFRESH_FOLDER("RFH", "RFH"), // Refresh
|
REFRESH_FOLDER("RFH", "RFH"), // Refresh
|
||||||
WEBDAV_URL("WDV", "WDV"), // WebDav
|
//WEBDAV_URL("WDV", "WDV"), // WebDav
|
||||||
GET_INFO("GTI", "GTI"), // GET INFO
|
GET_INFO("GTI", "GTI"), // GET INFO
|
||||||
HISTORY("HST", "HST"), // HISTORY
|
HISTORY("HST", "HST"), // HISTORY
|
||||||
ACCREAD("ACR", "ACR"), // ACCOUNTING READ
|
ACCREAD("ACR", "ACR"), // ACCOUNTING READ
|
||||||
|
@ -37,7 +37,8 @@ public enum WorkspaceOperation {
|
||||||
FOLDER_LINK_REMOVE("FPR", "FPR"),
|
FOLDER_LINK_REMOVE("FPR", "FPR"),
|
||||||
VERSIONING("VRN", "VRN"), // VERSIONING
|
VERSIONING("VRN", "VRN"), // VERSIONING
|
||||||
EXECUTE_DM_TASK("EDT", "EDT"), //EXECUTE DM TASK
|
EXECUTE_DM_TASK("EDT", "EDT"), //EXECUTE DM TASK
|
||||||
SEND_TO_SWITCHBOARD("SDSB", "SDSB"); //SEND_TO_SWITCHBOARD
|
SEND_TO_SWITCHBOARD("SDSB", "SDSB"), //SEND_TO_SWITCHBOARD
|
||||||
|
COPY("COPY", "COPY");
|
||||||
|
|
||||||
private String id; // ID CONTEXT MENU
|
private String id; // ID CONTEXT MENU
|
||||||
private String name;
|
private String name;
|
||||||
|
|
|
@ -0,0 +1,90 @@
|
||||||
|
package org.gcube.portlets.user.workspace.client.event;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.gcube.portlets.user.workspace.client.interfaces.EventsTypeEnum;
|
||||||
|
import org.gcube.portlets.user.workspace.client.interfaces.GuiEventInterface;
|
||||||
|
|
||||||
|
import com.google.gwt.event.shared.GwtEvent;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Class CopyItemsEvent.
|
||||||
|
*
|
||||||
|
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
|
||||||
|
* Oct 10, 2018
|
||||||
|
*/
|
||||||
|
public class CopyItemsEvent extends GwtEvent<CopyItemsEventHandler> implements GuiEventInterface{
|
||||||
|
public static Type<CopyItemsEventHandler> TYPE = new Type<CopyItemsEventHandler>();
|
||||||
|
|
||||||
|
private List<String> ids;
|
||||||
|
|
||||||
|
private String destinationFolderId;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Instantiates a new copy items event.
|
||||||
|
*
|
||||||
|
* @param ids the ids
|
||||||
|
* @param destinationFolderId the destination folder id
|
||||||
|
*/
|
||||||
|
public CopyItemsEvent(List<String> ids, String destinationFolderId) {
|
||||||
|
this.ids = ids;
|
||||||
|
this.destinationFolderId = destinationFolderId;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see com.google.gwt.event.shared.GwtEvent#getAssociatedType()
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Type<CopyItemsEventHandler> getAssociatedType() {
|
||||||
|
return TYPE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see com.google.gwt.event.shared.GwtEvent#dispatch(com.google.gwt.event.shared.EventHandler)
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
protected void dispatch(CopyItemsEventHandler handler) {
|
||||||
|
handler.onCopyItems(this);
|
||||||
|
|
||||||
|
}
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.gcube.portlets.user.workspace.client.interfaces.GuiEventInterface#getKey()
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public EventsTypeEnum getKey() {
|
||||||
|
return EventsTypeEnum.COPY_EVENT;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the ids.
|
||||||
|
*
|
||||||
|
* @return the ids
|
||||||
|
*/
|
||||||
|
public List<String> getIds() {
|
||||||
|
return ids;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the ids.
|
||||||
|
*
|
||||||
|
* @param ids the new ids
|
||||||
|
*/
|
||||||
|
public void setIds(List<String> ids) {
|
||||||
|
this.ids = ids;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the destination folder id.
|
||||||
|
*
|
||||||
|
* @return the destinationId
|
||||||
|
*/
|
||||||
|
public String getDestinationFolderId() {
|
||||||
|
|
||||||
|
return destinationFolderId;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,21 @@
|
||||||
|
package org.gcube.portlets.user.workspace.client.event;
|
||||||
|
|
||||||
|
import com.google.gwt.event.shared.EventHandler;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Interface CopyItemsEventHandler.
|
||||||
|
*
|
||||||
|
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
|
||||||
|
* Oct 10, 2018
|
||||||
|
*/
|
||||||
|
public interface CopyItemsEventHandler extends EventHandler {
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* On copy items.
|
||||||
|
*
|
||||||
|
* @param copytemEvent the copytem event
|
||||||
|
*/
|
||||||
|
void onCopyItems(CopyItemsEvent copytemEvent);
|
||||||
|
}
|
|
@ -1,57 +0,0 @@
|
||||||
package org.gcube.portlets.user.workspace.client.event;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import org.gcube.portlets.user.workspace.client.interfaces.EventsTypeEnum;
|
|
||||||
import org.gcube.portlets.user.workspace.client.interfaces.GuiEventInterface;
|
|
||||||
|
|
||||||
import com.google.gwt.event.shared.GwtEvent;
|
|
||||||
|
|
||||||
public class CopytemEvent extends GwtEvent<CopytemEventHandler> implements GuiEventInterface{
|
|
||||||
public static Type<CopytemEventHandler> TYPE = new Type<CopytemEventHandler>();
|
|
||||||
|
|
||||||
// private String itemId = null;
|
|
||||||
|
|
||||||
private List<String> ids;
|
|
||||||
|
|
||||||
// public CopytemEvent(String itemId) {
|
|
||||||
// this.itemId = itemId;
|
|
||||||
// }
|
|
||||||
|
|
||||||
public CopytemEvent(List<String> ids) {
|
|
||||||
this.ids = ids;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Type<CopytemEventHandler> getAssociatedType() {
|
|
||||||
return TYPE;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void dispatch(CopytemEventHandler handler) {
|
|
||||||
handler.onCopyItem(this);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// public String getItemId() {
|
|
||||||
// return itemId;
|
|
||||||
// }
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.gcube.portlets.user.workspace.client.interfaces.GuiEventInterface#getKey()
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public EventsTypeEnum getKey() {
|
|
||||||
return EventsTypeEnum.COPY_EVENT;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<String> getIds() {
|
|
||||||
return ids;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setIds(List<String> ids) {
|
|
||||||
this.ids = ids;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,10 +0,0 @@
|
||||||
package org.gcube.portlets.user.workspace.client.event;
|
|
||||||
|
|
||||||
import com.google.gwt.event.shared.EventHandler;
|
|
||||||
|
|
||||||
public interface CopytemEventHandler extends EventHandler {
|
|
||||||
/**
|
|
||||||
* @param copytemEvent
|
|
||||||
*/
|
|
||||||
void onCopyItem(CopytemEvent copytemEvent);
|
|
||||||
}
|
|
|
@ -7,14 +7,14 @@ import org.gcube.portlets.user.workspace.client.model.FolderModel;
|
||||||
|
|
||||||
import com.google.gwt.event.shared.GwtEvent;
|
import com.google.gwt.event.shared.GwtEvent;
|
||||||
|
|
||||||
public class MoveItemEvent extends GwtEvent<MoveItemEventHandler> implements GuiEventInterface{
|
public class DragOnTreeMoveItemEvent extends GwtEvent<DragOnTreeMoveItemEventHandler> implements GuiEventInterface{
|
||||||
public static Type<MoveItemEventHandler> TYPE = new Type<MoveItemEventHandler>();
|
public static Type<DragOnTreeMoveItemEventHandler> TYPE = new Type<DragOnTreeMoveItemEventHandler>();
|
||||||
|
|
||||||
private FileModel source = null;
|
private FileModel source = null;
|
||||||
private FolderModel target = null;
|
private FolderModel target = null;
|
||||||
// private FileModel target = null;
|
// private FileModel target = null;
|
||||||
|
|
||||||
public MoveItemEvent(FileModel fileSourceModel, FolderModel parentFileModel) {
|
public DragOnTreeMoveItemEvent(FileModel fileSourceModel, FolderModel parentFileModel) {
|
||||||
this.source = fileSourceModel;
|
this.source = fileSourceModel;
|
||||||
this.target = parentFileModel;
|
this.target = parentFileModel;
|
||||||
}
|
}
|
||||||
|
@ -25,13 +25,13 @@ public class MoveItemEvent extends GwtEvent<MoveItemEventHandler> implements Gui
|
||||||
// }
|
// }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Type<MoveItemEventHandler> getAssociatedType() {
|
public Type<DragOnTreeMoveItemEventHandler> getAssociatedType() {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
return TYPE;
|
return TYPE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void dispatch(MoveItemEventHandler handler) {
|
protected void dispatch(DragOnTreeMoveItemEventHandler handler) {
|
||||||
handler.onMoveItem(this);
|
handler.onMoveItem(this);
|
||||||
|
|
||||||
}
|
}
|
|
@ -0,0 +1,7 @@
|
||||||
|
package org.gcube.portlets.user.workspace.client.event;
|
||||||
|
|
||||||
|
import com.google.gwt.event.shared.EventHandler;
|
||||||
|
|
||||||
|
public interface DragOnTreeMoveItemEventHandler extends EventHandler {
|
||||||
|
void onMoveItem(DragOnTreeMoveItemEvent event);
|
||||||
|
}
|
|
@ -0,0 +1,72 @@
|
||||||
|
package org.gcube.portlets.user.workspace.client.event;
|
||||||
|
|
||||||
|
import org.gcube.portlets.user.workspace.client.interfaces.EventsTypeEnum;
|
||||||
|
import org.gcube.portlets.user.workspace.client.interfaces.GuiEventInterface;
|
||||||
|
import org.gcube.portlets.user.workspace.client.model.FileModel;
|
||||||
|
|
||||||
|
import com.google.gwt.event.shared.GwtEvent;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Class MoveItemsEvent.
|
||||||
|
*
|
||||||
|
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
|
||||||
|
* Oct 4, 2018
|
||||||
|
*/
|
||||||
|
public class LoadFolderEvent extends GwtEvent<LoadFolderEventHandler> implements GuiEventInterface{
|
||||||
|
public static Type<LoadFolderEventHandler> TYPE = new Type<LoadFolderEventHandler>();
|
||||||
|
|
||||||
|
private FileModel targetFolder; //Used to move
|
||||||
|
/**
|
||||||
|
* Instantiates a new load folder event.
|
||||||
|
*
|
||||||
|
* @param targetFolder the target folder
|
||||||
|
*/
|
||||||
|
public LoadFolderEvent(FileModel targetFolder) {
|
||||||
|
this.targetFolder = targetFolder;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see com.google.gwt.event.shared.GwtEvent#getAssociatedType()
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Type<LoadFolderEventHandler> getAssociatedType() {
|
||||||
|
return TYPE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see com.google.gwt.event.shared.GwtEvent#dispatch(com.google.gwt.event.shared.EventHandler)
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
* Dispatch.
|
||||||
|
*
|
||||||
|
* @param handler the handler
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
protected void dispatch(LoadFolderEventHandler handler) {
|
||||||
|
handler.onLoadFolder(this);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.gcube.portlets.user.workspace.client.interfaces.GuiEventInterface#getKey()
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public EventsTypeEnum getKey() {
|
||||||
|
return EventsTypeEnum.LOAD_FOLDER_EVENT;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the targetFolder
|
||||||
|
*/
|
||||||
|
public FileModel getTargetFolder() {
|
||||||
|
|
||||||
|
return targetFolder;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,21 @@
|
||||||
|
package org.gcube.portlets.user.workspace.client.event;
|
||||||
|
|
||||||
|
import com.google.gwt.event.shared.EventHandler;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Interface LoadFolderEventHandler.
|
||||||
|
*
|
||||||
|
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
|
||||||
|
* Oct 9, 2018
|
||||||
|
*/
|
||||||
|
public interface LoadFolderEventHandler extends EventHandler {
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* On load folder.
|
||||||
|
*
|
||||||
|
* @param loadFolderEvent the load folder event
|
||||||
|
*/
|
||||||
|
void onLoadFolder(LoadFolderEvent loadFolderEvent);
|
||||||
|
}
|
|
@ -1,7 +0,0 @@
|
||||||
package org.gcube.portlets.user.workspace.client.event;
|
|
||||||
|
|
||||||
import com.google.gwt.event.shared.EventHandler;
|
|
||||||
|
|
||||||
public interface MoveItemEventHandler extends EventHandler {
|
|
||||||
void onMoveItem(MoveItemEvent event);
|
|
||||||
}
|
|
|
@ -0,0 +1,135 @@
|
||||||
|
package org.gcube.portlets.user.workspace.client.event;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.gcube.portlets.user.workspace.client.interfaces.EventsTypeEnum;
|
||||||
|
import org.gcube.portlets.user.workspace.client.interfaces.GuiEventInterface;
|
||||||
|
import org.gcube.portlets.user.workspace.client.model.FileModel;
|
||||||
|
|
||||||
|
import com.google.gwt.event.shared.GwtEvent;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Class MoveItemsEvent.
|
||||||
|
*
|
||||||
|
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
|
||||||
|
* Oct 4, 2018
|
||||||
|
*/
|
||||||
|
public class MoveItemsEvent extends GwtEvent<MoveItemsEventHandler> implements GuiEventInterface{
|
||||||
|
public static Type<MoveItemsEventHandler> TYPE = new Type<MoveItemsEventHandler>();
|
||||||
|
|
||||||
|
private String destionationFolderId;
|
||||||
|
|
||||||
|
private List<String> ids;
|
||||||
|
|
||||||
|
private FileModel sourceParentFolder; //Used to move
|
||||||
|
|
||||||
|
private boolean treeRefreshable;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Instantiates a new move items event.
|
||||||
|
*
|
||||||
|
* @param ids the ids
|
||||||
|
* @param folderDestinationId the folder destination id
|
||||||
|
* @param sourceParentFolder the source parent folder
|
||||||
|
*/
|
||||||
|
public MoveItemsEvent(List<String> ids, String folderDestinationId, FileModel sourceParentFolder) {
|
||||||
|
this.ids = ids;
|
||||||
|
this.destionationFolderId = folderDestinationId;
|
||||||
|
this.sourceParentFolder = sourceParentFolder;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see com.google.gwt.event.shared.GwtEvent#getAssociatedType()
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Type<MoveItemsEventHandler> getAssociatedType() {
|
||||||
|
return TYPE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see com.google.gwt.event.shared.GwtEvent#dispatch(com.google.gwt.event.shared.EventHandler)
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
protected void dispatch(MoveItemsEventHandler handler) {
|
||||||
|
handler.onMoveItems(this);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.gcube.portlets.user.workspace.client.interfaces.GuiEventInterface#getKey()
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public EventsTypeEnum getKey() {
|
||||||
|
return EventsTypeEnum.MOVED_EVENT;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the ids.
|
||||||
|
*
|
||||||
|
* @return the ids
|
||||||
|
*/
|
||||||
|
public List<String> getIds() {
|
||||||
|
return ids;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the ids.
|
||||||
|
*
|
||||||
|
* @param ids the new ids
|
||||||
|
*/
|
||||||
|
public void setIds(List<String> ids) {
|
||||||
|
this.ids = ids;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Sets the tree refreshable.
|
||||||
|
*
|
||||||
|
* @param bool the new tree refreshable
|
||||||
|
*/
|
||||||
|
public void setTreeRefreshable(boolean bool){
|
||||||
|
this.treeRefreshable = bool;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if is tree refreshable.
|
||||||
|
*
|
||||||
|
* @return true, if is tree refreshable
|
||||||
|
*/
|
||||||
|
public boolean isTreeRefreshable() {
|
||||||
|
return treeRefreshable;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the destionation folder id.
|
||||||
|
*
|
||||||
|
* @return the destionationFolderId
|
||||||
|
*/
|
||||||
|
public String getDestionationFolderId() {
|
||||||
|
|
||||||
|
return destionationFolderId;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the sourceParentFolder
|
||||||
|
*/
|
||||||
|
public FileModel getSourceParentFolder() {
|
||||||
|
|
||||||
|
return sourceParentFolder;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param destionationFolderId the destionationFolderId to set
|
||||||
|
*/
|
||||||
|
public void setDestionationFolderId(String destionationFolderId) {
|
||||||
|
|
||||||
|
this.destionationFolderId = destionationFolderId;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,20 @@
|
||||||
|
package org.gcube.portlets.user.workspace.client.event;
|
||||||
|
|
||||||
|
import com.google.gwt.event.shared.EventHandler;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Interface MoveItemsEventHandler.
|
||||||
|
*
|
||||||
|
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
|
||||||
|
* Oct 4, 2018
|
||||||
|
*/
|
||||||
|
public interface MoveItemsEventHandler extends EventHandler {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* On move items.
|
||||||
|
*
|
||||||
|
* @param pasteItemEvent the paste item event
|
||||||
|
*/
|
||||||
|
void onMoveItems(MoveItemsEvent pasteItemEvent);
|
||||||
|
}
|
|
@ -1,51 +1,94 @@
|
||||||
package org.gcube.portlets.user.workspace.client.event;
|
package org.gcube.portlets.user.workspace.client.event;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import org.gcube.portlets.user.workspace.client.constant.WorkspaceOperation;
|
import org.gcube.portlets.user.workspace.client.constant.WorkspaceOperation;
|
||||||
import org.gcube.portlets.user.workspace.client.model.FileModel;
|
import org.gcube.portlets.user.workspace.client.model.FileModel;
|
||||||
|
|
||||||
import com.google.gwt.event.shared.GwtEvent;
|
import com.google.gwt.event.shared.GwtEvent;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Class OpenContextMenuTreeEvent.
|
||||||
|
*
|
||||||
|
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
|
||||||
|
* Oct 8, 2018
|
||||||
|
*/
|
||||||
public class OpenContextMenuTreeEvent extends GwtEvent<OpenContextMenuTreeEventHandler> {
|
public class OpenContextMenuTreeEvent extends GwtEvent<OpenContextMenuTreeEventHandler> {
|
||||||
public static Type<OpenContextMenuTreeEventHandler> TYPE = new Type<OpenContextMenuTreeEventHandler>();
|
public static Type<OpenContextMenuTreeEventHandler> TYPE = new Type<OpenContextMenuTreeEventHandler>();
|
||||||
|
|
||||||
private FileModel targetFileModel = null;
|
private List<FileModel> selectedItems = null;
|
||||||
private int clientX;
|
private int clientX;
|
||||||
private int clientY;
|
private int clientY;
|
||||||
|
|
||||||
private WorkspaceOperation wsOperation;
|
private WorkspaceOperation wsOperation;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the ws operation.
|
||||||
|
*
|
||||||
|
* @return the ws operation
|
||||||
|
*/
|
||||||
public WorkspaceOperation getWsOperation() {
|
public WorkspaceOperation getWsOperation() {
|
||||||
return wsOperation;
|
return wsOperation;
|
||||||
}
|
}
|
||||||
|
|
||||||
public OpenContextMenuTreeEvent(FileModel targetFileModel, int clientX, int clientY) {
|
|
||||||
this.targetFileModel = targetFileModel;
|
/**
|
||||||
|
* Instantiates a new open context menu tree event.
|
||||||
|
*
|
||||||
|
* @param selectedItems the selected items
|
||||||
|
* @param clientX the client x
|
||||||
|
* @param clientY the client y
|
||||||
|
*/
|
||||||
|
public OpenContextMenuTreeEvent(List<FileModel> selectedItems, int clientX, int clientY) {
|
||||||
|
this.selectedItems = selectedItems;
|
||||||
this.clientX = clientX;
|
this.clientX = clientX;
|
||||||
this.clientY = clientY;
|
this.clientY = clientY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see com.google.gwt.event.shared.GwtEvent#getAssociatedType()
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Type<OpenContextMenuTreeEventHandler> getAssociatedType() {
|
public Type<OpenContextMenuTreeEventHandler> getAssociatedType() {
|
||||||
return TYPE;
|
return TYPE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see com.google.gwt.event.shared.GwtEvent#dispatch(com.google.gwt.event.shared.EventHandler)
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
protected void dispatch(OpenContextMenuTreeEventHandler handler) {
|
protected void dispatch(OpenContextMenuTreeEventHandler handler) {
|
||||||
handler.onOpenContextMenuTree(this);
|
handler.onOpenContextMenuTree(this);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the client x.
|
||||||
|
*
|
||||||
|
* @return the client x
|
||||||
|
*/
|
||||||
public int getClientX() {
|
public int getClientX() {
|
||||||
return clientX;
|
return clientX;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the client y.
|
||||||
|
*
|
||||||
|
* @return the client y
|
||||||
|
*/
|
||||||
public int getClientY() {
|
public int getClientY() {
|
||||||
return clientY;
|
return clientY;
|
||||||
}
|
}
|
||||||
|
|
||||||
public FileModel getTargetFileModel() {
|
/**
|
||||||
return targetFileModel;
|
* Gets the selected items.
|
||||||
|
*
|
||||||
|
* @return the selectedItems
|
||||||
|
*/
|
||||||
|
public List<FileModel> getSelectedItems() {
|
||||||
|
|
||||||
|
return selectedItems;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,92 +0,0 @@
|
||||||
package org.gcube.portlets.user.workspace.client.event;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import org.gcube.portlets.user.workspace.client.interfaces.EventsTypeEnum;
|
|
||||||
import org.gcube.portlets.user.workspace.client.interfaces.GuiEventInterface;
|
|
||||||
import org.gcube.portlets.user.workspace.client.view.tree.CutCopyAndPaste.OperationType;
|
|
||||||
|
|
||||||
import com.google.gwt.event.shared.GwtEvent;
|
|
||||||
|
|
||||||
public class PasteItemEvent extends GwtEvent<PasteItemEventHandler> implements GuiEventInterface{
|
|
||||||
public static Type<PasteItemEventHandler> TYPE = new Type<PasteItemEventHandler>();
|
|
||||||
|
|
||||||
// private String itemId = null;
|
|
||||||
private String folderDestinationId;
|
|
||||||
|
|
||||||
private List<String> ids;
|
|
||||||
|
|
||||||
private OperationType operationType;
|
|
||||||
|
|
||||||
private String folderSourceId; //Used to move
|
|
||||||
|
|
||||||
private boolean treeRefreshable;
|
|
||||||
|
|
||||||
|
|
||||||
// public PasteItemEvent(String itemId, String folderDestinationId) {
|
|
||||||
// this.itemId = itemId;
|
|
||||||
// this.folderDestinationId = folderDestinationId;
|
|
||||||
// }
|
|
||||||
|
|
||||||
public PasteItemEvent(List<String> ids, String folderDestinationId, OperationType operation) {
|
|
||||||
this.ids = ids;
|
|
||||||
this.folderDestinationId = folderDestinationId;
|
|
||||||
this.operationType = operation;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Type<PasteItemEventHandler> getAssociatedType() {
|
|
||||||
return TYPE;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void dispatch(PasteItemEventHandler handler) {
|
|
||||||
handler.onCutCopyAndPaste(this);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// public String getItemId() {
|
|
||||||
// return itemId;
|
|
||||||
// }
|
|
||||||
|
|
||||||
public String getFolderDestinationId() {
|
|
||||||
return folderDestinationId;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.gcube.portlets.user.workspace.client.interfaces.GuiEventInterface#getKey()
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public EventsTypeEnum getKey() {
|
|
||||||
return EventsTypeEnum.PASTED_EVENT;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<String> getIds() {
|
|
||||||
return ids;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setIds(List<String> ids) {
|
|
||||||
this.ids = ids;
|
|
||||||
}
|
|
||||||
|
|
||||||
public OperationType getOperationType() {
|
|
||||||
return operationType;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getFolderSourceId() {
|
|
||||||
return folderSourceId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setFolderSourceId(String folderSourceId) {
|
|
||||||
this.folderSourceId = folderSourceId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setTreeRefreshable(boolean bool){
|
|
||||||
this.treeRefreshable = bool;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isTreeRefreshable() {
|
|
||||||
return treeRefreshable;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,7 +0,0 @@
|
||||||
package org.gcube.portlets.user.workspace.client.event;
|
|
||||||
|
|
||||||
import com.google.gwt.event.shared.EventHandler;
|
|
||||||
|
|
||||||
public interface PasteItemEventHandler extends EventHandler {
|
|
||||||
void onCutCopyAndPaste(PasteItemEvent pasteItemEvent);
|
|
||||||
}
|
|
|
@ -28,11 +28,12 @@ public enum EventsTypeEnum
|
||||||
REPLY_FORWARD_MESSAGE,
|
REPLY_FORWARD_MESSAGE,
|
||||||
FILE_DOWNLAD_EVENT,
|
FILE_DOWNLAD_EVENT,
|
||||||
SESSION_EXPIRED,
|
SESSION_EXPIRED,
|
||||||
PASTED_EVENT,
|
MOVED_EVENT,
|
||||||
COPY_EVENT,
|
COPY_EVENT,
|
||||||
TRASH_EVENT,
|
TRASH_EVENT,
|
||||||
UPDATED_VRE_PERMISSION,
|
UPDATED_VRE_PERMISSION,
|
||||||
UPDATE_WORKSPACE_SIZE,
|
UPDATE_WORKSPACE_SIZE,
|
||||||
ADD_ADMINISTRATOR_EVENT,
|
ADD_ADMINISTRATOR_EVENT,
|
||||||
FILE_VERSIONING_HISTORY_EVENT;
|
FILE_VERSIONING_HISTORY_EVENT,
|
||||||
|
LOAD_FOLDER_EVENT;
|
||||||
}
|
}
|
|
@ -132,18 +132,22 @@ public interface SubscriberInterface {
|
||||||
*/
|
*/
|
||||||
void viewSessionExpiredPanel();
|
void viewSessionExpiredPanel();
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Paste event is completed.
|
* Move event is completed.
|
||||||
*
|
*
|
||||||
* @param isTreeRefreshable the is tree refreshable
|
* @param isTreeRefreshable the is tree refreshable
|
||||||
* @param parentId the parent id
|
* @param folderDestinationId the folder destination id
|
||||||
*/
|
*/
|
||||||
void pasteEventIsCompleted(boolean isTreeRefreshable, String parentId);
|
void moveEventIsCompleted(boolean isTreeRefreshable, String folderDestinationId);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Copy event is completed.
|
* Copy event is completed.
|
||||||
|
*
|
||||||
|
* @param folderDestinationId the folder destination id
|
||||||
*/
|
*/
|
||||||
void copyEventIsCompleted();
|
void copyEventIsCompleted(String folderDestinationId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Trash event.
|
* Trash event.
|
||||||
|
@ -185,4 +189,12 @@ public interface SubscriberInterface {
|
||||||
*/
|
*/
|
||||||
void versioningHistory(FileModel file);
|
void versioningHistory(FileModel file);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Load folder.
|
||||||
|
*
|
||||||
|
* @param folderTarget the folder target
|
||||||
|
*/
|
||||||
|
void loadFolder(FileModel folderTarget);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -607,6 +607,8 @@ public class FileModel extends BaseModelData implements Serializable {
|
||||||
builder.append(getIdentifier());
|
builder.append(getIdentifier());
|
||||||
builder.append(", getName()=");
|
builder.append(", getName()=");
|
||||||
builder.append(getName());
|
builder.append(getName());
|
||||||
|
builder.append(", isPublic()=");
|
||||||
|
builder.append(isPublic);
|
||||||
// builder.append(", getParentFileModel()=");
|
// builder.append(", getParentFileModel()=");
|
||||||
// builder.append(getParentFileModel());
|
// builder.append(getParentFileModel());
|
||||||
builder.append(", isDirectory()=");
|
builder.append(", isDirectory()=");
|
||||||
|
|
|
@ -456,6 +456,8 @@ public interface Icons extends ClientBundle {
|
||||||
@Source("icons/sync-icon-synched.png")
|
@Source("icons/sync-icon-synched.png")
|
||||||
ImageResource syncIconSynched();
|
ImageResource syncIconSynched();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1261,6 +1261,16 @@ public class Resources {
|
||||||
return AbstractImagePrototype.create(ICONS.syncIconSynched());
|
return AbstractImagePrototype.create(ICONS.syncIconSynched());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the image delete.
|
||||||
|
*
|
||||||
|
* @return the image delete
|
||||||
|
*/
|
||||||
|
public static AbstractImagePrototype getIconMove24() {
|
||||||
|
return AbstractImagePrototype.create(StorageHubIconResources.INSTANCE.move24());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//ImageResources
|
//ImageResources
|
||||||
/**
|
/**
|
||||||
* Gets the image path separator.
|
* Gets the image path separator.
|
||||||
|
@ -1326,7 +1336,6 @@ public class Resources {
|
||||||
return ICONS.delete2();
|
return ICONS.delete2();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the image attachs.
|
* Gets the image attachs.
|
||||||
*
|
*
|
||||||
|
@ -1501,4 +1510,7 @@ public class Resources {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,6 +28,7 @@ import org.gcube.portlets.user.workspace.shared.TrashContent;
|
||||||
import org.gcube.portlets.user.workspace.shared.TrashOperationContent;
|
import org.gcube.portlets.user.workspace.shared.TrashOperationContent;
|
||||||
import org.gcube.portlets.user.workspace.shared.UserBean;
|
import org.gcube.portlets.user.workspace.shared.UserBean;
|
||||||
import org.gcube.portlets.user.workspace.shared.WorkspaceACL;
|
import org.gcube.portlets.user.workspace.shared.WorkspaceACL;
|
||||||
|
import org.gcube.portlets.user.workspace.shared.WorkspaceOperationResult;
|
||||||
import org.gcube.portlets.user.workspace.shared.WorkspaceTrashOperation;
|
import org.gcube.portlets.user.workspace.shared.WorkspaceTrashOperation;
|
||||||
import org.gcube.portlets.user.workspace.shared.WorkspaceUserQuote;
|
import org.gcube.portlets.user.workspace.shared.WorkspaceUserQuote;
|
||||||
import org.gcube.portlets.user.workspace.shared.WorkspaceVersioningOperation;
|
import org.gcube.portlets.user.workspace.shared.WorkspaceVersioningOperation;
|
||||||
|
@ -44,6 +45,14 @@ import com.google.gwt.user.client.rpc.RemoteServiceRelativePath;
|
||||||
*/
|
*/
|
||||||
@RemoteServiceRelativePath("WorkspaceService")
|
@RemoteServiceRelativePath("WorkspaceService")
|
||||||
public interface GWTWorkspaceService extends RemoteService{
|
public interface GWTWorkspaceService extends RemoteService{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the link for send to switch board.
|
||||||
|
*
|
||||||
|
* @param itemId the item id
|
||||||
|
* @return the link for send to switch board
|
||||||
|
* @throws Exception the exception
|
||||||
|
*/
|
||||||
String getLinkForSendToSwitchBoard(String itemId) throws Exception ;
|
String getLinkForSendToSwitchBoard(String itemId) throws Exception ;
|
||||||
/**
|
/**
|
||||||
* Gets the servlet context path.
|
* Gets the servlet context path.
|
||||||
|
@ -75,7 +84,7 @@ public interface GWTWorkspaceService extends RemoteService{
|
||||||
* @return the root for tree
|
* @return the root for tree
|
||||||
* @throws Exception the exception
|
* @throws Exception the exception
|
||||||
*/
|
*/
|
||||||
public FolderModel getRootForTree(String scopeId) throws Exception;
|
//public FolderModel getRootForTree(String scopeId) throws Exception;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the all scope.
|
* Gets the all scope.
|
||||||
|
@ -228,17 +237,6 @@ public interface GWTWorkspaceService extends RemoteService{
|
||||||
*/
|
*/
|
||||||
List<FileGridModel> getItemsBySearchName(String text, String folderId) throws Exception;
|
List<FileGridModel> getItemsBySearchName(String text, String folderId) throws Exception;
|
||||||
|
|
||||||
/**
|
|
||||||
* Move item.
|
|
||||||
*
|
|
||||||
* @param itemId the item id
|
|
||||||
* @param destinationId the destination id
|
|
||||||
* @return the boolean
|
|
||||||
* @throws Exception the exception
|
|
||||||
*/
|
|
||||||
public Boolean moveItem(String itemId, String destinationId) throws Exception;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Delete item.
|
* Delete item.
|
||||||
*
|
*
|
||||||
|
@ -298,16 +296,6 @@ public interface GWTWorkspaceService extends RemoteService{
|
||||||
*/
|
*/
|
||||||
public boolean sendToById(List<String> listContactsId, List<String> listAttachmentsId, String subject, String text) throws Exception;
|
public boolean sendToById(List<String> listContactsId, List<String> listAttachmentsId, String subject, String text) throws Exception;
|
||||||
|
|
||||||
/**
|
|
||||||
* Copy item.
|
|
||||||
*
|
|
||||||
* @param itemId the item id
|
|
||||||
* @param destinationFolderId the destination folder id
|
|
||||||
* @return true, if successful
|
|
||||||
* @throws Exception the exception
|
|
||||||
*/
|
|
||||||
public boolean copyItem(String itemId, String destinationFolderId) throws Exception;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the time series by id.
|
* Gets the time series by id.
|
||||||
*
|
*
|
||||||
|
@ -469,15 +457,16 @@ public interface GWTWorkspaceService extends RemoteService{
|
||||||
*/
|
*/
|
||||||
String getShortUrl(String longUrl) throws Exception;
|
String getShortUrl(String longUrl) throws Exception;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the public link for folder item id.
|
* Gets the public link for file item id.
|
||||||
*
|
*
|
||||||
* @param itemId the item id
|
* @param itemId the item id
|
||||||
* @param shortenUrl the shorten url
|
* @param shortenUrl the shorten url
|
||||||
* @return the public link for folder item id
|
* @return the public link for file item id
|
||||||
* @throws Exception the exception
|
* @throws Exception the exception
|
||||||
*/
|
*/
|
||||||
PublicLink getPublicLinkForFolderItemId(String itemId, boolean shortenUrl)
|
PublicLink getPublicLinkForFileItemId(String itemId, boolean shortenUrl)
|
||||||
throws Exception;
|
throws Exception;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -508,18 +497,19 @@ public interface GWTWorkspaceService extends RemoteService{
|
||||||
* @return true, if successful
|
* @return true, if successful
|
||||||
* @throws Exception the exception
|
* @throws Exception the exception
|
||||||
*/
|
*/
|
||||||
boolean copyItems(List<String> idsItem, String destinationFolderId)
|
WorkspaceOperationResult copyItems(List<String> idsItem, String destinationFolderId)
|
||||||
throws Exception;
|
throws Exception;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Move items.
|
* Move items.
|
||||||
*
|
*
|
||||||
* @param ids the ids
|
* @param ids the ids
|
||||||
* @param destinationId the destination id
|
* @param destinationId the destination id
|
||||||
* @return the boolean
|
* @return the workpace operation result
|
||||||
* @throws Exception the exception
|
* @throws Exception the exception
|
||||||
*/
|
*/
|
||||||
Boolean moveItems(List<String> ids, String destinationId) throws Exception;
|
WorkspaceOperationResult moveItems(List<String> ids, String destinationId) throws Exception;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the AC ls.
|
* Gets the AC ls.
|
||||||
|
|
|
@ -30,6 +30,7 @@ import org.gcube.portlets.user.workspace.shared.TrashContent;
|
||||||
import org.gcube.portlets.user.workspace.shared.TrashOperationContent;
|
import org.gcube.portlets.user.workspace.shared.TrashOperationContent;
|
||||||
import org.gcube.portlets.user.workspace.shared.UserBean;
|
import org.gcube.portlets.user.workspace.shared.UserBean;
|
||||||
import org.gcube.portlets.user.workspace.shared.WorkspaceACL;
|
import org.gcube.portlets.user.workspace.shared.WorkspaceACL;
|
||||||
|
import org.gcube.portlets.user.workspace.shared.WorkspaceOperationResult;
|
||||||
import org.gcube.portlets.user.workspace.shared.WorkspaceTrashOperation;
|
import org.gcube.portlets.user.workspace.shared.WorkspaceTrashOperation;
|
||||||
import org.gcube.portlets.user.workspace.shared.WorkspaceUserQuote;
|
import org.gcube.portlets.user.workspace.shared.WorkspaceUserQuote;
|
||||||
import org.gcube.portlets.user.workspace.shared.WorkspaceVersioningOperation;
|
import org.gcube.portlets.user.workspace.shared.WorkspaceVersioningOperation;
|
||||||
|
@ -68,7 +69,7 @@ public interface GWTWorkspaceServiceAsync {
|
||||||
* @param callback the callback
|
* @param callback the callback
|
||||||
* @return the root for tree
|
* @return the root for tree
|
||||||
*/
|
*/
|
||||||
void getRootForTree(String scopeId, AsyncCallback<FolderModel> callback);
|
//void getRootForTree(String scopeId, AsyncCallback<FolderModel> callback);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the folder children.
|
* Gets the folder children.
|
||||||
|
@ -88,15 +89,6 @@ public interface GWTWorkspaceServiceAsync {
|
||||||
*/
|
*/
|
||||||
void getFolderChildrenForFileGrid(FileModel folder, AsyncCallback<List<FileGridModel>> callback);
|
void getFolderChildrenForFileGrid(FileModel folder, AsyncCallback<List<FileGridModel>> callback);
|
||||||
|
|
||||||
/**
|
|
||||||
* Move item.
|
|
||||||
*
|
|
||||||
* @param itemId the item id
|
|
||||||
* @param destinationId the destination id
|
|
||||||
* @param callback the callback
|
|
||||||
*/
|
|
||||||
void moveItem(String itemId, String destinationId, AsyncCallback<Boolean> callback);
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Delete item.
|
* Delete item.
|
||||||
|
@ -261,7 +253,6 @@ public interface GWTWorkspaceServiceAsync {
|
||||||
*/
|
*/
|
||||||
void getAllContacts(AsyncCallback<List<InfoContactModel>> callback);
|
void getAllContacts(AsyncCallback<List<InfoContactModel>> callback);
|
||||||
|
|
||||||
// void sendTo(List<InfoContactModel> listContacts, List<FileModel> listAttachments, String subject, String text, AsyncCallback<Boolean> callback);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Send to by id.
|
* Send to by id.
|
||||||
|
@ -274,14 +265,6 @@ public interface GWTWorkspaceServiceAsync {
|
||||||
*/
|
*/
|
||||||
void sendToById(List<String> listContactsId, List<String> listAttachmentsId, String subject, String text, AsyncCallback<Boolean> callback);
|
void sendToById(List<String> listContactsId, List<String> listAttachmentsId, String subject, String text, AsyncCallback<Boolean> callback);
|
||||||
|
|
||||||
/**
|
|
||||||
* Copy item.
|
|
||||||
*
|
|
||||||
* @param itemId the item id
|
|
||||||
* @param destinationFolderId the destination folder id
|
|
||||||
* @param callback the callback
|
|
||||||
*/
|
|
||||||
void copyItem(String itemId, String destinationFolderId, AsyncCallback<Boolean> callback);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the url web dav.
|
* Gets the url web dav.
|
||||||
|
@ -478,15 +461,16 @@ public interface GWTWorkspaceServiceAsync {
|
||||||
*/
|
*/
|
||||||
void getShortUrl(String longUrl, AsyncCallback<String> callback);
|
void getShortUrl(String longUrl, AsyncCallback<String> callback);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the public link for folder item id.
|
* Gets the public link for file item id.
|
||||||
*
|
*
|
||||||
* @param itemId the item id
|
* @param itemId the item id
|
||||||
* @param shortenUrl the shorten url
|
* @param shortenUrl the shorten url
|
||||||
* @param callback the callback
|
* @param callback the callback
|
||||||
* @return the public link for folder item id
|
* @return the public link for file item id
|
||||||
*/
|
*/
|
||||||
void getPublicLinkForFolderItemId(String itemId, boolean shortenUrl,
|
void getPublicLinkForFileItemId(String itemId, boolean shortenUrl,
|
||||||
AsyncCallback<PublicLink> callback);
|
AsyncCallback<PublicLink> callback);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -505,25 +489,13 @@ public interface GWTWorkspaceServiceAsync {
|
||||||
void deleteListItemsForIds(List<String> ids,
|
void deleteListItemsForIds(List<String> ids,
|
||||||
AsyncCallback<List<GarbageItem>> callback);
|
AsyncCallback<List<GarbageItem>> callback);
|
||||||
|
|
||||||
/**
|
void copyItems(
|
||||||
* Copy items.
|
List<String> idsItem, String destinationFolderId,
|
||||||
*
|
AsyncCallback<WorkspaceOperationResult> callback);
|
||||||
* @param idsItem the ids item
|
|
||||||
* @param destinationFolderId the destination folder id
|
|
||||||
* @param callback the callback
|
|
||||||
*/
|
|
||||||
void copyItems(List<String> idsItem, String destinationFolderId,
|
|
||||||
AsyncCallback<Boolean> callback);
|
|
||||||
|
|
||||||
/**
|
void moveItems(
|
||||||
* Move items.
|
List<String> ids, String destinationId,
|
||||||
*
|
AsyncCallback<WorkspaceOperationResult> callback);
|
||||||
* @param ids the ids
|
|
||||||
* @param destinationId the destination id
|
|
||||||
* @param callback the callback
|
|
||||||
*/
|
|
||||||
void moveItems(List<String> ids, String destinationId,
|
|
||||||
AsyncCallback<Boolean> callback);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the AC ls.
|
* Gets the AC ls.
|
||||||
|
|
|
@ -1,304 +0,0 @@
|
||||||
//package org.gcube.portlets.user.workspace.client.uploader;
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//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.client.view.windows.InfoDisplayMessage;
|
|
||||||
//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.MessageBoxWait;
|
|
||||||
//import org.gcube.portlets.user.workspace.shared.HandlerResultMessage;
|
|
||||||
//
|
|
||||||
//import com.extjs.gxt.ui.client.Style.HorizontalAlignment;
|
|
||||||
//import com.extjs.gxt.ui.client.event.ButtonEvent;
|
|
||||||
//import com.extjs.gxt.ui.client.event.Events;
|
|
||||||
//import com.extjs.gxt.ui.client.event.FormEvent;
|
|
||||||
//import com.extjs.gxt.ui.client.event.Listener;
|
|
||||||
//import com.extjs.gxt.ui.client.event.MessageBoxEvent;
|
|
||||||
//import com.extjs.gxt.ui.client.event.SelectionListener;
|
|
||||||
//import com.extjs.gxt.ui.client.widget.Dialog;
|
|
||||||
//import com.extjs.gxt.ui.client.widget.Info;
|
|
||||||
//import com.extjs.gxt.ui.client.widget.Window;
|
|
||||||
//import com.extjs.gxt.ui.client.widget.button.Button;
|
|
||||||
//import com.extjs.gxt.ui.client.widget.form.FileUploadField;
|
|
||||||
//import com.extjs.gxt.ui.client.widget.form.FormPanel;
|
|
||||||
//import com.extjs.gxt.ui.client.widget.form.FormPanel.Encoding;
|
|
||||||
//import com.extjs.gxt.ui.client.widget.form.FormPanel.Method;
|
|
||||||
//import com.google.gwt.user.client.Timer;
|
|
||||||
//import com.google.gwt.user.client.rpc.AsyncCallback;
|
|
||||||
//import com.google.gwt.user.client.ui.HTML;
|
|
||||||
//import com.google.gwt.user.client.ui.Hidden;
|
|
||||||
//
|
|
||||||
//
|
|
||||||
///**
|
|
||||||
// * @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
|
||||||
// *
|
|
||||||
// */
|
|
||||||
//public class DialogUpload extends Window {
|
|
||||||
//
|
|
||||||
// private final FormPanel formPanel = new FormPanel();
|
|
||||||
// private FileUploadField fileUploadField = new FileUploadField();
|
|
||||||
// private MessageBoxWait messageBoxWait = null;
|
|
||||||
// private boolean isStatusCompleted = false;
|
|
||||||
// private Button btnSubmit = new Button("Submit");
|
|
||||||
// private Button btnCancel = new Button("Cancel");
|
|
||||||
// private Hidden hiddenOverwrite = new Hidden(ConstantsExplorer.IS_OVERWRITE,"false");
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// private String parentIdentifier = "";
|
|
||||||
// private String parentName = "";
|
|
||||||
//
|
|
||||||
// public DialogUpload(String headerTitle, String parentName, final FileModel parent, String fieldLabel){
|
|
||||||
//
|
|
||||||
// this.setHeaderVisible(true);
|
|
||||||
// this.setHeading(headerTitle + parentName);
|
|
||||||
// this.parentIdentifier = parent.getIdentifier();
|
|
||||||
// this.parentName = parentName;
|
|
||||||
// this.setStyleAttribute("margin", "10px");
|
|
||||||
//
|
|
||||||
// // Create a FormPanel and point it at a service.
|
|
||||||
//
|
|
||||||
// // Create a FormPanel and point it at a service.
|
|
||||||
// formPanel.setHeaderVisible(false);
|
|
||||||
// formPanel.setFrame(true);
|
|
||||||
// formPanel.setAction(ConstantsExplorer.UPLOAD_WORKSPACE_SERVICE);
|
|
||||||
// formPanel.setEncoding(Encoding.MULTIPART);
|
|
||||||
// formPanel.setMethod(Method.POST);
|
|
||||||
//
|
|
||||||
// formPanel.setButtonAlign(HorizontalAlignment.CENTER);
|
|
||||||
// formPanel.setWidth(400);
|
|
||||||
//
|
|
||||||
// // TextField<String> name = new TextField<String>();
|
|
||||||
// // name.setFieldLabel("Name");
|
|
||||||
// // formPanel.add(name);
|
|
||||||
//
|
|
||||||
// fileUploadField.setAllowBlank(false);
|
|
||||||
// fileUploadField.setName(ConstantsExplorer.UPLOAD_FORM_ELEMENT);
|
|
||||||
//
|
|
||||||
// // Add hidden parameters
|
|
||||||
// formPanel.add(new Hidden(ConstantsExplorer.ID_FOLDER,parent.getIdentifier()));
|
|
||||||
// formPanel.add(new Hidden(ConstantsExplorer.UPLOAD_TYPE,fieldLabel));
|
|
||||||
// formPanel.add(hiddenOverwrite);
|
|
||||||
//
|
|
||||||
// // fileUploadField.setFieldLabel(ConstantsExplorer.FILE);
|
|
||||||
// fileUploadField.setFieldLabel(fieldLabel);
|
|
||||||
// formPanel.add(fileUploadField);
|
|
||||||
// formPanel.addButton(btnSubmit);
|
|
||||||
//
|
|
||||||
// formPanel.addButton(btnCancel);
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// // handle the post
|
|
||||||
// formPanel.addListener(Events.Submit, new Listener<FormEvent>() {
|
|
||||||
//
|
|
||||||
// public void handleEvent(FormEvent event) {
|
|
||||||
// // When the form submission is successfully completed, this
|
|
||||||
// // event is
|
|
||||||
// // fired. Assuming the service returned a response of type
|
|
||||||
// // text/html,
|
|
||||||
//
|
|
||||||
// isStatusCompleted = true;
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// // Log.trace("onSubmitComplete");
|
|
||||||
// String result = event.getResultHtml();
|
|
||||||
//
|
|
||||||
// // Log.trace("Result "+result);
|
|
||||||
// hide();
|
|
||||||
//
|
|
||||||
// messageBoxWait.getMessageBoxWait().close();
|
|
||||||
//
|
|
||||||
// if (result == null) {
|
|
||||||
// // MessageUtil.showErrorMessage("Error during upload", "An error occurred during file upload.");
|
|
||||||
// new MessageBoxAlert("Error during upload", "An error occurred during file upload.", null);
|
|
||||||
// return;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// //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(result).getText();
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//// com.google.gwt.user.client.Window.alert(result);
|
|
||||||
//// com.google.gwt.user.client.Window.alert("Stripped: " + strippedResult);
|
|
||||||
//
|
|
||||||
// final HandlerResultMessage resultMessage = HandlerResultMessage.parseResult(strippedResult);
|
|
||||||
//
|
|
||||||
// switch (resultMessage.getStatus()) {
|
|
||||||
// case ERROR:
|
|
||||||
// new MessageBoxAlert("Error during upload", resultMessage.getMessage(), null);
|
|
||||||
// break;
|
|
||||||
// case UNKNOWN:
|
|
||||||
// new MessageBoxAlert("Error during upload", resultMessage.getMessage(), null);
|
|
||||||
// break;
|
|
||||||
// case WARN: {
|
|
||||||
// new MessageBoxAlert("Upload completed with warnings", resultMessage.getMessage(), null);
|
|
||||||
// break;
|
|
||||||
// }
|
|
||||||
// case OK: {
|
|
||||||
// Timer t = new Timer() {
|
|
||||||
// public void run() {
|
|
||||||
// AppControllerExplorer.getEventBus().fireEvent(new CompletedFileUploadEvent(parent, null));
|
|
||||||
// new InfoDisplayMessage("Upload completed successfully", resultMessage.getMessage());
|
|
||||||
// }
|
|
||||||
// };
|
|
||||||
//
|
|
||||||
// t.schedule(250);
|
|
||||||
//
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
//
|
|
||||||
// add(formPanel);
|
|
||||||
//
|
|
||||||
// this.addListeners();
|
|
||||||
//
|
|
||||||
// this.setAutoWidth(true);
|
|
||||||
// this.setAutoHeight(true);
|
|
||||||
//
|
|
||||||
//// this.show();
|
|
||||||
//
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// private void addListeners() {
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// btnSubmit.addSelectionListener(new SelectionListener<ButtonEvent>() {
|
|
||||||
// @Override
|
|
||||||
// public void componentSelected(ButtonEvent ce) {
|
|
||||||
// if (fileUploadField.getValue()==null || !(fileUploadField.getValue().length()>2)) {
|
|
||||||
// new MessageBoxAlert(ConstantsExplorer.ERROR, ConstantsExplorer.NOFILESPECIFIED, null);
|
|
||||||
// return;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
//// com.google.gwt.user.client.Window.alert("parentIdentifier "+parentIdentifier);
|
|
||||||
//// com.google.gwt.user.client.Window.alert("fileUploadField.getValue() "+fileUploadField.getValue());
|
|
||||||
//// com.google.gwt.user.client.Window.alert("parentName "+parentName);
|
|
||||||
// /*
|
|
||||||
// * TODO: recall: Some browser would write in fileUploadField.getValue() C:\fakepath\$fileName
|
|
||||||
// */
|
|
||||||
// String normalizedFileName = fileUploadField.getValue();
|
|
||||||
//
|
|
||||||
//// 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;
|
|
||||||
// AppControllerExplorer.rpcWorkspaceService.itemExistsInWorkpaceFolder(parentIdentifier, normalizedFileName, new AsyncCallback<String>() {
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public void onSuccess(final String itemId) {
|
|
||||||
//
|
|
||||||
// if(itemId!=null){
|
|
||||||
//
|
|
||||||
// MessageBoxConfirm msg = new MessageBoxConfirm("Replace "+label+"?", label + " exists in folder "+parentName + ". Overwrite?");
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// msg.getMessageBoxConfirm().addCallback(new Listener<MessageBoxEvent>() {
|
|
||||||
//
|
|
||||||
// public void handleEvent(MessageBoxEvent be) {
|
|
||||||
//
|
|
||||||
// //IF NOT CANCELLED
|
|
||||||
// String clickedButton = be.getButtonClicked().getItemId();
|
|
||||||
//
|
|
||||||
// if(clickedButton.equals(Dialog.YES)){
|
|
||||||
//
|
|
||||||
//// removeItemAndSubmitForm(itemId);
|
|
||||||
// updateItemSubmitForm(itemId);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
// }else
|
|
||||||
// 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");
|
|
||||||
//
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// });
|
|
||||||
//
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// btnCancel.addSelectionListener(new SelectionListener<ButtonEvent>() {
|
|
||||||
// @Override
|
|
||||||
// public void componentSelected(ButtonEvent ce) {
|
|
||||||
// hide();
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// public void submitForm(){
|
|
||||||
//
|
|
||||||
// messageBoxWait = new MessageBoxWait(ConstantsExplorer.PROGRESS, ConstantsExplorer.SAVINGYOURFILE, fileUploadField.getValue());
|
|
||||||
//
|
|
||||||
// //Progress bar for upload
|
|
||||||
// final Timer t = new Timer()
|
|
||||||
// {
|
|
||||||
// public void run()
|
|
||||||
// {
|
|
||||||
// if (isStatusCompleted)
|
|
||||||
// {
|
|
||||||
// cancel();
|
|
||||||
// messageBoxWait.getMessageBoxWait().close();
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// };
|
|
||||||
// t.scheduleRepeating(500);
|
|
||||||
// formPanel.submit();
|
|
||||||
//
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// private void removeItemAndSubmitForm(String itemId){
|
|
||||||
//
|
|
||||||
// AppControllerExplorer.rpcWorkspaceService.removeItem(itemId, new AsyncCallback<Boolean>() {
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public void onFailure(Throwable caught) {
|
|
||||||
// Info.display("Error", caught.getMessage());
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public void onSuccess(Boolean result) {
|
|
||||||
// if(result){
|
|
||||||
// hiddenOverwrite.setValue("true");
|
|
||||||
// submitForm();
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// private void updateItemSubmitForm(String itemId){
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// hiddenOverwrite.setValue("true");
|
|
||||||
// submitForm();
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
//
|
|
|
@ -1,131 +0,0 @@
|
||||||
///**
|
|
||||||
// *
|
|
||||||
// */
|
|
||||||
//package org.gcube.portlets.user.workspace.client.uploader;
|
|
||||||
//
|
|
||||||
//import org.gcube.portlets.user.workspace.client.ConstantsExplorer;
|
|
||||||
//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;
|
|
||||||
//
|
|
||||||
//
|
|
||||||
///**
|
|
||||||
// * The Class FileUploader.
|
|
||||||
// *
|
|
||||||
// * @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
|
||||||
// * Jul 15, 2015
|
|
||||||
// */
|
|
||||||
//public class FileUploader {
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// private final UploadProgressDialog dlg;
|
|
||||||
// private FileModel folderParent;
|
|
||||||
// private UpdateServiceUploader updateServiceUploader;
|
|
||||||
// private String uploadType;
|
|
||||||
//
|
|
||||||
// /**
|
|
||||||
// * Instantiates a new file uploader.
|
|
||||||
// *
|
|
||||||
// * @param eventBus the event bus
|
|
||||||
// * @param folderParent the folder parent
|
|
||||||
// * @param uploadType the upload type
|
|
||||||
// */
|
|
||||||
// public FileUploader(HandlerManager eventBus, FileModel folderParent, String uploadType) {
|
|
||||||
// this.folderParent = folderParent;
|
|
||||||
// this.uploadType = uploadType;
|
|
||||||
//
|
|
||||||
// /**
|
|
||||||
// * Prepare new servlet uploader
|
|
||||||
// */
|
|
||||||
// updateServiceUploader = new UpdateServiceUploader(this, folderParent, uploadType);
|
|
||||||
//
|
|
||||||
// String caption = "Upload ";
|
|
||||||
// if(uploadType.compareTo(ConstantsExplorer.ARCHIVE)==0)
|
|
||||||
// caption+= " a zip Archive";
|
|
||||||
// else if(uploadType.compareTo(ConstantsExplorer.FILE)==0)
|
|
||||||
// caption+= "File";
|
|
||||||
//
|
|
||||||
// caption+= " in: "+folderParent.getName();
|
|
||||||
//
|
|
||||||
// dlg = new UploadProgressDialog(caption, eventBus, true);
|
|
||||||
// dlg.center();
|
|
||||||
// dlg.show();
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// /**
|
|
||||||
// * Submit form.
|
|
||||||
// */
|
|
||||||
// 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();
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// /**
|
|
||||||
// * Overwrite.
|
|
||||||
// */
|
|
||||||
// public void overwrite(){
|
|
||||||
// updateServiceUploader.setOverwrite();
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// /**
|
|
||||||
// * Submit servlet form.
|
|
||||||
// *
|
|
||||||
// * @param absolutePathOnServer the absolute path of the file uploaded on the server
|
|
||||||
// */
|
|
||||||
// public void submitServletForm(String absolutePathOnServer){
|
|
||||||
//
|
|
||||||
// updateServiceUploader.setFileName(absolutePathOnServer);
|
|
||||||
// try {
|
|
||||||
// updateServiceUploader.submitForm();
|
|
||||||
// } catch (Exception e) {
|
|
||||||
// dlg.showRegisteringResult(false);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// /**
|
|
||||||
// * Gets the folder parent.
|
|
||||||
// *
|
|
||||||
// * @return the folder parent
|
|
||||||
// */
|
|
||||||
// public FileModel getFolderParent() {
|
|
||||||
// return folderParent;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// /**
|
|
||||||
// * Gets the upload type.
|
|
||||||
// *
|
|
||||||
// * @return the upload type
|
|
||||||
// */
|
|
||||||
// public String getUploadType() {
|
|
||||||
// return uploadType;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// /**
|
|
||||||
// * Show registering result.
|
|
||||||
// *
|
|
||||||
// * @param b the b
|
|
||||||
// * @param message the message
|
|
||||||
// */
|
|
||||||
// public void showRegisteringResult(boolean b, String message) {
|
|
||||||
// this.dlg.showRegisteringResult(b, message);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// /**
|
|
||||||
// * Show registering result.
|
|
||||||
// *
|
|
||||||
// * @param b the b
|
|
||||||
// */
|
|
||||||
// public void showRegisteringResult(boolean b) {
|
|
||||||
// this.dlg.showRegisteringResult(b);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
//}
|
|
|
@ -1,172 +0,0 @@
|
||||||
//package org.gcube.portlets.user.workspace.client.uploader;
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//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.http.client.URL;
|
|
||||||
//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 static String encodeUrlDelimiters(String s) {
|
|
||||||
// if (s == null) {
|
|
||||||
// return null;
|
|
||||||
// }
|
|
||||||
// s = s.replaceAll(";", "%2F");
|
|
||||||
// s = s.replaceAll("/", "%2F");
|
|
||||||
// s = s.replaceAll(":", "%3A");
|
|
||||||
// s = s.replaceAll("\\?", "%3F");
|
|
||||||
// s = s.replaceAll("&", "%26");
|
|
||||||
// s = s.replaceAll("\\=", "%3D");
|
|
||||||
// s = s.replaceAll("\\+", "%2B");
|
|
||||||
// s = s.replaceAll("\\$", "%24");
|
|
||||||
// s = s.replaceAll(",", "%2C");
|
|
||||||
// s = s.replaceAll("#", "%23");
|
|
||||||
// return s;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// public void submitForm() throws Exception{
|
|
||||||
//
|
|
||||||
// if(fileName == null || fileName.isEmpty())
|
|
||||||
// throw new Exception("File absolute path on server is null");
|
|
||||||
//
|
|
||||||
// String parameters = "";
|
|
||||||
//
|
|
||||||
// String fileNameEscaped = URL.encodeQueryString(fileName);
|
|
||||||
// parameters+=ConstantsExplorer.UPLOAD_FORM_ELEMENT+"="+fileNameEscaped+"&";
|
|
||||||
//
|
|
||||||
// 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;
|
|
||||||
//
|
|
||||||
// GWT.log("Encoded parameters are: "+parameters);
|
|
||||||
//
|
|
||||||
//// String urlRequest = ConstantsExplorer.LOCAL_UPLOAD_WORKSPACE_SERVICE+"?"+parameters;
|
|
||||||
// RequestBuilder requestBuilder = new RequestBuilder(RequestBuilder.POST, ConstantsExplorer.LOCAL_UPLOAD_WORKSPACE_SERVICE);
|
|
||||||
// requestBuilder.setHeader("Content-Type", "application/x-www-form-urlencoded");
|
|
||||||
//
|
|
||||||
// try {
|
|
||||||
//
|
|
||||||
// requestBuilder.sendRequest(parameters, 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:
|
|
||||||
// GWT.log("Error during upload: "+resultMessage.getMessage());
|
|
||||||
// fileUploaderDlg.showRegisteringResult(false, resultMessage.getMessage());
|
|
||||||
// break;
|
|
||||||
// case UNKNOWN:
|
|
||||||
// GWT.log("Error during upload: "+resultMessage.getMessage());
|
|
||||||
// fileUploaderDlg.showRegisteringResult(false, "Error during upload: "+resultMessage.getMessage());
|
|
||||||
// break;
|
|
||||||
// case WARN: {
|
|
||||||
// GWT.log("Upload completed with warnings: "+resultMessage.getMessage());
|
|
||||||
// fileUploaderDlg.showRegisteringResult(false, "Upload completed with warnings: "+resultMessage.getMessage());
|
|
||||||
// break;
|
|
||||||
// }
|
|
||||||
// case OK: {
|
|
||||||
// Timer t = new Timer() {
|
|
||||||
// public void run() {
|
|
||||||
// AppControllerExplorer.getEventBus().fireEvent(new CompletedFileUploadEvent(parent, null));
|
|
||||||
// fileUploaderDlg.showRegisteringResult(true);
|
|
||||||
// }
|
|
||||||
// };
|
|
||||||
//
|
|
||||||
// t.schedule(250);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public void onError(Request request, Throwable exception) {
|
|
||||||
// fileUploaderDlg.showRegisteringResult(false);
|
|
||||||
// return;
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
//
|
|
||||||
// } catch (RequestException e) {
|
|
||||||
// e.printStackTrace();
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// public void setOverwrite(){
|
|
||||||
// overwrite = true;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// public String getFileName() {
|
|
||||||
// return fileName;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// public void setFileName(String fileName) {
|
|
||||||
// this.fileName = fileName;
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
//
|
|
|
@ -1,185 +0,0 @@
|
||||||
package org.gcube.portlets.user.workspace.client.util;
|
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
|
||||||
|
|
||||||
import org.gcube.portlets.user.gcubewidgets.client.popup.GCubeDialog;
|
|
||||||
import org.gcube.portlets.user.workspace.client.ConstantsExplorer;
|
|
||||||
import org.gcube.portlets.user.workspace.client.event.FileDownloadEvent;
|
|
||||||
import org.gcube.portlets.user.workspace.client.rpc.GWTWorkspaceService;
|
|
||||||
import org.gcube.portlets.user.workspace.client.rpc.GWTWorkspaceServiceAsync;
|
|
||||||
import org.gcube.portlets.user.workspace.client.view.windows.MessageBoxAlert;
|
|
||||||
import org.realityforge.gwt.websockets.client.WebSocket;
|
|
||||||
import org.realityforge.gwt.websockets.client.WebSocketListener;
|
|
||||||
|
|
||||||
import com.github.gwtbootstrap.client.ui.Button;
|
|
||||||
import com.github.gwtbootstrap.client.ui.Icon;
|
|
||||||
import com.github.gwtbootstrap.client.ui.constants.IconType;
|
|
||||||
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.typedarrays.shared.ArrayBuffer;
|
|
||||||
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.ui.HTML;
|
|
||||||
import com.google.gwt.user.client.ui.HasAlignment;
|
|
||||||
import com.google.gwt.user.client.ui.VerticalPanel;
|
|
||||||
|
|
||||||
public class FolderDownloadDialog extends GCubeDialog implements WebSocketListener {
|
|
||||||
private final GWTWorkspaceServiceAsync rpcWorkspaceService = (GWTWorkspaceServiceAsync) GWT.create(GWTWorkspaceService.class);
|
|
||||||
|
|
||||||
public static final int WIDTH = 300;
|
|
||||||
public static final int HEIGHT = 50;
|
|
||||||
|
|
||||||
private final WebSocket webSocket = WebSocket.newWebSocketIfSupported();
|
|
||||||
private final String username;
|
|
||||||
private VerticalPanel topPanel = new VerticalPanel();
|
|
||||||
private Icon loading = new Icon();
|
|
||||||
Button close = new Button("Cancel Download");
|
|
||||||
private HTML toShow = new HTML("Locating folder, please wait ...");
|
|
||||||
private String webSocketURL;
|
|
||||||
public FolderDownloadDialog(final FileDownloadEvent folder2Download, String username) {
|
|
||||||
this.webSocket.setListener( this );
|
|
||||||
this.username = username;
|
|
||||||
setText("Preparing folder download");
|
|
||||||
|
|
||||||
toShow.getElement().getStyle().setFontSize(14, Unit.PX);
|
|
||||||
loading.setSpin(true);
|
|
||||||
loading.setType(IconType.ROTATE_RIGHT);
|
|
||||||
|
|
||||||
topPanel.add(toShow);
|
|
||||||
topPanel.add(loading);
|
|
||||||
topPanel.setPixelSize(WIDTH, HEIGHT);
|
|
||||||
|
|
||||||
|
|
||||||
VerticalPanel bPanel = new VerticalPanel();
|
|
||||||
bPanel.setWidth(WIDTH+"px");
|
|
||||||
bPanel.setHorizontalAlignment(HasAlignment.ALIGN_RIGHT);
|
|
||||||
bPanel.add(close);
|
|
||||||
close.addClickHandler(new ClickHandler() {
|
|
||||||
@Override
|
|
||||||
public void onClick(ClickEvent event) {
|
|
||||||
hide();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
topPanel.add(bPanel);
|
|
||||||
add(topPanel);
|
|
||||||
|
|
||||||
rpcWorkspaceService.getServletContextPath(Window.Location.getProtocol(), new AsyncCallback<String>() {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onSuccess(String servletContextPath) {
|
|
||||||
webSocketURL = getWebSocketURL(servletContextPath);
|
|
||||||
startZipping(webSocketURL, folder2Download.getItemIdentifier());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onFailure(Throwable caught) {
|
|
||||||
loading.setIcon(IconType.EXCLAMATION_SIGN);
|
|
||||||
loading.setSpin(false);
|
|
||||||
toShow.setText("Error trying contact the server, please refresh this page and retry");
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean startZipping(String webSocketURL, final String folderIdToZip) {
|
|
||||||
if ( null == webSocket ) {
|
|
||||||
Window.alert( "WebSocket not available!" );
|
|
||||||
}
|
|
||||||
|
|
||||||
webSocket.connect( webSocketURL );
|
|
||||||
//allow some timet to connect
|
|
||||||
Timer t = new Timer() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
webSocket.send(ConstantsExplorer.DOWNLOAD_WORKSPACE_FOLDER_PROTOCOL_DO_ZIP+":"+folderIdToZip+":"+username);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
t.schedule(2000);
|
|
||||||
return true;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private String getWebSocketURL(String servletContextPath) {
|
|
||||||
String moduleBaseURL = servletContextPath;
|
|
||||||
return moduleBaseURL.replaceFirst( "http", "ws" ) + "/" + ConstantsExplorer.DOWNLOAD_WORKSPACE_FOLDER_SERVICE;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onOpen(WebSocket webSocket) { }
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onClose(WebSocket webSocket, boolean wasClean, int code, String reason) { }
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onMessage( @Nonnull final WebSocket webSocket, @Nonnull final String textData ) {
|
|
||||||
switch (textData) {
|
|
||||||
case ConstantsExplorer.DOWNLOAD_WORKSPACE_FOLDER_PROTOCOL_ZIPPING:
|
|
||||||
toShow.setText("Compressing folder, this could take some time ...");
|
|
||||||
break;
|
|
||||||
case ConstantsExplorer.DOWNLOAD_WORKSPACE_FOLDER_PROTOCOL_ERROR_NOT_FOUND:
|
|
||||||
toShow.setText("Could not locate the folder on server, please report this issue");
|
|
||||||
loading.setIcon(IconType.EXCLAMATION_SIGN);
|
|
||||||
loading.setSpin(false);
|
|
||||||
webSocket.close();
|
|
||||||
break;
|
|
||||||
case ConstantsExplorer.DOWNLOAD_WORKSPACE_FOLDER_PROTOCOL_ERROR_DURING_COMPRESSION:
|
|
||||||
toShow.setText("An error occurred while compressing this folder, please report this issue");
|
|
||||||
loading.setIcon(IconType.EXCLAMATION_SIGN);
|
|
||||||
loading.setSpin(false);
|
|
||||||
webSocket.close();
|
|
||||||
break;
|
|
||||||
case ConstantsExplorer.DOWNLOAD_WORKSPACE_FOLDER_PROTOCOL_ERROR_NOT_A_FOLDER:
|
|
||||||
toShow.setText("An error occurred, the folderId is not a valid folder, please report this issue");
|
|
||||||
loading.setIcon(IconType.EXCLAMATION_SIGN);
|
|
||||||
loading.setSpin(false);
|
|
||||||
webSocket.close();
|
|
||||||
break;
|
|
||||||
case ConstantsExplorer.DOWNLOAD_WORKSPACE_FOLDER_PROTOCOL_ERROR_SESSION_EXPIRED:
|
|
||||||
toShow.setText("It seems your session expired, please refresh the page and try again");
|
|
||||||
loading.setIcon(IconType.EXCLAMATION_SIGN);
|
|
||||||
loading.setSpin(false);
|
|
||||||
webSocket.close();
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
//the thread zipping has finished, is sending the zipped filepath on the server
|
|
||||||
toShow.setHTML("Compressing folder success, <a title=\""+textData+"\" href=\""+textData+"\">click here</a> to download");
|
|
||||||
loading.setIcon(IconType.OK_SIGN);
|
|
||||||
loading.setSpin(false);
|
|
||||||
close.setText("Close");
|
|
||||||
this.setModal(false);
|
|
||||||
webSocket.close();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onMessage( @Nonnull final WebSocket webSocket, @Nonnull final ArrayBuffer data ) {}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onError(WebSocket webSocket) {
|
|
||||||
toShow.setText("Error contacting the server socket, please refresh this page and retry");
|
|
||||||
}
|
|
||||||
|
|
||||||
public AsyncCallback<WindowOpenParameter> downloadHandlerCallback = new AsyncCallback<WindowOpenParameter>() {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onFailure(Throwable caught) {
|
|
||||||
new MessageBoxAlert("Error", caught.getMessage(), null);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onSuccess(WindowOpenParameter windowOpenParam) {
|
|
||||||
String params = "?"+windowOpenParam.getParameters();
|
|
||||||
|
|
||||||
if(params.length()>1)
|
|
||||||
params+="&";
|
|
||||||
|
|
||||||
params+=ConstantsExplorer.REDIRECTONERROR+"="+windowOpenParam.isRedirectOnError();
|
|
||||||
|
|
||||||
windowOpenParam.getBrowserWindow().setUrl(ConstantsExplorer.DOWNLOAD_WORKSPACE_FOLDER_SERVLET+params);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
|
@ -87,7 +87,7 @@ public class ExplorerPanel extends LayoutContainer {
|
||||||
setBorders(false);
|
setBorders(false);
|
||||||
initRadioButtons();
|
initRadioButtons();
|
||||||
this.asycTreePanel = new AsyncTreePanel();
|
this.asycTreePanel = new AsyncTreePanel();
|
||||||
this.asycTreePanel.loadRootItem(null,selectRootItem); //load root item
|
this.asycTreePanel.loadRootItem(selectRootItem); //load root item
|
||||||
this.expPanel = new ContentPanel();
|
this.expPanel = new ContentPanel();
|
||||||
this.expPanel.setHeaderVisible(false);
|
this.expPanel.setHeaderVisible(false);
|
||||||
// asycTreePanel.setVisible(true);
|
// asycTreePanel.setVisible(true);
|
||||||
|
|
|
@ -160,8 +160,10 @@ public class DialogShareFolder extends Dialog {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess(InfoContactModel result) {
|
public void onSuccess(InfoContactModel result) {
|
||||||
|
GWT.log("getOwner returned: "+result);
|
||||||
shareOwner = result;
|
shareOwner = result;
|
||||||
txtOwner.setValue(result.getName());
|
if(shareOwner!=null)
|
||||||
|
txtOwner.setValue(shareOwner.getName());
|
||||||
//IF THE FOLDER IS NOT SHARED, CHECKS PERMISSIONS
|
//IF THE FOLDER IS NOT SHARED, CHECKS PERMISSIONS
|
||||||
if(!folder.isShared())
|
if(!folder.isShared())
|
||||||
permissionControl(result.getLogin(), true);
|
permissionControl(result.getLogin(), true);
|
||||||
|
@ -462,7 +464,10 @@ public class DialogShareFolder extends Dialog {
|
||||||
public void componentSelected(ButtonEvent ce) {
|
public void componentSelected(ButtonEvent ce) {
|
||||||
// initSuggestContacts();
|
// initSuggestContacts();
|
||||||
suggestPanel.resetItemSelected();
|
suggestPanel.resetItemSelected();
|
||||||
|
//SHARE OWNER IS NULL IN CASE OF NEW SHARE
|
||||||
|
if(shareOwner!=null)
|
||||||
suggestPanel.addRecipient(shareOwner.getName(),false);
|
suggestPanel.addRecipient(shareOwner.getName(),false);
|
||||||
|
|
||||||
for (InfoContactModel infoContactModel : multiDrag.getTargetListContact()) {
|
for (InfoContactModel infoContactModel : multiDrag.getTargetListContact()) {
|
||||||
suggestPanel.addRecipient(infoContactModel.getName(),true);
|
suggestPanel.addRecipient(infoContactModel.getName(),true);
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,8 +7,8 @@ import org.gcube.portlets.user.workspace.client.AppControllerExplorer;
|
||||||
import org.gcube.portlets.user.workspace.client.ConstantsExplorer;
|
import org.gcube.portlets.user.workspace.client.ConstantsExplorer;
|
||||||
import org.gcube.portlets.user.workspace.client.constant.WorkspaceOperation;
|
import org.gcube.portlets.user.workspace.client.constant.WorkspaceOperation;
|
||||||
import org.gcube.portlets.user.workspace.client.event.CheckItemLockedBySyncEvent;
|
import org.gcube.portlets.user.workspace.client.event.CheckItemLockedBySyncEvent;
|
||||||
|
import org.gcube.portlets.user.workspace.client.event.DragOnTreeMoveItemEvent;
|
||||||
import org.gcube.portlets.user.workspace.client.event.ExpandFolderEvent;
|
import org.gcube.portlets.user.workspace.client.event.ExpandFolderEvent;
|
||||||
import org.gcube.portlets.user.workspace.client.event.MoveItemEvent;
|
|
||||||
import org.gcube.portlets.user.workspace.client.event.SelectedItemEvent;
|
import org.gcube.portlets.user.workspace.client.event.SelectedItemEvent;
|
||||||
import org.gcube.portlets.user.workspace.client.event.SessionExpiredEvent;
|
import org.gcube.portlets.user.workspace.client.event.SessionExpiredEvent;
|
||||||
import org.gcube.portlets.user.workspace.client.model.FileModel;
|
import org.gcube.portlets.user.workspace.client.model.FileModel;
|
||||||
|
@ -73,7 +73,7 @@ public class AsyncTreePanel extends LayoutContainer {
|
||||||
private ContentPanel cp = new ContentPanel();
|
private ContentPanel cp = new ContentPanel();
|
||||||
private boolean isSubTreeLoaded = false;
|
private boolean isSubTreeLoaded = false;
|
||||||
private boolean isSearch = false;
|
private boolean isSearch = false;
|
||||||
private String scopeId = null;
|
//private String scopeId = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Enum DragType.
|
* The Enum DragType.
|
||||||
|
@ -325,35 +325,14 @@ public class AsyncTreePanel extends LayoutContainer {
|
||||||
/**
|
/**
|
||||||
* Load root item.
|
* Load root item.
|
||||||
*
|
*
|
||||||
* @param scopeId the scope id
|
|
||||||
* @param selectRoot the select root
|
* @param selectRoot the select root
|
||||||
*/
|
*/
|
||||||
public void loadRootItem(String scopeId, final boolean selectRoot){
|
public void loadRootItem(final boolean selectRoot){
|
||||||
|
|
||||||
this.scopeId = scopeId;
|
//this.scopeId = scopeId;
|
||||||
|
|
||||||
System.out.println("***Start Root load with scopeid: " + scopeId);
|
System.out.println("***Start Root load");
|
||||||
|
|
||||||
|
|
||||||
if(this.scopeId !=null){
|
|
||||||
//Load Root with specific scope id
|
|
||||||
AppControllerExplorer.rpcWorkspaceService.getRootForTree(scopeId, new AsyncCallback<FolderModel>() {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onFailure(Throwable caught) {
|
|
||||||
new MessageBoxAlert("Error", ConstantsExplorer.SERVER_ERROR + " getting root item. " +ConstantsExplorer.TRY_AGAIN, null);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onSuccess(FolderModel result) {
|
|
||||||
loadRootInStore(result, selectRoot);
|
|
||||||
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
else{
|
|
||||||
//Load Root without filtering on scope id
|
//Load Root without filtering on scope id
|
||||||
AppControllerExplorer.rpcWorkspaceService.getRootForTree(new AsyncCallback<FolderModel>() {
|
AppControllerExplorer.rpcWorkspaceService.getRootForTree(new AsyncCallback<FolderModel>() {
|
||||||
|
|
||||||
|
@ -368,7 +347,42 @@ public class AsyncTreePanel extends LayoutContainer {
|
||||||
loadRootInStore(result, selectRoot);
|
loadRootInStore(result, selectRoot);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
|
||||||
|
|
||||||
|
// if(this.scopeId !=null){
|
||||||
|
// //Load Root with specific scope id
|
||||||
|
// AppControllerExplorer.rpcWorkspaceService.getRootForTree(scopeId, new AsyncCallback<FolderModel>() {
|
||||||
|
//
|
||||||
|
// @Override
|
||||||
|
// public void onFailure(Throwable caught) {
|
||||||
|
// new MessageBoxAlert("Error", ConstantsExplorer.SERVER_ERROR + " getting root item. " +ConstantsExplorer.TRY_AGAIN, null);
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// @Override
|
||||||
|
// public void onSuccess(FolderModel result) {
|
||||||
|
// loadRootInStore(result, selectRoot);
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
// });
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// else{
|
||||||
|
// //Load Root without filtering on scope id
|
||||||
|
// AppControllerExplorer.rpcWorkspaceService.getRootForTree(new AsyncCallback<FolderModel>() {
|
||||||
|
//
|
||||||
|
// @Override
|
||||||
|
// public void onFailure(Throwable caught) {
|
||||||
|
// new MessageBoxAlert("Error", ConstantsExplorer.SERVER_ERROR + " getting root item. " +ConstantsExplorer.TRY_AGAIN, null);
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// @Override
|
||||||
|
// public void onSuccess(FolderModel result) {
|
||||||
|
// loadRootInStore(result, selectRoot);
|
||||||
|
// }
|
||||||
|
// });
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -383,7 +397,7 @@ public class AsyncTreePanel extends LayoutContainer {
|
||||||
if(root!=null){
|
if(root!=null){
|
||||||
store.removeAll();
|
store.removeAll();
|
||||||
store.insert(root, 0, false);
|
store.insert(root, 0, false);
|
||||||
System.out.println("Root Name: " + store.getRootItems().get(0).get(FileModel.NAME));
|
GWT.log("Root Name: " + store.getRootItems().get(0).get(FileModel.NAME));
|
||||||
treePanel.setExpanded(store.getRootItems().get(0),true); //expand level 1
|
treePanel.setExpanded(store.getRootItems().get(0),true); //expand level 1
|
||||||
if(selectRootOnLoad)
|
if(selectRootOnLoad)
|
||||||
selectRootItem(); //select root item
|
selectRootItem(); //select root item
|
||||||
|
@ -516,8 +530,8 @@ public class AsyncTreePanel extends LayoutContainer {
|
||||||
FileModel destination = getDragDestination(item, DragType.APPEND);
|
FileModel destination = getDragDestination(item, DragType.APPEND);
|
||||||
if(destination != null){
|
if(destination != null){
|
||||||
//REMOVE THIS COMMENT TODO
|
//REMOVE THIS COMMENT TODO
|
||||||
eventBus.fireEvent(new MoveItemEvent(listFileModel.get(0), (FolderModel) destination));
|
eventBus.fireEvent(new DragOnTreeMoveItemEvent(listFileModel.get(0), (FolderModel) destination));
|
||||||
System.out.println("Destination: " +destination.getName() + " id "+ destination.getIdentifier());
|
GWT.log("Destination: " +destination.getName() + " id "+ destination.getIdentifier());
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
//MULTIDRAG
|
//MULTIDRAG
|
||||||
|
@ -544,7 +558,7 @@ public class AsyncTreePanel extends LayoutContainer {
|
||||||
if(destination != null){
|
if(destination != null){
|
||||||
GWT.log("Destination: " +destination.getName() + " id "+ destination.getIdentifier());
|
GWT.log("Destination: " +destination.getName() + " id "+ destination.getIdentifier());
|
||||||
//REMOVE THIS COMMENT TODO
|
//REMOVE THIS COMMENT TODO
|
||||||
eventBus.fireEvent(new MoveItemEvent(listFileModel.get(0), (FolderModel) destination));
|
eventBus.fireEvent(new DragOnTreeMoveItemEvent(listFileModel.get(0), (FolderModel) destination));
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
//multi drag
|
//multi drag
|
||||||
|
@ -746,29 +760,15 @@ public class AsyncTreePanel extends LayoutContainer {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Manage context menu.
|
* Manage context menu.
|
||||||
*/
|
*/
|
||||||
private void manageContextMenu(){
|
private void manageContextMenu(){
|
||||||
|
|
||||||
System.out.println("***Event Context Menu open");
|
|
||||||
|
|
||||||
contextMenuTree.setListSelectedItems(treePanel.getSelectionModel().getSelectedItems()); //Set items list selected in context menu tree
|
contextMenuTree.setListSelectedItems(treePanel.getSelectionModel().getSelectedItems()); //Set items list selected in context menu tree
|
||||||
|
List<FileModel> selectedItems = treePanel.getSelectionModel().getSelectedItems();
|
||||||
FileModel selectedItem = treePanel.getSelectionModel().getSelectedItems().get(0); //get first element
|
contextMenuTree.viewContextMenu(selectedItems,-1,-1);
|
||||||
|
|
||||||
if (store.getRootItems().get(0).equals(selectedItem)) {//selected root item?
|
|
||||||
setVisibleRenameAndRemoveContextMenu(false);
|
|
||||||
setVisibileGetWebDavUrl(true);
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
setVisibleRenameAndRemoveContextMenu(true);
|
|
||||||
setVisibileGetWebDavUrl(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
contextMenuTree.contextMenuSwitch(selectedItem);
|
|
||||||
|
|
||||||
System.out.println("***End Event Context Menu open");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -935,14 +935,14 @@ public class AsyncTreePanel extends LayoutContainer {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
// /**
|
||||||
* Sets the visibile get web dav url.
|
// * Sets the visibile get web dav url.
|
||||||
*
|
// *
|
||||||
* @param bool the new visibile get web dav url
|
// * @param bool the new visibile get web dav url
|
||||||
*/
|
// */
|
||||||
private void setVisibileGetWebDavUrl(boolean bool){
|
// private void setVisibileGetWebDavUrl(boolean bool){
|
||||||
treePanel.getContextMenu().getItemByItemId(WorkspaceOperation.WEBDAV_URL.getId()).setVisible(bool);
|
// treePanel.getContextMenu().getItemByItemId(WorkspaceOperation.WEBDAV_URL.getId()).setVisible(bool);
|
||||||
}
|
// }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the alphanumeric store sorter.
|
* Sets the alphanumeric store sorter.
|
||||||
|
@ -1263,7 +1263,7 @@ public class AsyncTreePanel extends LayoutContainer {
|
||||||
*/
|
*/
|
||||||
public void removeAllAndRecoveryRoot(){
|
public void removeAllAndRecoveryRoot(){
|
||||||
store.removeAll();
|
store.removeAll();
|
||||||
loadRootItem(scopeId,true);
|
loadRootItem(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1273,7 +1273,7 @@ public class AsyncTreePanel extends LayoutContainer {
|
||||||
*/
|
*/
|
||||||
public void removeAllAndRecoveryRoot(boolean selectRoot){
|
public void removeAllAndRecoveryRoot(boolean selectRoot){
|
||||||
store.removeAll();
|
store.removeAll();
|
||||||
loadRootItem(scopeId,selectRoot);
|
loadRootItem(selectRoot);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1,8 +1,10 @@
|
||||||
package org.gcube.portlets.user.workspace.client.view.tree;
|
package org.gcube.portlets.user.workspace.client.view.tree;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.gcube.portal.stohubicons.shared.resources.StorageHubIconResources;
|
||||||
import org.gcube.portlets.user.workspace.client.AppControllerExplorer;
|
import org.gcube.portlets.user.workspace.client.AppControllerExplorer;
|
||||||
import org.gcube.portlets.user.workspace.client.ConstantsExplorer;
|
import org.gcube.portlets.user.workspace.client.ConstantsExplorer;
|
||||||
import org.gcube.portlets.user.workspace.client.ConstantsExplorer.WS_UPLOAD_TYPE;
|
import org.gcube.portlets.user.workspace.client.ConstantsExplorer.WS_UPLOAD_TYPE;
|
||||||
|
@ -12,7 +14,7 @@ import org.gcube.portlets.user.workspace.client.event.AccountingHistoryEvent;
|
||||||
import org.gcube.portlets.user.workspace.client.event.AccountingReadersEvent;
|
import org.gcube.portlets.user.workspace.client.event.AccountingReadersEvent;
|
||||||
import org.gcube.portlets.user.workspace.client.event.AddAdministratorEvent;
|
import org.gcube.portlets.user.workspace.client.event.AddAdministratorEvent;
|
||||||
import org.gcube.portlets.user.workspace.client.event.AddFolderEvent;
|
import org.gcube.portlets.user.workspace.client.event.AddFolderEvent;
|
||||||
import org.gcube.portlets.user.workspace.client.event.CopytemEvent;
|
import org.gcube.portlets.user.workspace.client.event.CopyItemsEvent;
|
||||||
import org.gcube.portlets.user.workspace.client.event.CreateSharedFolderEvent;
|
import org.gcube.portlets.user.workspace.client.event.CreateSharedFolderEvent;
|
||||||
import org.gcube.portlets.user.workspace.client.event.CreateUrlEvent;
|
import org.gcube.portlets.user.workspace.client.event.CreateUrlEvent;
|
||||||
import org.gcube.portlets.user.workspace.client.event.DeleteItemEvent;
|
import org.gcube.portlets.user.workspace.client.event.DeleteItemEvent;
|
||||||
|
@ -26,8 +28,8 @@ import org.gcube.portlets.user.workspace.client.event.GetInfoEvent;
|
||||||
import org.gcube.portlets.user.workspace.client.event.GetPublicLinkEvent;
|
import org.gcube.portlets.user.workspace.client.event.GetPublicLinkEvent;
|
||||||
import org.gcube.portlets.user.workspace.client.event.GetShareLinkEvent;
|
import org.gcube.portlets.user.workspace.client.event.GetShareLinkEvent;
|
||||||
import org.gcube.portlets.user.workspace.client.event.ImagePreviewEvent;
|
import org.gcube.portlets.user.workspace.client.event.ImagePreviewEvent;
|
||||||
|
import org.gcube.portlets.user.workspace.client.event.MoveItemsEvent;
|
||||||
import org.gcube.portlets.user.workspace.client.event.OpenUrlEvent;
|
import org.gcube.portlets.user.workspace.client.event.OpenUrlEvent;
|
||||||
import org.gcube.portlets.user.workspace.client.event.PasteItemEvent;
|
|
||||||
import org.gcube.portlets.user.workspace.client.event.PublishOnDataCatalogueEvent;
|
import org.gcube.portlets.user.workspace.client.event.PublishOnDataCatalogueEvent;
|
||||||
import org.gcube.portlets.user.workspace.client.event.RefreshFolderEvent;
|
import org.gcube.portlets.user.workspace.client.event.RefreshFolderEvent;
|
||||||
import org.gcube.portlets.user.workspace.client.event.RenameItemEvent;
|
import org.gcube.portlets.user.workspace.client.event.RenameItemEvent;
|
||||||
|
@ -36,13 +38,10 @@ import org.gcube.portlets.user.workspace.client.event.SyncWithThreddsCatalogueEv
|
||||||
import org.gcube.portlets.user.workspace.client.event.UnShareFolderEvent;
|
import org.gcube.portlets.user.workspace.client.event.UnShareFolderEvent;
|
||||||
import org.gcube.portlets.user.workspace.client.event.VRESettingPermissionEvent;
|
import org.gcube.portlets.user.workspace.client.event.VRESettingPermissionEvent;
|
||||||
import org.gcube.portlets.user.workspace.client.event.VersioningHistoryShowEvent;
|
import org.gcube.portlets.user.workspace.client.event.VersioningHistoryShowEvent;
|
||||||
import org.gcube.portlets.user.workspace.client.event.WebDavUrlEvent;
|
|
||||||
import org.gcube.portlets.user.workspace.client.model.FileModel;
|
import org.gcube.portlets.user.workspace.client.model.FileModel;
|
||||||
import org.gcube.portlets.user.workspace.client.resources.Resources;
|
import org.gcube.portlets.user.workspace.client.resources.Resources;
|
||||||
import org.gcube.portlets.user.workspace.client.util.FileModelUtils;
|
import org.gcube.portlets.user.workspace.client.util.FileModelUtils;
|
||||||
import org.gcube.portlets.user.workspace.client.view.tree.CutCopyAndPaste.OperationType;
|
|
||||||
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.shared.PublicLink;
|
|
||||||
import org.gcube.portlets.user.workspace.shared.SessionExpiredException;
|
import org.gcube.portlets.user.workspace.shared.SessionExpiredException;
|
||||||
import org.gcube.portlets.user.workspace.shared.WorkspaceVersioningOperation;
|
import org.gcube.portlets.user.workspace.shared.WorkspaceVersioningOperation;
|
||||||
|
|
||||||
|
@ -56,6 +55,7 @@ import com.google.gwt.core.client.GWT;
|
||||||
import com.google.gwt.event.shared.HandlerManager;
|
import com.google.gwt.event.shared.HandlerManager;
|
||||||
import com.google.gwt.user.client.Window;
|
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.AbstractImagePrototype;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Class ContextMenuTree.
|
* The Class ContextMenuTree.
|
||||||
|
@ -132,7 +132,7 @@ public class ContextMenuTree {
|
||||||
});
|
});
|
||||||
|
|
||||||
contextMenu.add(openUrl);
|
contextMenu.add(openUrl);
|
||||||
contextMenu.add(new SeparatorMenuItem());
|
//contextMenu.add(new SeparatorMenuItem());
|
||||||
//END SPECIFIC OPERATION
|
//END SPECIFIC OPERATION
|
||||||
|
|
||||||
MenuItem mnGetInfo = new MenuItem();
|
MenuItem mnGetInfo = new MenuItem();
|
||||||
|
@ -241,8 +241,6 @@ public class ContextMenuTree {
|
||||||
|
|
||||||
contextMenu.add(mnFolderLinkRemove);
|
contextMenu.add(mnFolderLinkRemove);
|
||||||
|
|
||||||
contextMenu.add(new SeparatorMenuItem());
|
|
||||||
|
|
||||||
MenuItem mnHistory = new MenuItem();
|
MenuItem mnHistory = new MenuItem();
|
||||||
mnHistory.setIcon(Resources.getIconHistory());
|
mnHistory.setIcon(Resources.getIconHistory());
|
||||||
mnHistory.setId(WorkspaceOperation.HISTORY.getId());
|
mnHistory.setId(WorkspaceOperation.HISTORY.getId());
|
||||||
|
@ -263,6 +261,8 @@ public class ContextMenuTree {
|
||||||
});
|
});
|
||||||
contextMenu.add(mnHistory);
|
contextMenu.add(mnHistory);
|
||||||
|
|
||||||
|
contextMenu.add(new SeparatorMenuItem());
|
||||||
|
|
||||||
//ACCOUNTING READ
|
//ACCOUNTING READ
|
||||||
mnRead = new MenuItem();
|
mnRead = new MenuItem();
|
||||||
mnRead.setIcon(Resources.getIconRead());
|
mnRead.setIcon(Resources.getIconRead());
|
||||||
|
@ -286,7 +286,7 @@ public class ContextMenuTree {
|
||||||
//COMMENTED AT 29/08/2013
|
//COMMENTED AT 29/08/2013
|
||||||
// contextMenu.add(mnRead);
|
// contextMenu.add(mnRead);
|
||||||
|
|
||||||
contextMenu.add(new SeparatorMenuItem());
|
//contextMenu.add(new SeparatorMenuItem());
|
||||||
|
|
||||||
MenuItem insertFolder = new MenuItem();
|
MenuItem insertFolder = new MenuItem();
|
||||||
insertFolder.setId(WorkspaceOperation.INSERT_FOLDER.getId());
|
insertFolder.setId(WorkspaceOperation.INSERT_FOLDER.getId());
|
||||||
|
@ -335,14 +335,13 @@ public class ContextMenuTree {
|
||||||
public void componentSelected(MenuEvent ce) {
|
public void componentSelected(MenuEvent ce) {
|
||||||
|
|
||||||
FileModel selected = listSelectedItems.get(0);
|
FileModel selected = listSelectedItems.get(0);
|
||||||
|
FileModel parent = null;
|
||||||
|
|
||||||
FileModel parent = selected.getParentFileModel();
|
|
||||||
if(parent==null){
|
|
||||||
if(selected.isDirectory()){
|
if(selected.isDirectory()){
|
||||||
parent = selected;
|
parent = selected; //Creating New URL in the selected folder
|
||||||
|
}else{
|
||||||
|
parent = selected.getParentFileModel(); //Creating New URL as brother of selected file
|
||||||
}
|
}
|
||||||
}
|
|
||||||
//FileModel parent = getDirectoryOrParent(selected);
|
|
||||||
|
|
||||||
if(parent!=null){
|
if(parent!=null){
|
||||||
eventBus.fireEvent(new CreateUrlEvent(null, parent));
|
eventBus.fireEvent(new CreateUrlEvent(null, parent));
|
||||||
|
@ -463,47 +462,45 @@ public class ContextMenuTree {
|
||||||
|
|
||||||
contextMenu.add(new SeparatorMenuItem());
|
contextMenu.add(new SeparatorMenuItem());
|
||||||
|
|
||||||
MenuItem copy = new MenuItem();
|
MenuItem moveto = new MenuItem();
|
||||||
copy.setId(WorkspaceOperation.COPY.getId());
|
moveto.setId(WorkspaceOperation.MOVE.getId());
|
||||||
copy.setText(ConstantsExplorer.COPYITEM);
|
moveto.setText(ConstantsExplorer.MOVE);
|
||||||
copy.setIcon(Resources.getIconCopy());
|
moveto.setIcon(AbstractImagePrototype.create(StorageHubIconResources.INSTANCE.move16()));
|
||||||
|
// Widget element = new Widget();
|
||||||
|
// element.getElement().setInnerHTML(theIcon.getHtml());
|
||||||
|
// Image theImage = Image.wrap(element.getElement());
|
||||||
|
|
||||||
copy.addSelectionListener(new SelectionListener<MenuEvent>() {
|
moveto.addSelectionListener(new SelectionListener<MenuEvent>() {
|
||||||
public void componentSelected(MenuEvent ce) {
|
public void componentSelected(MenuEvent ce) {
|
||||||
List<String> ids = FileModelUtils.convertFileModelsToIds(listSelectedItems);
|
List<String> ids = FileModelUtils.convertFileModelsToIds(listSelectedItems);
|
||||||
if(ids.size()>0){
|
if(ids.size()>0){
|
||||||
CutCopyAndPaste.copy(ids, OperationType.COPY);
|
FileModel theSourceParent = listSelectedItems.get(0).getParentFileModel();
|
||||||
eventBus.fireEvent(new CopytemEvent(ids));
|
eventBus.fireEvent(new MoveItemsEvent(ids, null, theSourceParent));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
contextMenu.add(moveto);
|
||||||
|
|
||||||
|
MenuItem copy = new MenuItem();
|
||||||
|
copy.setId(WorkspaceOperation.COPY.getId());
|
||||||
|
copy.setText(ConstantsExplorer.COPY);
|
||||||
|
copy.setIcon(AbstractImagePrototype.create(StorageHubIconResources.INSTANCE.PASTE()));
|
||||||
|
|
||||||
|
copy.addSelectionListener(new SelectionListener<MenuEvent>() {
|
||||||
|
public void componentSelected(MenuEvent ce) {
|
||||||
|
|
||||||
|
List<String> ids = FileModelUtils.convertFileModelsToIds(listSelectedItems);
|
||||||
|
if(ids.size()>0){
|
||||||
|
FileModel theSourceParent = listSelectedItems.get(0).getParentFileModel();
|
||||||
|
eventBus.fireEvent(new CopyItemsEvent(ids, theSourceParent.getIdentifier()));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
contextMenu.add(copy);
|
contextMenu.add(copy);
|
||||||
|
|
||||||
MenuItem paste = new MenuItem();
|
|
||||||
paste.setId(WorkspaceOperation.PASTE.getId());
|
|
||||||
paste.setText(ConstantsExplorer.PASTEITEM);
|
|
||||||
paste.setIcon(Resources.getIconPaste());
|
|
||||||
|
|
||||||
paste.addSelectionListener(new SelectionListener<MenuEvent>() {
|
|
||||||
public void componentSelected(MenuEvent ce) {
|
|
||||||
|
|
||||||
for (FileModel target : listSelectedItems) {
|
|
||||||
FileModel parentTarget = getDirectoryOrParent(target);
|
|
||||||
if(parentTarget!=null){
|
|
||||||
|
|
||||||
eventBus.fireEvent(new PasteItemEvent(CutCopyAndPaste.getCopiedIdsFilesModel(), parentTarget.getIdentifier(), CutCopyAndPaste.getOperationType()));
|
|
||||||
CutCopyAndPaste.setCopiedIdsFileModels(null);
|
|
||||||
CutCopyAndPaste.setOperationType(null);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
contextMenu.add(paste);
|
|
||||||
|
|
||||||
MenuItem share = new MenuItem();
|
MenuItem share = new MenuItem();
|
||||||
share.setId(WorkspaceOperation.SHARE.getId());
|
share.setId(WorkspaceOperation.SHARE.getId());
|
||||||
share.setText("Share");
|
share.setText("Share");
|
||||||
|
@ -579,6 +576,7 @@ public class ContextMenuTree {
|
||||||
contextMenu.add(remove);
|
contextMenu.add(remove);
|
||||||
|
|
||||||
contextMenu.add(new SeparatorMenuItem());
|
contextMenu.add(new SeparatorMenuItem());
|
||||||
|
|
||||||
MenuItem show = new MenuItem();
|
MenuItem show = new MenuItem();
|
||||||
show.setId(WorkspaceOperation.SHOW.getId());
|
show.setId(WorkspaceOperation.SHOW.getId());
|
||||||
show.setText(ConstantsExplorer.MESSAGE_SHOW);
|
show.setText(ConstantsExplorer.MESSAGE_SHOW);
|
||||||
|
@ -597,24 +595,24 @@ public class ContextMenuTree {
|
||||||
|
|
||||||
contextMenu.add(show);
|
contextMenu.add(show);
|
||||||
|
|
||||||
MenuItem viewWebDav = new MenuItem();
|
// MenuItem viewWebDav = new MenuItem();
|
||||||
viewWebDav.setId(WorkspaceOperation.WEBDAV_URL.getId());
|
// viewWebDav.setId(WorkspaceOperation.WEBDAV_URL.getId());
|
||||||
viewWebDav.setText(ConstantsExplorer.MESSAGE_WEBDAV_URL);
|
// viewWebDav.setText(ConstantsExplorer.MESSAGE_WEBDAV_URL);
|
||||||
viewWebDav.setIcon(Resources.getIconUrlWebDav());
|
// viewWebDav.setIcon(Resources.getIconUrlWebDav());
|
||||||
|
//
|
||||||
viewWebDav.addSelectionListener(new SelectionListener<MenuEvent>() {
|
// viewWebDav.addSelectionListener(new SelectionListener<MenuEvent>() {
|
||||||
public void componentSelected(MenuEvent ce) {
|
// public void componentSelected(MenuEvent ce) {
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// for (final FileModel sel : listSelectedItems)
|
||||||
|
// eventBus.fireEvent(new WebDavUrlEvent(sel.getIdentifier()));
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
// });
|
||||||
|
|
||||||
|
|
||||||
for (final FileModel sel : listSelectedItems)
|
//contextMenu.add(viewWebDav);
|
||||||
eventBus.fireEvent(new WebDavUrlEvent(sel.getIdentifier()));
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
contextMenu.add(viewWebDav);
|
|
||||||
|
|
||||||
MenuItem upload = new MenuItem();
|
MenuItem upload = new MenuItem();
|
||||||
upload.setId(WorkspaceOperation.UPLOAD_FILE.getId());
|
upload.setId(WorkspaceOperation.UPLOAD_FILE.getId());
|
||||||
|
@ -648,7 +646,6 @@ public class ContextMenuTree {
|
||||||
for (FileModel sel : listSelectedItems) {
|
for (FileModel sel : listSelectedItems) {
|
||||||
|
|
||||||
FileModel parent = getDirectoryOrParent(sel);
|
FileModel parent = getDirectoryOrParent(sel);
|
||||||
|
|
||||||
eventBus.fireEvent(new FileUploadEvent(parent, WS_UPLOAD_TYPE.Archive));
|
eventBus.fireEvent(new FileUploadEvent(parent, WS_UPLOAD_TYPE.Archive));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -673,7 +670,7 @@ public class ContextMenuTree {
|
||||||
});
|
});
|
||||||
|
|
||||||
contextMenu.add(downloadArchive);
|
contextMenu.add(downloadArchive);
|
||||||
contextMenu.add(new SeparatorMenuItem());
|
//contextMenu.add(new SeparatorMenuItem());
|
||||||
|
|
||||||
MenuItem changePermission = new MenuItem();
|
MenuItem changePermission = new MenuItem();
|
||||||
changePermission.setId(WorkspaceOperation.VRE_CHANGE_PERIMISSIONS.getId());
|
changePermission.setId(WorkspaceOperation.VRE_CHANGE_PERIMISSIONS.getId());
|
||||||
|
@ -693,7 +690,7 @@ public class ContextMenuTree {
|
||||||
});
|
});
|
||||||
|
|
||||||
contextMenu.add(changePermission);
|
contextMenu.add(changePermission);
|
||||||
contextMenu.add(new SeparatorMenuItem());
|
//contextMenu.add(new SeparatorMenuItem());
|
||||||
|
|
||||||
MenuItem addAdministrator = new MenuItem();
|
MenuItem addAdministrator = new MenuItem();
|
||||||
// addAdministrator.setId(WorkspaceOperation.ADD_ADMINISTRATOR.getId());
|
// addAdministrator.setId(WorkspaceOperation.ADD_ADMINISTRATOR.getId());
|
||||||
|
@ -726,7 +723,7 @@ public class ContextMenuTree {
|
||||||
});
|
});
|
||||||
|
|
||||||
contextMenu.add(refreshItem);
|
contextMenu.add(refreshItem);
|
||||||
contextMenu.add(new SeparatorMenuItem());
|
//contextMenu.add(new SeparatorMenuItem());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -748,18 +745,22 @@ public class ContextMenuTree {
|
||||||
/**
|
/**
|
||||||
* Called from context menu on grid.
|
* Called from context menu on grid.
|
||||||
*
|
*
|
||||||
* @param targetFileModel the target file model
|
* @param selectedItems the selected items
|
||||||
* @param posX the pos x
|
* @param posX the pos x
|
||||||
* @param posY the pos y
|
* @param posY the pos y
|
||||||
*/
|
*/
|
||||||
public void openContextMenuOnItem(final FileModel targetFileModel, final int posX, final int posY) {
|
public void openContextMenuOnItem(final List<FileModel> selectedItems, final int posX, final int posY) {
|
||||||
clearListSelectedItems();
|
clearListSelectedItems();
|
||||||
listSelectedItems.add(0, targetFileModel);
|
|
||||||
|
|
||||||
//printSelected();
|
if(selectedItems!=null){
|
||||||
|
|
||||||
if(targetFileModel!=null){
|
int i=0;
|
||||||
|
for (FileModel fileModel : selectedItems) {
|
||||||
|
listSelectedItems.add(i, fileModel);
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
|
||||||
|
final FileModel targetFileModel = listSelectedItems.get(0); //selecting the first item
|
||||||
if(targetFileModel.getParentFileModel()==null){
|
if(targetFileModel.getParentFileModel()==null){
|
||||||
|
|
||||||
Info.display("Wait", "loading available operations..");
|
Info.display("Wait", "loading available operations..");
|
||||||
|
@ -776,7 +777,7 @@ public class ContextMenuTree {
|
||||||
public void onSuccess(FileModel result) {
|
public void onSuccess(FileModel result) {
|
||||||
if(result!=null){
|
if(result!=null){
|
||||||
targetFileModel.setParentFileModel(result);
|
targetFileModel.setParentFileModel(result);
|
||||||
viewContextMenu(targetFileModel, posX, posY);
|
viewContextMenu(Arrays.asList(targetFileModel), posX, posY);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
Info.display("Error", "sorry an error occurrend on loading available operations");
|
Info.display("Error", "sorry an error occurrend on loading available operations");
|
||||||
|
@ -787,7 +788,7 @@ public class ContextMenuTree {
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
viewContextMenu(targetFileModel, posX, posY);
|
viewContextMenu(listSelectedItems, posX, posY);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -795,22 +796,53 @@ public class ContextMenuTree {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* View context menu.
|
* View context menu.
|
||||||
*
|
* Called by right-click
|
||||||
* @param targetFileModel the target file model
|
* @param listFileModel the list file model
|
||||||
* @param posX the pos x
|
* @param posX the pos x
|
||||||
* @param posY the pos y
|
* @param posY the pos y
|
||||||
*/
|
*/
|
||||||
private void viewContextMenu(FileModel targetFileModel, int posX, int posY){
|
protected void viewContextMenu(List<FileModel> listFileModel, int posX, int posY){
|
||||||
|
|
||||||
contextMenuSwitch(targetFileModel);
|
//SET NOT VISIBLE ALL OPERATIONS
|
||||||
contextMenu.getItemByItemId(WorkspaceOperation.INSERT_FOLDER.getId()).setVisible(false); //set invisible create folder
|
for (WorkspaceOperation value : WorkspaceOperation.values()) {
|
||||||
contextMenu.getItemByItemId(WorkspaceOperation.INSERT_SHARED_FOLDER.getId()).setVisible(false); //set invisible create shared folder
|
try{
|
||||||
contextMenu.getItemByItemId(WorkspaceOperation.WEBDAV_URL.getId()).setVisible(false); //set invisible webdav url
|
contextMenu.getItemByItemId(value.getId()).setVisible(false); //setting all to visible false
|
||||||
contextMenu.getItemByItemId(WorkspaceOperation.UPLOAD_FILE.getId()).setVisible(false); //set invisible upload file
|
}catch(Exception e){
|
||||||
contextMenu.getItemByItemId(WorkspaceOperation.UPLOAD_ARCHIVE.getId()).setVisible(false); //set invisible upload archive
|
|
||||||
//contextMenu.getItemByItemId(WorkspaceOperation.ADD_URL.getId()).setVisible(false); //set invisible add url
|
}
|
||||||
contextMenu.getItemByItemId(WorkspaceOperation.REFRESH_FOLDER.getId()).setVisible(false); //set invisible refresh
|
}
|
||||||
|
|
||||||
|
//SINGLE SELECTION
|
||||||
|
if(listFileModel.size()==1){
|
||||||
|
contextMenuSwitch(listFileModel.get(0));
|
||||||
|
|
||||||
|
//IT IS A SINGLE SELECTION TO FILE.. ACTIVATING COPY
|
||||||
|
if(!listFileModel.get(0).isDirectory())
|
||||||
|
contextMenu.getItemByItemId(WorkspaceOperation.COPY.getId()).setVisible(true);
|
||||||
|
}else{
|
||||||
|
//IT IS MULTIPLE-SELECTION
|
||||||
|
boolean foundDir = false;
|
||||||
|
for (FileModel fileModel : listFileModel) {
|
||||||
|
if(fileModel.isDirectory()){
|
||||||
|
foundDir = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//IF NO DIRECTORY FOUND AS SELECTION... ACTIVATING COPY
|
||||||
|
if(!foundDir)
|
||||||
|
contextMenu.getItemByItemId(WorkspaceOperation.COPY.getId()).setVisible(true);
|
||||||
|
|
||||||
|
contextMenu.getItemByItemId(WorkspaceOperation.MOVE.getId()).setVisible(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
//SETTINGS GET_INFO TO VISIBLE ALWAYS
|
||||||
|
contextMenu.getItemByItemId(WorkspaceOperation.GET_INFO.getId()).setVisible(true);
|
||||||
|
|
||||||
|
if(posX!=-1 && posY!=-1)
|
||||||
contextMenu.showAt(posX, posY);
|
contextMenu.showAt(posX, posY);
|
||||||
|
else
|
||||||
|
contextMenu.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -818,113 +850,63 @@ public class ContextMenuTree {
|
||||||
*
|
*
|
||||||
* @param selectedItem the selected item
|
* @param selectedItem the selected item
|
||||||
*/
|
*/
|
||||||
public void contextMenuSwitch(FileModel selectedItem) {
|
private void contextMenuSwitch(FileModel selectedItem) {
|
||||||
|
|
||||||
contextMenu.getItemByItemId(WorkspaceOperation.INSERT_FOLDER.getId()).setVisible(true); //insert folder
|
//VALID OPERATIONS FOR FILE AND FOLDER
|
||||||
contextMenu.getItemByItemId(WorkspaceOperation.INSERT_SHARED_FOLDER.getId()).setVisible(true); //insert shared folder
|
contextMenu.getItemByItemId(WorkspaceOperation.DOWNLOAD.getId()).setVisible(true);
|
||||||
contextMenu.getItemByItemId(WorkspaceOperation.UPLOAD_FILE.getId()).setVisible(true);
|
contextMenu.getItemByItemId(WorkspaceOperation.MOVE.getId()).setVisible(true);
|
||||||
contextMenu.getItemByItemId(WorkspaceOperation.UPLOAD_ARCHIVE.getId()).setVisible(true);
|
contextMenu.getItemByItemId(WorkspaceOperation.RENAME.getId()).setVisible(true);
|
||||||
contextMenu.getItemByItemId(WorkspaceOperation.ADD_URL.getId()).setVisible(true);
|
contextMenu.getItemByItemId(WorkspaceOperation.REMOVE.getId()).setVisible(true);
|
||||||
contextMenu.getItemByItemId(WorkspaceOperation.DOWNLOAD.getId()).setVisible(true); //DOWNLOAD
|
contextMenu.getItemByItemId(WorkspaceOperation.HISTORY.getId()).setVisible(true);
|
||||||
contextMenu.getItemByItemId(WorkspaceOperation.COPY.getId()).setEnabled(true);
|
|
||||||
contextMenu.getItemByItemId(WorkspaceOperation.EXECUTE_DM_TASK.getId()).setVisible(false);
|
|
||||||
|
|
||||||
contextMenu.getItemByItemId(WorkspaceOperation.PREVIEW.getId()).setVisible(false); //preview image
|
|
||||||
contextMenu.getItemByItemId(WorkspaceOperation.LINK.getId()).setVisible(false); //open link
|
|
||||||
contextMenu.getItemByItemId(WorkspaceOperation.SHOW.getId()).setVisible(false); //show
|
|
||||||
//contextMenu.getItemByItemId(WorkspaceOperation.OPEN_REPORT.getId()).setVisible(false); //open report
|
|
||||||
//contextMenu.getItemByItemId(WorkspaceOperation.OPEN_REPORT_TEMPLATE.getId()).setVisible(false); //open report template
|
|
||||||
contextMenu.getItemByItemId(WorkspaceOperation.PASTE.getId()).setEnabled(false); //paste
|
|
||||||
contextMenu.getItemByItemId(WorkspaceOperation.REFRESH_FOLDER.getId()).setVisible(false); //refresh
|
|
||||||
contextMenu.getItemByItemId(WorkspaceOperation.PUBLIC_LINK.getId()).setVisible(false); //public link
|
|
||||||
contextMenu.getItemByItemId(WorkspaceOperation.FOLDER_LINK.getId()).setVisible(false); //folder link
|
|
||||||
contextMenu.getItemByItemId(WorkspaceOperation.FOLDER_LINK_REMOVE.getId()).setVisible(false); //folder link remove
|
|
||||||
// contextMenu.getItemByItemId(WorkspaceOperation.ADD_ADMINISTRATOR.getId()).setVisible(false); //public link
|
|
||||||
contextMenu.getItemByItemId(WorkspaceOperation.EDIT_PERMISSIONS.getId()).setVisible(false);
|
|
||||||
contextMenu.getItemByItemId(WorkspaceOperation.SHARE.getId()).setVisible(false); //SHARE
|
|
||||||
contextMenu.getItemByItemId(WorkspaceOperation.UNSHARE.getId()).setVisible(false); //UNSHARE
|
|
||||||
contextMenu.getItemByItemId(WorkspaceOperation.PUBLISH_ON_DATA_CATALOGUE.getId()).setVisible(false); //publish on data catalogue
|
|
||||||
contextMenu.getItemByItemId(WorkspaceOperation.PUBLISH_ON_THREDDS.getId()).setVisible(false); //publish on thredds
|
|
||||||
|
|
||||||
contextMenu.getItemByItemId(WorkspaceOperation.SHARE_LINK.getId()).setVisible(false); //SHARE
|
//SELECTED ITEM IS A FOLDER
|
||||||
|
|
||||||
contextMenu.getItemByItemId(WorkspaceOperation.VRE_CHANGE_PERIMISSIONS.getId()).setVisible(false); //VRE CHANGE PERMISSIONS
|
|
||||||
|
|
||||||
contextMenu.getItemByItemId(WorkspaceOperation.VERSIONING.getId()).setVisible(false);
|
|
||||||
|
|
||||||
if(selectedItem.isShared()){ //SHARE LINK ON SHARED ITEM
|
|
||||||
contextMenu.getItemByItemId(WorkspaceOperation.SHARE_LINK.getId()).setVisible(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
//IS VRE FOLDER or SPECIAL FOLDER?
|
|
||||||
if(selectedItem.isVreFolder() || selectedItem.isSpecialFolder()){
|
|
||||||
|
|
||||||
contextMenu.getItemByItemId(WorkspaceOperation.SHARE.getId()).setVisible(false); //SHARE
|
|
||||||
contextMenu.getItemByItemId(WorkspaceOperation.INSERT_SHARED_FOLDER.getId()).setVisible(false); //insert shared folder
|
|
||||||
contextMenu.getItemByItemId(WorkspaceOperation.UNSHARE.getId()).setVisible(false); //UNSHARE
|
|
||||||
contextMenu.getItemByItemId(WorkspaceOperation.RENAME.getId()).setVisible(false); //RENAME
|
|
||||||
contextMenu.getItemByItemId(WorkspaceOperation.REMOVE.getId()).setVisible(false); //REMOVE
|
|
||||||
contextMenu.getItemByItemId(WorkspaceOperation.REFRESH_FOLDER.getId()).setVisible(true); //REFRESH_FOLDER
|
|
||||||
contextMenu.getItemByItemId(WorkspaceOperation.COPY.getId()).setEnabled(false);
|
|
||||||
|
|
||||||
//ADDED 14/03/2014
|
|
||||||
if(selectedItem.isVreFolder()){
|
|
||||||
contextMenu.getItemByItemId(WorkspaceOperation.VRE_CHANGE_PERIMISSIONS.getId()).setVisible(true); //REFRESH_FOLDER
|
|
||||||
|
|
||||||
if(CutCopyAndPaste.getCopiedIdsFilesModel()!=null)
|
|
||||||
contextMenu.getItemByItemId(WorkspaceOperation.PASTE.getId()).setEnabled(true); //enable paste button
|
|
||||||
}
|
|
||||||
|
|
||||||
// if(selectedItem.isVreFolder() && CutCopyAndPaste.getCopiedIdsFilesModel()!=null)
|
|
||||||
// contextMenu.getItemByItemId(WorkspaceOperation.PASTE.getId()).setEnabled(true); //enable paste button
|
|
||||||
else if(selectedItem.isSpecialFolder()){
|
|
||||||
//contextMenu.getItemByItemId(WorkspaceOperation.COPY.getId()).setEnabled(false);
|
|
||||||
contextMenu.getItemByItemId(WorkspaceOperation.PASTE.getId()).setEnabled(false);
|
|
||||||
contextMenu.getItemByItemId(WorkspaceOperation.UPLOAD_FILE.getId()).setVisible(false);
|
|
||||||
contextMenu.getItemByItemId(WorkspaceOperation.UPLOAD_ARCHIVE.getId()).setVisible(false);
|
|
||||||
contextMenu.getItemByItemId(WorkspaceOperation.ADD_URL.getId()).setVisible(false);
|
|
||||||
contextMenu.getItemByItemId(WorkspaceOperation.INSERT_FOLDER.getId()).setVisible(false); //insert folder
|
|
||||||
contextMenu.getItemByItemId(WorkspaceOperation.DOWNLOAD.getId()).setVisible(false);
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
//CASE DIRECTORY
|
|
||||||
if(selectedItem.isDirectory()){
|
if(selectedItem.isDirectory()){
|
||||||
contextMenu.getItemByItemId(WorkspaceOperation.PUBLISH_ON_DATA_CATALOGUE.getId()).setVisible(true);
|
|
||||||
contextMenu.getItemByItemId(WorkspaceOperation.PUBLISH_ON_THREDDS.getId()).setVisible(true);
|
showWriteOperations(true);
|
||||||
contextMenu.getItemByItemId(WorkspaceOperation.SHARE.getId()).setVisible(true); //SHARE
|
showExecuteOperations(true);
|
||||||
contextMenu.getItemByItemId(WorkspaceOperation.SHOW.getId()).setVisible(false); //show
|
|
||||||
contextMenu.getItemByItemId(WorkspaceOperation.REFRESH_FOLDER.getId()).setVisible(true); //refresh
|
contextMenu.getItemByItemId(WorkspaceOperation.SHARE.getId()).setVisible(true);
|
||||||
contextMenu.getItemByItemId(WorkspaceOperation.FOLDER_LINK.getId()).setVisible(true); //folder link
|
//contextMenu.getItemByItemId(WorkspaceOperation.SHOW.getId()).setVisible(false);
|
||||||
|
contextMenu.getItemByItemId(WorkspaceOperation.REFRESH_FOLDER.getId()).setVisible(true);
|
||||||
|
contextMenu.getItemByItemId(WorkspaceOperation.FOLDER_LINK.getId()).setVisible(true); //create folder link, set folder as public
|
||||||
contextMenu.getItemByItemId(WorkspaceOperation.EXECUTE_DM_TASK.getId()).setVisible(true);
|
contextMenu.getItemByItemId(WorkspaceOperation.EXECUTE_DM_TASK.getId()).setVisible(true);
|
||||||
|
|
||||||
if(selectedItem.isShared()){//IS SHARED
|
if(selectedItem.isShared()){//IS SHARED
|
||||||
//contextMenu.getItemByItemId(WorkspaceOperation.ADD_ADMINISTRATOR.getId()).setVisible(true); //add administrator
|
contextMenu.getItemByItemId(WorkspaceOperation.INSERT_SHARED_FOLDER.getId()).setVisible(false);
|
||||||
|
contextMenu.getItemByItemId(WorkspaceOperation.SHARE_LINK.getId()).setVisible(true);
|
||||||
if(selectedItem.isShareable()){ //IS SHARABLE
|
if(selectedItem.isShareable()){ //IS SHARABLE
|
||||||
contextMenu.getItemByItemId(WorkspaceOperation.INSERT_SHARED_FOLDER.getId()).setVisible(false); //insert shared folder
|
|
||||||
contextMenu.getItemByItemId(WorkspaceOperation.UNSHARE.getId()).setVisible(true);
|
contextMenu.getItemByItemId(WorkspaceOperation.UNSHARE.getId()).setVisible(true);
|
||||||
}else { //IS SUBFOLDER
|
}else { //IS SUBFOLDER
|
||||||
contextMenu.getItemByItemId(WorkspaceOperation.EDIT_PERMISSIONS.getId()).setVisible(true);
|
contextMenu.getItemByItemId(WorkspaceOperation.EDIT_PERMISSIONS.getId()).setVisible(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
}else if(selectedItem.isRoot()){ //IS ROOT
|
}
|
||||||
contextMenu.getItemByItemId(WorkspaceOperation.SHARE.getId()).setVisible(false); //SHARE
|
if(selectedItem.isRoot()){ //IS ROOT
|
||||||
contextMenu.getItemByItemId(WorkspaceOperation.INSERT_SHARED_FOLDER.getId()).setVisible(true); //insert shared folder
|
contextMenu.getItemByItemId(WorkspaceOperation.SHARE.getId()).setVisible(false);
|
||||||
contextMenu.getItemByItemId(WorkspaceOperation.UNSHARE.getId()).setVisible(false); //UNSHARE
|
contextMenu.getItemByItemId(WorkspaceOperation.INSERT_SHARED_FOLDER.getId()).setVisible(true);
|
||||||
|
contextMenu.getItemByItemId(WorkspaceOperation.UNSHARE.getId()).setVisible(false);
|
||||||
|
contextMenu.getItemByItemId(WorkspaceOperation.RENAME.getId()).setVisible(false);
|
||||||
|
contextMenu.getItemByItemId(WorkspaceOperation.REMOVE.getId()).setVisible(false);
|
||||||
|
contextMenu.getItemByItemId(WorkspaceOperation.MOVE.getId()).setVisible(false);
|
||||||
|
contextMenu.getItemByItemId(WorkspaceOperation.DOWNLOAD.getId()).setVisible(false);
|
||||||
|
contextMenu.getItemByItemId(WorkspaceOperation.FOLDER_LINK.getId()).setVisible(false);
|
||||||
|
showExecuteOperations(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(selectedItem.isPublic())
|
if(selectedItem.isPublic())
|
||||||
contextMenu.getItemByItemId(WorkspaceOperation.FOLDER_LINK_REMOVE.getId()).setVisible(true); //folder link
|
contextMenu.getItemByItemId(WorkspaceOperation.FOLDER_LINK_REMOVE.getId()).setVisible(true);
|
||||||
|
|
||||||
GWT.log("HideSharing = " + hideSharing);
|
GWT.log("HideSharing = " + hideSharing);
|
||||||
//not supported in tree Reports
|
//not supported in tree Reports
|
||||||
if (hideSharing) {
|
if (hideSharing) {
|
||||||
contextMenu.getItemByItemId(WorkspaceOperation.SHARE.getId()).setVisible(false); //SHARE
|
contextMenu.getItemByItemId(WorkspaceOperation.SHARE.getId()).setVisible(false);
|
||||||
contextMenu.getItemByItemId(WorkspaceOperation.INSERT_SHARED_FOLDER.getId()).setVisible(false); //insert shared folder
|
contextMenu.getItemByItemId(WorkspaceOperation.INSERT_SHARED_FOLDER.getId()).setVisible(false);
|
||||||
contextMenu.getItemByItemId(WorkspaceOperation.UNSHARE.getId()).setVisible(false); //UNSHARE
|
contextMenu.getItemByItemId(WorkspaceOperation.UNSHARE.getId()).setVisible(false);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else{
|
//SELECTED ITEM IS A FILE
|
||||||
|
}else{
|
||||||
contextMenu.getItemByItemId(WorkspaceOperation.SHOW.getId()).setVisible(true);
|
contextMenu.getItemByItemId(WorkspaceOperation.SHOW.getId()).setVisible(true);
|
||||||
contextMenu.getItemByItemId(WorkspaceOperation.EXECUTE_DM_TASK.getId()).setVisible(true);
|
contextMenu.getItemByItemId(WorkspaceOperation.EXECUTE_DM_TASK.getId()).setVisible(true);
|
||||||
|
|
||||||
|
@ -940,20 +922,24 @@ public class ContextMenuTree {
|
||||||
contextMenu.getItemByItemId(WorkspaceOperation.PUBLIC_LINK.getId()).setVisible(true); //public link
|
contextMenu.getItemByItemId(WorkspaceOperation.PUBLIC_LINK.getId()).setVisible(true); //public link
|
||||||
contextMenu.getItemByItemId(WorkspaceOperation.VERSIONING.getId()).setVisible(true);
|
contextMenu.getItemByItemId(WorkspaceOperation.VERSIONING.getId()).setVisible(true);
|
||||||
contextMenu.getItemByItemId(WorkspaceOperation.PUBLISH_ON_DATA_CATALOGUE.getId()).setVisible(true);
|
contextMenu.getItemByItemId(WorkspaceOperation.PUBLISH_ON_DATA_CATALOGUE.getId()).setVisible(true);
|
||||||
|
contextMenu.getItemByItemId(WorkspaceOperation.COPY.getId()).setVisible(true);
|
||||||
break;
|
break;
|
||||||
case EXTERNAL_FILE:
|
case EXTERNAL_FILE:
|
||||||
contextMenu.getItemByItemId(WorkspaceOperation.PUBLIC_LINK.getId()).setVisible(true); //public link
|
contextMenu.getItemByItemId(WorkspaceOperation.PUBLIC_LINK.getId()).setVisible(true); //public link
|
||||||
contextMenu.getItemByItemId(WorkspaceOperation.VERSIONING.getId()).setVisible(true);
|
contextMenu.getItemByItemId(WorkspaceOperation.VERSIONING.getId()).setVisible(true);
|
||||||
contextMenu.getItemByItemId(WorkspaceOperation.PUBLISH_ON_DATA_CATALOGUE.getId()).setVisible(true);
|
contextMenu.getItemByItemId(WorkspaceOperation.PUBLISH_ON_DATA_CATALOGUE.getId()).setVisible(true);
|
||||||
|
contextMenu.getItemByItemId(WorkspaceOperation.COPY.getId()).setVisible(true);
|
||||||
break;
|
break;
|
||||||
case EXTERNAL_PDF_FILE:
|
case EXTERNAL_PDF_FILE:
|
||||||
contextMenu.getItemByItemId(WorkspaceOperation.PUBLIC_LINK.getId()).setVisible(true); //public link
|
contextMenu.getItemByItemId(WorkspaceOperation.PUBLIC_LINK.getId()).setVisible(true); //public link
|
||||||
contextMenu.getItemByItemId(WorkspaceOperation.VERSIONING.getId()).setVisible(true);
|
contextMenu.getItemByItemId(WorkspaceOperation.VERSIONING.getId()).setVisible(true);
|
||||||
contextMenu.getItemByItemId(WorkspaceOperation.PUBLISH_ON_DATA_CATALOGUE.getId()).setVisible(true);
|
contextMenu.getItemByItemId(WorkspaceOperation.PUBLISH_ON_DATA_CATALOGUE.getId()).setVisible(true);
|
||||||
|
contextMenu.getItemByItemId(WorkspaceOperation.COPY.getId()).setVisible(true);
|
||||||
break;
|
break;
|
||||||
case EXTERNAL_URL:
|
case EXTERNAL_URL:
|
||||||
contextMenu.getItemByItemId(WorkspaceOperation.LINK.getId()).setVisible(true);
|
contextMenu.getItemByItemId(WorkspaceOperation.LINK.getId()).setVisible(true);
|
||||||
contextMenu.getItemByItemId(WorkspaceOperation.PUBLISH_ON_DATA_CATALOGUE.getId()).setVisible(true);
|
contextMenu.getItemByItemId(WorkspaceOperation.PUBLISH_ON_DATA_CATALOGUE.getId()).setVisible(true);
|
||||||
|
contextMenu.getItemByItemId(WorkspaceOperation.COPY.getId()).setVisible(true);
|
||||||
break;
|
break;
|
||||||
case REPORT_TEMPLATE:
|
case REPORT_TEMPLATE:
|
||||||
//contextMenu.getItemByItemId(WorkspaceOperation.OPEN_REPORT_TEMPLATE.getId()).setVisible(true);
|
//contextMenu.getItemByItemId(WorkspaceOperation.OPEN_REPORT_TEMPLATE.getId()).setVisible(true);
|
||||||
|
@ -991,12 +977,60 @@ public class ContextMenuTree {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//IS VRE FOLDER or SPECIAL FOLDER?
|
||||||
|
if(selectedItem.isVreFolder() || selectedItem.isSpecialFolder()){
|
||||||
|
|
||||||
if(CutCopyAndPaste.getCopiedIdsFilesModel()!=null)
|
contextMenu.getItemByItemId(WorkspaceOperation.SHARE.getId()).setVisible(false);
|
||||||
contextMenu.getItemByItemId(WorkspaceOperation.PASTE.getId()).setEnabled(true); //enable paste button
|
contextMenu.getItemByItemId(WorkspaceOperation.INSERT_SHARED_FOLDER.getId()).setVisible(false);
|
||||||
|
contextMenu.getItemByItemId(WorkspaceOperation.UNSHARE.getId()).setVisible(false);
|
||||||
|
contextMenu.getItemByItemId(WorkspaceOperation.RENAME.getId()).setVisible(false);
|
||||||
|
contextMenu.getItemByItemId(WorkspaceOperation.REMOVE.getId()).setVisible(false);
|
||||||
|
contextMenu.getItemByItemId(WorkspaceOperation.MOVE.getId()).setVisible(false);
|
||||||
|
contextMenu.getItemByItemId(WorkspaceOperation.FOLDER_LINK.getId()).setVisible(false);
|
||||||
|
showExecuteOperations(false);
|
||||||
|
|
||||||
|
//ADDED 14/03/2014
|
||||||
|
if(selectedItem.isVreFolder()){
|
||||||
|
contextMenu.getItemByItemId(WorkspaceOperation.VRE_CHANGE_PERIMISSIONS.getId()).setVisible(true); //VRE_CHANGE_PERIMISSIONS
|
||||||
|
}
|
||||||
|
else if(selectedItem.isSpecialFolder()){ //e.g. the root folder "VRE Folders"
|
||||||
|
showExecuteOperations(false);
|
||||||
|
showWriteOperations(false);
|
||||||
|
contextMenu.getItemByItemId(WorkspaceOperation.DOWNLOAD.getId()).setVisible(false);
|
||||||
|
contextMenu.getItemByItemId(WorkspaceOperation.FOLDER_LINK.getId()).setVisible(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show write operations.
|
||||||
|
*
|
||||||
|
* @param visible the visible
|
||||||
|
*/
|
||||||
|
private void showWriteOperations(boolean visible){
|
||||||
|
//CREATE OPERATIONS
|
||||||
|
contextMenu.getItemByItemId(WorkspaceOperation.INSERT_FOLDER.getId()).setVisible(visible);
|
||||||
|
contextMenu.getItemByItemId(WorkspaceOperation.INSERT_SHARED_FOLDER.getId()).setVisible(visible);
|
||||||
|
contextMenu.getItemByItemId(WorkspaceOperation.UPLOAD_FILE.getId()).setVisible(visible);
|
||||||
|
contextMenu.getItemByItemId(WorkspaceOperation.UPLOAD_ARCHIVE.getId()).setVisible(visible);
|
||||||
|
contextMenu.getItemByItemId(WorkspaceOperation.ADD_URL.getId()).setVisible(visible);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show execute operations.
|
||||||
|
*
|
||||||
|
* @param visible the visible
|
||||||
|
*/
|
||||||
|
private void showExecuteOperations(boolean visible){
|
||||||
|
//CREATE OPERATIONS
|
||||||
|
contextMenu.getItemByItemId(WorkspaceOperation.PUBLISH_ON_DATA_CATALOGUE.getId()).setVisible(visible);
|
||||||
|
contextMenu.getItemByItemId(WorkspaceOperation.PUBLISH_ON_THREDDS.getId()).setVisible(visible);
|
||||||
|
contextMenu.getItemByItemId(WorkspaceOperation.EXECUTE_DM_TASK.getId()).setVisible(visible);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The method return input file model if is directory otherwise parent of file model.
|
* The method return input file model if is directory otherwise parent of file model.
|
||||||
*
|
*
|
||||||
|
|
|
@ -1,35 +0,0 @@
|
||||||
package org.gcube.portlets.user.workspace.client.view.tree;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
|
|
||||||
public class CutCopyAndPaste {
|
|
||||||
|
|
||||||
private static List<String> idsFilesModel = null;
|
|
||||||
|
|
||||||
public enum OperationType {CUT, COPY};
|
|
||||||
|
|
||||||
private static OperationType operationType;
|
|
||||||
|
|
||||||
public static void copy(List<String> idsFileModel, OperationType operationType){
|
|
||||||
CutCopyAndPaste.idsFilesModel = idsFileModel;
|
|
||||||
CutCopyAndPaste.operationType = operationType;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static List<String> getCopiedIdsFilesModel() {
|
|
||||||
return idsFilesModel;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void setCopiedIdsFileModels(List<String> idsFileModel) {
|
|
||||||
CutCopyAndPaste.idsFilesModel = idsFileModel;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static OperationType getOperationType() {
|
|
||||||
return operationType;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void setOperationType(OperationType operationType) {
|
|
||||||
CutCopyAndPaste.operationType = operationType;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -101,7 +101,7 @@ public class DialogGetLink extends Dialog {
|
||||||
setIcon(Resources.getIconPublicLink());
|
setIcon(Resources.getIconPublicLink());
|
||||||
|
|
||||||
if(item.getIdentifier()!=null && !item.getIdentifier().isEmpty()){
|
if(item.getIdentifier()!=null && !item.getIdentifier().isEmpty()){
|
||||||
AppControllerExplorer.rpcWorkspaceService.getPublicLinkForFolderItemId(item.getIdentifier(), true, new AsyncCallback<PublicLink>() {
|
AppControllerExplorer.rpcWorkspaceService.getPublicLinkForFileItemId(item.getIdentifier(), true, new AsyncCallback<PublicLink>() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess(PublicLink publicLink) {
|
public void onSuccess(PublicLink publicLink) {
|
||||||
|
|
|
@ -164,7 +164,14 @@ public class ImagesPreviewController {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess(List<GWTWorkspaceItem> result) {
|
public void onSuccess(List<GWTWorkspaceItem> result) {
|
||||||
GWT.log("Preloaded: "+result +" image/s");
|
|
||||||
|
if(result==null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
GWT.log("Preloaded image/s");
|
||||||
|
for (GWTWorkspaceItem gwtWorkspaceItem : result) {
|
||||||
|
GWT.log("Preloaded: "+gwtWorkspaceItem);
|
||||||
|
}
|
||||||
parentImages = result;
|
parentImages = result;
|
||||||
if(parentImages.size()>0)
|
if(parentImages.size()>0)
|
||||||
carousel.showArrows(true);
|
carousel.showArrows(true);
|
||||||
|
|
|
@ -1,279 +0,0 @@
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
package org.gcube.portlets.user.workspace.server;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.FileInputStream;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.OutputStream;
|
|
||||||
import java.io.StringReader;
|
|
||||||
|
|
||||||
import javax.servlet.ServletException;
|
|
||||||
import javax.servlet.http.HttpServlet;
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
|
||||||
import javax.servlet.http.HttpServletResponse;
|
|
||||||
|
|
||||||
import org.apache.commons.io.IOUtils;
|
|
||||||
import org.apache.log4j.Logger;
|
|
||||||
import org.gcube.portlets.user.workspace.client.ConstantsExplorer;
|
|
||||||
import org.gcube.portlets.user.workspace.server.property.PortalUrlGroupGatewayProperty;
|
|
||||||
import org.gcube.portlets.user.workspace.shared.HandlerResultMessage;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The Class DownloadFolderServlet.
|
|
||||||
*
|
|
||||||
* @author M. Assante, CNR-ISTI
|
|
||||||
*/
|
|
||||||
@SuppressWarnings("serial")
|
|
||||||
public class DownloadFolderServlet extends HttpServlet{
|
|
||||||
|
|
||||||
|
|
||||||
protected static Logger logger = Logger.getLogger(DownloadFolderServlet.class);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void init() throws ServletException {
|
|
||||||
super.init();
|
|
||||||
logger.trace("Workspace DownloadFolderServlet ready.");
|
|
||||||
}
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see javax.servlet.http.HttpServlet#doGet(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
|
|
||||||
*/
|
|
||||||
public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException {
|
|
||||||
boolean urlRedirectOnError = req.getParameter(ConstantsExplorer.REDIRECTONERROR)==null?false:req.getParameter(ConstantsExplorer.REDIRECTONERROR).equals("true");
|
|
||||||
|
|
||||||
//REMOVED BECAUSE IT DOES NOT WORK. MUST BE CHECK USERID AND CONTEXTID
|
|
||||||
// try {
|
|
||||||
// if(WsUtil.isSessionExpired(req))
|
|
||||||
// throw new SessionExpiredException();
|
|
||||||
// } catch (Exception e) {
|
|
||||||
//
|
|
||||||
// if (e instanceof SessionExpiredException){
|
|
||||||
// sendErrorForStatus(resp, HttpServletResponse.SC_UNAUTHORIZED +": Session expired", HttpServletResponse.SC_UNAUTHORIZED);
|
|
||||||
// return;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
String fileRelativePath = req.getParameter("filepath");
|
|
||||||
String tmpDir = System.getProperty("java.io.tmpdir");
|
|
||||||
String pathToFile = tmpDir + File.separator + fileRelativePath;
|
|
||||||
try {
|
|
||||||
logger.debug("looking for File in " + pathToFile);
|
|
||||||
File tmpZip = new File(pathToFile);
|
|
||||||
logger.debug("File instanciated " + pathToFile);
|
|
||||||
|
|
||||||
resp.setHeader( "Content-Disposition", "attachment; filename=\"" + tmpZip.getName() + ".zip\"" );
|
|
||||||
resp.setContentType("application/zip");
|
|
||||||
resp = setContentLength(resp, tmpZip.length());
|
|
||||||
OutputStream out = resp.getOutputStream();
|
|
||||||
|
|
||||||
FileInputStream fileTmpZip = new FileInputStream(tmpZip);
|
|
||||||
IOUtils.copy(fileTmpZip, resp.getOutputStream());
|
|
||||||
fileTmpZip.close();
|
|
||||||
|
|
||||||
out.close();
|
|
||||||
tmpZip.deleteOnExit();
|
|
||||||
return;
|
|
||||||
|
|
||||||
} catch (Exception e) {
|
|
||||||
logger.error("Error during folder compression "+pathToFile,e);
|
|
||||||
handleError(urlRedirectOnError, req, resp, fileRelativePath, HttpServletResponse.SC_INTERNAL_SERVER_ERROR +": Error during folder compression: "+e.getMessage());
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Method to manage HttpServletResponse content length also to big data.
|
|
||||||
*
|
|
||||||
* @param resp the resp
|
|
||||||
* @param length the length
|
|
||||||
* @return the http servlet response
|
|
||||||
*/
|
|
||||||
protected HttpServletResponse setContentLength(HttpServletResponse resp, long length){
|
|
||||||
try{
|
|
||||||
if (length <= Integer.MAX_VALUE)
|
|
||||||
resp.setContentLength((int)length);
|
|
||||||
else
|
|
||||||
resp.addHeader("Content-Length", Long.toString(length));
|
|
||||||
}catch(Exception e){
|
|
||||||
//silent
|
|
||||||
}
|
|
||||||
return resp;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Handle error.
|
|
||||||
*
|
|
||||||
* @param urlRedirectOnError the url redirect on error
|
|
||||||
* @param req the req
|
|
||||||
* @param resp the resp
|
|
||||||
* @param itemId the item id
|
|
||||||
* @param message the message
|
|
||||||
* @throws IOException Signals that an I/O exception has occurred.
|
|
||||||
*/
|
|
||||||
protected void handleError(boolean urlRedirectOnError, HttpServletRequest req, HttpServletResponse resp, String itemId, String message) throws IOException{
|
|
||||||
|
|
||||||
logger.warn("Handle error occurred: "+message);
|
|
||||||
logger.trace("urlRedirectOnError is active: "+urlRedirectOnError);
|
|
||||||
if(urlRedirectOnError){
|
|
||||||
urlRedirect(req, resp, itemId);
|
|
||||||
}else
|
|
||||||
sendError(resp,message);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Send error.
|
|
||||||
*
|
|
||||||
* @param response the response
|
|
||||||
* @param message the message
|
|
||||||
* @throws IOException Signals that an I/O exception has occurred.
|
|
||||||
*/
|
|
||||||
protected void sendError(HttpServletResponse response, String message) throws IOException
|
|
||||||
{
|
|
||||||
response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
|
|
||||||
HandlerResultMessage resultMessage = HandlerResultMessage.errorResult(message);
|
|
||||||
logger.trace("error message: "+resultMessage);
|
|
||||||
logger.trace("writing response...");
|
|
||||||
StringReader sr = new StringReader(resultMessage.toString());
|
|
||||||
IOUtils.copy(sr, response.getOutputStream());
|
|
||||||
|
|
||||||
logger.trace("response writed");
|
|
||||||
response.flushBuffer();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Send error for status.
|
|
||||||
*
|
|
||||||
* @param response the response
|
|
||||||
* @param message the message
|
|
||||||
* @param status the status
|
|
||||||
* @throws IOException Signals that an I/O exception has occurred.
|
|
||||||
*/
|
|
||||||
protected void sendErrorForStatus(HttpServletResponse response, String message, int status) throws IOException
|
|
||||||
{
|
|
||||||
response.setStatus(status);
|
|
||||||
HandlerResultMessage resultMessage = HandlerResultMessage.errorResult(message);
|
|
||||||
logger.trace("error message: "+resultMessage);
|
|
||||||
logger.trace("writing response...");
|
|
||||||
StringReader sr = new StringReader(resultMessage.toString());
|
|
||||||
IOUtils.copy(sr, response.getOutputStream());
|
|
||||||
|
|
||||||
logger.trace("response written");
|
|
||||||
response.flushBuffer();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Send message.
|
|
||||||
*
|
|
||||||
* @param response the response
|
|
||||||
* @param message the message
|
|
||||||
* @throws IOException Signals that an I/O exception has occurred.
|
|
||||||
*/
|
|
||||||
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();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Send message resource available.
|
|
||||||
*
|
|
||||||
* @param response the response
|
|
||||||
* @param message the message
|
|
||||||
* @throws IOException Signals that an I/O exception has occurred.
|
|
||||||
*/
|
|
||||||
protected void sendMessageResourceAvailable(HttpServletResponse response, String message) throws IOException
|
|
||||||
{
|
|
||||||
response.setStatus(HttpServletResponse.SC_ACCEPTED);
|
|
||||||
HandlerResultMessage resultMessage = HandlerResultMessage.okResult(message);
|
|
||||||
response.getWriter().write(resultMessage.toString());
|
|
||||||
response.flushBuffer();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Send warn message.
|
|
||||||
*
|
|
||||||
* @param response the response
|
|
||||||
* @param message the message
|
|
||||||
* @throws IOException Signals that an I/O exception has occurred.
|
|
||||||
*/
|
|
||||||
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();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Url redirect.
|
|
||||||
*
|
|
||||||
* @param req the req
|
|
||||||
* @param response the response
|
|
||||||
* @param fakePath the fake path
|
|
||||||
* @throws IOException Signals that an I/O exception has occurred.
|
|
||||||
*/
|
|
||||||
protected void urlRedirect(HttpServletRequest req, HttpServletResponse response, String fakePath) throws IOException {
|
|
||||||
|
|
||||||
String requestUrl = getRequestURL(req) +fakePath;
|
|
||||||
logger.trace("Url redirect on: "+requestUrl);
|
|
||||||
// System.out.println("Url redirect on: "+requestUrl);
|
|
||||||
response.sendRedirect(response.encodeRedirectURL(requestUrl));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the request url.
|
|
||||||
*
|
|
||||||
* @param req the req
|
|
||||||
* @return the request url
|
|
||||||
*/
|
|
||||||
public static String getRequestURL(HttpServletRequest req) {
|
|
||||||
|
|
||||||
String scheme = req.getScheme(); // http
|
|
||||||
String serverName = req.getServerName(); // hostname.com
|
|
||||||
int serverPort = req.getServerPort(); // 80
|
|
||||||
String contextPath = req.getContextPath(); // /mywebapp
|
|
||||||
|
|
||||||
|
|
||||||
// Reconstruct original requesting URL
|
|
||||||
StringBuffer url = new StringBuffer();
|
|
||||||
url.append(scheme).append("://").append(serverName);
|
|
||||||
|
|
||||||
if (serverPort != 80 && serverPort != 443) {
|
|
||||||
url.append(":").append(serverPort);
|
|
||||||
}
|
|
||||||
|
|
||||||
logger.trace("server: "+url);
|
|
||||||
logger.trace("omitted contextPath: "+contextPath);
|
|
||||||
|
|
||||||
|
|
||||||
PortalUrlGroupGatewayProperty p = new PortalUrlGroupGatewayProperty();
|
|
||||||
|
|
||||||
int lenght = p.getPath().length();
|
|
||||||
|
|
||||||
String groupgatewaypath = "/";
|
|
||||||
|
|
||||||
if(lenght>1){
|
|
||||||
|
|
||||||
String lastChar = p.getPath().substring(lenght-1, lenght-1);
|
|
||||||
|
|
||||||
groupgatewaypath+= lastChar.compareTo("/")!=0?p.getPath()+"/":p.getPath();
|
|
||||||
}
|
|
||||||
|
|
||||||
url.append(groupgatewaypath);
|
|
||||||
|
|
||||||
return url.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -3,22 +3,14 @@
|
||||||
*/
|
*/
|
||||||
package org.gcube.portlets.user.workspace.server;
|
package org.gcube.portlets.user.workspace.server;
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.FileOutputStream;
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
|
||||||
|
|
||||||
import javax.servlet.ServletException;
|
import javax.servlet.ServletException;
|
||||||
import javax.servlet.http.HttpServlet;
|
import javax.servlet.http.HttpServlet;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
import org.apache.commons.io.IOUtils;
|
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
import org.gcube.common.homelibrary.home.HomeLibrary;
|
|
||||||
import org.gcube.common.homelibrary.home.workspace.Workspace;
|
|
||||||
import org.gcube.common.homelibrary.home.workspace.WorkspaceItem;
|
|
||||||
import org.gcube.common.homelibrary.home.workspace.folder.items.ExternalFile;
|
|
||||||
import org.gcube.portlets.user.workspace.server.property.PortalUrlGroupGatewayProperty;
|
import org.gcube.portlets.user.workspace.server.property.PortalUrlGroupGatewayProperty;
|
||||||
import org.gcube.portlets.user.workspace.shared.HandlerResultMessage;
|
import org.gcube.portlets.user.workspace.shared.HandlerResultMessage;
|
||||||
|
|
||||||
|
@ -118,30 +110,30 @@ public class DownloadPublicLinkServlet extends HttpServlet{
|
||||||
return url.toString();
|
return url.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
// /**
|
||||||
* The main method.
|
// * The main method.
|
||||||
*
|
// *
|
||||||
* @param args the arguments
|
// * @param args the arguments
|
||||||
*/
|
// */
|
||||||
public static void main(String[] args) {
|
// public static void main(String[] args) {
|
||||||
|
//
|
||||||
InputStream is = null;
|
// InputStream is = null;
|
||||||
logger.trace("start");
|
// logger.trace("start");
|
||||||
try{
|
// try{
|
||||||
|
//
|
||||||
Workspace ws = HomeLibrary.getHomeManagerFactory().getHomeManager().getHome("francesco.mangiacrapa").getWorkspace();
|
// Workspace ws = HomeLibrary.getHomeManagerFactory().getHomeManager().getHome("francesco.mangiacrapa").getWorkspace();
|
||||||
WorkspaceItem wsItem = ws.getItem("907ce8ef-5c0b-4601-83ac-215d1f432f6b");
|
// WorkspaceItem wsItem = ws.getItem("907ce8ef-5c0b-4601-83ac-215d1f432f6b");
|
||||||
logger.trace("metadata info recovered from HL: [ID: "+wsItem.getId() +", name: "+wsItem.getName()+"]");
|
// logger.trace("metadata info recovered from HL: [ID: "+wsItem.getId() +", name: "+wsItem.getName()+"]");
|
||||||
FileOutputStream out = new FileOutputStream(new File("/tmp/bla"));
|
// FileOutputStream out = new FileOutputStream(new File("/tmp/bla"));
|
||||||
logger.trace("cast as external file");
|
// logger.trace("cast as external file");
|
||||||
ExternalFile f = (ExternalFile) wsItem;
|
// ExternalFile f = (ExternalFile) wsItem;
|
||||||
is = f.getData();
|
// is = f.getData();
|
||||||
IOUtils.copy(is, out);
|
// IOUtils.copy(is, out);
|
||||||
is.close();
|
// is.close();
|
||||||
out.close();
|
// out.close();
|
||||||
logger.trace("end");
|
// logger.trace("end");
|
||||||
}catch (Exception e) {
|
// }catch (Exception e) {
|
||||||
e.printStackTrace();
|
// e.printStackTrace();
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,8 +3,6 @@
|
||||||
*/
|
*/
|
||||||
package org.gcube.portlets.user.workspace.server;
|
package org.gcube.portlets.user.workspace.server;
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.FileInputStream;
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
|
@ -18,24 +16,17 @@ import javax.servlet.http.HttpServletResponse;
|
||||||
import org.apache.commons.io.FilenameUtils;
|
import org.apache.commons.io.FilenameUtils;
|
||||||
import org.apache.commons.io.IOUtils;
|
import org.apache.commons.io.IOUtils;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
import org.gcube.common.homelibary.model.versioning.WorkspaceVersion;
|
|
||||||
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.exceptions.ItemNotFoundException;
|
|
||||||
import org.gcube.common.homelibrary.home.workspace.folder.FolderItem;
|
|
||||||
import org.gcube.common.homelibrary.home.workspace.folder.items.ExternalFile;
|
|
||||||
import org.gcube.common.homelibrary.home.workspace.folder.items.ExternalImage;
|
|
||||||
import org.gcube.common.homelibrary.home.workspace.folder.items.ExternalUrl;
|
|
||||||
import org.gcube.common.homelibrary.home.workspace.folder.items.GCubeItem;
|
|
||||||
import org.gcube.common.homelibrary.home.workspace.folder.items.Query;
|
|
||||||
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.home.workspace.folder.items.ts.TimeSeries;
|
|
||||||
import org.gcube.common.homelibrary.util.Extensions;
|
|
||||||
import org.gcube.common.homelibrary.util.MimeTypeUtil;
|
import org.gcube.common.homelibrary.util.MimeTypeUtil;
|
||||||
import org.gcube.common.homelibrary.util.zip.ZipUtil;
|
|
||||||
import org.gcube.common.portal.PortalContext;
|
import org.gcube.common.portal.PortalContext;
|
||||||
|
import org.gcube.common.storagehubwrapper.server.StorageHubWrapper;
|
||||||
|
import org.gcube.common.storagehubwrapper.server.tohl.Workspace;
|
||||||
|
import org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceFolder;
|
||||||
|
import org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceItem;
|
||||||
|
import org.gcube.common.storagehubwrapper.shared.tohl.items.FileItem;
|
||||||
|
import org.gcube.common.storagehubwrapper.shared.tohl.items.ImageFileItem;
|
||||||
|
import org.gcube.common.storagehubwrapper.shared.tohl.items.ItemStreamDescriptor;
|
||||||
|
import org.gcube.common.storagehubwrapper.shared.tohl.items.PDFFileItem;
|
||||||
|
import org.gcube.common.storagehubwrapper.shared.tohl.items.URLFileItem;
|
||||||
import org.gcube.portlets.user.workspace.client.ConstantsExplorer;
|
import org.gcube.portlets.user.workspace.client.ConstantsExplorer;
|
||||||
import org.gcube.portlets.user.workspace.server.property.PortalUrlGroupGatewayProperty;
|
import org.gcube.portlets.user.workspace.server.property.PortalUrlGroupGatewayProperty;
|
||||||
import org.gcube.portlets.user.workspace.server.util.WsUtil;
|
import org.gcube.portlets.user.workspace.server.util.WsUtil;
|
||||||
|
@ -44,12 +35,12 @@ import org.gcube.portlets.user.workspace.shared.SessionExpiredException;
|
||||||
import org.gcube.vomanagement.usermanagement.model.GCubeUser;
|
import org.gcube.vomanagement.usermanagement.model.GCubeUser;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Class DownloadServlet.
|
* The Class DownloadServlet.
|
||||||
*
|
*
|
||||||
* @author Federico De Faveri defaveri@isti.cnr.it
|
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
|
||||||
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
* Oct 18, 2018
|
||||||
* Dec 21, 2016
|
|
||||||
*/
|
*/
|
||||||
public class DownloadServlet extends HttpServlet{
|
public class DownloadServlet extends HttpServlet{
|
||||||
|
|
||||||
|
@ -91,20 +82,17 @@ public class DownloadServlet extends HttpServlet{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
logger.debug("DOWNLOAD REQUEST FOR ITEM ID: "+itemId);
|
logger.debug("DOWNLOAD REQUEST FOR ITEM ID: "+itemId);
|
||||||
Workspace wa = null;
|
//Workspace wa = null;
|
||||||
|
StorageHubWrapper storageHubWrapper = null;
|
||||||
try {
|
try {
|
||||||
//REMOVED BECAUSE IT DOES NOT WORK. MUST BE CHECK USERID AND CONTEXTID
|
|
||||||
// //ADDED 13-01-2014 SESSION VALIDATION
|
|
||||||
// if(WsUtil.isSessionExpired(req))
|
|
||||||
// throw new SessionExpiredException();
|
|
||||||
|
|
||||||
if(WsUtil.isSessionExpired(req))
|
if(WsUtil.isSessionExpired(req))
|
||||||
throw new SessionExpiredException();
|
throw new SessionExpiredException();
|
||||||
|
|
||||||
GCubeUser gcubeUser = PortalContext.getConfiguration().getCurrentUser(req);
|
GCubeUser gcubeUser = PortalContext.getConfiguration().getCurrentUser(req);
|
||||||
wa = WsUtil.getWorkspace(req, contextID, gcubeUser);
|
storageHubWrapper = WsUtil.getStorageHubWrapper(req, contextID,gcubeUser);
|
||||||
|
//wa = WsUtil.getWorkspace(req, contextID, gcubeUser);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
||||||
if (e instanceof SessionExpiredException){
|
if (e instanceof SessionExpiredException){
|
||||||
|
@ -116,12 +104,13 @@ public class DownloadServlet extends HttpServlet{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (wa == null) {
|
if (storageHubWrapper == null || storageHubWrapper.getWorkspace()==null) {
|
||||||
handleError(urlRedirectOnError, req, resp, itemId, HttpServletResponse.SC_INTERNAL_SERVER_ERROR +": Error, no workspace in session");
|
handleError(urlRedirectOnError, req, resp, itemId, HttpServletResponse.SC_INTERNAL_SERVER_ERROR +": Error, no workspace in session");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
WorkspaceItem item;
|
WorkspaceItem item = null;
|
||||||
|
Workspace wa = storageHubWrapper.getWorkspace();
|
||||||
try {
|
try {
|
||||||
|
|
||||||
item = wa.getItem(itemId);
|
item = wa.getItem(itemId);
|
||||||
|
@ -132,7 +121,7 @@ public class DownloadServlet extends HttpServlet{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (ItemNotFoundException e) {
|
} catch (Exception e) {
|
||||||
logger.error("Requested item "+itemId+" not found",e);
|
logger.error("Requested item "+itemId+" not found",e);
|
||||||
handleError(urlRedirectOnError, req, resp, itemId, HttpServletResponse.SC_INTERNAL_SERVER_ERROR +": The file has been deleted by another user.");
|
handleError(urlRedirectOnError, req, resp, itemId, HttpServletResponse.SC_INTERNAL_SERVER_ERROR +": The file has been deleted by another user.");
|
||||||
return;
|
return;
|
||||||
|
@ -140,134 +129,79 @@ public class DownloadServlet extends HttpServlet{
|
||||||
|
|
||||||
switch (item.getType()) {
|
switch (item.getType()) {
|
||||||
|
|
||||||
|
|
||||||
|
case FOLDER:
|
||||||
case SHARED_FOLDER:
|
case SHARED_FOLDER:
|
||||||
case FOLDER:{
|
case VRE_FOLDER:
|
||||||
|
case SMART_FOLDER:{
|
||||||
|
|
||||||
|
WorkspaceFolder workspaceFolder = (WorkspaceFolder) item;
|
||||||
|
ItemStreamDescriptor descr;
|
||||||
try {
|
try {
|
||||||
File tmpZip = ZipUtil.zipFolder((WorkspaceFolder) item);
|
descr = wa.downloadFolder(workspaceFolder.getId(), workspaceFolder.getName(), null);
|
||||||
resp.setHeader( "Content-Disposition", "attachment; filename=\"" + item.getName() + ".zip\"" );
|
}
|
||||||
resp.setContentType("application/zip");
|
catch (Exception e) {
|
||||||
resp = setContentLength(resp, tmpZip.length());
|
logger.error("Error on downloading the folder with id "+itemId, e);
|
||||||
OutputStream out = resp.getOutputStream();
|
String error = e.getMessage()!=null?e.getMessage():"The folder is not available for downloading";
|
||||||
|
handleError(urlRedirectOnError, req, resp, itemId, HttpServletResponse.SC_INTERNAL_SERVER_ERROR +": "+error);
|
||||||
FileInputStream fileTmpZip = new FileInputStream(tmpZip);
|
|
||||||
IOUtils.copy(fileTmpZip, resp.getOutputStream());
|
|
||||||
fileTmpZip.close();
|
|
||||||
|
|
||||||
out.close();
|
|
||||||
tmpZip.delete();
|
|
||||||
return;
|
|
||||||
|
|
||||||
} catch (Exception e) {
|
|
||||||
logger.error("Error during folder compression "+itemId,e);
|
|
||||||
handleError(urlRedirectOnError, req, resp, itemId, HttpServletResponse.SC_INTERNAL_SERVER_ERROR +": Error during folder compression: "+e.getMessage());
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
case FOLDER_ITEM:{
|
|
||||||
FolderItem folderItem = (FolderItem) item;
|
|
||||||
|
|
||||||
switch (folderItem.getFolderItemType()) {
|
|
||||||
|
|
||||||
case REPORT_TEMPLATE:{
|
|
||||||
try{
|
try{
|
||||||
ReportTemplate reportTemplate = (ReportTemplate)folderItem;
|
|
||||||
String extension = FilenameUtils.getExtension(item.getName());
|
|
||||||
String itemName = item.getName();
|
|
||||||
logger.trace("case REPORT_TEMPLATE extension is" +extension);
|
|
||||||
|
|
||||||
if(extension.compareToIgnoreCase(Extensions.REPORT_TEMPLATE.getName())!=0) //ADD EXTENSION?
|
logger.info("Downloading the folder: "+workspaceFolder);
|
||||||
itemName = "." + Extensions.REPORT_TEMPLATE.getName();
|
|
||||||
|
|
||||||
logger.trace("case REPORT_TEMPLATE itemName is" +extension);
|
|
||||||
String contentDisposition = viewContent?"inline":"attachment";
|
String contentDisposition = viewContent?"inline":"attachment";
|
||||||
|
String mimeType = "application/zip";
|
||||||
|
String itemName = MimeTypeUtil.getNameWithExtension(item.getName(), mimeType);
|
||||||
resp.setHeader("Content-Disposition", contentDisposition+"; filename=\"" + itemName + "\"" );
|
resp.setHeader("Content-Disposition", contentDisposition+"; filename=\"" + itemName + "\"" );
|
||||||
|
|
||||||
resp.setContentType("application/zip");
|
|
||||||
resp = setContentLength(resp, reportTemplate.getLength());
|
|
||||||
OutputStream out = resp.getOutputStream();
|
|
||||||
|
|
||||||
//MODIFIED 22-05-2013 CLOSE STREAM
|
|
||||||
InputStream is = reportTemplate.getData();
|
|
||||||
IOUtils.copy(is, resp.getOutputStream());
|
|
||||||
is.close();
|
|
||||||
|
|
||||||
out.close();
|
|
||||||
} catch (Exception e) {
|
|
||||||
logger.error("Error during external item sending "+itemId,e);
|
|
||||||
handleError(urlRedirectOnError, req, resp, itemId, HttpServletResponse.SC_INTERNAL_SERVER_ERROR +": Error during data retrieving: "+e.getMessage());
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
|
|
||||||
}
|
|
||||||
case REPORT:{
|
|
||||||
try{
|
|
||||||
Report report = (Report)folderItem;
|
|
||||||
String extension = FilenameUtils.getExtension(item.getName());
|
|
||||||
String itemName = item.getName();
|
|
||||||
logger.trace("case REPORT extension is" +extension);
|
|
||||||
|
|
||||||
if(extension.compareToIgnoreCase(Extensions.REPORT.getName())!=0) //ADD EXTENSION?
|
|
||||||
itemName = "." + Extensions.REPORT.getName();
|
|
||||||
|
|
||||||
logger.trace("case REPORT itemName is" +extension);
|
|
||||||
String contentDisposition = viewContent?"inline":"attachment";
|
|
||||||
resp.setHeader( "Content-Disposition", contentDisposition+"; filename=\"" + itemName + "\"" );
|
|
||||||
|
|
||||||
resp.setContentType("application/zip");
|
|
||||||
resp = setContentLength(resp, report.getLength());
|
|
||||||
OutputStream out = resp.getOutputStream();
|
|
||||||
|
|
||||||
//MODIFIED 22-05-2013 CLOSE STREAM
|
|
||||||
InputStream is = report.getData();
|
|
||||||
IOUtils.copy(is, resp.getOutputStream());
|
|
||||||
is.close();
|
|
||||||
|
|
||||||
out.close();
|
|
||||||
} catch (Exception e) {
|
|
||||||
logger.error("Error during external item sending "+itemId,e);
|
|
||||||
handleError(urlRedirectOnError, req, resp, itemId, HttpServletResponse.SC_INTERNAL_SERVER_ERROR +": Error during data retrieving: "+e.getMessage());
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
|
|
||||||
}
|
|
||||||
case EXTERNAL_PDF_FILE:
|
|
||||||
case EXTERNAL_FILE:{
|
|
||||||
|
|
||||||
InputStream is = null;
|
|
||||||
OutputStream out = null;
|
|
||||||
try{
|
|
||||||
ExternalFile externalFile = (ExternalFile) folderItem;
|
|
||||||
String mimeType = externalFile.getMimeType();
|
|
||||||
logger.trace("EXTERNAL_FILE DOWNLOAD FOR "+externalFile.getId());
|
|
||||||
String contentDisposition = viewContent?"inline":"attachment";
|
|
||||||
resp.setHeader("Content-Disposition", contentDisposition+"; filename=\"" + item.getName() + "\"" );
|
|
||||||
resp.setContentType(mimeType);
|
resp.setContentType(mimeType);
|
||||||
|
|
||||||
if(versionID!=null){
|
OutputStream out = resp.getOutputStream();
|
||||||
logger.info("Downloading version id: "+versionID);
|
InputStream is = descr.getStream();
|
||||||
//TODO MUST BE ADDED SIZE FOR VERSIONED FILE
|
IOUtils.copy(descr.getStream(), out);
|
||||||
WorkspaceVersion vers = externalFile.getVersion(versionID);
|
|
||||||
if(vers!=null){
|
|
||||||
long versionSize = vers.getSize(); //just one read
|
|
||||||
versionSize = versionSize>0?versionSize:-1;
|
|
||||||
if(versionSize>0)
|
|
||||||
resp = setContentLength(resp, versionSize);
|
|
||||||
|
|
||||||
is = externalFile.downloadVersion(versionID);
|
is.close();
|
||||||
}else{
|
out.close();
|
||||||
logger.error("Error file version "+versionID+" not found in the server-side. Refresh and try again.");
|
return;
|
||||||
handleError(urlRedirectOnError, req, resp, itemId, HttpServletResponse.SC_INTERNAL_SERVER_ERROR +": Error file version "+versionID+" not found in the server-side. Refresh and try again.");
|
} catch (Exception e) {
|
||||||
|
logger.error("Error during item downloading "+itemId,e);
|
||||||
|
handleError(urlRedirectOnError, req, resp, itemId, HttpServletResponse.SC_INTERNAL_SERVER_ERROR +": Error during folder data retrieving: "+e.getMessage());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
}else{
|
}
|
||||||
resp = setContentLength(resp, externalFile.getLength());
|
case FILE_ITEM:{
|
||||||
is = externalFile.getData();
|
|
||||||
|
FileItem workspaceFileItem = (FileItem) item;
|
||||||
|
ItemStreamDescriptor descr;
|
||||||
|
try {
|
||||||
|
logger.info("Downloading the file id: "+workspaceFileItem.getId()+" with name: "+workspaceFileItem.getName()+" and versionID: "+versionID);
|
||||||
|
descr = wa.downloadFile(workspaceFileItem.getId(), workspaceFileItem.getName(), versionID, null);
|
||||||
|
}
|
||||||
|
catch (Exception e1) {
|
||||||
|
logger.error("Error on downloading the file with id "+itemId, e1);
|
||||||
|
String error = e1.getMessage()!=null?e1.getMessage():"The file is not available for downloading";
|
||||||
|
handleError(urlRedirectOnError, req, resp, itemId, HttpServletResponse.SC_INTERNAL_SERVER_ERROR +": "+error);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
out = resp.getOutputStream();
|
switch (workspaceFileItem.getFileItemType()) {
|
||||||
|
|
||||||
|
case PDF_DOCUMENT:{
|
||||||
|
|
||||||
|
try{
|
||||||
|
PDFFileItem pdfFile = (PDFFileItem) workspaceFileItem;
|
||||||
|
logger.info("Downloading: "+pdfFile);
|
||||||
|
String mimeType = pdfFile.getMimeType();
|
||||||
|
logger.trace("EXTERNAL_FILE DOWNLOAD FOR "+pdfFile.getId());
|
||||||
|
String contentDisposition = viewContent?"inline":"attachment";
|
||||||
|
String itemName = MimeTypeUtil.getNameWithExtension(descr.getItemName(), mimeType);
|
||||||
|
|
||||||
|
resp.setHeader("Content-Disposition", contentDisposition+"; filename=\"" + itemName + "\"" );
|
||||||
|
resp.setContentType(mimeType);
|
||||||
|
resp = setContentLength(resp, pdfFile.getSize());
|
||||||
|
InputStream is = descr.getStream();
|
||||||
|
OutputStream out = resp.getOutputStream();
|
||||||
IOUtils.copy(is, out);
|
IOUtils.copy(is, out);
|
||||||
|
|
||||||
is.close();
|
is.close();
|
||||||
|
@ -281,44 +215,23 @@ public class DownloadServlet extends HttpServlet{
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
case EXTERNAL_IMAGE:{
|
case IMAGE_DOCUMENT:{
|
||||||
|
|
||||||
try{
|
try{
|
||||||
ExternalImage externalImage = (ExternalImage)folderItem;
|
ImageFileItem imageFile = (ImageFileItem) workspaceFileItem;
|
||||||
|
logger.info("Downloading: "+imageFile);
|
||||||
String mimeType = externalImage.getMimeType();
|
String mimeType = imageFile.getMimeType();
|
||||||
String itemName = MimeTypeUtil.getNameWithExtension(item.getName(), mimeType);
|
String itemName = MimeTypeUtil.getNameWithExtension(descr.getItemName(), mimeType);
|
||||||
|
|
||||||
String contentDisposition = viewContent?"inline":"attachment";
|
String contentDisposition = viewContent?"inline":"attachment";
|
||||||
resp.setHeader("Content-Disposition", contentDisposition+"; filename=\"" + itemName + "\"" );
|
resp.setHeader("Content-Disposition", contentDisposition+"; filename=\"" + itemName + "\"" );
|
||||||
resp.setContentType(externalImage.getMimeType());
|
resp.setContentType(mimeType);
|
||||||
InputStream is;
|
resp = setContentLength(resp, imageFile.getSize());
|
||||||
if(versionID!=null){
|
|
||||||
logger.info("Downloading version id: "+versionID);
|
|
||||||
//TODO MUST BE ADDED SIZE FOR VERSIONED FILE
|
|
||||||
WorkspaceVersion vers = externalImage.getVersion(versionID);
|
|
||||||
if(vers!=null){
|
|
||||||
long versionSize = vers.getSize(); //just one read
|
|
||||||
versionSize = versionSize>0?versionSize:-1;
|
|
||||||
if(versionSize>0)
|
|
||||||
resp = setContentLength(resp, versionSize);
|
|
||||||
|
|
||||||
is = externalImage.downloadVersion(versionID);
|
|
||||||
}else{
|
|
||||||
logger.error("Error file version "+versionID+" not found in the server-side. Refresh and try again.");
|
|
||||||
handleError(urlRedirectOnError, req, resp, itemId, HttpServletResponse.SC_INTERNAL_SERVER_ERROR +": Error file version "+versionID+" not found in the server-side. Refresh and try again.");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
}else{
|
|
||||||
resp = setContentLength(resp, externalImage.getLength());
|
|
||||||
is = externalImage.getData();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
InputStream is = descr.getStream();
|
||||||
OutputStream out = resp.getOutputStream();
|
OutputStream out = resp.getOutputStream();
|
||||||
IOUtils.copy(is, out);
|
IOUtils.copy(is, out);
|
||||||
is.close();
|
|
||||||
|
|
||||||
|
is.close();
|
||||||
out.close();
|
out.close();
|
||||||
return;
|
return;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
@ -327,22 +240,23 @@ public class DownloadServlet extends HttpServlet{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
case EXTERNAL_URL:{
|
case URL_DOCUMENT:{
|
||||||
try{
|
try{
|
||||||
ExternalUrl externalUrl = (ExternalUrl)folderItem;
|
URLFileItem externalUrl = (URLFileItem) workspaceFileItem;
|
||||||
|
logger.info("Downloading: "+externalUrl);
|
||||||
String itemName = MimeTypeUtil.getNameWithExtension(externalUrl.getName(), "text/uri-list");
|
String urlMimeType = "text/uri-list";
|
||||||
|
String itemName = MimeTypeUtil.getNameWithExtension(descr.getItemName(), urlMimeType);
|
||||||
String contentDisposition = viewContent?"inline":"attachment";
|
String contentDisposition = viewContent?"inline":"attachment";
|
||||||
resp.setHeader("Content-Disposition", contentDisposition+"; filename=\"" + itemName + "\"" );
|
resp.setHeader("Content-Disposition", contentDisposition+"; filename=\"" + itemName + "\"" );
|
||||||
resp.setContentType("text/uri-list");
|
resp.setContentType(urlMimeType);
|
||||||
resp = setContentLength(resp, externalUrl.getLength());
|
resp = setContentLength(resp, externalUrl.getSize());
|
||||||
|
|
||||||
//MODIFIED 22-05-2013 CLOSE STREAM
|
//MODIFIED 22-05-2013 CLOSE STREAM
|
||||||
StringReader sr = new StringReader(externalUrl.getUrl());
|
|
||||||
OutputStream out = resp.getOutputStream();
|
OutputStream out = resp.getOutputStream();
|
||||||
IOUtils.copy(sr, out);
|
InputStream is = descr.getStream();
|
||||||
|
IOUtils.copy(descr.getStream(), out);
|
||||||
|
|
||||||
sr.close();
|
is.close();
|
||||||
out.close();
|
out.close();
|
||||||
return;
|
return;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
@ -351,91 +265,24 @@ public class DownloadServlet extends HttpServlet{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
case QUERY:{
|
|
||||||
|
|
||||||
Query query = (Query)folderItem;
|
case GCUBE_ITEM:{
|
||||||
resp.setContentType("text/plain");
|
|
||||||
try {
|
|
||||||
resp = setContentLength(resp, query.getLength());
|
|
||||||
} catch (Exception e) {
|
|
||||||
logger.error("Error getting item lenght "+query,e);
|
|
||||||
handleError(urlRedirectOnError, req, resp, itemId, HttpServletResponse.SC_INTERNAL_SERVER_ERROR +": Error during data retrieving: "+e.getMessage());
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
//MODIFIED 22-05-2013 CLOSE STREAM
|
|
||||||
OutputStream out = resp.getOutputStream();
|
|
||||||
StringReader sr = new StringReader(query.getQuery());
|
|
||||||
IOUtils.copy(sr, out);
|
|
||||||
sr.close();
|
|
||||||
|
|
||||||
out.close();
|
|
||||||
return;
|
|
||||||
|
|
||||||
}
|
|
||||||
case TIME_SERIES:{
|
|
||||||
try{
|
|
||||||
TimeSeries ts = (TimeSeries)folderItem;
|
|
||||||
File tmpZip = ZipUtil.zipTimeSeries(ts);
|
|
||||||
|
|
||||||
String contentDisposition = viewContent?"inline":"attachment";
|
|
||||||
resp.setHeader( "Content-Disposition", contentDisposition+"; filename=\"" + item.getName() + ".zip\"" );
|
|
||||||
resp.setContentType("application/zip");
|
|
||||||
resp = setContentLength(resp, tmpZip.length());
|
|
||||||
|
|
||||||
//MODIFIED 22-05-2013 CLOSE STREAM
|
|
||||||
OutputStream out = resp.getOutputStream();
|
|
||||||
FileInputStream fileTmpZip = new FileInputStream(tmpZip);
|
|
||||||
IOUtils.copy(fileTmpZip, out);
|
|
||||||
fileTmpZip.close();
|
|
||||||
|
|
||||||
out.close();
|
|
||||||
tmpZip.delete();
|
|
||||||
return;
|
|
||||||
} catch (Exception e) {
|
|
||||||
logger.error("Error during item retrieving "+itemId,e);
|
|
||||||
handleError(urlRedirectOnError, req, resp, itemId, HttpServletResponse.SC_INTERNAL_SERVER_ERROR +": Error during data retrieving: "+e.getMessage());
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
case IMAGE_DOCUMENT:
|
|
||||||
case PDF_DOCUMENT:
|
|
||||||
case URL_DOCUMENT:
|
|
||||||
case DOCUMENT:{
|
|
||||||
try{
|
try{
|
||||||
// Document document = (Document)item;
|
// Document document = (Document)item;
|
||||||
GCubeItem document = (GCubeItem) item; //Cast GCubeItem
|
org.gcube.common.storagehubwrapper.shared.tohl.items.GCubeItem gcubeItem = (org.gcube.common.storagehubwrapper.shared.tohl.items.GCubeItem) item; //Cast GCubeItem
|
||||||
|
logger.info("Downloading: "+gcubeItem);
|
||||||
if (!viewContent){
|
String mimeType = "text/plain";
|
||||||
File tmpZip = ZipUtil.zipDocument(document);
|
String contentDisposition = viewContent?"inline":"attachment";
|
||||||
|
resp.setHeader("Content-Disposition", contentDisposition+"; filename=\"" + gcubeItem.getName() + ".txt\"" );
|
||||||
resp.setHeader( "Content-Disposition", "attachment; filename=\"" + item.getName() + ".zip\"" );
|
resp.setContentType(mimeType);
|
||||||
resp.setContentType("application/zip");
|
|
||||||
resp = setContentLength(resp, tmpZip.length());
|
|
||||||
|
|
||||||
//MODIFIED 22-05-2013 CLOSE STREAM
|
//MODIFIED 22-05-2013 CLOSE STREAM
|
||||||
OutputStream out = resp.getOutputStream();
|
OutputStream out = resp.getOutputStream();
|
||||||
FileInputStream fileTmpZip = new FileInputStream(tmpZip);
|
InputStream is = descr.getStream();
|
||||||
IOUtils.copy(fileTmpZip, out);
|
|
||||||
fileTmpZip.close();
|
|
||||||
|
|
||||||
out.close();
|
|
||||||
tmpZip.delete();
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
String mimeType = document.getMimeType();
|
|
||||||
String itemName = MimeTypeUtil.getNameWithExtension(item.getName(), mimeType);
|
|
||||||
resp.setHeader( "Content-Disposition", "inline; filename=\"" + itemName + "\"" );
|
|
||||||
resp.setContentType(document.getMimeType());
|
|
||||||
resp = setContentLength(resp, document.getLength());
|
|
||||||
//MODIFIED 22-05-2013 CLOSE STREAM
|
|
||||||
OutputStream out = resp.getOutputStream();
|
|
||||||
InputStream is = document.getData();
|
|
||||||
IOUtils.copy(is, out);
|
IOUtils.copy(is, out);
|
||||||
is.close();
|
is.close();
|
||||||
|
|
||||||
out.close();
|
out.close();
|
||||||
}
|
|
||||||
return;
|
return;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.error("Error during item retrieving "+itemId,e);
|
logger.error("Error during item retrieving "+itemId,e);
|
||||||
|
@ -443,22 +290,24 @@ public class DownloadServlet extends HttpServlet{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
default:{
|
||||||
|
|
||||||
case METADATA:{
|
|
||||||
try{
|
try{
|
||||||
// Metadata document = (Metadata)item;
|
|
||||||
GCubeItem metadata = (GCubeItem) item; //Cast GCubeItem
|
|
||||||
|
|
||||||
resp.setContentType("text/html");
|
String itemName = MimeTypeUtil.getNameWithExtension(descr.getItemName(), workspaceFileItem.getMimeType());
|
||||||
resp = setContentLength(resp, metadata.getLength());
|
logger.info("Downloading default item: "+workspaceFileItem);
|
||||||
|
String contentDisposition = viewContent?"inline":"attachment";
|
||||||
|
resp.setHeader("Content-Disposition", contentDisposition+"; filename=\"" + itemName + "\"" );
|
||||||
|
if(workspaceFileItem.getSize()!=null && workspaceFileItem.getSize()>0)
|
||||||
|
resp = setContentLength(resp, workspaceFileItem.getSize());
|
||||||
|
|
||||||
//MODIFIED 22-05-2013 CLOSE STREAM
|
//MODIFIED 22-05-2013 CLOSE STREAM
|
||||||
OutputStream out = resp.getOutputStream();
|
OutputStream out = resp.getOutputStream();
|
||||||
InputStream is = metadata.getData();
|
InputStream is = descr.getStream();
|
||||||
IOUtils.copy(is, out);
|
IOUtils.copy(descr.getStream(), out);
|
||||||
|
|
||||||
is.close();
|
is.close();
|
||||||
out.close();
|
out.close();
|
||||||
|
|
||||||
return;
|
return;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.error("Error during item retrieving "+itemId,e);
|
logger.error("Error during item retrieving "+itemId,e);
|
||||||
|
@ -466,15 +315,39 @@ public class DownloadServlet extends HttpServlet{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
handleError(urlRedirectOnError, req, resp, itemId,HttpServletResponse.SC_INTERNAL_SERVER_ERROR +": Error during data retrieving");
|
handleError(urlRedirectOnError, req, resp, itemId,HttpServletResponse.SC_INTERNAL_SERVER_ERROR +": Error during data retrieving");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the file name with version.
|
||||||
|
* IF DONWLOADING A VERSIONED FILE ADDS THE VERSION NAME AS SUFFIX
|
||||||
|
* DONE by StorageHub
|
||||||
|
* @param fileName the file name
|
||||||
|
* @param versionName the version name
|
||||||
|
* @return the file name with version
|
||||||
|
*/
|
||||||
|
protected String getFileNameWithVersion(String fileName, String versionName){
|
||||||
|
|
||||||
|
String fileNameToDwnld = fileName;
|
||||||
|
|
||||||
|
|
||||||
|
if(versionName!=null && !versionName.isEmpty())
|
||||||
|
fileNameToDwnld = FilenameUtils.getBaseName(fileName)+"v"+versionName+FilenameUtils.getExtension(fileName);
|
||||||
|
|
||||||
|
return fileNameToDwnld;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method to manage HttpServletResponse content length also to big data.
|
* Method to manage HttpServletResponse content length also to big data.
|
||||||
*
|
*
|
||||||
|
@ -509,7 +382,7 @@ public class DownloadServlet extends HttpServlet{
|
||||||
logger.warn("Handle error occurred: "+message);
|
logger.warn("Handle error occurred: "+message);
|
||||||
logger.trace("urlRedirectOnError is active: "+urlRedirectOnError);
|
logger.trace("urlRedirectOnError is active: "+urlRedirectOnError);
|
||||||
if(urlRedirectOnError){
|
if(urlRedirectOnError){
|
||||||
urlRedirect(req, resp, itemId);
|
urlRedirect(req, resp, itemId, message);
|
||||||
}else
|
}else
|
||||||
sendError(resp,message);
|
sendError(resp,message);
|
||||||
|
|
||||||
|
@ -608,13 +481,13 @@ public class DownloadServlet extends HttpServlet{
|
||||||
* @param req the req
|
* @param req the req
|
||||||
* @param response the response
|
* @param response the response
|
||||||
* @param fakePath the fake path
|
* @param fakePath the fake path
|
||||||
|
* @param errorMessage the error message
|
||||||
* @throws IOException Signals that an I/O exception has occurred.
|
* @throws IOException Signals that an I/O exception has occurred.
|
||||||
*/
|
*/
|
||||||
protected void urlRedirect(HttpServletRequest req, HttpServletResponse response, String fakePath) throws IOException {
|
protected void urlRedirect(HttpServletRequest req, HttpServletResponse response, String fakePath, String errorMessage) throws IOException {
|
||||||
|
|
||||||
String requestUrl = getRequestURL(req) +fakePath;
|
String requestUrl = getRequestURL(req) +fakePath;
|
||||||
logger.trace("Url redirect on: "+requestUrl);
|
logger.trace("Url redirect on: "+requestUrl);
|
||||||
// System.out.println("Url redirect on: "+requestUrl);
|
|
||||||
response.sendRedirect(response.encodeRedirectURL(requestUrl));
|
response.sendRedirect(response.encodeRedirectURL(requestUrl));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,7 +20,6 @@ import org.gcube.common.homelibary.model.items.gcube.DocumentMetadata;
|
||||||
import org.gcube.common.homelibary.model.items.gcube.DocumentPartLink;
|
import org.gcube.common.homelibary.model.items.gcube.DocumentPartLink;
|
||||||
import org.gcube.common.homelibary.model.items.type.NodeProperty;
|
import org.gcube.common.homelibary.model.items.type.NodeProperty;
|
||||||
import org.gcube.common.homelibary.model.items.type.WorkspaceItemType;
|
import org.gcube.common.homelibary.model.items.type.WorkspaceItemType;
|
||||||
import org.gcube.common.homelibary.model.versioning.WorkspaceVersion;
|
|
||||||
import org.gcube.common.homelibrary.home.User;
|
import org.gcube.common.homelibrary.home.User;
|
||||||
import org.gcube.common.homelibrary.home.exceptions.InternalErrorException;
|
import org.gcube.common.homelibrary.home.exceptions.InternalErrorException;
|
||||||
import org.gcube.common.homelibrary.home.workspace.Properties;
|
import org.gcube.common.homelibrary.home.workspace.Properties;
|
||||||
|
@ -66,7 +65,6 @@ import org.gcube.portlets.user.workspace.client.model.FileDetailsModel;
|
||||||
import org.gcube.portlets.user.workspace.client.model.FileGridModel;
|
import org.gcube.portlets.user.workspace.client.model.FileGridModel;
|
||||||
import org.gcube.portlets.user.workspace.client.model.FileModel;
|
import org.gcube.portlets.user.workspace.client.model.FileModel;
|
||||||
import org.gcube.portlets.user.workspace.client.model.FileTrashedModel;
|
import org.gcube.portlets.user.workspace.client.model.FileTrashedModel;
|
||||||
import org.gcube.portlets.user.workspace.client.model.FileVersionModel;
|
|
||||||
import org.gcube.portlets.user.workspace.client.model.FolderGridModel;
|
import org.gcube.portlets.user.workspace.client.model.FolderGridModel;
|
||||||
import org.gcube.portlets.user.workspace.client.model.FolderModel;
|
import org.gcube.portlets.user.workspace.client.model.FolderModel;
|
||||||
import org.gcube.portlets.user.workspace.client.model.InfoContactModel;
|
import org.gcube.portlets.user.workspace.client.model.InfoContactModel;
|
||||||
|
@ -624,13 +622,14 @@ public class GWTWorkspaceBuilder {
|
||||||
return listFileModel;
|
return listFileModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Builds the gxt info contacts from portal logins.
|
* Builds the gxt info contacts from portal logins.
|
||||||
*
|
*
|
||||||
* @param listPortalLogin the list portal login
|
* @param listPortalLogin the list portal login
|
||||||
* @return the list
|
* @return the list
|
||||||
*/
|
*/
|
||||||
public List<InfoContactModel> buildGxtInfoContactsFromPortalLogins(List<String> listPortalLogin){
|
public static List<InfoContactModel> buildGxtInfoContactsFromPortalLogins(List<String> listPortalLogin){
|
||||||
|
|
||||||
List<InfoContactModel> listContact = new ArrayList<InfoContactModel>();
|
List<InfoContactModel> listContact = new ArrayList<InfoContactModel>();
|
||||||
|
|
||||||
|
@ -643,13 +642,14 @@ public class GWTWorkspaceBuilder {
|
||||||
return listContact;
|
return listContact;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Builds the gxt info contact from portal login.
|
* Builds the gxt info contact from portal login.
|
||||||
*
|
*
|
||||||
* @param portalLogin the portal login
|
* @param portalLogin the portal login
|
||||||
* @return the info contact model
|
* @return the info contact model
|
||||||
*/
|
*/
|
||||||
protected InfoContactModel buildGxtInfoContactFromPortalLogin(String portalLogin){
|
public static InfoContactModel buildGxtInfoContactFromPortalLogin(String portalLogin){
|
||||||
|
|
||||||
if(portalLogin==null){
|
if(portalLogin==null){
|
||||||
logger.warn("portal login is null, return empty");
|
logger.warn("portal login is null, return empty");
|
||||||
|
@ -660,13 +660,14 @@ public class GWTWorkspaceBuilder {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Used in test mode.
|
* Builds the gxt info contact from portal login test mode.
|
||||||
*
|
*
|
||||||
* @param listPortalLogin the list portal login
|
* @param listPortalLogin the list portal login
|
||||||
* @return the list
|
* @return the list
|
||||||
*/
|
*/
|
||||||
protected List<InfoContactModel> buildGxtInfoContactFromPortalLoginTestMode(List<String> listPortalLogin){
|
public static List<InfoContactModel> buildGxtInfoContactFromPortalLoginTestMode(List<String> listPortalLogin){
|
||||||
|
|
||||||
List<InfoContactModel> listContact = new ArrayList<InfoContactModel>();
|
List<InfoContactModel> listContact = new ArrayList<InfoContactModel>();
|
||||||
|
|
||||||
|
@ -2291,29 +2292,6 @@ public class GWTWorkspaceBuilder {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* To version history.
|
|
||||||
*
|
|
||||||
* @param versions the versions
|
|
||||||
* @return the list
|
|
||||||
*/
|
|
||||||
public List<FileVersionModel> toVersionHistory(List<WorkspaceVersion> versions){
|
|
||||||
|
|
||||||
if(versions==null){
|
|
||||||
logger.warn("Version history is null!!!");
|
|
||||||
return new ArrayList<FileVersionModel>();
|
|
||||||
}
|
|
||||||
|
|
||||||
List<FileVersionModel> listVersions = new ArrayList<FileVersionModel>(versions.size());
|
|
||||||
for (WorkspaceVersion wsVersion : versions) {
|
|
||||||
String user = UserUtil.getUserFullName(wsVersion.getUser());
|
|
||||||
FileVersionModel file = new FileVersionModel(wsVersion.getName(), wsVersion.getName(), wsVersion.getRemotePath(), user, toDate(wsVersion.getCreated()), wsVersion.isCurrentVersion());
|
|
||||||
listVersions.add(file);
|
|
||||||
}
|
|
||||||
return listVersions;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the synched thredds state for.
|
* Sets the synched thredds state for.
|
||||||
*
|
*
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -14,31 +14,37 @@ import javax.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
import org.apache.commons.io.IOUtils;
|
import org.apache.commons.io.IOUtils;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
import org.gcube.common.homelibary.model.items.type.FolderItemType;
|
|
||||||
import org.gcube.common.homelibary.model.items.type.WorkspaceItemType;
|
|
||||||
import org.gcube.common.homelibrary.home.exceptions.InternalErrorException;
|
|
||||||
import org.gcube.common.homelibrary.home.workspace.Workspace;
|
|
||||||
import org.gcube.common.homelibrary.home.workspace.WorkspaceItem;
|
|
||||||
import org.gcube.common.homelibrary.home.workspace.exceptions.ItemNotFoundException;
|
|
||||||
import org.gcube.common.homelibrary.home.workspace.folder.FolderItem;
|
|
||||||
import org.gcube.common.homelibrary.home.workspace.folder.items.Image;
|
|
||||||
import org.gcube.common.portal.PortalContext;
|
import org.gcube.common.portal.PortalContext;
|
||||||
|
import org.gcube.common.storagehubwrapper.server.StorageHubWrapper;
|
||||||
|
import org.gcube.common.storagehubwrapper.server.tohl.Workspace;
|
||||||
|
import org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceItem;
|
||||||
|
import org.gcube.common.storagehubwrapper.shared.tohl.exceptions.InternalErrorException;
|
||||||
|
import org.gcube.common.storagehubwrapper.shared.tohl.exceptions.ItemNotFoundException;
|
||||||
|
import org.gcube.common.storagehubwrapper.shared.tohl.items.FileItem;
|
||||||
|
import org.gcube.common.storagehubwrapper.shared.tohl.items.FileItemType;
|
||||||
|
import org.gcube.common.storagehubwrapper.shared.tohl.items.ImageFileItem;
|
||||||
|
import org.gcube.common.storagehubwrapper.shared.tohl.items.ItemStreamDescriptor;
|
||||||
import org.gcube.portlets.user.workspace.client.ConstantsExplorer;
|
import org.gcube.portlets.user.workspace.client.ConstantsExplorer;
|
||||||
import org.gcube.portlets.user.workspace.client.util.ImageRequestType;
|
import org.gcube.portlets.user.workspace.client.util.ImageRequestType;
|
||||||
|
import org.gcube.portlets.user.workspace.server.util.ThumbnailGenerator;
|
||||||
import org.gcube.portlets.user.workspace.server.util.WsUtil;
|
import org.gcube.portlets.user.workspace.server.util.WsUtil;
|
||||||
import org.gcube.portlets.user.workspace.shared.SessionExpiredException;
|
import org.gcube.portlets.user.workspace.shared.SessionExpiredException;
|
||||||
import org.gcube.vomanagement.usermanagement.model.GCubeUser;
|
import org.gcube.vomanagement.usermanagement.model.GCubeUser;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Class ImageServlet.
|
* The Class ImageServlet.
|
||||||
*
|
*
|
||||||
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
|
||||||
* Jun 6, 2017
|
* Oct 18, 2018
|
||||||
*/
|
*/
|
||||||
public class ImageServlet extends HttpServlet{
|
public class ImageServlet extends HttpServlet{
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private static final int THUMB_MAX_SIZE = 300;
|
||||||
|
|
||||||
private static final long serialVersionUID = -8423345575690165644L;
|
private static final long serialVersionUID = -8423345575690165644L;
|
||||||
|
|
||||||
protected static Logger logger = Logger.getLogger(ImageServlet.class);
|
protected static Logger logger = Logger.getLogger(ImageServlet.class);
|
||||||
|
@ -66,10 +72,8 @@ public class ImageServlet extends HttpServlet{
|
||||||
boolean viewContent = req.getParameter("viewContent")==null?false:req.getParameter("viewContent").equals("true");
|
boolean viewContent = req.getParameter("viewContent")==null?false:req.getParameter("viewContent").equals("true");
|
||||||
//String currUserId = req.getParameter(ConstantsExplorer.CURRENT_USER_ID);
|
//String currUserId = req.getParameter(ConstantsExplorer.CURRENT_USER_ID);
|
||||||
|
|
||||||
logger.info("request image id: "+imageId+", type: "+imageType +", "+ConstantsExplorer.CURRENT_CONTEXT_ID+ ": "+contextID);
|
|
||||||
|
|
||||||
ImageRequestType requestType = getRequestType(imageType);
|
ImageRequestType requestType = getRequestType(imageType);
|
||||||
|
logger.info("request image id: "+imageId+", type: "+requestType +", "+ConstantsExplorer.CURRENT_CONTEXT_ID+ ": "+contextID+", viewContent: "+viewContent);
|
||||||
Workspace wa = null;
|
Workspace wa = null;
|
||||||
try {
|
try {
|
||||||
|
|
||||||
|
@ -77,7 +81,10 @@ public class ImageServlet extends HttpServlet{
|
||||||
throw new SessionExpiredException();
|
throw new SessionExpiredException();
|
||||||
|
|
||||||
GCubeUser gcubeUser = PortalContext.getConfiguration().getCurrentUser(req);
|
GCubeUser gcubeUser = PortalContext.getConfiguration().getCurrentUser(req);
|
||||||
wa = WsUtil.getWorkspace(req, contextID, gcubeUser);
|
StorageHubWrapper storageHubWrapper = WsUtil.getStorageHubWrapper(req, contextID, gcubeUser);
|
||||||
|
wa = storageHubWrapper.getWorkspace();
|
||||||
|
|
||||||
|
//wa = WsUtil.getWorkspace(req, contextID, gcubeUser);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
if (e instanceof SessionExpiredException){
|
if (e instanceof SessionExpiredException){
|
||||||
resp.sendError(HttpServletResponse.SC_UNAUTHORIZED, "Error the user session is expired");
|
resp.sendError(HttpServletResponse.SC_UNAUTHORIZED, "Error the user session is expired");
|
||||||
|
@ -101,63 +108,85 @@ public class ImageServlet extends HttpServlet{
|
||||||
logger.error("Error, no images found", e);
|
logger.error("Error, no images found", e);
|
||||||
resp.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR,"Error, no images found");
|
resp.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR,"Error, no images found");
|
||||||
return;
|
return;
|
||||||
}
|
} catch (Exception e) {
|
||||||
|
logger.error("Error on getting image: ", e);
|
||||||
if (item.getType() != WorkspaceItemType.FOLDER_ITEM) {
|
resp.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR,"Error on getting image");
|
||||||
logger.error("Error wrong item type, expected FOLDER_ITEM, found "+item.getType());
|
|
||||||
resp.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR,"Error wrong item type, expected FOLDER_ITEM, found "+item.getType());
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
FolderItem folderItem = (FolderItem) item;
|
if (item instanceof FileItem == false) {
|
||||||
FolderItemType itemType = folderItem.getFolderItemType();
|
logger.error("Error wrong item type, expected a file, found "+item.getType());
|
||||||
|
resp.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR,"Error wrong item type, expected a file, found "+item.getType());
|
||||||
if (itemType != FolderItemType.EXTERNAL_IMAGE
|
|
||||||
&& itemType != FolderItemType.IMAGE_DOCUMENT) {
|
|
||||||
logger.error("Error wrong folder item type, expected EXTERNAL_IMAGE or IMAGE_DOCUMENT, found "+itemType);
|
|
||||||
resp.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "Error wrong folder item type, expected EXTERNAL_IMAGE or IMAGE_DOCUMENT, found "+itemType);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Image image = (Image) folderItem;
|
FileItem folderItem = (FileItem) item;
|
||||||
// Get the MIME type of the image
|
FileItemType itemType = folderItem.getFileItemType();
|
||||||
String mimeType = image.getMimeType();
|
|
||||||
// Set content type
|
if (itemType != FileItemType.IMAGE_DOCUMENT) {
|
||||||
resp.setContentType(mimeType);
|
logger.error("Error is wrong the file type, expected an "+FileItemType.IMAGE_DOCUMENT+", found "+itemType);
|
||||||
|
resp.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "Error wrong file item type, expected EXTERNAL_IMAGE or IMAGE_DOCUMENT, found "+itemType);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
ImageFileItem image = (ImageFileItem) folderItem;
|
||||||
|
|
||||||
|
try {
|
||||||
|
|
||||||
|
long size = 0;
|
||||||
|
ItemStreamDescriptor streamDescr = null;
|
||||||
|
String mimeType = null;
|
||||||
|
switch (requestType) {
|
||||||
|
case THUMBNAIL:
|
||||||
|
|
||||||
|
try{
|
||||||
|
streamDescr = wa.getThumbnailData(image.getId());
|
||||||
|
}catch (Exception e) {
|
||||||
|
logger.warn("Thumbnail data not available from StorageHub, creating it by the "+ThumbnailGenerator.class.getSimpleName() +" provided by the "+ImageServlet.class.getSimpleName());
|
||||||
|
streamDescr = wa.downloadFile(image.getId(), image.getName(), null, null);
|
||||||
|
InputStream thumbIs = ThumbnailGenerator.generateThumbnail(streamDescr.getStream(), image.getName(), THUMB_MAX_SIZE, THUMB_MAX_SIZE);
|
||||||
|
streamDescr = new org.gcube.common.storagehubwrapper.shared.tohl.impl.StreamDescriptor(thumbIs, image.getName(), null, image.getMimeType());
|
||||||
|
}
|
||||||
|
mimeType = streamDescr.getMimeType()!=null?streamDescr.getMimeType():image.getMimeType();
|
||||||
|
size = streamDescr.getSize()==null?0:streamDescr.getSize(); //reading size from byte.lenght
|
||||||
|
logger.info("THUMBNAIL size: "+size);
|
||||||
|
break;
|
||||||
|
case IMAGE:
|
||||||
|
default:
|
||||||
|
//reading mimeType from source image
|
||||||
|
mimeType = image.getMimeType();
|
||||||
|
size = image.getSize()==null?0:image.getSize(); //reading size from image source
|
||||||
|
streamDescr = wa.downloadFile(image.getId(), image.getName(), null, null);
|
||||||
|
logger.info("IMAGE size is: "+size);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
String fileName = image.getName();
|
||||||
String contentDisposition = viewContent?"inline":"attachment";
|
String contentDisposition = viewContent?"inline":"attachment";
|
||||||
|
resp.setHeader("Content-Disposition", contentDisposition+"; filename=\"" + fileName + "\"" );
|
||||||
|
|
||||||
try {
|
logger.info("mimeType is: "+mimeType);
|
||||||
resp.setHeader( "Content-Disposition", contentDisposition+"; filename=\"" + image.getName() + "\"" );
|
resp.setContentType(mimeType);
|
||||||
}
|
|
||||||
catch (InternalErrorException e1) {
|
|
||||||
logger.warn("Image name not found skipping set header response");
|
|
||||||
}
|
|
||||||
|
|
||||||
// Set content size
|
//if image/thumbnail size is 0, skipping setContentLength
|
||||||
try {
|
if(size!=0)
|
||||||
/*
|
|
||||||
long size = (requestType==ImageRequestType.IMAGE)?image.getLength():image.getThumbnailLength();
|
|
||||||
resp.setContentLength((int)size);
|
resp.setContentLength((int)size);
|
||||||
*/
|
|
||||||
long size = requestType==ImageRequestType.IMAGE?image.getLength():0;
|
|
||||||
if(size == 0){
|
|
||||||
logger.warn("Image or Thumbnail size is 0, skipping set content lenght");
|
|
||||||
}else
|
|
||||||
resp.setContentLength((int)size);
|
|
||||||
} catch (InternalErrorException e) {
|
|
||||||
resp.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR,"Error in image lenght retrieving");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Send the content
|
InputStream in = streamDescr.getStream();
|
||||||
try {
|
|
||||||
|
if(in==null)
|
||||||
|
throw new InternalErrorException("Image/Thumbnail data is null for image: "+image.getName());
|
||||||
|
|
||||||
OutputStream out = resp.getOutputStream();
|
OutputStream out = resp.getOutputStream();
|
||||||
InputStream in = requestType==ImageRequestType.IMAGE?image.getData():image.getThumbnail();
|
// Send the content
|
||||||
IOUtils.copy(in, out);
|
IOUtils.copy(in, out);
|
||||||
in.close();
|
in.close();
|
||||||
out.close();
|
out.close();
|
||||||
} catch (InternalErrorException e) {
|
logger.info("stream copied correctly");
|
||||||
resp.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR,"Error in image data retrieving");
|
} catch (Exception e) {
|
||||||
|
logger.error("Error: ",e);
|
||||||
|
resp.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR,"Error on gettimg the image/thumbnail data");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -111,112 +111,6 @@ public class NotificationsProducer {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Runs a new thread to notify the contacts passed in input.
|
|
||||||
*
|
|
||||||
* @param listSharedContact the list shared contact
|
|
||||||
* @param folderItem the folder item
|
|
||||||
* @param itemOldName the item old name
|
|
||||||
* @param itemNewName the item new name
|
|
||||||
* @param idsharedFolder the idshared folder
|
|
||||||
*/
|
|
||||||
public void notifyFolderRenamed(final List<InfoContactModel> listSharedContact, final WorkspaceItem folderItem, final String itemOldName, final String itemNewName, final String idsharedFolder) {
|
|
||||||
|
|
||||||
new Thread(){
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
|
|
||||||
logger.trace("Send notifies shared folder was renamed is running...");
|
|
||||||
|
|
||||||
try {
|
|
||||||
|
|
||||||
if(NotificationsUtil.checkIsRootFolderShared(folderItem.getId(), idsharedFolder)){
|
|
||||||
logger.trace("Notification isn't sent because the event is on root shared folder");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
} catch (InternalErrorException e1) {
|
|
||||||
logger.error("An error occurred in checkIsRootFolderShared ", e1);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (InfoContactModel infoContactModel : listSharedContact) {
|
|
||||||
try{
|
|
||||||
//NOTIFIES ONLY THE USERS THAT ARE DIFFERENT FROM CURRENT USER
|
|
||||||
if(infoContactModel.getLogin().compareTo(userId)!=0){
|
|
||||||
|
|
||||||
logger.trace("Sending notification share folder "+itemOldName+" was renamed as " + itemNewName+ "for user "+infoContactModel.getLogin());
|
|
||||||
|
|
||||||
//DEBUG
|
|
||||||
System.out.println("Sending notification share folder "+itemOldName+" was renamed as " + itemNewName+ "for user "+infoContactModel.getLogin());
|
|
||||||
|
|
||||||
boolean notify = notificationsMng.notifyFolderRenaming(infoContactModel.getLogin(), itemOldName, itemNewName, idsharedFolder);
|
|
||||||
|
|
||||||
|
|
||||||
if(!notify)
|
|
||||||
logger.error("An error occured when notify user: "+infoContactModel.getLogin());
|
|
||||||
}
|
|
||||||
}catch (Exception e) {
|
|
||||||
logger.error("An error occured in notifyFolderRenamed ", e);
|
|
||||||
// e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
logger.trace("notifies share folder was renamed is completed");
|
|
||||||
}
|
|
||||||
}.start();
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Runs a new thread to notify the contacts passed in input.
|
|
||||||
*
|
|
||||||
* @param listSharedContact the list shared contact
|
|
||||||
* @param previousName the previous name
|
|
||||||
* @param item the item
|
|
||||||
* @param sharedFolder the shared folder
|
|
||||||
*/
|
|
||||||
public void notifyItemRenamed(final List<InfoContactModel> listSharedContact, final String previousName, final WorkspaceItem item, final WorkspaceSharedFolder sharedFolder) {
|
|
||||||
|
|
||||||
new Thread(){
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
|
|
||||||
logger.trace("Send notifies shared item was updated is running...");
|
|
||||||
|
|
||||||
for (InfoContactModel infoContactModel : listSharedContact) {
|
|
||||||
try{
|
|
||||||
//NOTIFIES ONLY THE USERS THAT ARE DIFFERENT FROM CURRENT USER
|
|
||||||
if(infoContactModel.getLogin().compareTo(userId)!=0){
|
|
||||||
|
|
||||||
logger.trace("Sending notification to user "+infoContactModel.getLogin() + " updated item "+item.getName());
|
|
||||||
|
|
||||||
//DEBUG
|
|
||||||
System.out.println("Sending notification to user "+infoContactModel.getLogin() + " updated item "+item.getName());
|
|
||||||
|
|
||||||
// notificationsMng.notifyItemRenaming(infoContactModel.getLogin(), previousName, item, sharedFolder);
|
|
||||||
|
|
||||||
boolean notify = notificationsMng.notifyItemRenaming(infoContactModel.getLogin(), previousName, item, sharedFolder);
|
|
||||||
|
|
||||||
if(!notify)
|
|
||||||
logger.error("An error occured when notify user: "+infoContactModel.getLogin());
|
|
||||||
}
|
|
||||||
}catch (Exception e) {
|
|
||||||
logger.error("An error occured in notifyItemUpdated ", e);
|
|
||||||
// e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
logger.trace("notifies shared item was updated is completed");
|
|
||||||
}
|
|
||||||
}.start();
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Runs a new thread to notify the updated (add/remove) contacts to sharing.
|
* Runs a new thread to notify the updated (add/remove) contacts to sharing.
|
||||||
*
|
*
|
||||||
|
|
|
@ -0,0 +1,67 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package org.gcube.portlets.user.workspace.server.notifications.tostoragehub;
|
||||||
|
|
||||||
|
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
import org.gcube.applicationsupportlayer.social.shared.SocialFileItem;
|
||||||
|
import org.gcube.applicationsupportlayer.social.shared.SocialSharedFolder;
|
||||||
|
import org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceItem;
|
||||||
|
import org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceSharedFolder;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Class NotificationMapper.
|
||||||
|
*
|
||||||
|
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
|
||||||
|
* Oct 2, 2018
|
||||||
|
*/
|
||||||
|
public class NotificationMapperToStorageHub {
|
||||||
|
|
||||||
|
protected static Logger logger = Logger.getLogger(NotificationMapperToStorageHub.class);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* To social shared folder.
|
||||||
|
*
|
||||||
|
* @param sharedFolder the shared folder
|
||||||
|
* @return the social shared folder
|
||||||
|
*/
|
||||||
|
public static SocialSharedFolder toSocialSharedFolder(WorkspaceSharedFolder sharedFolder){
|
||||||
|
|
||||||
|
return new SocialSharedFolder(sharedFolder.getId(),
|
||||||
|
sharedFolder.getName(),
|
||||||
|
sharedFolder.getTitle(),
|
||||||
|
sharedFolder.getName(),
|
||||||
|
sharedFolder.getPath(),
|
||||||
|
sharedFolder.getParentId(),
|
||||||
|
sharedFolder.isVreFolder());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* To social item.
|
||||||
|
*
|
||||||
|
* @param workspace the workspace
|
||||||
|
* @param item the item
|
||||||
|
* @return the social file item
|
||||||
|
*/
|
||||||
|
public static SocialFileItem toSocialItem(org.gcube.common.storagehubwrapper.server.tohl.Workspace workspace, WorkspaceItem item){
|
||||||
|
|
||||||
|
WorkspaceItem theParentFolder = null;
|
||||||
|
try {
|
||||||
|
theParentFolder = workspace.getItem(item.getParentId());
|
||||||
|
}
|
||||||
|
catch (Exception e) {
|
||||||
|
logger.warn("Impossible the item using the parent id: "+item.getParentId());
|
||||||
|
}
|
||||||
|
//
|
||||||
|
SocialSharedFolder parent = null;
|
||||||
|
if(theParentFolder!=null && theParentFolder instanceof WorkspaceSharedFolder)
|
||||||
|
parent = toSocialSharedFolder((WorkspaceSharedFolder) theParentFolder);
|
||||||
|
//
|
||||||
|
return new SocialFileItem(item.getId(), item.getName(), item.getTitle(), item.getPath(), parent);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,211 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package org.gcube.portlets.user.workspace.server.notifications.tostoragehub;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
import org.gcube.common.storagehub.model.types.WorkspaceItemType;
|
||||||
|
import org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceFolder;
|
||||||
|
import org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceItem;
|
||||||
|
import org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceSharedFolder;
|
||||||
|
import org.gcube.portlets.user.workspace.client.model.InfoContactModel;
|
||||||
|
import org.gcube.portlets.user.workspace.server.GWTWorkspaceBuilder;
|
||||||
|
import org.gcube.portlets.user.workspace.server.util.WsUtil;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Class NotificationFromStorageHub.
|
||||||
|
*
|
||||||
|
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
||||||
|
* Oct 2, 2018
|
||||||
|
*/
|
||||||
|
public class NotificationStorageHubUtil {
|
||||||
|
|
||||||
|
private static Logger logger = Logger.getLogger(NotificationStorageHubUtil.class);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check notify add item to share.
|
||||||
|
*
|
||||||
|
* @param workspaceItem the workspace item
|
||||||
|
* @param sourceRootSharedFolderId the source shared id
|
||||||
|
* @param parentFolderItem the parent folder item
|
||||||
|
* @param workspace the workspace
|
||||||
|
* @param np the NotificationsProducerToStorageHub
|
||||||
|
*/
|
||||||
|
public static void checkNotifyAddItemToShare(final WorkspaceItem workspaceItem, final String sourceRootSharedFolderId, final WorkspaceFolder parentFolderItem, org.gcube.common.storagehubwrapper.server.tohl.Workspace workspace, NotificationsProducerToStorageHub np) {
|
||||||
|
|
||||||
|
logger.trace("checkNotifyAddItemToShare");
|
||||||
|
|
||||||
|
if(parentFolderItem!=null){
|
||||||
|
|
||||||
|
try{
|
||||||
|
//if folder destination is shared folder
|
||||||
|
if(parentFolderItem.isShared()){ //Notify Added Item To Sharing?
|
||||||
|
|
||||||
|
WorkspaceItem rootSharedFolder = workspace.getRootSharedFolder(parentFolderItem.getId());
|
||||||
|
logger.trace("checkNotifyAddItemToShare source item: "+workspaceItem.getName()+" sourceRootSharedFolderId: "+sourceRootSharedFolderId + " folder destination: "+parentFolderItem.getName());
|
||||||
|
//share condition is true if source shared folder is null or not equal to destination shared folder
|
||||||
|
boolean shareChangeCondition = sourceRootSharedFolderId==null || sourceRootSharedFolderId.compareTo(rootSharedFolder.getId())!=0;
|
||||||
|
//System.out.println("shareChangeCondition add item: "+ shareChangeCondition);
|
||||||
|
logger.trace("shareChangeCondition add item: "+shareChangeCondition);
|
||||||
|
|
||||||
|
//if shareChangeCondition is true.. notifies added item to sharing
|
||||||
|
if(shareChangeCondition){
|
||||||
|
|
||||||
|
List<InfoContactModel> listContacts = getListUserSharedByFolderSharedId(rootSharedFolder, workspace);
|
||||||
|
//WorkspaceItem destinationSharedFolder = workspace.getItem(rootSharedFolder.getId());
|
||||||
|
WorkspaceItem destinationSharedFolder = rootSharedFolder;
|
||||||
|
|
||||||
|
if(destinationSharedFolder instanceof WorkspaceSharedFolder){
|
||||||
|
np.notifyAddedItemToSharing(workspace, listContacts, workspaceItem, (WorkspaceSharedFolder) destinationSharedFolder);
|
||||||
|
logger.trace("The notifies sent correctly");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
logger.warn("Notifies added item: "+workspaceItem+ "to share doesn't sent because "+destinationSharedFolder+" is not istance of WorkspaceSharedFolder");
|
||||||
|
// np.notifyAddedItemToSharing(listContacts, (WorkspaceFolder) folderDestinationItem);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
logger.trace("folder destination is not shared");
|
||||||
|
|
||||||
|
}catch (Exception e) {
|
||||||
|
logger.error("An error occurred in verifyNotifyAddItemToShare ",e);
|
||||||
|
}
|
||||||
|
}else
|
||||||
|
logger.warn("The notifies is failure in verifyNotifyAddItemToShare because folder destination item is null");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check notify move item from share.
|
||||||
|
*
|
||||||
|
* @param sourceItemIsShared the source item is shared
|
||||||
|
* @param sourceItem the source item
|
||||||
|
* @param sourceRootSharedFolderId the source root shared folder id
|
||||||
|
* @param folderDestination the folder destination
|
||||||
|
* @param workspace the workspace
|
||||||
|
* @param np the NotificationsProducerToStorageHub
|
||||||
|
*/
|
||||||
|
public static void checkNotifyMoveItemFromShare(
|
||||||
|
boolean sourceItemIsShared,
|
||||||
|
org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceItem sourceItem,
|
||||||
|
String sourceRootSharedFolderId,
|
||||||
|
org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceFolder folderDestination, org.gcube.common.storagehubwrapper.server.tohl.Workspace workspace, NotificationsProducerToStorageHub np) {
|
||||||
|
|
||||||
|
try{
|
||||||
|
|
||||||
|
String rootDestSharedFolderId = null;
|
||||||
|
WorkspaceItem rootDestSharedFolder = null;
|
||||||
|
|
||||||
|
if(folderDestination.isShared()){
|
||||||
|
rootDestSharedFolder = workspace.getRootSharedFolder(folderDestination.getId());
|
||||||
|
rootDestSharedFolderId = rootDestSharedFolder.getId();
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean shareChangeCondition = false;
|
||||||
|
|
||||||
|
//share condition is true if source shared folder is not equal to destination shared folder
|
||||||
|
if(rootDestSharedFolderId!=null)
|
||||||
|
shareChangeCondition = sourceRootSharedFolderId==null?false:sourceRootSharedFolderId.compareTo(rootDestSharedFolderId)!=0;
|
||||||
|
|
||||||
|
logger.trace("checkNotifyMoveItemFromShare source item: "+sourceItem.getName()+" rootSharedFolderId: "+sourceRootSharedFolderId + " folder destination: "+folderDestination.getName() +" sourceItemIsShared: "+sourceItemIsShared);
|
||||||
|
logger.trace("shareChangeCondition remove item: "+ shareChangeCondition);
|
||||||
|
|
||||||
|
//Notify Removed Item To Sharing?
|
||||||
|
//if source Item is shared and folder destination is not shared or shareChangeCondition is true.. notifies removed item to sharing
|
||||||
|
if(sourceItemIsShared && (!folderDestination.isShared() || shareChangeCondition)){
|
||||||
|
|
||||||
|
//get contacts
|
||||||
|
List<InfoContactModel> listContacts = getListUserSharedByFolderSharedId(rootDestSharedFolder, workspace);
|
||||||
|
|
||||||
|
WorkspaceItem sourceRootSharedFolder = workspace.getItem(sourceRootSharedFolderId);
|
||||||
|
|
||||||
|
if(sourceRootSharedFolder instanceof WorkspaceSharedFolder){
|
||||||
|
np.notifyMovedItemToSharing(workspace, listContacts, sourceItem, (WorkspaceSharedFolder) sourceRootSharedFolder);
|
||||||
|
logger.trace("The notifies was sent correctly");
|
||||||
|
}else
|
||||||
|
logger.warn("Notifies moved item: "+sourceItem+ "from share doesn't sent because "+sourceRootSharedFolder+" is not istance of WorkspaceSharedFolder");
|
||||||
|
}
|
||||||
|
|
||||||
|
}catch (Exception e) {
|
||||||
|
logger.error("An error occurred in checkNotifyMoveItemFromShare ",e);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the list user shared by folder shared id.
|
||||||
|
*
|
||||||
|
* @param rootSharedFolder the root shared folder
|
||||||
|
* @param workspace the workspace
|
||||||
|
* @return the list user shared by folder shared id
|
||||||
|
* @throws Exception the exception
|
||||||
|
*/
|
||||||
|
public static List<InfoContactModel> getListUserSharedByFolderSharedId(WorkspaceItem rootSharedFolder, org.gcube.common.storagehubwrapper.server.tohl.Workspace workspace) throws Exception{
|
||||||
|
|
||||||
|
logger.debug("getListUserSharedByFolderSharedId "+ rootSharedFolder);
|
||||||
|
|
||||||
|
try {
|
||||||
|
|
||||||
|
if(isASharedFolder(rootSharedFolder)){ //JUST TO BE SURE
|
||||||
|
|
||||||
|
List<String> listPortalLogin = workspace.getSharedFolderMembers(rootSharedFolder.getId());
|
||||||
|
logger.debug("StorageHub returned "+ listPortalLogin.size() + " user/s");
|
||||||
|
|
||||||
|
if(!WsUtil.isWithinPortal())
|
||||||
|
return GWTWorkspaceBuilder.buildGxtInfoContactFromPortalLoginTestMode(listPortalLogin);
|
||||||
|
|
||||||
|
return GWTWorkspaceBuilder.buildGxtInfoContactsFromPortalLogins(listPortalLogin);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
logger.debug("the item with id: "+rootSharedFolder.getId()+ " is not "+WorkspaceItemType.SHARED_FOLDER);
|
||||||
|
|
||||||
|
return new ArrayList<InfoContactModel>();
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error("Error in getListUserSharedByItemId ", e);
|
||||||
|
throw new Exception(e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if is a shared folder.
|
||||||
|
*
|
||||||
|
* @param wsItem the ws item
|
||||||
|
* @return true, if is a shared folder
|
||||||
|
*/
|
||||||
|
public static boolean isASharedFolder(WorkspaceItem wsItem){
|
||||||
|
if(wsItem!=null)
|
||||||
|
return wsItem.getType().equals(WorkspaceItemType.SHARED_FOLDER);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check is root folder shared.
|
||||||
|
*
|
||||||
|
* @param itemId the item id
|
||||||
|
* @param rootFolderSharedId the root folder shared id
|
||||||
|
* @return true, if successful
|
||||||
|
*/
|
||||||
|
public static boolean checkIsRootFolderShared(String itemId, String rootFolderSharedId) {
|
||||||
|
|
||||||
|
logger.trace("checkIsRootFolderShared between [itemid: "+itemId +", rootFolderSharedId: "+rootFolderSharedId+"]");
|
||||||
|
if(itemId==null)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if(rootFolderSharedId==null)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if(itemId.compareTo(rootFolderSharedId)==0)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,228 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package org.gcube.portlets.user.workspace.server.notifications.tostoragehub;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import javax.servlet.http.HttpSession;
|
||||||
|
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
import org.gcube.applicationsupportlayer.social.NotificationsManager;
|
||||||
|
import org.gcube.common.scope.impl.ScopeBean;
|
||||||
|
import org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceItem;
|
||||||
|
import org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceSharedFolder;
|
||||||
|
import org.gcube.portlets.user.workspace.client.model.InfoContactModel;
|
||||||
|
import org.gcube.portlets.user.workspace.server.util.PortalContextInfo;
|
||||||
|
import org.gcube.portlets.user.workspace.server.util.WsUtil;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Class NotificationsProducerToStorageHub.
|
||||||
|
*
|
||||||
|
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
|
||||||
|
* Oct 5, 2018
|
||||||
|
*/
|
||||||
|
public class NotificationsProducerToStorageHub {
|
||||||
|
|
||||||
|
protected ScopeBean scope;
|
||||||
|
|
||||||
|
protected static Logger logger = Logger.getLogger(NotificationsProducerToStorageHub.class);
|
||||||
|
|
||||||
|
protected NotificationsManager notificationsMng;
|
||||||
|
protected HttpSession httpSession;
|
||||||
|
protected String userId;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Instantiates a new notifications producer.
|
||||||
|
*
|
||||||
|
* @param httpServletRequest the http servlet request
|
||||||
|
*/
|
||||||
|
public NotificationsProducerToStorageHub(HttpServletRequest httpServletRequest) {
|
||||||
|
PortalContextInfo info = WsUtil.getPortalContext(httpServletRequest);
|
||||||
|
this.notificationsMng = WsUtil.getNotificationManager(httpServletRequest);
|
||||||
|
this.userId = info.getUsername();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Runs a new thread to notify the contacts passed in input.
|
||||||
|
*
|
||||||
|
* @param workspace the workspace
|
||||||
|
* @param listContacts the list contacts
|
||||||
|
* @param workspaceItem the workspace item
|
||||||
|
* @param sharedFolder the shared folder
|
||||||
|
*/
|
||||||
|
public void notifyAddedItemToSharing(final org.gcube.common.storagehubwrapper.server.tohl.Workspace workspace, final List<InfoContactModel> listContacts, final WorkspaceItem workspaceItem, final WorkspaceSharedFolder sharedFolder) {
|
||||||
|
|
||||||
|
new Thread() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
|
||||||
|
// printContacts(listContacts);
|
||||||
|
logger.debug("Send notifies added item in sharedfolder is running...");
|
||||||
|
|
||||||
|
for (InfoContactModel infoContactModel : listContacts) {
|
||||||
|
try{
|
||||||
|
|
||||||
|
//NOTIFIES ONLY THE USERS THAT ARE DIFFERENT FROM CURRENT USER
|
||||||
|
if(infoContactModel.getLogin().compareTo(userId)!=0){
|
||||||
|
|
||||||
|
logger.debug("Sending notification to user "+infoContactModel.getLogin() +" added item [id: "+workspaceItem.getId() +"] name: "+workspaceItem.getName()+" in shared folder "+sharedFolder.getName());
|
||||||
|
boolean notify = notificationsMng.notifyAddedItem(infoContactModel.getLogin(), NotificationMapperToStorageHub.toSocialItem(workspace, workspaceItem), NotificationMapperToStorageHub.toSocialSharedFolder(sharedFolder));
|
||||||
|
|
||||||
|
if(!notify){
|
||||||
|
logger.error("An error occured when notify user: "+infoContactModel.getLogin());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}catch (Exception e) {
|
||||||
|
logger.error("An error occured in notifyAddedItemToSharing ", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
logger.debug("notifies of added item in shared folder is completed");
|
||||||
|
}
|
||||||
|
|
||||||
|
}.start();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Notify moved item to sharing.
|
||||||
|
*
|
||||||
|
* @param workspace the workspace
|
||||||
|
* @param listContacts the list contacts
|
||||||
|
* @param workspaceItem the workspace item
|
||||||
|
* @param sourceRootSharedFolder the shared folder
|
||||||
|
*/
|
||||||
|
public void notifyMovedItemToSharing(final org.gcube.common.storagehubwrapper.server.tohl.Workspace workspace, final List<InfoContactModel> listContacts, final WorkspaceItem workspaceItem, final WorkspaceSharedFolder sourceRootSharedFolder) {
|
||||||
|
|
||||||
|
|
||||||
|
new Thread() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
|
||||||
|
logger.debug("Sending notification remove item in shared folder is running...");
|
||||||
|
|
||||||
|
for (InfoContactModel infoContactModel : listContacts) {
|
||||||
|
try{
|
||||||
|
|
||||||
|
//NOTIFIES ONLY THE USERS THAT ARE DIFFERENT FROM CURRENT USER
|
||||||
|
if(infoContactModel.getLogin().compareTo(userId)!=0){
|
||||||
|
|
||||||
|
logger.debug("Sending notification to user "+infoContactModel.getLogin() +" moved item "+workspaceItem.getName()+" in shared folder "+sourceRootSharedFolder.getName());
|
||||||
|
boolean notify = notificationsMng.notifyMovedItem(infoContactModel.getLogin(), NotificationMapperToStorageHub.toSocialItem(workspace, workspaceItem), NotificationMapperToStorageHub.toSocialSharedFolder(sourceRootSharedFolder));
|
||||||
|
|
||||||
|
if(!notify){
|
||||||
|
logger.error("An error occured when notify user: "+infoContactModel.getLogin());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}catch (Exception e) {
|
||||||
|
logger.error("An error occurred in notifyMovedItemToSharing ", e);
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
logger.debug("notifies of moved item in shared folder is completed");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}.start();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Notify folder renamed.
|
||||||
|
*
|
||||||
|
* @param listSharedContact the list shared contact
|
||||||
|
* @param folderItem the folder item
|
||||||
|
* @param itemOldName the item old name
|
||||||
|
* @param itemNewName the item new name
|
||||||
|
* @param idRootSharedFolder the id root shared folder
|
||||||
|
*/
|
||||||
|
public void notifyFolderRenamed(final List<InfoContactModel> listSharedContact, final WorkspaceItem folderItem, final String itemOldName, final String itemNewName, final String idRootSharedFolder) {
|
||||||
|
|
||||||
|
new Thread(){
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
|
||||||
|
logger.trace("Send notifies shared folder was renamed is running...");
|
||||||
|
|
||||||
|
if(NotificationStorageHubUtil.checkIsRootFolderShared(folderItem.getId(), idRootSharedFolder)){
|
||||||
|
logger.info("Notification not sent because the event is on root shared folder");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (InfoContactModel infoContactModel : listSharedContact) {
|
||||||
|
try{
|
||||||
|
//NOTIFIES ONLY THE USERS THAT ARE DIFFERENT FROM CURRENT USER
|
||||||
|
if(infoContactModel.getLogin().compareTo(userId)!=0){
|
||||||
|
|
||||||
|
logger.debug("Sending notification share folder "+itemOldName+" was renamed as " + itemNewName+ "for user "+infoContactModel.getLogin());
|
||||||
|
boolean notify = notificationsMng.notifyFolderRenaming(infoContactModel.getLogin(), itemOldName, itemNewName, idRootSharedFolder);
|
||||||
|
|
||||||
|
if(!notify)
|
||||||
|
logger.error("An error occured when notify user: "+infoContactModel.getLogin());
|
||||||
|
}
|
||||||
|
}catch (Exception e) {
|
||||||
|
logger.error("An error occured in notifyFolderRenamed ", e);
|
||||||
|
// e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
logger.trace("notifies share folder was renamed is completed");
|
||||||
|
}
|
||||||
|
}.start();
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Notify item renamed.
|
||||||
|
*
|
||||||
|
* @param listSharedContact the list shared contact
|
||||||
|
* @param previousName the previous name
|
||||||
|
* @param item the item
|
||||||
|
* @param sharedFolder the shared folder
|
||||||
|
* @param workspace the workspace
|
||||||
|
*/
|
||||||
|
public void notifyItemRenamed(final List<InfoContactModel> listSharedContact, final String previousName, final WorkspaceItem item, final WorkspaceSharedFolder sharedFolder, final org.gcube.common.storagehubwrapper.server.tohl.Workspace workspace) {
|
||||||
|
|
||||||
|
new Thread(){
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
|
||||||
|
logger.trace("Send notifies shared item was updated is running...");
|
||||||
|
|
||||||
|
for (InfoContactModel infoContactModel : listSharedContact) {
|
||||||
|
try{
|
||||||
|
//NOTIFIES ONLY THE USERS THAT ARE DIFFERENT FROM CURRENT USER
|
||||||
|
if(infoContactModel.getLogin().compareTo(userId)!=0){
|
||||||
|
|
||||||
|
logger.debug("Sending notification to user "+infoContactModel.getLogin() + " updated item "+item.getName());
|
||||||
|
boolean notify = notificationsMng.notifyItemRenaming(infoContactModel.getLogin(), previousName, NotificationMapperToStorageHub.toSocialItem(workspace, item), NotificationMapperToStorageHub.toSocialSharedFolder(sharedFolder));
|
||||||
|
|
||||||
|
if(!notify)
|
||||||
|
logger.error("An error occured when notify user: "+infoContactModel.getLogin());
|
||||||
|
}
|
||||||
|
}catch (Exception e) {
|
||||||
|
logger.error("An error occured in notifyItemUpdated ", e);
|
||||||
|
// e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
logger.trace("notifies shared item was updated is completed");
|
||||||
|
}
|
||||||
|
}.start();
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,298 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package org.gcube.portlets.user.workspace.server.tostoragehub;
|
||||||
|
|
||||||
|
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
import org.gcube.common.storagehubwrapper.shared.tohl.exceptions.InternalErrorException;
|
||||||
|
import org.gcube.common.storagehubwrapper.shared.tohl.impl.WorkspaceSharedFolder;
|
||||||
|
import org.gcube.common.storagehubwrapper.shared.tohl.items.FileItem;
|
||||||
|
import org.gcube.portlets.user.workspace.client.interfaces.GXTCategorySmartFolder;
|
||||||
|
import org.gcube.portlets.user.workspace.client.interfaces.GXTFolderItemTypeEnum;
|
||||||
|
import org.gcube.portlets.user.workspace.client.model.FileGridModel;
|
||||||
|
import org.gcube.portlets.user.workspace.client.model.FileModel;
|
||||||
|
import org.gcube.portlets.user.workspace.client.model.FolderGridModel;
|
||||||
|
import org.gcube.portlets.user.workspace.client.model.FolderModel;
|
||||||
|
import org.gcube.portlets.user.workspace.server.GWTWorkspaceBuilder;
|
||||||
|
import org.gcube.portlets.user.workspace.server.util.UserUtil;
|
||||||
|
import org.gcube.vomanagement.usermanagement.model.GCubeUser;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Class StorageHubToWorkpaceConveter.
|
||||||
|
*
|
||||||
|
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
|
||||||
|
* Sep 20, 2018
|
||||||
|
*/
|
||||||
|
public class ObjectStorageHubToWorkpaceMapper {
|
||||||
|
|
||||||
|
|
||||||
|
protected static Logger logger = Logger.getLogger(ObjectStorageHubToWorkpaceMapper.class);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* To root folder.
|
||||||
|
*
|
||||||
|
* @param folder the folder
|
||||||
|
* @return the folder model
|
||||||
|
* @throws InternalErrorException the internal error exception
|
||||||
|
*/
|
||||||
|
public static FolderModel toRootFolder(org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceFolder folder) throws InternalErrorException{
|
||||||
|
|
||||||
|
if(folder==null)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
boolean isVreFolder = false;
|
||||||
|
boolean isPublicFolder = false; //TODO
|
||||||
|
if(folder.isShared()){
|
||||||
|
WorkspaceSharedFolder sharedFolder = (WorkspaceSharedFolder) folder;
|
||||||
|
isVreFolder = sharedFolder.isVreFolder();
|
||||||
|
}
|
||||||
|
|
||||||
|
// FolderModel root = new FolderModel(workspaceRoot.getId(),workspaceRoot.getName(),null, true, workspaceRoot.isShared(), false, workspaceRoot.isPublic());
|
||||||
|
// root.setIsRoot(true);
|
||||||
|
|
||||||
|
FolderModel theFolder = new FolderModel(folder.getId(), folder.getName(), null, folder.isFolder(), folder.isShared(), isVreFolder, isPublicFolder);
|
||||||
|
theFolder.setIsRoot(folder.isRoot());
|
||||||
|
return theFolder;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* To tree file model item.
|
||||||
|
*
|
||||||
|
* @param wrappedItem the wrapped item
|
||||||
|
* @param parentFolderModel the parent folder model
|
||||||
|
* @param isParentShared the is parent shared
|
||||||
|
* @return the file model
|
||||||
|
* @throws InternalErrorException the internal error exception
|
||||||
|
*/
|
||||||
|
public static FileModel toTreeFileModelItem(org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceItem wrappedItem, FileModel parentFolderModel, boolean isParentShared) throws InternalErrorException{
|
||||||
|
|
||||||
|
FileModel fileModel = null;
|
||||||
|
//boolean isPublic = false;
|
||||||
|
|
||||||
|
switch (wrappedItem.getType()) {
|
||||||
|
|
||||||
|
case FOLDER:
|
||||||
|
boolean isPublicFolder = ((org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceFolder) wrappedItem).isPublicFolder(); //TODO
|
||||||
|
fileModel = new FolderModel(wrappedItem.getId(), wrappedItem.getName(), parentFolderModel, true, false, false, isPublicFolder);
|
||||||
|
if(isPublicFolder)
|
||||||
|
fileModel.setType(GXTFolderItemTypeEnum.FOLDER_PUBLIC.getLabel());
|
||||||
|
else
|
||||||
|
fileModel.setType(GXTFolderItemTypeEnum.FOLDER.getLabel());
|
||||||
|
|
||||||
|
fileModel.setType(GXTFolderItemTypeEnum.FOLDER.getLabel());
|
||||||
|
fileModel.setShareable(true);
|
||||||
|
fileModel.setDescription(wrappedItem.getDescription());
|
||||||
|
break;
|
||||||
|
|
||||||
|
case FILE_ITEM:
|
||||||
|
fileModel = new FileModel(wrappedItem.getId(), wrappedItem.getName(), parentFolderModel, false, false);
|
||||||
|
FileItem folderItem = (FileItem) wrappedItem;
|
||||||
|
fileModel = setFolderItemType(fileModel, folderItem);
|
||||||
|
fileModel.setShareable(true);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case VRE_FOLDER:
|
||||||
|
fileModel = new FolderModel(wrappedItem.getId(), wrappedItem.getName(), parentFolderModel, true, true, true, false);
|
||||||
|
fileModel.setType(GXTFolderItemTypeEnum.FOLDER_SHARED.toString());
|
||||||
|
fileModel.setShareable(true);
|
||||||
|
fileModel.setDescription(wrappedItem.getDescription());
|
||||||
|
break;
|
||||||
|
case SHARED_FOLDER:
|
||||||
|
//WorkspaceSharedFolder shared = (WorkspaceSharedFolder) wrappedItem;
|
||||||
|
boolean isPublicDir = ((org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceFolder) wrappedItem).isPublicFolder(); //TODO
|
||||||
|
//isPublic = ((WorkspaceFolder) shared).isPublic(); //TODO isPublic
|
||||||
|
//OLD HL
|
||||||
|
//String name = shared.isVreFolder()?shared.getDisplayName():item.getName();
|
||||||
|
fileModel = new FolderModel(wrappedItem.getId(), wrappedItem.getName(), parentFolderModel, true, true, false, isPublicDir);
|
||||||
|
if(isPublicDir)
|
||||||
|
fileModel.setType(GXTFolderItemTypeEnum.FOLDER_SHARED_PUBLIC.toString());
|
||||||
|
else
|
||||||
|
fileModel.setType(GXTFolderItemTypeEnum.FOLDER_SHARED.toString());
|
||||||
|
|
||||||
|
fileModel.setShareable(true);
|
||||||
|
fileModel.setDescription(wrappedItem.getDescription());
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
logger.error("ALERT Conversion RETURNING null for item "+wrappedItem.getName());
|
||||||
|
break;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//SET SHARE POLICY
|
||||||
|
if(parentFolderModel!=null && parentFolderModel.isShared()){
|
||||||
|
fileModel.setShared(true);
|
||||||
|
fileModel.setShareable(false); //UPDATED TO CHANGE PERMISSIONS TO SHARED SUBFOLDERS
|
||||||
|
}else if(parentFolderModel==null && wrappedItem.isShared()){ //ADDED TO FIX #1808
|
||||||
|
fileModel.setShared(true);
|
||||||
|
if(wrappedItem.getParentId()!=null && isParentShared)
|
||||||
|
fileModel.setShareable(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
//setSynchedThreddsStateFor(fileModel);
|
||||||
|
fileModel.setIsRoot(wrappedItem.isRoot());
|
||||||
|
logger.trace("Returning converted tree item: "+fileModel);
|
||||||
|
return fileModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* To grid file model item.
|
||||||
|
*
|
||||||
|
* @param wrappedItem the wrapped item
|
||||||
|
* @param parentFolderModel the parent folder model
|
||||||
|
* @param isParentShared the is parent shared
|
||||||
|
* @param loggedUser the logged user
|
||||||
|
* @return the file grid model
|
||||||
|
* @throws InternalErrorException the internal error exception
|
||||||
|
*/
|
||||||
|
public static FileGridModel toGridFileModelItem(org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceItem wrappedItem, FileModel parentFolderModel, GCubeUser loggedUser) throws InternalErrorException{
|
||||||
|
|
||||||
|
FileGridModel fileGridModel = null;
|
||||||
|
|
||||||
|
//logger.debug("toGridFileModelItem: "+wrappedItem);
|
||||||
|
//logger.debug("toGridFileModelItem getType: "+wrappedItem.getType());
|
||||||
|
|
||||||
|
switch (wrappedItem.getType()) {
|
||||||
|
|
||||||
|
case FOLDER:
|
||||||
|
boolean isPublicFolder = ((org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceFolder) wrappedItem).isPublicFolder(); //TODO
|
||||||
|
fileGridModel = new FolderGridModel(wrappedItem.getId(), wrappedItem.getName(), GWTWorkspaceBuilder.toDate(wrappedItem.getLastModificationTime()), parentFolderModel, -1, true, false,false, isPublicFolder);
|
||||||
|
if(isPublicFolder)
|
||||||
|
fileGridModel.setType(GXTFolderItemTypeEnum.FOLDER_PUBLIC.getLabel().toString());
|
||||||
|
else
|
||||||
|
fileGridModel.setType(GXTFolderItemTypeEnum.FOLDER.getLabel().toString());
|
||||||
|
|
||||||
|
fileGridModel.setShortcutCategory(GXTCategorySmartFolder.SMF_FOLDERS);
|
||||||
|
fileGridModel.setShareable(true);
|
||||||
|
fileGridModel.setDescription(wrappedItem.getDescription());
|
||||||
|
break;
|
||||||
|
|
||||||
|
case FILE_ITEM:
|
||||||
|
FileItem fileItem = (FileItem) wrappedItem;
|
||||||
|
fileGridModel = new FileGridModel(fileItem.getId(),
|
||||||
|
fileItem.getName(),
|
||||||
|
GWTWorkspaceBuilder.
|
||||||
|
toDate(fileItem.getLastModificationTime()),
|
||||||
|
parentFolderModel,
|
||||||
|
fileItem.getSize()==null?0:fileItem.getSize(),
|
||||||
|
false,
|
||||||
|
false);
|
||||||
|
fileGridModel = (FileGridModel) setFolderItemType(fileGridModel, fileItem);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case VRE_FOLDER:
|
||||||
|
fileGridModel = new FolderGridModel(wrappedItem.getId(), wrappedItem.getName(), GWTWorkspaceBuilder.toDate(wrappedItem.getLastModificationTime()), parentFolderModel, -1, true, false,true, false);
|
||||||
|
fileGridModel.setType(GXTFolderItemTypeEnum.FOLDER_SHARED.toString());
|
||||||
|
fileGridModel.setShareable(true);
|
||||||
|
fileGridModel.setDescription(wrappedItem.getDescription());
|
||||||
|
break;
|
||||||
|
|
||||||
|
case SHARED_FOLDER:
|
||||||
|
WorkspaceSharedFolder shared = (WorkspaceSharedFolder) wrappedItem;
|
||||||
|
boolean isPublicDir = ((org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceFolder) wrappedItem).isPublicFolder(); //TODO
|
||||||
|
//String name = shared.isVreFolder()?shared.getTitle():shared.getName();
|
||||||
|
fileGridModel = new FolderGridModel(wrappedItem.getId(), wrappedItem.getName(), GWTWorkspaceBuilder.toDate(wrappedItem.getLastModificationTime()), parentFolderModel, -1, true, true, shared.isVreFolder(), isPublicDir);
|
||||||
|
|
||||||
|
if(isPublicDir)
|
||||||
|
fileGridModel.setType(GXTFolderItemTypeEnum.FOLDER_SHARED_PUBLIC.getLabel().toString());
|
||||||
|
else
|
||||||
|
fileGridModel.setType(GXTFolderItemTypeEnum.FOLDER_SHARED.getLabel().toString());
|
||||||
|
|
||||||
|
fileGridModel.setShortcutCategory(GXTCategorySmartFolder.SMF_SHARED_FOLDERS);
|
||||||
|
fileGridModel.setShareable(true);
|
||||||
|
fileGridModel.setDescription(wrappedItem.getDescription());
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
logger.error("gxt conversion return null for item "+wrappedItem.getName());
|
||||||
|
break;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if(parentFolderModel!=null && parentFolderModel.isShared()){
|
||||||
|
fileGridModel.setShared(true);
|
||||||
|
fileGridModel.setShareable(false); //UPDATED TO CHANGE PERMISSIONS TO SHARED SUBFOLDERS
|
||||||
|
}
|
||||||
|
|
||||||
|
//OWNER
|
||||||
|
if(wrappedItem.isShared()){ //IT IS READ FROM HL ONLY IF THE ITEM IS SHARED
|
||||||
|
fileGridModel.setShared(true); //NOT REMOVE IT IS IMPORTAT SEE #1459
|
||||||
|
String ownerUsername = wrappedItem.getOwner();
|
||||||
|
if(ownerUsername!=null){
|
||||||
|
// System.out.println("++++reading owner");
|
||||||
|
//String portalLogin = owner.getPortalLogin();
|
||||||
|
fileGridModel.setOwnerFullName(UserUtil.getUserFullName(ownerUsername));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
if(loggedUser!=null)
|
||||||
|
// fileGridModel.setOwner(new InfoContactModel(userLogged.getId(), userLogged.getLogin(), userLogged.getName()));
|
||||||
|
fileGridModel.setOwnerFullName(loggedUser.getFullname());
|
||||||
|
}
|
||||||
|
|
||||||
|
logger.trace("Returning converted grid item: "+fileGridModel);
|
||||||
|
return fileGridModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the folder item type.
|
||||||
|
*
|
||||||
|
* @param fileModel the file model
|
||||||
|
* @param wrappedFileItem the worspace folder item
|
||||||
|
* @return the file model
|
||||||
|
* @throws InternalErrorException the internal error exception
|
||||||
|
*/
|
||||||
|
public static FileModel setFolderItemType(FileModel fileModel, FileItem wrappedFileItem) throws InternalErrorException{
|
||||||
|
|
||||||
|
fileModel.setType(wrappedFileItem.getMimeType());
|
||||||
|
|
||||||
|
//logger.debug("WrappedItem: "+wrappedFileItem);
|
||||||
|
//logger.debug("FolderItemType: "+wrappedFileItem.getFileItemType());
|
||||||
|
|
||||||
|
switch(wrappedFileItem.getFileItemType()){
|
||||||
|
|
||||||
|
case PDF_DOCUMENT:
|
||||||
|
fileModel.setFolderItemType(GXTFolderItemTypeEnum.EXTERNAL_PDF_FILE);
|
||||||
|
fileModel.setShortcutCategory(GXTCategorySmartFolder.SMF_DOCUMENTS);
|
||||||
|
// PDFFileItem extFile = (PDFFileItem) wrappedFileItem;
|
||||||
|
break;
|
||||||
|
case IMAGE_DOCUMENT:
|
||||||
|
fileModel.setFolderItemType(GXTFolderItemTypeEnum.EXTERNAL_IMAGE);
|
||||||
|
fileModel.setShortcutCategory(GXTCategorySmartFolder.SMF_IMAGES);
|
||||||
|
break;
|
||||||
|
case DOCUMENT:
|
||||||
|
fileModel.setFolderItemType(GXTFolderItemTypeEnum.EXTERNAL_FILE);
|
||||||
|
fileModel.setShortcutCategory(GXTCategorySmartFolder.SMF_DOCUMENTS);
|
||||||
|
// Document doc = (Document) worspaceFolderItem;
|
||||||
|
break;
|
||||||
|
case URL_DOCUMENT:
|
||||||
|
fileModel.setFolderItemType(GXTFolderItemTypeEnum.EXTERNAL_URL);
|
||||||
|
fileModel.setShortcutCategory(GXTCategorySmartFolder.SMF_DOCUMENTS);
|
||||||
|
break;
|
||||||
|
case METADATA:
|
||||||
|
fileModel.setFolderItemType(GXTFolderItemTypeEnum.METADATA);
|
||||||
|
fileModel.setShortcutCategory(GXTCategorySmartFolder.SMF_DOCUMENTS);
|
||||||
|
break;
|
||||||
|
case GCUBE_ITEM:
|
||||||
|
fileModel.setFolderItemType(GXTFolderItemTypeEnum.GCUBE_ITEM);
|
||||||
|
fileModel.setShortcutCategory(GXTCategorySmartFolder.SMF_GCUBE_ITEMS);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
fileModel.setFolderItemType(GXTFolderItemTypeEnum.UNKNOWN_TYPE);
|
||||||
|
fileModel.setShortcutCategory(GXTCategorySmartFolder.SMF_UNKNOWN);
|
||||||
|
fileModel.setType(GXTFolderItemTypeEnum.UNKNOWN_TYPE.toString());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return fileModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,274 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package org.gcube.portlets.user.workspace.server.tostoragehub;
|
||||||
|
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
import org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceItem;
|
||||||
|
import org.gcube.common.storagehubwrapper.shared.tohl.exceptions.InternalErrorException;
|
||||||
|
import org.gcube.common.storagehubwrapper.shared.tohl.impl.WorkspaceFileVersion;
|
||||||
|
import org.gcube.common.storagehubwrapper.shared.tohl.items.PropertyMap;
|
||||||
|
import org.gcube.portal.wssynclibrary.shared.thredds.Sync_Status;
|
||||||
|
import org.gcube.portal.wssynclibrary.thredds.WorkspaceThreddsSynchronize;
|
||||||
|
import org.gcube.portlets.user.workspace.client.model.FileGridModel;
|
||||||
|
import org.gcube.portlets.user.workspace.client.model.FileModel;
|
||||||
|
import org.gcube.portlets.user.workspace.client.model.FileTrashedModel;
|
||||||
|
import org.gcube.portlets.user.workspace.client.model.FileVersionModel;
|
||||||
|
import org.gcube.portlets.user.workspace.client.model.FolderModel;
|
||||||
|
import org.gcube.portlets.user.workspace.client.model.InfoContactModel;
|
||||||
|
import org.gcube.portlets.user.workspace.server.GWTWorkspaceBuilder;
|
||||||
|
import org.gcube.portlets.user.workspace.server.util.UserUtil;
|
||||||
|
import org.gcube.vomanagement.usermanagement.model.GCubeUser;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Class StorageHubToWorkpaceConverter.
|
||||||
|
*
|
||||||
|
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
|
||||||
|
* Sep 20, 2018
|
||||||
|
*/
|
||||||
|
public class StorageHubToWorkpaceConverter implements Serializable{
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private static final long serialVersionUID = 6935303928299846569L;
|
||||||
|
|
||||||
|
protected static Logger logger = Logger.getLogger(StorageHubToWorkpaceConverter.class);
|
||||||
|
private String scope;
|
||||||
|
private GCubeUser loggedUser;
|
||||||
|
private String workspaceRootId;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Instantiates a new storage hub to workpace converter.
|
||||||
|
*/
|
||||||
|
public StorageHubToWorkpaceConverter() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* To version history.
|
||||||
|
*
|
||||||
|
* @param versions the versions
|
||||||
|
* @return the list
|
||||||
|
*/
|
||||||
|
public List<FileVersionModel> toVersionHistory(List<WorkspaceFileVersion> versions){
|
||||||
|
|
||||||
|
if(versions==null || versions.isEmpty()){
|
||||||
|
logger.warn("Version history is null or empty!");
|
||||||
|
return new ArrayList<FileVersionModel>();
|
||||||
|
}
|
||||||
|
|
||||||
|
List<FileVersionModel> listVersions = new ArrayList<FileVersionModel>(versions.size());
|
||||||
|
for (WorkspaceFileVersion wsVersion : versions) {
|
||||||
|
String user = UserUtil.getUserFullName(wsVersion.getOwner());
|
||||||
|
FileVersionModel file = new FileVersionModel(wsVersion.getId(), wsVersion.getName(), wsVersion.getRemotePath(), user, GWTWorkspaceBuilder.toDate(wsVersion.getCreated()), wsVersion.isCurrentVersion());
|
||||||
|
listVersions.add(file);
|
||||||
|
}
|
||||||
|
return listVersions;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Instantiates a new storage hub to workpace converter.
|
||||||
|
*
|
||||||
|
* @param scope the scope
|
||||||
|
* @param loggedUser the logged user
|
||||||
|
*/
|
||||||
|
public StorageHubToWorkpaceConverter(String scope, GCubeUser loggedUser) {
|
||||||
|
this.scope = scope;
|
||||||
|
this.loggedUser = loggedUser;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* To root folder.
|
||||||
|
*
|
||||||
|
* @param folder the folder
|
||||||
|
* @return the folder model
|
||||||
|
* @throws InternalErrorException the internal error exception
|
||||||
|
*/
|
||||||
|
public FolderModel toRootFolder(org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceFolder folder) throws InternalErrorException{
|
||||||
|
|
||||||
|
return ObjectStorageHubToWorkpaceMapper.toRootFolder(folder);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* To tree file model item.
|
||||||
|
*
|
||||||
|
* @param wrappedItem the wrapped item
|
||||||
|
* @param parentFolderModel the parent folder model
|
||||||
|
* @param isParentShared the is parent shared
|
||||||
|
* @return the file model
|
||||||
|
* @throws InternalErrorException the internal error exception
|
||||||
|
*/
|
||||||
|
public FileModel toTreeFileModel(org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceItem wrappedItem, FileModel parentFolderModel, Boolean isParentShared) throws InternalErrorException{
|
||||||
|
|
||||||
|
FileModel fileModel = ObjectStorageHubToWorkpaceMapper.toTreeFileModelItem(wrappedItem, parentFolderModel, isParentShared);
|
||||||
|
return setSynchedThreddsStateFor(fileModel, wrappedItem);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* To grid file model.
|
||||||
|
*
|
||||||
|
* @param wrappedItem the wrapped item
|
||||||
|
* @param parentFolderModel the parent folder model
|
||||||
|
* @return the file grid model
|
||||||
|
* @throws InternalErrorException the internal error exception
|
||||||
|
*/
|
||||||
|
public FileGridModel toGridFileModel(org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceItem wrappedItem, FileModel parentFolderModel) throws InternalErrorException{
|
||||||
|
|
||||||
|
FileGridModel fileGridModel = ObjectStorageHubToWorkpaceMapper.toGridFileModelItem(wrappedItem, parentFolderModel, loggedUser);
|
||||||
|
return (FileGridModel) setSynchedThreddsStateFor(fileGridModel, wrappedItem);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the synched thredds state for.
|
||||||
|
*
|
||||||
|
* @param fileModel the file model
|
||||||
|
* @param wrappedItem
|
||||||
|
* @return the file model
|
||||||
|
*/
|
||||||
|
protected FileModel setSynchedThreddsStateFor(FileModel fileModel, WorkspaceItem wrappedItem) {
|
||||||
|
|
||||||
|
Sync_Status status = null;
|
||||||
|
|
||||||
|
try {
|
||||||
|
if(wrappedItem.getPropertyMap()!=null) {
|
||||||
|
String wsSyncStatus = null;
|
||||||
|
try{
|
||||||
|
|
||||||
|
PropertyMap map = wrappedItem.getPropertyMap();
|
||||||
|
logger.debug("Property Map for folder: "+fileModel.getName()+" has value: "+map.getValues());
|
||||||
|
wsSyncStatus = (String) map.getValues().get(WorkspaceThreddsSynchronize.WS_SYNCH_SYNCH_STATUS);
|
||||||
|
logger.debug("Item id: "+wrappedItem.getId()+" read from Shub has current: "+WorkspaceThreddsSynchronize.WS_SYNCH_SYNCH_STATUS +" value at: "+wsSyncStatus);
|
||||||
|
if(wsSyncStatus!=null)
|
||||||
|
status = Sync_Status.valueOf(wsSyncStatus);
|
||||||
|
}catch (Exception e) {
|
||||||
|
logger.warn(wsSyncStatus + " is not value of "+Sync_Status.values()+", returning null");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.warn("It is not possible to get synched status for item: "+fileModel.getIdentifier());
|
||||||
|
}
|
||||||
|
|
||||||
|
fileModel.setSyncThreddsStatus(status);
|
||||||
|
return fileModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* To file trashed model.
|
||||||
|
*
|
||||||
|
* @param trashItem the trash item
|
||||||
|
* @return the file trashed model
|
||||||
|
*/
|
||||||
|
public FileTrashedModel toFileTrashedModel(org.gcube.common.storagehubwrapper.shared.tohl.TrashedItem trashItem) {
|
||||||
|
|
||||||
|
FileTrashedModel fileTrashModel = new FileTrashedModel();
|
||||||
|
try {
|
||||||
|
fileTrashModel.setName(trashItem.getTitle()); //ADDING THE TITLE INSTEAD OF NAME
|
||||||
|
|
||||||
|
fileTrashModel.setIdentifier(trashItem.getId());
|
||||||
|
|
||||||
|
//SETTING PARENT
|
||||||
|
FileModel oldParent = new FileModel(trashItem.getOriginalParentId(), "", true);
|
||||||
|
|
||||||
|
fileTrashModel.setOrginalPath(trashItem.getDeletedFrom());
|
||||||
|
fileTrashModel.setParentFileModel(oldParent);
|
||||||
|
//
|
||||||
|
// //SETTING DELETED BY
|
||||||
|
InfoContactModel deleteUser = buildGxtInfoContactFromPortalLogin(trashItem.getDeletedBy());
|
||||||
|
fileTrashModel.setDeleteUser(deleteUser);
|
||||||
|
|
||||||
|
//SETTING MIME TYPE
|
||||||
|
|
||||||
|
// String mimeType = "";
|
||||||
|
// if(trashItem instanceof FileItem){
|
||||||
|
// FileItem fileItem = (FileItem) trashItem;
|
||||||
|
// mimeType = fileItem.getMimeType();
|
||||||
|
// }
|
||||||
|
|
||||||
|
String mimeType = trashItem.getMimeType()!=null?trashItem.getMimeType():"";
|
||||||
|
fileTrashModel.setType(mimeType);
|
||||||
|
|
||||||
|
//SETTING IS DIRECTORY
|
||||||
|
fileTrashModel.setIsDirectory(trashItem.isFolder());
|
||||||
|
|
||||||
|
//SETTING DELETE DATE
|
||||||
|
fileTrashModel.setDeleteDate(GWTWorkspaceBuilder.toDate(trashItem.getDeletedTime()));
|
||||||
|
|
||||||
|
fileTrashModel.setShared(trashItem.isShared());
|
||||||
|
|
||||||
|
logger.debug("Converting return trash item: "+fileTrashModel.getName() +" id: "+fileTrashModel.getIdentifier());
|
||||||
|
|
||||||
|
logger.trace("Returning trash item: "+fileTrashModel);
|
||||||
|
|
||||||
|
}catch (Exception e) {
|
||||||
|
|
||||||
|
logger.debug("Error into toFileTrashedModel for item: "+fileTrashModel.getName() +" id: "+fileTrashModel.getIdentifier());
|
||||||
|
return null;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return fileTrashModel;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Builds the gxt info contact from portal login.
|
||||||
|
*
|
||||||
|
* @param portalLogin the portal login
|
||||||
|
* @return the info contact model
|
||||||
|
*/
|
||||||
|
protected InfoContactModel buildGxtInfoContactFromPortalLogin(String portalLogin){
|
||||||
|
|
||||||
|
if(portalLogin==null){
|
||||||
|
logger.warn("portal login is null, return empty");
|
||||||
|
portalLogin = "";
|
||||||
|
}
|
||||||
|
|
||||||
|
return new InfoContactModel(portalLogin, portalLogin, UserUtil.getUserFullName(portalLogin), false);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the workspace root id.
|
||||||
|
*
|
||||||
|
* @return the workspaceRootId
|
||||||
|
*/
|
||||||
|
public String getWorkspaceRootId() {
|
||||||
|
|
||||||
|
return workspaceRootId;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the workspace root id.
|
||||||
|
*
|
||||||
|
* @param workspaceRootId the workspaceRootId to set
|
||||||
|
*/
|
||||||
|
public void setWorkspaceRootId(String workspaceRootId) {
|
||||||
|
|
||||||
|
this.workspaceRootId = workspaceRootId;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,158 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.gcube.portlets.user.workspace.server.util;
|
||||||
|
|
||||||
|
import java.awt.Color;
|
||||||
|
import java.awt.Graphics2D;
|
||||||
|
import java.awt.Image;
|
||||||
|
import java.awt.RenderingHints;
|
||||||
|
import java.awt.image.BufferedImage;
|
||||||
|
import java.io.ByteArrayInputStream;
|
||||||
|
import java.io.ByteArrayOutputStream;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileOutputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
|
||||||
|
import javax.imageio.ImageIO;
|
||||||
|
|
||||||
|
import org.apache.commons.io.FilenameUtils;
|
||||||
|
import org.apache.commons.io.IOUtils;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Class ThumbnailGenerator.
|
||||||
|
*
|
||||||
|
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
|
||||||
|
* Oct 18, 2018
|
||||||
|
*/
|
||||||
|
public class ThumbnailGenerator {
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates the thumbnail.
|
||||||
|
*
|
||||||
|
* @param originalFile the original file
|
||||||
|
* @param thumbWidth the thumb width
|
||||||
|
* @param thumbHeight the thumb height
|
||||||
|
* @return the input stream
|
||||||
|
* @throws Exception the exception
|
||||||
|
*/
|
||||||
|
public static InputStream generateThumbnail(
|
||||||
|
String originalFile, int thumbWidth,
|
||||||
|
int thumbHeight)
|
||||||
|
throws Exception {
|
||||||
|
|
||||||
|
String baseName = FilenameUtils.getBaseName(originalFile);
|
||||||
|
Image image = ImageIO.read(new File(originalFile));
|
||||||
|
return createThumb(image, baseName, thumbWidth, thumbHeight);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generate thumbnail.
|
||||||
|
*
|
||||||
|
* @param originalFile the original file
|
||||||
|
* @param fileName the file name
|
||||||
|
* @param thumbWidth the thumb width
|
||||||
|
* @param thumbHeight the thumb height
|
||||||
|
* @return the input stream
|
||||||
|
* @throws Exception the exception
|
||||||
|
*/
|
||||||
|
public static InputStream generateThumbnail(
|
||||||
|
InputStream originalFile, String fileName, int thumbWidth,
|
||||||
|
int thumbHeight)
|
||||||
|
throws Exception {
|
||||||
|
Image image = ImageIO.read(originalFile);
|
||||||
|
return createThumb(image, fileName, thumbWidth, thumbHeight);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates the thumb.
|
||||||
|
*
|
||||||
|
* @param image the image
|
||||||
|
* @param imageName the image name
|
||||||
|
* @param thumbWidth the thumb width
|
||||||
|
* @param thumbHeight the thumb height
|
||||||
|
* @return the input stream
|
||||||
|
* @throws IOException
|
||||||
|
*/
|
||||||
|
public static InputStream createThumb(Image image, String imageName, int thumbWidth,
|
||||||
|
int thumbHeight) throws IOException{
|
||||||
|
double thumbRatio = (double) thumbWidth / (double) thumbHeight;
|
||||||
|
int imageWidth = image.getWidth(null);
|
||||||
|
int imageHeight = image.getHeight(null);
|
||||||
|
double imageRatio = (double) imageWidth / (double) imageHeight;
|
||||||
|
if (thumbRatio < imageRatio) {
|
||||||
|
thumbHeight = (int) (thumbWidth / imageRatio);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
thumbWidth = (int) (thumbHeight * imageRatio);
|
||||||
|
}
|
||||||
|
if (imageWidth < thumbWidth && imageHeight < thumbHeight) {
|
||||||
|
thumbWidth = imageWidth;
|
||||||
|
thumbHeight = imageHeight;
|
||||||
|
}
|
||||||
|
else if (imageWidth < thumbWidth)
|
||||||
|
thumbWidth = imageWidth;
|
||||||
|
else if (imageHeight < thumbHeight)
|
||||||
|
thumbHeight = imageHeight;
|
||||||
|
|
||||||
|
BufferedImage thumbImage = new BufferedImage(thumbWidth, thumbHeight, BufferedImage.TYPE_INT_RGB);
|
||||||
|
|
||||||
|
Graphics2D graphics2D = thumbImage.createGraphics();
|
||||||
|
graphics2D.setBackground(Color.WHITE);
|
||||||
|
graphics2D.setPaint(Color.WHITE);
|
||||||
|
graphics2D.fillRect(0, 0, thumbWidth, thumbHeight);
|
||||||
|
graphics2D.setRenderingHint(
|
||||||
|
RenderingHints.KEY_INTERPOLATION,
|
||||||
|
RenderingHints.VALUE_INTERPOLATION_BILINEAR);
|
||||||
|
graphics2D.drawImage(image, 0, 0, thumbWidth, thumbHeight, null);
|
||||||
|
|
||||||
|
String ext = FilenameUtils.getExtension(imageName);
|
||||||
|
// String baseName = FilenameUtils.getBaseName(originalFile);
|
||||||
|
|
||||||
|
ByteArrayOutputStream os = new ByteArrayOutputStream();
|
||||||
|
ImageIO.write(thumbImage, ext, os);
|
||||||
|
return new ByteArrayInputStream(os.toByteArray());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Stream2file.
|
||||||
|
*
|
||||||
|
* @param in the in
|
||||||
|
* @param filename the filename
|
||||||
|
* @param extension the extension
|
||||||
|
* @return the file
|
||||||
|
* @throws IOException Signals that an I/O exception has occurred.
|
||||||
|
*/
|
||||||
|
public static File stream2file (InputStream in, String filename, String extension) throws IOException {
|
||||||
|
|
||||||
|
extension = extension.startsWith(".")?extension:"."+extension;
|
||||||
|
final File tempFile = File.createTempFile(filename, extension);
|
||||||
|
//tempFile.deleteOnExit();
|
||||||
|
try (FileOutputStream out = new FileOutputStream(tempFile)) {
|
||||||
|
IOUtils.copy(in, out);
|
||||||
|
}
|
||||||
|
return tempFile;
|
||||||
|
}
|
||||||
|
|
||||||
|
// /**
|
||||||
|
// * The main method.
|
||||||
|
// *
|
||||||
|
// * @param args the arguments
|
||||||
|
// * @throws Exception the exception
|
||||||
|
// */
|
||||||
|
// public static void main(String[] args) throws Exception {
|
||||||
|
//
|
||||||
|
// String originalFile = "/home/francesco-mangiacrapa/Pictures/Screenshot from 2016-04-11 10:20:43.png";
|
||||||
|
// int thumbWidth = 200;
|
||||||
|
// int thumbHeight = 200;
|
||||||
|
//
|
||||||
|
// createThumbnail(originalFile, thumbWidth, thumbHeight);
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
}
|
|
@ -21,11 +21,14 @@ import org.gcube.common.storagehubwrapper.server.StorageHubWrapper;
|
||||||
import org.gcube.common.storagehubwrapper.shared.tohl.exceptions.InternalErrorException;
|
import org.gcube.common.storagehubwrapper.shared.tohl.exceptions.InternalErrorException;
|
||||||
import org.gcube.common.storagehubwrapper.shared.tohl.exceptions.WorkspaceFolderNotFoundException;
|
import org.gcube.common.storagehubwrapper.shared.tohl.exceptions.WorkspaceFolderNotFoundException;
|
||||||
import org.gcube.portlets.user.urlshortener.UrlShortener;
|
import org.gcube.portlets.user.urlshortener.UrlShortener;
|
||||||
|
import org.gcube.portlets.user.workspace.client.model.FileModel;
|
||||||
import org.gcube.portlets.user.workspace.client.model.InfoContactModel;
|
import org.gcube.portlets.user.workspace.client.model.InfoContactModel;
|
||||||
import org.gcube.portlets.user.workspace.server.GWTWorkspaceBuilder;
|
import org.gcube.portlets.user.workspace.server.GWTWorkspaceBuilder;
|
||||||
import org.gcube.portlets.user.workspace.server.notifications.NotificationsProducer;
|
import org.gcube.portlets.user.workspace.server.notifications.NotificationsProducer;
|
||||||
|
import org.gcube.portlets.user.workspace.server.notifications.tostoragehub.NotificationsProducerToStorageHub;
|
||||||
import org.gcube.portlets.user.workspace.server.resolver.UriResolverReaderParameterForResolverIndex;
|
import org.gcube.portlets.user.workspace.server.resolver.UriResolverReaderParameterForResolverIndex;
|
||||||
import org.gcube.portlets.user.workspace.server.resolver.UriResolverReaderParameterForResolverIndex.RESOLVER_TYPE;
|
import org.gcube.portlets.user.workspace.server.resolver.UriResolverReaderParameterForResolverIndex.RESOLVER_TYPE;
|
||||||
|
import org.gcube.portlets.user.workspace.server.tostoragehub.StorageHubToWorkpaceConverter;
|
||||||
import org.gcube.portlets.user.workspace.server.util.resource.PropertySpecialFolderReader;
|
import org.gcube.portlets.user.workspace.server.util.resource.PropertySpecialFolderReader;
|
||||||
import org.gcube.portlets.user.workspace.server.util.scope.ScopeUtilFilter;
|
import org.gcube.portlets.user.workspace.server.util.scope.ScopeUtilFilter;
|
||||||
import org.gcube.vomanagement.usermanagement.model.GCubeUser;
|
import org.gcube.vomanagement.usermanagement.model.GCubeUser;
|
||||||
|
@ -54,8 +57,11 @@ public class WsUtil {
|
||||||
public static final String WORKSPACEBUILDER_ATTRIBUTE = "WORKSPACEBUILDER";
|
public static final String WORKSPACEBUILDER_ATTRIBUTE = "WORKSPACEBUILDER";
|
||||||
public static final String NOTIFICATION_MANAGER = "NOTIFICATION_MANAGER";
|
public static final String NOTIFICATION_MANAGER = "NOTIFICATION_MANAGER";
|
||||||
public static final String NOTIFICATION_PRODUCER = "NOTIFICATION_PRODUCER";
|
public static final String NOTIFICATION_PRODUCER = "NOTIFICATION_PRODUCER";
|
||||||
|
//public static final String NOTIFICATION_MANAGER_TO_STORAGEHUB = "NOTIFICATION_MANAGER_TO_STORAGEHUB";
|
||||||
|
public static final String NOTIFICATION_PRODUCER_TO_STORAGEHUB = "NOTIFICATION_PRODUCER_TO_STORAGEHUB";
|
||||||
public static final String WS_RUN_IN_TEST_MODE = "WS_RUN_IN_TEST_MODE";
|
public static final String WS_RUN_IN_TEST_MODE = "WS_RUN_IN_TEST_MODE";
|
||||||
public static final String WORKSPACE_SCOPE_UTIL = "WORKSPACE_SCOPE_UTIL";
|
public static final String WORKSPACE_SCOPE_UTIL = "WORKSPACE_SCOPE_UTIL";
|
||||||
|
public static final String WORKSPACE_STORAGE_HUB_CONVERTER = "WORKSPACE_STORAGE_HUB_CONVERTER";
|
||||||
public static final String URL_SHORTENER_SERVICE = "URL_SHORTENER_SERVICE";
|
public static final String URL_SHORTENER_SERVICE = "URL_SHORTENER_SERVICE";
|
||||||
public static final String URI_RESOLVER_SERVICE = "URI_RESOLVER_SERVICE";
|
public static final String URI_RESOLVER_SERVICE = "URI_RESOLVER_SERVICE";
|
||||||
public static final String PROPERTY_SPECIAL_FOLDER = "PROPERTY_SPECIAL_FOLDER";
|
public static final String PROPERTY_SPECIAL_FOLDER = "PROPERTY_SPECIAL_FOLDER";
|
||||||
|
@ -260,6 +266,7 @@ public class WsUtil {
|
||||||
return notifMng;
|
return notifMng;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the notification producer.
|
* Gets the notification producer.
|
||||||
*
|
*
|
||||||
|
@ -442,9 +449,9 @@ public class WsUtil {
|
||||||
else
|
else
|
||||||
scope = pContext.getCurrentScope(request);
|
scope = pContext.getCurrentScope(request);
|
||||||
|
|
||||||
logger.debug("Instancing "+StorageHubWrapper.class.getSimpleName()+" for user: "+user.getUsername() +", by using the scope: "+scope);
|
logger.debug("Getting "+StorageHubWrapper.class.getSimpleName()+" for user: "+user.getUsername() +" by using the scope: "+scope);
|
||||||
String token = pContext.getCurrentUserToken(scope, user.getUsername());
|
String token = pContext.getCurrentUserToken(scope, user.getUsername());
|
||||||
return new StorageHubWrapper(scope, token);
|
return new StorageHubWrapper(scope, token, false, false, true);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.error("Error during getting storageHub wrapper", e);
|
logger.error("Error during getting storageHub wrapper", e);
|
||||||
throw new Exception("Error on gettig the StorageHub wrapper for userId: "+user);
|
throw new Exception("Error on gettig the StorageHub wrapper for userId: "+user);
|
||||||
|
@ -452,4 +459,115 @@ public class WsUtil {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the storage hub to workpace converter.
|
||||||
|
*
|
||||||
|
* @param request the request
|
||||||
|
* @param scopeGroupId the scope group id
|
||||||
|
* @param user the user
|
||||||
|
* @return the storage hub to workpace converter
|
||||||
|
* @throws Exception the exception
|
||||||
|
*/
|
||||||
|
public static StorageHubToWorkpaceConverter getStorageHubToWorkpaceConverter(final HttpServletRequest request, String scopeGroupId, GCubeUser user) throws Exception {
|
||||||
|
|
||||||
|
if(user==null || user.getUsername().isEmpty())
|
||||||
|
throw new Exception("Session expired");
|
||||||
|
|
||||||
|
try {
|
||||||
|
HttpSession session = request.getSession();
|
||||||
|
StorageHubToWorkpaceConverter converter = (StorageHubToWorkpaceConverter) session.getAttribute(WORKSPACE_STORAGE_HUB_CONVERTER);
|
||||||
|
|
||||||
|
String scope;
|
||||||
|
PortalContext pContext = PortalContext.getConfiguration();
|
||||||
|
if(WsUtil.isWithinPortal() && scopeGroupId!=null){
|
||||||
|
scope = pContext.getCurrentScope(scopeGroupId);
|
||||||
|
logger.debug(scope+" has retrieved by using the scopeGroupId="+scopeGroupId);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
scope = pContext.getCurrentScope(request);
|
||||||
|
|
||||||
|
if(converter==null){
|
||||||
|
converter = new StorageHubToWorkpaceConverter(scope, user);
|
||||||
|
session.setAttribute(WORKSPACE_STORAGE_HUB_CONVERTER, converter);
|
||||||
|
}
|
||||||
|
|
||||||
|
return converter;
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error("Error during getting storageHub conveter", e);
|
||||||
|
throw new Exception("Error on gettig the StorageHub conveter for user: "+user);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if is root folder.
|
||||||
|
*
|
||||||
|
* @param folder the folder
|
||||||
|
* @param converter the converter
|
||||||
|
* @return true, if is root folder
|
||||||
|
*/
|
||||||
|
public static boolean isRootFolder(FileModel folder, StorageHubToWorkpaceConverter converter){
|
||||||
|
|
||||||
|
if(folder==null)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if(folder.getIdentifier().compareTo(converter.getWorkspaceRootId())==0)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
return false;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// /**
|
||||||
|
// * Gets the notification manager to storage hub.
|
||||||
|
// *
|
||||||
|
// * @param httpServletRequest the http servlet request
|
||||||
|
// * @return the notification manager to storage hub
|
||||||
|
// */
|
||||||
|
// public static NotificationsManager getNotificationManagerToStorageHub(HttpServletRequest httpServletRequest)
|
||||||
|
// {
|
||||||
|
// PortalContextInfo info = getPortalContext(httpServletRequest);
|
||||||
|
// HttpSession session = httpServletRequest.getSession();
|
||||||
|
// NotificationsManager notifMng = (NotificationsManager) session.getAttribute(NOTIFICATION_MANAGER_TO_STORAGEHUB);
|
||||||
|
//
|
||||||
|
// if (notifMng == null) {
|
||||||
|
// try{
|
||||||
|
// logger.trace("Create new NotificationsManager for user: "+info.getUsername());
|
||||||
|
// logger.trace("New ApplicationNotificationsManager with portlet class name: "+NOTIFICATION_PORTLET_CLASS_ID);
|
||||||
|
// SocialNetworkingSite site = new SocialNetworkingSite(httpServletRequest);
|
||||||
|
// SocialNetworkingUser curser = new SocialNetworkingUser(info.getUsername(), info.getUserEmail(), info.getUserFullName(), info.getUserAvatarID());
|
||||||
|
// notifMng = new ApplicationNotificationsManager(site, info.getCurrentScope(), curser, NOTIFICATION_PORTLET_CLASS_ID);
|
||||||
|
// session.setAttribute(NOTIFICATION_MANAGER_TO_STORAGEHUB, notifMng);
|
||||||
|
// }catch (Exception e) {
|
||||||
|
// logger.error("An error occurred instancing ApplicationNotificationsManager for user: "+info.getUsername(),e);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// return notifMng;
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the notification producer to storage hub.
|
||||||
|
*
|
||||||
|
* @param httpServletRequest the http servlet request
|
||||||
|
* @return the notification producer to storage hub
|
||||||
|
*/
|
||||||
|
public static NotificationsProducerToStorageHub getNotificationProducerToStorageHub(HttpServletRequest httpServletRequest)
|
||||||
|
{
|
||||||
|
PortalContextInfo info = getPortalContext(httpServletRequest);
|
||||||
|
HttpSession session = httpServletRequest.getSession();
|
||||||
|
NotificationsProducerToStorageHub notifProducer = (NotificationsProducerToStorageHub) session.getAttribute(NOTIFICATION_PRODUCER_TO_STORAGEHUB);
|
||||||
|
|
||||||
|
if (notifProducer == null) {
|
||||||
|
logger.trace("Create new Notification Producer for user: "+info.getUsername());
|
||||||
|
notifProducer = new NotificationsProducerToStorageHub(httpServletRequest);
|
||||||
|
session.setAttribute(NOTIFICATION_PRODUCER_TO_STORAGEHUB, notifProducer);
|
||||||
|
}
|
||||||
|
return notifProducer;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,144 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package org.gcube.portlets.user.workspace.shared;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
import com.google.gwt.user.client.rpc.IsSerializable;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Class WorkspaceOperationResult.
|
||||||
|
*
|
||||||
|
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
|
||||||
|
* Oct 8, 2018
|
||||||
|
*/
|
||||||
|
public class WorkspaceOperationResult implements Serializable, IsSerializable{
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private static final long serialVersionUID = 4252367709147458665L;
|
||||||
|
String operationName;
|
||||||
|
boolean operationCompleted;
|
||||||
|
String error;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Instantiates a new workspace operation result.
|
||||||
|
*/
|
||||||
|
public WorkspaceOperationResult() {
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Instantiates a new workspace operation result.
|
||||||
|
*
|
||||||
|
* @param operationName the operation name
|
||||||
|
* @param operationCompleted the operation completed
|
||||||
|
* @param error the error
|
||||||
|
*/
|
||||||
|
public WorkspaceOperationResult(
|
||||||
|
String operationName, boolean operationCompleted, String error) {
|
||||||
|
|
||||||
|
super();
|
||||||
|
this.operationName = operationName;
|
||||||
|
this.operationCompleted = operationCompleted;
|
||||||
|
this.error = error;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the operation name.
|
||||||
|
*
|
||||||
|
* @return the operationName
|
||||||
|
*/
|
||||||
|
public String getOperationName() {
|
||||||
|
|
||||||
|
return operationName;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if is operation completed.
|
||||||
|
*
|
||||||
|
* @return the operationCompleted
|
||||||
|
*/
|
||||||
|
public boolean isOperationCompleted() {
|
||||||
|
|
||||||
|
return operationCompleted;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the error.
|
||||||
|
*
|
||||||
|
* @return the error
|
||||||
|
*/
|
||||||
|
public String getError() {
|
||||||
|
|
||||||
|
return error;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the operation name.
|
||||||
|
*
|
||||||
|
* @param operationName the operationName to set
|
||||||
|
*/
|
||||||
|
public void setOperationName(String operationName) {
|
||||||
|
|
||||||
|
this.operationName = operationName;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the operation completed.
|
||||||
|
*
|
||||||
|
* @param operationCompleted the operationCompleted to set
|
||||||
|
*/
|
||||||
|
public void setOperationCompleted(boolean operationCompleted) {
|
||||||
|
|
||||||
|
this.operationCompleted = operationCompleted;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the error.
|
||||||
|
*
|
||||||
|
* @param error the error to set
|
||||||
|
*/
|
||||||
|
public void setError(String error) {
|
||||||
|
|
||||||
|
this.error = error;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see java.lang.Object#toString()
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
|
||||||
|
StringBuilder builder = new StringBuilder();
|
||||||
|
builder.append("WorkpaceOperationResult [operationName=");
|
||||||
|
builder.append(operationName);
|
||||||
|
builder.append(", operationCompleted=");
|
||||||
|
builder.append(operationCompleted);
|
||||||
|
builder.append(", error=");
|
||||||
|
builder.append(error);
|
||||||
|
builder.append("]");
|
||||||
|
return builder.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -19,7 +19,7 @@ public enum WorkspaceVersioningOperation {
|
||||||
|
|
||||||
//CALLING OPERATION SERVER
|
//CALLING OPERATION SERVER
|
||||||
REFRESH("Refresh", "Refresh history of versioning"),
|
REFRESH("Refresh", "Refresh history of versioning"),
|
||||||
RESTORE("Restore", "Restore the file to the selected version"),
|
//RESTORE("Restore", "Restore the file to the selected version"),
|
||||||
DOWNLOAD("Download", "Download the version of the selected file"),
|
DOWNLOAD("Download", "Download the version of the selected file"),
|
||||||
DELETE_PERMANENTLY("Delete Permanently", "Delete Permanently the version for the selected file"),
|
DELETE_PERMANENTLY("Delete Permanently", "Delete Permanently the version for the selected file"),
|
||||||
DELETE_ALL_OLDER_VERSIONS("Delete all versions permanently", "Delete definitively all versions of the file");
|
DELETE_ALL_OLDER_VERSIONS("Delete all versions permanently", "Delete definitively all versions of the file");
|
||||||
|
|
|
@ -0,0 +1,98 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.gcube.portlets.user.workspace;
|
||||||
|
|
||||||
|
import java.awt.Color;
|
||||||
|
import java.awt.Graphics2D;
|
||||||
|
import java.awt.Image;
|
||||||
|
import java.awt.RenderingHints;
|
||||||
|
import java.awt.image.BufferedImage;
|
||||||
|
import java.io.ByteArrayInputStream;
|
||||||
|
import java.io.ByteArrayOutputStream;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileOutputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
|
||||||
|
import javax.imageio.ImageIO;
|
||||||
|
|
||||||
|
import org.apache.commons.io.FilenameUtils;
|
||||||
|
import org.apache.commons.io.IOUtils;
|
||||||
|
|
||||||
|
public class ThumbnailGenerator {
|
||||||
|
|
||||||
|
public ThumbnailGenerator() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void transform(
|
||||||
|
String originalFile, int thumbWidth,
|
||||||
|
int thumbHeight)
|
||||||
|
throws Exception {
|
||||||
|
|
||||||
|
Image image = javax.imageio.ImageIO.read(new File(originalFile));
|
||||||
|
double thumbRatio = (double) thumbWidth / (double) thumbHeight;
|
||||||
|
int imageWidth = image.getWidth(null);
|
||||||
|
int imageHeight = image.getHeight(null);
|
||||||
|
double imageRatio = (double) imageWidth / (double) imageHeight;
|
||||||
|
if (thumbRatio < imageRatio) {
|
||||||
|
thumbHeight = (int) (thumbWidth / imageRatio);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
thumbWidth = (int) (thumbHeight * imageRatio);
|
||||||
|
}
|
||||||
|
if (imageWidth < thumbWidth && imageHeight < thumbHeight) {
|
||||||
|
thumbWidth = imageWidth;
|
||||||
|
thumbHeight = imageHeight;
|
||||||
|
}
|
||||||
|
else if (imageWidth < thumbWidth)
|
||||||
|
thumbWidth = imageWidth;
|
||||||
|
else if (imageHeight < thumbHeight)
|
||||||
|
thumbHeight = imageHeight;
|
||||||
|
|
||||||
|
BufferedImage thumbImage = new BufferedImage(thumbWidth, thumbHeight, BufferedImage.TYPE_INT_RGB);
|
||||||
|
|
||||||
|
Graphics2D graphics2D = thumbImage.createGraphics();
|
||||||
|
graphics2D.setBackground(Color.WHITE);
|
||||||
|
graphics2D.setPaint(Color.WHITE);
|
||||||
|
graphics2D.fillRect(0, 0, thumbWidth, thumbHeight);
|
||||||
|
graphics2D.setRenderingHint(
|
||||||
|
RenderingHints.KEY_INTERPOLATION,
|
||||||
|
RenderingHints.VALUE_INTERPOLATION_BILINEAR);
|
||||||
|
graphics2D.drawImage(image, 0, 0, thumbWidth, thumbHeight, null);
|
||||||
|
|
||||||
|
String ext = FilenameUtils.getExtension(originalFile);
|
||||||
|
String baseName = FilenameUtils.getBaseName(originalFile);
|
||||||
|
|
||||||
|
ByteArrayOutputStream os = new ByteArrayOutputStream();
|
||||||
|
ImageIO.write(thumbImage, ext, os);
|
||||||
|
InputStream is = new ByteArrayInputStream(os.toByteArray());
|
||||||
|
|
||||||
|
File tempFile = stream2file(is, "thunmb-"+baseName, ext);
|
||||||
|
System.out.println(tempFile.getAbsolutePath());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static File stream2file (InputStream in, String filename, String extension) throws IOException {
|
||||||
|
|
||||||
|
extension = extension.startsWith(".")?extension:"."+extension;
|
||||||
|
final File tempFile = File.createTempFile(filename, extension);
|
||||||
|
//tempFile.deleteOnExit();
|
||||||
|
try (FileOutputStream out = new FileOutputStream(tempFile)) {
|
||||||
|
IOUtils.copy(in, out);
|
||||||
|
}
|
||||||
|
return tempFile;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void main(String[] args) throws Exception {
|
||||||
|
|
||||||
|
String originalFile = "/home/francesco-mangiacrapa/Pictures/Screenshot from 2016-04-11 10:20:43.png";
|
||||||
|
int thumbWidth = 200;
|
||||||
|
int thumbHeight = 200;
|
||||||
|
|
||||||
|
transform(originalFile, thumbWidth, thumbHeight);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue