2 * ============LICENSE_START====================================================
4 * ===========================================================================
5 * Copyright (c) 2018 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====================================================
22 package org.onap.aaf.cadi.http;
24 import java.net.HttpURLConnection;
26 import java.net.URISyntaxException;
28 import org.onap.aaf.cadi.CadiException;
29 import org.onap.aaf.cadi.LocatorException;
30 import org.onap.aaf.cadi.SecuritySetter;
31 import org.onap.aaf.cadi.Locator.Item;
32 import org.onap.aaf.cadi.client.EClient;
33 import org.onap.aaf.cadi.client.Rcli;
34 import org.onap.aaf.misc.env.APIException;
35 import org.onap.aaf.misc.env.Data.TYPE;
40 * JAXB defined JSON or XML over HTTP/S
46 public class HRcli extends Rcli<HttpURLConnection> {
49 private SecuritySetter<HttpURLConnection> ss;
51 public HRcli(HMangr hman, Item locItem, SecuritySetter<HttpURLConnection> secSet) throws URISyntaxException, LocatorException {
53 uri=hman.loc.get(locItem);
57 apiVersion = hman.apiVersion();
60 public HRcli(HMangr hman, URI uri, Item locItem, SecuritySetter<HttpURLConnection> secSet) {
66 apiVersion = hman.apiVersion();
70 protected HRcli clone(URI uri, SecuritySetter<HttpURLConnection> ss) {
71 return new HRcli(hman,uri,item,ss);
79 * @throws APIException
80 * @throws DME2Exception
82 protected EClient<HttpURLConnection> client() throws CadiException {
85 Item item = hman.loc.best();
87 throw new CadiException("No service available for " + hman.loc.toString());
89 uri = hman.loc.get(item);
91 return new HClient(ss,uri,connectionTimeout);
92 } catch (Exception e) {
93 throw new CadiException(e);
98 * @see org.onap.aaf.cadi.client.Rcli#setSecuritySetter(org.onap.aaf.cadi.SecuritySetter)
101 public void setSecuritySetter(SecuritySetter<HttpURLConnection> ss) {
106 * @see org.onap.aaf.cadi.client.Rcli#getSecuritySetter()
109 public SecuritySetter<HttpURLConnection> getSecuritySetter() {
113 public void invalidate() throws CadiException {
115 hman.loc.invalidate(item);
116 } catch (Exception e) {
117 throw new CadiException(e);
121 public HRcli setManager(HMangr hman) {
126 public String toString() {
127 return uri.toString();