Search in sources :

Example 1 with JargonException

use of org.irods.jargon.core.exception.JargonException 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 JargonException

use of org.irods.jargon.core.exception.JargonException 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 JargonException

use of org.irods.jargon.core.exception.JargonException in project metalnx-web by irods-contrib.

the class ResourceServiceImpl method findAll.

@Override
public List<DataGridResource> findAll() throws DataGridConnectionRefusedException {
    logger.info("Find all resources in the grid");
    List<DataGridResource> dataGridResources = new ArrayList<DataGridResource>();
    ResourceAO resourceAO = irodsServices.getResourceAO();
    try {
        List<Resource> resources = resourceAO.findAll();
        for (Resource irodsResource : resources) {
            DataGridResource newDataGridResource = getDataGridResource(irodsResource);
            dataGridResources.add(newDataGridResource);
            for (Resource r : resources) {
                if (r.getParentName().equals(irodsResource.getName())) {
                    newDataGridResource.addChildResc(r.getName());
                }
            }
        }
    } catch (JargonException e) {
        logger.error("Could not find all resources: ", e);
    }
    logger.debug("got all resources");
    // sorting this list alphabetically
    Collections.sort(dataGridResources);
    logger.debug("sorted...");
    return dataGridResources;
}
Also used : ResourceAO(org.irods.jargon.core.pub.ResourceAO) JargonException(org.irods.jargon.core.exception.JargonException) ArrayList(java.util.ArrayList) Resource(org.irods.jargon.core.pub.domain.Resource) DataGridResource(com.emc.metalnx.core.domain.entity.DataGridResource) DataGridResource(com.emc.metalnx.core.domain.entity.DataGridResource)

Example 4 with JargonException

use of org.irods.jargon.core.exception.JargonException in project metalnx-web by irods-contrib.

the class RuleServiceImpl method executeRule.

@Override
public Map<String, IRODSRuleExecResultOutputParameter> executeRule(String rule) throws DataGridRuleException, DataGridConnectionRefusedException {
    if (rule == null || rule.isEmpty())
        return null;
    Map<String, IRODSRuleExecResultOutputParameter> ruleResultMap;
    try {
        IRODSRuleExecResult result = is.getRuleProcessingAO().executeRule(rule);
        ruleResultMap = result.getOutputParameterResults();
    } catch (JargonException e) {
        String error = String.format("Could not execute rule %s: %s", rule, e.getMessage());
        logger.error(error);
        throw new DataGridRuleException(error);
    }
    return ruleResultMap;
}
Also used : DataGridRuleException(com.emc.metalnx.core.domain.exceptions.DataGridRuleException) IRODSRuleExecResultOutputParameter(org.irods.jargon.core.rule.IRODSRuleExecResultOutputParameter) JargonException(org.irods.jargon.core.exception.JargonException) IRODSRuleExecResult(org.irods.jargon.core.rule.IRODSRuleExecResult)

Example 5 with JargonException

use of org.irods.jargon.core.exception.JargonException in project metalnx-web by irods-contrib.

the class SpecificQueryServiceImpl method createSpecificQuery.

@Override
public boolean createSpecificQuery(DataGridSpecificQuery specificQuery) throws DataGridConnectionRefusedException {
    SpecificQueryAO specificQueryAO = irodsServices.getSpecificQueryAO();
    try {
        SpecificQueryDefinition newQuery = new SpecificQueryDefinition(specificQuery.getAlias(), specificQuery.getQuery());
        specificQueryAO.addSpecificQuery(newQuery);
        return true;
    } catch (JargonException e) {
        logger.error("Could not create specific query {}", specificQuery.getAlias(), e);
    }
    return false;
}
Also used : JargonException(org.irods.jargon.core.exception.JargonException) SpecificQueryAO(org.irods.jargon.core.pub.SpecificQueryAO) SpecificQueryDefinition(org.irods.jargon.core.pub.domain.SpecificQueryDefinition)

Aggregations

JargonException (org.irods.jargon.core.exception.JargonException)86 DataGridCollectionAndDataObject (com.emc.metalnx.core.domain.entity.DataGridCollectionAndDataObject)20 CollectionAO (org.irods.jargon.core.pub.CollectionAO)20 DataGridException (com.emc.metalnx.core.domain.exceptions.DataGridException)18 DataObjectAO (org.irods.jargon.core.pub.DataObjectAO)18 IRODSFile (org.irods.jargon.core.pub.io.IRODSFile)17 IRODSFileFactory (org.irods.jargon.core.pub.io.IRODSFileFactory)15 ArrayList (java.util.ArrayList)12 SpecificQueryAO (org.irods.jargon.core.pub.SpecificQueryAO)12 DataGridConnectionRefusedException (com.emc.metalnx.core.domain.exceptions.DataGridConnectionRefusedException)11 CollectionAndDataObjectListAndSearchAO (org.irods.jargon.core.pub.CollectionAndDataObjectListAndSearchAO)10 SpecificQueryDefinition (org.irods.jargon.core.pub.domain.SpecificQueryDefinition)10 SpecificQueryResultSet (org.irods.jargon.core.query.SpecificQueryResultSet)9 UnsupportedDataGridFeatureException (com.emc.metalnx.core.domain.exceptions.UnsupportedDataGridFeatureException)8 SpecificQueryProvider (com.emc.metalnx.services.irods.utils.SpecificQueryProvider)8 ClientHints (org.irods.jargon.core.pub.domain.ClientHints)8 DataObject (org.irods.jargon.core.pub.domain.DataObject)8 CollectionAndDataObjectListingEntry (org.irods.jargon.core.query.CollectionAndDataObjectListingEntry)8 SpecificQuery (org.irods.jargon.core.query.SpecificQuery)8 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)8