1 /*******************************************************************************
\r
2 * ============LICENSE_START====================================================
\r
4 * * ===========================================================================
\r
5 * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
\r
6 * * Copyright © 2017 Amdocs
\r
7 * * ===========================================================================
\r
8 * * Licensed under the Apache License, Version 2.0 (the "License");
\r
9 * * you may not use this file except in compliance with the License.
\r
10 * * You may obtain a copy of the License at
\r
12 * * http://www.apache.org/licenses/LICENSE-2.0
\r
14 * * Unless required by applicable law or agreed to in writing, software
\r
15 * * distributed under the License is distributed on an "AS IS" BASIS,
\r
16 * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
17 * * See the License for the specific language governing permissions and
\r
18 * * limitations under the License.
\r
19 * * ============LICENSE_END====================================================
\r
21 * * ECOMP is a trademark and service mark of AT&T Intellectual Property.
\r
23 ******************************************************************************/
\r
24 package com.att.cadi.http;
\r
26 import java.net.HttpURLConnection;
\r
27 import java.net.URI;
\r
28 import java.net.URISyntaxException;
\r
30 import com.att.aft.dme2.api.DME2Exception;
\r
31 import com.att.cadi.CadiException;
\r
32 import com.att.cadi.LocatorException;
\r
33 import com.att.cadi.SecuritySetter;
\r
34 import com.att.cadi.Locator.Item;
\r
35 import com.att.cadi.client.EClient;
\r
36 import com.att.cadi.client.Rcli;
\r
37 import com.att.inno.env.APIException;
\r
38 import com.att.inno.env.Data.TYPE;
\r
41 * DME2 Rosetta Client
\r
43 * JAXB defined JSON or XML over DME2 middleware
\r
48 public class HRcli extends Rcli<HttpURLConnection> {
\r
49 private HMangr hman;
\r
51 private SecuritySetter<HttpURLConnection> ss;
\r
53 public HRcli(HMangr hman, Item locItem, SecuritySetter<HttpURLConnection> secSet) throws URISyntaxException, LocatorException {
\r
55 uri=hman.loc.get(locItem);
\r
59 apiVersion = hman.apiVersion();
\r
62 public HRcli(HMangr hman, URI uri, Item locItem, SecuritySetter<HttpURLConnection> secSet) {
\r
68 apiVersion = hman.apiVersion();
\r
72 protected HRcli clone(URI uri, SecuritySetter<HttpURLConnection> ss) {
\r
73 return new HRcli(hman,uri,item,ss);
\r
79 * Note from Thaniga on 11/5. DME2Client is not expected to be reused... need a fresh one
\r
80 * on each transaction, which is expected to cover the Async aspects.
\r
83 * @throws APIException
\r
84 * @throws DME2Exception
\r
86 protected EClient<HttpURLConnection> client() throws CadiException {
\r
89 Item item = hman.loc.best();
\r
91 throw new CadiException("No service available for " + hman.loc.toString());
\r
93 uri = hman.loc.get(item);
\r
95 return new HClient(ss,uri,connectionTimeout);
\r
96 } catch (Exception e) {
\r
97 throw new CadiException(e);
\r
102 * @see com.att.cadi.client.Rcli#setSecuritySetter(com.att.cadi.SecuritySetter)
\r
105 public void setSecuritySetter(SecuritySetter<HttpURLConnection> ss) {
\r
110 * @see com.att.cadi.client.Rcli#getSecuritySetter()
\r
113 public SecuritySetter<HttpURLConnection> getSecuritySetter() {
\r
117 public void invalidate() throws CadiException {
\r
119 hman.loc.invalidate(item);
\r
120 } catch (Exception e) {
\r
121 throw new CadiException(e);
\r
125 public HRcli setManager(HMangr hman) {
\r
130 public String toString() {
\r
131 return uri.toString();
\r