ref 13226:StorageHub - Update workspace-sharing-widget to SH

https://support.d4science.org/issues/13226

Updated to StorageHub

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/widgets/workspace-sharing-widget@177215 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Giancarlo Panichi 2019-02-22 10:14:22 +00:00
parent da0f424536
commit b9d5ac9622
54 changed files with 3784 additions and 2551 deletions

View File

@ -13,13 +13,17 @@
<attribute name="maven.pomderived" value="true"/> <attribute name="maven.pomderived" value="true"/>
</attributes> </attributes>
</classpathentry> </classpathentry>
<classpathentry including="**/*.java" kind="src" output="target/test-classes" path="src/test/resources"/> <classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"> <classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER">
<attributes> <attributes>
<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/> <attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
</attributes> </attributes>
</classpathentry> </classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"> <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
<attributes> <attributes>
<attribute name="maven.pomderived" value="true"/> <attribute name="maven.pomderived" value="true"/>
</attributes> </attributes>

View File

@ -1,6 +1,6 @@
eclipse.preferences.version=1 eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.compliance=1.7 org.eclipse.jdt.core.compiler.compliance=1.7
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error org.eclipse.jdt.core.compiler.problem.enumIdentifier=error

View File

@ -1,18 +1,19 @@
<ReleaseNotes> <ReleaseNotes>
<Changeset component="portlets-widgets.workspace-sharing-widget.1-9-0"
date="2019-01-31">
<Change>Updated to StorageHub [ticket: #13226]</Change>
</Changeset>
<Changeset component="portlets-widgets.workspace-sharing-widget.1-8-2" <Changeset component="portlets-widgets.workspace-sharing-widget.1-8-2"
date="2017-02-24"> date="2017-02-24">
<Change>[Task 3236] Stylesheet fix <Change>[Task 3236] Stylesheet fix</Change>
</Change>
</Changeset> </Changeset>
<Changeset component="portlets-widgets.workspace-sharing-widget.1-8-1" <Changeset component="portlets-widgets.workspace-sharing-widget.1-8-1"
date="2016-11-25"> date="2016-11-25">
<Change>Removed ASL Session dependency <Change>Removed ASL Session dependency</Change>
</Change>
</Changeset> </Changeset>
<Changeset component="portlets-widgets.workspace-sharing-widget.1-7-0" <Changeset component="portlets-widgets.workspace-sharing-widget.1-7-0"
date="2016-05-31"> date="2016-05-31">
<Change>Feature #4128: Migration to Liferay 6.2 <Change>Feature #4128: Migration to Liferay 6.2</Change>
</Change>
</Changeset> </Changeset>
<Changeset component="portlets-widgets.workspace-sharing-widget.1-6-0" <Changeset component="portlets-widgets.workspace-sharing-widget.1-6-0"
date="2016-04-14"> date="2016-04-14">
@ -21,8 +22,7 @@
</Changeset> </Changeset>
<Changeset component="portlets-widgets.workspace-sharing-widget.1-5-1" <Changeset component="portlets-widgets.workspace-sharing-widget.1-5-1"
date="2016-01-04"> date="2016-01-04">
<Change>Removed portal-framework dependecy from Etics <Change>Removed portal-framework dependecy from Etics</Change>
</Change>
</Changeset> </Changeset>
<Changeset component="portlets-widgets.workspace-sharing-widget.1-5-0" <Changeset component="portlets-widgets.workspace-sharing-widget.1-5-0"
date="2015-09-28"> date="2015-09-28">

19
pom.xml
View File

@ -14,7 +14,7 @@
<groupId>org.gcube.portlets.widgets</groupId> <groupId>org.gcube.portlets.widgets</groupId>
<artifactId>workspace-sharing-widget</artifactId> <artifactId>workspace-sharing-widget</artifactId>
<packaging>jar</packaging> <packaging>jar</packaging>
<version>1.8.3-SNAPSHOT</version> <version>1.9.0-SNAPSHOT</version>
<name>gCube Workspace Sharing Widget</name> <name>gCube Workspace Sharing Widget</name>
<description> <description>
gCube Workspace Sharing Widget allows users to share gCube Workspace items gCube Workspace Sharing Widget allows users to share gCube Workspace items
@ -33,7 +33,7 @@
<distroDirectory>distro</distroDirectory> <distroDirectory>distro</distroDirectory>
<!-- GWT needs at least java 1.6 --> <!-- GWT needs at least java 1.6 -->
<maven.compiler.source>1.7</maven.compiler.source> <maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target> <maven.compiler.target>1.8</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
@ -115,17 +115,28 @@
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<!-- StorageHub -->
<dependency>
<groupId>org.gcube.common</groupId>
<artifactId>storagehub-client-library</artifactId>
<scope>compile</scope>
</dependency>
<!-- HOME LIBRARY --> <!-- HOME LIBRARY -->
<dependency> <dependency>
<groupId>org.gcube.common</groupId> <groupId>org.gcube.common</groupId>
<artifactId>home-library-jcr</artifactId> <artifactId>home-library-jcr</artifactId>
<version>[2.0.0-SNAPSHOT, 3.0.0-SNAPSHOT)</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.gcube.common</groupId> <groupId>org.gcube.common</groupId>
<artifactId>home-library</artifactId> <artifactId>home-library</artifactId>
<version>[2.0.0-SNAPSHOT, 3.0.0-SNAPSHOT)</version> <scope>provided</scope>
</dependency>
<dependency>
<groupId>org.gcube.common</groupId>
<artifactId>home-library-model</artifactId>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>

View File

@ -4,8 +4,7 @@
package org.gcube.portlets.widgets.workspacesharingwidget.client; package org.gcube.portlets.widgets.workspacesharingwidget.client;
/** /**
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it * @author Francesco Mangiacrapa Feb 25, 2014
* @Feb 25, 2014
* *
*/ */
public interface ConstantsSharing { public interface ConstantsSharing {
@ -14,11 +13,12 @@ public interface ConstantsSharing {
public static final String SERVER_ERROR = "Sorry, an error has occurred on the server when"; public static final String SERVER_ERROR = "Sorry, an error has occurred on the server when";
public static final String TRY_AGAIN = "Try again"; public static final String TRY_AGAIN = "Try again";
public static int WIDTH_DIALOG = 530; public static int WIDTH_DIALOG = 530;
public static int HEIGHT_DIALOG = 430; public static int HEIGHT_DIALOG = 430;
public static final String PATH_SEPARATOR = "/"; public static final String PATH_SEPARATOR = "/";
public static enum LOAD_CONTACTS_AS{SHARED_USER, ADMINISTRATOR} public static enum LOAD_CONTACTS_AS {
SHARED_USER, ADMINISTRATOR
}
} }

View File

@ -5,8 +5,7 @@ package org.gcube.portlets.widgets.workspacesharingwidget.client;
/** /**
* *
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it * @author Francesco Mangiacrapa Sep 22, 2014
* @Sep 22, 2014
* *
* Defines customizable labels used by MultiDrag Dialog * Defines customizable labels used by MultiDrag Dialog
* *

View File

@ -27,13 +27,11 @@ import com.extjs.gxt.ui.client.widget.MessageBox;
import com.google.gwt.core.shared.GWT; import com.google.gwt.core.shared.GWT;
import com.google.gwt.user.client.rpc.AsyncCallback; import com.google.gwt.user.client.rpc.AsyncCallback;
/** /**
* *
* A dialog to drag and edit permissions of a workspace folder * A dialog to drag and edit permissions of a workspace folder
* *
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it * @author Francesco Mangiacrapa Jan 27, 2015
* @Jan 27, 2015
* *
*/ */
public class MultiDragContactsEditPermissions { public class MultiDragContactsEditPermissions {
@ -44,20 +42,18 @@ public class MultiDragContactsEditPermissions {
private UserStore userStore = new UserStore(); private UserStore userStore = new UserStore();
private ConstantsSharing.LOAD_CONTACTS_AS loadContactAs; private ConstantsSharing.LOAD_CONTACTS_AS loadContactAs;
private DialogMultiDragContact dialogMultiDragContact = new DialogMultiDragContact(MultiDragConstants.HEADING_DIALOG, MultiDragConstants.ALL_CONTACTS_LEFT_LIST, MultiDragConstants.SHARE_WITH_RIGHT_LIST,false, false); private DialogMultiDragContact dialogMultiDragContact = new DialogMultiDragContact(
MultiDragConstants.HEADING_DIALOG, MultiDragConstants.ALL_CONTACTS_LEFT_LIST,
MultiDragConstants.SHARE_WITH_RIGHT_LIST, false, false);
private List<InfoContactModel> sources = new ArrayList<InfoContactModel>(); private List<InfoContactModel> sources = new ArrayList<InfoContactModel>();
private boolean hiddenMySelf; private boolean hiddenMySelf;
private String workspaceItemId; private String workspaceItemId;
private String myLogin; private String myLogin;
private InfoContactModel myContact; private InfoContactModel myContact;
/**
* public MultiDragContactsEditPermissions(ConstantsSharing.LOAD_CONTACTS_AS load, final String workspaceItemId,
* @param load boolean hiddenMySelf) {
* @param workspaceItemId
* @param hiddenMySelf
*/
public MultiDragContactsEditPermissions(ConstantsSharing.LOAD_CONTACTS_AS load, final String workspaceItemId, boolean hiddenMySelf) {
initMultiDrag(load, workspaceItemId, hiddenMySelf); initMultiDrag(load, workspaceItemId, hiddenMySelf);
// dialog = super.getDialogMultiDragContact(); // dialog = super.getDialogMultiDragContact();
@ -72,11 +68,11 @@ public class MultiDragContactsEditPermissions {
lcCurrentPermissions.add(htmlCurrentPermissions); lcCurrentPermissions.add(htmlCurrentPermissions);
lcCurrentPermissions.add(lcCurrentPermissions); lcCurrentPermissions.add(lcCurrentPermissions);
dialogMultiDragContact.getLcTop().add(lcCurrentPermissions); dialogMultiDragContact.getLcTop().add(lcCurrentPermissions);
// dialog.setHeight(dialog.getHeight()+100); // dialog.setHeight(dialog.getHeight()+100);
WorkspaceSharingController.rpcWorkspaceSharingService.getACLsDescriptionForSharedFolderId(workspaceItemId, new AsyncCallback<String>() { WorkspaceSharingController.rpcWorkspaceSharingService.getACLsDescriptionForSharedFolderId(workspaceItemId,
new AsyncCallback<String>() {
@Override @Override
public void onFailure(Throwable caught) { public void onFailure(Throwable caught) {
@ -142,7 +138,8 @@ public class MultiDragContactsEditPermissions {
/** /**
* The HL ID of the selected ACL * The HL ID of the selected ACL
* @return *
* @return ACL ID
*/ */
public String getSelectedAclID() { public String getSelectedAclID() {
if (permission.getSelectedACL() != null) if (permission.getSelectedACL() != null)
@ -154,7 +151,8 @@ public class MultiDragContactsEditPermissions {
/** /**
* The selected ACL * The selected ACL
* @return *
* @return Workspace ACL
*/ */
public WorkspaceACL getSelectedAcl() { public WorkspaceACL getSelectedAcl() {
if (permission.getSelectedACL() != null) if (permission.getSelectedACL() != null)
@ -166,14 +164,20 @@ public class MultiDragContactsEditPermissions {
/** /**
* Load administrators or shared users to workspace item id * Load administrators or shared users to workspace item id
*
* @param load * @param load
* if LOAD_CONTACTS_AS.SHARED_USER loads source users from Shared Users * if LOAD_CONTACTS_AS.SHARED_USER loads source users from Shared
* if LOAD_CONTACTS_AS.ADMINISTRATOR loads source users from Administrators * Users if LOAD_CONTACTS_AS.ADMINISTRATOR loads source users
* from Administrators
* *
* @param workspaceItemId * @param workspaceItemId
* @param hiddenMySelf if true the login read from ASL is hidden (so it's not removable to target users), the login returned anyway among the target users * @param hiddenMySelf
* if true the login read from ASL is hidden (so it's not
* removable to target users), the login returned anyway among
* the target users
*/ */
private void initMultiDrag(ConstantsSharing.LOAD_CONTACTS_AS load, String workspaceItemId, final boolean hiddenMySelf) { private void initMultiDrag(ConstantsSharing.LOAD_CONTACTS_AS load, String workspaceItemId,
final boolean hiddenMySelf) {
this.loadContactAs = load; this.loadContactAs = load;
this.hiddenMySelf = hiddenMySelf; this.hiddenMySelf = hiddenMySelf;
this.workspaceItemId = workspaceItemId; this.workspaceItemId = workspaceItemId;
@ -184,10 +188,9 @@ public class MultiDragContactsEditPermissions {
loadSharedContacts(); loadSharedContacts();
} }
private void loadMyLogin(final boolean loadContacts) { private void loadMyLogin(final boolean loadContacts) {
WorkspaceSharingServiceAsync.Util.getInstance().getMyLogin(new AsyncCallback<String>() { WorkspaceSharingServiceAsync.INSTANCE.getMyLogin(new AsyncCallback<String>() {
@Override @Override
public void onFailure(Throwable caught) { public void onFailure(Throwable caught) {
@ -271,10 +274,6 @@ public class MultiDragContactsEditPermissions {
} }
/**
*
* @param result
*/
private void fillMultiDrag(List<InfoContactModel> result) { private void fillMultiDrag(List<InfoContactModel> result) {
GWT.log("Filling multi-drag.."); GWT.log("Filling multi-drag..");
@ -296,18 +295,12 @@ public class MultiDragContactsEditPermissions {
public void show() { public void show() {
dialogMultiDragContact.show(); dialogMultiDragContact.show();
} }
/**
*
* @return
*/
public List<InfoContactModel> getTargetContacts() { public List<InfoContactModel> getTargetContacts() {
return dialogMultiDragContact.getMultiDrag().getTargetListContact(); return dialogMultiDragContact.getMultiDrag().getTargetListContact();
} }
/**
*
* @return
*/
public List<InfoContactModel> getTargetContactsWithMyLogin() { public List<InfoContactModel> getTargetContactsWithMyLogin() {
List<InfoContactModel> contacts = getTargetContacts(); List<InfoContactModel> contacts = getTargetContacts();

View File

@ -0,0 +1,96 @@
package org.gcube.portlets.widgets.workspacesharingwidget.client;
import org.gcube.portlets.widgets.workspacesharingwidget.client.resources.Resources;
import org.gcube.portlets.widgets.workspacesharingwidget.client.view.sharing.multisuggest.MultiDragContact;
import com.extjs.gxt.ui.client.Style.HorizontalAlignment;
import com.extjs.gxt.ui.client.Style.Scroll;
import com.extjs.gxt.ui.client.event.ButtonEvent;
import com.extjs.gxt.ui.client.event.SelectionListener;
import com.extjs.gxt.ui.client.widget.Dialog;
import com.extjs.gxt.ui.client.widget.Html;
import com.extjs.gxt.ui.client.widget.LayoutContainer;
import com.google.gwt.core.shared.GWT;
import com.google.gwt.user.client.Random;
import com.google.gwt.user.client.rpc.AsyncCallback;
public class ShowPermissionsDialog extends Dialog {
private static final int HEIGHT_DIALOG = 300;
private static final int WIDTH_DIALOG = 600;
private String headTitle;
private String itemId;
private Html htmlCurrentPermissions;
public ShowPermissionsDialog(String headTitle, String itemId) {
this.headTitle = headTitle;
this.itemId = itemId;
init();
}
private void init() {
setId(ShowPermissionsDialog.class.getName() + Random.nextInt());
setSize(WIDTH_DIALOG, HEIGHT_DIALOG);
setResizable(false);
setMaximizable(false);
setIcon(Resources.getIconUsers());
setModal(true);
setHeading(headTitle);
setButtonAlign(HorizontalAlignment.CENTER);
setButtons(Dialog.OKCANCEL);
this.getButtonById(Dialog.CANCEL).addSelectionListener(new SelectionListener<ButtonEvent>() {
@Override
public void componentSelected(ButtonEvent ce) {
hide();
}
});
this.getButtonById(Dialog.OK).addSelectionListener(new SelectionListener<ButtonEvent>() {
@Override
public void componentSelected(ButtonEvent ce) {
hide();
}
});
createCurrentPermissionPanel();
}
void createCurrentPermissionPanel() {
htmlCurrentPermissions = new Html();
LayoutContainer lcCurrentPermissions = new LayoutContainer();
htmlCurrentPermissions.setWidth(MultiDragContact.WIDTH_CP);
htmlCurrentPermissions.setStyleAttribute("padding", MultiDragContact.PADDING + "px");
lcCurrentPermissions.setScrollMode(Scroll.AUTOY);
lcCurrentPermissions.setHeight(50);
lcCurrentPermissions.add(htmlCurrentPermissions);
WorkspaceSharingController.rpcWorkspaceSharingService.getACLsDescriptionForSharedFolderId(itemId,
new AsyncCallback<String>() {
@Override
public void onFailure(Throwable caught) {
GWT.log("error getACLsDescriptionForSharedFolderId: " + caught.getMessage(), caught);
}
@Override
public void onSuccess(String result) {
String msg = "#<b>Current Permissions:</b> <br/>";
msg += result;
htmlCurrentPermissions.setHtml(msg);
}
});
add(lcCurrentPermissions);
}
public String getHeadTitle() {
return headTitle;
}
}

View File

@ -16,16 +16,18 @@ import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.rpc.AsyncCallback; import com.google.gwt.user.client.rpc.AsyncCallback;
/** /**
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it * @author Francesco Mangiacrapa Jul 30, 2014
* @Jul 30, 2014
* *
* A simple multi drag dialog to manage users (shared or administrators) of a workspace item * A simple multi drag dialog to manage users (shared or administrators)
* of a workspace item
*/ */
public class SimpleMultiDragWorkspaceContact { public class SimpleMultiDragWorkspaceContact {
private UserStore userStore = new UserStore(); private UserStore userStore = new UserStore();
private ConstantsSharing.LOAD_CONTACTS_AS loadContactAs; private ConstantsSharing.LOAD_CONTACTS_AS loadContactAs;
private DialogMultiDragContact dialogMultiDragContact = new DialogMultiDragContact(MultiDragConstants.HEADING_DIALOG, MultiDragConstants.ALL_CONTACTS_LEFT_LIST, MultiDragConstants.SHARE_WITH_RIGHT_LIST,false, false); private DialogMultiDragContact dialogMultiDragContact = new DialogMultiDragContact(
MultiDragConstants.HEADING_DIALOG, MultiDragConstants.ALL_CONTACTS_LEFT_LIST,
MultiDragConstants.SHARE_WITH_RIGHT_LIST, false, false);
private List<InfoContactModel> targets = new ArrayList<InfoContactModel>(); private List<InfoContactModel> targets = new ArrayList<InfoContactModel>();
private boolean readGroupsFromPortal; private boolean readGroupsFromPortal;
private boolean readGroupsFromHL; private boolean readGroupsFromHL;
@ -36,16 +38,25 @@ public class SimpleMultiDragWorkspaceContact {
/** /**
* Load administrators or shared users to workspace item id * Load administrators or shared users to workspace item id
*
* @param load * @param load
* if LOAD_CONTACTS_AS.SHARED_USER loads target users from Shared Users * if LOAD_CONTACTS_AS.SHARED_USER loads target users from Shared
* if LOAD_CONTACTS_AS.ADMINISTRATOR loads target users from Administrators * Users if LOAD_CONTACTS_AS.ADMINISTRATOR loads target users
* from Administrators
* *
* @param workspaceItemId * @param workspaceItemId
* Item id
* @param readGroupsFromHL * @param readGroupsFromHL
* Groups
* @param readGroupsFromPortal * @param readGroupsFromPortal
* @param hiddenMySelf if true the login read from ASL is hidden (so it's not removable to target users), the login returned anyway among the target users * Portal
* @param hiddenMySelf
* if true the login read from ASL is hidden (so it's not
* removable to target users), the login returned anyway among
* the target users
*/ */
public SimpleMultiDragWorkspaceContact(ConstantsSharing.LOAD_CONTACTS_AS load, String workspaceItemId, final boolean readGroupsFromHL, final boolean readGroupsFromPortal, final boolean hiddenMySelf) { public SimpleMultiDragWorkspaceContact(ConstantsSharing.LOAD_CONTACTS_AS load, String workspaceItemId,
final boolean readGroupsFromHL, final boolean readGroupsFromPortal, final boolean hiddenMySelf) {
this.loadContactAs = load; this.loadContactAs = load;
this.readGroupsFromHL = readGroupsFromHL; this.readGroupsFromHL = readGroupsFromHL;
this.readGroupsFromPortal = readGroupsFromPortal; this.readGroupsFromPortal = readGroupsFromPortal;
@ -58,10 +69,9 @@ public class SimpleMultiDragWorkspaceContact {
loadSharedContacts(); loadSharedContacts();
} }
private void loadMyLogin(final boolean loadContacts) { private void loadMyLogin(final boolean loadContacts) {
WorkspaceSharingServiceAsync.Util.getInstance().getMyLogin(new AsyncCallback<String>() { WorkspaceSharingServiceAsync.INSTANCE.getMyLogin(new AsyncCallback<String>() {
@Override @Override
public void onFailure(Throwable caught) { public void onFailure(Throwable caught) {
@ -147,10 +157,7 @@ public class SimpleMultiDragWorkspaceContact {
} }
/**
*
* @param result
*/
private void fillMultiDrag(List<InfoContactModel> result) { private void fillMultiDrag(List<InfoContactModel> result) {
GWT.log("Filling multi-drag.."); GWT.log("Filling multi-drag..");
@ -171,8 +178,6 @@ public class SimpleMultiDragWorkspaceContact {
/** /**
* Load all contacts * Load all contacts
* @param readGroupsFromHL
* @param readGroupsFromPortal
*/ */
private void loadAllContacts(boolean readGroupsFromHL, boolean readGroupsFromPortal) { private void loadAllContacts(boolean readGroupsFromHL, boolean readGroupsFromPortal) {
userStore.getListContact(addSourceContacts, false, readGroupsFromHL, readGroupsFromPortal); userStore.getListContact(addSourceContacts, false, readGroupsFromHL, readGroupsFromPortal);
@ -209,22 +214,15 @@ public class SimpleMultiDragWorkspaceContact {
return dialogMultiDragContact; return dialogMultiDragContact;
} }
public void show() { public void show() {
dialogMultiDragContact.show(); dialogMultiDragContact.show();
} }
/**
*
* @return
*/
public List<InfoContactModel> getTargetContacts() { public List<InfoContactModel> getTargetContacts() {
return dialogMultiDragContact.getMultiDrag().getTargetListContact(); return dialogMultiDragContact.getMultiDrag().getTargetListContact();
} }
/**
*
* @return
*/
public List<InfoContactModel> getTargetContactsWithMyLogin() { public List<InfoContactModel> getTargetContactsWithMyLogin() {
List<InfoContactModel> contacts = getTargetContacts(); List<InfoContactModel> contacts = getTargetContacts();

View File

@ -4,8 +4,7 @@
package org.gcube.portlets.widgets.workspacesharingwidget.client; package org.gcube.portlets.widgets.workspacesharingwidget.client;
/** /**
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it * @author Francesco Mangiacrapa Jul 8, 2014
* @Jul 8, 2014
* *
* Defines customizable labels used by Smart Sharing Dialog * Defines customizable labels used by Smart Sharing Dialog
* *
@ -15,7 +14,9 @@ public abstract class SmartConstants {
public static String ITEM_NAME = "Item Name"; public static String ITEM_NAME = "Item Name";
public static String SHARE_WITH_USERS = "Share with users"; public static String SHARE_WITH_USERS = "Share with users";
public static String HEADER_TITLE = null; //if null sets the header title for the panel as "Share [Folder Name]" public static String HEADER_TITLE = null; // if null sets the header title
// for the panel as "Share
// [Folder Name]"
public static String ADD_MORE = "Add More"; public static String ADD_MORE = "Add More";
public static String ERROR_NO_USER_SELECTED = "You must pick at least one user with which share the folder"; public static String ERROR_NO_USER_SELECTED = "You must pick at least one user with which share the folder";

View File

@ -18,13 +18,13 @@ import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.rpc.AsyncCallback; import com.google.gwt.user.client.rpc.AsyncCallback;
/** /**
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it * @author Francesco Mangiacrapa Feb 25, 2014
* @Feb 25, 2014
* *
*/ */
public class WorkspaceSharingController { public class WorkspaceSharingController {
public static final WorkspaceSharingServiceAsync rpcWorkspaceSharingService = (WorkspaceSharingServiceAsync) GWT.create(WorkspaceSharingService.class); public static final WorkspaceSharingServiceAsync rpcWorkspaceSharingService = (WorkspaceSharingServiceAsync) GWT
.create(WorkspaceSharingService.class);
private static String myLogin; private static String myLogin;
@ -36,16 +36,21 @@ public class WorkspaceSharingController {
private DialogShareWItem sharingDialog = null; private DialogShareWItem sharingDialog = null;
private boolean readGroupsFromHL; // private boolean readGroupsFromHL;
private boolean readGroupsFromPortal;
// private boolean readGroupsFromPortal;
/** /**
* This controller instancing sharing dialog * This controller instancing sharing dialog
* @param itemId workspace item id *
* @param if true, only owner can share, otherwise an alert with an error message is displayed * @param itemId
* @param defaultPermission ACL_TYPE default permission, if is null default ACL_TYPE is loaded from server * workspace item id
* @param shareOnlyOwner
* true if only owner can share, otherwise an alert with an error
* message is displayed
* @param defaultPermission
* ACL_TYPE default permission, if is null default ACL_TYPE is
* loaded from server
* *
* base constructor by default does not retrieve the groups * base constructor by default does not retrieve the groups
*/ */
@ -55,19 +60,27 @@ public class WorkspaceSharingController {
/** /**
* This controller instancing sharing dialog * This controller instancing sharing dialog
* @param itemId workspace item id *
* @param if true, only owner can share, otherwise an alert with an error message is displayed * @param itemId
* @param defaultPermission ACL_TYPE default permission, if is null default ACL_TYPE is loaded from server * workspace item id
* @param readGroupsFromHL - if true, read group names from HL * @param shareOnlyOwner
* @param readGroupsFromPortal - if true, read group names from Portal (as VRE) * true if only owner can share, otherwise an alert with an error
* message is displayed
* @param defaultPermission
* ACL_TYPE default permission, if is null default ACL_TYPE is
* loaded from server
* @param readGroupsFromHL
* true if read group names from HL
* @param readGroupsFromPortal
* true if read group names from Portal (as VRE)
*/ */
public WorkspaceSharingController(String itemId, boolean shareOnlyOwner, ACL_TYPE defaultPermission, boolean readGroupsFromHL, boolean readGroupsFromPortal) { public WorkspaceSharingController(String itemId, boolean shareOnlyOwner, ACL_TYPE defaultPermission,
boolean readGroupsFromHL, boolean readGroupsFromPortal) {
this.workspaceItemId = itemId; this.workspaceItemId = itemId;
this.shareOnlyOwner = shareOnlyOwner; this.shareOnlyOwner = shareOnlyOwner;
this.defaultPermission = defaultPermission; this.defaultPermission = defaultPermission;
this.readGroupsFromHL = readGroupsFromHL; // this.readGroupsFromHL = readGroupsFromHL;
this.readGroupsFromPortal = readGroupsFromPortal; // this.readGroupsFromPortal = readGroupsFromPortal;
if (workspaceItemId == null || workspaceItemId.isEmpty()) { if (workspaceItemId == null || workspaceItemId.isEmpty()) {
MessageBox.alert("Error", "Item id is null or empty", null); MessageBox.alert("Error", "Item id is null or empty", null);
@ -78,8 +91,6 @@ public class WorkspaceSharingController {
sharingDialog.setSize(ConstantsSharing.WIDTH_DIALOG + 20, ConstantsSharing.HEIGHT_DIALOG + 20); sharingDialog.setSize(ConstantsSharing.WIDTH_DIALOG + 20, ConstantsSharing.HEIGHT_DIALOG + 20);
sharingDialog.mask("Loading item information from Workspace", ConstantsSharing.LOADINGSTYLE); sharingDialog.mask("Loading item information from Workspace", ConstantsSharing.LOADINGSTYLE);
if (shareOnlyOwner) { if (shareOnlyOwner) {
loadMyLogin(true, true); loadMyLogin(true, true);
} else { } else {
@ -109,11 +120,8 @@ public class WorkspaceSharingController {
}); });
} }
private void addListenersSharingDialog() { private void addListenersSharingDialog() {
sharingDialog.getButtonById(Dialog.OK).addSelectionListener(new SelectionListener<ButtonEvent>() { sharingDialog.getButtonById(Dialog.OK).addSelectionListener(new SelectionListener<ButtonEvent>() {
@Override @Override
@ -124,25 +132,35 @@ public class WorkspaceSharingController {
FileModel fileModel = sharingDialog.getFileToShare(); FileModel fileModel = sharingDialog.getFileToShare();
// create a lowest object to send to server // create a lowest object to send to server
fileModel = new FileModel(fileModel.getIdentifier(), fileModel.getName(), fileModel.getParentFileModel(), fileModel.isDirectory(), fileModel.isShared()); fileModel = new FileModel(fileModel.getIdentifier(), fileModel.getName(),
fileModel.getDescription(), fileModel.getParentFileModel(), fileModel.isDirectory(),
fileModel.isShared());
fileModel.setDescription(sharingDialog.getDescription()); fileModel.setDescription(sharingDialog.getDescription());
// DEBUG // DEBUG
/* /*
System.out.println("FileModel id "+fileModel.getIdentifier() + " name: "+fileModel.getName() + " parent " + fileModel.getParentFileModel()); * System.out.println("FileModel id "+fileModel.
for(InfoContactModel contact:finalDialog.getSharedListUsers() ){ * getIdentifier() + " name: "+fileModel.getName() +
System.out.println("Share with Contact "+contact) ; * " parent " + fileModel.getParentFileModel());
* for(InfoContactModel
}*/ * contact:finalDialog.getSharedListUsers() ){
* System.out.println("Share with Contact "+contact) ;
*
* }
*/
GWT.log("ACL selected is " + sharingDialog.getSelectedACL()); GWT.log("ACL selected is " + sharingDialog.getSelectedACL());
final String itemName = fileModel.getName(); final String itemName = fileModel.getName();
sharingDialog.mask("Sharing and setting permissions", ConstantsSharing.LOADINGSTYLE); sharingDialog.mask("Sharing and setting permissions", ConstantsSharing.LOADINGSTYLE);
rpcWorkspaceSharingService.shareFolder(fileModel, sharingDialog.getSharedListUsers(), false, sharingDialog.getSelectedACL(), new AsyncCallback<Boolean>() { rpcWorkspaceSharingService.shareFolder(fileModel.getIdentifier(), fileModel.getName(),
fileModel.getDescription(),
fileModel.getParentFileModel() != null ? fileModel.getParentFileModel().getIdentifier()
: null,
sharingDialog.getSharedListUsers(), false, sharingDialog.getSelectedACL(),
new AsyncCallback<Boolean>() {
@Override @Override
public void onFailure(Throwable caught) { public void onFailure(Throwable caught) {
@ -174,10 +192,6 @@ public class WorkspaceSharingController {
}); });
} }
/**
*
* @param fileModel
*/
private void updateSharingDialog(FileModel fileModel) { private void updateSharingDialog(FileModel fileModel) {
sharingDialog.updateSharingDialog(fileModel, shareOnlyOwner, defaultPermission); sharingDialog.updateSharingDialog(fileModel, shareOnlyOwner, defaultPermission);
sharingDialog.unmask(); sharingDialog.unmask();
@ -186,11 +200,6 @@ public class WorkspaceSharingController {
sharingDialog.layout(); sharingDialog.layout();
} }
/**
*
* @param loadFileModel
* @param showSharingDialog
*/
private void loadMyLogin(final boolean loadFileModel, final boolean showSharingDialog) { private void loadMyLogin(final boolean loadFileModel, final boolean showSharingDialog) {
rpcWorkspaceSharingService.getMyLogin(new AsyncCallback<String>() { rpcWorkspaceSharingService.getMyLogin(new AsyncCallback<String>() {
@ -221,21 +230,14 @@ public class WorkspaceSharingController {
return workspaceItemId; return workspaceItemId;
} }
public boolean isShareOnlyOwner() { public boolean isShareOnlyOwner() {
return shareOnlyOwner; return shareOnlyOwner;
} }
public ACL_TYPE getDefaultPermission() { public ACL_TYPE getDefaultPermission() {
return defaultPermission; return defaultPermission;
} }
/**
*
* @return gxt 2.2.5 Dialog
*/
public Dialog getSharingDialog() { public Dialog getSharingDialog() {
return sharingDialog; return sharingDialog;
} }

View File

@ -20,65 +20,62 @@ public class WorkspaceSharingWidgetEntryPoint implements EntryPoint {
try { try {
/*
/*WorkspaceSharingController controller = new WorkspaceSharingController(ITEMID, true, ACL_TYPE.READ_ONLY); * WorkspaceSharingController controller = new
* WorkspaceSharingController(ITEMID, true, ACL_TYPE.READ_ONLY);
final Window sharingWindow = controller.getSharingDialog(); *
* final Window sharingWindow = controller.getSharingDialog();
Button openSharingWindow = new Button("Show Sharing Window", *
new ClickHandler() { * Button openSharingWindow = new Button("Show Sharing Window", new
public void onClick(ClickEvent event) { * ClickHandler() { public void onClick(ClickEvent event) {
*
sharingWindow.show(); * sharingWindow.show(); } });
} *
}); * RootPanel.get("workpacesharingwidget").add(openSharingWindow);
*
RootPanel.get("workpacesharingwidget").add(openSharingWindow);
*/ */
/*FileModel file = new FileModel("123", "test", false); /*
WorkspaceSmartSharingController controller = new WorkspaceSmartSharingController(file, null, false, false); * FileModel file = new FileModel("123", "test", false);
* WorkspaceSmartSharingController controller = new
SmartConstants.HEADER_TITLE = "puppa"; * WorkspaceSmartSharingController(file, null, false, false);
SmartConstants.ITEM_NAME = "aa"; *
* SmartConstants.HEADER_TITLE = "puppa"; SmartConstants.ITEM_NAME =
final SmartShare sharingWindow = controller.getSharingDialog(); * "aa";
Button openSharingWindow = new Button("Show Smart Share Window", *
new ClickHandler() { * final SmartShare sharingWindow = controller.getSharingDialog();
public void onClick(ClickEvent event) { * Button openSharingWindow = new Button("Show Smart Share Window",
* new ClickHandler() { public void onClick(ClickEvent event) {
sharingWindow.show(); *
} * sharingWindow.show(); } });
}); *
* RootPanel.get("workpacesharingwidget").add(openSharingWindow);
RootPanel.get("workpacesharingwidget").add(openSharingWindow); *
* sharingWindow.getButtonById(Dialog.OK).addListener(Events.Select,
sharingWindow.getButtonById(Dialog.OK).addListener(Events.Select, new Listener<BaseEvent>() { * new Listener<BaseEvent>() {
*
@Override * @Override public void handleEvent(BaseEvent be) {
public void handleEvent(BaseEvent be) { *
* if(sharingWindow.isValidForm(true)){ //THAT'S OK
if(sharingWindow.isValidForm(true)){ *
//THAT'S OK * sharingWindow.getSharedListUsers(); //@return the selected
* contacts (as InfoContactModel)
sharingWindow.getSharedListUsers(); //@return the selected contacts (as InfoContactModel) *
* sharingWindow.getSharedListUsersCredential(); //@return the
sharingWindow.getSharedListUsersCredential(); //@return the selected contacts (as CredentialModel) * selected contacts (as CredentialModel)
*
for (InfoContactModel contact : sharingWindow.getSharedListUsers()) { * for (InfoContactModel contact :
System.out.println(contact); * sharingWindow.getSharedListUsers()) {
} * System.out.println(contact); }
*
for (CredentialModel credential : sharingWindow.getSharedListUsersCredential()) { * for (CredentialModel credential :
System.out.println(credential); * sharingWindow.getSharedListUsersCredential()) {
} * System.out.println(credential); }
*
} * }
*
} * } });
}); *
*/ */
showSimpleMultiDrag(); showSimpleMultiDrag();
@ -90,10 +87,10 @@ public class WorkspaceSharingWidgetEntryPoint implements EntryPoint {
private void showSimpleMultiDrag() { private void showSimpleMultiDrag() {
final SimpleMultiDragWorkspaceContact multiDragContact = new SimpleMultiDragWorkspaceContact(ConstantsSharing.LOAD_CONTACTS_AS.SHARED_USER, ITEMID, true, false, true); final SimpleMultiDragWorkspaceContact multiDragContact = new SimpleMultiDragWorkspaceContact(
ConstantsSharing.LOAD_CONTACTS_AS.SHARED_USER, ITEMID, true, false, true);
Button openSharingWindow = new Button("Show Simple Multi Drag", Button openSharingWindow = new Button("Show Simple Multi Drag", new ClickHandler() {
new ClickHandler() {
public void onClick(ClickEvent event) { public void onClick(ClickEvent event) {
multiDragContact.getDialogMultiDragContact().show(); multiDragContact.getDialogMultiDragContact().show();

View File

@ -18,13 +18,13 @@ import com.extjs.gxt.ui.client.widget.Dialog;
import com.google.gwt.core.client.GWT; import com.google.gwt.core.client.GWT;
/** /**
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it * @author Francesco Mangiacrapa Feb 25, 2014
* @Feb 25, 2014
* *
*/ */
public class WorkspaceSmartSharingController { public class WorkspaceSmartSharingController {
public static final WorkspaceSharingServiceAsync rpcWorkspaceSharingService = (WorkspaceSharingServiceAsync) GWT.create(WorkspaceSharingService.class); public static final WorkspaceSharingServiceAsync rpcWorkspaceSharingService = (WorkspaceSharingServiceAsync) GWT
.create(WorkspaceSharingService.class);
private SmartShare smartShare = null; private SmartShare smartShare = null;
@ -36,11 +36,13 @@ public class WorkspaceSmartSharingController {
private boolean readGroupsFromPortal; private boolean readGroupsFromPortal;
/** /**
* *
* @param file - a fake file to display the field name ("filename") into dialog * @param file
* @param listAlreadySharedContact - list of already shared contacts to show into dialog * - a fake file to display the field name ("filename") into
* dialog
* @param listAlreadySharedContact
* - list of already shared contacts to show into dialog
* *
* base constructor by default does not retrieve the groups * base constructor by default does not retrieve the groups
* *
@ -51,13 +53,19 @@ public class WorkspaceSmartSharingController {
/** /**
* *
* @param file - a fake file to display the field name ("filename") into dialog * @param file
* @param listAlreadySharedContact - list of already shared contacts to show into dialog * - a fake file to display the field name ("filename") into
* @param readGroupsFromHL - if true, read group names from HL * dialog
* @param readGroupsFromPortal - if true, read group names from Portal (as VRE) * @param listAlreadySharedContact
* - list of already shared contacts to show into dialog
* @param readGroupsFromHL
* - if true, read group names from HL
* @param readGroupsFromPortal
* - if true, read group names from Portal (as VRE)
* *
*/ */
public WorkspaceSmartSharingController(FileModel file, List<CredentialModel> listAlreadySharedContact, boolean readGroupsFromHL, boolean readGroupsFromPortal) { public WorkspaceSmartSharingController(FileModel file, List<CredentialModel> listAlreadySharedContact,
boolean readGroupsFromHL, boolean readGroupsFromPortal) {
this.listAlreadySharedContact = listAlreadySharedContact; this.listAlreadySharedContact = listAlreadySharedContact;
this.fileModel = file; this.fileModel = file;
this.readGroupsFromHL = readGroupsFromHL; this.readGroupsFromHL = readGroupsFromHL;
@ -68,7 +76,6 @@ public class WorkspaceSmartSharingController {
addListenersSharingDialog(); addListenersSharingDialog();
} }
/** /**
* Example of listeners * Example of listeners
*/ */
@ -82,15 +89,19 @@ public class WorkspaceSmartSharingController {
// if(smartShare.isValidForm(true)){ // if(smartShare.isValidForm(true)){
// //THAT'S OK // //THAT'S OK
// //
// smartShare.getSharedListUsers(); //@return the selected contacts (as InfoContactModel) // smartShare.getSharedListUsers(); //@return the selected
// contacts (as InfoContactModel)
// //
// smartShare.getSharedListUsersCredential(); //@return tthe selected contacts (as CredentialModel) // smartShare.getSharedListUsersCredential(); //@return tthe
// selected contacts (as CredentialModel)
// //
// for (InfoContactModel contact : smartShare.getSharedListUsers()) { // for (InfoContactModel contact :
// smartShare.getSharedListUsers()) {
// System.out.println(contact); // System.out.println(contact);
// } // }
// //
// for (CredentialModel credential : smartShare.getSharedListUsersCredential()) { // for (CredentialModel credential :
// smartShare.getSharedListUsersCredential()) {
// System.out.println(credential); // System.out.println(credential);
// } // }
// //

View File

@ -5,7 +5,7 @@ import com.extjs.gxt.ui.client.event.MessageBoxEvent;
import com.extjs.gxt.ui.client.widget.MessageBox; import com.extjs.gxt.ui.client.widget.MessageBox;
/** /**
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it * @author Francesco Mangiacrapa
* *
*/ */
public class MessageBoxAlert { public class MessageBoxAlert {

View File

@ -9,8 +9,8 @@ import com.google.gwt.user.client.ui.AbstractImagePrototype;
/** /**
* *
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it * @author Francesco Mangiacrapa
* @Feb 25, 2014 * Feb 25, 2014
* *
*/ */
public class GetPermissionIconByACL { public class GetPermissionIconByACL {

View File

@ -26,39 +26,21 @@ public interface Icons extends ClientBundle {
@Source("share.png") @Source("share.png")
ImageResource share(); ImageResource share();
/**
* @return
*/
@Source("shareuser.png") @Source("shareuser.png")
ImageResource user(); ImageResource user();
/**
* @return
*/
@Source("sharegroup.png") @Source("sharegroup.png")
ImageResource group(); ImageResource group();
/**
* @return
*/
@Source("aoneleft.png") @Source("aoneleft.png")
ImageResource selectedLeft(); ImageResource selectedLeft();
/**
* @return
*/
@Source("aoneright.png") @Source("aoneright.png")
ImageResource selectedRight(); ImageResource selectedRight();
/**
* @return
*/
@Source("amoreleft.png") @Source("amoreleft.png")
ImageResource allLeft(); ImageResource allLeft();
/**
* @return
*/
@Source("amoreright.png") @Source("amoreright.png")
ImageResource allRight(); ImageResource allRight();
} }

View File

@ -5,8 +5,7 @@ import com.google.gwt.user.client.ui.AbstractImagePrototype;
/** /**
* *
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it * @author Francesco Mangiacrapa Feb 25, 2014
* @Feb 25, 2014
* *
*/ */
public class Resources { public class Resources {
@ -39,23 +38,14 @@ public class Resources {
return AbstractImagePrototype.create(ICONS.info()); return AbstractImagePrototype.create(ICONS.info());
} }
/**
* @return
*/
public static AbstractImagePrototype getIconShare() { public static AbstractImagePrototype getIconShare() {
return AbstractImagePrototype.create(ICONS.share()); return AbstractImagePrototype.create(ICONS.share());
} }
/**
* @return
*/
public static AbstractImagePrototype getIconUser() { public static AbstractImagePrototype getIconUser() {
return AbstractImagePrototype.create(ICONS.user()); return AbstractImagePrototype.create(ICONS.user());
} }
/**
* @return
*/
public static AbstractImagePrototype getIconGroup() { public static AbstractImagePrototype getIconGroup() {
return AbstractImagePrototype.create(ICONS.group()); return AbstractImagePrototype.create(ICONS.group());
} }

View File

@ -2,9 +2,12 @@ package org.gcube.portlets.widgets.workspacesharingwidget.client.rpc;
import java.util.List; import java.util.List;
import org.gcube.portlets.widgets.workspacesharingwidget.shared.AllowAccess;
import org.gcube.portlets.widgets.workspacesharingwidget.shared.CredentialModel; import org.gcube.portlets.widgets.workspacesharingwidget.shared.CredentialModel;
import org.gcube.portlets.widgets.workspacesharingwidget.shared.ExtendedWorkspaceACL;
import org.gcube.portlets.widgets.workspacesharingwidget.shared.FileModel; import org.gcube.portlets.widgets.workspacesharingwidget.shared.FileModel;
import org.gcube.portlets.widgets.workspacesharingwidget.shared.InfoContactModel; import org.gcube.portlets.widgets.workspacesharingwidget.shared.InfoContactModel;
import org.gcube.portlets.widgets.workspacesharingwidget.shared.ReportAssignmentACL;
import org.gcube.portlets.widgets.workspacesharingwidget.shared.WorkspaceACL; import org.gcube.portlets.widgets.workspacesharingwidget.shared.WorkspaceACL;
import com.google.gwt.user.client.rpc.RemoteService; import com.google.gwt.user.client.rpc.RemoteService;
@ -16,76 +19,46 @@ import com.google.gwt.user.client.rpc.RemoteServiceRelativePath;
@RemoteServiceRelativePath("workspacesharing") @RemoteServiceRelativePath("workspacesharing")
public interface WorkspaceSharingService extends RemoteService { public interface WorkspaceSharingService extends RemoteService {
List<InfoContactModel> getAllContacts(boolean readGroupsFromHL, AllowAccess accessToFolderLink(String itemId) throws Exception;
boolean readGroupsFromPortal) throws Exception;
/** List<InfoContactModel> getAllContacts() throws Exception;
* @param folderSharedId
* @return List<InfoContactModel> getListUserSharedByFolderSharedId(String folderSharedId) throws Exception;
* @throws Exception
*/
List<InfoContactModel> getListUserSharedByFolderSharedId(
String folderSharedId) throws Exception;
/**
* @param itemId
* @return
* @throws Exception
*/
InfoContactModel getOwnerByItemId(String itemId) throws Exception; InfoContactModel getOwnerByItemId(String itemId) throws Exception;
/**
* @return
* @throws Exception
*/
List<WorkspaceACL> getACLs() throws Exception; List<WorkspaceACL> getACLs() throws Exception;
/** String getMyLogin() throws Exception;
* @return
*/
String getMyLogin();
/**
* @param itemId
* @return
* @throws Exception
*/
FileModel getFileModelByWorkpaceItemId(String itemId) throws Exception; FileModel getFileModelByWorkpaceItemId(String itemId) throws Exception;
/**
* @return
* @throws Exception
*/
boolean isSessionExpired() throws Exception; boolean isSessionExpired() throws Exception;
/** boolean shareFolder(String id, String name, String description, String parentId,
* @param folder List<InfoContactModel> listContacts, boolean isNewFolder, WorkspaceACL acl) throws Exception;
* @param listContacts
* @param isNewFolder
* @param acl
* @return
* @throws Exception
*/
boolean shareFolder(FileModel folder, List<InfoContactModel> listContacts,
boolean isNewFolder, WorkspaceACL acl) throws Exception;
/** List<InfoContactModel> getInfoContactModelsFromCredential(List<CredentialModel> listAlreadySharedContact)
* @param listAlreadySharedContact throws Exception;
* @return
* @throws Exception
*/
List<InfoContactModel> getInfoContactModelsFromCredential(List<CredentialModel> listAlreadySharedContact) throws Exception;
List<InfoContactModel> getAdministratorsByFolderId(String sharedFolderId) throws Exception; List<InfoContactModel> getAdministratorsByFolderId(String sharedFolderId) throws Exception;
WorkspaceACL getACLsForSharedFolderId(String itemID) throws Exception; WorkspaceACL getACLsForSharedFolderId(String itemID) throws Exception;
/** String getACLsDescriptionForSharedFolderId(String folderId) throws Exception;
* @param folderId
* @return boolean unSharedFolderByFolderSharedId(String folderId) throws Exception;
* @throws Exception
*/ List<ExtendedWorkspaceACL> getUserACLForFolderId(String folderId) throws Exception;
String getACLsDescriptionForSharedFolderId(String folderId)
throws Exception; String getACLsDescriptionForWorkspaceItemById(String workspaceItemId) throws Exception;
void setACLs(String folderId, List<String> listLogins, String aclType) throws Exception;
void updateACLForVREbyGroupName(String folderId, String aclType) throws Exception;
ReportAssignmentACL validateACLToUser(String folderId, List<String> listLogins, String aclType) throws Exception;
boolean addAdministratorsByFolderId(String itemId, List<String> listContactLogins) throws Exception;
} }

View File

@ -2,90 +2,63 @@ package org.gcube.portlets.widgets.workspacesharingwidget.client.rpc;
import java.util.List; import java.util.List;
import org.gcube.portlets.widgets.workspacesharingwidget.shared.AllowAccess;
import org.gcube.portlets.widgets.workspacesharingwidget.shared.CredentialModel; import org.gcube.portlets.widgets.workspacesharingwidget.shared.CredentialModel;
import org.gcube.portlets.widgets.workspacesharingwidget.shared.ExtendedWorkspaceACL;
import org.gcube.portlets.widgets.workspacesharingwidget.shared.FileModel; import org.gcube.portlets.widgets.workspacesharingwidget.shared.FileModel;
import org.gcube.portlets.widgets.workspacesharingwidget.shared.InfoContactModel; import org.gcube.portlets.widgets.workspacesharingwidget.shared.InfoContactModel;
import org.gcube.portlets.widgets.workspacesharingwidget.shared.ReportAssignmentACL;
import org.gcube.portlets.widgets.workspacesharingwidget.shared.WorkspaceACL; import org.gcube.portlets.widgets.workspacesharingwidget.shared.WorkspaceACL;
import com.google.gwt.core.client.GWT; import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.rpc.AsyncCallback; import com.google.gwt.user.client.rpc.AsyncCallback;
public interface WorkspaceSharingServiceAsync public interface WorkspaceSharingServiceAsync {
{
/** public static WorkspaceSharingServiceAsync INSTANCE = (WorkspaceSharingServiceAsync) GWT
* Utility class to get the RPC Async interface from client-side code .create(WorkspaceSharingService.class);
*/
public static final class Util
{
private static WorkspaceSharingServiceAsync instance;
public static final WorkspaceSharingServiceAsync getInstance() void getAllContacts(AsyncCallback<List<InfoContactModel>> callback);
{
if ( instance == null )
{
instance = (WorkspaceSharingServiceAsync) GWT.create( WorkspaceSharingService.class );
}
return instance;
}
private Util() void getListUserSharedByFolderSharedId(String folderSharedId, AsyncCallback<List<InfoContactModel>> callback);
{
// Utility class should not be instanciated
}
}
void getAllContacts(boolean readGroupsFromHL, boolean readGroupsFromPortal, AsyncCallback<List<InfoContactModel>> callback);
void getListUserSharedByFolderSharedId(String folderSharedId,
AsyncCallback<List<InfoContactModel>> callback);
void getOwnerByItemId(String itemId,
AsyncCallback<InfoContactModel> callback);
void getOwnerByItemId(String itemId, AsyncCallback<InfoContactModel> callback);
void getACLs(AsyncCallback<List<WorkspaceACL>> callback); void getACLs(AsyncCallback<List<WorkspaceACL>> callback);
void getMyLogin(AsyncCallback<String> callback); void getMyLogin(AsyncCallback<String> callback);
void getFileModelByWorkpaceItemId(String itemId, AsyncCallback<FileModel> callback);
void getFileModelByWorkpaceItemId(String itemId,
AsyncCallback<FileModel> callback);
void isSessionExpired(AsyncCallback<Boolean> callback); void isSessionExpired(AsyncCallback<Boolean> callback);
void shareFolder(String id, String name, String description, String parentId, List<InfoContactModel> listContacts,
boolean isNewFolder, WorkspaceACL acl, AsyncCallback<Boolean> callback);
void shareFolder(FileModel folder, List<InfoContactModel> listContacts, void getInfoContactModelsFromCredential(List<CredentialModel> listAlreadySharedContact,
boolean isNewFolder, WorkspaceACL acl,
AsyncCallback<Boolean> callback);
void getInfoContactModelsFromCredential(
List<CredentialModel> listAlreadySharedContact,
AsyncCallback<List<InfoContactModel>> callback); AsyncCallback<List<InfoContactModel>> callback);
/**
* @param sharedFolderId
*/
void getAdministratorsByFolderId(String sharedFolderId, AsyncCallback<List<InfoContactModel>> callback); void getAdministratorsByFolderId(String sharedFolderId, AsyncCallback<List<InfoContactModel>> callback);
void getACLsForSharedFolderId(String itemID, AsyncCallback<WorkspaceACL> asyncCallback);
/** void getACLsDescriptionForSharedFolderId(String folderId, AsyncCallback<String> callback);
* @param itemID
* @param asyncCallback
*/
void getACLsForSharedFolderId(String itemID,
AsyncCallback<WorkspaceACL> asyncCallback);
void unSharedFolderByFolderSharedId(String folderId, AsyncCallback<Boolean> asyncCallback);
void getACLsDescriptionForSharedFolderId(String folderId, void getUserACLForFolderId(String folderId, AsyncCallback<List<ExtendedWorkspaceACL>> callback);
AsyncCallback<String> callback);
void getACLsDescriptionForWorkspaceItemById(String workspaceItemId, AsyncCallback<String> callback);
void accessToFolderLink(String itemId, AsyncCallback<AllowAccess> callback);
void setACLs(String folderId, List<String> listLogins, String aclType, AsyncCallback<Void> callback);
void updateACLForVREbyGroupName(String folderId, String aclType, AsyncCallback<Void> callback);
void validateACLToUser(String folderId, List<String> listLogins, String aclType,
AsyncCallback<ReportAssignmentACL> callback);
void addAdministratorsByFolderId(String itemId, List<String> listContactLogins, AsyncCallback<Boolean> callback);
} }

View File

@ -14,10 +14,7 @@ public interface ContactFetcher {
public List<InfoContactModel> getExclusiveContactsFromAllContact(List<InfoContactModel> listSharedUser); public List<InfoContactModel> getExclusiveContactsFromAllContact(List<InfoContactModel> listSharedUser);
public void getOwner(String sharedFolderId, AsyncCallback<InfoContactModel> callback); public void getOwner(String sharedFolderId, AsyncCallback<InfoContactModel> callback);
/**
* @param listAlreadySharedContact
* @param callback
*/
public void getInfoContactModelsFromCredential( public void getInfoContactModelsFromCredential(
List<CredentialModel> listAlreadySharedContact, List<CredentialModel> listAlreadySharedContact,
AsyncCallback<List<InfoContactModel>> callback); AsyncCallback<List<InfoContactModel>> callback);

View File

@ -36,13 +36,11 @@ import com.google.gwt.user.client.ui.Label;
/** /**
* *
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it * @author Francesco Mangiacrapa Feb 27, 2014
* @Feb 27, 2014
* *
*/ */
public class DialogShareWItem extends Dialog { public class DialogShareWItem extends Dialog {
private int heightTextArea = 100; private int heightTextArea = 100;
private TextField<String> txtName; private TextField<String> txtName;
private TextArea textAreaDescription = new TextArea(); private TextArea textAreaDescription = new TextArea();
@ -64,11 +62,6 @@ public class DialogShareWItem extends Dialog {
this(false, false); this(false, false);
} }
/**
*
* @param readGroupsFromHL
* @param readGroupsFromPortal
*/
public DialogShareWItem(boolean readGroupsFromHL, boolean readGroupsFromPortal) { public DialogShareWItem(boolean readGroupsFromHL, boolean readGroupsFromPortal) {
this.readGroupsFromHL = readGroupsFromHL; this.readGroupsFromHL = readGroupsFromHL;
this.readGroupsFromPortal = readGroupsFromPortal; this.readGroupsFromPortal = readGroupsFromPortal;
@ -76,17 +69,10 @@ public class DialogShareWItem extends Dialog {
initLayout(); initLayout();
} }
private List<InfoContactModel> listAlreadyShared = new ArrayList<InfoContactModel>() { private List<InfoContactModel> listAlreadyShared = new ArrayList<InfoContactModel>() {
/**
*
*/
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
/**
* Compare Login
*/
@Override @Override
public boolean contains(Object o) { public boolean contains(Object o) {
@ -104,17 +90,18 @@ public class DialogShareWItem extends Dialog {
}; };
}; };
/** /**
* Use to modify a shared folder or share an existing folder * Use to modify a shared folder or share an existing folder
*
* @param fileModel * @param fileModel
* @param type * FileModel
* @param shareOnlyOwner
* Share only owner
* @param defaultACL
* Default ACL
*/ */
public void updateSharingDialog(FileModel fileModel, final boolean shareOnlyOwner, final ACL_TYPE defaultACL) { public void updateSharingDialog(FileModel fileModel, final boolean shareOnlyOwner, final ACL_TYPE defaultACL) {
this.fileToShare = fileModel; this.fileToShare = fileModel;
@ -159,7 +146,6 @@ public class DialogShareWItem extends Dialog {
buttonMultiDrag.setStyleName("wizardButton"); buttonMultiDrag.setStyleName("wizardButton");
flexTable.setWidget(1, 0, new Label("Add more")); flexTable.setWidget(1, 0, new Label("Add more"));
flexTable.setWidget(1, 1, buttonMultiDrag); flexTable.setWidget(1, 1, buttonMultiDrag);
@ -167,7 +153,6 @@ public class DialogShareWItem extends Dialog {
flexTable.setWidget(2, 0, labelDescription); flexTable.setWidget(2, 0, labelDescription);
flexTable.setWidget(2, 1, textAreaDescription); flexTable.setWidget(2, 1, textAreaDescription);
hpPermission = new HorizontalPanel(); hpPermission = new HorizontalPanel();
hpPermission.setVerticalAlign(VerticalAlignment.MIDDLE); hpPermission.setVerticalAlign(VerticalAlignment.MIDDLE);
Label labelProperty = new Label("Permissions"); Label labelProperty = new Label("Permissions");
@ -191,7 +176,6 @@ public class DialogShareWItem extends Dialog {
} }
}); });
lc.add(flexTable); lc.add(flexTable);
if (hpPermission != null) if (hpPermission != null)
lc.add(hpPermission); lc.add(hpPermission);
@ -219,7 +203,6 @@ public class DialogShareWItem extends Dialog {
} }
}); });
userStore.getOwner(fileModel.getIdentifier(), new AsyncCallback<InfoContactModel>() { userStore.getOwner(fileModel.getIdentifier(), new AsyncCallback<InfoContactModel>() {
@Override @Override
@ -248,7 +231,8 @@ public class DialogShareWItem extends Dialog {
} }
private void permissionControl(String owner, boolean showAlert) { private void permissionControl(String owner, boolean showAlert) {
GWT.log("Permission control compare between owner: "+owner +" and my login: "+WorkspaceSharingController.getMyLogin()); GWT.log("Permission control compare between owner: " + owner + " and my login: "
+ WorkspaceSharingController.getMyLogin());
if (WorkspaceSharingController.getMyLogin().compareToIgnoreCase(owner) != 0) { if (WorkspaceSharingController.getMyLogin().compareToIgnoreCase(owner) != 0) {
enableFormDialog(false); enableFormDialog(false);
@ -260,7 +244,9 @@ public class DialogShareWItem extends Dialog {
} }
} }
/* (non-Javadoc) /*
* (non-Javadoc)
*
* @see com.extjs.gxt.ui.client.widget.Window#afterShow() * @see com.extjs.gxt.ui.client.widget.Window#afterShow()
*/ */
@Override @Override
@ -268,7 +254,9 @@ public class DialogShareWItem extends Dialog {
super.afterShow(); super.afterShow();
if (showError) { if (showError) {
MessageBox.alert("Permission denied", "You have no permissions to change sharing. You are not owner of \""+txtName.getValue()+"\"", null); MessageBox.alert("Permission denied",
"You have no permissions to change sharing. You are not owner of \"" + txtName.getValue() + "\"",
null);
} }
} }
@ -282,13 +270,14 @@ public class DialogShareWItem extends Dialog {
public void setAsError(String message) { public void setAsError(String message) {
enableFormDialog(false); enableFormDialog(false);
this.add(new Html("<br/> <p style=\"color:red; font-family:verdana, arial; font-size:14px;\">"+message+"</p>")); this.add(new Html(
"<br/> <p style=\"color:red; font-family:verdana, arial; font-size:14px;\">" + message + "</p>"));
this.layout(); this.layout();
} }
/** /**
* *
* @return * @return File Model
*/ */
public FileModel getFileToShare() { public FileModel getFileToShare() {
return fileToShare; return fileToShare;
@ -309,13 +298,11 @@ public class DialogShareWItem extends Dialog {
setButtons(Dialog.OKCANCEL); setButtons(Dialog.OKCANCEL);
} }
public List<InfoContactModel> getSharedListUsers() { public List<InfoContactModel> getSharedListUsers() {
// printSelectedUser(); // printSelectedUser();
return suggestPanel.getSelectedUser(); return suggestPanel.getSelectedUser();
} }
public void addListners() { public void addListners() {
this.getButtonById(Dialog.CANCEL).addSelectionListener(new SelectionListener<ButtonEvent>() { this.getButtonById(Dialog.CANCEL).addSelectionListener(new SelectionListener<ButtonEvent>() {
@ -326,15 +313,12 @@ public class DialogShareWItem extends Dialog {
} }
}); });
/*
/*this.getButtonById(Dialog.OK).addSelectionListener(new SelectionListener<ButtonEvent>() { * this.getButtonById(Dialog.OK).addSelectionListener(new
* SelectionListener<ButtonEvent>() {
@Override *
public void componentSelected(ButtonEvent ce) { * @Override public void componentSelected(ButtonEvent ce) {
if(isValidForm(true)) * if(isValidForm(true)) hide(); } });
hide();
}
});
*/ */
buttonMultiDrag.addClickHandler(new ClickHandler() { buttonMultiDrag.addClickHandler(new ClickHandler() {
@ -345,7 +329,8 @@ public class DialogShareWItem extends Dialog {
final MultiDragContact multiDrag = dialog.getMultiDrag(); final MultiDragContact multiDrag = dialog.getMultiDrag();
dialog.show(); dialog.show();
List<InfoContactModel> exclusiveContacts = userStore.getExclusiveContactsFromAllContact(suggestPanel.getSelectedUser()); List<InfoContactModel> exclusiveContacts = userStore
.getExclusiveContactsFromAllContact(suggestPanel.getSelectedUser());
multiDrag.addSourceContacts(exclusiveContacts); multiDrag.addSourceContacts(exclusiveContacts);
for (InfoContactModel infoContactModel : suggestPanel.getSelectedUser()) { for (InfoContactModel infoContactModel : suggestPanel.getSelectedUser()) {
@ -365,7 +350,8 @@ public class DialogShareWItem extends Dialog {
suggestPanel.addRecipient(infoContactModel.getName(), true); suggestPanel.addRecipient(infoContactModel.getName(), true);
} }
// for (InfoContactModel infoContactModel : multiDrag.getTargetListContact()) { // for (InfoContactModel infoContactModel :
// multiDrag.getTargetListContact()) {
// //
// if(!listAlreadySharedContains(infoContactModel)) // if(!listAlreadySharedContains(infoContactModel))
// suggestPanel.addRecipient(infoContactModel.getName(),true); // suggestPanel.addRecipient(infoContactModel.getName(),true);
@ -414,7 +400,6 @@ public class DialogShareWItem extends Dialog {
suggestPanel.addRecipient(contact.getName(), false); suggestPanel.addRecipient(contact.getName(), false);
} }
} }
public String getName() { public String getName() {
@ -428,11 +413,6 @@ public class DialogShareWItem extends Dialog {
return textAreaDescription.getValue(); return textAreaDescription.getValue();
} }
/**
*
* @param displayAlert
* @return
*/
public boolean isValidForm(boolean displayAlert) { public boolean isValidForm(boolean displayAlert) {
if (!txtName.isValid()) { if (!txtName.isValid()) {

View File

@ -9,8 +9,8 @@ import org.gcube.portlets.widgets.workspacesharingwidget.shared.CredentialModel;
import org.gcube.portlets.widgets.workspacesharingwidget.shared.InfoContactModel; import org.gcube.portlets.widgets.workspacesharingwidget.shared.InfoContactModel;
/** /**
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it * @author Francesco Mangiacrapa
* @Mar 4, 2014 * Mar 4, 2014
* *
*/ */
public interface SmartDialogInterface { public interface SmartDialogInterface {

View File

@ -36,8 +36,8 @@ import com.google.gwt.user.client.ui.Label;
/** /**
* The Class SmartShare. * The Class SmartShare.
* *
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it * @author Francesco Mangiacrapa
* @Mar 3, 2014 * Mar 3, 2014
*/ */
public class SmartShare extends Dialog implements SmartDialogInterface{ public class SmartShare extends Dialog implements SmartDialogInterface{

View File

@ -13,7 +13,7 @@ import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.rpc.AsyncCallback; import com.google.gwt.user.client.rpc.AsyncCallback;
/** /**
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it * @author Francesco Mangiacrapa
* *
*/ */
public class UserStore implements ContactFetcher{ public class UserStore implements ContactFetcher{
@ -34,7 +34,7 @@ public class UserStore implements ContactFetcher{
listAllContact = new ArrayList<InfoContactModel>(); listAllContact = new ArrayList<InfoContactModel>();
WorkspaceSharingController.rpcWorkspaceSharingService.getAllContacts(readGroupsFromHL, readGroupsFromPortal, new AsyncCallback<List<InfoContactModel>>() { WorkspaceSharingController.rpcWorkspaceSharingService.getAllContacts(new AsyncCallback<List<InfoContactModel>>() {
@Override @Override
public void onSuccess(List<InfoContactModel> result) { public void onSuccess(List<InfoContactModel> result) {

View File

@ -6,7 +6,7 @@ import com.google.gwt.user.client.ui.Widget;
/** /**
* *
* @author Massimiliano Assante, ISTI-CNR * @author Massimiliano Assante, ISTI-CNR
* @version 0.1 Sep 2012 * 1 Sep 2012
* *
*/ */
public class BulletList extends ComplexPanel { public class BulletList extends ComplexPanel {

View File

@ -21,8 +21,8 @@ import com.extjs.gxt.ui.client.widget.toolbar.ToolBar;
import com.google.gwt.user.client.Random; import com.google.gwt.user.client.Random;
/** /**
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it * @author Francesco Mangiacrapa
* @Jan 27, 2015 * Jan 27, 2015
* *
*/ */
public class DialogMultiDragContact extends Dialog{ public class DialogMultiDragContact extends Dialog{
@ -43,14 +43,7 @@ public class DialogMultiDragContact extends Dialog{
private LayoutContainer lcTop = new LayoutContainer(); private LayoutContainer lcTop = new LayoutContainer();
private LayoutContainer lcMiddle = new LayoutContainer(); private LayoutContainer lcMiddle = new LayoutContainer();
private LayoutContainer lcBottom = new LayoutContainer(); private LayoutContainer lcBottom = new LayoutContainer();
/**
*
* @param headTitle
* @param leftListContactsTitle
* @param rightListContactsTitle
* @param visibleAlreadyShared
* @param hideOnPressOk
*/
public DialogMultiDragContact(String headTitle, String leftListContactsTitle, String rightListContactsTitle, boolean visibleAlreadyShared, boolean hideOnPressOk) { public DialogMultiDragContact(String headTitle, String leftListContactsTitle, String rightListContactsTitle, boolean visibleAlreadyShared, boolean hideOnPressOk) {
this.multiDragContact = new MultiDragContact(leftListContactsTitle, rightListContactsTitle, visibleAlreadyShared); this.multiDragContact = new MultiDragContact(leftListContactsTitle, rightListContactsTitle, visibleAlreadyShared);
this.hideOnPressOkButton = hideOnPressOk; this.hideOnPressOkButton = hideOnPressOk;
@ -60,11 +53,6 @@ public class DialogMultiDragContact extends Dialog{
// add(multiDragContact); // add(multiDragContact);
} }
/**
*
* @param visibleAlreadyShared
* @param hideOnPressOk
*/
public DialogMultiDragContact(boolean visibleAlreadyShared, boolean hideOnPressOk){ public DialogMultiDragContact(boolean visibleAlreadyShared, boolean hideOnPressOk){
this.multiDragContact = new MultiDragContact(visibleAlreadyShared); this.multiDragContact = new MultiDragContact(visibleAlreadyShared);
this.hideOnPressOkButton = hideOnPressOk; this.hideOnPressOkButton = hideOnPressOk;
@ -83,17 +71,10 @@ public class DialogMultiDragContact extends Dialog{
} }
/**
*
* @param bool
*/
public void showToolBar(boolean bool){ public void showToolBar(boolean bool){
this.toolBar.setVisible(bool); this.toolBar.setVisible(bool);
} }
/**
*
*/
private void init() { private void init() {
setId(DialogMultiDragContact.class.getName()+Random.nextInt()); setId(DialogMultiDragContact.class.getName()+Random.nextInt());
setSize(WIDTH_DIALOG, HEIGHT_DIALOG); setSize(WIDTH_DIALOG, HEIGHT_DIALOG);
@ -175,9 +156,6 @@ public class DialogMultiDragContact extends Dialog{
} }
/**
*
*/
public MultiDragContact getMultiDrag() { public MultiDragContact getMultiDrag() {
return multiDragContact; return multiDragContact;
} }

View File

@ -12,7 +12,7 @@ import com.google.gwt.user.client.ui.Widget;
/** /**
* *
* @author Massimiliano Assante, ISTI-CNR * @author Massimiliano Assante, ISTI-CNR
* @version 0.1 Sep 2012 * 1 Sep 2012
* *
*/ */
public class ListItem extends ComplexPanel { public class ListItem extends ComplexPanel {

View File

@ -45,15 +45,13 @@ import com.google.gwt.user.client.Random;
/** /**
* *
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it * @author Francesco Mangiacrapa
* @Jan 27, 2015 * Jan 27, 2015
* *
*/ */
public class MultiDragContact extends ContentPanel { public class MultiDragContact extends ContentPanel {
/**
*
*/
private static final int HEIGHT_CP = 375; private static final int HEIGHT_CP = 375;
private static final String ALL_CONTACTS = "All Contacts"; private static final String ALL_CONTACTS = "All Contacts";
private static final String SHARE_WITH = "Share with..."; private static final String SHARE_WITH = "Share with...";
@ -92,14 +90,6 @@ public class MultiDragContact extends ContentPanel {
setRightListContactsTitle(rightListContactsTitle); setRightListContactsTitle(rightListContactsTitle);
} }
/**
*
* @param headTitle
* @param leftListContactsTitle
* @param rightListContactsTitle
* @param visibleAlreadyShared
* @param hideOnPressOk
*/
public MultiDragContact(boolean visibleAlreadyShared) { public MultiDragContact(boolean visibleAlreadyShared) {
this.setHeaderVisible(false); this.setHeaderVisible(false);
this.setBodyBorder(false); this.setBodyBorder(false);
@ -530,9 +520,7 @@ public class MultiDragContact extends ContentPanel {
storeTarget.add(listContact); storeTarget.add(listContact);
} }
/**
* @param infoContactModel
*/
public void addSourceContact(InfoContactModel contact) { public void addSourceContact(InfoContactModel contact) {
if (contact != null) if (contact != null)
storeSource.add(contact); storeSource.add(contact);

View File

@ -27,8 +27,8 @@ import com.google.gwt.user.client.ui.TextBox;
/** /**
* The Class MultiValuePanel. * The Class MultiValuePanel.
* *
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it * @author Francesco Mangiacrapa
* @Feb 25, 2014 * Feb 25, 2014
*/ */
public class MultiValuePanel extends Composite { public class MultiValuePanel extends Composite {

View File

@ -8,19 +8,25 @@ import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import org.gcube.common.homelibrary.home.User; //import org.gcube.common.homelibrary.home.User;
import org.gcube.common.homelibrary.home.exceptions.InternalErrorException; import org.gcube.common.portal.PortalContext;
import org.gcube.common.homelibrary.home.workspace.WorkspaceItem; import org.gcube.common.storagehub.model.acls.ACL;
import org.gcube.common.homelibrary.home.workspace.WorkspaceSharedFolder; import org.gcube.common.storagehub.model.acls.AccessType;
import org.gcube.common.homelibrary.home.workspace.accessmanager.ACLType; import org.gcube.common.storagehub.model.items.AbstractFileItem;
import org.gcube.common.homelibrary.home.workspace.folder.FolderItem; import org.gcube.common.storagehub.model.items.ExternalURL;
import org.gcube.common.homelibrary.home.workspace.folder.items.ExternalFile; import org.gcube.common.storagehub.model.items.FolderItem;
import org.gcube.common.homelibrary.home.workspace.folder.items.ExternalImage; import org.gcube.common.storagehub.model.items.GCubeItem;
import org.gcube.common.homelibrary.home.workspace.folder.items.ExternalPDFFile; import org.gcube.common.storagehub.model.items.GenericFileItem;
import org.gcube.common.homelibrary.home.workspace.folder.items.GCubeItem; import org.gcube.common.storagehub.model.items.ImageFile;
import org.gcube.common.homelibrary.home.workspace.usermanager.GCubeGroup; import org.gcube.common.storagehub.model.items.Item;
import org.gcube.common.storagehub.model.items.PDFFileItem;
import org.gcube.common.storagehub.model.items.SharedFolder;
//import org.gcube.common.homelibrary.home.workspace.usermanager.GCubeGroup;
import org.gcube.portlets.widgets.workspacesharingwidget.client.ConstantsSharing; import org.gcube.portlets.widgets.workspacesharingwidget.client.ConstantsSharing;
import org.gcube.portlets.widgets.workspacesharingwidget.server.util.PortalContextInfo;
import org.gcube.portlets.widgets.workspacesharingwidget.server.util.ScopeUtility;
import org.gcube.portlets.widgets.workspacesharingwidget.server.util.UserUtil; import org.gcube.portlets.widgets.workspacesharingwidget.server.util.UserUtil;
import org.gcube.portlets.widgets.workspacesharingwidget.server.util.WsUtil;
import org.gcube.portlets.widgets.workspacesharingwidget.shared.ACL_TYPE; import org.gcube.portlets.widgets.workspacesharingwidget.shared.ACL_TYPE;
import org.gcube.portlets.widgets.workspacesharingwidget.shared.FileModel; import org.gcube.portlets.widgets.workspacesharingwidget.shared.FileModel;
import org.gcube.portlets.widgets.workspacesharingwidget.shared.FolderModel; import org.gcube.portlets.widgets.workspacesharingwidget.shared.FolderModel;
@ -30,6 +36,7 @@ import org.gcube.portlets.widgets.workspacesharingwidget.shared.WorkspaceACL;
import org.gcube.portlets.widgets.workspacesharingwidget.shared.WorkspaceACL.USER_TYPE; import org.gcube.portlets.widgets.workspacesharingwidget.shared.WorkspaceACL.USER_TYPE;
import org.gcube.portlets.widgets.workspacesharingwidget.shared.system.VO; import org.gcube.portlets.widgets.workspacesharingwidget.shared.system.VO;
import org.gcube.portlets.widgets.workspacesharingwidget.shared.system.VRE; import org.gcube.portlets.widgets.workspacesharingwidget.shared.system.VRE;
import org.gcube.vomanagement.usermanagement.model.GCubeGroup;
import org.gcube.vomanagement.usermanagement.model.GCubeUser; import org.gcube.vomanagement.usermanagement.model.GCubeUser;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@ -37,16 +44,13 @@ import org.slf4j.LoggerFactory;
/** /**
* The Class GWTWorkspaceSharingBuilder. * The Class GWTWorkspaceSharingBuilder.
* *
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it * @author Francesco Mangiacrapa Feb 25, 2014
* @Feb 25, 2014
*/ */
public class GWTWorkspaceSharingBuilder { public class GWTWorkspaceSharingBuilder {
protected Logger logger = LoggerFactory.getLogger(GWTWorkspaceSharingBuilder.class); private static Logger logger = LoggerFactory.getLogger(GWTWorkspaceSharingBuilder.class);
private InfoContactModel userLogged; private static HashMap<String, InfoContactModel> hashTestUser = null;
protected static HashMap<String, InfoContactModel> hashTestUser = null;
/** /**
* Used in test mode. * Used in test mode.
@ -58,40 +62,31 @@ public class GWTWorkspaceSharingBuilder {
if (hashTestUser == null) { if (hashTestUser == null) {
hashTestUser = new HashMap<String, InfoContactModel>(); hashTestUser = new HashMap<String, InfoContactModel>();
hashTestUser.put("federico.defaveri", new InfoContactModel( hashTestUser.put("federico.defaveri",
"federico.defaveri", "federico.defaveri", new InfoContactModel("federico.defaveri", "federico.defaveri", "Federico de Faveri", false));
"Federico de Faveri", false));
hashTestUser.put("antonio.gioia", new InfoContactModel( hashTestUser.put("antonio.gioia",
"antonio.gioia", "antonio.gioia", "Antonio Gioia", false)); new InfoContactModel("antonio.gioia", "antonio.gioia", "Antonio Gioia", false));
hashTestUser.put("fabio.sinibaldi", new InfoContactModel( hashTestUser.put("fabio.sinibaldi",
"fabio.sinibaldi", "fabio.sinibaldi", "Fabio Sinibaldi", new InfoContactModel("fabio.sinibaldi", "fabio.sinibaldi", "Fabio Sinibaldi", false));
false));
hashTestUser.put("pasquale.pagano", new InfoContactModel( hashTestUser.put("pasquale.pagano",
"pasquale.pagano", "pasquale.pagano", "Pasquale Pagano", new InfoContactModel("pasquale.pagano", "pasquale.pagano", "Pasquale Pagano", false));
false));
hashTestUser.put("francesco.mangiacrapa", new InfoContactModel( hashTestUser.put("francesco.mangiacrapa", new InfoContactModel("francesco.mangiacrapa",
"francesco.mangiacrapa", "francesco.mangiacrapa", "francesco.mangiacrapa", "Francesco Mangiacrapa", false));
"Francesco Mangiacrapa", false));
hashTestUser.put("massimiliano.assante", new InfoContactModel( hashTestUser.put("massimiliano.assante", new InfoContactModel("massimiliano.assante",
"massimiliano.assante", "massimiliano.assante", "massimiliano.assante", "Massimiliano Assante", false));
"Massimiliano Assante", false));
hashTestUser.put("leonardo.candela", new InfoContactModel( hashTestUser.put("leonardo.candela",
"leonardo.candela", "leonardo.candela", "Leonardo Candela", new InfoContactModel("leonardo.candela", "leonardo.candela", "Leonardo Candela", false));
false));
hashTestUser.put("valentina.marioli", new InfoContactModel( hashTestUser.put("valentina.marioli",
"valentina.marioli", "valentina.marioli", new InfoContactModel("valentina.marioli", "valentina.marioli", "Valentina Marioli", false));
"Valentina Marioli", false));
hashTestUser.put("devVRE", new InfoContactModel( hashTestUser.put("devVRE", new InfoContactModel("devVRE", "devVRE", "devVRE", true));
"devVRE", "devVRE",
"devVRE", true));
// hashTestUser.put(WsUtil.TEST_USER.toString(), // hashTestUser.put(WsUtil.TEST_USER.toString(),
// new InfoContactModel( // new InfoContactModel(
@ -106,20 +101,45 @@ public class GWTWorkspaceSharingBuilder {
/** /**
* Sets the user logged. * Sets the user logged.
* *
* @param infoContactModel the new user logged * @param info
* Portal Context info
* @return List of contacts
*/ */
public void setUserLogged(InfoContactModel infoContactModel) { public List<InfoContactModel> getGXTListContactsModelFromVOs(PortalContextInfo info) {
this.userLogged = infoContactModel; logger.info("Reading group names as scopes from Infrastructure..");
List<InfoContactModel> listContactsModel = new ArrayList<>();
PortalContext context = PortalContext.getConfiguration();
logger.info("context.getInfrastructureName(): " + context.getInfrastructureName());
// String groupName = info.getCurrentGroupName(request);
logger.info("context.getGroupId(): " + info.getCurrGroupId());
logger.info("context.getScope(): " + info.getCurrentScope());
try {
ScopeUtility scopeUtility = new ScopeUtility(info.getCurrentScope());
if (scopeUtility.getVoName() != null) {
logger.info("VO name is not null, trying to calculate List VO");
List<VO> lsVOs = WsUtil.getVresFromInfrastructure(context.getInfrastructureName(),
scopeUtility.getVoName());
listContactsModel.addAll(buildGXTListContactsModelFromVOs(lsVOs, scopeUtility.getVo()));
} else
logger.warn("VO name is null, skipping list VO " + info.getCurrGroupId());
} catch (Exception e) {
logger.warn("An error occurred on recovering vo name, skipping list VO " + info.getCurrGroupId());
}
return listContactsModel;
} }
/** /**
* Builds the gxt list contacts model from gcube group. * Builds the gxt list contacts model from gcube group.
* *
* @param list the list * @param list
* the list
* @return the list * @return the list
* @throws InternalErrorException the internal error exception * @throws Exception
* the internal error exception
*/ */
public List<InfoContactModel> buildGXTListContactsModelFromGcubeGroup(List<GCubeGroup> list) throws InternalErrorException { public List<InfoContactModel> buildGXTListContactsModelFromGcubeGroup(List<GCubeGroup> list) throws Exception {
List<InfoContactModel> listContactsModel = new ArrayList<InfoContactModel>(); List<InfoContactModel> listContactsModel = new ArrayList<InfoContactModel>();
@ -132,34 +152,32 @@ public class GWTWorkspaceSharingBuilder {
for (GCubeGroup group : list) { for (GCubeGroup group : list) {
try { try {
String groupDN = group.getDisplayName(); String groupDN = group.getGroupName();
if (groupDN == null || groupDN.isEmpty()) if (groupDN == null || groupDN.isEmpty())
groupDN = group.getName(); groupDN = group.getGroupName();
if (group.getName() == null || group.getName().isEmpty()) if (group.getGroupName() == null || group.getGroupName().isEmpty())
logger.warn("Skipping group with null or empty name " + group); logger.warn("Skipping group with null or empty name " + group);
else { else {
InfoContactModel contact = new InfoContactModel( InfoContactModel contact = new InfoContactModel(group.getGroupName(), group.getGroupName(), groupDN,
group.getName(), group.getName(), groupDN, true); true);
logger.trace("Adding group " + contact); logger.trace("Adding group " + contact);
listContactsModel.add(contact); listContactsModel.add(contact);
} }
} catch (InternalErrorException e) { } catch (Exception e) {
logger.warn("Dispaly name is not available to group " + group); logger.warn("Dispaly name is not available to group " + group);
logger.warn("Adding get name property " + group.getName()); logger.warn("Adding get name property " + group.getGroupName());
if (group.getName() == null || group.getName().isEmpty()) if (group.getGroupName() == null || group.getGroupName().isEmpty())
logger.warn("Skipping group with null or empty name " logger.warn("Skipping group with null or empty name " + group);
+ group);
else else
listContactsModel.add(new InfoContactModel(group.getName(), listContactsModel.add(new InfoContactModel(group.getGroupName(), group.getGroupName(),
group.getName(), group.getName(), true)); group.getGroupName(), true));
} }
} }
logger.trace("List GCubeGroup contact model completed, return " logger.trace("List GCubeGroup contact model completed, return " + listContactsModel.size() + " contacts");
+ listContactsModel.size() + " contacts");
return listContactsModel; return listContactsModel;
} }
@ -167,12 +185,15 @@ public class GWTWorkspaceSharingBuilder {
/** /**
* Builds the gxt list contacts model from v os. * Builds the gxt list contacts model from v os.
* *
* @param listVO the list vo * @param listVO
* @param voPath the vo path * the list vo
* @param voPath
* the vo path
* @return the list * @return the list
* @throws InternalErrorException the internal error exception * @throws Exception
* the internal error exception
*/ */
public List<InfoContactModel> buildGXTListContactsModelFromVOs(List<VO> listVO, String voPath) throws InternalErrorException { public List<InfoContactModel> buildGXTListContactsModelFromVOs(List<VO> listVO, String voPath) throws Exception {
List<InfoContactModel> listContactsModel = new ArrayList<InfoContactModel>(); List<InfoContactModel> listContactsModel = new ArrayList<InfoContactModel>();
@ -207,7 +228,9 @@ public class GWTWorkspaceSharingBuilder {
if (vre.getName() != null || !vre.getName().isEmpty()) { if (vre.getName() != null || !vre.getName().isEmpty()) {
String groupId = voPath + vre.getName(); String groupId = voPath + vre.getName();
logger.trace("adding contact groupId: " + groupId + " VRE name: " + vre.getName()); logger.trace("adding contact groupId: " + groupId + " VRE name: " + vre.getName());
// InfoContactModel contact = new InfoContactModel(groupId, groupId, vre.getName(), true); // InfoContactModel contact = new
// InfoContactModel(groupId, groupId, vre.getName(),
// true);
// logger.trace("Adding group contact " + contact); // logger.trace("Adding group contact " + contact);
// listContactsModel.add(contact); // listContactsModel.add(contact);
} }
@ -216,45 +239,44 @@ public class GWTWorkspaceSharingBuilder {
logger.trace("vres list is null, skipping VO " + vo.getName()); logger.trace("vres list is null, skipping VO " + vo.getName());
} }
logger.trace("List GCubeGroup contact model completed, return " logger.trace("List GCubeGroup contact model completed, return " + listContactsModel.size() + " contacts");
+ listContactsModel.size() + " contacts");
return listContactsModel; return listContactsModel;
} }
/** /**
* Builds the gxt list contacts model from user model.
* *
* @param listUsers the list users * @param info
* @return the list * Portal Context info
* @throws InternalErrorException the internal error exception * @return the list of users
* @throws Exception
* Error
*/ */
public List<InfoContactModel> buildGXTListContactsModelFromUserModel( public List<InfoContactModel> buildGXTListContactsModelFromUserModel(PortalContextInfo info) throws Exception {
List<GCubeUser> listUsers) throws InternalErrorException {
List<GCubeUser> listUsers = UserUtil.getOrganizationUsers(info.getCurrentScope());
if (listUsers == null) {
logger.error("No users found in: " + info.getCurrentScope());
throw new Exception("An error occurred on recovering users from Portal, try again later");
}
List<InfoContactModel> listContactsModel = new ArrayList<InfoContactModel>(); List<InfoContactModel> listContactsModel = new ArrayList<InfoContactModel>();
if (listUsers == null) logger.trace("List<UserModel> size returned from Portal VO is: " + listUsers.size());
return listContactsModel;
logger.trace("List<UserModel> size returned from Portal VO is: "
+ listUsers.size());
logger.trace("Building list contact model list user model"); logger.trace("Building list contact model list user model");
for (GCubeUser userModel : listUsers) { for (GCubeUser userModel : listUsers) {
String fullName = userModel.getFullname(); String fullName = userModel.getFullname();
if (fullName != null && !fullName.isEmpty()) if (fullName != null && !fullName.isEmpty())
listContactsModel.add(new InfoContactModel(userModel listContactsModel.add(
.getUserId() + "", userModel.getScreenName(), fullName, new InfoContactModel(userModel.getUserId() + "", userModel.getUsername(), fullName, false));
false));
else else
logger.trace("buildGXTListContactsModel is not returning user: " logger.trace("buildGXTListContactsModel is not returning user: " + userModel.getUsername()
+ userModel.getScreenName()
+ "because name is null or empty"); + "because name is null or empty");
} }
logger.trace("List contact model completed, return " logger.trace("List contact model completed, return " + listContactsModel.size() + " contacts");
+ listContactsModel.size() + " contacts");
return listContactsModel; return listContactsModel;
} }
@ -262,7 +284,8 @@ public class GWTWorkspaceSharingBuilder {
/** /**
* Builds the gxt info contacts from portal logins. * Builds the gxt info contacts from portal logins.
* *
* @param listPortalLogin the list portal login * @param listPortalLogin
* the list portal login
* @return the list * @return the list
*/ */
public List<InfoContactModel> buildGxtInfoContactsFromPortalLogins(List<String> listPortalLogin) { public List<InfoContactModel> buildGxtInfoContactsFromPortalLogins(List<String> listPortalLogin) {
@ -277,7 +300,8 @@ public class GWTWorkspaceSharingBuilder {
/** /**
* Builds the gxt info contact from portal login. * Builds the gxt info contact from portal login.
* *
* @param portalLogin the portal login * @param portalLogin
* the portal login
* @return the info contact model * @return the info contact model
*/ */
protected InfoContactModel buildGxtInfoContactFromPortalLogin(String portalLogin) { protected InfoContactModel buildGxtInfoContactFromPortalLogin(String portalLogin) {
@ -289,11 +313,11 @@ public class GWTWorkspaceSharingBuilder {
return new InfoContactModel(portalLogin, portalLogin, UserUtil.getUserFullName(portalLogin), false); return new InfoContactModel(portalLogin, portalLogin, UserUtil.getUserFullName(portalLogin), false);
} }
/** /**
* Builds the gxt info contact from portal group. * Builds the gxt info contact from portal group.
* *
* @param grouoLogin the grouo login * @param grouoLogin
* the grouo login
* @return the info contact model * @return the info contact model
*/ */
protected InfoContactModel buildGxtInfoContactFromPortalGroup(String grouoLogin) { protected InfoContactModel buildGxtInfoContactFromPortalGroup(String grouoLogin) {
@ -320,7 +344,8 @@ public class GWTWorkspaceSharingBuilder {
/** /**
* Used in test mode. * Used in test mode.
* *
* @param listPortalLogin the list portal login * @param listPortalLogin
* the list portal login
* @return the list * @return the list
*/ */
protected List<InfoContactModel> buildGxtInfoContactFromPortalLoginTestMode(List<String> listPortalLogin) { protected List<InfoContactModel> buildGxtInfoContactFromPortalLoginTestMode(List<String> listPortalLogin) {
@ -334,162 +359,111 @@ public class GWTWorkspaceSharingBuilder {
return listContact; return listContact;
} }
/**
* Builds the gxt info contact model.
*
* @param user the user
* @return the info contact model
* @throws InternalErrorException the internal error exception
*/
public InfoContactModel buildGXTInfoContactModel(User user)
throws InternalErrorException {
// TODO ISGROUP
if (user != null)
return new InfoContactModel(user.getId(), user.getPortalLogin(),
UserUtil.getUserFullName(user.getPortalLogin()), false);
return new InfoContactModel();
}
/** /**
* Builds the gxt file model item. * Builds the gxt file model item.
* *
* @param item the item * @param item
* @param parentFolderModel the parent folder model * the item
* @param parent
* the parent folder model
* @return the file model * @return the file model
* @throws Exception the exception * @throws Exception
* the exception
*/ */
protected FileModel buildGXTFileModelItem(WorkspaceItem item, public FileModel buildGXTFileModelItem(Item item, FileModel parent) throws Exception {
FileModel parentFolderModel) throws Exception { try {
FileModel fileModel = null;
FileModel parent = parentFolderModel != null ? (FileModel) parentFolderModel FileModel fileModel = null;
: null;
logger.info("Workspace item converting..."); logger.info("Workspace item converting...");
try { if (item instanceof SharedFolder) {
switch (item.getType()) { logger.info("Workspace item is a SharedFolder...");
SharedFolder shared = (SharedFolder) item;
case FOLDER: String name = shared.isVreFolder() ? shared.getDisplayName() : item.getName();
logger.info("Workspace item is folder..."); fileModel = new FolderModel(item.getId(), name, item.getDescription(),parent, true, true, shared.isVreFolder());
fileModel = new FolderModel(item.getId(), item.getName(), fileModel.setType(GXTFolderItemTypeEnum.SHARED_FOLDER.toString());
parent, true, false, false); fileModel.setDescription(item.getDescription());
} else {
if (item instanceof FolderItem) {
logger.info("Workspace item is a Folder...");
fileModel = new FolderModel(item.getId(), item.getName(), item.getDescription(),parent, true, false, false);
fileModel.setType(GXTFolderItemTypeEnum.FOLDER.toString()); fileModel.setType(GXTFolderItemTypeEnum.FOLDER.toString());
fileModel.setDescription(item.getDescription()); fileModel.setDescription(item.getDescription());
break; } else {
if (item instanceof AbstractFileItem) {
case FOLDER_ITEM: logger.info("Workspace item is a AbstractFileItem...");
logger.info("Workspace item is folder item..."); fileModel = new FileModel(item.getId(), item.getName(), item.getDescription(), parent, false, false);
fileModel = new FileModel(item.getId(), item.getName(), parent, AbstractFileItem abstractFileItem = (AbstractFileItem) item;
false, false); fileModel = setFolderItemType(fileModel, abstractFileItem);
FolderItem folderItem = (FolderItem) item; } else {
fileModel = setFolderItemType(fileModel, folderItem); if (item instanceof GCubeItem) {
break; logger.info("Workspace item is a GCubeItem...");
fileModel = new FileModel(item.getId(), item.getName(), item.getDescription(),parent, false, false);
case SHARED_FOLDER: fileModel.setFolderItemType(GXTFolderItemTypeEnum.GCUBE_ITEM);
logger.info("Workspace item is shared item..."); } else {
WorkspaceSharedFolder shared = (WorkspaceSharedFolder) item; logger.error("gxt conversion return null for item " + item.getName());
String name = shared.isVreFolder() ? shared.getDisplayName() }
: item.getName();
fileModel = new FolderModel(item.getId(), name, parent, true,
true, shared.isVreFolder());
fileModel.setType(GXTFolderItemTypeEnum.SHARED_FOLDER
.toString());
fileModel.setDescription(item.getDescription());
break;
default:
logger.error("gxt conversion return null for item "
+ item.getName());
break;
} }
} catch (Exception e) { }
logger.error("gxt conversion error: ", e);
throw new Exception("Error on conversion: ", e);
} }
return fileModel; return fileModel;
} catch (Exception e) {
logger.error("Build GXTFileModelItem error: " + e.getLocalizedMessage(), e);
throw new Exception("Error building item model: " + e.getLocalizedMessage(), e);
}
} }
/** /**
* Sets the folder item type. * Sets item type.
* *
* @param fileModel the file model * @param fileModel
* @param worspaceFolderItem the worspace folder item * the file model
* @param abstractfileItem
* the worspace folder item
* @return the file model * @return the file model
*/ */
protected FileModel setFolderItemType(FileModel fileModel, protected FileModel setFolderItemType(FileModel fileModel, AbstractFileItem abstractfileItem) {
FolderItem worspaceFolderItem) {
switch (worspaceFolderItem.getFolderItemType()) { if (abstractfileItem instanceof ExternalURL) {
case EXTERNAL_IMAGE:
fileModel.setFolderItemType(GXTFolderItemTypeEnum.EXTERNAL_IMAGE);
ExternalImage extImage = (ExternalImage) worspaceFolderItem;
fileModel.setType(extImage.getMimeType());
break;
case EXTERNAL_FILE:
fileModel.setFolderItemType(GXTFolderItemTypeEnum.EXTERNAL_FILE);
ExternalFile extFile = (ExternalFile) worspaceFolderItem;
fileModel.setType(extFile.getMimeType());
break;
case EXTERNAL_PDF_FILE:
fileModel.setFolderItemType(GXTFolderItemTypeEnum.EXTERNAL_PDF_FILE);
ExternalPDFFile pdfExt = (ExternalPDFFile) worspaceFolderItem;
fileModel.setType(pdfExt.getMimeType());
break;
case EXTERNAL_URL:
fileModel.setFolderItemType(GXTFolderItemTypeEnum.EXTERNAL_URL); fileModel.setFolderItemType(GXTFolderItemTypeEnum.EXTERNAL_URL);
break; } else {
case REPORT_TEMPLATE: if (abstractfileItem instanceof GenericFileItem) {
fileModel.setFolderItemType(GXTFolderItemTypeEnum.REPORT_TEMPLATE);
break;
case REPORT:
fileModel.setFolderItemType(GXTFolderItemTypeEnum.REPORT);
break;
case QUERY:
fileModel.setFolderItemType(GXTFolderItemTypeEnum.QUERY);
break;
case TIME_SERIES:
fileModel.setFolderItemType(GXTFolderItemTypeEnum.TIME_SERIES);
break;
case PDF_DOCUMENT:
fileModel.setFolderItemType(GXTFolderItemTypeEnum.PDF_DOCUMENT);
break;
case IMAGE_DOCUMENT:
fileModel.setFolderItemType(GXTFolderItemTypeEnum.IMAGE_DOCUMENT);
GCubeItem imgDoc = (GCubeItem) worspaceFolderItem; //Cast GCubeItem
try {
fileModel.setType(imgDoc.getMimeType());
} catch (InternalErrorException e) {
logger.error("IMAGE_DOCUMENT InternalErrorException when getting MimeType on "+fileModel.getIdentifier());
}
break;
case DOCUMENT:
fileModel.setFolderItemType(GXTFolderItemTypeEnum.DOCUMENT); fileModel.setFolderItemType(GXTFolderItemTypeEnum.DOCUMENT);
GCubeItem doc = (GCubeItem) worspaceFolderItem; //Cast GCubeItem GenericFileItem doc = (GenericFileItem) abstractfileItem;
try { String mimetype = doc.getContent().getMimeType();
fileModel.setType(doc.getMimeType()); if (mimetype != null && !mimetype.isEmpty()) {
} catch (InternalErrorException e) { fileModel.setType(mimetype);
logger.error("DOCUMENT InternalErrorException when getting MimeType on "+fileModel.getIdentifier()); } else {
logger.error("Error retrieving MimeType on file id: " + abstractfileItem.getId());
} }
break; } else {
case URL_DOCUMENT: if (abstractfileItem instanceof ImageFile) {
fileModel.setFolderItemType(GXTFolderItemTypeEnum.URL_DOCUMENT); fileModel.setFolderItemType(GXTFolderItemTypeEnum.IMAGE_DOCUMENT);
break; ImageFile img = (ImageFile) abstractfileItem;
case METADATA: String mimetype = img.getContent().getMimeType();
fileModel.setFolderItemType(GXTFolderItemTypeEnum.METADATA); if (mimetype != null && !mimetype.isEmpty()) {
break; fileModel.setType(mimetype);
case GCUBE_ITEM: } else {
fileModel.setFolderItemType(GXTFolderItemTypeEnum.GCUBE_ITEM); logger.error("Error retrieving MimeType on file id: " + abstractfileItem.getId());
break; }
default: } else {
if (abstractfileItem instanceof PDFFileItem) {
fileModel.setFolderItemType(GXTFolderItemTypeEnum.PDF_DOCUMENT);
} else {
fileModel.setFolderItemType(GXTFolderItemTypeEnum.UNKNOWN_TYPE); fileModel.setFolderItemType(GXTFolderItemTypeEnum.UNKNOWN_TYPE);
fileModel.setType(GXTFolderItemTypeEnum.UNKNOWN_TYPE.toString()); fileModel.setType(GXTFolderItemTypeEnum.UNKNOWN_TYPE.toString());
break;
}
}
}
} }
return fileModel; return fileModel;
@ -498,15 +472,17 @@ public class GWTWorkspaceSharingBuilder {
/** /**
* Gets the workspace acl from ac ls. * Gets the workspace acl from ac ls.
* *
* @param types the types * @param types
* the types
* @return the workspace acl from ac ls * @return the workspace acl from ac ls
* @throws Exception the exception * @throws Exception
* the exception
*/ */
public List<WorkspaceACL> getWorkspaceACLFromACLs(List<ACLType> types) throws Exception { public List<WorkspaceACL> getWorkspaceACLFromAccessType(List<AccessType> types) throws Exception {
List<WorkspaceACL> acls = new ArrayList<WorkspaceACL>(); List<WorkspaceACL> acls = new ArrayList<WorkspaceACL>();
for (ACLType acl : types) { for (AccessType acl : types) {
switch (acl) { switch (acl) {
@ -516,24 +492,22 @@ public class GWTWorkspaceSharingBuilder {
// USER_TYPE.ADMINISTRATOR, "")); // USER_TYPE.ADMINISTRATOR, ""));
break; break;
case READ_ONLY: case READ_ONLY:
acls.add(new WorkspaceACL(acl.toString(), ACL_TYPE.READ_ONLY, acls.add(new WorkspaceACL(acl.toString(), ACL_TYPE.READ_ONLY, "Read Only", false, USER_TYPE.OTHER,
"Read Only", false, USER_TYPE.OTHER,
"Users can read any file but cannot update/delete")); "Users can read any file but cannot update/delete"));
break; break;
case WRITE_OWNER: case WRITE_OWNER:
acls.add(new WorkspaceACL(acl.toString(), ACL_TYPE.WRITE_OWNER, acls.add(new WorkspaceACL(acl.toString(), ACL_TYPE.WRITE_OWNER, "Write Own", true, USER_TYPE.OTHER,
"Write Own", true, USER_TYPE.OTHER,
"Users can update/delete only their files")); "Users can update/delete only their files"));
break; break;
case WRITE_ALL: case WRITE_ALL:
acls.add(new WorkspaceACL(acl.toString(), ACL_TYPE.WRITE_ANY, acls.add(new WorkspaceACL(acl.toString(), ACL_TYPE.WRITE_ANY, "Write Any", false, USER_TYPE.OTHER,
"Write Any", false, USER_TYPE.OTHER,
"Any user can update/delete any file")); "Any user can update/delete any file"));
break; break;
default: default:
// acls.add(new WorkspaceACL(acl.toString(), ACL_TYPE.WRITE_OWNER, // acls.add(new WorkspaceACL(acl.toString(),
// ACL_TYPE.WRITE_OWNER,
// acl.toString(), false, USER_TYPE.OTHER, "")); // acl.toString(), false, USER_TYPE.OTHER, ""));
break; break;
} }
@ -545,19 +519,96 @@ public class GWTWorkspaceSharingBuilder {
return acls; return acls;
} }
/**
* Gets the workspace acl from ac ls.
*
* @param listACL
* the types
* @return the workspace acl from ac ls
* @throws Exception
* the exception
*/
public List<WorkspaceACL> getWorkspaceACLFromACLs(List<ACL> listACL) throws Exception {
List<WorkspaceACL> acls = new ArrayList<WorkspaceACL>();
for (ACL acl : listACL) {
List<AccessType> listAccessType = acl.getAccessTypes();
for (AccessType accessType : listAccessType) {
switch (accessType) {
case ADMINISTRATOR:
// acls.add(new WorkspaceACL(acl.toString(),
// ACL_TYPE.ADMINISTRATOR, "Admin", false,
// USER_TYPE.ADMINISTRATOR, ""));
break;
case READ_ONLY:
acls.add(new WorkspaceACL(acl.toString(), ACL_TYPE.READ_ONLY, "Read Only", false, USER_TYPE.OTHER,
"Users can read any file but cannot update/delete"));
break;
case WRITE_OWNER:
acls.add(new WorkspaceACL(acl.toString(), ACL_TYPE.WRITE_OWNER, "Write Own", true, USER_TYPE.OTHER,
"Users can update/delete only their files"));
break;
case WRITE_ALL:
acls.add(new WorkspaceACL(acl.toString(), ACL_TYPE.WRITE_ANY, "Write Any", false, USER_TYPE.OTHER,
"Any user can update/delete any file"));
break;
default:
// acls.add(new WorkspaceACL(acl.toString(),
// ACL_TYPE.WRITE_OWNER,
// acl.toString(), false, USER_TYPE.OTHER, ""));
break;
}
}
}
if (acls.size() == 0)
throw new Exception("No ACLs rules found!");
return acls;
}
/** /**
* Gets the formatted html acl from ac ls. * Gets the formatted html acl from ac ls.
* *
* @param aclOwner the acl owner * @param acls
* the acl owner
* @return the formatted html acl from ac ls * @return the formatted html acl from ac ls
*/ */
public String getFormattedHtmlACLFromACLs(Map<ACLType, List<String>> aclOwner) { public String getFormattedHtmlACLFromACLs(List<ACL> acls) {
String html = "<div style=\"width: 100%; text-align:left; font-size: 10px;\">"; String html = "<div style=\"width: 100%; text-align:left; font-size: 10px;\">";
logger.trace("Formatting "+aclOwner.size() +" ACL/s"); logger.trace("Formatting " + acls.size() + " ACL/s");
for (ACLType type : aclOwner.keySet()) { Map<AccessType, List<String>> aclOwner = new HashMap<>();
for (ACL acl : acls) {
for (AccessType accessType : acl.getAccessTypes()) {
if (aclOwner.containsKey(accessType)) {
List<String> users = aclOwner.get(accessType);
boolean notfound = true;
for (String user : users) {
if (user.compareTo(acl.getPricipal()) == 0) {
notfound = false;
break;
}
}
if (notfound) {
users.add(acl.getPricipal());
aclOwner.put(accessType, users);
}
} else {
List<String> users = new ArrayList<String>();
users.add(acl.getPricipal());
aclOwner.put(accessType, users);
}
}
}
for (AccessType type : aclOwner.keySet()) {
List<String> listLogins = aclOwner.get(type); List<String> listLogins = aclOwner.get(type);
html += "<span style=\"font-weight:bold; padding-top: 5px;\">" + type + ": </span>"; html += "<span style=\"font-weight:bold; padding-top: 5px;\">" + type + ": </span>";
@ -574,7 +625,6 @@ public class GWTWorkspaceSharingBuilder {
} }
html += "</div>"; html += "</div>";
return html; return html;
} }

View File

@ -7,21 +7,20 @@ import javax.servlet.http.HttpServletRequest;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
import org.gcube.applicationsupportlayer.social.NotificationsManager; import org.gcube.applicationsupportlayer.social.NotificationsManager;
import org.gcube.common.homelibrary.home.exceptions.InternalErrorException; import org.gcube.applicationsupportlayer.social.shared.SocialFileItem;
import org.gcube.common.homelibrary.home.workspace.WorkspaceItem; import org.gcube.applicationsupportlayer.social.shared.SocialSharedFolder;
import org.gcube.common.homelibrary.home.workspace.WorkspaceSharedFolder;
import org.gcube.common.scope.impl.ScopeBean; import org.gcube.common.scope.impl.ScopeBean;
import org.gcube.common.storagehub.model.items.Item;
import org.gcube.common.storagehub.model.items.SharedFolder;
import org.gcube.portlets.widgets.workspacesharingwidget.server.util.DiffereceBeetweenInfoContactModel; import org.gcube.portlets.widgets.workspacesharingwidget.server.util.DiffereceBeetweenInfoContactModel;
import org.gcube.portlets.widgets.workspacesharingwidget.server.util.UserUtil; import org.gcube.portlets.widgets.workspacesharingwidget.server.util.UserUtil;
import org.gcube.portlets.widgets.workspacesharingwidget.server.util.WsUtil; import org.gcube.portlets.widgets.workspacesharingwidget.server.util.WsUtil;
import org.gcube.portlets.widgets.workspacesharingwidget.shared.InfoContactModel; import org.gcube.portlets.widgets.workspacesharingwidget.shared.InfoContactModel;
/** /**
* The Class NotificationsProducer. * The Class NotificationsProducer.
* *
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it * @author Francesco Mangiacrapa Nov 25, 2016
* Nov 25, 2016
*/ */
public class NotificationsProducer { public class NotificationsProducer {
@ -30,11 +29,11 @@ public class NotificationsProducer {
protected NotificationsManager notificationsMng; protected NotificationsManager notificationsMng;
protected String userId; protected String userId;
/** /**
* Instantiates a new notifications producer. * Instantiates a new notifications producer.
* *
* @param request the request * @param request
* the request
*/ */
public NotificationsProducer(HttpServletRequest request) { public NotificationsProducer(HttpServletRequest request) {
this.notificationsMng = WsUtil.getNotificationManager(request); this.notificationsMng = WsUtil.getNotificationManager(request);
@ -53,7 +52,8 @@ public class NotificationsProducer {
/** /**
* Sets the notification mng. * Sets the notification mng.
* *
* @param notificationMng the new notification mng * @param notificationMng
* the new notification mng
*/ */
public void setNotificationMng(NotificationsManager notificationMng) { public void setNotificationMng(NotificationsManager notificationMng) {
this.notificationsMng = notificationMng; this.notificationsMng = notificationMng;
@ -62,10 +62,12 @@ public class NotificationsProducer {
/** /**
* Runs a new thread to notify the contacts passed in input. * Runs a new thread to notify the contacts passed in input.
* *
* @param listContacts the list contacts * @param listContacts
* @param sharedFolder the shared folder * the list contacts
* @param sharedFolder
* the shared folder
*/ */
public void notifyFolderSharing(final List<InfoContactModel> listContacts, final WorkspaceSharedFolder sharedFolder) { public void notifyFolderSharing(final List<InfoContactModel> listContacts, final SharedFolder sharedFolder) {
new Thread() { new Thread() {
@Override @Override
@ -75,16 +77,22 @@ public class NotificationsProducer {
for (InfoContactModel infoContactModel : listContacts) { for (InfoContactModel infoContactModel : listContacts) {
try { try {
//NOTIFIES ONLY THE USERS THAT ARE DIFFERENT FROM CURRENT USER // NOTIFIES ONLY THE USERS THAT ARE DIFFERENT FROM
// CURRENT USER
if (infoContactModel.getLogin().compareTo(userId) != 0) { if (infoContactModel.getLogin().compareTo(userId) != 0) {
logger.trace("Sending notification new share folder "+sharedFolder.getName()+" for user "+infoContactModel.getLogin()); logger.trace("Sending notification new share folder " + sharedFolder.getName()
+ " for user " + infoContactModel.getLogin());
// DEBUG // DEBUG
System.out.println("Sending notification new share folder "+sharedFolder.getName()+" for user "+infoContactModel.getLogin()); System.out.println("Sending notification new share folder " + sharedFolder.getName()
+ " for user " + infoContactModel.getLogin());
boolean notify = notificationsMng.notifyFolderSharing(infoContactModel.getLogin(), sharedFolder); SocialItemFactory socialItemFactor = new SocialItemFactory();
SocialSharedFolder socialSharedFolder = socialItemFactor
.createSocialSharedFolder(sharedFolder);
boolean notify = notificationsMng.notifyFolderSharing(infoContactModel.getLogin(),
socialSharedFolder);
if (!notify) if (!notify)
logger.error("An error occured when notify user: " + infoContactModel.getLogin()); logger.error("An error occured when notify user: " + infoContactModel.getLogin());
@ -99,21 +107,24 @@ public class NotificationsProducer {
} }
}.start(); }.start();
} }
/** /**
* Runs a new thread to notify the contacts passed in input. * Runs a new thread to notify the contacts passed in input.
* *
* @param listSharedContact the list shared contact * @param listSharedContact
* @param folderItem the folder item * the list shared contact
* @param itemOldName the item old name * @param folderItem
* @param itemNewName the item new name * the folder item
* @param idsharedFolder the idshared folder * @param itemOldName
* the item old name
* @param itemNewName
* the item new name
* @param idsharedFolder
* the idshared folder
*/ */
public void notifyFolderRenamed(final List<InfoContactModel> listSharedContact, final WorkspaceItem folderItem, final String itemOldName, final String itemNewName, final String idsharedFolder) { public void notifyFolderRenamed(final List<InfoContactModel> listSharedContact, final Item folderItem,
final String itemOldName, final String itemNewName, final String idsharedFolder) {
new Thread() { new Thread() {
@Override @Override
@ -122,29 +133,32 @@ public class NotificationsProducer {
logger.trace("Send notifies shared folder was renamed is running..."); logger.trace("Send notifies shared folder was renamed is running...");
try { try {
NotificationsUtil notificationsUtil=new NotificationsUtil();
if(NotificationsUtil.checkIsRootFolderShared(folderItem.getId(), idsharedFolder)){ if (notificationsUtil.checkIsRootFolderShared(folderItem.getId(), idsharedFolder)) {
logger.trace("Notification isn't sent because the event is on root shared folder"); logger.trace("Notification isn't sent because the event is on root shared folder");
return; return;
} }
} catch (InternalErrorException e1) { } catch (Exception e1) {
logger.error("An error occurred in checkIsRootFolderShared ", e1); logger.error("An error occurred in checkIsRootFolderShared ", e1);
return; return;
} }
for (InfoContactModel infoContactModel : listSharedContact) { for (InfoContactModel infoContactModel : listSharedContact) {
try { try {
//NOTIFIES ONLY THE USERS THAT ARE DIFFERENT FROM CURRENT USER // NOTIFIES ONLY THE USERS THAT ARE DIFFERENT FROM
// CURRENT USER
if (infoContactModel.getLogin().compareTo(userId) != 0) { if (infoContactModel.getLogin().compareTo(userId) != 0) {
logger.trace("Sending notification share folder "+itemOldName+" was renamed as " + itemNewName+ "for user "+infoContactModel.getLogin()); logger.trace("Sending notification share folder " + itemOldName + " was renamed as "
+ itemNewName + "for user " + infoContactModel.getLogin());
// DEBUG // DEBUG
System.out.println("Sending notification share folder "+itemOldName+" was renamed as " + itemNewName+ "for user "+infoContactModel.getLogin()); System.out.println("Sending notification share folder " + itemOldName + " was renamed as "
+ itemNewName + "for user " + infoContactModel.getLogin());
boolean notify = notificationsMng.notifyFolderRenaming(infoContactModel.getLogin(), itemOldName, itemNewName, idsharedFolder);
boolean notify = notificationsMng.notifyFolderRenaming(infoContactModel.getLogin(),
itemOldName, itemNewName, idsharedFolder);
if (!notify) if (!notify)
logger.error("An error occured when notify user: " + infoContactModel.getLogin()); logger.error("An error occured when notify user: " + infoContactModel.getLogin());
@ -159,19 +173,22 @@ public class NotificationsProducer {
} }
}.start(); }.start();
} }
/** /**
* Runs a new thread to notify the contacts passed in input. * Runs a new thread to notify the contacts passed in input.
* *
* @param listSharedContact the list shared contact * @param listSharedContact
* @param previousName the previous name * the list shared contact
* @param item the item * @param previousName
* @param sharedFolder the shared folder * the previous name
* @param item
* the item
* @param sharedFolder
* the shared folder
*/ */
public void notifyItemRenamed(final List<InfoContactModel> listSharedContact, final String previousName, final WorkspaceItem item, final WorkspaceSharedFolder sharedFolder) { public void notifyItemRenamed(final List<InfoContactModel> listSharedContact, final String previousName,
final Item item, final SharedFolder sharedFolder) {
new Thread() { new Thread() {
@Override @Override
@ -181,17 +198,26 @@ public class NotificationsProducer {
for (InfoContactModel infoContactModel : listSharedContact) { for (InfoContactModel infoContactModel : listSharedContact) {
try { try {
//NOTIFIES ONLY THE USERS THAT ARE DIFFERENT FROM CURRENT USER // NOTIFIES ONLY THE USERS THAT ARE DIFFERENT FROM
// CURRENT USER
if (infoContactModel.getLogin().compareTo(userId) != 0) { if (infoContactModel.getLogin().compareTo(userId) != 0) {
logger.trace("Sending notification to user "+infoContactModel.getLogin() + " updated item "+item.getName()); logger.trace("Sending notification to user " + infoContactModel.getLogin()
+ " updated item " + item.getName());
// DEBUG // DEBUG
System.out.println("Sending notification to user "+infoContactModel.getLogin() + " updated item "+item.getName()); System.out.println("Sending notification to user " + infoContactModel.getLogin()
+ " updated item " + item.getName());
// notificationsMng.notifyItemRenaming(infoContactModel.getLogin(), previousName, item, sharedFolder); // notificationsMng.notifyItemRenaming(infoContactModel.getLogin(),
// previousName, item, sharedFolder);
SocialItemFactory socialItemFactor = new SocialItemFactory();
SocialSharedFolder socialSharedFolder = socialItemFactor
.createSocialSharedFolder(sharedFolder);
SocialFileItem socialFileItem = socialItemFactor.createSocialFileItem(item, sharedFolder);
boolean notify = notificationsMng.notifyItemRenaming(infoContactModel.getLogin(), previousName, item, sharedFolder); boolean notify = notificationsMng.notifyItemRenaming(infoContactModel.getLogin(),
previousName, socialFileItem, socialSharedFolder);
if (!notify) if (!notify)
logger.error("An error occured when notify user: " + infoContactModel.getLogin()); logger.error("An error occured when notify user: " + infoContactModel.getLogin());
@ -206,18 +232,20 @@ public class NotificationsProducer {
} }
}.start(); }.start();
} }
/** /**
* Runs a new thread to notify the new contacts passed in input. * Runs a new thread to notify the new contacts passed in input.
* *
* @param listSharedContact - list of contacts already shared * @param listSharedContact
* @param listSharingContact - list of "new" contacts witch share * - list of contacts already shared
* @param sharedFolder - the shared folder * @param listSharingContact
* - list of "new" contacts witch share
* @param sharedFolder
* - the shared folder
*/ */
public void notifyAddedUsersToSharing(final List<InfoContactModel> listSharedContact, final List<InfoContactModel> listSharingContact, final WorkspaceSharedFolder sharedFolder) { public void notifyAddedUsersToSharing(final List<InfoContactModel> listSharedContact,
final List<InfoContactModel> listSharingContact, final SharedFolder sharedFolder) {
new Thread() { new Thread() {
@Override @Override
@ -225,7 +253,8 @@ public class NotificationsProducer {
try { try {
DiffereceBeetweenInfoContactModel diff = new DiffereceBeetweenInfoContactModel(listSharingContact, listSharedContact); DiffereceBeetweenInfoContactModel diff = new DiffereceBeetweenInfoContactModel(listSharingContact,
listSharedContact);
List<InfoContactModel> listExclusiveContacts = diff.getDifferentsContacts(); List<InfoContactModel> listExclusiveContacts = diff.getDifferentsContacts();
@ -233,20 +262,42 @@ public class NotificationsProducer {
if (listExclusiveContacts.size() > 0) { if (listExclusiveContacts.size() > 0) {
if(listExclusiveContacts.size()==1){ //CASE ONLY ONE CONTACS WAS ADDED if (listExclusiveContacts.size() == 1) { // CASE ONLY
// ONE
// CONTACS
// WAS ADDED
InfoContactModel infoContactModel = listExclusiveContacts.get(0); InfoContactModel infoContactModel = listExclusiveContacts.get(0);
for (InfoContactModel contact : listSharedContact) { //NOTIFIES ALREADY SHARED CONTACTS THATH A NEW USER WAS ADDED for (InfoContactModel contact : listSharedContact) { // NOTIFIES
// ALREADY
// SHARED
// CONTACTS
// THATH
// A
// NEW
// USER
// WAS
// ADDED
try { try {
logger.trace("Sending notification to user "+contact.getLogin()+", added user "+ infoContactModel.getLogin() +" to share folder "+sharedFolder.getName()); logger.trace("Sending notification to user " + contact.getLogin() + ", added user "
+ infoContactModel.getLogin() + " to share folder "
+ sharedFolder.getName());
// DEBUG // DEBUG
// System.out.println("Sending notification added user "+ infoContactModel.getLogin() +" to share folder "+sharedFolder.getName() + " for user "+contact.getLogin()); // System.out.println("Sending notification
// added user "+ infoContactModel.getLogin()
// +" to share folder
// "+sharedFolder.getName() + " for user
// "+contact.getLogin());
SocialItemFactory socialItemFactor = new SocialItemFactory();
SocialSharedFolder socialSharedFolder = socialItemFactor
.createSocialSharedFolder(sharedFolder);
boolean notify = notificationsMng.notifyFolderAddedUser(contact.getLogin(), sharedFolder, infoContactModel.getLogin()); boolean notify = notificationsMng.notifyFolderAddedUser(contact.getLogin(),
socialSharedFolder, infoContactModel.getLogin());
if (!notify) if (!notify)
logger.error("An error occured when notifies user: " + contact.getLogin()); logger.error("An error occured when notifies user: " + contact.getLogin());
@ -259,22 +310,45 @@ public class NotificationsProducer {
List<InfoContactModel> listCts = new ArrayList<InfoContactModel>(); List<InfoContactModel> listCts = new ArrayList<InfoContactModel>();
listCts.add(infoContactModel); listCts.add(infoContactModel);
notifyFolderSharing(listCts, sharedFolder); //NOTIFIER NEW USER OF SHARING FOLDER notifyFolderSharing(listCts, sharedFolder); // NOTIFIER
// NEW
// USER
// OF
// SHARING
// FOLDER
} else { // CASE MORE THEN ONE CONTACS WAS ADDED } else { // CASE MORE THEN ONE CONTACS WAS ADDED
List<String> listLogins = UserUtil.getListLoginByInfoContactModel(listExclusiveContacts); List<String> listLogins = UserUtil.getListLoginByInfoContactModel(listExclusiveContacts);
for (InfoContactModel contact : listSharedContact) { //NOTIFIES ALREADY SHARED CONTACTS THATH A NEW USER WAS ADDED for (InfoContactModel contact : listSharedContact) { // NOTIFIES
// ALREADY
// SHARED
// CONTACTS
// THATH
// A
// NEW
// USER
// WAS
// ADDED
try { try {
logger.trace("Sending notification to user "+contact.getLogin()+", added "+listLogins.size()+" users to share folder "+sharedFolder.getName()); logger.trace("Sending notification to user " + contact.getLogin() + ", added "
+ listLogins.size() + " users to share folder " + sharedFolder.getName());
// DEBUG // DEBUG
// System.out.println("Sending notification added user "+ infoContactModel.getLogin() +" to share folder "+sharedFolder.getName() + " for user "+contact.getLogin()); // System.out.println("Sending notification
// added user "+ infoContactModel.getLogin()
// +" to share folder
// "+sharedFolder.getName() + " for user
// "+contact.getLogin());
SocialItemFactory socialItemFactor = new SocialItemFactory();
SocialSharedFolder socialSharedFolder = socialItemFactor
.createSocialSharedFolder(sharedFolder);
boolean notify = notificationsMng.notifyFolderAddedUsers(contact.getLogin(), sharedFolder, listLogins); boolean notify = notificationsMng.notifyFolderAddedUsers(contact.getLogin(),
socialSharedFolder, listLogins);
if (!notify) if (!notify)
logger.error("An error occured when notifies user: " + contact.getLogin()); logger.error("An error occured when notifies user: " + contact.getLogin());
@ -285,9 +359,12 @@ public class NotificationsProducer {
} }
} }
notifyFolderSharing(listExclusiveContacts, sharedFolder); // NOTIFIER
notifyFolderSharing(listExclusiveContacts, sharedFolder); //NOTIFIER NEW USER OF SHARING FOLDER // NEW
// USER
// OF
// SHARING
// FOLDER
} }
} }
@ -302,15 +379,15 @@ public class NotificationsProducer {
} }
/** /**
* Runs a new thread to notify the contacts passed in input. * Runs a new thread to notify the contacts passed in input.
* *
* @param listContacts the list contacts * @param listContacts
* @param unSharedFolder the un shared folder * the list contacts
* @param unSharedFolder
* the un shared folder
*/ */
public void notifyFolderUnSharing(final List<InfoContactModel> listContacts, final WorkspaceSharedFolder unSharedFolder) { public void notifyFolderUnSharing(final List<InfoContactModel> listContacts, final SharedFolder unSharedFolder) {
new Thread() { new Thread() {
@Override @Override
@ -322,14 +399,23 @@ public class NotificationsProducer {
for (InfoContactModel infoContactModel : listContacts) { for (InfoContactModel infoContactModel : listContacts) {
try { try {
//NOTIFIES ONLY THE USERS THAT ARE DIFFERENT FROM CURRENT USER // NOTIFIES ONLY THE USERS THAT ARE DIFFERENT FROM
// CURRENT USER
if (infoContactModel.getLogin().compareTo(userId) != 0) { if (infoContactModel.getLogin().compareTo(userId) != 0) {
logger.trace("Sending notification to user "+infoContactModel.getLogin() +" un shared folder "+unSharedFolder.getName()); logger.trace("Sending notification to user " + infoContactModel.getLogin()
+ " un shared folder " + unSharedFolder.getName());
// DEBUG // DEBUG
// System.out.println("Sending notification to user "+infoContactModel.getLogin() +" un shared folder "+unSharedFolder.getName()); // System.out.println("Sending notification to user
boolean notify = notificationsMng.notifyFolderRemovedUser(infoContactModel.getLogin(), unSharedFolder); // "+infoContactModel.getLogin() +" un shared folder
// "+unSharedFolder.getName());
SocialItemFactory socialItemFactor = new SocialItemFactory();
SocialSharedFolder socialSharedFolder = socialItemFactor
.createSocialSharedFolder(unSharedFolder);
boolean notify = notificationsMng.notifyFolderRemovedUser(infoContactModel.getLogin(),
socialSharedFolder);
if (!notify) if (!notify)
logger.error("An error occured when notifies user: " + infoContactModel.getLogin()); logger.error("An error occured when notifies user: " + infoContactModel.getLogin());
@ -347,16 +433,18 @@ public class NotificationsProducer {
} }
/** /**
* Runs a new thread to notify the contacts passed in input. * Runs a new thread to notify the contacts passed in input.
* *
* @param listContacts the list contacts * @param listContacts
* @param workspaceItem the workspace item * the list contacts
* @param sharedFolder the shared folder * @param item
* the workspace item
* @param sharedFolder
* the shared folder
*/ */
public void notifyAddedItemToSharing(final List<InfoContactModel> listContacts, final WorkspaceItem workspaceItem, final WorkspaceSharedFolder sharedFolder) { public void notifyAddedItemToSharing(final List<InfoContactModel> listContacts, final Item item,
final SharedFolder sharedFolder) {
new Thread() { new Thread() {
@Override @Override
@ -371,23 +459,33 @@ public class NotificationsProducer {
for (InfoContactModel infoContactModel : listContacts) { for (InfoContactModel infoContactModel : listContacts) {
try { try {
//NOTIFIES ONLY THE USERS THAT ARE DIFFERENT FROM CURRENT USER // NOTIFIES ONLY THE USERS THAT ARE DIFFERENT FROM
// CURRENT USER
if (infoContactModel.getLogin().compareTo(userId) != 0) { if (infoContactModel.getLogin().compareTo(userId) != 0) {
logger.trace("Sending notification to user "+infoContactModel.getLogin() +" added item "+workspaceItem.getName()+" in shared folder "+sharedFolder.getName()); logger.trace("Sending notification to user " + infoContactModel.getLogin() + " added item "
+ item.getName() + " in shared folder " + sharedFolder.getName());
// DEBUG // DEBUG
System.out.println("Sending notification to user "+infoContactModel.getLogin() +" added item "+workspaceItem.getName()+" in shared folder "+sharedFolder.getName()); System.out.println("Sending notification to user " + infoContactModel.getLogin()
+ " added item " + item.getName() + " in shared folder " + sharedFolder.getName());
// DEBUG // DEBUG
// System.out.println("Send notify folder un share user "+infoContactModel.getLogin()); // System.out.println("Send notify folder un share
// user "+infoContactModel.getLogin());
SocialItemFactory socialItemFactor = new SocialItemFactory();
SocialSharedFolder socialSharedFolder = socialItemFactor
.createSocialSharedFolder(sharedFolder);
SocialFileItem socialFileItem = socialItemFactor.createSocialFileItem(item, sharedFolder);
boolean notify = notificationsMng.notifyAddedItem(infoContactModel.getLogin(), workspaceItem, sharedFolder); boolean notify = notificationsMng.notifyAddedItem(infoContactModel.getLogin(),
socialFileItem, socialSharedFolder);
if (!notify) { if (!notify) {
logger.error("An error occured when notify user: " + infoContactModel.getLogin()); logger.error("An error occured when notify user: " + infoContactModel.getLogin());
// DEBUG // DEBUG
// System.out.println("An error occured when notify user: "+infoContactModel.getLogin()); // System.out.println("An error occured when
// notify user: "+infoContactModel.getLogin());
} }
} }
} catch (Exception e) { } catch (Exception e) {
@ -399,21 +497,25 @@ public class NotificationsProducer {
logger.trace("notifies of added item in shared folder is completed"); logger.trace("notifies of added item in shared folder is completed");
// DEBUG // DEBUG
// System.out.println("notifies of added item in shared folder is completed"); // System.out.println("notifies of added item in shared folder
// is completed");
} }
}.start(); }.start();
} }
/** /**
* Runs a new thread to notify the contacts passed in input. * Runs a new thread to notify the contacts passed in input.
* *
* @param listContacts the list contacts * @param listContacts
* @param workspaceItem the workspace item * the list contacts
* @param sharedFolder the shared folder * @param item
* the workspace item
* @param sharedFolder
* the shared folder
*/ */
public void notifyUpdatedItemToSharing(final List<InfoContactModel> listContacts, final WorkspaceItem workspaceItem, final WorkspaceSharedFolder sharedFolder) { public void notifyUpdatedItemToSharing(final List<InfoContactModel> listContacts, final Item item,
final SharedFolder sharedFolder) {
new Thread() { new Thread() {
@Override @Override
@ -423,28 +525,42 @@ public class NotificationsProducer {
logger.trace("Send notifies updated item in shared folder is running..."); logger.trace("Send notifies updated item in shared folder is running...");
// DEBUG // DEBUG
// System.out.println("Send notifies updated item in shared folder is running..."); // System.out.println("Send notifies updated item in shared
// folder is running...");
for (InfoContactModel infoContactModel : listContacts) { for (InfoContactModel infoContactModel : listContacts) {
try { try {
//NOTIFIES ONLY THE USERS THAT ARE DIFFERENT FROM CURRENT USER // NOTIFIES ONLY THE USERS THAT ARE DIFFERENT FROM
// CURRENT USER
if (infoContactModel.getLogin().compareTo(userId) != 0) { if (infoContactModel.getLogin().compareTo(userId) != 0) {
logger.trace("Sending notification to user "+infoContactModel.getLogin() +" updated item "+workspaceItem.getName()+" in shared folder "+sharedFolder.getName()); logger.trace(
"Sending notification to user " + infoContactModel.getLogin() + " updated item "
+ item.getName() + " in shared folder " + sharedFolder.getName());
// DEBUG // DEBUG
// System.out.println("Sending notification to user "+infoContactModel.getLogin() +" updated item "+workspaceItem.getName()+" in shared folder "+sharedFolder.getName()); // System.out.println("Sending notification to user
// "+infoContactModel.getLogin() +" updated item
// "+workspaceItem.getName()+" in shared folder
// "+sharedFolder.getName());
// DEBUG // DEBUG
// System.out.println("Send notify folder un share user "+infoContactModel.getLogin()); // System.out.println("Send notify folder un share
// user "+infoContactModel.getLogin());
SocialItemFactory socialItemFactor = new SocialItemFactory();
SocialSharedFolder socialSharedFolder = socialItemFactor
.createSocialSharedFolder(sharedFolder);
SocialFileItem socialFileItem = socialItemFactor.createSocialFileItem(item, sharedFolder);
boolean notify = notificationsMng.notifyUpdatedItem(infoContactModel.getLogin(), workspaceItem, sharedFolder); boolean notify = notificationsMng.notifyUpdatedItem(infoContactModel.getLogin(),
socialFileItem, socialSharedFolder);
if (!notify) { if (!notify) {
logger.error("An error updated when notify user: " + infoContactModel.getLogin()); logger.error("An error updated when notify user: " + infoContactModel.getLogin());
// DEBUG // DEBUG
// System.out.println("An error updated when notify user: "+infoContactModel.getLogin()); // System.out.println("An error updated when
// notify user: "+infoContactModel.getLogin());
} }
} }
} catch (Exception e) { } catch (Exception e) {
@ -456,25 +572,25 @@ public class NotificationsProducer {
logger.trace("notifies of updated item in shared folder is completed"); logger.trace("notifies of updated item in shared folder is completed");
// DEBUG // DEBUG
// System.out.println("notifies of updated item in shared folder is completed"); // System.out.println("notifies of updated item in shared folder
// is completed");
} }
}.start(); }.start();
} }
/** /**
* Runs a new thread to notify the contacts passed in input. * Runs a new thread to notify the contacts passed in input.
* *
* @param listContacts the list contacts * @param listContacts
* @param workspaceItem the workspace item * the list contacts
* @param sharedFolder the shared folder * @param item
* the workspace item
* @param sharedFolder
* the shared folder
*/ */
public void notifyMovedItemToSharing(final List<InfoContactModel> listContacts, final WorkspaceItem workspaceItem, final WorkspaceSharedFolder sharedFolder) { public void notifyMovedItemToSharing(final List<InfoContactModel> listContacts, final Item item,
final SharedFolder sharedFolder) {
new Thread() { new Thread() {
@Override @Override
@ -484,39 +600,51 @@ public class NotificationsProducer {
// printContacts(listContacts); // printContacts(listContacts);
try { try {
NotificationsUtil notificationsUtil=new NotificationsUtil();
if(NotificationsUtil.checkIsRootFolderShared(workspaceItem.getId(), sharedFolder.getId())){ if (notificationsUtil.checkIsRootFolderShared(item.getId(), sharedFolder.getId())) {
logger.trace("Notification isn't sent because the event is on root shared folder"); logger.trace("Notification isn't sent because the event is on root shared folder");
return; return;
} }
} catch (InternalErrorException e1) { } catch (Exception e1) {
logger.error("An error occurred in checkIsRootFolderShared ", e1); logger.error("An error occurred in checkIsRootFolderShared ", e1);
return; return;
} }
logger.trace("Sending notification moved item in shared folder is running..."); logger.trace("Sending notification moved item in shared folder is running...");
// System.out.println("Sending notification moved item in shared folder is running..."); // System.out.println("Sending notification moved item in shared
// folder is running...");
for (InfoContactModel infoContactModel : listContacts) { for (InfoContactModel infoContactModel : listContacts) {
try { try {
//NOTIFIES ONLY THE USERS THAT ARE DIFFERENT FROM CURRENT USER // NOTIFIES ONLY THE USERS THAT ARE DIFFERENT FROM
// CURRENT USER
if (infoContactModel.getLogin().compareTo(userId) != 0) { if (infoContactModel.getLogin().compareTo(userId) != 0) {
logger.trace("Sending notification to user "+infoContactModel.getLogin() +" moved item "+workspaceItem.getName()+" in shared folder "+sharedFolder.getName()); logger.trace("Sending notification to user " + infoContactModel.getLogin() + " moved item "
+ item.getName() + " in shared folder " + sharedFolder.getName());
// DEBUG // DEBUG
// System.out.println("Sending notification to user "+infoContactModel.getLogin() +" moved item "+workspaceItem.getName()+" in shared folder "+sharedFolder.getName()); // System.out.println("Sending notification to user
// "+infoContactModel.getLogin() +" moved item
// "+workspaceItem.getName()+" in shared folder
// "+sharedFolder.getName());
SocialItemFactory socialItemFactor = new SocialItemFactory();
SocialSharedFolder socialSharedFolder = socialItemFactor
.createSocialSharedFolder(sharedFolder);
SocialFileItem socialFileItem = socialItemFactor.createSocialFileItem(item, sharedFolder);
boolean notify = notificationsMng.notifyMovedItem(infoContactModel.getLogin(), workspaceItem, sharedFolder); boolean notify = notificationsMng.notifyMovedItem(infoContactModel.getLogin(),
socialFileItem, socialSharedFolder);
if (!notify) { if (!notify) {
logger.error("An error occured when notify user: " + infoContactModel.getLogin()); logger.error("An error occured when notify user: " + infoContactModel.getLogin());
// DEBUG // DEBUG
// System.out.println("An error occured when notify user: "+infoContactModel.getLogin()); // System.out.println("An error occured when
// notify user: "+infoContactModel.getLogin());
} }
} }
} catch (Exception e) { } catch (Exception e) {
@ -528,25 +656,26 @@ public class NotificationsProducer {
logger.trace("notifies of moved item in shared folder is completed"); logger.trace("notifies of moved item in shared folder is completed");
// DEBUG // DEBUG
// System.out.println("notifies of moved item in shared folder is completed"); // System.out.println("notifies of moved item in shared folder
// is completed");
} }
}.start(); }.start();
} }
/** /**
* Runs a new thread to notify the contacts passed in input. * Runs a new thread to notify the contacts passed in input.
* *
* @param listContacts the list contacts * @param listContacts
* @param itemName the item name * the list contacts
* @param sharedFolder the shared folder * @param itemName
* the item name
* @param sharedFolder
* the shared folder
*/ */
public void notifyRemovedItemToSharing(final List<InfoContactModel> listContacts, final String itemName, final WorkspaceSharedFolder sharedFolder) { public void notifyRemovedItemToSharing(final List<InfoContactModel> listContacts, final String itemName,
final SharedFolder sharedFolder) {
new Thread() { new Thread() {
@Override @Override
@ -566,26 +695,36 @@ public class NotificationsProducer {
logger.trace("Sending notification removed item in shared folder is running..."); logger.trace("Sending notification removed item in shared folder is running...");
// System.out.println("Sending notification removed item in shared folder is running..."); // System.out.println("Sending notification removed item in
// shared folder is running...");
for (InfoContactModel infoContactModel : listContacts) { for (InfoContactModel infoContactModel : listContacts) {
try { try {
//NOTIFIES ONLY THE USERS THAT ARE DIFFERENT FROM CURRENT USER // NOTIFIES ONLY THE USERS THAT ARE DIFFERENT FROM
// CURRENT USER
if (infoContactModel.getLogin().compareTo(userId) != 0) { if (infoContactModel.getLogin().compareTo(userId) != 0) {
logger.trace("Sending notification to user "+infoContactModel.getLogin() +" removed item "+itemName+" in shared folder "+sharedFolder.getName()); logger.trace("Sending notification to user " + infoContactModel.getLogin()
+ " removed item " + itemName + " in shared folder " + sharedFolder.getName());
// DEBUG // DEBUG
// System.out.println("Sending notification to user "+infoContactModel.getLogin() +" removed item "+itemName+" in shared folder "+sharedFolder.getName()); // System.out.println("Sending notification to user
// "+infoContactModel.getLogin() +" removed item
// "+itemName+" in shared folder
// "+sharedFolder.getName());
SocialItemFactory socialItemFactor=new SocialItemFactory();
SocialSharedFolder socialSharedFolder=socialItemFactor.createSocialSharedFolder(sharedFolder);
boolean notify = notificationsMng.notifyRemovedItem(infoContactModel.getLogin(), itemName, sharedFolder); boolean notify = notificationsMng.notifyRemovedItem(infoContactModel.getLogin(), itemName,
socialSharedFolder);
if (!notify) { if (!notify) {
logger.error("An error occured when notify user: " + infoContactModel.getLogin()); logger.error("An error occured when notify user: " + infoContactModel.getLogin());
// DEBUG // DEBUG
// System.out.println("An error occured when notify user: "+infoContactModel.getLogin()); // System.out.println("An error occured when
// notify user: "+infoContactModel.getLogin());
} }
} }
} catch (Exception e) { } catch (Exception e) {
@ -597,7 +736,8 @@ public class NotificationsProducer {
logger.trace("notifies of moved item in shared folder is completed"); logger.trace("notifies of moved item in shared folder is completed");
// DEBUG // DEBUG
// System.out.println("notifies of moved item in shared folder is completed"); // System.out.println("notifies of moved item in shared folder
// is completed");
} }
}.start(); }.start();
@ -606,12 +746,13 @@ public class NotificationsProducer {
/** /**
* Runs a new thread to notify the contacts passed in input. * Runs a new thread to notify the contacts passed in input.
* *
* @param listContacts the list contacts * @param listContacts
* @param folderNameDeleted the folder name deleted * the list contacts
* @param folderNameDeleted
* the folder name deleted
*/ */
public void notifySharedFolderDeleted(final List<InfoContactModel> listContacts, final String folderNameDeleted) { public void notifySharedFolderDeleted(final List<InfoContactModel> listContacts, final String folderNameDeleted) {
new Thread() { new Thread() {
@Override @Override
public void run() { public void run() {
@ -622,19 +763,23 @@ public class NotificationsProducer {
for (InfoContactModel infoContactModel : listContacts) { for (InfoContactModel infoContactModel : listContacts) {
try { try {
//NOTIFIES ONLY THE USERS THAT ARE DIFFERENT FROM CURRENT USER // NOTIFIES ONLY THE USERS THAT ARE DIFFERENT FROM
// CURRENT USER
if (infoContactModel.getLogin().compareTo(userId) != 0) { if (infoContactModel.getLogin().compareTo(userId) != 0) {
logger.trace("Sending notification to user "+infoContactModel.getLogin() +" deleted shared folder "+folderNameDeleted); logger.trace("Sending notification to user " + infoContactModel.getLogin()
+ " deleted shared folder " + folderNameDeleted);
// DEBUG // DEBUG
System.out.println("Sending notification to user "+infoContactModel.getLogin() +" deleted shared folder "+folderNameDeleted); System.out.println("Sending notification to user " + infoContactModel.getLogin()
+ " deleted shared folder " + folderNameDeleted);
// TODO // TODO
// boolean notify = notificationsMng. // boolean notify = notificationsMng.
// if(!notify) // if(!notify)
// logger.error("An error occured when notifies user: "+infoContactModel.getLogin()); // logger.error("An error occured when notifies
// user: "+infoContactModel.getLogin());
} }
} catch (Exception e) { } catch (Exception e) {
logger.error("An error occured in notifySharedFolderDeleted ", e); logger.error("An error occured in notifySharedFolderDeleted ", e);
@ -649,13 +794,12 @@ public class NotificationsProducer {
} }
// DEBUG // DEBUG
/** /**
* Prints the contacts. * Prints the contacts.
* *
* @param listContacts the list contacts * @param listContacts
* the list contacts
*/ */
private void printContacts(List<InfoContactModel> listContacts) { private void printContacts(List<InfoContactModel> listContacts) {
@ -666,24 +810,21 @@ public class NotificationsProducer {
System.out.println("End print contacts"); System.out.println("End print contacts");
} }
/*public static void main(String[] args) throws Exception /*
{ * public static void main(String[] args) throws Exception { String
String sessionID = "1"; * sessionID = "1"; String user = "francesco.mangiacrapa"; String
String user = "francesco.mangiacrapa"; * scopeString = "/gcube/devsec/devVRE"; String fullName =
String scopeString = "/gcube/devsec/devVRE"; * "Francesco Mangiacrapa";
String fullName = "Francesco Mangiacrapa"; *
* ScopeBean scope; ASLSession session;
ScopeBean scope; *
ASLSession session; * session = SessionManager.getInstance().getASLSession(sessionID, user);
* scope = new ScopeBean(scopeString); session.setScope(scope.toString());
session = SessionManager.getInstance().getASLSession(sessionID, user); * session.setUserAvatarId(user + "Avatar");
scope = new ScopeBean(scopeString); * session.setUserFullName(fullName);
session.setScope(scope.toString()); *
session.setUserAvatarId(user + "Avatar"); *
session.setUserFullName(fullName); * NotificationsProducer feeder = new NotificationsProducer(session); }
*/
NotificationsProducer feeder = new NotificationsProducer(session);
}*/
} }

View File

@ -5,13 +5,18 @@ package org.gcube.portlets.widgets.workspacesharingwidget.server.notifications;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import org.gcube.common.homelibary.model.items.type.WorkspaceItemType; import org.gcube.common.storagehub.client.dsl.FolderContainer;
import org.gcube.common.homelibrary.home.workspace.Workspace; import org.gcube.common.storagehub.client.dsl.OpenResolver;
import org.gcube.common.homelibrary.home.workspace.WorkspaceItem; import org.gcube.common.storagehub.client.dsl.StorageHubClient;
import org.gcube.common.homelibrary.home.workspace.WorkspaceSharedFolder; import org.gcube.common.storagehub.model.Metadata;
import org.gcube.common.storagehub.model.acls.ACL;
import org.gcube.common.storagehub.model.items.FolderItem;
import org.gcube.common.storagehub.model.items.Item;
import org.gcube.common.storagehub.model.items.SharedFolder;
import org.gcube.portlets.widgets.workspacesharingwidget.server.GWTWorkspaceSharingBuilder; import org.gcube.portlets.widgets.workspacesharingwidget.server.GWTWorkspaceSharingBuilder;
import org.gcube.portlets.widgets.workspacesharingwidget.server.util.WsUtil; import org.gcube.portlets.widgets.workspacesharingwidget.server.util.WsUtil;
import org.gcube.portlets.widgets.workspacesharingwidget.shared.InfoContactModel; import org.gcube.portlets.widgets.workspacesharingwidget.shared.InfoContactModel;
@ -21,24 +26,29 @@ import org.slf4j.LoggerFactory;
/** /**
* The Class NotificationsUtil. * The Class NotificationsUtil.
* *
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it * @author Francesco Mangiacrapa
* @May 27, 2013 * May 27, 2013
*/ */
public class NotificationsUtil { public class NotificationsUtil {
protected static Logger logger = LoggerFactory.getLogger(NotificationsUtil.class); protected static Logger logger = LoggerFactory.getLogger(NotificationsUtil.class);
/** /**
* Send a notification if an item is added or updated to sharing folder. * Send a notification if an item is added or updated to sharing folder.
* *
* @param request the request * @param request
* @param sourceItem the source item * the request
* @param sourceSharedId the source shared id * @param sourceItem
* @param folderDestinationItem the folder destination item * the source item
* @param isOverwrite the is overwrite * @param sourceSharedId
* the source shared id
* @param folderDestinationItem
* the folder destination item
* @param isOverwrite
* the is overwrite
*/ */
public static void checkSendNotifyChangedItemToShare(HttpServletRequest request, final WorkspaceItem sourceItem, final String sourceSharedId, final WorkspaceItem folderDestinationItem, boolean isOverwrite) { public void checkSendNotifyChangedItemToShare(HttpServletRequest request, final Item sourceItem,
final String sourceSharedId, final FolderItem folderDestinationItem, boolean isOverwrite) {
logger.info("checkSendNotifyAddItemToShare"); logger.info("checkSendNotifyAddItemToShare");
@ -46,84 +56,97 @@ public class NotificationsUtil {
try { try {
// if folder destination is shared folder // if folder destination is shared folder
if(folderDestinationItem.isShared()){ //Notify Added Item To Sharing? if (folderDestinationItem.isShared()) { // Notify Added Item To
// Sharing?
logger.info("checkNotifyAddItemToShare source item: "+sourceItem.getName()+" sourceSharedId: "+sourceSharedId + " folder destination: "+folderDestinationItem.getName() + " folder destination shared folder id: "+folderDestinationItem.getIdSharedFolder()); logger.info("checkNotifyAddItemToShare source item: " + sourceItem.getName() + " sourceSharedId: "
+ sourceSharedId + " folder destination: " + folderDestinationItem.getName()
+ " folder destination shared folder id: " + folderDestinationItem.getId());
//share condition is true if source shared folder is not null // share condition is true if source shared folder is not
// null
boolean shareChangeCondition = sourceSharedId == null ? false : true; boolean shareChangeCondition = sourceSharedId == null ? false : true;
//System.out.println("shareChangeCondition add item: "+ shareChangeCondition); // System.out.println("shareChangeCondition add item: "+
// shareChangeCondition);
logger.info("shareChangeCondition add item: " + shareChangeCondition); logger.info("shareChangeCondition add item: " + shareChangeCondition);
//if shareChangeCondition is true.. notifies added item to sharing // if shareChangeCondition is true.. notifies added item to
// sharing
if (shareChangeCondition) { if (shareChangeCondition) {
Workspace workspace = WsUtil.getWorkspace(request); List<InfoContactModel> listContacts = getListUserSharedByFolderSharedId(
folderDestinationItem.getId());
List<InfoContactModel> listContacts = getListUserSharedByFolderSharedId(workspace, folderDestinationItem.getIdSharedFolder());
WorkspaceItem destinationSharedFolder = workspace.getItem(folderDestinationItem.getIdSharedFolder());
NotificationsProducer np = new NotificationsProducer(request); NotificationsProducer np = new NotificationsProducer(request);
// SWITCH BEETWEEN ADDED OR UPDATED // SWITCH BEETWEEN ADDED OR UPDATED
if (!isOverwrite) if (!isOverwrite)
np.notifyAddedItemToSharing(listContacts, sourceItem, (WorkspaceSharedFolder) destinationSharedFolder); np.notifyAddedItemToSharing(listContacts, sourceItem, (SharedFolder) folderDestinationItem);
else else
np.notifyUpdatedItemToSharing(listContacts, sourceItem, (WorkspaceSharedFolder) destinationSharedFolder); np.notifyUpdatedItemToSharing(listContacts, sourceItem,
(SharedFolder) folderDestinationItem);
logger.info("The notifies was sent correctly"); logger.info("The notifies was sent correctly");
// np.notifyAddedItemToSharing(listContacts, (WorkspaceFolder) folderDestinationItem); // np.notifyAddedItemToSharing(listContacts,
// (WorkspaceFolder) folderDestinationItem);
} }
} } else
else
logger.info("folder destination is not shared"); logger.info("folder destination is not shared");
} catch (Exception e) { } catch (Exception e) {
logger.error("An error occurred in checkSendNotifyAddItemToShare ", e); logger.error("An error occurred in checkSendNotifyAddItemToShare ", e);
} }
} else } else
logger.warn("The notifies is failure in checkSendNotifyAddItemToShare because folder destination item is null"); logger.warn(
"The notifies is failure in checkSendNotifyAddItemToShare because folder destination item is null");
} }
/** /**
* Gets the list user shared by folder shared id. * Gets the list user shared by folder shared id.
* *
* @param workspace the workspace * @param workspace
* @param idSharedFolder the id shared folder * the workspace
* @param idSharedFolder
* the id shared folder
* @return the list user shared by folder shared id * @return the list user shared by folder shared id
* @throws Exception the exception * @throws Exception
* the exception
*/ */
public static List<InfoContactModel> getListUserSharedByFolderSharedId(Workspace workspace, String idSharedFolder) throws Exception { /**
*
* @param id
* Folder Id
* @return List of users
* @throws Exception
* Exception
*/
public List<InfoContactModel> getListUserSharedByFolderSharedId(String id) throws Exception {
logger.info("getListUserSharedByFolderSharedId "+ idSharedFolder); logger.info("getListUserSharedByFolderSharedId " + id);
try { try {
StorageHubClient shc = new StorageHubClient();
WorkspaceItem wsItem = workspace.getItem(idSharedFolder); OpenResolver openResolverForItem = shc.open(id);
FolderContainer folderContainer = openResolverForItem.asFolder();
if(isARootSharedFolder(wsItem)){ FolderItem folderItem = folderContainer.get();
if (folderItem.isShared() && folderItem instanceof SharedFolder) {
WorkspaceSharedFolder wsFolder = (WorkspaceSharedFolder) wsItem; SharedFolder sharedFolder = (SharedFolder) folderItem;
Metadata metadata = sharedFolder.getUsers();
GWTWorkspaceSharingBuilder builder = new GWTWorkspaceSharingBuilder(); Map<String, Object> map = metadata.getMap();
List<String> listPortalLogin = new ArrayList<>(map.keySet());
List<String> listPortalLogin = wsFolder.getUsers();
logger.info("getListUserSharedByFolderSharedId return " + listPortalLogin.size() + " user"); logger.info("getListUserSharedByFolderSharedId return " + listPortalLogin.size() + " user");
GWTWorkspaceSharingBuilder builder = new GWTWorkspaceSharingBuilder();
return builder.buildGxtInfoContactsFromPortalLogins(listPortalLogin); return builder.buildGxtInfoContactsFromPortalLogins(listPortalLogin);
} } else {
else{ logger.error("The item with id: " + id + " is not a shared folder.");
logger.info("the item with id: "+idSharedFolder+ " is not "+WorkspaceItemType.SHARED_FOLDER);
// DEBUG // DEBUG
//System.out.println("the item with id: "+folderSharedId+ " is not "+WorkspaceItemType.SHARED_FOLDER); // System.out.println("the item with id: "+folderSharedId+ " is
// not "+WorkspaceItemType.SHARED_FOLDER);
} }
return new ArrayList<InfoContactModel>(); return new ArrayList<InfoContactModel>();
@ -136,13 +159,19 @@ public class NotificationsUtil {
/** /**
* Check send notify remove item to share. * Check send notify remove item to share.
* *
* @param request the request * @param request
* @param sourceItemIsShared the source item is shared * the request
* @param oldItemName the old item name * @param sourceItemIsShared
* @param oldItemId the old item id * the source item is shared
* @param sourceFolderSharedId the source folder shared id * @param oldItemName
* the old item name
* @param oldItemId
* the old item id
* @param sourceFolderSharedId
* the source folder shared id
*/ */
public static void checkSendNotifyRemoveItemToShare(HttpServletRequest request, final boolean sourceItemIsShared, final String oldItemName, String oldItemId, final String sourceFolderSharedId) { public void checkSendNotifyRemoveItemToShare(HttpServletRequest request, final boolean sourceItemIsShared,
final String oldItemName, String oldItemId, final String sourceFolderSharedId) {
logger.info("checkNotifyRemoveItemToShare:"); logger.info("checkNotifyRemoveItemToShare:");
@ -153,8 +182,7 @@ public class NotificationsUtil {
return; return;
} }
String idSharedFolder = sourceFolderSharedId!=null?sourceFolderSharedId:""; boolean isRootFolderShared = isRootSharedFolderById(sourceFolderSharedId);
boolean isRootFolderShared = checkIsRootFolderShared(oldItemId, idSharedFolder);
logger.info("isRootFolderShared is: " + isRootFolderShared); logger.info("isRootFolderShared is: " + isRootFolderShared);
if (isRootFolderShared) { if (isRootFolderShared) {
@ -162,31 +190,21 @@ public class NotificationsUtil {
return; return;
} }
boolean isSharedFolder = isASharedFolderForId(request,idSharedFolder); logger.info("idSharedFolder is: " + sourceFolderSharedId);
logger.info("idSharedFolder is: "+ idSharedFolder +" is shared folder: "+isSharedFolder);
//Notify Removed Item To Sharing?
if(isSharedFolder && !isRootFolderShared){
Workspace workspace = WsUtil.getWorkspace(request);
// get contacts // get contacts
List<InfoContactModel> listContacts = getListUserSharedByFolderSharedId(workspace, idSharedFolder); List<InfoContactModel> listContacts = getListUserSharedByFolderSharedId(sourceFolderSharedId);
WorkspaceItem sourceSharedFolder = workspace.getItem(idSharedFolder);
//System.out.println(" name sourceSharedFolder: "+ sourceSharedFolder.getName());
StorageHubClient shc = new StorageHubClient();
OpenResolver openResolverForItem = shc.open(sourceFolderSharedId);
FolderContainer folderContainer = openResolverForItem.asFolder();
FolderItem folderItem = folderContainer.get();
if (folderItem instanceof SharedFolder) {
SharedFolder sharedFolder = (SharedFolder) folderItem;
NotificationsProducer np = new NotificationsProducer(request); NotificationsProducer np = new NotificationsProducer(request);
np.notifyRemovedItemToSharing(listContacts, oldItemName, sharedFolder);
if(sourceSharedFolder instanceof WorkspaceSharedFolder)
np.notifyRemovedItemToSharing(listContacts, oldItemName, (WorkspaceSharedFolder) sourceSharedFolder);
else
logger.info("Source shared folder "+sourceSharedFolder + " is not instanceof WorkspaceSharedFolder, skipping");
logger.info("The notifies was sent correctly");
} }
logger.info("The notifies was sent correctly");
} catch (Exception e) { } catch (Exception e) {
logger.error("An error occurred in checkSendNotifyRemoveItemToShare ", e); logger.error("An error occurred in checkSendNotifyRemoveItemToShare ", e);
@ -197,53 +215,81 @@ public class NotificationsUtil {
/** /**
* Checks if is a root shared folder. * Checks if is a root shared folder.
* *
* @param wsItem the ws item * @param wsItem
* the ws item
* @return true, if is a root shared folder * @return true, if is a root shared folder
*/ */
public static boolean isARootSharedFolder(WorkspaceItem wsItem){ /*
if(wsItem!=null) * public boolean isARootSharedFolder(Item wsItem) { if (wsItem != null)
return wsItem.getType().equals(WorkspaceItemType.SHARED_FOLDER); * return wsItem.getType().equals(WorkspaceItemType.SHARED_FOLDER); return
return false; * false; }
} */
/** /**
* Checks if is a shared folder for id. * Checks if is a shared folder for id.
* *
* @param request the request * @param request
* @param itemId the item id * the request
* @param itemId
* the item id
* @return true, if is a shared folder for id * @return true, if is a shared folder for id
*/ */
public static boolean isASharedFolderForId(HttpServletRequest request, String itemId){ /*
* public boolean isASharedFolderForId(String itemId) {
if(itemId==null || itemId.isEmpty()) *
return false; * if (itemId == null || itemId.isEmpty()) return false;
*
* try {
*
* Workspace workspace = WsUtil.getWorkspace(request); WorkspaceItem wsItem
* = workspace.getItem(itemId); if (wsItem != null) return
* wsItem.getType().equals(WorkspaceItemType.SHARED_FOLDER); return false;
*
* } catch (Exception e) {
* logger.error("An errror occurred in isASharedFolderForId", e); return
* false; } }
*/
private boolean isRootSharedFolderById(String id) throws Exception {
try { try {
if (id == null || id.isEmpty()) {
Workspace workspace = WsUtil.getWorkspace(request); logger.error("The item with id: " + id + " is not a shared folder.");
WorkspaceItem wsItem = workspace.getItem(itemId);
if(wsItem!=null)
return wsItem.getType().equals(WorkspaceItemType.SHARED_FOLDER);
return false; return false;
}
StorageHubClient shc = new StorageHubClient();
OpenResolver openResolverForItem = shc.open(id);
FolderContainer folderContainer = openResolverForItem.asFolder();
FolderItem folderItem = folderContainer.get();
if (folderItem.isShared() && folderItem instanceof SharedFolder) {
logger.info("The item with id: " + id + " is a shared folder.");
return true;
} else {
logger.error("The item with id: " + id + " is not a shared folder.");
return false;
}
} catch (Exception e) { } catch (Exception e) {
logger.error("An errror occurred in isASharedFolderForId", e); logger.error("Error in isASharedFolderById: " + e.getLocalizedMessage(), e);
return false; throw new Exception("Error checking the type of folder: [id=" + id + "]");
}
} }
}
/** /**
* Check is root folder shared. * Check is root folder shared.
* *
* @param itemId the item id * @param itemId
* @param rootFolderSharedId the root folder shared id * the item id
* @param rootFolderSharedId
* the root folder shared id
* @return true, if successful * @return true, if successful
*/ */
public static boolean checkIsRootFolderShared(String itemId, String rootFolderSharedId) { public boolean checkIsRootFolderShared(String itemId, String rootFolderSharedId) {
logger.info("checkIsRootFolderShared between [itemid: "+itemId +", rootFolderSharedId: "+rootFolderSharedId+"]"); logger.info("checkIsRootFolderShared between [itemid: " + itemId + ", rootFolderSharedId: "
+ rootFolderSharedId + "]");
if (itemId == null) if (itemId == null)
return false; return false;

View File

@ -0,0 +1,26 @@
package org.gcube.portlets.widgets.workspacesharingwidget.server.notifications;
import org.gcube.applicationsupportlayer.social.shared.SocialFileItem;
import org.gcube.applicationsupportlayer.social.shared.SocialSharedFolder;
import org.gcube.common.storagehub.model.items.FolderItem;
import org.gcube.common.storagehub.model.items.Item;
/**
*
* @author Giancarlo Panichi
*
*/
public class SocialItemFactory {
public SocialFileItem createSocialFileItem(Item item, FolderItem parent) {
SocialSharedFolder socialSharedFolder=createSocialSharedFolder(parent);
return new SocialFileItem(item.getId(), item.getName(), item.getTitle(), item.getPath(), socialSharedFolder);
}
public SocialSharedFolder createSocialSharedFolder(FolderItem folder) {
return new SocialSharedFolder(folder.getId(), folder.getName(), folder.getTitle(), folder.getName(),
folder.getPath(), folder.getParentId(), false);
}
}

View File

@ -0,0 +1,104 @@
/**
*
*/
package org.gcube.portlets.widgets.workspacesharingwidget.server.util;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import org.gcube.common.storagehub.model.acls.AccessType;
/**
* The Class AclTypeComparator.
*
* @author Francesco Mangiacrapa francesco.mangiacrapaATisti.cnr.it Mar 5, 2015
*/
public class AccessTypeComparator implements Comparator<AccessType> {
public static final Map<AccessType, Integer> aclTypeOrder;
static {
aclTypeOrder = new LinkedHashMap<AccessType, Integer>();
aclTypeOrder.put(AccessType.READ_ONLY, 0);
aclTypeOrder.put(AccessType.WRITE_OWNER, 1);
aclTypeOrder.put(AccessType.WRITE_ALL, 2);
// aclTypeOrder.put(ACLType.ADMINISTRATOR, 3);
}
/*
* (non-Javadoc)
*
* @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
*/
@Override
public int compare(AccessType o1, AccessType o2) {
if (o1 == null)
return -1;
if (o2 == null)
return 1;
Integer order1 = aclTypeOrder.get(o1);
Integer order2 = aclTypeOrder.get(o2);
if (order1 == null)
return -1;
if (order2 == null)
return 1;
if (order1 == order2)
return 0;
return order1 < order2 ? -1 : 1;
}
/**
* Gets the allowed.
*
* @param accessType
* the acl type to compare
* @param includeEqual
* if true include equal ACLType, no otherwise
* @return the allowed
*/
public List<AccessType> getAllowed(AccessType accessType, boolean includeEqual) {
List<AccessType> allowed = new ArrayList<>();
if (accessType == null)
return allowed;
// IF MAP DOES NOT CONTAINS ACT TYPE IT IS NOT COMPARABLE
if (aclTypeOrder.get(accessType) == null)
return allowed;
for (AccessType aMap : aclTypeOrder.keySet()) {
int comparator = compare(aMap, accessType);
if (comparator == 1)
allowed.add(aMap);
else if (includeEqual && comparator == 0)
allowed.add(aMap);
}
return allowed;
}
/**
* The main method.
*
* @param args
* the arguments
*/
public static void main(String[] args) {
AccessTypeComparator comparator = new AccessTypeComparator();
List<AccessType> allowed = comparator.getAllowed(AccessType.WRITE_ALL, false);
System.out.println(allowed);
}
}

View File

@ -7,20 +7,21 @@ import org.gcube.portlets.widgets.workspacesharingwidget.shared.InfoContactModel
/** /**
* *
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it * @author Francesco Mangiacrapa Feb 25, 2014
* @Feb 25, 2014
* *
*/ */
public class DiffereceBeetweenInfoContactModel { public class DiffereceBeetweenInfoContactModel {
private List<InfoContactModel> listOne; private List<InfoContactModel> listOne;
private List<InfoContactModel> listTwo; private List<InfoContactModel> listTwo;
/** /**
* Get difference between listA and listB * Get difference between listA and listB
*
* @param listA * @param listA
* List A
* @param listB * @param listB
* List B
*/ */
public DiffereceBeetweenInfoContactModel(List<InfoContactModel> listA, List<InfoContactModel> listB) { public DiffereceBeetweenInfoContactModel(List<InfoContactModel> listA, List<InfoContactModel> listB) {
@ -62,12 +63,6 @@ public class DiffereceBeetweenInfoContactModel {
} }
/**
*
* @param o1
* @param o2
* @return 0 if and only if o1.getName().compareTo(o2.getName())==0 && (o1.getLogin().compareTo(o2.getLogin())==0) is true
*/
public int compare(InfoContactModel o1, InfoContactModel o2) { public int compare(InfoContactModel o1, InfoContactModel o2) {
if (o1 == null) { if (o1 == null) {
@ -83,30 +78,5 @@ public class DiffereceBeetweenInfoContactModel {
} }
/**
* test
* @param args
*/
/*public static void main(String[] args) {
List<InfoContactModel> listA = new ArrayList<InfoContactModel>();
listA.add(new InfoContactModel("federico.defaveri", "federico.defaveri", "Federico de Faveri", false));
listA.add(new InfoContactModel("antonio.gioia", "antonio.gioia", "Antonio Gioia",false));
listA.add(new InfoContactModel("fabio.sinibaldi", "fabio.sinibaldi", "Fabio Sinibaldi",false));
listA.add(new InfoContactModel("pasquale.pagano", "pasquale.pagano", "Pasquale Pagano",false));
listA.add(new InfoContactModel("francesco.mangiacrapa", "francesco.mangiacrapa", "Francesco Mangiacrapa",false));
listA.add(new InfoContactModel("massimiliano.assante", "massimiliano.assante", "Massimiliano Assante",false));
List<InfoContactModel> listB = new ArrayList<InfoContactModel>();
listB.add(new InfoContactModel("federico.defaveri", "federico.defaveri", "Federico de Faveri",false));
listB.add(new InfoContactModel("fabio.sinibaldi", "fabio.sinibaldi", "Fabio Sinibaldi",false));
listB.add(new InfoContactModel("antonio.gioia", "antonio.gioia", "Antonio Gioia",false));
listB.add(new InfoContactModel("pasquale.pagano", "pasquale.pagano", "Pasquale Pagano",false));
DiffereceBeetweenInfoContactModel diff = new DiffereceBeetweenInfoContactModel(listA, listB);
System.out.println("the differce is: "+diff.getDifferentsContacts());
}*/
} }

View File

@ -22,29 +22,22 @@ import org.slf4j.LoggerFactory;
* *
* @author Massimiliano Assante ISTI-CNR * @author Massimiliano Assante ISTI-CNR
* *
* @version 2.0 Jan 10th 2012 * Jan 10th 2012
* *
* changed by Francesco Mangiacrapa * changed by Francesco Mangiacrapa
*/ */
public class LoginServiceUtil { public class LoginServiceUtil {
/**
*
*/
public static final String ROOT_ORG = "rootorganization"; public static final String ROOT_ORG = "rootorganization";
/**
*
*/
public static final String PUBLIC_LAYOUT_NAME = " Data e-Infrastructure gateway"; public static final String PUBLIC_LAYOUT_NAME = " Data e-Infrastructure gateway";
/**
*
*/
public static final String GUEST_COMMUNITY_NAME = "Guest"; public static final String GUEST_COMMUNITY_NAME = "Guest";
private static final Logger _log = LoggerFactory.getLogger(LoginServiceUtil.class); private static final Logger _log = LoggerFactory.getLogger(LoginServiceUtil.class);
/** /**
* simply returns fake VOS for debugging purpose * simply returns fake VOS for debugging purpose
* @return *
* @return List of VO
*/ */
protected static List<VO> getFakeVOs() { protected static List<VO> getFakeVOs() {
VO rootVO = new VO(); VO rootVO = new VO();
@ -54,14 +47,14 @@ public class LoginServiceUtil {
rootVO.setImageURL("http://portal.d4science.research-infrastructures.eu/vologin/html/RedGrid.jpg"); rootVO.setImageURL("http://portal.d4science.research-infrastructures.eu/vologin/html/RedGrid.jpg");
rootVO.setUserBelonging(UserBelonging.BELONGING); rootVO.setUserBelonging(UserBelonging.BELONGING);
/***************************************/ /***************************************/
VO emVO = new VO(); VO emVO = new VO();
emVO.setRoot(false); emVO.setRoot(false);
emVO.setGroupName("/d4science.research-infrastructures.eu/EM/"); emVO.setGroupName("/d4science.research-infrastructures.eu/EM/");
emVO.setName("EM VO"); emVO.setName("EM VO");
emVO.setDescription("EM and AEM Virtual Organisation The FARM Virtual Organisation is the dynamic group of individuals and/or institutions defined around a set of sharing rules in which resource providers and consumers specify clearly and carefully just what is shared, who is allowed to share, and the conditions under which sharing occurs to serve the needs of the Fisheries and Aquaculture Resources Management."); emVO.setDescription(
"EM and AEM Virtual Organisation The FARM Virtual Organisation is the dynamic group of individuals and/or institutions defined around a set of sharing rules in which resource providers and consumers specify clearly and carefully just what is shared, who is allowed to share, and the conditions under which sharing occurs to serve the needs of the Fisheries and Aquaculture Resources Management.");
emVO.setImageURL("http://portal.d4science.research-infrastructures.eu/vologin/html/RedGrid.jpg"); emVO.setImageURL("http://portal.d4science.research-infrastructures.eu/vologin/html/RedGrid.jpg");
emVO.setUserBelonging(UserBelonging.NOT_BELONGING); emVO.setUserBelonging(UserBelonging.NOT_BELONGING);
@ -70,8 +63,8 @@ public class LoginServiceUtil {
VRE cool_EM_VRE = new VRE(); VRE cool_EM_VRE = new VRE();
cool_EM_VRE.setName("COOL EM VRE"); cool_EM_VRE.setName("COOL EM VRE");
cool_EM_VRE.setGroupName("/d4science.research-infrastructures.eu/EM/COOLEMVRE"); cool_EM_VRE.setGroupName("/d4science.research-infrastructures.eu/EM/COOLEMVRE");
cool_EM_VRE.setDescription("cool_EM_VRE VRE Description<br />"+ cool_EM_VRE.setDescription("cool_EM_VRE VRE Description<br />"
"This Virtual Research Environment is for cool authors, managers and researchers who produce reports containing cool data."); + "This Virtual Research Environment is for cool authors, managers and researchers who produce reports containing cool data.");
cool_EM_VRE.setImageURL("http://portal.d4science.research-infrastructures.eu/vologin/html/gcm-preview.jpg"); cool_EM_VRE.setImageURL("http://portal.d4science.research-infrastructures.eu/vologin/html/gcm-preview.jpg");
cool_EM_VRE.setUserBelonging(UserBelonging.BELONGING); cool_EM_VRE.setUserBelonging(UserBelonging.BELONGING);
emVO.addVRE(cool_EM_VRE); emVO.addVRE(cool_EM_VRE);
@ -79,26 +72,28 @@ public class LoginServiceUtil {
VRE cool_EM_VRE2 = new VRE(); VRE cool_EM_VRE2 = new VRE();
cool_EM_VRE2.setName("COOL VRE 2"); cool_EM_VRE2.setName("COOL VRE 2");
cool_EM_VRE2.setGroupName("/d4science.research-infrastructures.eu/EM/COOLEMVRE2"); cool_EM_VRE2.setGroupName("/d4science.research-infrastructures.eu/EM/COOLEMVRE2");
cool_EM_VRE2.setDescription("Cool VRE Description<br />"+ cool_EM_VRE2.setDescription("Cool VRE Description<br />"
"This Virtual Research Environment is for cool authors, managers and researchers who produce reports containing cool data."); + "This Virtual Research Environment is for cool authors, managers and researchers who produce reports containing cool data.");
cool_EM_VRE2.setImageURL("http://portal.d4science.research-infrastructures.eu/vologin/html/aquamaps-preview.jpg"); cool_EM_VRE2
.setImageURL("http://portal.d4science.research-infrastructures.eu/vologin/html/aquamaps-preview.jpg");
cool_EM_VRE2.setUserBelonging(UserBelonging.NOT_BELONGING); cool_EM_VRE2.setUserBelonging(UserBelonging.NOT_BELONGING);
VRE cool_EM_VRE3 = new VRE(); VRE cool_EM_VRE3 = new VRE();
cool_EM_VRE3.setName("COOL EM VRE TRE"); cool_EM_VRE3.setName("COOL EM VRE TRE");
cool_EM_VRE3.setGroupName("/d4science.research-infrastructures.eu/EM/COOlVRE3"); cool_EM_VRE3.setGroupName("/d4science.research-infrastructures.eu/EM/COOlVRE3");
cool_EM_VRE3.setDescription("Cool VRE Description<br />"+ cool_EM_VRE3.setDescription("Cool VRE Description<br />"
"This Virtual Research Environment is for cool authors, managers and researchers who produce reports containing cool data."); + "This Virtual Research Environment is for cool authors, managers and researchers who produce reports containing cool data.");
cool_EM_VRE3.setImageURL("http://portal.d4science.research-infrastructures.eu/vologin/html/aquamaps-preview.jpg"); cool_EM_VRE3
.setImageURL("http://portal.d4science.research-infrastructures.eu/vologin/html/aquamaps-preview.jpg");
cool_EM_VRE3.setUserBelonging(UserBelonging.BELONGING); cool_EM_VRE3.setUserBelonging(UserBelonging.BELONGING);
VRE demo = new VRE(); VRE demo = new VRE();
demo.setName("Demo"); demo.setName("Demo");
demo.setGroupName("/d4science.research-infrastructures.eu/EM/Demo"); demo.setGroupName("/d4science.research-infrastructures.eu/EM/Demo");
demo.setDescription("Cool VRE Description<br />"+ demo.setDescription("Cool VRE Description<br />"
"This Virtual Research Environment is for cool authors, managers and researchers who produce reports containing cool data."); + "This Virtual Research Environment is for cool authors, managers and researchers who produce reports containing cool data.");
demo.setImageURL("http://portal.d4science.research-infrastructures.eu/vologin/html/RedGrid.jpg"); demo.setImageURL("http://portal.d4science.research-infrastructures.eu/vologin/html/RedGrid.jpg");
demo.setUserBelonging(UserBelonging.BELONGING); demo.setUserBelonging(UserBelonging.BELONGING);
@ -111,7 +106,6 @@ public class LoginServiceUtil {
vreGCM.setImageURL("http://portal.d4science.research-infrastructures.eu/vologin/html/aquamaps-preview.jpg"); vreGCM.setImageURL("http://portal.d4science.research-infrastructures.eu/vologin/html/aquamaps-preview.jpg");
vreGCM.setUserBelonging(UserBelonging.BELONGING); vreGCM.setUserBelonging(UserBelonging.BELONGING);
emVO.addVRE(cool_EM_VRE); emVO.addVRE(cool_EM_VRE);
emVO.addVRE(cool_EM_VRE2); emVO.addVRE(cool_EM_VRE2);
emVO.addVRE(cool_EM_VRE3); emVO.addVRE(cool_EM_VRE3);
@ -127,7 +121,8 @@ public class LoginServiceUtil {
/** /**
* *
* @param scopename a string * @param scopename
* a string
* @return true if any VRE Exists * @return true if any VRE Exists
*/ */
protected static Boolean checkVresPresence(String scopename) { protected static Boolean checkVresPresence(String scopename) {
@ -151,10 +146,12 @@ public class LoginServiceUtil {
return null; return null;
} }
} }
/** /**
* *
* @param scopename a string * @param scopename scope name
* @return an arraylist of <class>VRE</class> with just name and description filled * @return List of VREs
*/ */
protected static List<VRE> getVREsFromInfrastructure(String scopename) { protected static List<VRE> getVREsFromInfrastructure(String scopename) {
List<VRE> toReturn = new ArrayList<VRE>(); List<VRE> toReturn = new ArrayList<VRE>();

View File

@ -9,7 +9,7 @@ import java.io.Serializable;
/** /**
* The Class PortalContextInfo. * The Class PortalContextInfo.
* *
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it * @author Francesco Mangiacrapa
* Nov 25, 2016 * Nov 25, 2016
*/ */
public class PortalContextInfo implements Serializable{ public class PortalContextInfo implements Serializable{

View File

@ -23,7 +23,7 @@ import org.slf4j.LoggerFactory;
/** /**
* The Class UserUtil. * The Class UserUtil.
* *
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it * @author Francesco Mangiacrapa
* Nov 25, 2016 * Nov 25, 2016
*/ */
public class UserUtil { public class UserUtil {

View File

@ -9,18 +9,15 @@ import java.util.List;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession; import javax.servlet.http.HttpSession;
import org.apache.commons.lang.StringUtils;
import org.gcube.applicationsupportlayer.social.ApplicationNotificationsManager; import org.gcube.applicationsupportlayer.social.ApplicationNotificationsManager;
import org.gcube.applicationsupportlayer.social.NotificationsManager; import org.gcube.applicationsupportlayer.social.NotificationsManager;
import org.gcube.applicationsupportlayer.social.shared.SocialNetworkingSite; import org.gcube.applicationsupportlayer.social.shared.SocialNetworkingSite;
import org.gcube.applicationsupportlayer.social.shared.SocialNetworkingUser; import org.gcube.applicationsupportlayer.social.shared.SocialNetworkingUser;
import org.gcube.common.homelibrary.home.HomeLibrary;
import org.gcube.common.homelibrary.home.exceptions.HomeNotFoundException;
import org.gcube.common.homelibrary.home.exceptions.InternalErrorException;
import org.gcube.common.homelibrary.home.workspace.Workspace;
import org.gcube.common.homelibrary.home.workspace.exceptions.WorkspaceFolderNotFoundException;
import org.gcube.common.portal.PortalContext; import org.gcube.common.portal.PortalContext;
import org.gcube.common.scope.api.ScopeProvider; import org.gcube.common.scope.api.ScopeProvider;
import org.gcube.common.storagehub.client.dsl.FolderContainer;
import org.gcube.common.storagehub.client.dsl.StorageHubClient;
import org.gcube.portlets.widgets.workspacesharingwidget.server.GWTWorkspaceSharingBuilder; import org.gcube.portlets.widgets.workspacesharingwidget.server.GWTWorkspaceSharingBuilder;
import org.gcube.portlets.widgets.workspacesharingwidget.server.notifications.NotificationsProducer; import org.gcube.portlets.widgets.workspacesharingwidget.server.notifications.NotificationsProducer;
import org.gcube.portlets.widgets.workspacesharingwidget.shared.InfoContactModel; import org.gcube.portlets.widgets.workspacesharingwidget.shared.InfoContactModel;
@ -36,7 +33,7 @@ import com.liferay.portal.service.UserLocalServiceUtil;
/** /**
* The Class WsUtil. * The Class WsUtil.
* *
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it * @author Francesco Mangiacrapa
* Nov 25, 2016 * Nov 25, 2016
*/ */
public class WsUtil { public class WsUtil {
@ -107,7 +104,7 @@ public class WsUtil {
* *
* @param infrastructure the infrastructure name * @param infrastructure the infrastructure name
* @param startScopes the starting scopes * @param startScopes the starting scopes
* @return an arraylist of <class>VO</class> containing their child VREs * @return an arraylist of VO containing their child VREs
*/ */
public static List<VO> getVresFromInfrastructure(String infrastructure, String startScopes) { public static List<VO> getVresFromInfrastructure(String infrastructure, String startScopes) {
List<VO> toReturn = new ArrayList<VO>(); List<VO> toReturn = new ArrayList<VO>();
@ -133,42 +130,6 @@ public class WsUtil {
return toReturn; return toReturn;
} }
/**
* Gets the workspace.
*
* @param httpServletRequest the http servlet request
* @return the workspace
* @throws InternalErrorException the internal error exception
* @throws HomeNotFoundException the home not found exception
* @throws WorkspaceFolderNotFoundException the workspace folder not found exception
*/
public static Workspace getWorkspace(HttpServletRequest httpServletRequest) throws InternalErrorException, HomeNotFoundException, WorkspaceFolderNotFoundException
{
logger.trace("Get Workspace");
PortalContextInfo info = getPortalContext(httpServletRequest);
logger.trace("PortalContextInfo: "+info);
ScopeProvider.instance.set(info.getCurrentScope());
logger.trace("Scope provider instancied");
Workspace workspace = HomeLibrary.getUserWorkspace(info.getUsername());
HttpSession session = httpServletRequest.getSession();
if (session.getAttribute(WORKSPACEBUILDER_ATTRIBUTE) == null)
{
logger.info("Initializing the workspace area builder");
GWTWorkspaceSharingBuilder builder = new GWTWorkspaceSharingBuilder();
//ADDED 03/09/2013
//TODO IS GROUP?
builder.setUserLogged(new InfoContactModel(info.getUsername(), info.getUsername(), info.getUserFullName(), false));
session.setAttribute(WORKSPACEBUILDER_ATTRIBUTE, builder);
}
return workspace;
}
/** /**
@ -241,9 +202,15 @@ public class WsUtil {
*/ */
public static boolean isVRE(String scope){ public static boolean isVRE(String scope){
int slashCount = StringUtils.countMatches(scope, "/"); int slashCounter = 0;
char slash="/".charAt(0);
for (int i = 0; i < scope.length(); i++) {
if (scope.charAt(i)==slash) {
slashCounter++;
}
}
if(slashCount < 3){ if(slashCounter < 3){
logger.trace("currentScope is not VRE"); logger.trace("currentScope is not VRE");
return false; return false;
} }

View File

@ -4,8 +4,8 @@
package org.gcube.portlets.widgets.workspacesharingwidget.shared; package org.gcube.portlets.widgets.workspacesharingwidget.shared;
/** /**
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it * @author Francesco Mangiacrapa
* @Feb 27, 2014 * Feb 27, 2014
* *
*/ */
public enum ACL_TYPE { public enum ACL_TYPE {

View File

@ -0,0 +1,123 @@
/**
*
*/
package org.gcube.portlets.widgets.workspacesharingwidget.shared;
import java.io.Serializable;
/**
*
* @author Francesco Mangiacrapa francesco.mangiacrapaATisti.cnr.it Nov 29, 2016
*/
public class AllowAccess implements Serializable {
/**
*
*/
private static final long serialVersionUID = -2180345568585856822L;
private String itemId;
private Boolean accessGranted = false;
private String accessAllowDenyMotivation;
private String error;
public AllowAccess() {
}
public AllowAccess(String itemId) {
}
public AllowAccess(String itemId, Boolean accessGranted, String accessAllowDenyMotivation, String error) {
super();
this.itemId = itemId;
this.accessGranted = accessGranted;
this.accessAllowDenyMotivation = accessAllowDenyMotivation;
this.error = error;
}
public String getItemId() {
return itemId;
}
public Boolean getAccessGranted() {
return accessGranted;
}
/**
* @return the accessAllowDenyMotivation
*/
public String getAccessAllowDenyMotivation() {
return accessAllowDenyMotivation;
}
/**
* @return the error
*/
public String getError() {
return error;
}
/**
* @param itemId
* the itemId to set
*/
public void setItemId(String itemId) {
this.itemId = itemId;
}
/**
* @param accessGranted
* the accessGranted to set
*/
public void setAccessGranted(Boolean accessGranted) {
this.accessGranted = accessGranted;
}
/**
* @param accessAllowDenyMotivation
* the accessAllowDenyMotivation to set
*/
public void setAccessAllowDenyMotivation(String accessAllowDenyMotivation) {
this.accessAllowDenyMotivation = accessAllowDenyMotivation;
}
/**
* @param error
* the error to set
*/
public void setError(String error) {
this.error = error;
}
/*
* (non-Javadoc)
*
* @see java.lang.Object#toString()
*/
@Override
public String toString() {
StringBuilder builder = new StringBuilder();
builder.append("AllowAccess [itemId=");
builder.append(itemId);
builder.append(", accessGranted=");
builder.append(accessGranted);
builder.append(", accessAllowDenyMotivation=");
builder.append(accessAllowDenyMotivation);
builder.append(", error=");
builder.append(error);
builder.append("]");
return builder.toString();
}
}

View File

@ -9,7 +9,7 @@ import java.io.Serializable;
/** /**
* The Class CredentialModel. * The Class CredentialModel.
* *
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it * @author Francesco Mangiacrapa
* Apr 14, 2016 * Apr 14, 2016
*/ */
public class CredentialModel implements Serializable{ public class CredentialModel implements Serializable{

View File

@ -0,0 +1,69 @@
package org.gcube.portlets.widgets.workspacesharingwidget.shared;
import org.gcube.portlets.widgets.workspacesharingwidget.shared.ACL_TYPE;
import org.gcube.portlets.widgets.workspacesharingwidget.shared.WorkspaceACL;
/**
*
* @author Francesco Mangiacrapa francesco.mangiacrapaATisti.cnr.it Feb 21, 2014
*
*/
public class ExtendedWorkspaceACL extends WorkspaceACL {
/**
*
*/
private static final long serialVersionUID = 5272059977475806564L;
private String loginOwner;
private String workspaceItemId;
private boolean isBaseSharedFolder;
/**
*
*/
public ExtendedWorkspaceACL() {
}
public ExtendedWorkspaceACL(String id, ACL_TYPE aclType, String label, boolean defaultValue, USER_TYPE userType,
String description, String loginOwner, String workspaceItemId, boolean isBaseSharedFolder) {
super(id, aclType, label, defaultValue, userType, description);
this.loginOwner = loginOwner;
this.workspaceItemId = workspaceItemId;
this.isBaseSharedFolder = isBaseSharedFolder;
}
public String getLoginOwner() {
return loginOwner;
}
public String getWorkspaceItemId() {
return workspaceItemId;
}
public void setLoginOwner(String loginOwner) {
this.loginOwner = loginOwner;
}
public void setWorkspaceItemId(String workspaceItemId) {
this.workspaceItemId = workspaceItemId;
}
public boolean isBaseSharedFolder() {
return isBaseSharedFolder;
}
public void setBaseSharedFolder(boolean isBaseSharedFolder) {
this.isBaseSharedFolder = isBaseSharedFolder;
}
@Override
public String toString() {
return "ExtendedWorkspaceACL [loginOwner=" + loginOwner + ", workspaceItemId=" + workspaceItemId
+ ", isBaseSharedFolder=" + isBaseSharedFolder + ", getId()=" + getId() + ", getLabel()=" + getLabel()
+ ", getDefaultValue()=" + getDefaultValue() + ", getUserType()=" + getUserType()
+ ", getDescription()=" + getDescription() + ", getAclType()=" + getAclType() + "]";
}
}

View File

@ -7,8 +7,7 @@ import com.extjs.gxt.ui.client.data.BaseModelData;
/** /**
* *
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it * @author Francesco Mangiacrapa Feb 25, 2014
* @Feb 25, 2014
* *
*/ */
public class FileModel extends BaseModelData implements Serializable { public class FileModel extends BaseModelData implements Serializable {
@ -17,28 +16,16 @@ public class FileModel extends BaseModelData implements Serializable {
* *
*/ */
private static final long serialVersionUID = 7291843683961579349L; private static final long serialVersionUID = 7291843683961579349L;
private static final String DIRECTORYDESCRIPTION = "DIRECTORYDESCRIPTION"; private static final String DIRECTORYDESCRIPTION = "DIRECTORYDESCRIPTION";
private static final String PARENT = "PARENT"; private static final String PARENT = "PARENT";
private static final String OWNER = "OWNER"; private static final String OWNER = "OWNER";
private static final String OWNERFULLNAME = "OWNERFULLNAME"; private static final String OWNERFULLNAME = "OWNERFULLNAME";
private static final String ISSHARED = "ISSHARED"; private static final String ISSHARED = "ISSHARED";
private static final String SHAREUSERS = "SHAREUSERS"; private static final String SHAREUSERS = "SHAREUSERS";
private static final String ISDIRECTORY = "ISDIRECTORY"; private static final String ISDIRECTORY = "ISDIRECTORY";
private static final String IDENTIFIER = "IDENTIFIER"; private static final String IDENTIFIER = "IDENTIFIER";
private static final String TYPE = "TYPE"; private static final String TYPE = "TYPE";
private static final String NAME = "NAME"; private static final String NAME = "NAME";
private static final String FOLDERITEMTYPE = "FOLDERITEMTYPE"; private static final String FOLDERITEMTYPE = "FOLDERITEMTYPE";
protected boolean isRoot = false; protected boolean isRoot = false;
@ -47,31 +34,19 @@ public class FileModel extends BaseModelData implements Serializable {
protected FileModel() { protected FileModel() {
} }
/** public FileModel(String identifier, String name, String description, FileModel parent, boolean isDirectory, boolean isShared) {
*
* @param identifier
* @param name
* @param parent
* @param isDirectory
* @param isShared
*/
public FileModel(String identifier, String name, FileModel parent, boolean isDirectory, boolean isShared) {
setIdentifier(identifier); setIdentifier(identifier);
setName(name); setName(name);
setDescription(description);
setParentFileModel(parent); setParentFileModel(parent);
setIsDirectory(isDirectory); setIsDirectory(isDirectory);
setShared(isShared); setShared(isShared);
} }
/** public FileModel(String identifier, String name, String description,boolean isDirectory) {
*
* @param identifier
* @param name
* @param isDirectory
*/
public FileModel(String identifier, String name, boolean isDirectory) {
setIdentifier(identifier); setIdentifier(identifier);
setName(name); setName(name);
setDescription(description);
setIsDirectory(isDirectory); setIsDirectory(isDirectory);
} }
@ -92,6 +67,7 @@ public class FileModel extends BaseModelData implements Serializable {
* ConstantsExplorer.FOLDERLOADED = "loaded"; * ConstantsExplorer.FOLDERLOADED = "loaded";
* *
* @param status * @param status
* Status
*/ */
public void setStatus(String status) { public void setStatus(String status) {
set("status", status); set("status", status);
@ -123,8 +99,7 @@ public class FileModel extends BaseModelData implements Serializable {
return get(OWNERFULLNAME); return get(OWNERFULLNAME);
} }
public void setSharingValue(boolean isShared, public void setSharingValue(boolean isShared, List<InfoContactModel> listShareUsers) {
List<InfoContactModel> listShareUsers) {
set(ISSHARED, isShared); set(ISSHARED, isShared);
set(SHAREUSERS, listShareUsers); set(SHAREUSERS, listShareUsers);
} }
@ -211,6 +186,7 @@ public class FileModel extends BaseModelData implements Serializable {
* It's: folder, mime type or unknown * It's: folder, mime type or unknown
* *
* @param type * @param type
* Type
*/ */
public void setType(String type) { public void setType(String type) {
set(TYPE, type); set(TYPE, type);
@ -227,4 +203,17 @@ public class FileModel extends BaseModelData implements Serializable {
public void setVreFolder(boolean isVreFolder) { public void setVreFolder(boolean isVreFolder) {
this.isVreFolder = isVreFolder; this.isVreFolder = isVreFolder;
} }
@Override
public String toString() {
return "FileModel [isRoot=" + isRoot + ", isVreFolder=" + isVreFolder + ", getDescription()=" + getDescription()
+ ", getOwner()=" + getOwner() + ", getOwnerFullName()=" + getOwnerFullName()
+ ", getListUserSharing()=" + getListUserSharing() + ", isShared()=" + isShared() + ", isRoot()="
+ isRoot() + ", getStatus()=" + getStatus() + ", getIdentifier()=" + getIdentifier() + ", getName()="
+ getName() + ", isDirectory()=" + isDirectory() + ", getType()=" + getType() + ", isVreFolder()="
+ isVreFolder() + "]";
}
} }

View File

@ -1,7 +1,7 @@
package org.gcube.portlets.widgets.workspacesharingwidget.shared; package org.gcube.portlets.widgets.workspacesharingwidget.shared;
/** /**
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it * @author Francesco Mangiacrapa
* *
*/ */
public class FolderModel extends FileModel { public class FolderModel extends FileModel {
@ -14,13 +14,13 @@ public class FolderModel extends FileModel {
public FolderModel() { public FolderModel() {
} }
public FolderModel(String identifier, String name, FileModel parent, boolean isDirectory, boolean isShared, boolean isVreFolder) { public FolderModel(String identifier, String name, String description, FileModel parent, boolean isDirectory, boolean isShared, boolean isVreFolder) {
super(identifier, name, parent, isDirectory, isShared); super(identifier, name, description, parent, isDirectory, isShared);
super.setVreFolder(isVreFolder); super.setVreFolder(isVreFolder);
} }
public FolderModel(String identifier, String name, boolean isDirectory, boolean isVreFolder) { public FolderModel(String identifier, String name, String description, boolean isDirectory, boolean isVreFolder) {
super(identifier, name, isDirectory); super(identifier, name, description, isDirectory);
super.setVreFolder(isVreFolder); super.setVreFolder(isVreFolder);
} }

View File

@ -6,7 +6,7 @@ import java.io.Serializable;
/** /**
* The Enum GXTFolderItemTypeEnum. * The Enum GXTFolderItemTypeEnum.
* *
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it * @author Francesco Mangiacrapa
* Jun 19, 2015 * Jun 19, 2015
*/ */
public enum GXTFolderItemTypeEnum implements Serializable { public enum GXTFolderItemTypeEnum implements Serializable {

View File

@ -6,7 +6,7 @@ import java.util.Comparator;
import com.extjs.gxt.ui.client.data.BaseModelData; import com.extjs.gxt.ui.client.data.BaseModelData;
/** /**
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it * @author Francesco Mangiacrapa
* *
*/ */
public class InfoContactModel extends BaseModelData implements Serializable, Comparable<InfoContactModel> { public class InfoContactModel extends BaseModelData implements Serializable, Comparable<InfoContactModel> {

View File

@ -0,0 +1,88 @@
/**
*
*/
package org.gcube.portlets.widgets.workspacesharingwidget.shared;
import java.io.Serializable;
import java.util.List;
/**
*
* @author Francesco Mangiacrapa francesco.mangiacrapaATisti.cnr.it
* Mar 6, 2015
*/
public class ReportAssignmentACL implements Serializable{
/**
*
*/
private static final long serialVersionUID = -7218122043660957432L;
private List<String> validLogins;
private List<String> errors;
private String aclType;
/**
*
*/
public ReportAssignmentACL() {
}
/**
* @return the validLogins
*/
public List<String> getValidLogins() {
return validLogins;
}
/**
* @param validLogins the validLogins to set
*/
public void setValidLogins(List<String> validLogins) {
this.validLogins = validLogins;
}
/**
* @return the errors
*/
public List<String> getErrors() {
return errors;
}
/**
* @param errors the errors to set
*/
public void setErrors(List<String> errors) {
this.errors = errors;
}
/**
* @return the aclType
*/
public String getAclType() {
return aclType;
}
/**
* @param aclType the aclType to set
*/
public void setAclType(String aclType) {
this.aclType = aclType;
}
/* (non-Javadoc)
* @see java.lang.Object#toString()
*/
@Override
public String toString() {
StringBuilder builder = new StringBuilder();
builder.append("ReportValidationACL [validLogins=");
builder.append(validLogins);
builder.append(", errors=");
builder.append(errors);
builder.append(", aclType=");
builder.append(aclType);
builder.append("]");
return builder.toString();
}
}

View File

@ -5,8 +5,8 @@ package org.gcube.portlets.widgets.workspacesharingwidget.shared;
/** /**
* *
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it * @author Francesco Mangiacrapa
* @Mar 3, 2014 * Mar 3, 2014
* *
*/ */
public class SessionExpiredException extends Exception{ public class SessionExpiredException extends Exception{

View File

@ -6,8 +6,8 @@ import java.io.Serializable;
/** /**
* *
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it * @author Francesco Mangiacrapa
* @Feb 21, 2014 * Feb 21, 2014
* *
*/ */
public class WorkspaceACL implements Serializable{ public class WorkspaceACL implements Serializable{
@ -31,15 +31,6 @@ public class WorkspaceACL implements Serializable{
public enum USER_TYPE{ADMINISTRATOR, GROUP, OWNER, OTHER}; public enum USER_TYPE{ADMINISTRATOR, GROUP, OWNER, OTHER};
/**
*
* @param serverId
* @param aclType
* @param label
* @param defaultValue
* @param userType
* @param description
*/
public WorkspaceACL(String serverId, ACL_TYPE aclType, String label, boolean defaultValue, USER_TYPE userType, String description) { public WorkspaceACL(String serverId, ACL_TYPE aclType, String label, boolean defaultValue, USER_TYPE userType, String description) {
super(); super();
this.id = serverId; this.id = serverId;

View File

@ -14,23 +14,11 @@ public class VO extends ResearchEnvironment implements Comparable<VO>, Serializa
private boolean isRoot; private boolean isRoot;
private ArrayList<VRE> vres = new ArrayList<VRE>(); private ArrayList<VRE> vres = new ArrayList<VRE>();
/**
*
*/
public VO() { public VO() {
super(); super();
} }
/**
*
* @param voName .
* @param description .
* @param imageURL .
* @param vomsGroupName .
* @param friendlyURL .
* @param userBelonging .
* @param isRoot .
* @param vres .
*/
public VO(String voName, String description, String imageURL, public VO(String voName, String description, String imageURL,
String vomsGroupName, String friendlyURL, String vomsGroupName, String friendlyURL,
UserBelonging userBelonging, boolean isRoot, ArrayList<VRE> vres) { UserBelonging userBelonging, boolean isRoot, ArrayList<VRE> vres) {
@ -51,18 +39,13 @@ public class VO extends ResearchEnvironment implements Comparable<VO>, Serializa
public void setVres(ArrayList<VRE> vres) { public void setVres(ArrayList<VRE> vres) {
this.vres = vres; this.vres = vres;
} }
/**
*
* @param toAdd
*/
public void addVRE(VRE toAdd) { public void addVRE(VRE toAdd) {
if (vres == null) if (vres == null)
vres = new ArrayList<VRE>(); vres = new ArrayList<VRE>();
vres.add(toAdd); vres.add(toAdd);
} }
/**
* compare the number of vres
*/
public int compareTo(VO voToCompare) { public int compareTo(VO voToCompare) {
return (this.vres.size() >= voToCompare.getVres().size()) ? 1 : -1; return (this.vres.size() >= voToCompare.getVres().size()) ? 1 : -1;
} }

View File

@ -5,23 +5,11 @@ import java.io.Serializable;
@SuppressWarnings("serial") @SuppressWarnings("serial")
public class VRE extends ResearchEnvironment implements Serializable { public class VRE extends ResearchEnvironment implements Serializable {
/**
*
*/
public VRE() { public VRE() {
super(); super();
// TODO Auto-generated constructor stub // TODO Auto-generated constructor stub
} }
/**
*
* @param vreName
* @param description
* @param imageURL
* @param vomsGroupName
* @param friendlyURL
* @param userBelonging
*/
public VRE(String vreName, String description, String imageURL, public VRE(String vreName, String description, String imageURL,
String vomsGroupName, String friendlyURL, String vomsGroupName, String friendlyURL,
UserBelonging userBelonging) { UserBelonging userBelonging) {

View File

@ -17,8 +17,8 @@ import org.gcube.common.scope.impl.ScopeBean;
/** /**
* *
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it * @author Francesco Mangiacrapa
* @Jan 29, 2014 * Jan 29, 2014
* *
*/ */
public class ItemRetrieving { public class ItemRetrieving {