Search in sources :

Example 21 with JargonException

use of org.irods.jargon.core.exception.JargonException in project metalnx-web by irods-contrib.

the class FileOperationServiceImpl method computeChecksum.

@Override
public void computeChecksum(String path, String filename) throws DataGridChecksumException, DataGridConnectionRefusedException {
    if (path == null || path.isEmpty() || filename == null || filename.isEmpty())
        throw new DataGridChecksumException("Could not calculate checksum. File path is invalid.");
    logger.info("Computing checksum for {} ({})", filename, path);
    IRODSFileFactory irodsFileFactory = irodsServices.getIRODSFileFactory();
    DataObjectAO dataObjectAO = irodsServices.getDataObjectAO();
    IRODSFile file;
    try {
        file = irodsFileFactory.instanceIRODSFile(path, filename);
        dataObjectAO.computeMD5ChecksumOnDataObject(file);
    } catch (JargonException e) {
        logger.error("Could not calculate checksum: {}", e.getMessage());
        throw new DataGridChecksumException("Could not calculate checksum.");
    }
}
Also used : IRODSFileFactory(org.irods.jargon.core.pub.io.IRODSFileFactory) JargonException(org.irods.jargon.core.exception.JargonException) DataGridChecksumException(com.emc.metalnx.core.domain.exceptions.DataGridChecksumException) DataObjectAO(org.irods.jargon.core.pub.DataObjectAO) IRODSFile(org.irods.jargon.core.pub.io.IRODSFile)

Example 22 with JargonException

use of org.irods.jargon.core.exception.JargonException in project metalnx-web by irods-contrib.

the class FileOperationServiceImpl method copy.

@Override
public boolean copy(String sourcePath, String dstPath, boolean copyWithMetadata) throws DataGridConnectionRefusedException {
    IRODSFileFactory irodsFileFactory = irodsServices.getIRODSFileFactory();
    DataTransferOperations dataTransferOperations = irodsServices.getDataTransferOperations();
    boolean isCopied = false;
    try {
        IRODSFile source = irodsFileFactory.instanceIRODSFile(sourcePath);
        IRODSFile target = irodsFileFactory.instanceIRODSFile(dstPath);
        dataTransferOperations.copy(source, target, null, null);
        isCopied = true;
        if (copyWithMetadata) {
            String objName = sourcePath.substring(sourcePath.lastIndexOf("/") + 1, sourcePath.length());
            dstPath = String.format("%s/%s", dstPath, objName);
            metadataService.copyMetadata(sourcePath, dstPath);
        }
    } catch (JargonException e) {
        logger.error("Could not copy item from " + sourcePath + " to " + dstPath + ": ", e.getMessage());
    }
    return isCopied;
}
Also used : IRODSFileFactory(org.irods.jargon.core.pub.io.IRODSFileFactory) DataTransferOperations(org.irods.jargon.core.pub.DataTransferOperations) JargonException(org.irods.jargon.core.exception.JargonException) IRODSFile(org.irods.jargon.core.pub.io.IRODSFile)

Example 23 with JargonException

use of org.irods.jargon.core.exception.JargonException in project metalnx-web by irods-contrib.

the class FileOperationServiceImpl method move.

@Override
public boolean move(String sourcePath, String targetPath) throws DataGridConnectionRefusedException {
    IRODSFileFactory irodsFileFactory = irodsServices.getIRODSFileFactory();
    DataTransferOperations dataTransferOperations = irodsServices.getDataTransferOperations();
    try {
        IRODSFile source = irodsFileFactory.instanceIRODSFile(sourcePath);
        if (source.isDirectory()) {
            targetPath += "/" + FilenameUtils.getBaseName(sourcePath);
        }
        IRODSFile target = irodsFileFactory.instanceIRODSFile(targetPath);
        dataTransferOperations.move(source, target);
        return true;
    } catch (JargonException e) {
        logger.error("Could not move item from " + sourcePath + " to " + targetPath + ": ", e.getMessage());
    }
    return false;
}
Also used : IRODSFileFactory(org.irods.jargon.core.pub.io.IRODSFileFactory) DataTransferOperations(org.irods.jargon.core.pub.DataTransferOperations) JargonException(org.irods.jargon.core.exception.JargonException) IRODSFile(org.irods.jargon.core.pub.io.IRODSFile)

Example 24 with JargonException

use of org.irods.jargon.core.exception.JargonException 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 25 with JargonException

use of org.irods.jargon.core.exception.JargonException in project metalnx-web by irods-contrib.

the class UserServiceImpl method getGroupIdsForUser.

@Override
public String[] getGroupIdsForUser(DataGridUser user) throws DataGridConnectionRefusedException {
    UserGroupAO userGroupAO = irodsServices.getGroupAO();
    try {
        // Getting list of groups the user belongs to.
        List<UserGroup> groups = userGroupAO.findUserGroupsForUser(user.getUsername());
        // Building Data Grid IDs list
        String[] ids = new String[groups.size()];
        for (int i = 0; i < groups.size(); i++) {
            ids[i] = groups.get(i).getUserGroupId();
        }
        // Returning results
        return ids;
    } catch (JargonException e) {
        logger.error("Could not find group list for user [" + user.getUsername() + "], ", e);
    }
    // If something goes wrong, return empty list.
    return new String[0];
}
Also used : JargonException(org.irods.jargon.core.exception.JargonException) UserGroupAO(org.irods.jargon.core.pub.UserGroupAO) UserGroup(org.irods.jargon.core.pub.domain.UserGroup)

Aggregations

JargonException (org.irods.jargon.core.exception.JargonException)86 DataGridCollectionAndDataObject (com.emc.metalnx.core.domain.entity.DataGridCollectionAndDataObject)20 CollectionAO (org.irods.jargon.core.pub.CollectionAO)20 DataGridException (com.emc.metalnx.core.domain.exceptions.DataGridException)18 DataObjectAO (org.irods.jargon.core.pub.DataObjectAO)18 IRODSFile (org.irods.jargon.core.pub.io.IRODSFile)17 IRODSFileFactory (org.irods.jargon.core.pub.io.IRODSFileFactory)15 ArrayList (java.util.ArrayList)12 SpecificQueryAO (org.irods.jargon.core.pub.SpecificQueryAO)12 DataGridConnectionRefusedException (com.emc.metalnx.core.domain.exceptions.DataGridConnectionRefusedException)11 CollectionAndDataObjectListAndSearchAO (org.irods.jargon.core.pub.CollectionAndDataObjectListAndSearchAO)10 SpecificQueryDefinition (org.irods.jargon.core.pub.domain.SpecificQueryDefinition)10 SpecificQueryResultSet (org.irods.jargon.core.query.SpecificQueryResultSet)9 UnsupportedDataGridFeatureException (com.emc.metalnx.core.domain.exceptions.UnsupportedDataGridFeatureException)8 SpecificQueryProvider (com.emc.metalnx.services.irods.utils.SpecificQueryProvider)8 ClientHints (org.irods.jargon.core.pub.domain.ClientHints)8 DataObject (org.irods.jargon.core.pub.domain.DataObject)8 CollectionAndDataObjectListingEntry (org.irods.jargon.core.query.CollectionAndDataObjectListingEntry)8 SpecificQuery (org.irods.jargon.core.query.SpecificQuery)8 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)8