Francesco Mangiacrapa 5 years ago
parent 347692bb5b
commit 913cfdc407

@ -1389,40 +1389,21 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
try {
List<InfoContactModel> listSharedContact = new ArrayList<InfoContactModel>();
NotificationsProducerToStorageHub np = getNotificationProducerToStorageHub();
org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceItem sourceShared = workspace
.getRootSharedFolder(wsItem.getId());
org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceItem sourceShared = workspace.getRootSharedFolder(wsItem.getId());
// NotificationsManager nManager =
// WsUtil.getNotificationManager(this.getThreadLocalRequest());
listSharedContact = NotificationStorageHubUtil.getListUserSharedByFolderSharedId(sourceShared,
workspace);
// IS A SHARED FOLDER
if (NotificationStorageHubUtil.isASharedFolder(wsItem)) {
// THE ITEM RENAMED IS A SHARED FOLDER
if (NotificationStorageHubUtil.isFolderAndShared(wsItem)) {
np.notifyFolderRenamed(listSharedContact, wsItem, previousName, newName, sourceShared.getId());
// NotificationStorageHubUtil.checkNotifyAddItemToShare(movedItem,
// sourceRootSharedFolderId, folderDestination,
// workspace, np);
// NotificationStorageHubUtil.checkNotifyMoveItemFromShare(sourceItemIsShared,
// sourceItem, sourceRootSharedFolderId,
// folderDestination, workspace, np);
} else {
// IS AN SHARED ITEM
if (sourceShared instanceof org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceSharedFolder)
// THE ITEM RENAMED IS A SHARED ITEM
//if (sourceShared instanceof org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceSharedFolder)
np.notifyItemRenamed(listSharedContact, previousName, wsItem,
(org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceSharedFolder) sourceShared,
(org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceFolder) sourceShared,
workspace);
// //TWO CASES: EITHER ROOT FOLDER AS
// WorkspaceSharedFolder OR DOESN'T.
// WorkspaceItem sharedFolder =
// workspace.getItem(wsItem.getIdSharedFolder());
// if(sharedFolder instanceof WorkspaceSharedFolder)
// notification.notifyItemRenamed(listSharedContact,
// previousName, wsItem, (WorkspaceSharedFolder)
// sharedFolder);
// else
// workspaceLogger.trace("Notifies for rename item
// itemId: "+itemId+" doesn't sent because:
// "+sharedFolder+" is not an instance of
// WorkspaceSharedFolder");
}
} catch (Exception e) {
workspaceLogger.error("An error occurred in checkNotify ", e);

@ -5,8 +5,8 @@ package org.gcube.portlets.user.workspace.server.notifications.tostoragehub;
import org.gcube.applicationsupportlayer.social.shared.SocialFileItem;
import org.gcube.applicationsupportlayer.social.shared.SocialSharedFolder;
import org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceFolder;
import org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceItem;
import org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceSharedFolder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -26,10 +26,12 @@ public class NotificationMapperToStorageHub {
* @param sharedFolder the shared folder
* @return the social shared folder
*/
public static SocialSharedFolder toSocialSharedFolder(WorkspaceSharedFolder sharedFolder) {
public static SocialSharedFolder toSocialSharedFolder(WorkspaceFolder sharedFolder) {
boolean isVREFolder = NotificationStorageHubUtil.isVREFolder(sharedFolder);
return new SocialSharedFolder(sharedFolder.getId(), sharedFolder.getName(), sharedFolder.getTitle(),
sharedFolder.getName(), sharedFolder.getPath(), sharedFolder.getParentId(), sharedFolder.isVreFolder());
sharedFolder.getName(), sharedFolder.getPath(), sharedFolder.getParentId(), isVREFolder);
}
/**
@ -50,8 +52,11 @@ public class NotificationMapperToStorageHub {
}
//
SocialSharedFolder parent = null;
if (theParentFolder != null && theParentFolder instanceof WorkspaceSharedFolder)
parent = toSocialSharedFolder((WorkspaceSharedFolder) theParentFolder);
boolean isFolderAndShared = NotificationStorageHubUtil.isFolderAndShared(theParentFolder);
if (theParentFolder != null && isFolderAndShared)
parent = toSocialSharedFolder((WorkspaceFolder) theParentFolder);
//
return new SocialFileItem(item.getId(), item.getName(), item.getTitle(), item.getPath(), parent);
}

@ -12,6 +12,7 @@ import org.gcube.common.storagehub.model.types.WorkspaceItemType;
import org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceFolder;
import org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceItem;
import org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceSharedFolder;
import org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceVREFolder;
import org.gcube.portlets.user.workspace.server.tostoragehub.StorageHubToWorkpaceConverter;
import org.gcube.portlets.user.workspace.server.util.WsUtil;
import org.gcube.portlets.widgets.workspacesharingwidget.shared.InfoContactModel;
@ -63,9 +64,9 @@ public class NotificationStorageHubUtil {
List<InfoContactModel> listContacts = getListUserSharedByFolderSharedId(rootSharedFolder, workspace);
//WorkspaceItem destinationSharedFolder = workspace.getItem(rootSharedFolder.getId());
WorkspaceItem destinationSharedFolder = rootSharedFolder;
if(destinationSharedFolder instanceof WorkspaceSharedFolder){
np.notifyAddedItemToSharing(workspace, listContacts, workspaceItem, (WorkspaceSharedFolder) destinationSharedFolder);
if(isFolderAndShared(destinationSharedFolder)){
np.notifyAddedItemToSharing(workspace, listContacts, workspaceItem, (WorkspaceFolder) destinationSharedFolder);
logger.trace("The notifies sent correctly");
}
else
@ -129,8 +130,8 @@ public class NotificationStorageHubUtil {
WorkspaceItem sourceRootSharedFolder = workspace.getItem(sourceRootSharedFolderId);
if(sourceRootSharedFolder instanceof WorkspaceSharedFolder){
np.notifyMovedItemToSharing(workspace, listContacts, sourceItem, (WorkspaceSharedFolder) sourceRootSharedFolder);
if(isFolderAndShared(sourceRootSharedFolder)){
np.notifyMovedItemToSharing(workspace, listContacts, sourceItem, (WorkspaceFolder) sourceRootSharedFolder);
logger.trace("The notifies was sent correctly");
}else
logger.warn("Notifies moved item: "+sourceItem+ "from share doesn't sent because "+sourceRootSharedFolder+" is not istance of WorkspaceSharedFolder");
@ -157,7 +158,7 @@ public class NotificationStorageHubUtil {
try {
if(isASharedFolder(rootSharedFolder)){ //JUST TO BE SURE
if(isFolderAndShared(rootSharedFolder)){ //JUST TO BE SURE
List<String> listPortalLogin = workspace.getSharedFolderMembers(rootSharedFolder.getId());
logger.debug("StorageHub returned "+ listPortalLogin.size() + " user/s");
@ -206,11 +207,11 @@ public class NotificationStorageHubUtil {
}
String idSharedFolder = sourceFolderSharedId!=null?sourceFolderSharedId:"";
boolean isRootFolderShared = checkIsRootFolderShared(oldItemId, idSharedFolder);
boolean isRootFolderShared = checkIsRootSharedFolder(oldItemId, idSharedFolder);
logger.trace("isRootFolderShared is: "+ isRootFolderShared);
WorkspaceItem sourceSharedFolder = workspace.getItem(idSharedFolder);
boolean isSharedFolder = isASharedFolder(sourceSharedFolder);
boolean isSharedFolder = isFolderAndShared(sourceSharedFolder);
if(isSharedFolder){
logger.trace("idSharedFolder is: "+ idSharedFolder +" is shared folder: "+isSharedFolder);
@ -219,12 +220,12 @@ public class NotificationStorageHubUtil {
//Notify Removed Item To Sharing?
if(!isRootFolderShared){
if(sourceSharedFolder instanceof org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceSharedFolder){
//if(isFolderAndShared(sourceSharedFolder)){
np.notifyRemovedItemToSharing(listContacts, oldItemName, (org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceSharedFolder) sourceSharedFolder);
logger.debug("Notification was sent correctly");
}
else
logger.debug("The notifies doesn't sent because "+sourceSharedFolder+ " is not instance of WorkspaceSharedFolder");
//}
//else
// logger.debug("The notifies doesn't sent because "+sourceSharedFolder+ " is not instance of WorkspaceSharedFolder");
}else{
//Case removed shared folder
@ -270,28 +271,56 @@ public class NotificationStorageHubUtil {
}
/**
* Checks if is a shared folder.
* Checks if is folder and shared.
*
* @param wsItem the ws item
* @return true, if is a shared folder
* @return true, if is folder and shared
*/
public static boolean isASharedFolder(WorkspaceItem wsItem){
if(wsItem!=null)
return wsItem.getType().equals(WorkspaceItemType.SHARED_FOLDER);
public static boolean isFolderAndShared(WorkspaceItem wsItem){
if(wsItem!=null) {
if (wsItem.isFolder() && wsItem.isShared()) {
return true;
}
}
return false;
}
/**
* Check is root folder shared.
* Checks if is VRE folder.
*
* @param folder the folder
* @return true, if is VRE folder
*/
public static boolean isVREFolder(WorkspaceFolder folder) {
try {
if(folder instanceof WorkspaceVREFolder) {
return true;
}
if(folder instanceof WorkspaceSharedFolder) {
WorkspaceSharedFolder sharedFolder = (WorkspaceSharedFolder) folder;
return sharedFolder.isVreFolder();
}
}catch (Exception e) {
//silent
}
return false;
}
/**
* Check is root shared folder.
*
* @param itemId the item id
* @param rootFolderSharedId the root folder shared id
* @return true, if successful
*/
public static boolean checkIsRootFolderShared(String itemId, String rootFolderSharedId) {
public static boolean checkIsRootSharedFolder(String itemId, String rootFolderSharedId) {
logger.trace("checkIsRootFolderShared between [itemid: "+itemId +", rootFolderSharedId: "+rootFolderSharedId+"]");
if(itemId==null)
@ -305,5 +334,7 @@ public class NotificationStorageHubUtil {
return false;
}
}

@ -12,8 +12,8 @@ import org.gcube.applicationsupportlayer.social.NotificationsManager;
import org.gcube.applicationsupportlayer.social.shared.SocialFileItem;
import org.gcube.applicationsupportlayer.social.shared.SocialSharedFolder;
import org.gcube.common.scope.impl.ScopeBean;
import org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceFolder;
import org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceItem;
import org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceSharedFolder;
import org.gcube.portlets.user.workspace.server.util.PortalContextInfo;
import org.gcube.portlets.user.workspace.server.util.WsUtil;
import org.gcube.portlets.widgets.workspacesharingwidget.shared.InfoContactModel;
@ -58,7 +58,7 @@ public class NotificationsProducerToStorageHub {
* @param workspaceItem the workspace item
* @param sharedFolder the shared folder
*/
public void notifyAddedItemToSharing(final org.gcube.common.storagehubwrapper.server.tohl.Workspace workspace, final List<InfoContactModel> listContacts, final WorkspaceItem workspaceItem, final WorkspaceSharedFolder sharedFolder) {
public void notifyAddedItemToSharing(final org.gcube.common.storagehubwrapper.server.tohl.Workspace workspace, final List<InfoContactModel> listContacts, final WorkspaceItem workspaceItem, final WorkspaceFolder sharedFolder) {
new Thread() {
@Override
@ -101,9 +101,9 @@ public class NotificationsProducerToStorageHub {
* @param workspace the workspace
* @param listContacts the list contacts
* @param workspaceItem the workspace item
* @param sourceRootSharedFolder the shared folder
* @param sourceRootSharedFolder the source root shared folder
*/
public void notifyMovedItemToSharing(final org.gcube.common.storagehubwrapper.server.tohl.Workspace workspace, final List<InfoContactModel> listContacts, final WorkspaceItem workspaceItem, final WorkspaceSharedFolder sourceRootSharedFolder) {
public void notifyMovedItemToSharing(final org.gcube.common.storagehubwrapper.server.tohl.Workspace workspace, final List<InfoContactModel> listContacts, final WorkspaceItem workspaceItem, final WorkspaceFolder sourceRootSharedFolder) {
new Thread() {
@ -159,7 +159,7 @@ public class NotificationsProducerToStorageHub {
logger.trace("Send notifies shared folder was renamed is running...");
if(NotificationStorageHubUtil.checkIsRootFolderShared(folderItem.getId(), idRootSharedFolder)){
if(NotificationStorageHubUtil.checkIsRootSharedFolder(folderItem.getId(), idRootSharedFolder)){
logger.info("Notification not sent because the event is on root shared folder");
return;
}
@ -188,8 +188,7 @@ public class NotificationsProducerToStorageHub {
}
/**
* Notify item renamed.
*
@ -199,7 +198,7 @@ public class NotificationsProducerToStorageHub {
* @param sharedFolder the shared folder
* @param workspace the workspace
*/
public void notifyItemRenamed(final List<InfoContactModel> listSharedContact, final String previousName, final WorkspaceItem item, final WorkspaceSharedFolder sharedFolder, final org.gcube.common.storagehubwrapper.server.tohl.Workspace workspace) {
public void notifyItemRenamed(final List<InfoContactModel> listSharedContact, final String previousName, final WorkspaceItem item, final WorkspaceFolder sharedFolder, final org.gcube.common.storagehubwrapper.server.tohl.Workspace workspace) {
new Thread(){
@Override
@ -231,6 +230,7 @@ public class NotificationsProducerToStorageHub {
}
/**
* Notify removed item to sharing.
*
@ -238,7 +238,7 @@ public class NotificationsProducerToStorageHub {
* @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 WorkspaceFolder sharedFolder) {
new Thread() {

Loading…
Cancel
Save