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.openecomp.mso.client.aai;
24 import java.util.UUID;
26 import javax.ws.rs.core.UriBuilder;
28 import org.openecomp.mso.client.RestPropertiesLoader;
29 import org.openecomp.mso.client.aai.entities.uri.AAIUri;
30 import org.openecomp.mso.client.defaultproperties.DefaultAAIPropertiesImpl;
31 import org.openecomp.mso.client.policy.RestClient;
33 import com.att.eelf.configuration.EELFLogger;
34 import com.att.eelf.configuration.EELFManager;
36 public abstract class AAIClient {
38 protected final AAIVersion defaultVersion;
39 private static final String AAI_ROOT = "/aai";
40 protected final EELFLogger metricsLogger = EELFManager.getInstance().getMetricsLogger();
41 private final AAIProperties properties;
42 protected final UUID requestId;
43 public AAIClient(UUID requestId) {
44 AAIProperties props = RestPropertiesLoader.getInstance().getNewImpl(AAIProperties.class);
46 metricsLogger.error("No RestProperty.AAIProperties implementation found on classpath");
47 props = new DefaultAAIPropertiesImpl();
49 this.properties = props;
50 this.defaultVersion = props.getDefaultVersion();
51 this.requestId = requestId;
53 protected URI constructPath(AAIUri uri) {
55 return UriBuilder.fromUri(AAI_ROOT + "/" + this.getVersion().toString() + uri.build().toString()).build();
58 protected RestClient createClient(AAIUri uri) {
59 return new AAIRestClient(properties, this.getRequestId(), constructPath(uri)).addRequestId(this.getRequestId());
63 protected UUID getRequestId() {
64 return this.requestId;
66 protected AAIVersion getVersion() {
67 return defaultVersion;