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", "");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -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);
|
||||||
|
}
|
|
@ -701,4 +701,9 @@ public interface GWTWorkspaceService extends RemoteService{
|
||||||
*/
|
*/
|
||||||
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;
|
||||||
|
@ -264,7 +265,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());
|
||||||
|
|
||||||
|
@ -305,6 +306,26 @@ 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());
|
||||||
|
@ -356,14 +377,14 @@ 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){
|
||||||
|
@ -617,7 +638,7 @@ public class ContextMenuTree {
|
||||||
|
|
||||||
|
|
||||||
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());
|
||||||
|
|
||||||
|
@ -630,7 +651,7 @@ 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());
|
||||||
|
@ -731,8 +752,8 @@ 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
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -775,7 +796,7 @@ 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
|
||||||
|
@ -806,8 +827,8 @@ public class ContextMenuTree {
|
||||||
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);
|
||||||
|
@ -824,13 +845,16 @@ public class ContextMenuTree {
|
||||||
|
|
||||||
//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
|
||||||
|
|
|
@ -118,18 +118,28 @@ 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){
|
||||||
|
synchronized (LOCK) {
|
||||||
|
if(instance == null){
|
||||||
try{
|
try{
|
||||||
String currentScope = ScopeProvider.instance.get();
|
String currentScope = WsUtil.getAslSession(this.getThreadLocalRequest().getSession()).getScope();
|
||||||
instance = new CKanUtilsImpl(currentScope);
|
instance = new CKanUtilsImpl(currentScope);
|
||||||
}catch(Exception e){
|
}catch(Exception e){
|
||||||
workspaceLogger.error("Unable to retrieve ckan information");
|
workspaceLogger.error("Unable to retrieve ckan information");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return instance;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the GWT workspace builder.
|
* Gets the GWT workspace builder.
|
||||||
|
@ -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);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -3421,30 +3434,29 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
|
||||||
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
|
|
||||||
String role = (String)asl.getAttribute(CKAN_ROLE);
|
|
||||||
|
|
||||||
if(role != null)
|
|
||||||
switch(role){
|
|
||||||
case "editor" :
|
|
||||||
case "admin" : return true;
|
|
||||||
default: return false; // member
|
|
||||||
}
|
|
||||||
|
|
||||||
try{
|
|
||||||
|
|
||||||
if(!isWithinPortal()){
|
if(!isWithinPortal()){
|
||||||
workspaceLogger.warn("OUT FROM PORTAL DETECTED RETURNING TRUE");
|
workspaceLogger.warn("OUT FROM PORTAL DETECTED RETURNING TRUE");
|
||||||
asl.setAttribute(CKAN_ROLE, "editor");
|
asl.setAttribute(CKAN_ROLE, "editor");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 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
|
||||||
|
Boolean role = (Boolean)asl.getAttribute(CKAN_ROLE);
|
||||||
|
|
||||||
|
// if the attribute was already set..
|
||||||
|
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)
|
// 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());
|
boolean isSysAdmin = getCkanUtils().isSysAdmin(username, getUserCKanTokenFromSession());
|
||||||
|
|
||||||
if(isSysAdmin){
|
if(isSysAdmin){
|
||||||
|
|
||||||
workspaceLogger.debug("The user is a sysadmin of the catalog -> he can edit/add");
|
workspaceLogger.debug("The user is a sysadmin of the catalog -> he can edit/add");
|
||||||
asl.setAttribute(CKAN_ROLE, "admin");
|
asl.setAttribute(CKAN_ROLE, true);
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
}else{
|
}else{
|
||||||
|
@ -3454,8 +3466,12 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
|
||||||
RoleManager roleManager = new LiferayRoleManager();
|
RoleManager roleManager = new LiferayRoleManager();
|
||||||
GroupManager groupManager = new LiferayGroupManager();
|
GroupManager groupManager = new LiferayGroupManager();
|
||||||
|
|
||||||
// we need to iterate over vres
|
// we need to iterate over vres of the user
|
||||||
List<GCubeGroup> groups = groupManager.listGroups();
|
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) {
|
for (GCubeGroup gCubeGroup : groups) {
|
||||||
|
|
||||||
|
@ -3469,41 +3485,37 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
|
||||||
|
|
||||||
// the default one
|
// the default one
|
||||||
RolesIntoOrganization correspondentRoleToCheck = RolesIntoOrganization.MEMBER;
|
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
|
// NOTE: it is supposed that there is just one role for this person correspondent to the one in the catalog
|
||||||
for (GCubeRole gCubeRole : roles) {
|
for (GCubeRole gCubeRole : roles) {
|
||||||
|
|
||||||
workspaceLogger.debug("User " + username + " has role " + gCubeRole.getRoleName() + " in " + groupName);
|
workspaceLogger.debug("User " + username + " has role " + gCubeRole.getRoleName() + " in " + groupName);
|
||||||
if(gCubeRole.getRoleName().equalsIgnoreCase(CkanRolesIntoLiferay.CATALOG_ADMIN.toString())){
|
if(gCubeRole.getRoleName().equalsIgnoreCase(CkanRolesIntoLiferay.CATALOG_ADMIN)){
|
||||||
correspondentRoleToCheck = RolesIntoOrganization.ADMIN;
|
correspondentRoleToCheck = RolesIntoOrganization.ADMIN;
|
||||||
roleToSetInSession = "admin";
|
toReturn = true;
|
||||||
break;
|
break;
|
||||||
}else if(gCubeRole.getRoleName().equalsIgnoreCase(CkanRolesIntoLiferay.CATALOG_EDITOR.toString())){
|
}else if(gCubeRole.getRoleName().equalsIgnoreCase(CkanRolesIntoLiferay.CATALOG_EDITOR)){
|
||||||
correspondentRoleToCheck = RolesIntoOrganization.EDITOR;
|
correspondentRoleToCheck = RolesIntoOrganization.EDITOR;
|
||||||
roleToSetInSession = "editor";
|
toReturn = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// if the role is member, keep continuing
|
// if the role is member, continue
|
||||||
if(correspondentRoleToCheck.equals(RolesIntoOrganization.MEMBER))
|
if(correspondentRoleToCheck.equals(RolesIntoOrganization.MEMBER))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// with this invocation, we check if the role is present in ckan and if it is not it will be added
|
// 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);
|
toReturn &= getCkanUtils().checkRole(username, groupName, correspondentRoleToCheck);
|
||||||
|
|
||||||
// set the role in the asl session
|
|
||||||
if(res){
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
return res;
|
|
||||||
|
|
||||||
|
// 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){
|
}catch(Exception e){
|
||||||
workspaceLogger.error("Unable to retrieve the role information for this user. Returning FALSE", e);
|
workspaceLogger.error("Unable to retrieve the role information for this user. Returning FALSE", e);
|
||||||
}
|
}
|
||||||
|
@ -3511,11 +3523,12 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
|
||||||
workspaceLogger.debug("Unable to check the role into ckan organization, returning FALSE");
|
workspaceLogger.debug("Unable to check the role into ckan organization, returning FALSE");
|
||||||
|
|
||||||
// set the role member into the asl
|
// set the role member into the asl
|
||||||
asl.setAttribute(CKAN_ROLE, "member");
|
asl.setAttribute(CKAN_ROLE, false);
|
||||||
|
|
||||||
// return false
|
// return false
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get current user's token.
|
* Get current user's token.
|
||||||
|
@ -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