Search in sources :

Example 1 with ResourceAO

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;
}
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 2 with ResourceAO

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;
}
Also used : ResourceAO(org.irods.jargon.core.pub.ResourceAO) DataGridConnectionRefusedException(com.emc.metalnx.core.domain.exceptions.DataGridConnectionRefusedException) JargonException(org.irods.jargon.core.exception.JargonException) UnknownHostException(java.net.UnknownHostException) DataGridServerException(com.emc.metalnx.core.domain.exceptions.DataGridServerException)

Example 3 with ResourceAO

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");
}
Also used : ResourceAO(org.irods.jargon.core.pub.ResourceAO) DataGridResource(com.emc.metalnx.core.domain.entity.DataGridResource)

Example 4 with ResourceAO

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;
}
Also used : ResourceAO(org.irods.jargon.core.pub.ResourceAO) DataGridResource(com.emc.metalnx.core.domain.entity.DataGridResource) DataGridConnectionRefusedException(com.emc.metalnx.core.domain.exceptions.DataGridConnectionRefusedException) JargonException(org.irods.jargon.core.exception.JargonException) UnknownHostException(java.net.UnknownHostException) DataGridServerException(com.emc.metalnx.core.domain.exceptions.DataGridServerException)

Example 5 with ResourceAO

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>();
}
Also used : ResourceAO(org.irods.jargon.core.pub.ResourceAO) JargonException(org.irods.jargon.core.exception.JargonException) Resource(org.irods.jargon.core.pub.domain.Resource) DataGridResource(com.emc.metalnx.core.domain.entity.DataGridResource) ArrayList(java.util.ArrayList)

Aggregations

ResourceAO (org.irods.jargon.core.pub.ResourceAO)6 DataGridResource (com.emc.metalnx.core.domain.entity.DataGridResource)5 JargonException (org.irods.jargon.core.exception.JargonException)5 Resource (org.irods.jargon.core.pub.domain.Resource)3 DataGridConnectionRefusedException (com.emc.metalnx.core.domain.exceptions.DataGridConnectionRefusedException)2 DataGridServerException (com.emc.metalnx.core.domain.exceptions.DataGridServerException)2 UnknownHostException (java.net.UnknownHostException)2 ArrayList (java.util.ArrayList)2 ZoneAO (org.irods.jargon.core.pub.ZoneAO)1