Search in sources :

Example 1 with DataObjectAO

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

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

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

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

the class CollectionServiceImpl method getTotalNumberOfReplsForDataObject.

@Override
public int getTotalNumberOfReplsForDataObject(String path) throws DataGridException {
    logger.info("getTotalNumberOfReplsForDataObject()");
    int totalNumberOfRepls = 0;
    if (path == null || path.isEmpty()) {
        return 0;
    }
    String parentPath = path.substring(0, path.lastIndexOf(IRODS_PATH_SEPARATOR));
    String dataObjectName = path.substring(path.lastIndexOf(IRODS_PATH_SEPARATOR), path.length());
    DataObjectAO dataObjectAO = irodsServices.getDataObjectAO();
    // getting total number of replicas
    try {
        totalNumberOfRepls = dataObjectAO.getTotalNumberOfReplsForDataObject(parentPath, dataObjectName);
    } catch (JargonException e) {
        logger.error("Could not get number of replicas of a data obj: {}", e.getMessage());
        throw new DataGridException(e.getMessage());
    }
    return totalNumberOfRepls;
}
Also used : DataGridException(com.emc.metalnx.core.domain.exceptions.DataGridException) JargonException(org.irods.jargon.core.exception.JargonException) DataObjectAO(org.irods.jargon.core.pub.DataObjectAO)

Example 5 with DataObjectAO

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

the class CollectionServiceImpl method getReplicationNumber.

@Override
public int getReplicationNumber(String path) throws DataGridConnectionRefusedException {
    logger.info("getReplicationNumber()");
    logger.debug("Getting replication number of " + path);
    DataObjectAO dataObjectAO = irodsServices.getDataObjectAO();
    DataObject dataObject = null;
    try {
        dataObject = dataObjectAO.findByAbsolutePath(path);
    } catch (JargonException e) {
        logger.error("Could not find a data object matching " + path, e);
    }
    if (dataObject != null) {
        return dataObject.getDataReplicationNumber();
    }
    return 0;
}
Also used : DataGridCollectionAndDataObject(com.emc.metalnx.core.domain.entity.DataGridCollectionAndDataObject) DataObject(org.irods.jargon.core.pub.domain.DataObject) JargonException(org.irods.jargon.core.exception.JargonException) DataObjectAO(org.irods.jargon.core.pub.DataObjectAO)

Aggregations

DataObjectAO (org.irods.jargon.core.pub.DataObjectAO)20 JargonException (org.irods.jargon.core.exception.JargonException)18 CollectionAO (org.irods.jargon.core.pub.CollectionAO)14 DataGridCollectionAndDataObject (com.emc.metalnx.core.domain.entity.DataGridCollectionAndDataObject)9 DataObject (org.irods.jargon.core.pub.domain.DataObject)8 IRODSFile (org.irods.jargon.core.pub.io.IRODSFile)6 IRODSFileFactory (org.irods.jargon.core.pub.io.IRODSFileFactory)6 DataGridException (com.emc.metalnx.core.domain.exceptions.DataGridException)4 CollectionAndDataObjectListAndSearchAO (org.irods.jargon.core.pub.CollectionAndDataObjectListAndSearchAO)4 AvuData (org.irods.jargon.core.pub.domain.AvuData)3 FilePermissionEnum (org.irods.jargon.core.protovalues.FilePermissionEnum)2 DataGridMetadata (com.emc.metalnx.core.domain.entity.DataGridMetadata)1 DataGridResource (com.emc.metalnx.core.domain.entity.DataGridResource)1 IconObject (com.emc.metalnx.core.domain.entity.IconObject)1 DataGridChecksumException (com.emc.metalnx.core.domain.exceptions.DataGridChecksumException)1 File (java.io.File)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 IRODSAccount (org.irods.jargon.core.connection.IRODSAccount)1