2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
21 package org.onap.so.client.aai;
24 import javax.ws.rs.NotFoundException;
25 import javax.ws.rs.core.UriBuilder;
26 import org.onap.so.client.RestClient;
27 import org.onap.so.client.graphinventory.GraphInventoryClient;
28 import org.onap.so.client.graphinventory.exceptions.GraphInventoryUriComputationException;
29 import org.slf4j.Logger;
30 import org.slf4j.LoggerFactory;
32 public class AAIClient extends GraphInventoryClient {
34 private static final String AAI_ROOT = "/aai";
35 protected static Logger logger = LoggerFactory.getLogger(AAIClient.class);
36 protected AAIVersion version;
38 protected AAIClient() {
39 super(AAIProperties.class);
42 protected AAIClient(AAIVersion version) {
43 super(AAIProperties.class);
44 this.version = version;
48 protected URI constructPath(URI uri) {
50 return UriBuilder.fromUri(AAI_ROOT + "/" + this.getVersion().toString() + uri.toString()).build();
54 protected RestClient createClient(URI uri) {
57 return new AAIRestClient(getRestProperties(), constructPath(uri));
58 } catch (GraphInventoryUriComputationException | NotFoundException e) {
59 logger.debug("failed to construct A&AI uri", e);
65 public AAIVersion getVersion() {
66 if (version == null) {
67 return this.<AAIProperties>getRestProperties().getDefaultVersion();
75 public String getGraphDBName() {