Search in sources :

Example 6 with IRODSFile

use of org.irods.jargon.core.pub.io.IRODSFile 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 7 with IRODSFile

use of org.irods.jargon.core.pub.io.IRODSFile 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 8 with IRODSFile

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

the class TestDownloadWithTicket method uploadFileToIRODS.

private void uploadFileToIRODS(String path, File file) throws DataGridConnectionRefusedException, JargonException, IOException {
    IRODSFile targetFile = irodsServices.getIRODSFileFactory().instanceIRODSFile(path, file.getName());
    if (targetFile.exists()) {
        return;
    }
    Stream2StreamAO streamAO = irodsServices.getStream2StreamAO();
    InputStream inputStream = new FileInputStream(file);
    streamAO.transferStreamToFileUsingIOStreams(inputStream, (File) targetFile, 0, BUFFER_SIZE);
    inputStream.close();
    targetFile.close();
}
Also used : Stream2StreamAO(org.irods.jargon.core.pub.Stream2StreamAO) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) IRODSFile(org.irods.jargon.core.pub.io.IRODSFile) FileInputStream(java.io.FileInputStream)

Example 9 with IRODSFile

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

the class TestRuleDeploymentService method createRuleCacheColl.

/**
 * Create the rule cache collection in the grid
 * @throws DataGridConnectionRefusedException
 * @throws JargonException
 */
private void createRuleCacheColl() throws DataGridConnectionRefusedException, JargonException {
    IRODSFileFactory iff = irodsServices.getIRODSFileFactory();
    IRODSFile ruleCacheColl = iff.instanceIRODSFile("/" + configService.getIrodsZone(), RULE_CACHE_DIR);
    irodsServices.getIRODSFileSystemAO().mkdir(ruleCacheColl, false);
}
Also used : IRODSFileFactory(org.irods.jargon.core.pub.io.IRODSFileFactory) IRODSFile(org.irods.jargon.core.pub.io.IRODSFile)

Example 10 with IRODSFile

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

the class PermissionsServiceImpl method setPermissionOnPath.

@Override
public boolean setPermissionOnPath(DataGridPermType permType, String uName, boolean recursive, boolean inAdminMode, String... paths) throws DataGridConnectionRefusedException {
    logger.info("Setting {} permission on path {} for user/group {}", permType, paths, uName);
    boolean operationResult = true;
    for (String path : paths) {
        try {
            IRODSFile irodsFile = irodsServices.getIRODSFileFactory().instanceIRODSFile(path);
            if (irodsFile.isDirectory()) {
                operationResult = chmodCollection(permType, path, recursive, uName, inAdminMode);
            } else {
                operationResult = chmodDataObject(permType, path, uName, inAdminMode);
            }
            // If the permissions is NONE, remove all bookmarks associated to the group and the path
            if (permType.equals(DataGridPermType.NONE)) {
                DataGridGroup group = groupDao.findByGroupnameAndZone(uName, irodsServices.getCurrentUserZone());
                if (group != null)
                    groupBookmarkDao.removeByGroupAndPath(group, path);
            }
            logger.info("Permission {} for user {} on path {} set successfully", permType, uName, paths);
        } catch (JargonException e) {
            logger.error("Could not set {} permission on path {} for user/group {}", permType, path, uName, e);
            operationResult = false;
        }
    }
    return operationResult;
}
Also used : JargonException(org.irods.jargon.core.exception.JargonException) IRODSFile(org.irods.jargon.core.pub.io.IRODSFile)

Aggregations

IRODSFile (org.irods.jargon.core.pub.io.IRODSFile)28 IRODSFileFactory (org.irods.jargon.core.pub.io.IRODSFileFactory)23 JargonException (org.irods.jargon.core.exception.JargonException)19 CollectionAO (org.irods.jargon.core.pub.CollectionAO)7 IRODSFileSystemAO (org.irods.jargon.core.pub.IRODSFileSystemAO)7 DataGridException (com.emc.metalnx.core.domain.exceptions.DataGridException)6 DataObjectAO (org.irods.jargon.core.pub.DataObjectAO)6 DataGridConnectionRefusedException (com.emc.metalnx.core.domain.exceptions.DataGridConnectionRefusedException)4 File (java.io.File)4 IOException (java.io.IOException)4 DataTransferOperations (org.irods.jargon.core.pub.DataTransferOperations)4 InputStream (java.io.InputStream)3 Stream2StreamAO (org.irods.jargon.core.pub.Stream2StreamAO)3 DataGridChecksumException (com.emc.metalnx.core.domain.exceptions.DataGridChecksumException)2 DataGridTicketInvalidUserException (com.emc.metalnx.core.domain.exceptions.DataGridTicketInvalidUserException)2 IRODSAccount (org.irods.jargon.core.connection.IRODSAccount)2 IRODSFileInputStream (org.irods.jargon.core.pub.io.IRODSFileInputStream)2 IRODSTestSetupUtilities (org.irods.jargon.testutils.IRODSTestSetupUtilities)2 TestingPropertiesHelper (org.irods.jargon.testutils.TestingPropertiesHelper)2 ScratchFileUtils (org.irods.jargon.testutils.filemanip.ScratchFileUtils)2