|
|
|
@ -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;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|