[AAI] Fix doc config files
[aai/aai-common.git] / aai-core / src / main / java / org / onap / aai / util / RestController.java
1 /**
2  * ============LICENSE_START=======================================================
3  * org.onap.aai
4  * ================================================================================
5  * Copyright © 2017-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
10  *
11  *    http://www.apache.org/licenses/LICENSE-2.0
12  *
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=========================================================
19  */
20
21 package org.onap.aai.util;
22
23 import org.slf4j.Logger;
24 import org.slf4j.LoggerFactory;
25 import com.fasterxml.jackson.databind.ObjectMapper;
26 import com.fasterxml.jackson.databind.type.TypeFactory;
27 import com.sun.jersey.api.client.Client;
28 import com.sun.jersey.api.client.ClientHandlerException;
29 import com.sun.jersey.api.client.ClientResponse;
30
31 import java.io.IOException;
32 import java.security.KeyManagementException;
33 import java.security.KeyStoreException;
34 import java.security.UnrecoverableKeyException;
35 import java.security.cert.CertificateException;
36 import java.security.NoSuchAlgorithmException;
37 import java.util.ArrayList;
38 import java.util.List;
39 import java.util.UUID;
40
41 import org.onap.aai.exceptions.AAIException;
42
43 public class RestController implements RestControllerInterface {
44
45     private static final String TARGET_NAME = "AAI";
46     private static final Logger LOGGER = LoggerFactory.getLogger(RestController.class);
47
48     private static Client client = null;
49
50     private String restSrvrBaseURL;
51
52     private String overrideLocalHost = null;
53
54     // To do - Come up with helper function that will automatically
55     // generate the REST API path based on path parameter(s) and query parameter(s)!
56     public static final String REST_APIPATH_COMPLEXES = "cloud-infrastructure/complexes";
57     public static final String REST_APIPATH_COMPLEX = "cloud-infrastructure/complexes/complex/";
58     public static final String REST_APIPATH_PSERVERS = "cloud-infrastructure/pservers";
59     public static final String REST_APIPATH_PSERVER = "cloud-infrastructure/pservers/pserver/";
60     public static final String REST_APIPATH_PHYSICALLINKS = "network/physical-links/";
61     public static final String REST_APIPATH_PHYSICALLINK = "network/physical-links/physical-link/";
62     public static final String REST_APIPATH_PINTERFACES = "network/p-interfaces/";
63     public static final String REST_APIPATH_PINTERFACE = "network/p-interfaces/p-interface/";
64     public static final String REST_APIPATH_VPLSPES = "network/vpls-pes/";
65     public static final String REST_APIPATH_VPLSPE = "network/vpls-pes/vpls-pe/";
66     public static final String REST_APIPATH_UPDATE = "actions/update/";
67     public static final String REST_APIPATH_SEARCH = "search/nodes-query?search-node-type=";
68
69     public static final String REST_APIPATH_CLOUDREGION = "cloud-infrastructure/cloud-regions/cloud-region/";
70     public static final String REST_APIPATH_TENANT = "cloud-infrastructure/tenants/tenant/";
71     public static final String REST_APIPATH_VIRTUAL_DATA_CENTER =
72             "cloud-infrastructure/virtual-data-centers/virtual-data-center/";
73     public static final String REST_APIPATH_VIRTUAL_DATA_CENTERS = "cloud-infrastructure/virtual-data-centers/";
74     public static final String REST_APIPATH_GENERIC_VNF = "network/generic-vnfs/generic-vnf/";
75     public static final String REST_APIPATH_GENERIC_VNFS = "network/generic-vnfs";
76     public static final String REST_APIPATH_L3_NETWORK = "network/l3-networks/l3-network/";
77     public static final String REST_APIPATH_L3_NETWORKS = "network/l3-networks";
78     public static final String REST_APIPATH_INSTANCE_GROUP = "network/instance-groups/instance-group";
79     public static final String REST_APIPATH_INSTANCE_GROUPS = "network/instance-groups";
80     public static final String REST_APIPATH_VFMODULE = "nodes/vf-modules/vf-module/";
81
82     public static final String REST_APIPATH_VCE = "network/vces/vce/";
83
84     public static final String REST_APIPATH_SERVICE = "service-design-and-creation/services/service/";
85     public static final String REST_APIPATH_LOGICALLINKS = "network/logical-links/";
86     public static final String REST_APIPATH_LOGICALLINK = "network/logical-links/logical-link/";
87
88     public RestController(String truststorePath, String truststorePassword, String keystorePath, String keystorePassword) throws AAIException {
89         this.initRestClient(truststorePath, truststorePassword, keystorePath, keystorePassword);
90     }
91     /**
92      * Inits the rest client.
93      *
94      * @throws AAIException the AAI exception
95      */
96     public void initRestClient(String truststorePath, String truststorePassword, String keystorePath, String keystorePassword) throws AAIException {
97         if (client == null) {
98             try {
99                 client = getHttpsAuthClient(truststorePath, truststorePassword, keystorePath, keystorePassword);
100             } catch (KeyManagementException e) {
101                 throw new AAIException("AAI_7117", "KeyManagementException in REST call to DB: " + e.toString());
102             } catch (Exception e) {
103                 throw new AAIException("AAI_7117", " Exception in REST call to DB: " + e.toString());
104             }
105         }
106     }
107     public Client getHttpsAuthClient(String truststorePath, String truststorePassword, String keystorePath, String keystorePassword) throws KeyManagementException, UnrecoverableKeyException, CertificateException, NoSuchAlgorithmException, KeyStoreException, IOException {
108         return HttpsAuthClient.getClient(truststorePath, truststorePassword, keystorePath, keystorePassword);
109     }
110
111     public Client getHttpsAuthClient() throws KeyManagementException, UnrecoverableKeyException, CertificateException, NoSuchAlgorithmException, KeyStoreException, IOException, AAIException {
112         return HttpsAuthClient.getClient();
113     }
114     /**
115      * Sets the rest srvr base URL.
116      *
117      * @param baseURL the base URL
118      * @throws AAIException the AAI exception
119      */
120     public void SetRestSrvrBaseURL(String baseURL) throws AAIException {
121         if (baseURL == null)
122             throw new AAIException("AAI_7117", "REST Server base URL cannot be null.");
123         restSrvrBaseURL = baseURL;
124     }
125
126     /**
127      * Gets the rest srvr base URL.
128      *
129      * @return the rest srvr base URL
130      */
131     public String getRestSrvrBaseURL() {
132         return restSrvrBaseURL;
133     }
134
135     public <T> void Get(T t, String sourceID, String transId, String path, RestObject<T> restObject, boolean oldserver)
136             throws AAIException {
137         Get(t, sourceID, transId, path, restObject, oldserver, AAIConstants.AAI_RESOURCES_PORT);
138     }
139
140     /**
141      * To do - optimization and automation. Also make it as generic as possible.
142      *
143      * @param <T> the generic type
144      * @param t the t
145      * @param sourceID the source ID
146      * @param transId the trans id
147      * @param path the path
148      * @param restObject the rest object
149      * @param oldserver the oldserver
150      * @throws AAIException the AAI exception
151      */
152     @SuppressWarnings("unchecked")
153     public <T> void Get(T t, String sourceID, String transId, String path, RestObject<T> restObject, boolean oldserver,
154             int port) throws AAIException {
155         String methodName = "Get";
156         String url = "";
157         transId += ":" + UUID.randomUUID().toString();
158
159         LOGGER.debug(methodName + " start");
160
161         restObject.set(t);
162
163         if (oldserver) {
164             url = AAIConfig.get(AAIConstants.AAI_OLDSERVER_URL) + path;
165         } else {
166             if (overrideLocalHost == null) {
167                 overrideLocalHost =
168                         AAIConfig.get(AAIConstants.AAI_LOCAL_OVERRIDE, AAIConstants.AAI_LOCAL_OVERRIDE_DEFAULT);
169             }
170             if (AAIConstants.AAI_LOCAL_OVERRIDE_DEFAULT.equals(overrideLocalHost)) {
171                 url = String.format(AAIConstants.AAI_LOCAL_REST, port,
172                         AAIConfig.get(AAIConstants.AAI_DEFAULT_API_VERSION_PROP)) + path;
173             } else {
174                 url = String.format(AAIConstants.AAI_LOCAL_REST_OVERRIDE, overrideLocalHost,
175                         AAIConfig.get(AAIConstants.AAI_DEFAULT_API_VERSION_PROP)) + path;
176             }
177         }
178         LOGGER.debug(url + " for the get REST API");
179         ClientResponse cres = client.resource(url).accept("application/json").header("X-TransactionId", transId)
180                 .header("X-FromAppId", sourceID).header("Real-Time", "true").type("application/json")
181                 .get(ClientResponse.class);
182
183         // System.out.println("cres.EntityInputSream()="+cres.getEntityInputStream().toString());
184         // System.out.println("cres.tostring()="+cres.toString());
185
186         if (cres.getStatus() == 200) {
187             // System.out.println(methodName + ": url=" + url);
188             t = (T) cres.getEntity(t.getClass());
189             restObject.set(t);
190             LOGGER.debug(methodName + "REST api GET was successfull!");
191         } else {
192             // System.out.println(methodName + ": url=" + url + " failed with status=" + cres.getStatus());
193             throw new AAIException("AAI_7116", methodName + " with status=" + cres.getStatus() + ", url=" + url);
194         }
195     }
196
197     /**
198      * To do - optimization and automation. Also make it as generic as possible.
199      *
200      * @param <T> the generic type
201      * @param t the t
202      * @param sourceID the source ID
203      * @param transId the trans id
204      * @param path the path
205      * @param restObject the rest object
206      * @param oldserver the oldserver
207      * @throws AAIException the AAI exception
208      */
209     @SuppressWarnings("unchecked")
210     public <T> void Get(T t, String sourceID, String transId, String path, RestObject<T> restObject, String apiVersion)
211             throws AAIException {
212         String methodName = "Get";
213         String url = "";
214         transId += ":" + UUID.randomUUID().toString();
215
216         LOGGER.debug(methodName + " start");
217
218         restObject.set(t);
219
220         url = AAIConfig.get(AAIConstants.AAI_SERVER_URL_BASE) + apiVersion + "/" + path;
221
222         LOGGER.debug(url + " for the get REST API");
223         ClientResponse cres = client.resource(url).accept("application/json").header("X-TransactionId", transId)
224                 .header("X-FromAppId", sourceID).header("Real-Time", "true").type("application/json")
225                 .get(ClientResponse.class);
226
227         // System.out.println("cres.EntityInputSream()="+cres.getEntityInputStream().toString());
228         // System.out.println("cres.tostring()="+cres.toString());
229
230         if (cres.getStatus() == 200) {
231             // System.out.println(methodName + ": url=" + url);
232             t = (T) cres.getEntity(t.getClass());
233             restObject.set(t);
234             LOGGER.debug(methodName + "REST api GET was successfull!");
235         } else {
236             // System.out.println(methodName + ": url=" + url + " failed with status=" + cres.getStatus());
237             throw new AAIException("AAI_7116", methodName + " with status=" + cres.getStatus() + ", url=" + url);
238         }
239     }
240
241     /**
242      * Map json to object list.
243      *
244      * @param <T> the generic type
245      * @param typeDef the type def
246      * @param json the json
247      * @param clazz the clazz
248      * @return the list
249      * @throws Exception the exception
250      */
251     private <T> List<T> mapJsonToObjectList(T typeDef, String json, Class clazz) throws Exception {
252         List<T> list;
253         ObjectMapper mapper = new ObjectMapper();
254         System.out.println(json);
255         TypeFactory t = TypeFactory.defaultInstance();
256         list = mapper.readValue(json, t.constructCollectionType(ArrayList.class, clazz));
257
258         return list;
259     }
260
261     /**
262      * Put.
263      *
264      * @param <T> the generic type
265      * @param t the t
266      * @param sourceID the source ID
267      * @param transId the trans id
268      * @param path the path
269      * @throws AAIException the AAI exception
270      */
271     public <T> void Put(T t, String sourceID, String transId, String path) throws AAIException {
272         Put(t, sourceID, transId, path, false, AAIConstants.AAI_RESOURCES_PORT);
273     }
274
275     /**
276      * Put.
277      *
278      * @param <T> the generic type
279      * @param t the t
280      * @param sourceID the source ID
281      * @param transId the trans id
282      * @param path the path
283      * @throws AAIException the AAI exception
284      */
285     public <T> void Put(T t, String sourceID, String transId, String path, boolean oldserver) throws AAIException {
286         Put(t, sourceID, transId, path, oldserver, AAIConstants.AAI_RESOURCES_PORT);
287     }
288
289     /**
290      * Put.
291      *
292      * @param <T> the generic type
293      * @param t the t
294      * @param sourceID the source ID
295      * @param transId the trans id
296      * @param path the path
297      * @param oldserver the oldserver
298      * @throws AAIException the AAI exception
299      */
300     public <T> void Put(T t, String sourceID, String transId, String path, boolean oldserver, int port)
301             throws AAIException {
302         String methodName = "Put";
303         String url = "";
304         transId += ":" + UUID.randomUUID().toString();
305
306         LOGGER.debug(methodName + " start");
307
308         if (oldserver) {
309             url = AAIConfig.get(AAIConstants.AAI_OLDSERVER_URL) + path;
310         } else {
311             if (overrideLocalHost == null) {
312                 overrideLocalHost =
313                         AAIConfig.get(AAIConstants.AAI_LOCAL_OVERRIDE, AAIConstants.AAI_LOCAL_OVERRIDE_DEFAULT);
314             }
315             if (AAIConstants.AAI_LOCAL_OVERRIDE_DEFAULT.equals(overrideLocalHost)) {
316                 url = String.format(AAIConstants.AAI_LOCAL_REST, port,
317                         AAIConfig.get(AAIConstants.AAI_DEFAULT_API_VERSION_PROP)) + path;
318             } else {
319                 url = String.format(AAIConstants.AAI_LOCAL_REST_OVERRIDE, overrideLocalHost,
320                         AAIConfig.get(AAIConstants.AAI_DEFAULT_API_VERSION_PROP)) + path;
321             }
322         }
323
324         ClientResponse cres = client.resource(url).accept("application/json").header("X-TransactionId", transId)
325                 .header("X-FromAppId", sourceID).header("Real-Time", "true").type("application/json").entity(t)
326                 .put(ClientResponse.class);
327
328         // System.out.println("cres.tostring()="+cres.toString());
329
330         int statuscode = cres.getStatus();
331         if (statuscode >= 200 && statuscode <= 299) {
332             LOGGER.debug(methodName + ": url=" + url + ", request=" + path);
333         } else {
334             throw new AAIException("AAI_7116", methodName + " with status=" + statuscode + ", url=" + url + ", msg="
335                     + cres.getEntity(String.class));
336         }
337     }
338     
339     /**
340      * Put.
341      *
342      * @param <T> the generic type
343      * @param t the t
344      * @param sourceID the source ID
345      * @param transId the trans id
346      * @param path the path
347      * @param apiVersion version number
348      * @throws AAIException the AAI exception
349      */
350     public <T> void Put(T t, String sourceID, String transId, String path, String apiVersion)
351             throws AAIException {
352         String methodName = "Put";
353         String url = "";
354         transId += ":" + UUID.randomUUID().toString();
355
356         LOGGER.debug(methodName + " start");
357         
358         url = AAIConfig.get(AAIConstants.AAI_SERVER_URL_BASE) + apiVersion + "/" + path;
359
360         ClientResponse cres = client.resource(url).accept("application/json").header("X-TransactionId", transId)
361                 .header("X-FromAppId", sourceID).header("Real-Time", "true").type("application/json").entity(t)
362                 .put(ClientResponse.class);
363
364         // System.out.println("cres.tostring()="+cres.toString());
365
366         int statuscode = cres.getStatus();
367         if (statuscode >= 200 && statuscode <= 299) {
368             LOGGER.debug(methodName + ": url=" + url + ", request=" + path);
369         } else {
370             throw new AAIException("AAI_7116", methodName + " with status=" + statuscode + ", url=" + url + ", msg="
371                     + cres.getEntity(String.class));
372         }
373     }
374
375     public void Delete(String sourceID, String transId, String path) throws AAIException {
376         Delete(sourceID, transId, path, AAIConstants.AAI_RESOURCES_PORT);
377     }
378
379     /**
380      * Delete.
381      *
382      * @param sourceID the source ID
383      * @param transId the trans id
384      * @param path the path
385      * @throws AAIException the AAI exception
386      */
387     public void Delete(String sourceID, String transId, String path, int port) throws AAIException {
388         String methodName = "Delete";
389         String url = "";
390         transId += ":" + UUID.randomUUID().toString();
391
392         LOGGER.debug(methodName + " start");
393
394         String request = "{}";
395         if (overrideLocalHost == null) {
396             overrideLocalHost = AAIConfig.get(AAIConstants.AAI_LOCAL_OVERRIDE, AAIConstants.AAI_LOCAL_OVERRIDE_DEFAULT);
397         }
398         if (AAIConstants.AAI_LOCAL_OVERRIDE_DEFAULT.equals(overrideLocalHost)) {
399             url = String.format(AAIConstants.AAI_LOCAL_REST, port,
400                     AAIConfig.get(AAIConstants.AAI_DEFAULT_API_VERSION_PROP)) + path;
401         } else {
402             url = String.format(AAIConstants.AAI_LOCAL_REST_OVERRIDE, overrideLocalHost,
403                     AAIConfig.get(AAIConstants.AAI_DEFAULT_API_VERSION_PROP)) + path;
404         }
405         ClientResponse cres = client.resource(url).accept("application/json").header("X-TransactionId", transId)
406                 .header("X-FromAppId", sourceID).header("Real-Time", "true").type("application/json").entity(request)
407                 .delete(ClientResponse.class);
408
409         if (cres.getStatus() == 404) { // resource not found
410             LOGGER.info("Resource does not exist...: " + cres.getStatus() + ":" + cres.getEntity(String.class));
411         } else if (cres.getStatus() == 200 || cres.getStatus() == 204) {
412             LOGGER.info("Resource " + url + " deleted");
413         } else {
414             LOGGER.error("Deleting Resource failed: " + cres.getStatus() + ":" + cres.getEntity(String.class));
415             throw new AAIException("AAI_7116", "Error during DELETE");
416         }
417     }
418
419     public <T> String Post(T t, String sourceID, String transId, String path) throws Exception {
420         return Post(t, sourceID, transId, path, AAIConfig.get(AAIConstants.AAI_DEFAULT_API_VERSION_PROP));
421     }
422
423     /**
424      * Post.
425      *
426      * @param <T> the generic type
427      * @param t the t
428      * @param sourceID the source ID
429      * @param transId the trans id
430      * @param path the path
431      * @param apiVersion the apiVersion
432      * @return the string
433      * @throws Exception the exception
434      */
435     public <T> String Post(T t, String sourceID, String transId, String path, String apiVersion) throws Exception {
436         String methodName = "Post";
437         String url = "";
438         transId += ":" + UUID.randomUUID().toString();
439
440         LOGGER.debug(methodName + " start");
441
442         try {
443
444             url = AAIConfig.get(AAIConstants.AAI_SERVER_URL_BASE) + apiVersion + "/" + path;
445
446             ClientResponse cres = client.resource(url).accept("application/json").header("X-TransactionId", transId)
447                     .header("X-FromAppId", sourceID).header("Real-Time", "true").type("application/json").entity(t)
448                     .post(ClientResponse.class);
449
450             int statuscode = cres.getStatus();
451             if (statuscode >= 200 && statuscode <= 299) {
452                 LOGGER.debug(methodName + "REST api POST was successful!");
453                 return cres.getEntity(String.class);
454             } else {
455                 throw new AAIException("AAI_7116", methodName + " with status=" + statuscode + ", url=" + url + ", msg="
456                         + cres.getEntity(String.class));
457             }
458
459         } catch (AAIException e) {
460             throw new AAIException("AAI_7116", methodName + " with url=" + url + ", Exception: " + e.toString());
461         } catch (Exception e) {
462             throw new AAIException("AAI_7116", methodName + " with url=" + url + ", Exception: " + e.toString());
463
464         } finally {
465         }
466     }
467
468     /**
469      * Gets the single instance of RestController.
470      *
471      * @param <T> the generic type
472      * @param clazz the clazz
473      * @return single instance of RestController
474      * @throws IllegalAccessException the illegal access exception
475      * @throws InstantiationException the instantiation exception
476      */
477     public <T> T getInstance(Class<T> clazz) throws IllegalAccessException, InstantiationException {
478         return clazz.newInstance();
479     }
480
481     /**
482      * Does resource exist.
483      *
484      * @param <T> the generic type
485      * @param resourcePath the resource path
486      * @param resourceClassName the resource class name
487      * @param fromAppId the from app id
488      * @param transId the trans id
489      * @return the t
490      */
491     /*
492      * DoesResourceExist
493      * 
494      * To check whether a resource exist or get a copy of the existing version of the resource
495      * 
496      * Resourcepath: should contain the qualified resource path (including encoded unique key identifier value),
497      * resourceClassName: is the canonical name of the resource class name,
498      * fromAppId:
499      * transId:
500      * 
501      * Will return null (if the resource doesn’t exist) (or)
502      * Will return the specified resource from the Graph.
503      * 
504      * Example:
505      * LogicalLink llink = new LogicalLink();
506      * String resourceClassName = llink.getClass().getCanonicalName();
507      * llink = RestController.DoesResourceExist("network/logical-links/logical-link/" + <encoded-link-name>,
508      * resourceClassName, fromAppId, transId);
509      */
510     public <T> T DoesResourceExist(String resourcePath, String resourceClassName, String fromAppId, String transId) {
511
512         try {
513
514             RestObject<T> restObj = new RestObject<T>();
515             @SuppressWarnings("unchecked")
516             T resourceObj = (T) getInstance(Class.forName(resourceClassName));
517             restObj.set(resourceObj);
518             Get(resourceObj, fromAppId, transId, resourcePath, restObj, false, AAIConstants.AAI_RESOURCES_PORT);
519
520             resourceObj = restObj.get();
521             if (resourceObj != null)
522                 return resourceObj;
523
524         } catch (AAIException e) {
525
526         } catch (ClientHandlerException che) {
527
528         } catch (Exception e) {
529
530         }
531
532         return null;
533     }
534
535     /**
536      * Patch.
537      *
538      * @param <T> the generic type
539      * @param sourceID the source ID
540      * @param transId the trans id
541      * @param path the path
542      * @throws AAIException the AAI exception
543      */
544     public <T> void Patch(T t, String sourceID, String transId, String path) throws AAIException {
545         String methodName = "Patch";
546         String url = "";
547         transId += ":" + UUID.randomUUID().toString();
548
549         int numRetries = 5;
550         ClientResponse cres = null;
551         int statusCode = -1;
552
553         try {
554             if (overrideLocalHost == null) {
555                 overrideLocalHost =
556                         AAIConfig.get(AAIConstants.AAI_LOCAL_OVERRIDE, AAIConstants.AAI_LOCAL_OVERRIDE_DEFAULT);
557             }
558             if (AAIConstants.AAI_LOCAL_OVERRIDE_DEFAULT.equals(overrideLocalHost)) {
559                 url = String.format(AAIConstants.AAI_LOCAL_REST, AAIConstants.AAI_RESOURCES_PORT,
560                         AAIConfig.get(AAIConstants.AAI_DEFAULT_API_VERSION_PROP)) + path;
561             } else {
562                 url = String.format(AAIConstants.AAI_LOCAL_REST_OVERRIDE, overrideLocalHost,
563                         AAIConfig.get(AAIConstants.AAI_DEFAULT_API_VERSION_PROP)) + path;
564             }
565
566             do {
567
568                 cres = client.resource(url).accept("application/json").header("X-TransactionId", transId)
569                         .header("X-FromAppId", sourceID).header("X-HTTP-Method-Override", "PATCH")
570                         .type("application/merge-patch+json").entity(t).post(ClientResponse.class);
571
572                 statusCode = cres.getStatus();
573
574                 if (statusCode >= 200 && statusCode <= 299) {
575                     LOGGER.debug(methodName + "REST api PATCH was successful!");
576                     return;
577                 } else {
578                     LOGGER.debug(methodName + "Unable to make the patch request to url " + url + " so retrying");
579                 }
580
581                 numRetries--;
582
583             } while (numRetries >= 0);
584
585             LOGGER.debug(methodName + "Unable to make the patch request to url " + url + " even after trying = "
586                     + numRetries + " times.");
587             throw new AAIException("AAI_7116", methodName + " with status=" + statusCode + ", url=" + url + ", msg="
588                     + cres.getEntity(String.class));
589
590         } catch (AAIException e) {
591             throw new AAIException("AAI_7116", methodName + " with url=" + url + ", Exception: " + e.toString());
592         } catch (Exception e) {
593             throw new AAIException("AAI_7116", methodName + " with url=" + url + ", Exception: " + e.toString());
594
595         } finally {
596         }
597
598     }
599 }