From 53b46b3c23eeb332fb7b0ab0c69ca04b961f38cf Mon Sep 17 00:00:00 2001 From: "Benjamin, Max" Date: Tue, 20 Aug 2019 12:56:16 -0400 Subject: path prefix now stripped off per system path prefix now stripped off per system Issue-ID: SO-2243 Signed-off-by: Benjamin, Max (mb388a) Change-Id: Ie74e7c68f927a49b612c433b4a664887058a1726 --- .../java/org/onap/so/client/aai/entities/uri/AAISimpleUri.java | 6 ++++++ .../org/onap/so/client/graphinventory/entities/uri/SimpleUri.java | 7 ++++++- 2 files changed, 12 insertions(+), 1 deletion(-) (limited to 'common/src') diff --git a/common/src/main/java/org/onap/so/client/aai/entities/uri/AAISimpleUri.java b/common/src/main/java/org/onap/so/client/aai/entities/uri/AAISimpleUri.java index f2f99050db..1fe9da984f 100644 --- a/common/src/main/java/org/onap/so/client/aai/entities/uri/AAISimpleUri.java +++ b/common/src/main/java/org/onap/so/client/aai/entities/uri/AAISimpleUri.java @@ -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+"); + } } diff --git a/common/src/main/java/org/onap/so/client/graphinventory/entities/uri/SimpleUri.java b/common/src/main/java/org/onap/so/client/graphinventory/entities/uri/SimpleUri.java index 41ba07ad6c..ffe47c5c51 100644 --- a/common/src/main/java/org/onap/so/client/graphinventory/entities/uri/SimpleUri.java +++ b/common/src/main/java/org/onap/so/client/graphinventory/entities/uri/SimpleUri.java @@ -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]; -- cgit 1.2.3-korg