Fixing class cast exceptiong during get USER ACL Info (see: https://support.d4science.org/issues/12956)
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/widgets/workspace-explorer@174463 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
43557eaad8
commit
54bd178d8a
|
@ -1,4 +1,11 @@
|
|||
<ReleaseNotes>
|
||||
<Changeset component="portlets-widgets.workspace-explorer.2-0-2"
|
||||
date="${buildDate}">
|
||||
<Change>[Incident #77436] Fixing class cast Exception for FolderItem son of a SharedFolder
|
||||
</Change>
|
||||
<Change>Fixed breadcrumb on SelectDialaog
|
||||
</Change>
|
||||
</Changeset>
|
||||
<Changeset component="portlets-widgets.workspace-explorer.2-0-1"
|
||||
date="${buildDate}">
|
||||
<Change>[Task #10943] Removed final to a Constant
|
||||
|
|
|
@ -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<? extends Item> 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<ACL> 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<ACL> 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();
|
||||
|
|
Loading…
Reference in New Issue