use of org.irods.jargon.core.protovalues.FilePermissionEnum in project metalnx-web by irods-contrib.
the class CollectionServiceImpl method getPermissionsForPath.
@Override
public String getPermissionsForPath(String path) throws DataGridConnectionRefusedException {
logger.info("getPermissionsForPath()");
FilePermissionEnum filePermissionEnum = null;
String permissionType = "none";
try {
String user = irodsServices.getCurrentUser();
String zone = irodsServices.getCurrentUserZone();
Object obj = irodsServices.getCollectionAndDataObjectListAndSearchAO().getFullObjectForType(path);
if (obj instanceof Collection) {
CollectionAO collectionAO = irodsServices.getCollectionAO();
filePermissionEnum = collectionAO.getPermissionForCollection(path, user, zone);
} else {
DataObjectAO dataObjectAO = irodsServices.getDataObjectAO();
filePermissionEnum = dataObjectAO.getPermissionForDataObject(path, user, zone);
}
if (filePermissionEnum != null) {
permissionType = filePermissionEnum.toString().toLowerCase();
}
} catch (FileNotFoundException e) {
logger.error("Could not find path: {}", e.getMessage());
} catch (JargonException e) {
logger.error("Could not get permission for path: {}", e.getMessage());
}
return permissionType;
}
use of org.irods.jargon.core.protovalues.FilePermissionEnum in project metalnx-web by irods-contrib.
the class PermissionsServiceImpl method chmodDataObject.
private boolean chmodDataObject(DataGridPermType permType, String path, String uName, boolean inAdminMode) throws DataGridConnectionRefusedException {
String currentZone = irodsServices.getCurrentUserZone();
DataObjectAO dataObjectAO = irodsServices.getDataObjectAO();
logger.debug("Setting {} permission on data object {} for user/group {}", permType, path, uName);
boolean isPermissionSet = false;
try {
if (!inAdminMode) {
FilePermissionEnum filePermission = FilePermissionEnum.valueOf(permType.toString());
dataObjectAO.setAccessPermission(currentZone, path, uName, filePermission);
} else if (permType.equals(DataGridPermType.READ))
dataObjectAO.setAccessPermissionReadInAdminMode(currentZone, path, uName);
else if (permType.equals(DataGridPermType.WRITE))
dataObjectAO.setAccessPermissionWriteInAdminMode(currentZone, path, uName);
else if (permType.equals(DataGridPermType.OWN))
dataObjectAO.setAccessPermissionOwnInAdminMode(currentZone, path, uName);
else
dataObjectAO.removeAccessPermissionsForUserInAdminMode(currentZone, path, uName);
isPermissionSet = true;
} catch (JargonException e) {
logger.error("Could not set {} permission on path {} for user/group {}", permType, path, uName, e);
}
return isPermissionSet;
}
use of org.irods.jargon.core.protovalues.FilePermissionEnum in project metalnx-web by irods-contrib.
the class PermissionsServiceImpl method chmodCollection.
private boolean chmodCollection(DataGridPermType permType, String path, boolean recursive, String uName, boolean inAdminMode) throws DataGridConnectionRefusedException {
String currentZone = irodsServices.getCurrentUserZone();
CollectionAO collectionAO = irodsServices.getCollectionAO();
boolean isPermissionSet = false;
try {
logger.debug("Setting {} permission on collection {} for user/group as ADMIN{}", permType, path, uName);
if (!inAdminMode) {
FilePermissionEnum filePermission = FilePermissionEnum.valueOf(permType.toString());
collectionAO.setAccessPermission(currentZone, path, uName, recursive, filePermission);
} else if (permType.equals(DataGridPermType.READ))
collectionAO.setAccessPermissionReadAsAdmin(currentZone, path, uName, recursive);
else if (permType.equals(DataGridPermType.WRITE))
collectionAO.setAccessPermissionWriteAsAdmin(currentZone, path, uName, recursive);
else if (permType.equals(DataGridPermType.OWN))
collectionAO.setAccessPermissionOwnAsAdmin(currentZone, path, uName, recursive);
else
collectionAO.removeAccessPermissionForUserAsAdmin(currentZone, path, uName, recursive);
isPermissionSet = true;
} catch (JargonException e) {
logger.error("Could not set {} permission on path {} for user/group {}", permType, path, uName, e);
}
return isPermissionSet;
}
Aggregations