1 /*******************************************************************************
\r
2 * ============LICENSE_START====================================================
\r
4 * * ===========================================================================
\r
5 * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
\r
6 * * ===========================================================================
\r
7 * * Licensed under the Apache License, Version 2.0 (the "License");
\r
8 * * you may not use this file except in compliance with the License.
\r
9 * * You may obtain a copy of the License at
\r
11 * * http://www.apache.org/licenses/LICENSE-2.0
\r
13 * * Unless required by applicable law or agreed to in writing, software
\r
14 * * distributed under the License is distributed on an "AS IS" BASIS,
\r
15 * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
16 * * See the License for the specific language governing permissions and
\r
17 * * limitations under the License.
\r
18 * * ============LICENSE_END====================================================
\r
20 * * ECOMP is a trademark and service mark of AT&T Intellectual Property.
\r
22 ******************************************************************************/
\r
23 package com.att.cadi.http;
\r
25 import java.net.HttpURLConnection;
\r
26 import java.net.URI;
\r
27 import java.net.URISyntaxException;
\r
29 import com.att.aft.dme2.api.DME2Exception;
\r
30 import com.att.cadi.CadiException;
\r
31 import com.att.cadi.LocatorException;
\r
32 import com.att.cadi.SecuritySetter;
\r
33 import com.att.cadi.Locator.Item;
\r
34 import com.att.cadi.client.EClient;
\r
35 import com.att.cadi.client.Rcli;
\r
36 import com.att.inno.env.APIException;
\r
37 import com.att.inno.env.Data.TYPE;
\r
40 * DME2 Rosetta Client
\r
42 * JAXB defined JSON or XML over DME2 middleware
\r
47 public class HRcli extends Rcli<HttpURLConnection> {
\r
48 private HMangr hman;
\r
50 private SecuritySetter<HttpURLConnection> ss;
\r
52 public HRcli(HMangr hman, Item locItem, SecuritySetter<HttpURLConnection> secSet) throws URISyntaxException, LocatorException {
\r
54 uri=hman.loc.get(locItem);
\r
58 apiVersion = hman.apiVersion();
\r
61 public HRcli(HMangr hman, URI uri, Item locItem, SecuritySetter<HttpURLConnection> secSet) {
\r
67 apiVersion = hman.apiVersion();
\r
71 protected HRcli clone(URI uri, SecuritySetter<HttpURLConnection> ss) {
\r
72 return new HRcli(hman,uri,item,ss);
\r
78 * Note from Thaniga on 11/5. DME2Client is not expected to be reused... need a fresh one
\r
79 * on each transaction, which is expected to cover the Async aspects.
\r
82 * @throws APIException
\r
83 * @throws DME2Exception
\r
85 protected EClient<HttpURLConnection> client() throws CadiException {
\r
88 Item item = hman.loc.best();
\r
90 throw new CadiException("No service available for " + hman.loc.toString());
\r
92 uri = hman.loc.get(item);
\r
94 return new HClient(ss,uri,connectionTimeout);
\r
95 } catch (Exception e) {
\r
96 throw new CadiException(e);
\r
101 * @see com.att.cadi.client.Rcli#setSecuritySetter(com.att.cadi.SecuritySetter)
\r
104 public void setSecuritySetter(SecuritySetter<HttpURLConnection> ss) {
\r
109 * @see com.att.cadi.client.Rcli#getSecuritySetter()
\r
112 public SecuritySetter<HttpURLConnection> getSecuritySetter() {
\r
116 public void invalidate() throws CadiException {
\r
118 hman.loc.invalidate(item);
\r
119 } catch (Exception e) {
\r
120 throw new CadiException(e);
\r
124 public HRcli setManager(HMangr hman) {
\r
129 public String toString() {
\r
130 return uri.toString();
\r