diff options
author | 2020-09-21 11:38:23 -0400 | |
---|---|---|
committer | 2020-09-23 16:32:42 -0400 | |
commit | 2505a543b0e45c1c3c2fe2fb8b85664b08bf2fca (patch) | |
tree | 5f1593d45f8c9a2fb2d400b8fa58dbb3e29ef671 /graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/entities | |
parent | 8d68a316f303d0fc57eb7da4fef881a26d39d439 (diff) |
removed references to AAIObjectType
removed references to AAIObjectType and AAIObjectPlurals
additional corrections for removal of aai object type
corrected additional java files
updated groovy files to match aai fluent builder style
Issue-ID: SO-3259
Signed-off-by: Benjamin, Max (mb388a) <mb388a@att.com>
Change-Id: Ifdf12fcacb34cc648548eb18b638afd06dad67a9
Diffstat (limited to 'graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/entities')
5 files changed, 57 insertions, 32 deletions
diff --git a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/entities/uri/AAIFluentTypeReverseLookup.java b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/entities/uri/AAIFluentTypeReverseLookup.java index bd9f4c713f..95cb1fe7c2 100644 --- a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/entities/uri/AAIFluentTypeReverseLookup.java +++ b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/entities/uri/AAIFluentTypeReverseLookup.java @@ -1,5 +1,6 @@ package org.onap.aaiclient.client.aai.entities.uri; +import java.lang.reflect.InvocationTargetException; import java.util.List; import java.util.Optional; import java.util.stream.Collectors; @@ -20,7 +21,7 @@ public class AAIFluentTypeReverseLookup { (Class<? extends GraphInventoryFluentType.Info>) Class .forName("org.onap.aaiclient.client.generated.fluentbuilders." + className + "$Info"); - GraphInventoryFluentType.Info type = clazz.newInstance(); + GraphInventoryFluentType.Info type = clazz.getConstructor().newInstance(); Optional<String> parentTemplate = findParentPath(type, uri); if (parentTemplate.isPresent()) { @@ -29,7 +30,8 @@ public class AAIFluentTypeReverseLookup { // fallback to enum lookup return AAIObjectType.fromTypeName(name); } - } catch (ClassNotFoundException | InstantiationException | IllegalAccessException e) { + } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | IllegalArgumentException + | InvocationTargetException | NoSuchMethodException | SecurityException e) { } return AAIObjectType.UNKNOWN; } diff --git a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/entities/uri/AAIUriFactory.java b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/entities/uri/AAIUriFactory.java index 6bb2cbd471..be49535f3e 100644 --- a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/entities/uri/AAIUriFactory.java +++ b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/entities/uri/AAIUriFactory.java @@ -21,29 +21,43 @@ package org.onap.aaiclient.client.aai.entities.uri; import java.net.URI; +import org.onap.aaiclient.client.aai.AAIObjectName; import org.onap.aaiclient.client.aai.AAIObjectPlurals; import org.onap.aaiclient.client.aai.AAIObjectType; +import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder.Types; public class AAIUriFactory { + + public static final AAIFluentTypeReverseLookup reverseLookup = new AAIFluentTypeReverseLookup(); + /** * values are filled into the URI template specified in {@link AAIObjectType} in order <br> - * There are two special lookups performed on certain types when a single value is specified: <br> - * Service Instance and AllottedResources <br> - * These can be retrieved without all their required keys but an HTTP call is required to do so - * + * * @param type * @param values * @return */ public static AAIResourceUri createResourceUri(AAIObjectType type, Object... values) { - if (AAIObjectType.SERVICE_INSTANCE.equals(type)) { - return new ServiceInstanceUri(values); - } else if (AAIObjectType.ALLOTTED_RESOURCE.equals(type)) { - return new AllottedResourceLookupUri(values); + return new AAISimpleUri(type, values); + } + + /** + * These can be retrieved without all their required keys but an HTTP call is required to do so + * + * @param type + * @param values + * @return + */ + public static AAIResourceUri createResourceUri(AAISingleFragment fragment) { + + if (Types.SERVICE_INSTANCE.typeName().equals(fragment.get().build().typeName())) { + return new ServiceInstanceUri(fragment); + } else if (Types.ALLOTTED_RESOURCE.typeName().equals(fragment.get().build().typeName())) { + return new AllottedResourceLookupUri(fragment); } else { - return new AAISimpleUri(type, values); + return null; } } @@ -51,13 +65,16 @@ public class AAIUriFactory { return new AAISimpleUri(uri.build(), uri.values()); } - public static NodesSingleUri createNodesUri(AAIObjectType type, Object... values) { + protected static NodesSingleUri createNodesUri(AAIObjectType type, Object... values) { return new NodesSingleUri(type, values); + } + public static NodesSingleUri createNodesUri(AAISingleFragment fragment) { + return new NodesSingleUri(fragment.get().build(), fragment.get().values()); } - public static NodesPluralUri createNodesUri(AAIObjectPlurals type) { - return new NodesPluralUri(type); + public static NodesPluralUri createNodesUri(AAIPluralFragment fragment) { + return new NodesPluralUri(fragment.get().build()); } @@ -68,7 +85,8 @@ public class AAIUriFactory { * @param uri * @return */ - public static AAISimpleUri createResourceFromExistingURI(AAIObjectType type, URI uri) { + public static AAISimpleUri createResourceFromExistingURI(AAIObjectName name, URI uri) { + AAIObjectType type = reverseLookup.fromName(name.typeName(), uri.toString()); return new AAISimpleUri(type, uri); } @@ -81,20 +99,19 @@ public class AAIUriFactory { * @param childValues * @return */ - public static AAISimpleUri createResourceFromParentURI(AAIResourceUri parentUri, AAIObjectType childType, - Object... childValues) { + public static AAISimpleUri createResourceFromParentURI(AAIResourceUri parentUri, AAISingleFragment fragment) { - return new AAISimpleUri(parentUri, childType, childValues); + return new AAISimpleUri(parentUri, fragment.get().build(), fragment.get().values()); } - public static AAISimplePluralUri createResourceFromParentURI(AAIResourceUri parentUri, AAIObjectPlurals childType) { + public static AAISimplePluralUri createResourceFromParentURI(AAIResourceUri parentUri, AAIPluralFragment fragment) { - return new AAISimplePluralUri(parentUri, childType); + return new AAISimplePluralUri(parentUri, fragment.get().build()); } public static AAISimplePluralUri createResourceUri(AAIFluentPluralType uri) { - return new AAISimplePluralUri(uri.build()); + return new AAISimplePluralUri(uri.build(), uri.values()); } diff --git a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/entities/uri/AllottedResourceLookupUri.java b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/entities/uri/AllottedResourceLookupUri.java index 7f51835580..099f717238 100644 --- a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/entities/uri/AllottedResourceLookupUri.java +++ b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/entities/uri/AllottedResourceLookupUri.java @@ -25,22 +25,25 @@ import java.util.Optional; import javax.ws.rs.core.UriBuilder; import org.onap.aaiclient.client.aai.AAIObjectType; import org.onap.aaiclient.client.aai.AAIResourcesClient; +import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder; public class AllottedResourceLookupUri extends HttpLookupUri { private static final long serialVersionUID = -9212594383876793188L; - protected AllottedResourceLookupUri(Object... values) { - super(AAIObjectType.ALLOTTED_RESOURCE, values); + protected AllottedResourceLookupUri(AAIObjectType type, UriBuilder builder, Optional<String> cachedValue, + Object... values) { + super(type, builder, cachedValue, values); } - protected AllottedResourceLookupUri(UriBuilder builder, Optional<String> cachedValue, Object... values) { - super(AAIObjectType.ALLOTTED_RESOURCE, builder, cachedValue, values); + protected AllottedResourceLookupUri(AAISingleFragment fragment) { + super(AAIFluentTypeBuilder.business().customer("").serviceSubscription("").serviceInstance("") + .allottedResource("").build(), fragment.get().values()); } @Override public AllottedResourceLookupUri clone() { - return new AllottedResourceLookupUri(this.internalURI.clone(), this.getCachedValue(), values); + return new AllottedResourceLookupUri(this.aaiType, this.internalURI.clone(), this.getCachedValue(), values); } public AAIResourcesClient getResourcesClient() { diff --git a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/entities/uri/HttpLookupUri.java b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/entities/uri/HttpLookupUri.java index c39eb50dc2..42f52565cd 100644 --- a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/entities/uri/HttpLookupUri.java +++ b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/entities/uri/HttpLookupUri.java @@ -45,7 +45,7 @@ import com.fasterxml.jackson.databind.ObjectMapper; public abstract class HttpLookupUri extends AAISimpleUri implements HttpAwareUri { private transient Optional<String> cachedValue = Optional.empty(); - private final AAIObjectType aaiType; + protected final AAIObjectType aaiType; protected HttpLookupUri(AAIObjectType type, Object... values) { super(type, values); diff --git a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/entities/uri/ServiceInstanceUri.java b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/entities/uri/ServiceInstanceUri.java index 96eaac5815..366a011b14 100644 --- a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/entities/uri/ServiceInstanceUri.java +++ b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/entities/uri/ServiceInstanceUri.java @@ -25,22 +25,25 @@ import java.util.Optional; import javax.ws.rs.core.UriBuilder; import org.onap.aaiclient.client.aai.AAIObjectType; import org.onap.aaiclient.client.aai.AAIResourcesClient; +import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder; public class ServiceInstanceUri extends HttpLookupUri { private static final long serialVersionUID = 2248914170527514548L; - protected ServiceInstanceUri(Object... values) { - super(AAIObjectType.SERVICE_INSTANCE, values); + protected ServiceInstanceUri(AAIObjectType type, UriBuilder builder, Optional<String> cachedValue, + Object... values) { + super(type, builder, cachedValue, values); } - protected ServiceInstanceUri(UriBuilder builder, Optional<String> cachedValue, Object... values) { - super(AAIObjectType.SERVICE_INSTANCE, builder, cachedValue, values); + protected ServiceInstanceUri(AAISingleFragment fragment) { + super(AAIFluentTypeBuilder.business().customer("").serviceSubscription("").serviceInstance("").build(), + fragment.get().values()); } @Override public ServiceInstanceUri clone() { - return new ServiceInstanceUri(this.internalURI.clone(), this.getCachedValue(), values); + return new ServiceInstanceUri(this.aaiType, this.internalURI.clone(), this.getCachedValue(), values); } public AAIResourcesClient getResourcesClient() { |