Search in sources :

Example 16 with DataObjectAO

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;
}
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 17 with DataObjectAO

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

Example 18 with DataObjectAO

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);
}
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)

Example 19 with 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;
}
Also used : IRODSFileFactory(org.irods.jargon.core.pub.io.IRODSFileFactory) CollectionAO(org.irods.jargon.core.pub.CollectionAO) JargonException(org.irods.jargon.core.exception.JargonException) DataObjectAO(org.irods.jargon.core.pub.DataObjectAO) IRODSFile(org.irods.jargon.core.pub.io.IRODSFile)

Example 20 with DataObjectAO

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

Aggregations

DataObjectAO (org.irods.jargon.core.pub.DataObjectAO)20 JargonException (org.irods.jargon.core.exception.JargonException)18 CollectionAO (org.irods.jargon.core.pub.CollectionAO)14 DataGridCollectionAndDataObject (com.emc.metalnx.core.domain.entity.DataGridCollectionAndDataObject)9 DataObject (org.irods.jargon.core.pub.domain.DataObject)8 IRODSFile (org.irods.jargon.core.pub.io.IRODSFile)6 IRODSFileFactory (org.irods.jargon.core.pub.io.IRODSFileFactory)6 DataGridException (com.emc.metalnx.core.domain.exceptions.DataGridException)4 CollectionAndDataObjectListAndSearchAO (org.irods.jargon.core.pub.CollectionAndDataObjectListAndSearchAO)4 AvuData (org.irods.jargon.core.pub.domain.AvuData)3 FilePermissionEnum (org.irods.jargon.core.protovalues.FilePermissionEnum)2 DataGridMetadata (com.emc.metalnx.core.domain.entity.DataGridMetadata)1 DataGridResource (com.emc.metalnx.core.domain.entity.DataGridResource)1 IconObject (com.emc.metalnx.core.domain.entity.IconObject)1 DataGridChecksumException (com.emc.metalnx.core.domain.exceptions.DataGridChecksumException)1 File (java.io.File)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 IRODSAccount (org.irods.jargon.core.connection.IRODSAccount)1