use of org.irods.jargon.core.pub.CollectionAO in project metalnx-web by irods-contrib.
the class CollectionServiceImpl method createCollection.
@Override
public boolean createCollection(DataGridCollectionAndDataObject collection) throws DataGridException {
logger.info("createCollection()");
boolean collCreated;
try {
IRODSFileSystemAO irodsFileSystemAO = irodsServices.getIRODSFileSystemAO();
IRODSFileFactory irodsFileFactory = irodsServices.getIRODSFileFactory();
IRODSFile newFile = irodsFileFactory.instanceIRODSFile(collection.getParentPath(), collection.getName());
irodsFileSystemAO.mkdir(newFile, false);
// Updating inheritance option on the collection, if needed
CollectionAO collectionAO = irodsServices.getCollectionAO();
String zoneName = irodsFileSystemAO.getIRODSServerProperties().getRodsZone();
// enable inheritance for this collection
if (collection.isInheritanceOption()) {
collectionAO.setAccessPermissionInherit(zoneName, collection.getPath(), false);
} else // disable inheritance for this collection
if ("own".equals(getPermissionsForPath(collection.getParentPath()))) {
collectionAO.setAccessPermissionToNotInherit(zoneName, collection.getPath(), false);
}
collCreated = true;
} catch (JargonException e) {
logger.debug("Could not create a collection in the data grid: {}", e.getMessage());
throw new DataGridException(e.getMessage());
}
return collCreated;
}
use of org.irods.jargon.core.pub.CollectionAO in project metalnx-web by irods-contrib.
the class CollectionServiceImpl method updateInheritanceOptions.
@Override
public boolean updateInheritanceOptions(Map<String, Boolean> toAdd, Map<String, Boolean> toRemove, String zoneName) throws DataGridConnectionRefusedException {
logger.info("updateInheritanceOptions()");
CollectionAO collectionAO = irodsServices.getCollectionAO();
try {
for (String addColl : toAdd.keySet()) {
collectionAO.setAccessPermissionInheritAsAdmin(zoneName, addColl, toAdd.get(addColl));
}
for (String removeColl : toRemove.keySet()) {
collectionAO.setAccessPermissionToNotInheritInAdminMode(zoneName, removeColl, toRemove.get(removeColl));
}
return true;
} catch (JargonException e) {
logger.error("Could not set inheritance: ", e);
}
return false;
}
use of org.irods.jargon.core.pub.CollectionAO 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.CollectionAO 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.pub.CollectionAO 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);
}
Aggregations