Update to handler data publishing
git-svn-id: http://svn.d4science-ii.research-infrastructures.eu/gcube/trunk/portlets/user/workspace-tree-widget@129475 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
6a022fa18c
commit
99166e43d8
|
@ -4,7 +4,6 @@ import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.gcube.portlets.user.workspace.client.ConstantsExplorer.WS_UPLOAD_TYPE;
|
import org.gcube.portlets.user.workspace.client.ConstantsExplorer.WS_UPLOAD_TYPE;
|
||||||
import org.gcube.portlets.user.workspace.client.ConstantsExplorer.WsPortletInitOperation;
|
import org.gcube.portlets.user.workspace.client.ConstantsExplorer.WsPortletInitOperation;
|
||||||
import org.gcube.portlets.user.workspace.client.event.AccountingHistoryEvent;
|
import org.gcube.portlets.user.workspace.client.event.AccountingHistoryEvent;
|
||||||
|
@ -60,6 +59,8 @@ 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.PasteItemEvent;
|
||||||
import org.gcube.portlets.user.workspace.client.event.PasteItemEventHandler;
|
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.PublishOnDataCatalogueEventHandler;
|
||||||
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.RefreshItemEventHandler;
|
import org.gcube.portlets.user.workspace.client.event.RefreshItemEventHandler;
|
||||||
import org.gcube.portlets.user.workspace.client.event.RenameItemEvent;
|
import org.gcube.portlets.user.workspace.client.event.RenameItemEvent;
|
||||||
|
@ -133,6 +134,7 @@ 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.accounting.GxtAccountingField;
|
import org.gcube.portlets.user.workspace.shared.accounting.GxtAccountingField;
|
||||||
|
import org.gcube.portlets.widgets.ckandatapublisherwidget.client.ui.CreateDatasetForm;
|
||||||
import org.gcube.portlets.widgets.workspacesharingwidget.client.ConstantsSharing.LOAD_CONTACTS_AS;
|
import org.gcube.portlets.widgets.workspacesharingwidget.client.ConstantsSharing.LOAD_CONTACTS_AS;
|
||||||
import org.gcube.portlets.widgets.workspacesharingwidget.client.MultiDragConstants;
|
import org.gcube.portlets.widgets.workspacesharingwidget.client.MultiDragConstants;
|
||||||
import org.gcube.portlets.widgets.workspacesharingwidget.client.MultiDragContactsEditPermissions;
|
import org.gcube.portlets.widgets.workspacesharingwidget.client.MultiDragContactsEditPermissions;
|
||||||
|
@ -150,11 +152,13 @@ import com.extjs.gxt.ui.client.event.MessageBoxEvent;
|
||||||
import com.extjs.gxt.ui.client.widget.Dialog;
|
import com.extjs.gxt.ui.client.widget.Dialog;
|
||||||
import com.extjs.gxt.ui.client.widget.Info;
|
import com.extjs.gxt.ui.client.widget.Info;
|
||||||
import com.extjs.gxt.ui.client.widget.MessageBox;
|
import com.extjs.gxt.ui.client.widget.MessageBox;
|
||||||
|
import com.github.gwtbootstrap.client.ui.Modal;
|
||||||
import com.google.gwt.core.client.GWT;
|
import com.google.gwt.core.client.GWT;
|
||||||
import com.google.gwt.event.shared.EventHandler;
|
import com.google.gwt.event.shared.EventHandler;
|
||||||
import com.google.gwt.event.shared.HandlerManager;
|
import com.google.gwt.event.shared.HandlerManager;
|
||||||
import com.google.gwt.http.client.RequestBuilder;
|
import com.google.gwt.http.client.RequestBuilder;
|
||||||
import com.google.gwt.user.client.Timer;
|
import com.google.gwt.user.client.Timer;
|
||||||
|
import com.google.gwt.user.client.Window;
|
||||||
import com.google.gwt.user.client.rpc.AsyncCallback;
|
import com.google.gwt.user.client.rpc.AsyncCallback;
|
||||||
import com.google.gwt.user.client.ui.HasWidgets;
|
import com.google.gwt.user.client.ui.HasWidgets;
|
||||||
|
|
||||||
|
@ -173,9 +177,10 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
|
||||||
|
|
||||||
|
|
||||||
private boolean selectRootItem;
|
private boolean selectRootItem;
|
||||||
// private FileUploader fileUploader;
|
// private FileUploader fileUploader;
|
||||||
public static String myLogin;
|
public static String myLogin;
|
||||||
public static String myLoginFirstName;
|
public static String myLoginFirstName;
|
||||||
|
public static boolean ckanEditorOrAdmin;
|
||||||
//PRE-LOAD LIST OF USER FORM LIFERAY
|
//PRE-LOAD LIST OF USER FORM LIFERAY
|
||||||
private UserStore userStore = new UserStore();
|
private UserStore userStore = new UserStore();
|
||||||
|
|
||||||
|
@ -225,6 +230,44 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
|
||||||
*/
|
*/
|
||||||
private void bind() {
|
private void bind() {
|
||||||
|
|
||||||
|
eventBus.addHandler(PublishOnDataCatalogueEvent.TYPE, new PublishOnDataCatalogueEventHandler() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onPublish(PublishOnDataCatalogueEvent publishEvent) {
|
||||||
|
|
||||||
|
// get the folder id
|
||||||
|
final String folderId = publishEvent.getFolderId();
|
||||||
|
|
||||||
|
if(folderId != null && !folderId.isEmpty()){
|
||||||
|
|
||||||
|
final Modal modal = new Modal(true, true);
|
||||||
|
// request who's doing the insert
|
||||||
|
rpcWorkspaceService.getUser(new AsyncCallback<String>() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onSuccess(String username) {
|
||||||
|
|
||||||
|
if (username != null) {
|
||||||
|
modal.setTitle("Publish Product");
|
||||||
|
modal.addStyleName("insert-metadata-modal-style");
|
||||||
|
modal.add(new CreateDatasetForm(folderId, username));
|
||||||
|
modal.setCloseVisible(true);
|
||||||
|
modal.show();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
Window.alert("Please, logout and login again then retry.");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onFailure(Throwable caught) {
|
||||||
|
|
||||||
|
Window.alert("Please, logout and login again then retry.");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
eventBus.addHandler(UpdateWorkspaceSizeEvent.TYPE, new UpdateWorkspaceSizeEventHandler() {
|
eventBus.addHandler(UpdateWorkspaceSizeEvent.TYPE, new UpdateWorkspaceSizeEventHandler() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -426,10 +469,10 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
|
||||||
FileModel parent = null;
|
FileModel parent = null;
|
||||||
|
|
||||||
//COMMENTED 26/02/2014
|
//COMMENTED 26/02/2014
|
||||||
// if(parentFileModel==null){ //PARENT IS ROOT
|
// if(parentFileModel==null){ //PARENT IS ROOT
|
||||||
// parent = explorerPanel.getAsycTreePanel().getRootItem();
|
// parent = explorerPanel.getAsycTreePanel().getRootItem();
|
||||||
// sourceFileModel.setParentFileModel(parent);
|
// sourceFileModel.setParentFileModel(parent);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
if(sourceFileModel.isDirectory()){
|
if(sourceFileModel.isDirectory()){
|
||||||
// explorerPanel.getAsycTreePanel().setExpandTreeLevel(sourceFileModel.getIdentifier(), true);
|
// explorerPanel.getAsycTreePanel().setExpandTreeLevel(sourceFileModel.getIdentifier(), true);
|
||||||
|
@ -515,7 +558,7 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
|
||||||
|
|
||||||
GWT.log("share completed throwing refresh folder : "+parentToRefresh.getName() +" get id: "+parentToRefresh.getIdentifier());
|
GWT.log("share completed throwing refresh folder : "+parentToRefresh.getName() +" get id: "+parentToRefresh.getIdentifier());
|
||||||
|
|
||||||
// eventBus.fireEvent(new RefreshFolderEvent(parentToRefresh, true, false, false));
|
// eventBus.fireEvent(new RefreshFolderEvent(parentToRefresh, true, false, false));
|
||||||
|
|
||||||
//TODO UPDATED ID
|
//TODO UPDATED ID
|
||||||
RefreshFolderEvent refEvent = new RefreshFolderEvent(parentToRefresh, true, true, false);
|
RefreshFolderEvent refEvent = new RefreshFolderEvent(parentToRefresh, true, true, false);
|
||||||
|
@ -703,8 +746,8 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
|
||||||
case CUT:
|
case CUT:
|
||||||
|
|
||||||
//TODO remove this comments
|
//TODO remove this comments
|
||||||
// if(pasteItemEvent.getFolderSourceId()==null || pasteItemEvent.getFolderSourceId().isEmpty())
|
// if(pasteItemEvent.getFolderSourceId()==null || pasteItemEvent.getFolderSourceId().isEmpty())
|
||||||
// return;
|
// return;
|
||||||
|
|
||||||
rpcWorkspaceService.moveItems(pasteItemEvent.getIds(), pasteItemEvent.getFolderDestinationId(), new AsyncCallback<Boolean>() {
|
rpcWorkspaceService.moveItems(pasteItemEvent.getIds(), pasteItemEvent.getFolderDestinationId(), new AsyncCallback<Boolean>() {
|
||||||
|
|
||||||
|
@ -717,7 +760,7 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
|
||||||
}
|
}
|
||||||
|
|
||||||
new MessageBoxAlert("Error", caught.getMessage()+"." , null);
|
new MessageBoxAlert("Error", caught.getMessage()+"." , null);
|
||||||
// System.out.println(caught.getMessage());
|
// System.out.println(caught.getMessage());
|
||||||
explorerPanel.getAsycTreePanel().reloadTreeLevelAndExpandFolder(pasteItemEvent.getFolderDestinationId(), false);
|
explorerPanel.getAsycTreePanel().reloadTreeLevelAndExpandFolder(pasteItemEvent.getFolderDestinationId(), false);
|
||||||
explorerPanel.getAsycTreePanel().reloadTreeLevelAndExpandFolder(pasteItemEvent.getFolderSourceId(), true);
|
explorerPanel.getAsycTreePanel().reloadTreeLevelAndExpandFolder(pasteItemEvent.getFolderSourceId(), true);
|
||||||
}
|
}
|
||||||
|
@ -1006,7 +1049,7 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
|
||||||
GWT.log("doCompletedFileUploadEvent..."+parent);
|
GWT.log("doCompletedFileUploadEvent..."+parent);
|
||||||
if(parent!=null && completedFileUploadEvent.getItemIdentifier()!=null){
|
if(parent!=null && completedFileUploadEvent.getItemIdentifier()!=null){
|
||||||
explorerPanel.getAsycTreePanel().reloadTreeLevelAndExpandFolder(completedFileUploadEvent.getParentId(), isLevelExpanded);
|
explorerPanel.getAsycTreePanel().reloadTreeLevelAndExpandFolder(completedFileUploadEvent.getParentId(), isLevelExpanded);
|
||||||
// explorerPanel.getAsycTreePanel().addItemIdAndExpandFolder(parent, completedFileUploadEvent.getItemIdentifier(), isLevelExpanded);
|
// explorerPanel.getAsycTreePanel().addItemIdAndExpandFolder(parent, completedFileUploadEvent.getItemIdentifier(), isLevelExpanded);
|
||||||
}
|
}
|
||||||
doUpdateWorkspaceSize(new UpdateWorkspaceSizeEvent());
|
doUpdateWorkspaceSize(new UpdateWorkspaceSizeEvent());
|
||||||
notifySubscriber(completedFileUploadEvent);
|
notifySubscriber(completedFileUploadEvent);
|
||||||
|
@ -1113,7 +1156,7 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
|
||||||
@Override
|
@Override
|
||||||
public void onSmartFolderSelected(SmartFolderSelectedEvent smartFolderSelectedEvent) {
|
public void onSmartFolderSelected(SmartFolderSelectedEvent smartFolderSelectedEvent) {
|
||||||
searching(true);
|
searching(true);
|
||||||
// System.out.println("Click smart folder : " + smartFolderSelectedEvent.getSmartFolderName());
|
// System.out.println("Click smart folder : " + smartFolderSelectedEvent.getSmartFolderName());
|
||||||
doSmartFolderSelected(smartFolderSelectedEvent);
|
doSmartFolderSelected(smartFolderSelectedEvent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1231,8 +1274,8 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
|
||||||
}
|
}
|
||||||
|
|
||||||
notifySubscriber(event);
|
notifySubscriber(event);
|
||||||
// doUpdateWorkspaceSize(new UpdateWorkspaceSizeEvent());
|
// doUpdateWorkspaceSize(new UpdateWorkspaceSizeEvent());
|
||||||
// eventBus.fireEvent(new UpdateWorkspaceSizeEvent());
|
// eventBus.fireEvent(new UpdateWorkspaceSizeEvent());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1383,7 +1426,7 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
|
||||||
}
|
}
|
||||||
|
|
||||||
new MessageBoxAlert("Error", caught.getMessage()+"." , null);
|
new MessageBoxAlert("Error", caught.getMessage()+"." , null);
|
||||||
// System.out.println(caught.getMessage());
|
// System.out.println(caught.getMessage());
|
||||||
explorerPanel.getAsycTreePanel().reloadTreeLevelAndExpandFolder(event.getTargetParentFileModel().getIdentifier(), false);
|
explorerPanel.getAsycTreePanel().reloadTreeLevelAndExpandFolder(event.getTargetParentFileModel().getIdentifier(), false);
|
||||||
explorerPanel.getAsycTreePanel().reloadTreeLevelAndExpandFolder(event.getFileSourceModel().getParentFileModel().getIdentifier(), true);
|
explorerPanel.getAsycTreePanel().reloadTreeLevelAndExpandFolder(event.getFileSourceModel().getParentFileModel().getIdentifier(), true);
|
||||||
}
|
}
|
||||||
|
@ -1562,12 +1605,12 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
|
||||||
String currentUrl = portalURL();
|
String currentUrl = portalURL();
|
||||||
int last = currentUrl.lastIndexOf("/");
|
int last = currentUrl.lastIndexOf("/");
|
||||||
String reportUrl = currentUrl.substring(0,last+1) + ConstantsExplorer.REPORTGENERATION;
|
String reportUrl = currentUrl.substring(0,last+1) + ConstantsExplorer.REPORTGENERATION;
|
||||||
// new WindowOpenUrl(reportUrl, "_self", "");
|
// new WindowOpenUrl(reportUrl, "_self", "");
|
||||||
newBrowserWindow.setUrl(reportUrl);
|
newBrowserWindow.setUrl(reportUrl);
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
String reportUrl = url;
|
String reportUrl = url;
|
||||||
// new WindowOpenUrl(reportUrl, "_self", "");
|
// new WindowOpenUrl(reportUrl, "_self", "");
|
||||||
newBrowserWindow.setUrl(reportUrl);
|
newBrowserWindow.setUrl(reportUrl);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1598,12 +1641,12 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
|
||||||
GWT.log("currentUrl " +currentUrl);
|
GWT.log("currentUrl " +currentUrl);
|
||||||
GWT.log("reportUrl " +templateUrl);
|
GWT.log("reportUrl " +templateUrl);
|
||||||
newBrowserWindow.setUrl(templateUrl);
|
newBrowserWindow.setUrl(templateUrl);
|
||||||
// new WindowOpenUrl(templateUrl, "_self", "");
|
// new WindowOpenUrl(templateUrl, "_self", "");
|
||||||
}else{
|
}else{
|
||||||
|
|
||||||
String templateUrl = url;
|
String templateUrl = url;
|
||||||
newBrowserWindow.setUrl(templateUrl);
|
newBrowserWindow.setUrl(templateUrl);
|
||||||
// new WindowOpenUrl(templateUrl, "_self", "");
|
// new WindowOpenUrl(templateUrl, "_self", "");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1695,7 +1738,7 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
|
||||||
sub.setParentItemSelected(subTreeEvent.getPathParentsList());
|
sub.setParentItemSelected(subTreeEvent.getPathParentsList());
|
||||||
|
|
||||||
// if(openTreeMenuEvent && isShowTreeMenu==false)
|
// if(openTreeMenuEvent && isShowTreeMenu==false)
|
||||||
// eventBus.fireEvent(new O)
|
// eventBus.fireEvent(new O)
|
||||||
|
|
||||||
}else if(event instanceof SmartFolderSelectedEvent){
|
}else if(event instanceof SmartFolderSelectedEvent){
|
||||||
|
|
||||||
|
@ -1894,7 +1937,7 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
|
||||||
this.explorerPanel.setSize(400, 600);
|
this.explorerPanel.setSize(400, 600);
|
||||||
this.explorerPanel.getAsycTreePanel().setSizeTreePanel(350, 550);
|
this.explorerPanel.getAsycTreePanel().setSizeTreePanel(350, 550);
|
||||||
|
|
||||||
// rootPanel.add(new BasicDNDExample()); //it's example of drag&drop
|
// rootPanel.add(new BasicDNDExample()); //it's example of drag&drop
|
||||||
}else
|
}else
|
||||||
this.explorerPanel = new ExplorerPanel(instancingSmartFolder,instancingMessages);
|
this.explorerPanel = new ExplorerPanel(instancingSmartFolder,instancingMessages);
|
||||||
|
|
||||||
|
@ -2016,7 +2059,7 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// GWT.log(targets.toString());
|
// GWT.log(targets.toString());
|
||||||
|
|
||||||
if(targets.size()>=1 && multiDragContact.getSelectedAcl()!=null){
|
if(targets.size()>=1 && multiDragContact.getSelectedAcl()!=null){
|
||||||
|
|
||||||
|
@ -2052,7 +2095,7 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
|
||||||
|
|
||||||
String names = "";
|
String names = "";
|
||||||
for (String name : result.getValidLogins()) {
|
for (String name : result.getValidLogins()) {
|
||||||
// String name = infoContactModel.getName()!=null? infoContactModel.getName():infoContactModel.getLogin();
|
// String name = infoContactModel.getName()!=null? infoContactModel.getName():infoContactModel.getLogin();
|
||||||
names+="<li><i>"+name +";</i></li>";
|
names+="<li><i>"+name +";</i></li>";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2066,7 +2109,7 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
|
||||||
//IF NOT CANCELLED
|
//IF NOT CANCELLED
|
||||||
String clickedButton = be.getButtonClicked().getItemId();
|
String clickedButton = be.getButtonClicked().getItemId();
|
||||||
if(clickedButton.equals(Dialog.YES)){
|
if(clickedButton.equals(Dialog.YES)){
|
||||||
// doAddAdministratorToFolderId(file, logins);
|
// doAddAdministratorToFolderId(file, logins);
|
||||||
setACLToFolderId(file.getIdentifier(), logins, multiDragContact.getSelectedAclID());
|
setACLToFolderId(file.getIdentifier(), logins, multiDragContact.getSelectedAclID());
|
||||||
multidrag.hide();
|
multidrag.hide();
|
||||||
}else if(clickedButton.equals(Dialog.CANCEL)){
|
}else if(clickedButton.equals(Dialog.CANCEL)){
|
||||||
|
@ -2234,6 +2277,7 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
|
||||||
GWT.log("My login is: "+user.getUsername());
|
GWT.log("My login is: "+user.getUsername());
|
||||||
myLogin = user.getUsername();
|
myLogin = user.getUsername();
|
||||||
myLoginFirstName = user.getFirstName();
|
myLoginFirstName = user.getFirstName();
|
||||||
|
ckanEditorOrAdmin = user.hasCataloguePermission();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -2559,11 +2603,11 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
|
||||||
|
|
||||||
if(fileModel.getGXTFolderItemType().equals(GXTFolderItemTypeEnum.URL_DOCUMENT)){
|
if(fileModel.getGXTFolderItemType().equals(GXTFolderItemTypeEnum.URL_DOCUMENT)){
|
||||||
newBrowserWindow.setUrl(((GWTUrlDocument) result).getUrl());
|
newBrowserWindow.setUrl(((GWTUrlDocument) result).getUrl());
|
||||||
// new WindowOpenUrl(((GWTUrlDocument) result).getUrl(), "_blank", "");
|
// new WindowOpenUrl(((GWTUrlDocument) result).getUrl(), "_blank", "");
|
||||||
GWT.log("URL_DOCUMENT Open " + ((GWTUrlDocument) result).getUrl());
|
GWT.log("URL_DOCUMENT Open " + ((GWTUrlDocument) result).getUrl());
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
// new WindowOpenUrl(((GWTExternalUrl) result).getUrl(), "_blank", "");
|
// new WindowOpenUrl(((GWTExternalUrl) result).getUrl(), "_blank", "");
|
||||||
newBrowserWindow.setUrl(((GWTExternalUrl) result).getUrl());
|
newBrowserWindow.setUrl(((GWTExternalUrl) result).getUrl());
|
||||||
GWT.log("ExternalUrl Open " + ((GWTExternalUrl) result).getUrl());
|
GWT.log("ExternalUrl Open " + ((GWTExternalUrl) result).getUrl());
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,6 +32,7 @@ public class ConstantsExplorer {
|
||||||
public static final String MESSAGE_ADD_SMART_FOLDER = "New Smart Folder";
|
public static final String MESSAGE_ADD_SMART_FOLDER = "New Smart Folder";
|
||||||
public static final String MESSAGE_ADD_FOLDER = "New Folder";
|
public static final String MESSAGE_ADD_FOLDER = "New Folder";
|
||||||
public static final String MESSAGE_ADD_SHARED_FOLDER = "New Shared Folder";
|
public static final String MESSAGE_ADD_SHARED_FOLDER = "New Shared Folder";
|
||||||
|
public static final String MESSAGE_DATA_CATALOGUE_PUBLISH = "Publish on Catalogue";
|
||||||
public static final String MESSAGE_ADD = "Add";
|
public static final String MESSAGE_ADD = "Add";
|
||||||
public static final String MESSAGE_ADD_FOLDER_IN = "Create a new folder in: ";
|
public static final String MESSAGE_ADD_FOLDER_IN = "Create a new folder in: ";
|
||||||
public static final String MESSAGE_ITEM_NAME = "Item Name";
|
public static final String MESSAGE_ITEM_NAME = "Item Name";
|
||||||
|
|
|
@ -10,6 +10,7 @@ public enum WorkspaceOperation {
|
||||||
PREVIEW("PRW", "PRW"),
|
PREVIEW("PRW", "PRW"),
|
||||||
RENAME("RNM", "RNM"),
|
RENAME("RNM", "RNM"),
|
||||||
INSERT_SHARED_FOLDER("ISHF", "ASHF"), // Insert shared Folder
|
INSERT_SHARED_FOLDER("ISHF", "ASHF"), // Insert shared Folder
|
||||||
|
PUBLISH_ON_DATA_CATALOGUE("PODC", "PODC"),
|
||||||
SHARE("SHR", "SHR"), // SHARE
|
SHARE("SHR", "SHR"), // SHARE
|
||||||
UNSHARE("USHR", "USHR"), // UNSHARE
|
UNSHARE("USHR", "USHR"), // UNSHARE
|
||||||
UPLOAD_ARCHIVE("UPA", "UPA"), // Upload Archive
|
UPLOAD_ARCHIVE("UPA", "UPA"), // Upload Archive
|
||||||
|
|
|
@ -0,0 +1,46 @@
|
||||||
|
package org.gcube.portlets.user.workspace.client.event;
|
||||||
|
|
||||||
|
import com.google.gwt.event.shared.GwtEvent;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Class PublishOnDataCatalogueEvent
|
||||||
|
* @author Costantino Perciante at ISTI-CNR (costantino.perciante@isti.cnr.it)
|
||||||
|
*/
|
||||||
|
public class PublishOnDataCatalogueEvent extends GwtEvent<PublishOnDataCatalogueEventHandler> {
|
||||||
|
public static Type<PublishOnDataCatalogueEventHandler> TYPE = new Type<PublishOnDataCatalogueEventHandler>();
|
||||||
|
|
||||||
|
private String folderId;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Instantiates a new insert metadata event.
|
||||||
|
*/
|
||||||
|
public PublishOnDataCatalogueEvent(String folderId) {
|
||||||
|
this.folderId = folderId;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the folderId
|
||||||
|
*/
|
||||||
|
public String getFolderId() {
|
||||||
|
return folderId;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see com.google.gwt.event.shared.GwtEvent#getAssociatedType()
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Type<PublishOnDataCatalogueEventHandler> getAssociatedType() {
|
||||||
|
return TYPE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see com.google.gwt.event.shared.GwtEvent#dispatch(com.google.gwt.event.shared.EventHandler)
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
protected void dispatch(PublishOnDataCatalogueEventHandler handler) {
|
||||||
|
handler.onPublish(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,18 @@
|
||||||
|
package org.gcube.portlets.user.workspace.client.event;
|
||||||
|
|
||||||
|
import com.google.gwt.event.shared.EventHandler;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Interface PublishOnDataCatalogueEventHandler
|
||||||
|
* @author Costantino Perciante at ISTI-CNR
|
||||||
|
* (costantino.perciante@isti.cnr.it)
|
||||||
|
*/
|
||||||
|
public interface PublishOnDataCatalogueEventHandler extends EventHandler {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* On insert metadata.
|
||||||
|
*
|
||||||
|
* @param loadSelecteReleaseEvent the load selecte release event
|
||||||
|
*/
|
||||||
|
void onPublish(PublishOnDataCatalogueEvent loadSelecteReleaseEvent);
|
||||||
|
}
|
|
@ -700,5 +700,10 @@ public interface GWTWorkspaceService extends RemoteService{
|
||||||
* @return true if he can publish, false otherwise
|
* @return true if he can publish, false otherwise
|
||||||
*/
|
*/
|
||||||
boolean hasUserRoleAdminOrEditor();
|
boolean hasUserRoleAdminOrEditor();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieve the username of the user into the session
|
||||||
|
* @return the username of the current user
|
||||||
|
*/
|
||||||
|
String getUser();
|
||||||
}
|
}
|
||||||
|
|
|
@ -690,4 +690,10 @@ public interface GWTWorkspaceServiceAsync {
|
||||||
*/
|
*/
|
||||||
void hasUserRoleAdminOrEditor(AsyncCallback<Boolean> callback);
|
void hasUserRoleAdminOrEditor(AsyncCallback<Boolean> callback);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieve the username of the user into the session
|
||||||
|
* @return the username of the current user
|
||||||
|
*/
|
||||||
|
void getUser(AsyncCallback<String> callback);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,6 +26,7 @@ import org.gcube.portlets.user.workspace.client.event.ImagePreviewEvent;
|
||||||
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.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.PasteItemEvent;
|
||||||
|
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;
|
||||||
import org.gcube.portlets.user.workspace.client.event.SendMessageEvent;
|
import org.gcube.portlets.user.workspace.client.event.SendMessageEvent;
|
||||||
|
@ -58,7 +59,7 @@ public class ContextMenuTree {
|
||||||
private Menu contextMenu = new Menu();
|
private Menu contextMenu = new Menu();
|
||||||
private HandlerManager eventBus = AppControllerExplorer.getEventBus();
|
private HandlerManager eventBus = AppControllerExplorer.getEventBus();
|
||||||
private List<FileModel> listSelectedItems = null;
|
private List<FileModel> listSelectedItems = null;
|
||||||
|
|
||||||
private MenuItem mnRead = new MenuItem();
|
private MenuItem mnRead = new MenuItem();
|
||||||
|
|
||||||
private boolean hideSharing = false;
|
private boolean hideSharing = false;
|
||||||
|
@ -102,7 +103,7 @@ public class ContextMenuTree {
|
||||||
});
|
});
|
||||||
|
|
||||||
contextMenu.add(previewImage);
|
contextMenu.add(previewImage);
|
||||||
|
|
||||||
|
|
||||||
//Open Url
|
//Open Url
|
||||||
MenuItem openUrl = new MenuItem();
|
MenuItem openUrl = new MenuItem();
|
||||||
|
@ -169,12 +170,12 @@ public class ContextMenuTree {
|
||||||
|
|
||||||
//END SPECIFIC OPERATION
|
//END SPECIFIC OPERATION
|
||||||
|
|
||||||
|
|
||||||
MenuItem mnGetInfo = new MenuItem();
|
MenuItem mnGetInfo = new MenuItem();
|
||||||
mnGetInfo.setId(WorkspaceOperation.GET_INFO.getId());
|
mnGetInfo.setId(WorkspaceOperation.GET_INFO.getId());
|
||||||
mnGetInfo.setText(ConstantsExplorer.MESSAGE_GET_INFO);
|
mnGetInfo.setText(ConstantsExplorer.MESSAGE_GET_INFO);
|
||||||
mnGetInfo.setIcon(Resources.getIconInfo());
|
mnGetInfo.setIcon(Resources.getIconInfo());
|
||||||
|
|
||||||
mnGetInfo.addSelectionListener(new SelectionListener<MenuEvent>() {
|
mnGetInfo.addSelectionListener(new SelectionListener<MenuEvent>() {
|
||||||
public void componentSelected(MenuEvent ce) {
|
public void componentSelected(MenuEvent ce) {
|
||||||
|
|
||||||
|
@ -183,16 +184,16 @@ public class ContextMenuTree {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
contextMenu.add(mnGetInfo);
|
contextMenu.add(mnGetInfo);
|
||||||
|
|
||||||
|
|
||||||
//SHARE LINK
|
//SHARE LINK
|
||||||
MenuItem mnGetLink = new MenuItem();
|
MenuItem mnGetLink = new MenuItem();
|
||||||
mnGetLink.setId(WorkspaceOperation.SHARE_LINK.getId());
|
mnGetLink.setId(WorkspaceOperation.SHARE_LINK.getId());
|
||||||
mnGetLink.setText(ConstantsExplorer.MESSAGE_SHARE_LINK);
|
mnGetLink.setText(ConstantsExplorer.MESSAGE_SHARE_LINK);
|
||||||
mnGetLink.setIcon(Resources.getIconShareLink());
|
mnGetLink.setIcon(Resources.getIconShareLink());
|
||||||
|
|
||||||
mnGetLink.addSelectionListener(new SelectionListener<MenuEvent>() {
|
mnGetLink.addSelectionListener(new SelectionListener<MenuEvent>() {
|
||||||
public void componentSelected(MenuEvent ce) {
|
public void componentSelected(MenuEvent ce) {
|
||||||
|
|
||||||
|
@ -201,15 +202,15 @@ public class ContextMenuTree {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
contextMenu.add(mnGetLink);
|
contextMenu.add(mnGetLink);
|
||||||
|
|
||||||
//PUBLIC LINK
|
//PUBLIC LINK
|
||||||
MenuItem mnPublicLink = new MenuItem();
|
MenuItem mnPublicLink = new MenuItem();
|
||||||
mnPublicLink.setId(WorkspaceOperation.PUBLIC_LINK.getId());
|
mnPublicLink.setId(WorkspaceOperation.PUBLIC_LINK.getId());
|
||||||
mnPublicLink.setText(ConstantsExplorer.MESSAGE_PUBLIC_LINK);
|
mnPublicLink.setText(ConstantsExplorer.MESSAGE_PUBLIC_LINK);
|
||||||
mnPublicLink.setIcon(Resources.getIconPublicLink());
|
mnPublicLink.setIcon(Resources.getIconPublicLink());
|
||||||
|
|
||||||
mnPublicLink.addSelectionListener(new SelectionListener<MenuEvent>() {
|
mnPublicLink.addSelectionListener(new SelectionListener<MenuEvent>() {
|
||||||
public void componentSelected(MenuEvent ce) {
|
public void componentSelected(MenuEvent ce) {
|
||||||
|
|
||||||
|
@ -218,21 +219,21 @@ public class ContextMenuTree {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
contextMenu.add(mnPublicLink);
|
contextMenu.add(mnPublicLink);
|
||||||
|
|
||||||
contextMenu.add(new SeparatorMenuItem());
|
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());
|
||||||
mnHistory.setText(ConstantsExplorer.HISTORY);
|
mnHistory.setText(ConstantsExplorer.HISTORY);
|
||||||
|
|
||||||
mnHistory.addSelectionListener(new SelectionListener<MenuEvent>() {
|
mnHistory.addSelectionListener(new SelectionListener<MenuEvent>() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void componentSelected(MenuEvent ce) {
|
public void componentSelected(MenuEvent ce) {
|
||||||
|
|
||||||
final FileModel sourceFileModel = listSelectedItems.get(0);
|
final FileModel sourceFileModel = listSelectedItems.get(0);
|
||||||
|
|
||||||
if (sourceFileModel != null) {
|
if (sourceFileModel != null) {
|
||||||
|
@ -242,30 +243,30 @@ public class ContextMenuTree {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
contextMenu.add(mnHistory);
|
contextMenu.add(mnHistory);
|
||||||
|
|
||||||
//ACCOUNTING READ
|
//ACCOUNTING READ
|
||||||
mnRead = new MenuItem();
|
mnRead = new MenuItem();
|
||||||
mnRead.setIcon(Resources.getIconRead());
|
mnRead.setIcon(Resources.getIconRead());
|
||||||
mnRead.setId(WorkspaceOperation.ACCREAD.getId());
|
mnRead.setId(WorkspaceOperation.ACCREAD.getId());
|
||||||
mnRead.setText(ConstantsExplorer.ACCREAD);
|
mnRead.setText(ConstantsExplorer.ACCREAD);
|
||||||
|
|
||||||
mnRead.addSelectionListener(new SelectionListener<MenuEvent>() {
|
mnRead.addSelectionListener(new SelectionListener<MenuEvent>() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void componentSelected(MenuEvent ce) {
|
public void componentSelected(MenuEvent ce) {
|
||||||
|
|
||||||
final FileModel sourceFileModel = listSelectedItems.get(0);
|
final FileModel sourceFileModel = listSelectedItems.get(0);
|
||||||
|
|
||||||
if (sourceFileModel != null) {
|
if (sourceFileModel != null) {
|
||||||
|
|
||||||
eventBus.fireEvent(new AccountingReadersEvent(sourceFileModel));
|
eventBus.fireEvent(new AccountingReadersEvent(sourceFileModel));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
//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();
|
||||||
|
@ -304,8 +305,28 @@ public class ContextMenuTree {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
contextMenu.add(createShareFolder);
|
contextMenu.add(createShareFolder);
|
||||||
|
|
||||||
|
// publish on data catalogue
|
||||||
|
MenuItem publishOnDataCatalogue = new MenuItem();
|
||||||
|
publishOnDataCatalogue.setId(WorkspaceOperation.PUBLISH_ON_DATA_CATALOGUE.getId());
|
||||||
|
publishOnDataCatalogue.setText(ConstantsExplorer.MESSAGE_DATA_CATALOGUE_PUBLISH);
|
||||||
|
publishOnDataCatalogue.setIcon(Resources.getIconPublicLink()); // TODO change icon
|
||||||
|
|
||||||
|
publishOnDataCatalogue.addSelectionListener(new SelectionListener<MenuEvent>() {
|
||||||
|
public void componentSelected(MenuEvent ce) {
|
||||||
|
|
||||||
|
FileModel sourceFileModel = listSelectedItems.get(0);
|
||||||
|
String folderId = sourceFileModel.getIdentifier();
|
||||||
|
|
||||||
|
if (sourceFileModel != null) {
|
||||||
|
eventBus.fireEvent(new PublishOnDataCatalogueEvent(folderId));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
publishOnDataCatalogue.setVisible(false);
|
||||||
|
contextMenu.add(publishOnDataCatalogue);
|
||||||
|
|
||||||
|
|
||||||
MenuItem editPermissions = new MenuItem();
|
MenuItem editPermissions = new MenuItem();
|
||||||
editPermissions.setId(WorkspaceOperation.EDIT_PERMISSIONS.getId());
|
editPermissions.setId(WorkspaceOperation.EDIT_PERMISSIONS.getId());
|
||||||
editPermissions.setText(ConstantsExplorer.EDIT_PERMISSIONS);
|
editPermissions.setText(ConstantsExplorer.EDIT_PERMISSIONS);
|
||||||
|
@ -321,7 +342,7 @@ public class ContextMenuTree {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
contextMenu.add(editPermissions);
|
contextMenu.add(editPermissions);
|
||||||
|
|
||||||
|
|
||||||
|
@ -355,17 +376,17 @@ public class ContextMenuTree {
|
||||||
|
|
||||||
copy.addSelectionListener(new SelectionListener<MenuEvent>() {
|
copy.addSelectionListener(new SelectionListener<MenuEvent>() {
|
||||||
public void componentSelected(MenuEvent ce) {
|
public void componentSelected(MenuEvent ce) {
|
||||||
|
|
||||||
// //HERE THE MULTI-SELECTION IS NOT ENABLED
|
// //HERE THE MULTI-SELECTION IS NOT ENABLED
|
||||||
// for (FileModel target : listSelectedItems) {
|
// for (FileModel target : listSelectedItems) {
|
||||||
// if(target.getIdentifier()!=null){
|
// if(target.getIdentifier()!=null){
|
||||||
// CopyAndPaste.copy(target.getIdentifier()));
|
// CopyAndPaste.copy(target.getIdentifier()));
|
||||||
// eventBus.fireEvent(new CopytemEvent(target.getIdentifier()));
|
// eventBus.fireEvent(new CopytemEvent(target.getIdentifier()));
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
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);
|
CutCopyAndPaste.copy(ids, OperationType.COPY);
|
||||||
eventBus.fireEvent(new CopytemEvent(ids));
|
eventBus.fireEvent(new CopytemEvent(ids));
|
||||||
|
@ -407,7 +428,7 @@ public class ContextMenuTree {
|
||||||
|
|
||||||
share.addSelectionListener(new SelectionListener<MenuEvent>() {
|
share.addSelectionListener(new SelectionListener<MenuEvent>() {
|
||||||
public void componentSelected(MenuEvent ce) {
|
public void componentSelected(MenuEvent ce) {
|
||||||
|
|
||||||
FileModel sourceFileModel = listSelectedItems.get(0);
|
FileModel sourceFileModel = listSelectedItems.get(0);
|
||||||
|
|
||||||
if (sourceFileModel != null) {
|
if (sourceFileModel != null) {
|
||||||
|
@ -416,7 +437,7 @@ public class ContextMenuTree {
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
contextMenu.add(share);
|
contextMenu.add(share);
|
||||||
|
|
||||||
MenuItem unShare = new MenuItem();
|
MenuItem unShare = new MenuItem();
|
||||||
|
@ -437,7 +458,7 @@ public class ContextMenuTree {
|
||||||
});
|
});
|
||||||
|
|
||||||
contextMenu.add(unShare);
|
contextMenu.add(unShare);
|
||||||
|
|
||||||
MenuItem rename = new MenuItem();
|
MenuItem rename = new MenuItem();
|
||||||
rename.setId(WorkspaceOperation.RENAME.getId());
|
rename.setId(WorkspaceOperation.RENAME.getId());
|
||||||
rename.setText("Rename Item");
|
rename.setText("Rename Item");
|
||||||
|
@ -593,7 +614,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());
|
||||||
changePermission.setText("Change Permission");
|
changePermission.setText("Change Permission");
|
||||||
|
@ -610,14 +631,14 @@ 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());
|
||||||
addAdministrator.setText("Manage Administrator/s");
|
addAdministrator.setText("Manage Administrator/s");
|
||||||
addAdministrator.setIcon(Resources.getIconManageAdministrator());
|
addAdministrator.setIcon(Resources.getIconManageAdministrator());
|
||||||
|
|
||||||
|
@ -629,8 +650,8 @@ public class ContextMenuTree {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// contextMenu.add(addAdministrator);
|
// contextMenu.add(addAdministrator);
|
||||||
|
|
||||||
MenuItem refreshItem = new MenuItem();
|
MenuItem refreshItem = new MenuItem();
|
||||||
refreshItem.setId(WorkspaceOperation.REFRESH_FOLDER.getId());
|
refreshItem.setId(WorkspaceOperation.REFRESH_FOLDER.getId());
|
||||||
|
@ -645,10 +666,10 @@ public class ContextMenuTree {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
contextMenu.add(refreshItem);
|
contextMenu.add(refreshItem);
|
||||||
contextMenu.add(new SeparatorMenuItem());
|
contextMenu.add(new SeparatorMenuItem());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -680,17 +701,17 @@ public class ContextMenuTree {
|
||||||
printSelected();
|
printSelected();
|
||||||
|
|
||||||
if(targetFileModel!=null){
|
if(targetFileModel!=null){
|
||||||
|
|
||||||
if(targetFileModel.getParentFileModel()==null){
|
if(targetFileModel.getParentFileModel()==null){
|
||||||
|
|
||||||
Info.display("Wait", "loading available operations..");
|
Info.display("Wait", "loading available operations..");
|
||||||
|
|
||||||
AppControllerExplorer.rpcWorkspaceService.getParentByItemId(targetFileModel.getIdentifier(), new AsyncCallback<FileModel>() {
|
AppControllerExplorer.rpcWorkspaceService.getParentByItemId(targetFileModel.getIdentifier(), new AsyncCallback<FileModel>() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onFailure(Throwable caught) {
|
public void onFailure(Throwable caught) {
|
||||||
Info.display("Error", "sorry an error occurrend on loading available operations");
|
Info.display("Error", "sorry an error occurrend on loading available operations");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -701,19 +722,19 @@ public class ContextMenuTree {
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
Info.display("Error", "sorry an error occurrend on loading available operations");
|
Info.display("Error", "sorry an error occurrend on loading available operations");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
viewContextMenu(targetFileModel, posX, posY);
|
viewContextMenu(targetFileModel, posX, posY);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* View context menu.
|
* View context menu.
|
||||||
*
|
*
|
||||||
|
@ -722,7 +743,7 @@ public class ContextMenuTree {
|
||||||
* @param posY the pos y
|
* @param posY the pos y
|
||||||
*/
|
*/
|
||||||
private void viewContextMenu(FileModel targetFileModel, int posX, int posY){
|
private void viewContextMenu(FileModel targetFileModel, int posX, int posY){
|
||||||
|
|
||||||
contextMenuSwitch(targetFileModel);
|
contextMenuSwitch(targetFileModel);
|
||||||
contextMenu.getItemByItemId(WorkspaceOperation.INSERT_FOLDER.getId()).setVisible(false); //set invisible create folder
|
contextMenu.getItemByItemId(WorkspaceOperation.INSERT_FOLDER.getId()).setVisible(false); //set invisible create folder
|
||||||
contextMenu.getItemByItemId(WorkspaceOperation.INSERT_SHARED_FOLDER.getId()).setVisible(false); //set invisible create shared folder
|
contextMenu.getItemByItemId(WorkspaceOperation.INSERT_SHARED_FOLDER.getId()).setVisible(false); //set invisible create shared folder
|
||||||
|
@ -731,11 +752,11 @@ public class ContextMenuTree {
|
||||||
contextMenu.getItemByItemId(WorkspaceOperation.UPLOAD_ARCHIVE.getId()).setVisible(false); //set invisible upload archive
|
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.ADD_URL.getId()).setVisible(false); //set invisible add url
|
||||||
contextMenu.getItemByItemId(WorkspaceOperation.REFRESH_FOLDER.getId()).setVisible(false); //set invisible refresh
|
contextMenu.getItemByItemId(WorkspaceOperation.REFRESH_FOLDER.getId()).setVisible(false); //set invisible refresh
|
||||||
// contextMenu.getItemByItemId(WorkspaceOperation.SHARE.getId()).setVisible(false); //set invisible share
|
// contextMenu.getItemByItemId(WorkspaceOperation.SHARE.getId()).setVisible(false); //set invisible share
|
||||||
// contextMenu.getItemByItemId(WorkspaceOperation.UNSHARE.getId()).setVisible(false); //set invisible unshare
|
// contextMenu.getItemByItemId(WorkspaceOperation.UNSHARE.getId()).setVisible(false); //set invisible unshare
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
contextMenu.showAt(posX, posY);
|
contextMenu.showAt(posX, posY);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -766,7 +787,7 @@ public class ContextMenuTree {
|
||||||
contextMenu.getItemByItemId(WorkspaceOperation.SENDTO.getId()).setVisible(true); //send to
|
contextMenu.getItemByItemId(WorkspaceOperation.SENDTO.getId()).setVisible(true); //send to
|
||||||
contextMenu.getItemByItemId(WorkspaceOperation.DOWNLOAD.getId()).setVisible(true); //DOWNLOAD
|
contextMenu.getItemByItemId(WorkspaceOperation.DOWNLOAD.getId()).setVisible(true); //DOWNLOAD
|
||||||
contextMenu.getItemByItemId(WorkspaceOperation.COPY.getId()).setEnabled(true); //DOWNLOAD
|
contextMenu.getItemByItemId(WorkspaceOperation.COPY.getId()).setEnabled(true); //DOWNLOAD
|
||||||
|
|
||||||
contextMenu.getItemByItemId(WorkspaceOperation.PREVIEW.getId()).setVisible(false); //preview image
|
contextMenu.getItemByItemId(WorkspaceOperation.PREVIEW.getId()).setVisible(false); //preview image
|
||||||
contextMenu.getItemByItemId(WorkspaceOperation.LINK.getId()).setVisible(false); //open link
|
contextMenu.getItemByItemId(WorkspaceOperation.LINK.getId()).setVisible(false); //open link
|
||||||
contextMenu.getItemByItemId(WorkspaceOperation.SHOW.getId()).setVisible(false); //show
|
contextMenu.getItemByItemId(WorkspaceOperation.SHOW.getId()).setVisible(false); //show
|
||||||
|
@ -775,39 +796,39 @@ public class ContextMenuTree {
|
||||||
contextMenu.getItemByItemId(WorkspaceOperation.PASTE.getId()).setEnabled(false); //paste
|
contextMenu.getItemByItemId(WorkspaceOperation.PASTE.getId()).setEnabled(false); //paste
|
||||||
contextMenu.getItemByItemId(WorkspaceOperation.REFRESH_FOLDER.getId()).setVisible(false); //refresh
|
contextMenu.getItemByItemId(WorkspaceOperation.REFRESH_FOLDER.getId()).setVisible(false); //refresh
|
||||||
contextMenu.getItemByItemId(WorkspaceOperation.PUBLIC_LINK.getId()).setVisible(false); //public link
|
contextMenu.getItemByItemId(WorkspaceOperation.PUBLIC_LINK.getId()).setVisible(false); //public link
|
||||||
// contextMenu.getItemByItemId(WorkspaceOperation.ADD_ADMINISTRATOR.getId()).setVisible(false); //public link
|
// contextMenu.getItemByItemId(WorkspaceOperation.ADD_ADMINISTRATOR.getId()).setVisible(false); //public link
|
||||||
contextMenu.getItemByItemId(WorkspaceOperation.EDIT_PERMISSIONS.getId()).setVisible(false);
|
contextMenu.getItemByItemId(WorkspaceOperation.EDIT_PERMISSIONS.getId()).setVisible(false);
|
||||||
contextMenu.getItemByItemId(WorkspaceOperation.SHARE.getId()).setVisible(false); //SHARE
|
contextMenu.getItemByItemId(WorkspaceOperation.SHARE.getId()).setVisible(false); //SHARE
|
||||||
contextMenu.getItemByItemId(WorkspaceOperation.UNSHARE.getId()).setVisible(false); //UNSHARE
|
contextMenu.getItemByItemId(WorkspaceOperation.UNSHARE.getId()).setVisible(false); //UNSHARE
|
||||||
|
|
||||||
contextMenu.getItemByItemId(WorkspaceOperation.SHARE_LINK.getId()).setVisible(false); //SHARE
|
contextMenu.getItemByItemId(WorkspaceOperation.SHARE_LINK.getId()).setVisible(false); //SHARE
|
||||||
|
|
||||||
contextMenu.getItemByItemId(WorkspaceOperation.VRE_CHANGE_PERIMISSIONS.getId()).setVisible(false); //VRE CHANGE PERMISSIONS
|
contextMenu.getItemByItemId(WorkspaceOperation.VRE_CHANGE_PERIMISSIONS.getId()).setVisible(false); //VRE CHANGE PERMISSIONS
|
||||||
|
|
||||||
if(selectedItem.isShared()){ //SHARE LINK ON SHARED ITEM
|
if(selectedItem.isShared()){ //SHARE LINK ON SHARED ITEM
|
||||||
|
|
||||||
contextMenu.getItemByItemId(WorkspaceOperation.SHARE_LINK.getId()).setVisible(true);
|
contextMenu.getItemByItemId(WorkspaceOperation.SHARE_LINK.getId()).setVisible(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
//IS VRE FOLDER or SPECIAL FOLDER?
|
//IS VRE FOLDER or SPECIAL FOLDER?
|
||||||
if(selectedItem.isVreFolder() || selectedItem.isSpecialFolder()){
|
if(selectedItem.isVreFolder() || selectedItem.isSpecialFolder()){
|
||||||
|
|
||||||
contextMenu.getItemByItemId(WorkspaceOperation.SHARE.getId()).setVisible(false); //SHARE
|
contextMenu.getItemByItemId(WorkspaceOperation.SHARE.getId()).setVisible(false); //SHARE
|
||||||
contextMenu.getItemByItemId(WorkspaceOperation.INSERT_SHARED_FOLDER.getId()).setVisible(false); //insert shared folder
|
contextMenu.getItemByItemId(WorkspaceOperation.INSERT_SHARED_FOLDER.getId()).setVisible(false); //insert shared folder
|
||||||
contextMenu.getItemByItemId(WorkspaceOperation.UNSHARE.getId()).setVisible(false); //UNSHARE
|
contextMenu.getItemByItemId(WorkspaceOperation.UNSHARE.getId()).setVisible(false); //UNSHARE
|
||||||
contextMenu.getItemByItemId(WorkspaceOperation.RENAME.getId()).setVisible(false); //RENAME
|
contextMenu.getItemByItemId(WorkspaceOperation.RENAME.getId()).setVisible(false); //RENAME
|
||||||
contextMenu.getItemByItemId(WorkspaceOperation.REMOVE.getId()).setVisible(false); //REMOVE
|
contextMenu.getItemByItemId(WorkspaceOperation.REMOVE.getId()).setVisible(false); //REMOVE
|
||||||
contextMenu.getItemByItemId(WorkspaceOperation.REFRESH_FOLDER.getId()).setVisible(true); //REFRESH_FOLDER
|
contextMenu.getItemByItemId(WorkspaceOperation.REFRESH_FOLDER.getId()).setVisible(true); //REFRESH_FOLDER
|
||||||
|
|
||||||
//ADDED 14/03/2014
|
//ADDED 14/03/2014
|
||||||
if(selectedItem.isVreFolder()){
|
if(selectedItem.isVreFolder()){
|
||||||
contextMenu.getItemByItemId(WorkspaceOperation.VRE_CHANGE_PERIMISSIONS.getId()).setVisible(true); //REFRESH_FOLDER
|
contextMenu.getItemByItemId(WorkspaceOperation.VRE_CHANGE_PERIMISSIONS.getId()).setVisible(true); //REFRESH_FOLDER
|
||||||
if(CutCopyAndPaste.getCopiedIdsFilesModel()!=null)
|
if(CutCopyAndPaste.getCopiedIdsFilesModel()!=null)
|
||||||
contextMenu.getItemByItemId(WorkspaceOperation.PASTE.getId()).setEnabled(true); //enable paste button
|
contextMenu.getItemByItemId(WorkspaceOperation.PASTE.getId()).setEnabled(true); //enable paste button
|
||||||
}
|
}
|
||||||
|
|
||||||
// if(selectedItem.isVreFolder() && CutCopyAndPaste.getCopiedIdsFilesModel()!=null)
|
// if(selectedItem.isVreFolder() && CutCopyAndPaste.getCopiedIdsFilesModel()!=null)
|
||||||
// contextMenu.getItemByItemId(WorkspaceOperation.PASTE.getId()).setEnabled(true); //enable paste button
|
// contextMenu.getItemByItemId(WorkspaceOperation.PASTE.getId()).setEnabled(true); //enable paste button
|
||||||
else if(selectedItem.isSpecialFolder()){
|
else if(selectedItem.isSpecialFolder()){
|
||||||
contextMenu.getItemByItemId(WorkspaceOperation.COPY.getId()).setEnabled(false);
|
contextMenu.getItemByItemId(WorkspaceOperation.COPY.getId()).setEnabled(false);
|
||||||
contextMenu.getItemByItemId(WorkspaceOperation.PASTE.getId()).setEnabled(false);
|
contextMenu.getItemByItemId(WorkspaceOperation.PASTE.getId()).setEnabled(false);
|
||||||
|
@ -818,20 +839,23 @@ public class ContextMenuTree {
|
||||||
contextMenu.getItemByItemId(WorkspaceOperation.INSERT_FOLDER.getId()).setVisible(false); //insert folder
|
contextMenu.getItemByItemId(WorkspaceOperation.INSERT_FOLDER.getId()).setVisible(false); //insert folder
|
||||||
contextMenu.getItemByItemId(WorkspaceOperation.DOWNLOAD.getId()).setVisible(false);
|
contextMenu.getItemByItemId(WorkspaceOperation.DOWNLOAD.getId()).setVisible(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
//CASE DIRECTORY
|
//CASE DIRECTORY
|
||||||
if(selectedItem.isDirectory()){
|
if(selectedItem.isDirectory()){
|
||||||
|
if(AppControllerExplorer.ckanEditorOrAdmin)
|
||||||
|
contextMenu.getItemByItemId(WorkspaceOperation.PUBLISH_ON_DATA_CATALOGUE.getId()).setVisible(true);
|
||||||
|
|
||||||
contextMenu.getItemByItemId(WorkspaceOperation.SHARE.getId()).setVisible(true); //SHARE
|
contextMenu.getItemByItemId(WorkspaceOperation.SHARE.getId()).setVisible(true); //SHARE
|
||||||
contextMenu.getItemByItemId(WorkspaceOperation.SHOW.getId()).setVisible(false); //show
|
contextMenu.getItemByItemId(WorkspaceOperation.SHOW.getId()).setVisible(false); //show
|
||||||
contextMenu.getItemByItemId(WorkspaceOperation.REFRESH_FOLDER.getId()).setVisible(true); //refresh
|
contextMenu.getItemByItemId(WorkspaceOperation.REFRESH_FOLDER.getId()).setVisible(true); //refresh
|
||||||
contextMenu.getItemByItemId(WorkspaceOperation.SENDTO.getId()).setVisible(false); //send to
|
contextMenu.getItemByItemId(WorkspaceOperation.SENDTO.getId()).setVisible(false); //send to
|
||||||
if(selectedItem.isShared()){//IS SHARED
|
if(selectedItem.isShared()){//IS SHARED
|
||||||
|
|
||||||
// contextMenu.getItemByItemId(WorkspaceOperation.ADD_ADMINISTRATOR.getId()).setVisible(true); //add administrator
|
// contextMenu.getItemByItemId(WorkspaceOperation.ADD_ADMINISTRATOR.getId()).setVisible(true); //add administrator
|
||||||
|
|
||||||
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.INSERT_SHARED_FOLDER.getId()).setVisible(false); //insert shared folder
|
||||||
contextMenu.getItemByItemId(WorkspaceOperation.UNSHARE.getId()).setVisible(true);
|
contextMenu.getItemByItemId(WorkspaceOperation.UNSHARE.getId()).setVisible(true);
|
||||||
|
@ -912,7 +936,7 @@ public class ContextMenuTree {
|
||||||
contextMenu.getItemByItemId(WorkspaceOperation.PASTE.getId()).setEnabled(true); //enable paste button
|
contextMenu.getItemByItemId(WorkspaceOperation.PASTE.getId()).setEnabled(true); //enable paste button
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 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.
|
||||||
*
|
*
|
||||||
|
|
|
@ -118,17 +118,27 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
|
||||||
|
|
||||||
// ckan utils methods
|
// ckan utils methods
|
||||||
private CKanUtilsImpl instance;
|
private CKanUtilsImpl instance;
|
||||||
|
private Object LOCK = new Object();
|
||||||
|
|
||||||
@Override
|
/**
|
||||||
public void init(){
|
* Retrieve the ckan utils object
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
private CKanUtilsImpl getCkanUtils(){
|
||||||
|
|
||||||
// retrieve ckan information
|
if(instance == null){
|
||||||
try{
|
synchronized (LOCK) {
|
||||||
String currentScope = ScopeProvider.instance.get();
|
if(instance == null){
|
||||||
instance = new CKanUtilsImpl(currentScope);
|
try{
|
||||||
}catch(Exception e){
|
String currentScope = WsUtil.getAslSession(this.getThreadLocalRequest().getSession()).getScope();
|
||||||
workspaceLogger.error("Unable to retrieve ckan information");
|
instance = new CKanUtilsImpl(currentScope);
|
||||||
|
}catch(Exception e){
|
||||||
|
workspaceLogger.error("Unable to retrieve ckan information");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
return instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -2685,7 +2695,7 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
|
||||||
String email = username+"@isti.cnr.it";
|
String email = username+"@isti.cnr.it";
|
||||||
String firstName = "Testing";
|
String firstName = "Testing";
|
||||||
String lastName = "User";
|
String lastName = "User";
|
||||||
|
boolean catalogueEditor = false;
|
||||||
|
|
||||||
if (isWithinPortal() && username.compareTo(WsUtil.TEST_USER) != 0) {
|
if (isWithinPortal() && username.compareTo(WsUtil.TEST_USER) != 0) {
|
||||||
try {
|
try {
|
||||||
|
@ -2694,6 +2704,9 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
|
||||||
firstName = user.getFirstName();
|
firstName = user.getFirstName();
|
||||||
lastName = user.getLastName();
|
lastName = user.getLastName();
|
||||||
email = user.getEmail();
|
email = user.getEmail();
|
||||||
|
|
||||||
|
// check if he has catalogue role
|
||||||
|
catalogueEditor = hasUserRoleAdminOrEditor();
|
||||||
}catch (UserManagementSystemException e) {
|
}catch (UserManagementSystemException e) {
|
||||||
workspaceLogger.error("UserManagementSystemException for username: "+username);
|
workspaceLogger.error("UserManagementSystemException for username: "+username);
|
||||||
}
|
}
|
||||||
|
@ -2702,7 +2715,7 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
return new UserBean(username, firstName, lastName, email);
|
return new UserBean(username, firstName, lastName, email, catalogueEditor);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -3420,101 +3433,101 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
|
||||||
public boolean hasUserRoleAdminOrEditor() {
|
public boolean hasUserRoleAdminOrEditor() {
|
||||||
ASLSession asl = WsUtil.getAslSession(this.getThreadLocalRequest().getSession());
|
ASLSession asl = WsUtil.getAslSession(this.getThreadLocalRequest().getSession());
|
||||||
String username = asl.getUsername();
|
String username = asl.getUsername();
|
||||||
|
|
||||||
// check if this information was already into the ASL Session
|
if(!isWithinPortal()){
|
||||||
String role = (String)asl.getAttribute(CKAN_ROLE);
|
workspaceLogger.warn("OUT FROM PORTAL DETECTED RETURNING TRUE");
|
||||||
|
asl.setAttribute(CKAN_ROLE, "editor");
|
||||||
if(role != null)
|
return true;
|
||||||
switch(role){
|
|
||||||
case "editor" :
|
|
||||||
case "admin" : return true;
|
|
||||||
default: return false; // member
|
|
||||||
}
|
|
||||||
|
|
||||||
try{
|
|
||||||
|
|
||||||
if(!isWithinPortal()){
|
|
||||||
workspaceLogger.warn("OUT FROM PORTAL DETECTED RETURNING TRUE");
|
|
||||||
asl.setAttribute(CKAN_ROLE, "editor");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
// first of all, check if the user is a sysadmin in the catalog (in this case he can do everything)
|
|
||||||
boolean isSysAdmin = instance.isSysAdmin(username, getUserCKanTokenFromSession());
|
|
||||||
|
|
||||||
if(isSysAdmin){
|
|
||||||
|
|
||||||
workspaceLogger.debug("The user is a sysadmin of the catalog -> he can edit/add");
|
|
||||||
asl.setAttribute(CKAN_ROLE, "admin");
|
|
||||||
return true;
|
|
||||||
|
|
||||||
}else{
|
|
||||||
|
|
||||||
// retrieve the liferay's roles for the user
|
|
||||||
UserManager userManager = new LiferayUserManager();
|
|
||||||
RoleManager roleManager = new LiferayRoleManager();
|
|
||||||
GroupManager groupManager = new LiferayGroupManager();
|
|
||||||
|
|
||||||
// we need to iterate over vres
|
|
||||||
List<GCubeGroup> groups = groupManager.listGroups();
|
|
||||||
|
|
||||||
for (GCubeGroup gCubeGroup : groups) {
|
|
||||||
|
|
||||||
String groupName = gCubeGroup.getGroupName();
|
|
||||||
|
|
||||||
// skip if it is not a vre
|
|
||||||
if(!groupManager.isVRE(gCubeGroup.getGroupId()))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
List<GCubeRole> roles = roleManager.listRolesByUserAndGroup(userManager.getUserId(username), groupManager.getGroupId(groupName));
|
|
||||||
|
|
||||||
// the default one
|
|
||||||
RolesIntoOrganization correspondentRoleToCheck = RolesIntoOrganization.MEMBER;
|
|
||||||
String roleToSetInSession = null;
|
|
||||||
|
|
||||||
// NOTE: it is supposed that there is just one role for this person correspondent to the one in the catalog
|
|
||||||
for (GCubeRole gCubeRole : roles) {
|
|
||||||
|
|
||||||
workspaceLogger.debug("User " + username + " has role " + gCubeRole.getRoleName() + " in " + groupName);
|
|
||||||
if(gCubeRole.getRoleName().equalsIgnoreCase(CkanRolesIntoLiferay.CATALOG_ADMIN.toString())){
|
|
||||||
correspondentRoleToCheck = RolesIntoOrganization.ADMIN;
|
|
||||||
roleToSetInSession = "admin";
|
|
||||||
break;
|
|
||||||
}else if(gCubeRole.getRoleName().equalsIgnoreCase(CkanRolesIntoLiferay.CATALOG_EDITOR.toString())){
|
|
||||||
correspondentRoleToCheck = RolesIntoOrganization.EDITOR;
|
|
||||||
roleToSetInSession = "editor";
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// if the role is member, keep continuing
|
|
||||||
if(correspondentRoleToCheck.equals(RolesIntoOrganization.MEMBER))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
// with this invocation, we check if the role is present in ckan and if it is not it will be added
|
|
||||||
boolean res = instance.checkRole(username, groupName, correspondentRoleToCheck);
|
|
||||||
|
|
||||||
// set the role in the asl session
|
|
||||||
if(res){
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
return res;
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}catch(Exception e){
|
|
||||||
workspaceLogger.error("Unable to retrieve the role information for this user. Returning FALSE", e);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
workspaceLogger.debug("Unable to check the role into ckan organization, returning FALSE");
|
// check if this information was already into the ASL Session (true means the user has at least in one org
|
||||||
|
// the role editor/admin), false that he is just a member so he cannot publish
|
||||||
// set the role member into the asl
|
Boolean role = (Boolean)asl.getAttribute(CKAN_ROLE);
|
||||||
asl.setAttribute(CKAN_ROLE, "member");
|
|
||||||
|
|
||||||
// return false
|
// if the attribute was already set..
|
||||||
return false;
|
if(role != null)
|
||||||
|
return role;
|
||||||
|
else{
|
||||||
|
|
||||||
|
try{
|
||||||
|
// first of all, check if the user is a sysadmin in the catalog (in this case he can do everything)
|
||||||
|
boolean isSysAdmin = getCkanUtils().isSysAdmin(username, getUserCKanTokenFromSession());
|
||||||
|
|
||||||
|
if(isSysAdmin){
|
||||||
|
|
||||||
|
workspaceLogger.debug("The user is a sysadmin of the catalog -> he can edit/add");
|
||||||
|
asl.setAttribute(CKAN_ROLE, true);
|
||||||
|
return true;
|
||||||
|
|
||||||
|
}else{
|
||||||
|
|
||||||
|
// retrieve the liferay's roles for the user
|
||||||
|
UserManager userManager = new LiferayUserManager();
|
||||||
|
RoleManager roleManager = new LiferayRoleManager();
|
||||||
|
GroupManager groupManager = new LiferayGroupManager();
|
||||||
|
|
||||||
|
// we need to iterate over vres of the user
|
||||||
|
List<GCubeGroup> groups = groupManager.listGroupsByUser(userManager.getUserId(username));
|
||||||
|
|
||||||
|
workspaceLogger.debug("The list of organizations of the user " + username + " is " + groups);
|
||||||
|
|
||||||
|
boolean toReturn = false;
|
||||||
|
|
||||||
|
for (GCubeGroup gCubeGroup : groups) {
|
||||||
|
|
||||||
|
String groupName = gCubeGroup.getGroupName();
|
||||||
|
|
||||||
|
// skip if it is not a vre
|
||||||
|
if(!groupManager.isVRE(gCubeGroup.getGroupId()))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
List<GCubeRole> roles = roleManager.listRolesByUserAndGroup(userManager.getUserId(username), groupManager.getGroupId(groupName));
|
||||||
|
|
||||||
|
// the default one
|
||||||
|
RolesIntoOrganization correspondentRoleToCheck = RolesIntoOrganization.MEMBER;
|
||||||
|
|
||||||
|
// NOTE: it is supposed that there is just one role for this person correspondent to the one in the catalog
|
||||||
|
for (GCubeRole gCubeRole : roles) {
|
||||||
|
|
||||||
|
workspaceLogger.debug("User " + username + " has role " + gCubeRole.getRoleName() + " in " + groupName);
|
||||||
|
if(gCubeRole.getRoleName().equalsIgnoreCase(CkanRolesIntoLiferay.CATALOG_ADMIN)){
|
||||||
|
correspondentRoleToCheck = RolesIntoOrganization.ADMIN;
|
||||||
|
toReturn = true;
|
||||||
|
break;
|
||||||
|
}else if(gCubeRole.getRoleName().equalsIgnoreCase(CkanRolesIntoLiferay.CATALOG_EDITOR)){
|
||||||
|
correspondentRoleToCheck = RolesIntoOrganization.EDITOR;
|
||||||
|
toReturn = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// if the role is member, continue
|
||||||
|
if(correspondentRoleToCheck.equals(RolesIntoOrganization.MEMBER))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
// with this invocation, we check if the role is present in ckan and if it is not it will be added
|
||||||
|
toReturn &= getCkanUtils().checkRole(username, groupName, correspondentRoleToCheck);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// set true in the asl session
|
||||||
|
workspaceLogger.debug("Setting CKAN_ROLE for " + username + " to " + toReturn);
|
||||||
|
asl.setAttribute(CKAN_ROLE, toReturn);
|
||||||
|
return toReturn;
|
||||||
|
}
|
||||||
|
|
||||||
|
}catch(Exception e){
|
||||||
|
workspaceLogger.error("Unable to retrieve the role information for this user. Returning FALSE", e);
|
||||||
|
}
|
||||||
|
|
||||||
|
workspaceLogger.debug("Unable to check the role into ckan organization, returning FALSE");
|
||||||
|
|
||||||
|
// set the role member into the asl
|
||||||
|
asl.setAttribute(CKAN_ROLE, false);
|
||||||
|
|
||||||
|
// return false
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -3534,7 +3547,7 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
|
||||||
token = (String)this.getThreadLocalRequest().getSession().getAttribute(CKAN_TOKEN_KEY);
|
token = (String)this.getThreadLocalRequest().getSession().getAttribute(CKAN_TOKEN_KEY);
|
||||||
else{
|
else{
|
||||||
|
|
||||||
token = instance.getApiKeyFromUsername(username);
|
token = getCkanUtils().getApiKeyFromUsername(username);
|
||||||
this.getThreadLocalRequest().getSession().setAttribute(CKAN_TOKEN_KEY, token);
|
this.getThreadLocalRequest().getSession().setAttribute(CKAN_TOKEN_KEY, token);
|
||||||
workspaceLogger.debug("Ckan token has been set for user " + username);
|
workspaceLogger.debug("Ckan token has been set for user " + username);
|
||||||
}
|
}
|
||||||
|
@ -3543,4 +3556,11 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
|
||||||
return token;
|
return token;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getUser() {
|
||||||
|
HttpSession httpSession = this.getThreadLocalRequest().getSession();
|
||||||
|
ASLSession session = WsUtil.getAslSession(httpSession);
|
||||||
|
return session.getUsername();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,13 +8,12 @@ public class UserBean implements Serializable {
|
||||||
private String firstName;
|
private String firstName;
|
||||||
private String lastName;
|
private String lastName;
|
||||||
private String email;
|
private String email;
|
||||||
|
private boolean cataloguePermission;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public UserBean(String username, String firstName, String lastName,
|
public UserBean(String username, String firstName, String lastName,
|
||||||
String email) {
|
String email, boolean cataloguePermission) {
|
||||||
super();
|
super();
|
||||||
|
this.cataloguePermission = cataloguePermission;
|
||||||
this.username = username;
|
this.username = username;
|
||||||
this.firstName = firstName;
|
this.firstName = firstName;
|
||||||
this.lastName = lastName;
|
this.lastName = lastName;
|
||||||
|
@ -46,7 +45,17 @@ public class UserBean implements Serializable {
|
||||||
public void setEmail(String email) {
|
public void setEmail(String email) {
|
||||||
this.email = email;
|
this.email = email;
|
||||||
}
|
}
|
||||||
|
public boolean hasCataloguePermission() {
|
||||||
|
return cataloguePermission;
|
||||||
|
}
|
||||||
|
public void setCataloguePermission(boolean cataloguePermission) {
|
||||||
|
this.cataloguePermission = cataloguePermission;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "UserBean [username=" + username + ", firstName=" + firstName
|
||||||
|
+ ", lastName=" + lastName + ", email=" + email
|
||||||
|
+ ", cataloguePermission=" + cataloguePermission + "]";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue