diff options
Diffstat (limited to 'common/src/main/java/org/onap/so/client/aai/AAIClient.java')
-rw-r--r-- | common/src/main/java/org/onap/so/client/aai/AAIClient.java | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/common/src/main/java/org/onap/so/client/aai/AAIClient.java b/common/src/main/java/org/onap/so/client/aai/AAIClient.java new file mode 100644 index 0000000000..39843b2263 --- /dev/null +++ b/common/src/main/java/org/onap/so/client/aai/AAIClient.java @@ -0,0 +1,62 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.client.aai; + +import java.net.URI; + +import javax.ws.rs.core.UriBuilder; + +import org.onap.so.client.RestClient; +import org.onap.so.client.graphinventory.GraphInventoryClient; +import org.onap.so.client.graphinventory.entities.uri.GraphInventoryUri; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public abstract class AAIClient extends GraphInventoryClient { + + private static final String AAI_ROOT = "/aai"; + protected static Logger logger = LoggerFactory.getLogger(AAIClient.class); + protected AAIVersion version; + public AAIClient() { + super(AAIProperties.class); + } + + public AAIClient(AAIVersion version) { + super(AAIProperties.class); + } + @Override + protected URI constructPath(GraphInventoryUri uri) { + + return UriBuilder.fromUri(AAI_ROOT + "/" + this.getVersion().toString() + uri.build().toString()).build(); + } + @Override + protected RestClient createClient(GraphInventoryUri uri) { + return new AAIRestClient(getRestProperties(), constructPath(uri)); + } + + protected AAIVersion getVersion() { + if (version == null) { + return this.<AAIProperties>getRestProperties().getDefaultVersion(); + } else { + return this.version; + } + } +} |