path prefix now stripped off per system 85/93985/1
authorBenjamin, Max <max.benjamin@att.com>
Tue, 20 Aug 2019 16:56:16 +0000 (12:56 -0400)
committerBenjamin, Max (mb388a) <mb388a@att.com>
Tue, 20 Aug 2019 16:56:18 +0000 (12:56 -0400)
path prefix now stripped off per system

Issue-ID: SO-2243
Signed-off-by: Benjamin, Max (mb388a) <mb388a@att.com>
Change-Id: Ie74e7c68f927a49b612c433b4a664887058a1726

common/src/main/java/org/onap/so/client/aai/entities/uri/AAISimpleUri.java
common/src/main/java/org/onap/so/client/graphinventory/entities/uri/SimpleUri.java

index f2f9905..1fe9da9 100644 (file)
@@ -21,6 +21,7 @@
 package org.onap.so.client.aai.entities.uri;
 
 import java.net.URI;
+import java.util.regex.Pattern;
 import javax.ws.rs.core.UriBuilder;
 import org.onap.so.client.aai.AAIObjectPlurals;
 import org.onap.so.client.aai.AAIObjectType;
@@ -138,4 +139,9 @@ public class AAISimpleUri extends SimpleUri implements AAIResourceUri {
     public AAISimpleUri format(Format format) {
         return (AAISimpleUri) super.format(format);
     }
+
+    @Override
+    protected Pattern getPrefixPattern() {
+        return Pattern.compile("/aai/v\\d+");
+    }
 }
index 41ba07a..ffe47c5 100644 (file)
@@ -29,6 +29,7 @@ import java.nio.charset.StandardCharsets;
 import java.util.HashMap;
 import java.util.Map;
 import java.util.Set;
+import java.util.regex.Pattern;
 import javax.ws.rs.core.UriBuilder;
 import org.apache.commons.lang3.builder.HashCodeBuilder;
 import org.onap.so.client.graphinventory.Format;
@@ -61,7 +62,7 @@ public class SimpleUri implements GraphInventoryResourceUri, Serializable {
     protected SimpleUri(GraphInventoryObjectType type, URI uri) {
         this.type = type;
         this.pluralType = null;
-        this.internalURI = UriBuilder.fromPath(uri.getRawPath().replaceAll("/aai/v\\d+", ""));
+        this.internalURI = UriBuilder.fromPath(uri.getRawPath().replaceAll(getPrefixPattern().toString(), ""));
         this.values = new Object[0];
     }
 
@@ -174,6 +175,10 @@ public class SimpleUri implements GraphInventoryResourceUri, Serializable {
         return build(this.values);
     }
 
+    protected Pattern getPrefixPattern() {
+        return Pattern.compile("/.*?/v\\d+");
+    }
+
     protected URI build(Object... values) {
         // This is a workaround because resteasy does not encode URIs correctly
         final String[] encoded = new String[values.length];