/** {@inheritDoc} */ @Override public final ResourcePath getRelativePathForAttribute(ResourcePath resourceParent, String instance) { return ResourcePath.get(resourceParent, m_resourceTypeName, instance); }
@Override public ResourcePath getParent() { return ResourcePath.get(m_ipAddress); }
@Override public ResourcePath getPath() { return ResourcePath.get("distributed", m_locationMonitorId, m_ipAddress); }
private static ResourcePath createStorageResourcePath(String foreignSource, String foreignId, int nodeId) { final ResourcePath dir; if(isStoreByForeignSource() && foreignSource != null && foreignId != null) { dir = ResourcePath.get(ResourceTypeUtils.FOREIGN_SOURCE_DIRECTORY, foreignSource, foreignId); } else { dir = ResourcePath.get(String.valueOf(nodeId)); } return dir; } }
/** * Retrieves the ResourcePath relative to rrd.base.dir. */ public static ResourcePath getResourcePathWithRepository(RrdRepository repository, ResourcePath resource) { // Here we just assume that the repository dir is of the form ${rrd.base.dir}/snmp or ${rrd.base.dir}/response // since all of operations in the ResourceDao assume that the resources are stored in these paths return ResourcePath.get(ResourcePath.get(repository.getRrdBaseDir().getName()), resource); } }
private static ResourcePath createStorageResourcePath(String foreignSource, String foreignId, int nodeId) { final ResourcePath dir; if(isStoreByForeignSource() && foreignSource != null && foreignId != null) { dir = ResourcePath.get(ResourceTypeUtils.FOREIGN_SOURCE_DIRECTORY, foreignSource, foreignId); } else { dir = ResourcePath.get(String.valueOf(nodeId)); } return dir; } }
@Override public ResourcePath getStorageResourcePath() { if (foreignSource != null && foreignId != null) { return ResourcePath.get("fs", foreignSource, foreignId); } else { return new ResourcePath(Integer.toString(nodeId)); } }
@Override public ResourcePath getStorageResourcePath() { if (foreignSource != null && foreignId != null) { return ResourcePath.get("fs", foreignSource, foreignId); } else { return new ResourcePath(Integer.toString(nodeId)); } }
/** * Converts a Newts resource id to a {@link org.opennms.netmgt.model.ResourcePath}. * * @param resourceId Newts resource id * @return path */ public static ResourcePath toResourcePath(String resourceId) { if (resourceId == null) { return null; } List<String> els = s_splitter.splitIdIntoElements(resourceId); return ResourcePath.get(els.subList(0, els.size() - 1)); }
@Override public ResourcePath getPath() { String label = getInterfaceLabel(); if (label == null || "".equals(label)) { throw new IllegalStateException("Could not construct resource directory because interface label is null or blank: nodeId: " + getNodeId()); } return ResourcePath.get(getCollectionAgent().getStorageResourcePath(), label); }
protected static ResourcePath getResourcePathForNode(OnmsNode node) { // Use the storeByFs path when enabled, falling back to the node id path when // the node in question has no foreign source or foreign id if (ResourceTypeUtils.isStoreByForeignSource() && node.getForeignSource() != null && node.getForeignId() != null) { return ResourcePath.get(ResourceTypeUtils.SNMP_DIRECTORY, ResourceTypeUtils.FOREIGN_SOURCE_DIRECTORY, node.getForeignSource(), node.getForeignId()); } else { return ResourcePath.get(ResourceTypeUtils.SNMP_DIRECTORY, Integer.toString(node.getId())); } }
private OnmsResource getResourceByParentPathAndInterface(ResourcePath parent, String intf, String label, OnmsSnmpInterface snmpInterface) throws DataAccessException { final ResourcePath path = ResourcePath.get(parent, intf); final AttributeLoader loader = new AttributeLoader(m_resourceStorageDao, path, snmpInterface); final Set<OnmsAttribute> set = new LazySet<OnmsAttribute>(loader); return new OnmsResource(intf, label, this, set, path); }
@Override public OnmsResource getResourceByName(String domain) { if (!m_resourceStorageDao.exists(ResourcePath.get(ResourceTypeUtils.SNMP_DIRECTORY, domain), 1)) { throw new ObjectRetrievalFailureException(OnmsResource.class, domain, "Top-level resource of type domain could not be found: " + domain, null); } return createResourceForDomain(domain); }
private OnmsResource getResourceByParentPathAndInterface(ResourcePath parent, String intf) { final ResourcePath path = ResourcePath.get(parent, intf); final LazyResourceAttributeLoader loader = new LazyResourceAttributeLoader(m_resourceStorageDao, path); final Set<OnmsAttribute> set = new LazySet<OnmsAttribute>(loader); return new OnmsResource(intf, intf, this, set, path); }
@Override public ResourcePath getPath(CollectionResource resource) { return getStorageStrategy().getRelativePathForAttribute(ResourcePath.get(), getStorageStrategy().getResourceNameFromIndex(resource)); }
/** {@inheritDoc} */ @Override public OnmsResource getChildByName(OnmsResource parent, String index) { if (parent == null) { return null; } final ResourcePath path = ResourcePath.get(parent.getPath(), getName(), index); if (!m_resourceStorageDao.exists(path, 0)) { throw new ObjectRetrievalFailureException(OnmsResource.class, path, "Generic resource with label " + m_label + " could not find resource at path: " + path, null); } return getResourceByPath(path, parent); }
private SnmpCollectionAgent createCollectionAgent() { SnmpCollectionAgent agent = EasyMock.createMock(SnmpCollectionAgent.class); EasyMock.expect(agent.getNodeId()).andReturn(1).anyTimes(); EasyMock.expect(agent.getHostAddress()).andReturn("127.0.0.1").anyTimes(); EasyMock.expect(agent.getSnmpInterfaceInfo((IfResourceType)EasyMock.anyObject())).andReturn(new HashSet<IfInfo>()).anyTimes(); EasyMock.expect(agent.getForeignSource()).andReturn("JUnit").anyTimes(); EasyMock.expect(agent.getForeignId()).andReturn("T001").anyTimes(); EasyMock.expect(agent.getStorageResourcePath()).andReturn(ResourcePath.get(ResourceTypeUtils.FOREIGN_SOURCE_DIRECTORY, "JUnit", "T001")).anyTimes(); EasyMock.replay(agent); return agent; }