Search in sources :

Example 76 with JargonException

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

the class IRODSServicesImpl method findIRodsVersion.

@Override
public String findIRodsVersion() throws DataGridConnectionRefusedException {
    String version = "";
    try {
        EnvironmentalInfoAO envInfoAO = irodsAccessObjectFactory.getEnvironmentalInfoAO(irodsAccount);
        IrodsVersion iv = envInfoAO.getIRODSServerPropertiesFromIRODSServer().getIrodsVersion();
        version = String.format("%s.%s.%s", iv.getMajorAsString(), iv.getMinorAsString(), iv.getPatchAsString());
    } catch (JargonException e) {
        logger.error("Could not find iRODS version: ", e);
        if (e.getCause() instanceof ConnectException) {
            throw new DataGridConnectionRefusedException(e.getMessage());
        }
    }
    return version;
}
Also used : EnvironmentalInfoAO(org.irods.jargon.core.pub.EnvironmentalInfoAO) DataGridConnectionRefusedException(com.emc.metalnx.core.domain.exceptions.DataGridConnectionRefusedException) JargonException(org.irods.jargon.core.exception.JargonException) IrodsVersion(org.irods.jargon.core.connection.IrodsVersion) ConnectException(java.net.ConnectException)

Example 77 with JargonException

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

the class IRODSServicesImpl method getTicketAdminService.

@Override
public TicketAdminService getTicketAdminService() throws DataGridConnectionRefusedException {
    TicketAdminService tas = null;
    try {
        TicketServiceFactory tsf = new TicketServiceFactoryImpl(irodsAccessObjectFactory);
        tas = tsf.instanceTicketAdminService(irodsAccount);
    } catch (JargonException e) {
        logger.error("Could not instantiate ticket admin service: ", e.getMessage());
        if (e.getCause() instanceof ConnectException) {
            throw new DataGridConnectionRefusedException(e.getMessage());
        }
    }
    return tas;
}
Also used : DataGridConnectionRefusedException(com.emc.metalnx.core.domain.exceptions.DataGridConnectionRefusedException) TicketServiceFactory(org.irods.jargon.ticket.TicketServiceFactory) TicketServiceFactoryImpl(org.irods.jargon.ticket.TicketServiceFactoryImpl) JargonException(org.irods.jargon.core.exception.JargonException) TicketAdminService(org.irods.jargon.ticket.TicketAdminService) ConnectException(java.net.ConnectException)

Example 78 with JargonException

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

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

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

the class PermissionsServiceImpl method resolveMostPermissiveAccessForUser.

@Override
public void resolveMostPermissiveAccessForUser(DataGridCollectionAndDataObject obj, DataGridUser user) throws DataGridException {
    if (obj == null || user == null)
        return;
    List<UserGroup> userGroups;
    List<UserFilePermission> acl;
    try {
        userGroups = irodsServices.getGroupAO().findUserGroupsForUser(user.getUsername());
        acl = getFilePermissionListForObject(obj.getPath());
    } catch (JargonException e) {
        throw new DataGridException();
    }
    // Building set containing group names for current user
    Set<String> userGroupsSet = new HashSet<>();
    for (UserGroup g : userGroups) {
        userGroupsSet.add(g.getUserGroupName());
    }
    // Instantiating comparison matrix for permissions
    List<String> permissions = new ArrayList<>();
    permissions.add("NONE");
    permissions.add("READ");
    permissions.add("WRITE");
    permissions.add("OWN");
    String resultingPermission = "NONE";
    for (UserFilePermission perm : acl) {
        String permUserName = perm.getUserName();
        // Checking if current permission is related to logged user
        if (permUserName.compareTo(user.getUsername()) == 0 || userGroupsSet.contains(permUserName)) {
            String permissionName = perm.getFilePermissionEnum().name();
            int userOrGroupPerm = permissions.indexOf(permissionName);
            int currentPermission = permissions.indexOf(resultingPermission);
            if (userOrGroupPerm > currentPermission) {
                resultingPermission = permissionName;
            }
        }
        if (resultingPermission.compareToIgnoreCase("OWN") == 0) {
            break;
        }
    }
    obj.setMostPermissiveAccessForCurrentUser(resultingPermission.toLowerCase());
}
Also used : UserFilePermission(org.irods.jargon.core.pub.domain.UserFilePermission) DataGridException(com.emc.metalnx.core.domain.exceptions.DataGridException) JargonException(org.irods.jargon.core.exception.JargonException) 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