use of com.emc.metalnx.core.domain.entity.DataGridGroupPermission in project metalnx-web by irods-contrib.
the class PermissionsController method getPermissionDetails.
/**
* Gives permission details related to a collection or file that is passed as a
* parameter
*
* @param model
* @param path
* @return
* @throws DataGridConnectionRefusedException
* @throws JargonException
* @throws FileNotFoundException
*/
@RequestMapping(value = "/getPermissionDetails/", method = RequestMethod.POST)
public String getPermissionDetails(final Model model, @RequestParam("path") final String path) throws DataGridConnectionRefusedException {
logger.debug("Getting permission info for {}", path);
DataGridCollectionAndDataObject obj = null;
List<DataGridFilePermission> permissions;
List<DataGridGroupPermission> groupPermissions;
List<DataGridUserPermission> userPermissions;
List<DataGridGroupBookmark> bookmarks;
List<DataGridUserBookmark> userBookmarks;
Set<String> groupsWithBookmarks;
Set<String> usersWithBookmarks;
boolean userCanModify = false;
boolean isCollection = false;
try {
loggedUser = luu.getLoggedDataGridUser();
permissions = ps.getPathPermissionDetails(path);
groupPermissions = ps.getGroupsWithPermissions(permissions);
userPermissions = ps.getUsersWithPermissions(permissions);
bookmarks = gBMS.findBookmarksOnPath(path);
userBookmarks = uBMS.findBookmarksOnPath(path);
userCanModify = loggedUser.isAdmin() || ps.canLoggedUserModifyPermissionOnPath(path);
groupsWithBookmarks = new HashSet<>();
for (DataGridGroupBookmark bookmark : bookmarks) {
groupsWithBookmarks.add(bookmark.getGroup().getGroupname());
}
usersWithBookmarks = new HashSet<>();
for (DataGridUserBookmark userBookmark : userBookmarks) {
usersWithBookmarks.add(userBookmark.getUser().getUsername());
}
obj = cs.findByName(path);
ps.resolveMostPermissiveAccessForUser(obj, loggedUser);
} catch (Exception e) {
logger.error("Could not get permission details {}: {}", path, e.getMessage());
groupPermissions = new ArrayList<>();
userPermissions = new ArrayList<>();
groupsWithBookmarks = new HashSet<>();
usersWithBookmarks = new HashSet<>();
}
model.addAttribute("usersWithBookmarks", usersWithBookmarks);
model.addAttribute("groupsWithBookmark", groupsWithBookmarks);
model.addAttribute("groupPermissions", groupPermissions);
model.addAttribute("userPermissions", userPermissions);
model.addAttribute("userCanModify", userCanModify);
model.addAttribute("permissions", PERMISSIONS);
model.addAttribute("permissionsWithoutNone", PERMISSIONS_WITHOUT_NONE);
model.addAttribute("collectionAndDataObject", obj);
model.addAttribute("isCollection", isCollection);
model.addAttribute("permissionOnCurrentPath", cs.getPermissionsForPath(path));
model.addAttribute("permissionFlag", true);
System.out.println("permissionOnCurrentPath =======" + cs.getPermissionsForPath(path));
System.out.println("------Permission Conroller - /getPermissionDetail/ ends------");
return "permissions/permissionDetails :: permissionDetails";
}
use of com.emc.metalnx.core.domain.entity.DataGridGroupPermission in project metalnx-web by irods-contrib.
the class CollectionServiceImpl method listCollectionsWithPermissionsForEntity.
/**
* Auxiliary method that filters the directories with the specified permission
* level for the given entity, that can be an user or a group
*
* @param path
* The path for which we would like to list the objects with
* permissions
* @param entityName
* The entity name
* @param permissionType
* The permission stype
* @param entityType
* The entity type that can be user or group
* @return
* @throws DataGridConnectionRefusedException
*/
private Set<String> listCollectionsWithPermissionsForEntity(String path, String entityName, FilePermissionEnum permissionType, String entityType) throws DataGridConnectionRefusedException {
logger.info("listCollectionsWithPermissionsForEntity()");
Set<String> collections = new HashSet<String>();
CollectionAndDataObjectListAndSearchAO collectionAndDataObjectListAndSearchAO = irodsServices.getCollectionAndDataObjectListAndSearchAO();
try {
List<CollectionAndDataObjectListingEntry> collList = collectionAndDataObjectListAndSearchAO.listDataObjectsAndCollectionsUnderPath(path);
logger.info("Getting permissions and bookmarks for path {}", path);
for (CollectionAndDataObjectListingEntry collEntry : collList) {
String filePath = "";
if (collEntry.isCollection()) {
filePath = collEntry.getPathOrName();
} else {
filePath = collEntry.getParentPath() + IRODS_PATH_SEPARATOR + collEntry.getPathOrName();
if (collEntry.getParentPath().compareTo(IRODS_PATH_SEPARATOR) == 0) {
filePath = collEntry.getParentPath() + collEntry.getPathOrName();
}
}
List<DataGridFilePermission> permissions = permissionsService.getPathPermissionDetails(filePath, entityName);
// Deciding whether we should get permissions for users or groups
if (entityType.compareTo("user") == 0) {
// Filtering permissions for users
List<DataGridUserPermission> userPermissions = permissionsService.getUsersWithPermissions(permissions);
// Adding collections with permissions into the result list
for (DataGridUserPermission dataGridUserPermission : userPermissions) {
if (dataGridUserPermission.getPermission().equalsIgnoreCase(permissionType.name())) {
collections.add(filePath);
}
}
} else {
// Filtering permissions for groups
List<DataGridGroupPermission> groupPermissions = permissionsService.getGroupsWithPermissions(permissions);
// Adding collections with permissions into the result list
for (DataGridGroupPermission dataGridGroupPermission : groupPermissions) {
if (dataGridGroupPermission.getPermission().equalsIgnoreCase(permissionType.name())) {
collections.add(filePath);
}
}
}
}
} catch (JargonException e) {
logger.error("Could not get permissions: ", e);
}
return collections;
}
Aggregations