public NamespaceName(String property, String cluster, String namespace) { validateNamespaceName(property, cluster, namespace); this.namespace = property + '/' + cluster + '/' + namespace; this.property = property; this.cluster = cluster; this.localName = namespace; }
public NamespaceName(String namespace) { try { checkNotNull(namespace); } catch (NullPointerException e) { throw new IllegalArgumentException("Invalid null namespace: " + namespace); } // Verify it's a proper namespace validateNamespaceName(namespace); this.namespace = namespace; }
private void validateNamespaceName(String namespace) { // assume the namespace is in the form of <property>/<cluster>/<namespace> try { checkNotNull(namespace); String testUrl = String.format("http://%s", namespace); URI uri = new URI(testUrl); checkNotNull(uri.getPath()); NamedEntity.checkURI(uri, testUrl); String[] parts = uri.getPath().split("/"); if (parts.length != 3) { throw new IllegalArgumentException("Invalid namespace format. namespace: " + namespace); } validateNamespaceName(uri.getHost(), parts[1], parts[2]); property = uri.getHost(); cluster = parts[1]; localName = parts[2]; } catch (URISyntaxException e) { throw new IllegalArgumentException("Invalid namespace format. namespace: " + namespace, e); } catch (NullPointerException e) { throw new IllegalArgumentException("Invalid namespace format. namespace: " + namespace, e); } }
this.partitionIndex = getPartitionIndex(destination); NamespaceName.validateNamespaceName(property, cluster, namespacePortion); if (checkNotNull(localName).isEmpty()) { throw new IllegalArgumentException("Invalid destination name: " + destination);