Search in sources :

Example 1 with CollectionAO

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

the class MetadataServiceImpl method addMetadataToPath.

@Override
public boolean addMetadataToPath(String path, String attribute, String value, String unit) throws DataGridConnectionRefusedException {
    CollectionAndDataObjectListAndSearchAO collectionAndDataObjectListAndSearchAO = irodsServices.getCollectionAndDataObjectListAndSearchAO();
    boolean isMetadataAdded = false;
    logger.debug(path + ": " + attribute + " " + value + " " + unit);
    try {
        AvuData avuData = new AvuData(attribute, value, unit);
        Object obj = collectionAndDataObjectListAndSearchAO.getFullObjectForType(path);
        if (obj instanceof DataObject) {
            DataObjectAO dataObjectAO = irodsServices.getDataObjectAO();
            dataObjectAO.addAVUMetadata(path, avuData);
        } else {
            CollectionAO collectionAO = irodsServices.getCollectionAO();
            collectionAO.addAVUMetadata(path, avuData);
        }
        isMetadataAdded = true;
    } catch (JargonException e) {
        logger.error("Error trying to add metadata: " + e);
    }
    return isMetadataAdded;
}
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 2 with CollectionAO

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

the class MetadataServiceImpl method modMetadataFromPath.

@Override
public boolean modMetadataFromPath(String path, String oldAttribute, String oldValue, String oldUnit, String newAttribute, String newValue, String newUnit) throws DataGridConnectionRefusedException {
    CollectionAndDataObjectListAndSearchAO collectionAndDataObjectListAndSearchAO = irodsServices.getCollectionAndDataObjectListAndSearchAO();
    try {
        AvuData oldAVUData = new AvuData(oldAttribute, oldValue, oldUnit);
        AvuData newAVUData = new AvuData(newAttribute, newValue, newUnit);
        Object obj = collectionAndDataObjectListAndSearchAO.getFullObjectForType(path);
        if (obj instanceof DataObject) {
            DataObjectAO dataObjectAO = irodsServices.getDataObjectAO();
            dataObjectAO.modifyAVUMetadata(path, oldAVUData, newAVUData);
        } else {
            CollectionAO collectionAO = irodsServices.getCollectionAO();
            collectionAO.modifyAVUMetadata(path, oldAVUData, newAVUData);
        }
    } catch (JargonException e) {
        logger.error("Error trying to modify 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 3 with CollectionAO

use of org.irods.jargon.core.pub.CollectionAO 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 4 with CollectionAO

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

the class CollectionServiceImpl method listInheritanceForPath.

@Override
public Set<String> listInheritanceForPath(String path) throws DataGridConnectionRefusedException {
    logger.info("listInheritanceForPath()");
    Set<String> collections = new HashSet<String>();
    CollectionAO collectionAO = irodsServices.getCollectionAO();
    CollectionAndDataObjectListAndSearchAO collectionAndDataObjectListAndSearchAO = irodsServices.getCollectionAndDataObjectListAndSearchAO();
    try {
        List<CollectionAndDataObjectListingEntry> collList = collectionAndDataObjectListAndSearchAO.listCollectionsUnderPathWithPermissions(path, 0);
        for (CollectionAndDataObjectListingEntry collEntry : collList) {
            String currentCollPath = collEntry.getPathOrName();
            if (collectionAO.isCollectionSetForPermissionInheritance(currentCollPath)) {
                collections.add(currentCollPath);
            }
        }
        return collections;
    } catch (JargonException e) {
        logger.error("Could not get collections with inheritance option enabled: ", e);
    }
    return null;
}
Also used : CollectionAndDataObjectListAndSearchAO(org.irods.jargon.core.pub.CollectionAndDataObjectListAndSearchAO) CollectionAO(org.irods.jargon.core.pub.CollectionAO) JargonException(org.irods.jargon.core.exception.JargonException) CollectionAndDataObjectListingEntry(org.irods.jargon.core.query.CollectionAndDataObjectListingEntry) HashSet(java.util.HashSet)

Example 5 with CollectionAO

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

the class CollectionServiceImpl method countAll.

@Override
public int countAll() throws DataGridConnectionRefusedException {
    logger.info("countAll()");
    CollectionAO collectionAO = irodsServices.getCollectionAO();
    try {
        return collectionAO.countAllFilesUnderneathTheGivenCollection(IRODS_PATH_SEPARATOR);
    } catch (JargonException e) {
        logger.error("Could not count all files in the data grid: ", e);
    }
    return 0;
}
Also used : CollectionAO(org.irods.jargon.core.pub.CollectionAO) JargonException(org.irods.jargon.core.exception.JargonException)

Aggregations

CollectionAO (org.irods.jargon.core.pub.CollectionAO)22 JargonException (org.irods.jargon.core.exception.JargonException)20 DataObjectAO (org.irods.jargon.core.pub.DataObjectAO)14 DataGridCollectionAndDataObject (com.emc.metalnx.core.domain.entity.DataGridCollectionAndDataObject)7 IRODSFile (org.irods.jargon.core.pub.io.IRODSFile)7 IRODSFileFactory (org.irods.jargon.core.pub.io.IRODSFileFactory)7 CollectionAndDataObjectListAndSearchAO (org.irods.jargon.core.pub.CollectionAndDataObjectListAndSearchAO)5 DataObject (org.irods.jargon.core.pub.domain.DataObject)5 DataGridException (com.emc.metalnx.core.domain.exceptions.DataGridException)4 HashSet (java.util.HashSet)3 AvuData (org.irods.jargon.core.pub.domain.AvuData)3 FileNotFoundException (org.irods.jargon.core.exception.FileNotFoundException)2 FilePermissionEnum (org.irods.jargon.core.protovalues.FilePermissionEnum)2 IRODSFileSystemAO (org.irods.jargon.core.pub.IRODSFileSystemAO)2 DataGridMetadata (com.emc.metalnx.core.domain.entity.DataGridMetadata)1 IconObject (com.emc.metalnx.core.domain.entity.IconObject)1 File (java.io.File)1 ArrayList (java.util.ArrayList)1 IRODSAccount (org.irods.jargon.core.connection.IRODSAccount)1 DataTransferOperations (org.irods.jargon.core.pub.DataTransferOperations)1