Search in sources :

Example 6 with CollectionAO

use of org.irods.jargon.core.pub.CollectionAO in project metalnx-web by irods-contrib.

the class CollectionServiceImpl method getInheritanceOptionForCollection.

@Override
public boolean getInheritanceOptionForCollection(String collPath) throws DataGridConnectionRefusedException, JargonException {
    logger.info("getInheritanceOptionForCollection()");
    if (collPath == null || collPath.isEmpty()) {
        throw new IllegalArgumentException("null or empty collPath");
    }
    logger.info("collPath:{}", collPath);
    CollectionAO collectionAO = irodsServices.getCollectionAO();
    try {
        return collectionAO.isCollectionSetForPermissionInheritance(collPath);
    } catch (FileNotFoundException e) {
        logger.warn("Collection {} does not exist: {}", collPath, e.getMessage());
    } catch (JargonException e) {
        logger.error("Could not retrieve inheritance option value for", collPath, e.getMessage());
        throw e;
    }
    return false;
}
Also used : CollectionAO(org.irods.jargon.core.pub.CollectionAO) JargonException(org.irods.jargon.core.exception.JargonException) FileNotFoundException(org.irods.jargon.core.exception.FileNotFoundException)

Example 7 with CollectionAO

use of org.irods.jargon.core.pub.CollectionAO in project metalnx-web by irods-contrib.

the class CollectionServiceImpl method listWritePermissionsForPathAndGroupRecursive.

@Override
public Set<String> listWritePermissionsForPathAndGroupRecursive(String path, String groupName) throws DataGridConnectionRefusedException, JargonException {
    logger.info("listWritePermissionsForPathAndGroupRecursive()");
    CollectionAO collectionAO = irodsServices.getCollectionAO();
    List<DataGridCollectionAndDataObject> children = getSubCollectionsAndDataObjectsUnderPath(path);
    Set<String> list = new HashSet<String>();
    for (DataGridCollectionAndDataObject child : children) {
        try {
            if (collectionAO.getPermissionForUserName(child.getPath(), groupName) != null) {
                list.add(child.getPath());
            } else {
                if (listWritePermissionsForPathAndGroupRecursive(child.getPath(), groupName).isEmpty()) {
                    list.add(child.getPath());
                }
            }
        } catch (JargonException e) {
            logger.error("Could not list write permissions for path " + path + "and group: " + groupName, e);
        }
    }
    return list;
}
Also used : CollectionAO(org.irods.jargon.core.pub.CollectionAO) JargonException(org.irods.jargon.core.exception.JargonException) DataGridCollectionAndDataObject(com.emc.metalnx.core.domain.entity.DataGridCollectionAndDataObject) HashSet(java.util.HashSet)

Example 8 with CollectionAO

use of org.irods.jargon.core.pub.CollectionAO in project metalnx-web by irods-contrib.

the class UserServiceImpl method updateReadPermissions.

@Override
public boolean updateReadPermissions(DataGridUser user, Map<String, Boolean> addCollectionsToRead, Map<String, Boolean> removeCollectionsToRead) throws DataGridConnectionRefusedException {
    CollectionAO collectionAO = null;
    DataObjectAO dataObjectAO = null;
    IRODSFile irodsFile = null;
    IRODSFileFactory irodsFileFactory = null;
    boolean readPermissionsUpdated = false;
    try {
        collectionAO = irodsServices.getCollectionAO();
        dataObjectAO = irodsServices.getDataObjectAO();
        irodsFileFactory = irodsServices.getIRODSFileFactory();
        for (String path : addCollectionsToRead.keySet()) {
            irodsFile = irodsFileFactory.instanceIRODSFile(path);
            if (irodsFile.isDirectory()) {
                // applying read permissions on a collection (not recursively)
                collectionAO.setAccessPermissionReadAsAdmin(user.getAdditionalInfo(), path, user.getUsername(), addCollectionsToRead.get(path));
            } else {
                // applying read permissions on a data object
                dataObjectAO.setAccessPermissionReadInAdminMode(user.getAdditionalInfo(), path, user.getUsername());
            }
        }
        removeAccessPermissionForUserAsAdmin(user, removeCollectionsToRead);
        readPermissionsUpdated = true;
    } catch (JargonException e) {
        logger.error("Could not set read permission:", e);
    }
    return readPermissionsUpdated;
}
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 9 with CollectionAO

use of org.irods.jargon.core.pub.CollectionAO in project metalnx-web by irods-contrib.

the class UserServiceImpl method removeAccessPermissionForUserAsAdmin.

@Override
public void removeAccessPermissionForUserAsAdmin(DataGridUser user, Map<String, Boolean> paths) throws JargonException, DataGridConnectionRefusedException {
    if (paths == null || paths.isEmpty()) {
        return;
    }
    IRODSFileFactory irodsFileFactory = irodsServices.getIRODSFileFactory();
    CollectionAO collectionAO = irodsServices.getCollectionAO();
    DataObjectAO dataObjectAO = irodsServices.getDataObjectAO();
    IRODSFile irodsFile = null;
    for (String path : paths.keySet()) {
        irodsFile = irodsFileFactory.instanceIRODSFile(path);
        if (irodsFile.isDirectory()) {
            collectionAO.removeAccessPermissionForUserAsAdmin(user.getAdditionalInfo(), path, user.getUsername(), paths.get(path));
        } else {
            dataObjectAO.removeAccessPermissionsForUserInAdminMode(user.getAdditionalInfo(), path, user.getUsername());
        }
    }
}
Also used : IRODSFileFactory(org.irods.jargon.core.pub.io.IRODSFileFactory) CollectionAO(org.irods.jargon.core.pub.CollectionAO) DataObjectAO(org.irods.jargon.core.pub.DataObjectAO) IRODSFile(org.irods.jargon.core.pub.io.IRODSFile)

Example 10 with CollectionAO

use of org.irods.jargon.core.pub.CollectionAO in project metalnx-web by irods-contrib.

the class FilePropertyServiceImpl method populateVisibilityForCurrentUser.

private void populateVisibilityForCurrentUser(List<DataGridCollectionAndDataObject> objectList) throws DataGridConnectionRefusedException {
    CollectionAO collectionAO = irodsServices.getCollectionAO();
    DataObjectAO dataObjectAO = irodsServices.getDataObjectAO();
    String currentUser = getLoggedDataGridUser().getUsername();
    for (DataGridCollectionAndDataObject obj : objectList) {
        List<UserFilePermission> permissions = null;
        try {
            if (obj.isCollection()) {
                permissions = collectionAO.listPermissionsForCollection(obj.getPath());
            } else {
                permissions = dataObjectAO.listPermissionsForDataObject(obj.getPath());
            }
        } catch (JargonException e) {
            logger.error("Could not get permission list for object {}", obj.getPath(), e);
        }
        obj.setVisibleToCurrentUser(false);
        if (permissions != null) {
            for (UserFilePermission permission : permissions) {
                if (permission.getUserName().compareTo(currentUser) == 0) {
                    obj.setVisibleToCurrentUser(true);
                    break;
                }
            }
        }
    }
}
Also used : UserFilePermission(org.irods.jargon.core.pub.domain.UserFilePermission) CollectionAO(org.irods.jargon.core.pub.CollectionAO) JargonException(org.irods.jargon.core.exception.JargonException) DataGridCollectionAndDataObject(com.emc.metalnx.core.domain.entity.DataGridCollectionAndDataObject) DataObjectAO(org.irods.jargon.core.pub.DataObjectAO)

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