diff --git a/distro/changelog.xml b/distro/changelog.xml index e2a083f..a140761 100644 --- a/distro/changelog.xml +++ b/distro/changelog.xml @@ -1,4 +1,11 @@ + + [Incident #77436] Fixing class cast Exception for FolderItem son of a SharedFolder + + Fixed breadcrumb on SelectDialaog + + [Task #10943] Removed final to a Constant diff --git a/src/main/java/org/gcube/portlets/widgets/wsexplorer/server/stohub/StorageHubServiceUtil.java b/src/main/java/org/gcube/portlets/widgets/wsexplorer/server/stohub/StorageHubServiceUtil.java index 34932b7..9cd9f09 100644 --- a/src/main/java/org/gcube/portlets/widgets/wsexplorer/server/stohub/StorageHubServiceUtil.java +++ b/src/main/java/org/gcube/portlets/widgets/wsexplorer/server/stohub/StorageHubServiceUtil.java @@ -14,6 +14,7 @@ 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.common.storagehub.model.items.VreFolder; import com.liferay.portal.kernel.log.Log; import com.liferay.portal.kernel.log.LogFactoryUtil; @@ -58,7 +59,7 @@ public class StorageHubServiceUtil { List toReturn = client.getAnchestors(itemId, ACCOUNTING_HL_NODE_NAME); return toReturn; } - + public static FolderItem createFolder(HttpServletRequest request, String parentId, String name, String description) { PortalContext pContext = PortalContext.getConfiguration(); String userName = pContext.getCurrentUser(request).getUsername(); @@ -72,7 +73,7 @@ public class StorageHubServiceUtil { } /** - * + * * @param request * @return the VRE Folders Id */ @@ -92,7 +93,7 @@ public class StorageHubServiceUtil { } catch (Exception e) { _log.info("This user has no VRE Folders", e); return null; - } + } }catch (Exception e) { e.printStackTrace(); } @@ -108,26 +109,44 @@ public class StorageHubServiceUtil { ScopeProvider.instance.set(scope); SecurityTokenProvider.instance.set(authorizationToken); - Item theFolder = getItem(request, folderId); - if (!theFolder.isShared()) { - return "OWNER"; - } else { - ItemManagerClient client = AbstractPlugin.item().build(); - List acls = client.getACL(folderId); - SharedFolder sharedFolder = (SharedFolder) theFolder; - - boolean found = false; //this is needed because in case o VRE Foder the permission is assigned ot the group and not to the user. - for (ACL acl : acls) { - if (acl.getPricipal().compareTo(userName) == 0) { - found = true; - return acl.getAccessTypes().get(0).toString(); - } - } - if (!found && sharedFolder.isVreFolder()) { + Item theItem = getItem(request, folderId); + + //IS IT REALLY A FOLDER? + if (theItem instanceof FolderItem){ + //THE FOLDER IS NOT SHARED + if (!theItem.isShared()) { + return "OWNER"; + } else { + //HERE THE FOLDER IS SHARED + ItemManagerClient client = AbstractPlugin.item().build(); + FolderItem folderItem = (FolderItem) theItem; + SharedFolder sharedfolder; + if (theItem instanceof SharedFolder || theItem instanceof VreFolder) { + ///THE FolderItem IS THE ROOT SHARED FOLDER + sharedfolder = (SharedFolder) folderItem; + + }else{ + //THE FolderItem IS SON OF ROOT SHARED FOLDER SO REQUESTING THE ROOT SHARED FOLDER + sharedfolder = (SharedFolder) client.getRootSharedFolder(folderItem.getId()); + _log.warn("This item "+folderId+" is a folder not castable at "+SharedFolder.class.getSimpleName() + " or at "+VreFolder.class.getSimpleName()); + } + + List acls = client.getACL(sharedfolder.getId()); + boolean found = false; //this is needed because in case o VRE Foder the permission is assigned to the group and not to the user. for (ACL acl : acls) { - if (acl.getPricipal().startsWith(pContext.getInfrastructureName())) + if (acl.getPricipal().compareTo(userName) == 0) { + found = true; return acl.getAccessTypes().get(0).toString(); + } } + + if (!found && sharedfolder.isVreFolder()) { + for (ACL acl : acls) { + if (acl.getPricipal().startsWith(pContext.getInfrastructureName())) + return acl.getAccessTypes().get(0).toString(); + } + } + } } return "UNDEFINED"; @@ -135,7 +154,7 @@ public class StorageHubServiceUtil { /** - * + * */ public static int getItemChildrenCount(HttpServletRequest request, String itemId) { PortalContext pContext = PortalContext.getConfiguration();