/** * Convenience method. */ public static ResourcePath get(Iterable<String> pathElements) { return new ResourcePath(pathElements); }
/** * Convenience method. */ public static ResourcePath get(String... path) { return new ResourcePath(path); }
/** * Convenience method. */ public static ResourcePath get(ResourcePath parent, String... path) { return new ResourcePath(parent, path); }
private static ResourcePath getRelativeInterfacePath(String id, String ipAddr) { return new ResourcePath( ResourceTypeUtils.RESPONSE_DIRECTORY, DISTRIBUTED_DIRECTORY, id, ipAddr); } }
/** * Convenience method. */ public static ResourcePath get(ResourcePath parent, Iterable<String> path) { return new ResourcePath(parent, path); }
private static ResourcePath getInterfacePath(final String location, final String ipAddr) { if (location == null) { return new ResourcePath(ResourceTypeUtils.RESPONSE_DIRECTORY, ipAddr); } else { return new ResourcePath(ResourceTypeUtils.RESPONSE_DIRECTORY, ResourcePath.sanitize(location), ipAddr); } }
@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)); } }
/** {@inheritDoc} */ @Override public List<OnmsResource> getResourcesForParent(OnmsResource parent) { if (parent == null) { return Collections.emptyList(); } List<OnmsResource> resources = Lists.newArrayList(); List<String> indexes = getQueryableIndexes(new ResourcePath(parent.getPath(), m_name)); for (String index : indexes) { resources.add(getResourceByPath(new ResourcePath(parent.getPath(), m_name, index), parent)); } return OnmsResource.sortIntoResourceList(resources); }
/** {@inheritDoc} */ @Override public boolean isResourceTypeOnParent(OnmsResource parent) { if (parent == null) { return false; } return m_resourceStorageDao.exists(new ResourcePath(parent.getPath(), m_name), 1); }
private OnmsResource createResourceForDomain(String domain) { final ResourcePath path = new ResourcePath(ResourceTypeUtils.SNMP_DIRECTORY, domain); final LazyChildResourceLoader loader = new LazyChildResourceLoader(m_resourceDao); final OnmsResource resource = new OnmsResource(domain, domain, this, s_emptyAttributeSet, new LazyList<OnmsResource>(loader), path); loader.setParent(resource); return resource; }
/** {@inheritDoc} */ @Override public OnmsResource getChildByName(final OnmsResource parent, final String name) { if (DomainResourceType.isDomain(parent)) { // Load all of the resources and search when dealing with domains. // This is not efficient, but resources of this type should be sparse. for (final OnmsResource resource : getResourcesForParent(parent)) { if (resource.getName().equals(name)) { return resource; } } throw new ObjectRetrievalFailureException(OnmsResource.class, "No child with name '" + name + "' found on '" + parent + "'"); } // Grab the node entity final OnmsNode node = ResourceTypeUtils.getNodeFromResource(parent); // Verify that the requested resource exists final ResourcePath resourcePath = new ResourcePath(parent.getPath(), name); if (!m_resourceStorageDao.exists(resourcePath, 0)) { throw new ObjectRetrievalFailureException(OnmsResource.class, "No resource with name '" + name + "' found."); } // Leverage the existing function for retrieving the resource list final List<OnmsResource> resources = getNodeResources(parent.getPath(), Sets.newHashSet(name), node); if (resources.size() != 1) { throw new ObjectRetrievalFailureException(OnmsResource.class, "No resource with name '" + name + "' found."); } final OnmsResource resource = resources.get(0); resource.setParent(parent); return resource; }