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.client.test;
\r
26 import java.net.URI;
\r
27 import java.util.Properties;
\r
29 import com.att.aft.dme2.api.DME2Client;
\r
30 import com.att.aft.dme2.api.DME2Manager;
\r
32 public class BasicDME2Client {
\r
33 public static void main(String[] args) {
\r
35 Properties props = System.getProperties();
\r
37 DME2Manager dm = new DME2Manager("DME2Manager TestBasicDME2Client",props);
\r
38 URI uri = new URI(System.getProperty("aaf_url"));
\r
39 DME2Client client = new DME2Client(dm,uri,3000);
\r
41 System.out.println(props.getProperty("aaf_id"));
\r
42 client.setCredentials(props.getProperty("aaf_id"),props.getProperty("aaf_password"));
\r
44 String path = String.format("/authz/perms/user/%s@csp.att.com",args.length>0?args[0]:"xx9999");
\r
45 System.out.printf("Path: %s\n",path);
\r
46 client.addHeader("Accept", "application/Perms+json;q=1.0;charset=utf-8;version=2.0,application/json;q=1.0;version=2.0,*");
\r
47 client.setMethod("GET");
\r
48 client.setContext(path);
\r
49 client.setPayload("");// Note: Even on "GET", you need a String in DME2
\r
51 String o = client.sendAndWait(5000); // There are other Asynchronous call options, see DME2 Docs
\r
53 System.out.println('[' + o + ']' + " (blank is good)");
\r
57 } catch (Exception e) {
\r
58 e.printStackTrace();
\r