use of com.emc.metalnx.core.domain.entity.enums.DataGridPermType in project metalnx-web by irods-contrib.
the class PermissionsServiceImpl method findMostRestrictivePermission.
@Override
public DataGridPermType findMostRestrictivePermission(String... paths) throws DataGridConnectionRefusedException {
logger.info("Find most restrictive permission");
DataGridPermType mostRestrictivePermission = DataGridPermType.NONE;
Set<String> permissions = new HashSet<>();
for (String path : paths) {
logger.info("Get permission for {}", path);
permissions.add(collectionService.getPermissionsForPath(path));
}
if (permissions.contains("none")) {
mostRestrictivePermission = DataGridPermType.NONE;
} else if (permissions.contains("read")) {
mostRestrictivePermission = DataGridPermType.READ;
} else if (permissions.contains("write")) {
mostRestrictivePermission = DataGridPermType.WRITE;
} else if (permissions.contains("own")) {
mostRestrictivePermission = DataGridPermType.OWN;
}
logger.info("Most restrictive permission: {}", mostRestrictivePermission);
return mostRestrictivePermission;
}
use of com.emc.metalnx.core.domain.entity.enums.DataGridPermType in project metalnx-web by irods-contrib.
the class PermissionsController method findMostRestrictivePermission.
/**
* Finds the most restrictive permission on paths selected on the UI.
*
* @return string containing the most restrictive permission ("none", "read",
* "write", or "own")
* @throws DataGridConnectionRefusedException
* if Metalnx cannot connect to the grid
*/
@RequestMapping(value = "/findMostRestrictive/", method = RequestMethod.POST, produces = { "text/plain" })
@ResponseBody
private String findMostRestrictivePermission(@RequestParam("paths[]") final String[] paths) throws DataGridConnectionRefusedException {
DataGridPermType mostRestrictivePermission = ps.findMostRestrictivePermission(paths);
boolean isAdmin = luu.getLoggedDataGridUser().isAdmin();
boolean isPermNone = mostRestrictivePermission.equals(DataGridPermType.NONE);
if (isPermNone && isAdmin) {
mostRestrictivePermission = DataGridPermType.IRODS_ADMIN;
}
return mostRestrictivePermission.toString().toLowerCase();
}
use of com.emc.metalnx.core.domain.entity.enums.DataGridPermType in project metalnx-web by irods-contrib.
the class PermissionsController method addUserToCreationList.
@RequestMapping(value = "/addUserPermissions/")
@ResponseBody
public String addUserToCreationList(@RequestParam("permission") final String permission, @RequestParam("users") final String users, @RequestParam("path") final String path, @RequestParam("bookmark") final boolean bookmark, @RequestParam("recursive") final boolean recursive) throws DataGridConnectionRefusedException {
boolean operationResult = true;
String[] usernames = users.split(",");
DataGridPermType permType = DataGridPermType.valueOf(permission);
loggedUser = luu.getLoggedDataGridUser();
for (String username : usernames) {
if (us.findByUsername(username).isEmpty()) {
return REQUEST_ERROR;
}
}
for (String username : usernames) {
operationResult &= ps.setPermissionOnPath(permType, username, recursive, loggedUser.isAdmin(), path);
// Updating bookmarks for the recently-created permissions
if (bookmark) {
Set<String> bookmarks = new HashSet<String>();
bookmarks.add(path);
// Getting list of users and updating bookmarks
List<DataGridUser> dataGridUsers = us.findByUsername(username);
if (dataGridUsers != null && !dataGridUsers.isEmpty()) {
uBMS.updateBookmarks(dataGridUsers.get(0), bookmarks, null);
}
}
}
return operationResult ? REQUEST_OK : REQUEST_ERROR;
}
use of com.emc.metalnx.core.domain.entity.enums.DataGridPermType in project metalnx-web by irods-contrib.
the class PermissionsController method changePermissionForUserOrGroupOnPath.
/* ********************************************************************* */
/* **************************** PRIVATE METHOS ************************* */
/* ********************************************************************* */
/**
* Sends the permissions change to the services layer and returns the result of
* the operation.
*
* @param permissionData
* @return
* @throws FileNotFoundException
* @throws JargonException
* @throws DataGridConnectionRefusedException
*/
private String changePermissionForUserOrGroupOnPath(final String permissionData, final boolean recursive) throws DataGridConnectionRefusedException {
// Getting information about the new permission to be applied and the path
// of the current object (collection or data object)
String[] permissionParts = permissionData.split("#");
DataGridPermType newPermission = DataGridPermType.valueOf(permissionParts[0]);
String path = permissionParts[1];
String userOrGroupName = permissionParts[2];
loggedUser = luu.getLoggedDataGridUser();
boolean permChanged = ps.setPermissionOnPath(newPermission, userOrGroupName, recursive, loggedUser.isAdmin(), path);
return permChanged ? REQUEST_OK : REQUEST_ERROR;
}
use of com.emc.metalnx.core.domain.entity.enums.DataGridPermType in project metalnx-web by irods-contrib.
the class PermissionsController method addGroupToCreationList.
@RequestMapping(value = "/addGroupPermissions/")
@ResponseBody
public String addGroupToCreationList(@RequestParam("permission") final String permission, @RequestParam("groups") final String groups, @RequestParam("path") final String path, @RequestParam("bookmark") final boolean bookmark, @RequestParam("recursive") final boolean recursive) throws DataGridConnectionRefusedException {
boolean operationResult = true;
String[] groupParts = groups.split(",");
DataGridPermType permType = DataGridPermType.valueOf(permission);
loggedUser = luu.getLoggedDataGridUser();
for (String group : groupParts) {
if (gs.findByGroupname(group).isEmpty()) {
return REQUEST_ERROR;
}
}
for (String group : groupParts) {
operationResult &= ps.setPermissionOnPath(permType, group, recursive, loggedUser.isAdmin(), path);
}
// Updating bookmarks for the recently-created permissions
if (bookmark) {
Set<String> bookmarks = new HashSet<String>();
bookmarks.add(path);
// Getting list of groups and updating bookmarks
List<DataGridGroup> groupObjects = gs.findByGroupNameList(groupParts);
for (DataGridGroup g : groupObjects) {
gBMS.updateBookmarks(g, bookmarks, null);
}
}
return operationResult ? REQUEST_OK : REQUEST_ERROR;
}
Aggregations