use of org.opennms.netmgt.collection.support.builder.InterfaceLevelResource in project opennms by OpenNMS.
the class XmpCollector method getResource.
protected Resource getResource(NodeLevelResource nodeLevelResource, String nodeTypeName, String resourceType, String instance) throws CollectionException {
if (CollectionResource.RESOURCE_TYPE_NODE.equalsIgnoreCase(nodeTypeName)) {
return nodeLevelResource;
}
final String effectiveResourceType;
if ((resourceType == null) || (resourceType.length() == 0)) {
effectiveResourceType = null;
} else {
effectiveResourceType = resourceType;
}
final String effectiveInstance;
if (instance != null) {
effectiveInstance = XmpCollector.sanitizeInstance(instance);
} else {
effectiveInstance = null;
}
if (effectiveResourceType != null) {
final ResourceType resourceTypeDef = m_resourceTypesDao.getResourceTypeByName(effectiveResourceType);
if (resourceType == null) {
throw new CollectionException("No resource type found with name '" + effectiveResourceType + "'.");
}
return new GenericTypeResource(nodeLevelResource, resourceTypeDef, effectiveInstance);
} else {
return new InterfaceLevelResource(nodeLevelResource, effectiveInstance);
}
}
Aggregations