use of org.irods.jargon.core.exception.JargonException in project metalnx-web by irods-contrib.
the class IRODSServicesImpl method findIRodsVersion.
@Override
public String findIRodsVersion() throws DataGridConnectionRefusedException {
String version = "";
try {
EnvironmentalInfoAO envInfoAO = irodsAccessObjectFactory.getEnvironmentalInfoAO(irodsAccount);
IrodsVersion iv = envInfoAO.getIRODSServerPropertiesFromIRODSServer().getIrodsVersion();
version = String.format("%s.%s.%s", iv.getMajorAsString(), iv.getMinorAsString(), iv.getPatchAsString());
} catch (JargonException e) {
logger.error("Could not find iRODS version: ", e);
if (e.getCause() instanceof ConnectException) {
throw new DataGridConnectionRefusedException(e.getMessage());
}
}
return version;
}
use of org.irods.jargon.core.exception.JargonException in project metalnx-web by irods-contrib.
the class IRODSServicesImpl method getTicketAdminService.
@Override
public TicketAdminService getTicketAdminService() throws DataGridConnectionRefusedException {
TicketAdminService tas = null;
try {
TicketServiceFactory tsf = new TicketServiceFactoryImpl(irodsAccessObjectFactory);
tas = tsf.instanceTicketAdminService(irodsAccount);
} catch (JargonException e) {
logger.error("Could not instantiate ticket admin service: ", e.getMessage());
if (e.getCause() instanceof ConnectException) {
throw new DataGridConnectionRefusedException(e.getMessage());
}
}
return tas;
}
use of org.irods.jargon.core.exception.JargonException 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.exception.JargonException 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;
}
use of org.irods.jargon.core.exception.JargonException in project metalnx-web by irods-contrib.
the class PermissionsServiceImpl method resolveMostPermissiveAccessForUser.
@Override
public void resolveMostPermissiveAccessForUser(DataGridCollectionAndDataObject obj, DataGridUser user) throws DataGridException {
if (obj == null || user == null)
return;
List<UserGroup> userGroups;
List<UserFilePermission> acl;
try {
userGroups = irodsServices.getGroupAO().findUserGroupsForUser(user.getUsername());
acl = getFilePermissionListForObject(obj.getPath());
} catch (JargonException e) {
throw new DataGridException();
}
// Building set containing group names for current user
Set<String> userGroupsSet = new HashSet<>();
for (UserGroup g : userGroups) {
userGroupsSet.add(g.getUserGroupName());
}
// Instantiating comparison matrix for permissions
List<String> permissions = new ArrayList<>();
permissions.add("NONE");
permissions.add("READ");
permissions.add("WRITE");
permissions.add("OWN");
String resultingPermission = "NONE";
for (UserFilePermission perm : acl) {
String permUserName = perm.getUserName();
// Checking if current permission is related to logged user
if (permUserName.compareTo(user.getUsername()) == 0 || userGroupsSet.contains(permUserName)) {
String permissionName = perm.getFilePermissionEnum().name();
int userOrGroupPerm = permissions.indexOf(permissionName);
int currentPermission = permissions.indexOf(resultingPermission);
if (userOrGroupPerm > currentPermission) {
resultingPermission = permissionName;
}
}
if (resultingPermission.compareToIgnoreCase("OWN") == 0) {
break;
}
}
obj.setMostPermissiveAccessForCurrentUser(resultingPermission.toLowerCase());
}
Aggregations