enhancements on groups integration

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/widgets/workspace-sharing-widget@97637 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Francesco Mangiacrapa 2014-06-23 15:02:57 +00:00
parent 1b2757285b
commit 66930d30f3
7 changed files with 157 additions and 111 deletions

View File

@ -43,7 +43,7 @@ public class WorkspaceSharingController {
* @param if true, only owner can share, otherwise an alert with an error message is displayed * @param if true, 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 defaultPermission ACL_TYPE default permission, if is null default ACL_TYPE is loaded from server
* *
* base constructor by default do not retrieve groups * base constructor by default does not retrieve groups
*/ */
public WorkspaceSharingController(String itemId, boolean shareOnlyOwner, ACL_TYPE defaultPermission) { public WorkspaceSharingController(String itemId, boolean shareOnlyOwner, ACL_TYPE defaultPermission) {
this(itemId, shareOnlyOwner, defaultPermission, false, false); this(itemId, shareOnlyOwner, defaultPermission, false, false);

View File

@ -42,7 +42,7 @@ public class WorkspaceSmartSharingController {
* @param file - a fake file to display the field name ("filename") into dialog * @param file - a fake file to display the field name ("filename") into dialog
* @param listAlreadySharedContact - list of already shared contacts to show into dialog * @param listAlreadySharedContact - list of already shared contacts to show into dialog
* *
* base constructor by default do not retrieve groups * base constructor by default does not retrieve groups
* *
*/ */
public WorkspaceSmartSharingController(FileModel file, List<CredentialModel> listAlreadySharedContact) { public WorkspaceSmartSharingController(FileModel file, List<CredentialModel> listAlreadySharedContact) {

View File

@ -47,7 +47,7 @@ public class SmartShare extends Dialog implements SmartDialogInterface{
private boolean readGroupsFromPortal; private boolean readGroupsFromPortal;
/** /**
* base constructor by default do not retrieve groups * SmartShare base constructor by default does not retrieve groupss
*/ */
public SmartShare() { public SmartShare() {
this(false, false); this(false, false);

View File

@ -359,14 +359,19 @@ public class WorkspaceSharingServiceImpl extends RemoteServiceServlet implements
if(created){ if(created){
NotificationsProducer np = getNotificationProducer(); NotificationsProducer np = getNotificationProducer();
if(!sourceFolderIsShared) //if source folder is not already shared if(!sourceFolderIsShared) {//if source folder is not already shared
np.notifyFolderSharing(listContacts, sharedFolder);
else{ //TODO ADD NOTIFICATION
// np.notifyFolderSharing(listContacts, sharedFolder);
}else{
/*System.out.println("SHARED CONTACS: "); /*System.out.println("SHARED CONTACS: ");
printContacts(listSharedContact); printContacts(listSharedContact);
System.out.println("NEW CONTACS: "); System.out.println("NEW CONTACS: ");
printContacts(listContacts);*/ printContacts(listContacts);*/
np.notifyAddedUsersToSharing(listSharedContact, listContacts, sharedFolder);
//TODO ADD NOTIFICATION
// np.notifyAddedUsersToSharing(listSharedContact, listContacts, sharedFolder);
} }
} }
@ -463,6 +468,7 @@ public class WorkspaceSharingServiceImpl extends RemoteServiceServlet implements
for (VO vo : vos) { for (VO vo : vos) {
System.out.println("vo name "+vo.getName()); System.out.println("vo name "+vo.getName());
} }
} catch (Exception e) { } catch (Exception e) {
// TODO Auto-generated catch block // TODO Auto-generated catch block
e.printStackTrace(); e.printStackTrace();

View File

@ -1,21 +1,20 @@
/**
*
*/
package org.gcube.portlets.widgets.workspacesharingwidget.server.notifications; package org.gcube.portlets.widgets.workspacesharingwidget.server.notifications;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import org.apache.log4j.Logger;
import org.gcube.application.framework.core.session.ASLSession; import org.gcube.application.framework.core.session.ASLSession;
import org.gcube.application.framework.core.session.SessionManager; import org.gcube.application.framework.core.session.SessionManager;
import org.gcube.applicationsupportlayer.social.NotificationsManager; import org.gcube.applicationsupportlayer.social.NotificationsManager;
import org.gcube.common.homelibrary.home.workspace.WorkspaceFolder; import org.gcube.common.homelibrary.home.exceptions.InternalErrorException;
import org.gcube.common.homelibrary.home.workspace.WorkspaceItem; import org.gcube.common.homelibrary.home.workspace.WorkspaceItem;
import org.gcube.common.homelibrary.home.workspace.WorkspaceSharedFolder; 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.portlets.widgets.workspacesharingwidget.server.util.DiffereceBeetweenInfoContactModel;
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;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/** /**
* *
@ -26,7 +25,7 @@ public class NotificationsProducer {
protected ScopeBean scope; protected ScopeBean scope;
protected static Logger logger = LoggerFactory.getLogger(NotificationsProducer.class); protected static Logger logger = Logger.getLogger(NotificationsProducer.class);
protected NotificationsManager notificationsMng; protected NotificationsManager notificationsMng;
protected ASLSession aslSession; protected ASLSession aslSession;
@ -55,25 +54,26 @@ public class NotificationsProducer {
return aslSession; return aslSession;
} }
/** /**
* Runs a new thread to notify the contacts passed in input * Runs a new thread to notify the contacts passed in input
* @param listContacts * @param listContacts
* @param sharedFolder * @param sharedFolder
*/ */
public void notifyFolderSharing(final List<InfoContactModel> listContacts, final WorkspaceFolder sharedFolder) { public void notifyFolderSharing(final List<InfoContactModel> listContacts, final WorkspaceSharedFolder sharedFolder) {
/*
new Thread(){ new Thread(){
@Override @Override
public void run() { public void run() {
logger.info("Send notifies folder sharing is running..."); logger.trace("Send notifies folder sharing 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.info("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());
@ -86,15 +86,15 @@ public class NotificationsProducer {
} }
}catch (Exception e) { }catch (Exception e) {
logger.error("An error occured in notifyFolderSharing ", e); logger.error("An error occured in notifyFolderSharing ", e);
e.printStackTrace(); // e.printStackTrace();
} }
} }
logger.info("notifies share folder is completed"); logger.trace("notifies share folder is completed");
} }
}.start(); }.start();
*/
} }
@ -106,17 +106,17 @@ public class NotificationsProducer {
* @param sharedFolder * @param sharedFolder
*/ */
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 WorkspaceItem folderItem, final String itemOldName, final String itemNewName, final String idsharedFolder) {
/*
new Thread(){ new Thread(){
@Override @Override
public void run() { public void run() {
logger.info("Send notifies shared folder was renamed is running..."); logger.trace("Send notifies shared folder was renamed is running...");
try { try {
if(NotificationsUtil.checkIsRootFolderShared(folderItem.getId(), idsharedFolder)){ if(NotificationsUtil.checkIsRootFolderShared(folderItem.getId(), idsharedFolder)){
logger.info("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;
} }
@ -130,7 +130,7 @@ public class NotificationsProducer {
//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.info("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());
@ -143,14 +143,15 @@ public class NotificationsProducer {
} }
}catch (Exception e) { }catch (Exception e) {
logger.error("An error occured in notifyFolderRenamed ", e); logger.error("An error occured in notifyFolderRenamed ", e);
e.printStackTrace(); // e.printStackTrace();
} }
} }
logger.info("notifies share folder was renamed is completed"); logger.trace("notifies share folder was renamed is completed");
} }
}.start(); }.start();
*/
} }
@ -159,41 +160,41 @@ public class NotificationsProducer {
* @param listContacts * @param listContacts
* @param sharedFolder * @param sharedFolder
*/ */
public void notifyItemRenamed(final List<InfoContactModel> listSharedContact, final String previousName, final WorkspaceItem item, final WorkspaceFolder sharedFolder) { public void notifyItemRenamed(final List<InfoContactModel> listSharedContact, final String previousName, final WorkspaceItem item, final WorkspaceSharedFolder sharedFolder) {
/*
new Thread(){ new Thread(){
@Override @Override
public void run() { public void run() {
logger.info("Send notifies shared item was updated is running..."); logger.trace("Send notifies shared item was updated is running...");
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.info("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);
boolean notify = notificationsMng.notifyItemRenaming(infoContactModel.getLogin(), previousName, item); boolean notify = notificationsMng.notifyItemRenaming(infoContactModel.getLogin(), previousName, item, sharedFolder);
if(!notify) if(!notify)
logger.error("An error occured when notify user: "+infoContactModel.getLogin()); logger.error("An error occured when notify user: "+infoContactModel.getLogin());
} }
}catch (Exception e) { }catch (Exception e) {
logger.error("An error occured in notifyItemUpdated ", e); logger.error("An error occured in notifyItemUpdated ", e);
e.printStackTrace(); // e.printStackTrace();
} }
} }
logger.info("notifies shared item was updated is completed"); logger.trace("notifies shared item was updated is completed");
} }
}.start(); }.start();
*/
} }
@ -205,7 +206,7 @@ public class NotificationsProducer {
* @param sharedFolder - the shared folder * @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 WorkspaceSharedFolder sharedFolder) {
/*
new Thread() { new Thread() {
@Override @Override
public void run() { public void run() {
@ -228,7 +229,7 @@ public class NotificationsProducer {
try{ try{
logger.info("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());
@ -240,7 +241,7 @@ public class NotificationsProducer {
}catch (Exception e) { }catch (Exception e) {
logger.error("An error occured in notifyFolderAddedUser ", e); logger.error("An error occured in notifyFolderAddedUser ", e);
e.printStackTrace(); // e.printStackTrace();
} }
} }
@ -256,7 +257,7 @@ public class NotificationsProducer {
try{ try{
logger.info("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());
@ -268,7 +269,7 @@ public class NotificationsProducer {
}catch (Exception e) { }catch (Exception e) {
logger.error("An error occured in notifyFolderAddedUser ", e); logger.error("An error occured in notifyFolderAddedUser ", e);
e.printStackTrace(); // e.printStackTrace();
} }
} }
@ -281,12 +282,12 @@ public class NotificationsProducer {
}catch (Exception e) { }catch (Exception e) {
logger.error("An error occured in notifyAddedUserToSharing ", e); logger.error("An error occured in notifyAddedUserToSharing ", e);
e.printStackTrace(); // e.printStackTrace();
} }
} }
}.start(); }.start();
*/
} }
@ -295,15 +296,15 @@ public class NotificationsProducer {
* @param listContacts * @param listContacts
* @param unSharedFolder * @param unSharedFolder
*/ */
public void notifyFolderUnSharing(final List<InfoContactModel> listContacts, final WorkspaceFolder unSharedFolder) { public void notifyFolderUnSharing(final List<InfoContactModel> listContacts, final WorkspaceSharedFolder unSharedFolder) {
/*
new Thread() { new Thread() {
@Override @Override
public void run() { public void run() {
// printContacts(listContacts); // printContacts(listContacts);
logger.info("Send notifies folder un share is running..."); logger.trace("Send notifies folder un share is running...");
for (InfoContactModel infoContactModel : listContacts) { for (InfoContactModel infoContactModel : listContacts) {
try{ try{
@ -311,27 +312,26 @@ public class NotificationsProducer {
//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.info("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 "+infoContactModel.getLogin() +" un shared folder "+unSharedFolder.getName());
boolean notify = notificationsMng.notifyFolderRemovedUser(infoContactModel.getLogin(), (WorkspaceSharedFolder) unSharedFolder);
boolean notify = notificationsMng.notifyFolderRemovedUser(infoContactModel.getLogin(), unSharedFolder);
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 notifyFolderUnSharing ", e); logger.error("An error occured in notifyFolderUnSharing ", e);
e.printStackTrace(); // e.printStackTrace();
} }
} }
logger.info("notifies of un share notifications is completed"); logger.trace("notifies of un share notifications is completed");
} }
}.start(); }.start();
*/
} }
@ -341,14 +341,14 @@ public class NotificationsProducer {
* @param listContacts * @param listContacts
* @param workspaceItem * @param workspaceItem
*/ */
public void notifyAddedItemToSharing(final List<InfoContactModel> listContacts, final WorkspaceItem workspaceItem, final WorkspaceFolder sharedFolder) { public void notifyAddedItemToSharing(final List<InfoContactModel> listContacts, final WorkspaceItem workspaceItem, final WorkspaceSharedFolder sharedFolder) {
/*
new Thread() { new Thread() {
@Override @Override
public void run() { public void run() {
// printContacts(listContacts); // printContacts(listContacts);
logger.info("Send notifies added item in sharedfolder is running..."); logger.trace("Send notifies added item in sharedfolder is running...");
//DEBUG //DEBUG
System.out.println("Send notifies added item in sharedfolder is running..."); System.out.println("Send notifies added item in sharedfolder is running...");
@ -359,7 +359,7 @@ public class NotificationsProducer {
//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.info("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 "+workspaceItem.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 "+workspaceItem.getName()+" in shared folder "+sharedFolder.getName());
@ -372,24 +372,22 @@ public class NotificationsProducer {
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) {
logger.error("An error occured in notifyAddedItemToSharing ", e); logger.error("An error occured in notifyAddedItemToSharing ", e);
e.printStackTrace(); // e.printStackTrace();
} }
} }
logger.info("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();
*/
} }
@ -398,17 +396,17 @@ public class NotificationsProducer {
* @param listContacts * @param listContacts
* @param workspaceItem * @param workspaceItem
*/ */
public void notifyUpdatedItemToSharing(final List<InfoContactModel> listContacts, final WorkspaceItem workspaceItem, final WorkspaceFolder sharedFolder) { public void notifyUpdatedItemToSharing(final List<InfoContactModel> listContacts, final WorkspaceItem workspaceItem, final WorkspaceSharedFolder sharedFolder) {
/*
new Thread() { new Thread() {
@Override @Override
public void run() { public void run() {
// printContacts(listContacts); // printContacts(listContacts);
logger.info("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{
@ -416,10 +414,10 @@ public class NotificationsProducer {
//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.info("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 "+workspaceItem.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());
@ -429,7 +427,7 @@ public class NotificationsProducer {
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) {
@ -438,15 +436,13 @@ public class NotificationsProducer {
} }
} }
logger.info("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();
*/
} }
@ -458,20 +454,20 @@ public class NotificationsProducer {
* @param listContacts * @param listContacts
* @param sharedFolder * @param sharedFolder
*/ */
public void notifyMovedItemToSharing(final List<InfoContactModel> listContacts, final WorkspaceItem workspaceItem, final WorkspaceFolder sharedFolder) { public void notifyMovedItemToSharing(final List<InfoContactModel> listContacts, final WorkspaceItem workspaceItem, final WorkspaceSharedFolder sharedFolder) {
/*
new Thread() { new Thread() {
@Override @Override
public void run() { public void run() {
logger.info("Sending notification remove item in shared folder is running..."); logger.trace("Sending notification remove item in shared folder is running...");
// printContacts(listContacts); // printContacts(listContacts);
try { try {
if(NotificationsUtil.checkIsRootFolderShared(workspaceItem.getId(), sharedFolder.getId())){ if(NotificationsUtil.checkIsRootFolderShared(workspaceItem.getId(), sharedFolder.getId())){
logger.info("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;
} }
@ -480,9 +476,9 @@ public class NotificationsProducer {
return; return;
} }
logger.info("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{
@ -490,10 +486,10 @@ public class NotificationsProducer {
//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.info("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 "+workspaceItem.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());
boolean notify = notificationsMng.notifyMovedItem(infoContactModel.getLogin(), workspaceItem, sharedFolder); boolean notify = notificationsMng.notifyMovedItem(infoContactModel.getLogin(), workspaceItem, sharedFolder);
@ -501,7 +497,7 @@ public class NotificationsProducer {
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) {
@ -510,16 +506,16 @@ public class NotificationsProducer {
} }
} }
logger.info("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();
*/
} }
@ -528,28 +524,28 @@ public class NotificationsProducer {
* @param listContacts * @param listContacts
* @param sharedFolder * @param sharedFolder
*/ */
public void notifyRemovedItemToSharing(final List<InfoContactModel> listContacts, final String itemName, final WorkspaceFolder sharedFolder) { public void notifyRemovedItemToSharing(final List<InfoContactModel> listContacts, final String itemName, final WorkspaceSharedFolder sharedFolder) {
/*
new Thread() { new Thread() {
@Override @Override
public void run() { public void run() {
logger.info("Sending notification remove item in shared folder is running..."); logger.trace("Sending notification remove item in shared folder is running...");
// printContacts(listContacts); // printContacts(listContacts);
if(itemName==null || itemName.isEmpty()){ if(itemName==null || itemName.isEmpty()){
logger.info("Notification isn't sent - itemName is null or empty"); logger.trace("Notification isn't sent - itemName is null or empty");
return; return;
} }
if(sharedFolder==null){ if(sharedFolder==null){
logger.info("Notification isn't sent - sharedFolder is null"); logger.trace("Notification isn't sent - sharedFolder is null");
} }
logger.info("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{
@ -557,41 +553,81 @@ public class NotificationsProducer {
//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.info("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());
boolean notify = notificationsMng.notifyRemovedItem(infoContactModel.getLogin(), itemName, sharedFolder); boolean notify = notificationsMng.notifyRemovedItem(infoContactModel.getLogin(), itemName, sharedFolder);
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) {
logger.error("An error occurred in notifyRemovedItemToSharing ", e); logger.error("An error occurred in notifyRemovedItemToSharing ", e);
e.printStackTrace(); // e.printStackTrace();
} }
} }
logger.info("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();
}
/**
* Runs a new thread to notify the contacts passed in input
* @param listContacts
* @param unSharedFolder
*/
public void notifySharedFolderDeleted(final List<InfoContactModel> listContacts, final String folderNameDeleted) {
new Thread() {
@Override
public void run() {
// printContacts(listContacts);
logger.trace("Send notifies shared folder deleted is running...");
for (InfoContactModel infoContactModel : listContacts) {
try{
//NOTIFIES ONLY THE USERS THAT ARE DIFFERENT FROM CURRENT USER
if(infoContactModel.getLogin().compareTo(userId)!=0){
logger.trace("Sending notification to user "+infoContactModel.getLogin() +" deleted shared folder "+folderNameDeleted);
//DEBUG
System.out.println("Sending notification to user "+infoContactModel.getLogin() +" deleted shared folder "+folderNameDeleted);
//TODO
// boolean notify = notificationsMng.
// if(!notify)
// logger.error("An error occured when notifies user: "+infoContactModel.getLogin());
}
}catch (Exception e) {
logger.error("An error occured in notifySharedFolderDeleted ", e);
// e.printStackTrace();
}
}
logger.trace("notifies of deleted shared foder is completed");
}
}.start(); }.start();
*/
} }
//DEBUG //DEBUG
private void printContacts(List<InfoContactModel> listContacts){ private void printContacts(List<InfoContactModel> listContacts){
@ -625,4 +661,4 @@ public class NotificationsProducer {
} }
} }

View File

@ -8,16 +8,15 @@ import java.util.List;
import javax.servlet.http.HttpSession; import javax.servlet.http.HttpSession;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.gcube.common.homelibrary.home.workspace.Workspace; import org.gcube.common.homelibrary.home.workspace.Workspace;
import org.gcube.common.homelibrary.home.workspace.WorkspaceFolder;
import org.gcube.common.homelibrary.home.workspace.WorkspaceItem; import org.gcube.common.homelibrary.home.workspace.WorkspaceItem;
import org.gcube.common.homelibrary.home.workspace.WorkspaceItemType; import org.gcube.common.homelibrary.home.workspace.WorkspaceItemType;
import org.gcube.common.homelibrary.home.workspace.WorkspaceSharedFolder; import org.gcube.common.homelibrary.home.workspace.WorkspaceSharedFolder;
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;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/** /**
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it * @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
@ -68,9 +67,9 @@ public class NotificationsUtil {
//SWITCH BEETWEEN ADDED OR UPDATED //SWITCH BEETWEEN ADDED OR UPDATED
if(!isOverwrite) if(!isOverwrite)
np.notifyAddedItemToSharing(listContacts, sourceItem, (WorkspaceFolder) destinationSharedFolder); np.notifyAddedItemToSharing(listContacts, sourceItem, (WorkspaceSharedFolder) destinationSharedFolder);
else else
np.notifyUpdatedItemToSharing(listContacts, sourceItem, (WorkspaceFolder) destinationSharedFolder); np.notifyUpdatedItemToSharing(listContacts, sourceItem, (WorkspaceSharedFolder) destinationSharedFolder);
logger.info("The notifies was sent correctly"); logger.info("The notifies was sent correctly");
@ -187,7 +186,10 @@ public class NotificationsUtil {
NotificationsProducer np = new NotificationsProducer(WsUtil.getAslSession(httpSession)); NotificationsProducer np = new NotificationsProducer(WsUtil.getAslSession(httpSession));
np.notifyRemovedItemToSharing(listContacts, oldItemName, (WorkspaceFolder) sourceSharedFolder); 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");

View File

@ -21,6 +21,7 @@ import org.gcube.common.homelibrary.home.workspace.exceptions.WorkspaceFolderNot
import org.gcube.common.scope.api.ScopeProvider; import org.gcube.common.scope.api.ScopeProvider;
import org.gcube.portal.custom.scopemanager.scopehelper.ScopeHelper; import org.gcube.portal.custom.scopemanager.scopehelper.ScopeHelper;
import org.gcube.portlets.widgets.workspacesharingwidget.server.GWTWorkspaceSharingBuilder; import org.gcube.portlets.widgets.workspacesharingwidget.server.GWTWorkspaceSharingBuilder;
import org.gcube.portlets.widgets.workspacesharingwidget.server.WorkspaceSharingServiceImpl;
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;
import org.gcube.portlets.widgets.workspacesharingwidget.shared.system.VO; import org.gcube.portlets.widgets.workspacesharingwidget.shared.system.VO;
@ -41,9 +42,10 @@ public class WsUtil {
public static final String WORKSPACEBUILDER_ATTRIBUTE = "WORKSPACE_SHARING_BUILDER_ATTRIBUTE"; public static final String WORKSPACEBUILDER_ATTRIBUTE = "WORKSPACE_SHARING_BUILDER_ATTRIBUTE";
public static final String NOTIFICATION_MANAGER = "NOTIFICATION_SHARING_MANAGER"; public static final String NOTIFICATION_MANAGER = "NOTIFICATION_SHARING_MANAGER";
public static final String NOTIFICATION_PRODUCER = "NOTIFICATION_SHARING_PRODUCER"; public static final String NOTIFICATION_PRODUCER = "NOTIFICATION_SHARING_PRODUCER";
public static final String WORKSPACE_SCOPE_UTIL = "WORKSPACE__SHARING_SCOPE_UTIL"; public static final String WORKSPACE_SCOPE_UTIL = "WORKSPACE_SHARING_SCOPE_UTIL";
public static final String NOTIFICATION_PORTLET_CLASS_ID = "org.gcube.portlets.user.workspace.server.GWTWorkspaceServiceImpl"; //USE THE SAME OF WORKSPACE public static final String NOTIFICATION_PORTLET_CLASS_ID = "org.gcube.portlets.user.workspace.server.GWTWorkspaceServiceImpl"; //USE THE SAME OF WORKSPACE
// public static final String TEST_SCOPE = "/gcube/devsec"; // public static final String TEST_SCOPE = "/gcube/devsec";
// public static final String TEST_USER = "pasquale.pagano"; // public static final String TEST_USER = "pasquale.pagano";