2 * ============LICENSE_START=======================================================
\r
4 * ================================================================================
\r
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
\r
6 * Copyright (C) 2017 Huawei Technologies Co., Ltd. All rights reserved.
\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
22 package org.openecomp.mso.bpmn.common.scripts
\r
24 import static org.apache.commons.lang3.StringUtils.*
\r
26 import org.apache.commons.lang3.*
\r
27 import org.camunda.bpm.engine.delegate.BpmnError
\r
28 import org.camunda.bpm.engine.delegate.DelegateExecution
\r
29 import org.openecomp.mso.rest.APIResponse
\r
30 import org.springframework.web.util.UriUtils
\r
34 * This class supports the GenericGetService Sub Flow.
\r
35 * This Generic sub flow can be used by any flow for accomplishing
\r
36 * the goal of getting a Service-Instance or Service-Subscription (from AAI).
\r
37 * The calling flow must set the GENGS_type variable as "service-instance"
\r
38 * or "service-subscription".
\r
40 * When using to Get a Service-Instance:
\r
41 * If the global-customer-id and service-type are not provided
\r
42 * this flow executes a query to get the service- Url using the
\r
43 * Service Id or Name (whichever is provided).
\r
45 * When using to Get a Service-Subscription:
\r
46 * The global-customer-id and service-type must be
\r
49 * Upon successful completion of this sub flow the
\r
50 * GENGS_SuccessIndicator will be true and the query response payload
\r
51 * will be set to GENGS_service. An MSOWorkflowException will
\r
52 * be thrown upon unsuccessful completion or if an error occurs
\r
53 * at any time during this sub flow. Please map variables
\r
54 * to the corresponding variable names below.
\r
56 * Note - If this sub flow receives a Not Found (404) response
\r
57 * from AAI at any time this will be considered an acceptable
\r
58 * successful response however the GENGS_FoundIndicator
\r
59 * will be set to false. This variable will allow the calling flow
\r
60 * to distinguish between the two Success scenarios,
\r
61 * "Success where service- is found" and
\r
62 * "Success where service- is NOT found".
\r
65 * Variable Mapping Below:
\r
67 * In Mapping Variables:
\r
68 * For Allotted-Resource:
\r
69 * @param - GENGS_allottedResourceId
\r
70 * @param - GENGS_type
\r
71 * @param (Optional) - GENGS_serviceInstanceId
\r
72 * @param (Optional) - GENGS_serviceType
\r
73 * @param (Optional) - GENGS_globalCustomerId
\r
75 * For Service-Instance:
\r
76 * @param - GENGS_serviceInstanceId or @param - GENGS_serviceInstanceName
\r
77 * @param - GENGS_type
\r
78 * @param (Optional) - GENGS_serviceType
\r
79 * @param (Optional) - GENGS_globalCustomerId
\r
81 * For Service-Subscription:
\r
82 * @param - GENGS_type
\r
83 * @param - GENGS_serviceType
\r
84 * @param - GENGS_globalCustomerId
\r
87 * Out Mapping Variables:
\r
88 * @param - GENGS_service
\r
89 * @param - GENGS_FoundIndicator
\r
90 * @param - WorkflowException
\r
92 class CustomE2EGetService extends AbstractServiceTaskProcessor{
\r
94 String Prefix = "GENGS_"
\r
95 ExceptionUtil exceptionUtil = new ExceptionUtil()
\r
98 * This method validates the incoming variables and
\r
99 * determines the subsequent event based on which
\r
100 * variables the calling flow provided.
\r
102 * @param - execution
\r
105 public void preProcessRequest(DelegateExecution execution) {
\r
106 def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
\r
107 execution.setVariable("prefix",Prefix)
\r
108 utils.log("DEBUG", " *** STARTED GenericGetService PreProcessRequest Process*** ", isDebugEnabled)
\r
110 execution.setVariable("GENGS_obtainObjectsUrl", false)
\r
111 execution.setVariable("GENGS_obtainServiceInstanceUrlByName", false)
\r
112 execution.setVariable("GENGS_SuccessIndicator", false)
\r
113 execution.setVariable("GENGS_FoundIndicator", false)
\r
114 execution.setVariable("GENGS_resourceLink", null)
\r
115 execution.setVariable("GENGS_siResourceLink", null)
\r
119 String allottedResourceId = execution.getVariable("GENGS_allottedResourceId")
\r
120 String serviceInstanceId = execution.getVariable("GENGS_serviceInstanceId")
\r
121 String serviceInstanceName = execution.getVariable("GENGS_serviceInstanceName")
\r
122 String serviceType = execution.getVariable("GENGS_serviceType")
\r
123 String globalCustomerId = execution.getVariable("GENGS_globalCustomerId")
\r
124 String type = execution.getVariable("GENGS_type")
\r
127 utils.log("DEBUG", "Incoming GENGS_type is: " + type, isDebugEnabled)
\r
128 if(type.equalsIgnoreCase("allotted-resource")){
\r
129 if(isBlank(allottedResourceId)){
\r
130 utils.log("DEBUG", "Incoming allottedResourceId is null. Allotted Resource Id is required to Get an allotted-resource.", isDebugEnabled)
\r
131 exceptionUtil.buildAndThrowWorkflowException(execution, 500, "Incoming allottedResourceId is null. Allotted Resource Id is required to Get an allotted-resource.")
\r
133 utils.log("DEBUG", "Incoming Allotted Resource Id is: " + allottedResourceId, isDebugEnabled)
\r
134 if(isBlank(globalCustomerId) || isBlank(serviceType) || isBlank(serviceInstanceId)){
\r
135 execution.setVariable("GENGS_obtainObjectsUrl", true)
\r
137 utils.log("DEBUG", "Incoming Service Instance Id is: " + serviceInstanceId, isDebugEnabled)
\r
138 utils.log("DEBUG", "Incoming Service Type is: " + serviceType, isDebugEnabled)
\r
139 utils.log("DEBUG", "Incoming Global Customer Id is: " + globalCustomerId, isDebugEnabled)
\r
142 }else if(type.equalsIgnoreCase("service-instance")){
\r
143 if(isBlank(serviceInstanceId) && isBlank(serviceInstanceName)){
\r
144 utils.log("DEBUG", "Incoming serviceInstanceId and serviceInstanceName are null. ServiceInstanceId or ServiceInstanceName is required to Get a service-instance.", isDebugEnabled)
\r
145 exceptionUtil.buildAndThrowWorkflowException(execution, 500, "Incoming serviceInstanceId and serviceInstanceName are null. ServiceInstanceId or ServiceInstanceName is required to Get a service-instance.")
\r
147 utils.log("DEBUG", "Incoming Service Instance Id is: " + serviceInstanceId, isDebugEnabled)
\r
148 utils.log("DEBUG", "Incoming Service Instance Name is: " + serviceInstanceName, isDebugEnabled)
\r
149 if(isBlank(globalCustomerId) || isBlank(serviceType)){
\r
150 execution.setVariable("GENGS_obtainObjectsUrl", true)
\r
151 if(isBlank(serviceInstanceId)){
\r
152 execution.setVariable("GENGS_obtainServiceInstanceUrlByName", true)
\r
155 utils.log("DEBUG", "Incoming Global Customer Id is: " + globalCustomerId, isDebugEnabled)
\r
156 utils.log("DEBUG", "Incoming Service Type is: " + serviceType, isDebugEnabled)
\r
159 }else if(type.equalsIgnoreCase("service-subscription")){
\r
160 if(isBlank(serviceType) || isBlank(globalCustomerId)){
\r
161 utils.log("DEBUG", "Incoming ServiceType or GlobalCustomerId is null. These variables are required to Get a service-subscription.", isDebugEnabled)
\r
162 exceptionUtil.buildAndThrowWorkflowException(execution, 500, "Incoming ServiceType or GlobalCustomerId is null. These variables are required to Get a service-subscription.")
\r
164 utils.log("DEBUG", "Incoming Service Type is: " + serviceType, isDebugEnabled)
\r
165 utils.log("DEBUG", "Incoming Global Customer Id is: " + globalCustomerId, isDebugEnabled)
\r
168 exceptionUtil.buildAndThrowWorkflowException(execution, 500, "Incoming Type is Invalid. Please Specify Type as service-instance or service-subscription")
\r
171 exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Incoming GENGS_type is null. Variable is Required.")
\r
174 }catch(BpmnError b){
\r
175 utils.log("DEBUG", "Rethrowing MSOWorkflowException", isDebugEnabled)
\r
177 }catch(Exception e){
\r
178 utils.log("DEBUG", "Internal Error encountered within GenericGetService PreProcessRequest method!" + e, isDebugEnabled)
\r
179 exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occured in GenericGetService PreProcessRequest")
\r
182 utils.log("DEBUG", "*** COMPLETED GenericGetService PreProcessRequest Process ***", isDebugEnabled)
\r
186 * This method obtains the Url to the provided service instance
\r
187 * using the Service Instance Id.
\r
189 * @param - execution
\r
191 public void obtainServiceInstanceUrlById(DelegateExecution execution){
\r
192 def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
\r
193 execution.setVariable("prefix",Prefix)
\r
194 utils.log("DEBUG", " *** STARTED GenericGetService ObtainServiceInstanceUrlById Process*** ", isDebugEnabled)
\r
196 AaiUtil aaiUriUtil = new AaiUtil(this)
\r
197 String aai_uri = aaiUriUtil.getSearchNodesQueryEndpoint(execution)
\r
198 String aai_endpoint = execution.getVariable("URN_aai_endpoint")
\r
200 String type = execution.getVariable("GENGS_type")
\r
202 if(type.equalsIgnoreCase("service-instance")){
\r
203 String serviceInstanceId = execution.getVariable("GENGS_serviceInstanceId")
\r
204 utils.log("DEBUG", " Querying Node for Service-Instance URL by using Service-Instance Id: " + serviceInstanceId, isDebugEnabled)
\r
205 path = "${aai_uri}?search-node-type=service-instance&filter=service-instance-id:EQUALS:${serviceInstanceId}"
\r
206 utils.logAudit("Service Instance Node Query Url is: " + path)
\r
207 utils.log("DEBUG", "Service Instance Node Query Url is: " + path, isDebugEnabled)
\r
208 }else if(type.equalsIgnoreCase("allotted-resource")){
\r
209 String allottedResourceId = execution.getVariable("GENGS_allottedResourceId")
\r
210 utils.log("DEBUG", " Querying Node for Service-Instance URL by using Allotted Resource Id: " + allottedResourceId, isDebugEnabled)
\r
211 path = "${aai_uri}?search-node-type=allotted-resource&filter=id:EQUALS:${allottedResourceId}"
\r
212 utils.logAudit("Allotted Resource Node Query Url is: " + path)
\r
213 utils.log("DEBUG", "Allotted Resource Node Query Url is: " + path, isDebugEnabled)
\r
216 //String url = "${aai_endpoint}${path}" host name needs to be removed from property
\r
217 String url = "${path}"
\r
218 execution.setVariable("GENGS_genericQueryPath", url)
\r
220 APIResponse response = aaiUriUtil.executeAAIGetCall(execution, url)
\r
221 int responseCode = response.getStatusCode()
\r
222 execution.setVariable("GENGS_genericQueryResponseCode", responseCode)
\r
223 utils.log("DEBUG", " GET Service Instance response code is: " + responseCode, isDebugEnabled)
\r
224 utils.logAudit("GenericGetService AAI GET Response Code: " + responseCode)
\r
226 String aaiResponse = response.getResponseBodyAsString()
\r
227 execution.setVariable("GENGS_obtainSIUrlResponseBeforeUnescaping", aaiResponse)
\r
228 utils.log("DEBUG", "GenericGetService AAI Response before unescaping: " + aaiResponse, isDebugEnabled)
\r
229 aaiResponse = StringEscapeUtils.unescapeXml(aaiResponse)
\r
230 execution.setVariable("GENGS_genericQueryResponse", aaiResponse)
\r
231 utils.logAudit("GenericGetService AAI Response: " + aaiResponse)
\r
232 utils.log("DEBUG", "GenericGetService AAI Response: " + aaiResponse, isDebugEnabled)
\r
235 if(responseCode == 200){
\r
236 utils.log("DEBUG", "Generic Query Received a Good Response Code", isDebugEnabled)
\r
237 execution.setVariable("GENGS_SuccessIndicator", true)
\r
238 if(utils.nodeExists(aaiResponse, "result-data")){
\r
239 utils.log("DEBUG", "Generic Query Response Does Contain Data" , isDebugEnabled)
\r
240 execution.setVariable("GENGS_FoundIndicator", true)
\r
241 String resourceLink = utils.getNodeText1(aaiResponse, "resource-link")
\r
242 execution.setVariable("GENGS_resourceLink", resourceLink)
\r
243 execution.setVariable("GENGS_siResourceLink", resourceLink)
\r
245 utils.log("DEBUG", "Generic Query Response Does NOT Contains Data" , isDebugEnabled)
\r
246 execution.setVariable("WorkflowResponse", " ") //for junits
\r
248 }else if(responseCode == 404){
\r
249 utils.log("DEBUG", "Generic Query Received a Not Found (404) Response", isDebugEnabled)
\r
250 execution.setVariable("GENGS_SuccessIndicator", true)
\r
251 execution.setVariable("WorkflowResponse", " ") //for junits
\r
253 utils.log("DEBUG", "Generic Query Received a BAD REST Response: \n" + aaiResponse, isDebugEnabled)
\r
254 exceptionUtil.MapAAIExceptionToWorkflowExceptionGeneric(execution, aaiResponse, responseCode)
\r
255 throw new BpmnError("MSOWorkflowException")
\r
257 }catch(BpmnError b){
\r
258 utils.log("DEBUG", "Rethrowing MSOWorkflowException", isDebugEnabled)
\r
260 }catch(Exception e){
\r
261 utils.log("ERROR", " Error encountered within GenericGetService ObtainServiceInstanceUrlById method!" + e, isDebugEnabled)
\r
262 exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occured During ObtainServiceInstanceUrlById")
\r
264 utils.log("DEBUG", " *** COMPLETED GenericGetService ObtainServiceInstanceUrlById Process*** ", isDebugEnabled)
\r
268 * This method obtains the Url to the provided service instance
\r
269 * using the Service Instance Name.
\r
271 * @param - execution
\r
273 public void obtainServiceInstanceUrlByName(DelegateExecution execution){
\r
274 def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
\r
275 execution.setVariable("prefix",Prefix)
\r
276 utils.log("DEBUG", " *** STARTED GenericGetService ObtainServiceInstanceUrlByName Process*** ", isDebugEnabled)
\r
278 String serviceInstanceName = execution.getVariable("GENGS_serviceInstanceName")
\r
279 utils.log("DEBUG", " Querying Node for Service-Instance URL by using Service-Instance Name " + serviceInstanceName, isDebugEnabled)
\r
281 AaiUtil aaiUriUtil = new AaiUtil(this)
\r
282 String aai_uri = aaiUriUtil.getSearchNodesQueryEndpoint(execution)
\r
283 String aai_endpoint = execution.getVariable("URN_aai_endpoint")
\r
284 String path = "${aai_uri}?search-node-type=service-instance&filter=service-instance-name:EQUALS:${serviceInstanceName}"
\r
286 //String url = "${aai_endpoint}${path}" host name needs to be removed from property
\r
287 String url = "${path}"
\r
288 execution.setVariable("GENGS_obtainSIUrlPath", url)
\r
290 utils.logAudit("GenericGetService AAI Endpoint: " + aai_endpoint)
\r
291 APIResponse response = aaiUriUtil.executeAAIGetCall(execution, url)
\r
292 int responseCode = response.getStatusCode()
\r
293 execution.setVariable("GENGS_obtainSIUrlResponseCode", responseCode)
\r
294 utils.log("DEBUG", " GET Service Instance response code is: " + responseCode, isDebugEnabled)
\r
295 utils.logAudit("GenericGetService AAI Response Code: " + responseCode)
\r
297 String aaiResponse = response.getResponseBodyAsString()
\r
298 aaiResponse = StringEscapeUtils.unescapeXml(aaiResponse)
\r
299 execution.setVariable("GENGS_obtainSIUrlResponse", aaiResponse)
\r
300 utils.logAudit("GenericGetService AAI Response: " + aaiResponse)
\r
302 if(responseCode == 200){
\r
303 utils.log("DEBUG", " Query for Service Instance Url Received a Good Response Code", isDebugEnabled)
\r
304 execution.setVariable("GENGS_SuccessIndicator", true)
\r
305 if(utils.nodeExists(aaiResponse, "result-data")){
\r
306 utils.log("DEBUG", "Query for Service Instance Url Response Does Contain Data" , isDebugEnabled)
\r
307 execution.setVariable("GENGS_FoundIndicator", true)
\r
308 String resourceLink = utils.getNodeText1(aaiResponse, "resource-link")
\r
309 execution.setVariable("GENGS_resourceLink", resourceLink)
\r
310 execution.setVariable("GENGS_siResourceLink", resourceLink)
\r
312 utils.log("DEBUG", "Query for Service Instance Url Response Does NOT Contains Data" , isDebugEnabled)
\r
313 execution.setVariable("WorkflowResponse", " ") //for junits
\r
315 }else if(responseCode == 404){
\r
316 utils.log("DEBUG", " Query for Service Instance Received a Not Found (404) Response", isDebugEnabled)
\r
317 execution.setVariable("GENGS_SuccessIndicator", true)
\r
318 execution.setVariable("WorkflowResponse", " ") //for junits
\r
320 utils.log("DEBUG", "Query for Service Instance Received a BAD REST Response: \n" + aaiResponse, isDebugEnabled)
\r
321 exceptionUtil.MapAAIExceptionToWorkflowExceptionGeneric(execution, aaiResponse, responseCode)
\r
322 throw new BpmnError("MSOWorkflowException")
\r
324 }catch(BpmnError b){
\r
325 utils.log("DEBUG", "Rethrowing MSOWorkflowException", isDebugEnabled)
\r
327 }catch(Exception e){
\r
328 utils.log("ERROR", " Error encountered within GenericGetService ObtainServiceInstanceUrlByName method!" + e, isDebugEnabled)
\r
329 exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occured During ObtainServiceInstanceUrlByName")
\r
331 utils.log("DEBUG", " *** COMPLETED GenericGetService ObtainServiceInstanceUrlByName Process*** ", isDebugEnabled)
\r
336 * This method executes a GET call to AAI to obtain the
\r
337 * service-instance or service-subscription
\r
339 * @param - execution
\r
341 public void getServiceObject(DelegateExecution execution){
\r
342 def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
\r
343 execution.setVariable("prefix",Prefix)
\r
344 utils.log("DEBUG", " *** STARTED GenericGetService GetServiceObject Process*** ", isDebugEnabled)
\r
346 String type = execution.getVariable("GENGS_type")
\r
347 AaiUtil aaiUriUtil = new AaiUtil(this)
\r
348 String aai_endpoint = execution.getVariable("URN_aai_endpoint")
\r
349 String serviceEndpoint = ""
\r
351 utils.logAudit("GenericGetService getServiceObject AAI Endpoint: " + aai_endpoint)
\r
352 if(type.equalsIgnoreCase("service-instance")){
\r
353 String siResourceLink = execution.getVariable("GENGS_resourceLink")
\r
354 if(isBlank(siResourceLink)){
\r
355 String serviceInstanceId = execution.getVariable("GENGS_serviceInstanceId")
\r
356 utils.log("DEBUG", " Incoming GENGS_serviceInstanceId is: " + serviceInstanceId, isDebugEnabled)
\r
357 String serviceType = execution.getVariable("GENGS_serviceType")
\r
358 utils.log("DEBUG", " Incoming GENGS_serviceType is: " + serviceType, isDebugEnabled)
\r
359 String globalCustomerId = execution.getVariable("GENGS_globalCustomerId")
\r
360 utils.log("DEBUG", "Incoming Global Customer Id is: " + globalCustomerId, isDebugEnabled)
\r
362 String aai_uri = aaiUriUtil.getBusinessCustomerUri(execution)
\r
363 logDebug('AAI URI is: ' + aai_uri, isDebugEnabled)
\r
364 serviceEndpoint = "${aai_uri}/" + UriUtils.encode(globalCustomerId,"UTF-8") + "/service-subscriptions/service-subscription/" + UriUtils.encode(serviceType,"UTF-8") + "/service-instances/service-instance/" + UriUtils.encode(serviceInstanceId,"UTF-8")
\r
366 utils.log("DEBUG", "Incoming Service Instance Url is: " + siResourceLink, isDebugEnabled)
\r
367 String[] split = siResourceLink.split("/aai/")
\r
368 serviceEndpoint = "/aai/" + split[1]
\r
370 }else if(type.equalsIgnoreCase("allotted-resource")){
\r
371 String siResourceLink = execution.getVariable("GENGS_resourceLink")
\r
372 if(isBlank(siResourceLink)){
\r
373 String allottedResourceId = execution.getVariable("GENGS_allottedResourceId")
\r
374 utils.log("DEBUG", " Incoming GENGS_allottedResourceId is: " + allottedResourceId, isDebugEnabled)
\r
375 String serviceInstanceId = execution.getVariable("GENGS_serviceInstanceId")
\r
376 utils.log("DEBUG", " Incoming GENGS_serviceInstanceId is: " + serviceInstanceId, isDebugEnabled)
\r
377 String serviceType = execution.getVariable("GENGS_serviceType")
\r
378 utils.log("DEBUG", " Incoming GENGS_serviceType is: " + serviceType, isDebugEnabled)
\r
379 String globalCustomerId = execution.getVariable("GENGS_globalCustomerId")
\r
380 utils.log("DEBUG", "Incoming Global Customer Id is: " + globalCustomerId, isDebugEnabled)
\r
382 String aai_uri = aaiUriUtil.getBusinessCustomerUri(execution)
\r
383 logDebug('AAI URI is: ' + aai_uri, isDebugEnabled)
\r
384 serviceEndpoint = "${aai_uri}/" + UriUtils.encode(globalCustomerId,"UTF-8") + "/service-subscriptions/service-subscription/" + UriUtils.encode(serviceType,"UTF-8") + "/service-instances/service-instance/" + UriUtils.encode(serviceInstanceId,"UTF-8") + "/allotted-resources/allotted-resource/" + UriUtils.encode(allottedResourceId,"UTF-8")
\r
386 utils.log("DEBUG", "Incoming Allotted-Resource Url is: " + siResourceLink, isDebugEnabled)
\r
387 String[] split = siResourceLink.split("/aai/")
\r
388 serviceEndpoint = "/aai/" + split[1]
\r
390 }else if(type.equalsIgnoreCase("service-subscription")){
\r
391 String aai_uri = aaiUriUtil.getBusinessCustomerUri(execution)
\r
392 String globalCustomerId = execution.getVariable("GENGS_globalCustomerId")
\r
393 String serviceType = execution.getVariable("GENGS_serviceType")
\r
394 serviceEndpoint = "${aai_uri}/" + UriUtils.encode(globalCustomerId,"UTF-8") + "/service-subscriptions/service-subscription/" + UriUtils.encode(serviceType,"UTF-8")
\r
397 String serviceUrl = "${aai_endpoint}" + serviceEndpoint
\r
399 execution.setVariable("GENGS_getServiceUrl", serviceUrl)
\r
400 utils.log("DEBUG", "GET Service AAI Path is: \n" + serviceUrl, isDebugEnabled)
\r
402 APIResponse response = aaiUriUtil.executeAAIGetCall(execution, serviceUrl)
\r
403 int responseCode = response.getStatusCode()
\r
404 execution.setVariable("GENGS_getServiceResponseCode", responseCode)
\r
405 utils.log("DEBUG", " GET Service response code is: " + responseCode, isDebugEnabled)
\r
406 utils.logAudit("GenericGetService AAI Response Code: " + responseCode)
\r
408 String aaiResponse = response.getResponseBodyAsString()
\r
409 aaiResponse = StringEscapeUtils.unescapeXml(aaiResponse)
\r
410 execution.setVariable("GENGS_getServiceResponse", aaiResponse)
\r
411 utils.logAudit("GenericGetService AAI Response: " + aaiResponse)
\r
413 if(responseCode == 200 || responseCode == 202){
\r
414 utils.log("DEBUG", "GET Service Received a Good Response Code", isDebugEnabled)
\r
415 if(utils.nodeExists(aaiResponse, "service-instance") || utils.nodeExists(aaiResponse, "service-subscription")){
\r
416 utils.log("DEBUG", "GET Service Response Contains a service-instance" , isDebugEnabled)
\r
417 execution.setVariable("GENGS_FoundIndicator", true)
\r
418 execution.setVariable("GENGS_service", aaiResponse)
\r
419 execution.setVariable("WorkflowResponse", aaiResponse)
\r
422 utils.log("DEBUG", "GET Service Response Does NOT Contain Data" , isDebugEnabled)
\r
424 }else if(responseCode == 404){
\r
425 utils.log("DEBUG", "GET Service Received a Not Found (404) Response", isDebugEnabled)
\r
426 execution.setVariable("WorkflowResponse", " ") //for junits
\r
429 utils.log("DEBUG", " GET Service Received a Bad Response: \n" + aaiResponse, isDebugEnabled)
\r
430 exceptionUtil.MapAAIExceptionToWorkflowExceptionGeneric(execution, aaiResponse, responseCode)
\r
431 throw new BpmnError("MSOWorkflowException")
\r
433 }catch(BpmnError b){
\r
434 utils.log("DEBUG", "Rethrowing MSOWorkflowException", isDebugEnabled)
\r
436 }catch(Exception e){
\r
437 utils.log("DEBUG", " Error encountered within GenericGetService GetServiceObject method!" + e, isDebugEnabled)
\r
438 exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occured During GenericGetService")
\r
440 utils.log("DEBUG", " *** COMPLETED GenericGetService GetServiceObject Process*** ", isDebugEnabled)
\r