Search in sources :

Example 16 with CollectionAO

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;
}
Also used : IRODSFileFactory(org.irods.jargon.core.pub.io.IRODSFileFactory) CollectionAO(org.irods.jargon.core.pub.CollectionAO) DataGridException(com.emc.metalnx.core.domain.exceptions.DataGridException) JargonException(org.irods.jargon.core.exception.JargonException) IRODSFileSystemAO(org.irods.jargon.core.pub.IRODSFileSystemAO) IRODSFile(org.irods.jargon.core.pub.io.IRODSFile)

Example 17 with CollectionAO

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;
}
Also used : CollectionAO(org.irods.jargon.core.pub.CollectionAO) JargonException(org.irods.jargon.core.exception.JargonException)

Example 18 with CollectionAO

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;
}
Also used : CollectionAO(org.irods.jargon.core.pub.CollectionAO) DataGridException(com.emc.metalnx.core.domain.exceptions.DataGridException) JargonException(org.irods.jargon.core.exception.JargonException) DataObjectAO(org.irods.jargon.core.pub.DataObjectAO)

Example 19 with CollectionAO

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;
}
Also used : CollectionAO(org.irods.jargon.core.pub.CollectionAO) JargonException(org.irods.jargon.core.exception.JargonException) FilePermissionEnum(org.irods.jargon.core.protovalues.FilePermissionEnum)

Example 20 with CollectionAO

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);
}
Also used : IRODSFileFactory(org.irods.jargon.core.pub.io.IRODSFileFactory) IRODSTestSetupUtilities(org.irods.jargon.testutils.IRODSTestSetupUtilities) CollectionAO(org.irods.jargon.core.pub.CollectionAO) DataTransferOperations(org.irods.jargon.core.pub.DataTransferOperations) IRODSAccount(org.irods.jargon.core.connection.IRODSAccount) DataObjectAO(org.irods.jargon.core.pub.DataObjectAO) IRODSFile(org.irods.jargon.core.pub.io.IRODSFile) IRODSFile(org.irods.jargon.core.pub.io.IRODSFile) File(java.io.File) TestingPropertiesHelper(org.irods.jargon.testutils.TestingPropertiesHelper) ScratchFileUtils(org.irods.jargon.testutils.filemanip.ScratchFileUtils) BeforeClass(org.junit.BeforeClass)

Aggregations

CollectionAO (org.irods.jargon.core.pub.CollectionAO)22 JargonException (org.irods.jargon.core.exception.JargonException)20 DataObjectAO (org.irods.jargon.core.pub.DataObjectAO)14 DataGridCollectionAndDataObject (com.emc.metalnx.core.domain.entity.DataGridCollectionAndDataObject)7 IRODSFile (org.irods.jargon.core.pub.io.IRODSFile)7 IRODSFileFactory (org.irods.jargon.core.pub.io.IRODSFileFactory)7 CollectionAndDataObjectListAndSearchAO (org.irods.jargon.core.pub.CollectionAndDataObjectListAndSearchAO)5 DataObject (org.irods.jargon.core.pub.domain.DataObject)5 DataGridException (com.emc.metalnx.core.domain.exceptions.DataGridException)4 HashSet (java.util.HashSet)3 AvuData (org.irods.jargon.core.pub.domain.AvuData)3 FileNotFoundException (org.irods.jargon.core.exception.FileNotFoundException)2 FilePermissionEnum (org.irods.jargon.core.protovalues.FilePermissionEnum)2 IRODSFileSystemAO (org.irods.jargon.core.pub.IRODSFileSystemAO)2 DataGridMetadata (com.emc.metalnx.core.domain.entity.DataGridMetadata)1 IconObject (com.emc.metalnx.core.domain.entity.IconObject)1 File (java.io.File)1 ArrayList (java.util.ArrayList)1 IRODSAccount (org.irods.jargon.core.connection.IRODSAccount)1 DataTransferOperations (org.irods.jargon.core.pub.DataTransferOperations)1