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;
}
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;
}
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;
}
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;
}
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;
}
Aggregations