use of org.irods.jargon.core.pub.ResourceAO 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.pub.ResourceAO in project metalnx-web by irods-contrib.
the class ResourceServiceImpl method addChildToResource.
@Override
public boolean addChildToResource(String resourceName, String child) {
try {
ResourceAO resourceAO = irodsServices.getResourceAO();
// adding new children to the resource
resourceAO.addChildToResource(resourceName, child, "");
return true;
} catch (Exception e) {
logger.error("Could not add children to the " + resourceName + " resource: ", e);
}
return false;
}
use of org.irods.jargon.core.pub.ResourceAO in project metalnx-web by irods-contrib.
the class UploadServiceImpl method processUploadRules.
/**
* @param targetPath
* @param destResc
* @param targetFile
* @throws DataGridConnectionRefusedException
* @throws JargonException
* @throws IOException
* @throws DataGridRuleException
* @throws FileNotFoundException
*/
private void processUploadRules(String targetPath, String destResc, IRODSFile targetFile) throws DataGridConnectionRefusedException, JargonException, IOException, DataGridRuleException, FileNotFoundException {
// Getting list of resources for upload
HashMap<String, String> resourceMap = null;
logger.info("getting resourceMap for upload");
ResourceAO resourceAO = is.getResourceAO();
resourceMap = DataGridUtils.buildMapForResourcesNamesAndMountPoints(resourceAO.findAll());
String objPath = targetFile.getCanonicalPath();
logger.info("getting file path");
String filePath = resourceMap.get(destResc) + objPath.substring(objPath.indexOf("/", 1), objPath.length());
logger.info("file path:{}", filePath);
logger.info("get resource based on dest:{}", destResc);
DataGridResource dgDestResc = resourceService.find(destResc);
if (dgDestResc == null) {
logger.info("no resource found, ignoring rules");
/*
* this may be further refined in issue File upload when no resource defined can
* result in NPE #29 as this functionality is better understood. This gives an
* escape route as something of a temporary work-around - mc
*/
}
String host = dgDestResc.getHost();
logger.info("executing rules...");
rs.execBamCramMetadataRule(host, objPath, filePath);
rs.execVCFMetadataRule(host, objPath, filePath);
rs.execPopulateMetadataRule(host, objPath);
rs.execImageRule(host, objPath, filePath);
rs.execIlluminaMetadataRule(dgDestResc, targetPath, objPath);
rs.execManifestFileRule(host, targetPath, objPath, filePath);
logger.info("rules executed");
}
use of org.irods.jargon.core.pub.ResourceAO in project metalnx-web by irods-contrib.
the class ResourceServiceImpl method deleteResource.
@Override
public boolean deleteResource(String resourceName) {
if (resourceName.isEmpty()) {
logger.error("Could not delete resource: name cannot be empty.");
return false;
}
boolean isResourceDeleted = true;
try {
DataGridResource dgRescToRemove = find(resourceName);
if (dgRescToRemove == null) {
logger.error("Could not delete resource: resource {} not found.", resourceName);
return false;
}
ResourceAO resourceAO = irodsServices.getResourceAO();
// that resource and its parent
if (!dgRescToRemove.isFirstLevelResc()) {
resourceAO.removeChildFromResource(dgRescToRemove.getParent(), resourceName);
}
deleteChildrenFromResource(dgRescToRemove);
resourceAO.deleteResource(resourceName);
} catch (Exception e) {
logger.error("Could not delete resource " + resourceName + ": ", e);
isResourceDeleted = false;
}
return isResourceDeleted;
}
use of org.irods.jargon.core.pub.ResourceAO in project metalnx-web by irods-contrib.
the class ResourceServiceImpl method getImmediateChildren.
@Override
public List<String> getImmediateChildren(String resourceName) throws DataGridConnectionRefusedException {
try {
ResourceAO resourceAO = irodsServices.getResourceAO();
Resource irodsResource = resourceAO.findByName(resourceName);
return irodsResource.getImmediateChildren();
} catch (JargonException e) {
logger.error("Could not get immediate children of resource " + resourceName + ": ", e);
}
return new ArrayList<String>();
}
Aggregations