Search in sources :

Example 6 with CollectionAndDataObjectListAndSearchAO

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

the class MetadataServiceImpl method delMetadataFromPath.

@Override
public boolean delMetadataFromPath(String path, String attribute, String value, String unit) throws DataGridConnectionRefusedException {
    CollectionAndDataObjectListAndSearchAO collectionAndDataObjectListAndSearchAO = irodsServices.getCollectionAndDataObjectListAndSearchAO();
    try {
        AvuData avuData = new AvuData(attribute, value, unit);
        Object obj = collectionAndDataObjectListAndSearchAO.getFullObjectForType(path);
        if (obj instanceof DataObject) {
            DataObjectAO dataObjectAO = irodsServices.getDataObjectAO();
            dataObjectAO.deleteAVUMetadata(path, avuData);
        } else {
            CollectionAO collectionAO = irodsServices.getCollectionAO();
            collectionAO.deleteAVUMetadata(path, avuData);
        }
    } catch (JargonException e) {
        logger.error("Error trying to delete metadata: " + e.toString());
        return false;
    }
    return true;
}
Also used : CollectionAndDataObjectListAndSearchAO(org.irods.jargon.core.pub.CollectionAndDataObjectListAndSearchAO) DataGridCollectionAndDataObject(com.emc.metalnx.core.domain.entity.DataGridCollectionAndDataObject) DataObject(org.irods.jargon.core.pub.domain.DataObject) CollectionAO(org.irods.jargon.core.pub.CollectionAO) JargonException(org.irods.jargon.core.exception.JargonException) AvuData(org.irods.jargon.core.pub.domain.AvuData) DataGridCollectionAndDataObject(com.emc.metalnx.core.domain.entity.DataGridCollectionAndDataObject) DataObject(org.irods.jargon.core.pub.domain.DataObject) DataObjectAO(org.irods.jargon.core.pub.DataObjectAO)

Example 7 with CollectionAndDataObjectListAndSearchAO

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

the class CollectionServiceImpl method listCollectionsWithPermissionsForEntity.

/**
 * Auxiliary method that filters the directories with the specified permission
 * level for the given entity, that can be an user or a group
 *
 * @param path
 *            The path for which we would like to list the objects with
 *            permissions
 * @param entityName
 *            The entity name
 * @param permissionType
 *            The permission stype
 * @param entityType
 *            The entity type that can be user or group
 * @return
 * @throws DataGridConnectionRefusedException
 */
private Set<String> listCollectionsWithPermissionsForEntity(String path, String entityName, FilePermissionEnum permissionType, String entityType) throws DataGridConnectionRefusedException {
    logger.info("listCollectionsWithPermissionsForEntity()");
    Set<String> collections = new HashSet<String>();
    CollectionAndDataObjectListAndSearchAO collectionAndDataObjectListAndSearchAO = irodsServices.getCollectionAndDataObjectListAndSearchAO();
    try {
        List<CollectionAndDataObjectListingEntry> collList = collectionAndDataObjectListAndSearchAO.listDataObjectsAndCollectionsUnderPath(path);
        logger.info("Getting permissions and bookmarks for path {}", path);
        for (CollectionAndDataObjectListingEntry collEntry : collList) {
            String filePath = "";
            if (collEntry.isCollection()) {
                filePath = collEntry.getPathOrName();
            } else {
                filePath = collEntry.getParentPath() + IRODS_PATH_SEPARATOR + collEntry.getPathOrName();
                if (collEntry.getParentPath().compareTo(IRODS_PATH_SEPARATOR) == 0) {
                    filePath = collEntry.getParentPath() + collEntry.getPathOrName();
                }
            }
            List<DataGridFilePermission> permissions = permissionsService.getPathPermissionDetails(filePath, entityName);
            // Deciding whether we should get permissions for users or groups
            if (entityType.compareTo("user") == 0) {
                // Filtering permissions for users
                List<DataGridUserPermission> userPermissions = permissionsService.getUsersWithPermissions(permissions);
                // Adding collections with permissions into the result list
                for (DataGridUserPermission dataGridUserPermission : userPermissions) {
                    if (dataGridUserPermission.getPermission().equalsIgnoreCase(permissionType.name())) {
                        collections.add(filePath);
                    }
                }
            } else {
                // Filtering permissions for groups
                List<DataGridGroupPermission> groupPermissions = permissionsService.getGroupsWithPermissions(permissions);
                // Adding collections with permissions into the result list
                for (DataGridGroupPermission dataGridGroupPermission : groupPermissions) {
                    if (dataGridGroupPermission.getPermission().equalsIgnoreCase(permissionType.name())) {
                        collections.add(filePath);
                    }
                }
            }
        }
    } catch (JargonException e) {
        logger.error("Could not get permissions: ", e);
    }
    return collections;
}
Also used : CollectionAndDataObjectListAndSearchAO(org.irods.jargon.core.pub.CollectionAndDataObjectListAndSearchAO) DataGridUserPermission(com.emc.metalnx.core.domain.entity.DataGridUserPermission) DataGridGroupPermission(com.emc.metalnx.core.domain.entity.DataGridGroupPermission) JargonException(org.irods.jargon.core.exception.JargonException) CollectionAndDataObjectListingEntry(org.irods.jargon.core.query.CollectionAndDataObjectListingEntry) DataGridFilePermission(com.emc.metalnx.core.domain.entity.DataGridFilePermission) HashSet(java.util.HashSet)

Example 8 with CollectionAndDataObjectListAndSearchAO

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

the class CollectionServiceImpl method getSubCollectionsUnderPath.

@Override
public List<DataGridCollectionAndDataObject> getSubCollectionsUnderPath(String parent) throws DataGridConnectionRefusedException {
    logger.info("getSubCollectionsUnderPath()");
    CollectionAndDataObjectListAndSearchAO collectionAndDataObjectListAndSearchAO = irodsServices.getCollectionAndDataObjectListAndSearchAO();
    List<DataGridCollectionAndDataObject> dataGridCollectionAndDataObjects = null;
    try {
        List<CollectionAndDataObjectListingEntry> collectionAndDataObjects = collectionAndDataObjectListAndSearchAO.listCollectionsUnderPath(parent, 0);
        dataGridCollectionAndDataObjects = this.mapListingEntryToDataGridCollectionAndDataObject(collectionAndDataObjects);
        return dataGridCollectionAndDataObjects;
    } catch (FileNotFoundException e) {
        logger.error("Could not locate file: ", e);
    } catch (JargonException e) {
        logger.error("Error: ", e);
    }
    return dataGridCollectionAndDataObjects;
}
Also used : CollectionAndDataObjectListAndSearchAO(org.irods.jargon.core.pub.CollectionAndDataObjectListAndSearchAO) JargonException(org.irods.jargon.core.exception.JargonException) DataGridCollectionAndDataObject(com.emc.metalnx.core.domain.entity.DataGridCollectionAndDataObject) FileNotFoundException(org.irods.jargon.core.exception.FileNotFoundException) CollectionAndDataObjectListingEntry(org.irods.jargon.core.query.CollectionAndDataObjectListingEntry)

Example 9 with CollectionAndDataObjectListAndSearchAO

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

the class CollectionServiceImpl method getSubCollectionsAndDataObjectsUnderPath.

@Override
public List<DataGridCollectionAndDataObject> getSubCollectionsAndDataObjectsUnderPath(String parent) throws DataGridConnectionRefusedException, JargonException {
    logger.info("getSubCollectionsAndDataObjectsUnderPath()");
    if (parent == null || parent.isEmpty()) {
        throw new IllegalArgumentException("null or empty parent");
    }
    logger.info("parent:{}", parent);
    CollectionAndDataObjectListAndSearchAO collectionAndDataObjectListAndSearchAO = irodsServices.getCollectionAndDataObjectListAndSearchAO();
    List<DataGridCollectionAndDataObject> dataGridCollectionAndDataObjects = null;
    try {
        List<CollectionAndDataObjectListingEntry> collectionAndDataObjects = collectionAndDataObjectListAndSearchAO.listDataObjectsAndCollectionsUnderPath(parent);
        dataGridCollectionAndDataObjects = new ArrayList<DataGridCollectionAndDataObject>();
        dataGridCollectionAndDataObjects = this.mapListingEntryToDataGridCollectionAndDataObject(collectionAndDataObjects);
        return dataGridCollectionAndDataObjects;
    } catch (FileNotFoundException e) {
        logger.error("Could not locate file: ", e);
        throw e;
    } catch (JargonException e) {
        logger.error("Error: ", e);
        throw e;
    }
}
Also used : CollectionAndDataObjectListAndSearchAO(org.irods.jargon.core.pub.CollectionAndDataObjectListAndSearchAO) JargonException(org.irods.jargon.core.exception.JargonException) DataGridCollectionAndDataObject(com.emc.metalnx.core.domain.entity.DataGridCollectionAndDataObject) FileNotFoundException(org.irods.jargon.core.exception.FileNotFoundException) CollectionAndDataObjectListingEntry(org.irods.jargon.core.query.CollectionAndDataObjectListingEntry)

Example 10 with CollectionAndDataObjectListAndSearchAO

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

the class CollectionServiceImpl method findByName.

@Override
public DataGridCollectionAndDataObject findByName(String path) throws FileNotFoundException, DataGridException {
    logger.info("findByName()");
    if (path == null || path.isEmpty()) {
        logger.info("Could not find collection or data object by name: path is null");
        return null;
    }
    logger.info("Find collection or data object by name: {}", path);
    CollectionAndDataObjectListAndSearchAO objectsAO = irodsServices.getCollectionAndDataObjectListAndSearchAO();
    DataGridCollectionAndDataObject dataGridCollectionAndDataObject;
    try {
        CollectionAndDataObjectListingEntry entry = objectsAO.getCollectionAndDataObjectListingEntryAtGivenAbsolutePathWithHeuristicPathGuessing(path);
        dataGridCollectionAndDataObject = this.mapListingEntryToDataGridCollectionAndDataObject(entry);
    } catch (FileNotFoundException fnf) {
        logger.warn("file not found for path:{}", path);
        throw fnf;
    } catch (JargonException e) {
        logger.debug("error finding collection/data object by name: {}", path);
        throw new DataGridException("Could not find path " + path);
    }
    return dataGridCollectionAndDataObject;
}
Also used : CollectionAndDataObjectListAndSearchAO(org.irods.jargon.core.pub.CollectionAndDataObjectListAndSearchAO) DataGridException(com.emc.metalnx.core.domain.exceptions.DataGridException) JargonException(org.irods.jargon.core.exception.JargonException) DataGridCollectionAndDataObject(com.emc.metalnx.core.domain.entity.DataGridCollectionAndDataObject) FileNotFoundException(org.irods.jargon.core.exception.FileNotFoundException) CollectionAndDataObjectListingEntry(org.irods.jargon.core.query.CollectionAndDataObjectListingEntry)

Aggregations

CollectionAndDataObjectListAndSearchAO (org.irods.jargon.core.pub.CollectionAndDataObjectListAndSearchAO)11 JargonException (org.irods.jargon.core.exception.JargonException)10 DataGridCollectionAndDataObject (com.emc.metalnx.core.domain.entity.DataGridCollectionAndDataObject)9 CollectionAndDataObjectListingEntry (org.irods.jargon.core.query.CollectionAndDataObjectListingEntry)6 CollectionAO (org.irods.jargon.core.pub.CollectionAO)5 DataObjectAO (org.irods.jargon.core.pub.DataObjectAO)4 DataObject (org.irods.jargon.core.pub.domain.DataObject)4 HashSet (java.util.HashSet)3 FileNotFoundException (org.irods.jargon.core.exception.FileNotFoundException)3 AvuData (org.irods.jargon.core.pub.domain.AvuData)3 DataGridFilePermission (com.emc.metalnx.core.domain.entity.DataGridFilePermission)1 DataGridGroupPermission (com.emc.metalnx.core.domain.entity.DataGridGroupPermission)1 DataGridMetadata (com.emc.metalnx.core.domain.entity.DataGridMetadata)1 DataGridUserPermission (com.emc.metalnx.core.domain.entity.DataGridUserPermission)1 DataGridException (com.emc.metalnx.core.domain.exceptions.DataGridException)1 AdminServices (com.emc.metalnx.services.interfaces.AdminServices)1 IRODSServices (com.emc.metalnx.services.interfaces.IRODSServices)1 ArrayList (java.util.ArrayList)1 IRODSAccount (org.irods.jargon.core.connection.IRODSAccount)1 EnvironmentalInfoAO (org.irods.jargon.core.pub.EnvironmentalInfoAO)1