Search in sources :

Example 1 with FilePermissionEnum

use of org.irods.jargon.core.protovalues.FilePermissionEnum in project metalnx-web by irods-contrib.

the class CollectionServiceImpl method getPermissionsForPath.

@Override
public String getPermissionsForPath(String path) throws DataGridConnectionRefusedException {
    logger.info("getPermissionsForPath()");
    FilePermissionEnum filePermissionEnum = null;
    String permissionType = "none";
    try {
        String user = irodsServices.getCurrentUser();
        String zone = irodsServices.getCurrentUserZone();
        Object obj = irodsServices.getCollectionAndDataObjectListAndSearchAO().getFullObjectForType(path);
        if (obj instanceof Collection) {
            CollectionAO collectionAO = irodsServices.getCollectionAO();
            filePermissionEnum = collectionAO.getPermissionForCollection(path, user, zone);
        } else {
            DataObjectAO dataObjectAO = irodsServices.getDataObjectAO();
            filePermissionEnum = dataObjectAO.getPermissionForDataObject(path, user, zone);
        }
        if (filePermissionEnum != null) {
            permissionType = filePermissionEnum.toString().toLowerCase();
        }
    } catch (FileNotFoundException e) {
        logger.error("Could not find path: {}", e.getMessage());
    } catch (JargonException e) {
        logger.error("Could not get permission for path: {}", e.getMessage());
    }
    return permissionType;
}
Also used : CollectionAO(org.irods.jargon.core.pub.CollectionAO) JargonException(org.irods.jargon.core.exception.JargonException) FileNotFoundException(org.irods.jargon.core.exception.FileNotFoundException) Collection(org.irods.jargon.core.pub.domain.Collection) IconObject(com.emc.metalnx.core.domain.entity.IconObject) DataGridCollectionAndDataObject(com.emc.metalnx.core.domain.entity.DataGridCollectionAndDataObject) IRODSDomainObject(org.irods.jargon.core.pub.domain.IRODSDomainObject) DataObject(org.irods.jargon.core.pub.domain.DataObject) DataObjectAO(org.irods.jargon.core.pub.DataObjectAO) FilePermissionEnum(org.irods.jargon.core.protovalues.FilePermissionEnum)

Example 2 with FilePermissionEnum

use of org.irods.jargon.core.protovalues.FilePermissionEnum 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 3 with FilePermissionEnum

use of org.irods.jargon.core.protovalues.FilePermissionEnum 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)

Aggregations

JargonException (org.irods.jargon.core.exception.JargonException)3 FilePermissionEnum (org.irods.jargon.core.protovalues.FilePermissionEnum)3 CollectionAO (org.irods.jargon.core.pub.CollectionAO)2 DataObjectAO (org.irods.jargon.core.pub.DataObjectAO)2 DataGridCollectionAndDataObject (com.emc.metalnx.core.domain.entity.DataGridCollectionAndDataObject)1 IconObject (com.emc.metalnx.core.domain.entity.IconObject)1 FileNotFoundException (org.irods.jargon.core.exception.FileNotFoundException)1 Collection (org.irods.jargon.core.pub.domain.Collection)1 DataObject (org.irods.jargon.core.pub.domain.DataObject)1 IRODSDomainObject (org.irods.jargon.core.pub.domain.IRODSDomainObject)1