Search in sources :

Example 6 with ResourceAO

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

the class ResourceServiceImpl method createResource.

@Override
public boolean createResource(DataGridResource newDataGridResource) throws DataGridConnectionRefusedException {
    try {
        ResourceAO resourceAO = irodsServices.getResourceAO();
        ZoneAO zoneAO = irodsServices.getZoneAO();
        // mapping data grid resource to iRODS Resource
        Resource irodsResource = new Resource();
        irodsResource.setName(newDataGridResource.getName());
        irodsResource.setType(newDataGridResource.getType());
        irodsResource.setZone(zoneAO.getZoneByName(newDataGridResource.getZone()));
        irodsResource.setCreateTime(newDataGridResource.getCreateTime());
        irodsResource.setModifyTime(newDataGridResource.getModifyTime());
        irodsResource.setStatus(newDataGridResource.getStatus());
        irodsResource.setInfo(newDataGridResource.getInfo());
        irodsResource.setParentName(newDataGridResource.getParent());
        irodsResource.setVaultPath(newDataGridResource.getPath());
        irodsResource.setLocation(newDataGridResource.getHost());
        // context string is not always set
        if (newDataGridResource.getContextString() != null) {
            irodsResource.setContextString(newDataGridResource.getContextString());
        }
        // adding the new resource to iRODS
        resourceAO.addResource(irodsResource);
        return true;
    } catch (JargonException e) {
        logger.error("Could not create resource: ", e);
    }
    return false;
}
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) ZoneAO(org.irods.jargon.core.pub.ZoneAO)

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