Search in sources :

Example 1 with Collection

use of org.irods.jargon.core.pub.domain.Collection 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 Collection

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

the class PermissionsServiceImpl method getFilePermissionListForObject.

/**
 * Gets the list of file permissions on the requested object for a particular user. The object
 * can be a collection as a single data object.
 *
 * @param path     the path to the object
 * @param username user name to get the permissions on the given path. If no user name is required,
 *                 an empty String or null should be provided
 * @return list of {@link UserFilePermission}
 * @throws FileNotFoundException
 * @throws JargonException
 * @throws DataGridConnectionRefusedException
 */
private List<UserFilePermission> getFilePermissionListForObject(String path, String username) throws DataGridConnectionRefusedException, JargonException {
    Object obj = irodsServices.getCollectionAndDataObjectListAndSearchAO().getFullObjectForType(path);
    List<UserFilePermission> filePermissionList = new ArrayList<UserFilePermission>();
    List<UserFilePermission> dataGridfilePermissionList = null;
    // If the object is a collection
    if (obj instanceof Collection) {
        logger.debug("Getting permission info for collection {}", path);
        dataGridfilePermissionList = irodsServices.getCollectionAO().listPermissionsForCollection(path);
    } else // If the object is a data object
    {
        logger.debug("Getting permission info for data object {}", path);
        dataGridfilePermissionList = irodsServices.getDataObjectAO().listPermissionsForDataObject(path);
    }
    // as the parameter
    if (username != null && !username.isEmpty()) {
        for (UserFilePermission userFilePermission : dataGridfilePermissionList) {
            if (userFilePermission.getUserName().equalsIgnoreCase(username)) {
                filePermissionList.add(userFilePermission);
            }
        }
    } else {
        filePermissionList = dataGridfilePermissionList;
    }
    return filePermissionList;
}
Also used : UserFilePermission(org.irods.jargon.core.pub.domain.UserFilePermission) Collection(org.irods.jargon.core.pub.domain.Collection)

Aggregations

Collection (org.irods.jargon.core.pub.domain.Collection)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 JargonException (org.irods.jargon.core.exception.JargonException)1 FilePermissionEnum (org.irods.jargon.core.protovalues.FilePermissionEnum)1 CollectionAO (org.irods.jargon.core.pub.CollectionAO)1 DataObjectAO (org.irods.jargon.core.pub.DataObjectAO)1 DataObject (org.irods.jargon.core.pub.domain.DataObject)1 IRODSDomainObject (org.irods.jargon.core.pub.domain.IRODSDomainObject)1 UserFilePermission (org.irods.jargon.core.pub.domain.UserFilePermission)1