use of org.irods.jargon.core.pub.DataObjectAO in project metalnx-web by irods-contrib.
the class GroupServiceImpl method updateWritePermissions.
@Override
public boolean updateWritePermissions(DataGridGroup group, Map<String, Boolean> addCollectionsToWrite, Map<String, Boolean> removeCollectionsToWrite) throws DataGridConnectionRefusedException {
DataObjectAO dataObjectAO = irodsServices.getDataObjectAO();
CollectionAO collectionAO = irodsServices.getCollectionAO();
try {
for (String path : addCollectionsToWrite.keySet()) {
if (collectionService.isCollection(path)) {
collectionAO.setAccessPermissionWriteAsAdmin(group.getAdditionalInfo(), path, group.getGroupname(), addCollectionsToWrite.get(path));
} else {
dataObjectAO.setAccessPermissionWriteInAdminMode(group.getAdditionalInfo(), path, group.getGroupname());
}
}
for (String path : removeCollectionsToWrite.keySet()) {
if (collectionService.isCollection(path)) {
collectionAO.removeAccessPermissionForUserAsAdmin(group.getAdditionalInfo(), path, group.getGroupname(), removeCollectionsToWrite.get(path));
} else {
dataObjectAO.removeAccessPermissionsForUserInAdminMode(group.getAdditionalInfo(), path, group.getGroupname());
}
}
return true;
} catch (JargonException | DataGridException e) {
logger.error("Could not set read permission:", e);
}
return false;
}
use of org.irods.jargon.core.pub.DataObjectAO 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.pub.DataObjectAO in project metalnx-web by irods-contrib.
the class SpecQueryServiceImplTest method setUpBeforeClass.
@BeforeClass
public static void setUpBeforeClass() throws Exception {
TestingPropertiesHelper testingPropertiesLoader = new TestingPropertiesHelper();
testingProperties = testingPropertiesLoader.getTestProperties();
scratchFileUtils = new ScratchFileUtils(testingProperties);
scratchFileUtils.clearAndReinitializeScratchDirectory(IRODS_TEST_SUBDIR_PATH);
irodsTestSetupUtilities = new IRODSTestSetupUtilities();
irodsTestSetupUtilities.initializeIrodsScratchDirectory();
irodsTestSetupUtilities.initializeDirectoryForTest(IRODS_TEST_SUBDIR_PATH);
irodsFileSystem = IRODSFileSystem.instance();
// set up test structure
String rootCollection = "SpecQueryServiceImplTestRoot";
String localCollectionAbsolutePath = scratchFileUtils.createAndReturnAbsoluteScratchPath(IRODS_TEST_SUBDIR_PATH + '/' + rootCollection);
IRODSAccount irodsAccount = testingPropertiesHelper.buildIRODSAccountFromTestProperties(testingProperties);
String irodsCollectionRootAbsolutePath = (MiscIRODSUtils.computeHomeDirectoryForIRODSAccount(irodsAccount) + '/' + rootCollection);
rootCollPathInIrods = irodsCollectionRootAbsolutePath;
FileGenerator.generateManyFilesAndCollectionsInParentCollectionByAbsolutePath(localCollectionAbsolutePath, "specQueryTset", 1, 2, 3, "testFile", ".txt", 4, 3, 2, 30000);
IRODSFileFactory irodsFileFactory = irodsFileSystem.getIRODSFileFactory(irodsAccount);
IRODSFile destFile = irodsFileFactory.instanceIRODSFile(irodsCollectionRootAbsolutePath);
destFile.deleteWithForceOption();
destFile.mkdirs();
DataTransferOperations dataTransferOperationsAO = irodsFileSystem.getIRODSAccessObjectFactory().getDataTransferOperations(irodsAccount);
DataObjectAO dataObjectAO = irodsFileSystem.getIRODSAccessObjectFactory().getDataObjectAO(irodsAccount);
CollectionAO collectionAO = irodsFileSystem.getIRODSAccessObjectFactory().getCollectionAO(irodsAccount);
File localFile = new File(localCollectionAbsolutePath);
dataTransferOperationsAO.putOperation(localFile, destFile, null, null);
// Decorate with various AVUs to use in tests
decorateChildren(destFile, collectionAO, dataObjectAO);
}
use of org.irods.jargon.core.pub.DataObjectAO in project metalnx-web by irods-contrib.
the class UserServiceImpl method updateWritePermissions.
@Override
public boolean updateWritePermissions(DataGridUser user, Map<String, Boolean> addCollectionsToWrite, Map<String, Boolean> removeCollectionsToWrite) throws DataGridConnectionRefusedException {
CollectionAO collectionAO = null;
DataObjectAO dataObjectAO = null;
IRODSFile irodsFile = null;
IRODSFileFactory irodsFileFactory = null;
boolean writePermissionsUpdated = false;
try {
collectionAO = irodsServices.getCollectionAO();
dataObjectAO = irodsServices.getDataObjectAO();
irodsFileFactory = irodsServices.getIRODSFileFactory();
for (String path : addCollectionsToWrite.keySet()) {
irodsFile = irodsFileFactory.instanceIRODSFile(path);
if (irodsFile.isDirectory()) {
collectionAO.setAccessPermissionWriteAsAdmin(user.getAdditionalInfo(), path, user.getUsername(), addCollectionsToWrite.get(path));
} else {
dataObjectAO.setAccessPermissionWriteInAdminMode(user.getAdditionalInfo(), path, user.getUsername());
}
}
removeAccessPermissionForUserAsAdmin(user, removeCollectionsToWrite);
writePermissionsUpdated = true;
} catch (JargonException e) {
logger.error("Could not set write permission:", e);
}
return writePermissionsUpdated;
}
use of org.irods.jargon.core.pub.DataObjectAO in project metalnx-web by irods-contrib.
the class UserServiceImpl method updateOwnership.
@Override
public boolean updateOwnership(DataGridUser user, Map<String, Boolean> addCollectionsToOwn, Map<String, Boolean> removeCollectionsToOwn) throws DataGridConnectionRefusedException {
CollectionAO collectionAO = null;
DataObjectAO dataObjectAO = null;
IRODSFile irodsFile = null;
IRODSFileFactory irodsFileFactory = null;
boolean ownPermissionsUpdated = false;
try {
collectionAO = irodsServices.getCollectionAO();
dataObjectAO = irodsServices.getDataObjectAO();
irodsFileFactory = irodsServices.getIRODSFileFactory();
for (String path : addCollectionsToOwn.keySet()) {
irodsFile = irodsFileFactory.instanceIRODSFile(path);
if (irodsFile.isDirectory()) {
collectionAO.setAccessPermissionOwnAsAdmin(user.getAdditionalInfo(), path, user.getUsername(), addCollectionsToOwn.get(path));
} else {
dataObjectAO.setAccessPermissionOwnInAdminMode(user.getAdditionalInfo(), path, user.getUsername());
}
}
removeAccessPermissionForUserAsAdmin(user, removeCollectionsToOwn);
ownPermissionsUpdated = true;
} catch (JargonException e) {
logger.error("Could not set ownership permission:", e);
}
return ownPermissionsUpdated;
}
Aggregations