private static Predicate<RegistryEntry> descriptionFactoryPrefix(String descriptionLink) { return r -> r.descriptionFactoryLink.equals(descriptionLink) || UriUtils.isChildPath(descriptionLink, r.descriptionFactoryLink); }
private static Predicate<RegistryEntry> stateFactoryPrefix(String stateLink) { return r -> r.stateFactoryLink.equals(stateLink) || UriUtils.isChildPath(stateLink, r.stateFactoryLink); }
if (UriUtils.isChildPath(suffix, factoryLink)) { index = factoryLink.length() + 1;
/** * The method makes sure that the documentSelfLink always the associated factory as the prefix. */ private String normalizeLink(String factoryLink, String documentLink) { if (UriUtils.isChildPath(documentLink, factoryLink)) { return documentLink; } String lastPathSegment = UriUtils.getLastPathSegment(documentLink); return UriUtils.buildUriPath(factoryLink, lastPathSegment); }
@Test public void isChildPath() { assertFalse(UriUtils.isChildPath(null, "/a/b")); assertFalse(UriUtils.isChildPath("/a/b/c", null)); assertTrue(UriUtils.isChildPath("/a/b/c", "/a/b")); assertTrue(UriUtils.isChildPath("/a/b/c", "/a/b/")); assertFalse(UriUtils.isChildPath("/a/bb/c", "/a/b")); assertTrue(UriUtils.isChildPath("b/c", "b")); assertFalse(UriUtils.isChildPath("b/c", "/a/b")); }
@Test public void isChildPath() { assertFalse(UriUtils.isChildPath(null, "/a/b")); assertFalse(UriUtils.isChildPath("/a/b/c", null)); assertTrue(UriUtils.isChildPath("/a/b/c", "/a/b")); assertTrue(UriUtils.isChildPath("/a/b/c", "/a/b/")); assertFalse(UriUtils.isChildPath("/a/bb/c", "/a/b")); assertTrue(UriUtils.isChildPath("b/c", "b")); assertFalse(UriUtils.isChildPath("b/c", "/a/b")); }
/** * Fetch targetLinks into network interface states or compute states */ private DeferredResult<Set<ResourceState>> getTargetStates(Collection<String> links) { if (links == null) { return DeferredResult.completed(null); } return DeferredResult .allOf(links.stream().map(link -> getDr(link)).collect(Collectors.toList())) .thenApply(operations -> operations.stream() .map(operation -> { if (operation != null) { String servicePath = operation.getUri().getPath(); if (UriUtils .isChildPath(servicePath, ComputeService.FACTORY_LINK)) { return operation.getBody(ComputeState.class); } else if (UriUtils.isChildPath(servicePath, NetworkInterfaceService.FACTORY_LINK)) { return operation.getBody(NetworkInterfaceState.class); } else { logWarning("Unrecognized type of target state with path: %s", servicePath); return operation.getBody(ResourceState.class); } } return null; }) .collect(Collectors.toSet())); }
body.documentSelfLink); } else { if (UriUtils.isChildPath(body.documentSelfLink, serviceSelfLink)) { serviceSelfLink = body.documentSelfLink; } else {
if (UriUtils.isChildPath(suffix, getSelfLink())) { serviceUri = UriUtils.buildUri(getHost(), suffix); } else {