1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
|
/*-
* ============LICENSE_START=======================================================
* ONAP - SO
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* ============LICENSE_END=========================================================
*/
package org.onap.so.db.catalog.client;
import org.onap.so.db.catalog.beans.BuildingBlockDetail;
import org.onap.so.db.catalog.beans.CloudSite;
import org.onap.so.db.catalog.beans.CloudifyManager;
import org.onap.so.db.catalog.beans.CollectionNetworkResourceCustomization;
import org.onap.so.db.catalog.beans.CollectionResourceInstanceGroupCustomization;
import org.onap.so.db.catalog.beans.ControllerSelectionReference;
import org.onap.so.db.catalog.beans.InstanceGroup;
import org.onap.so.db.catalog.beans.NetworkCollectionResourceCustomization;
import org.onap.so.db.catalog.beans.NetworkRecipe;
import org.onap.so.db.catalog.beans.NetworkResourceCustomization;
import org.onap.so.db.catalog.beans.OrchestrationAction;
import org.onap.so.db.catalog.beans.OrchestrationStatus;
import org.onap.so.db.catalog.beans.OrchestrationStatusStateTransitionDirective;
import org.onap.so.db.catalog.beans.ResourceType;
import org.onap.so.db.catalog.beans.Service;
import org.onap.so.db.catalog.beans.ServiceRecipe;
import org.onap.so.db.catalog.beans.VfModule;
import org.onap.so.db.catalog.beans.VfModuleCustomization;
import org.onap.so.db.catalog.beans.VnfComponentsRecipe;
import org.onap.so.db.catalog.beans.VnfRecipe;
import org.onap.so.db.catalog.beans.VnfResource;
import org.onap.so.db.catalog.beans.VnfResourceCustomization;
import org.onap.so.db.catalog.beans.VnfcInstanceGroupCustomization;
import org.onap.so.db.catalog.beans.macro.NorthBoundRequest;
import org.onap.so.db.catalog.beans.macro.OrchestrationFlow;
import org.onap.so.db.catalog.beans.macro.RainyDayHandlerStatus;
import org.onap.so.logging.jaxrs.filter.jersey.SpringClientFilter;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.HttpHeaders;
import org.springframework.http.client.BufferingClientHttpRequestFactory;
import org.springframework.http.client.ClientHttpRequestFactory;
import org.springframework.http.client.HttpComponentsClientHttpRequestFactory;
import org.springframework.stereotype.Component;
import uk.co.blackpepper.bowman.Client;
import uk.co.blackpepper.bowman.ClientFactory;
import uk.co.blackpepper.bowman.Configuration;
import javax.annotation.PostConstruct;
import javax.ws.rs.core.UriBuilder;
import java.net.URI;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
@Component("CatalogDbClient")
public class CatalogDbClient {
private static final String CLOUD_SITE = "/cloudSite";
private static final String CLOUDIFY_MANAGER = "/cloudifyManager";
private static final String RAINY_DAY_HANDLER_MACRO = "/rainy_day_handler_macro";
private static final String NORTHBOUND_REQUEST_REF_LOOKUP = "/northbound_request_ref_lookup";
private static final String NETWORK_RESOURCE_CUSTOMIZATION = "/networkResourceCustomization";
private static final String COLLECTION_RESOURCE_INSTANCE_GROUP_CUSTOMIZATION = "/collectionResourceInstanceGroupCustomization";
private static final String VNFC_INSTANCE_GROUP_CUSTOMIZATION = "/vnfcInstanceGroupCustomization";
private static final String ORCHESTRATION_FLOW = "/orchestrationFlow";
private static final String ORCHESTRATION_STATUS_STATE_TRANSITION_DIRECTIVE = "/orchestrationStatusStateTransitionDirective";
private static final String INSTANCE_GROUP = "/instanceGroup";
private static final String COLLECTION_NETWORK_RESOURCE_CUSTOMIZATION = "/collectionNetworkResourceCustomization";
private static final String BUILDING_BLOCK_DETAIL = "/buildingBlockDetail";
private static final String NETWORK_COLLECTION_RESOURCE_CUSTOMIZATION = "/networkCollectionResourceCustomization";
private static final String VNF_RESOURCE_CUSTOMIZATION = "/vnfResourceCustomization";
private static final String SERVICE = "/service";
private static final String VNF_RESOURCE = "/vnfResource";
private static final String VNF_RECIPE = "/vnfRecipe";
private static final String VFMODULE = "/vfModule";
private static final String VFMODULE_CUSTOMIZATION = "/vfModuleCustomization";
private static final String VNF_COMPONENTS_RECIPE = "/vnfComponentsRecipe";
private static final String SERVICE_RECIPE = "/serviceRecipe";
private static final String NETWORK_RECIPE = "/networkRecipe";
private static final String SEARCH = "/search";
private static final String URI_SEPARATOR = "/";
private static final String SERVICE_MODEL_UUID = "serviceModelUUID";
private static final String MODEL_CUSTOMIZATION_UUID = "modelCustomizationUUID";
private static final String ACTION = "action";
private static final String MODEL_NAME = "modelName";
private static final String MODEL_VERSION = "modelVersion";
private static final String MODEL_INVARIANT_UUID = "modelInvariantUUID";
private static final String MODEL_INSTANCE_NAME = "modelInstanceName";
private static final String VNF_RESOURCE_MODEL_UUID = "vnfResourceModelUUID";
private static final String NF_ROLE = "nfRole";
private static final String VF_MODULE_MODEL_UUID = "vfModuleModelUUID";
private static final String VNF_COMPONENT_TYPE = "vnfComponentType";
private static final String BUILDING_BLOCK_NAME = "buildingBlockName";
private static final String RESOURCE_TYPE = "resourceType";
private static final String ORCHESTRATION_STATUS = "orchestrationStatus";
private static final String TARGET_ACTION = "targetAction";
private static final String REQUEST_SCOPE = "requestScope";
private static final String IS_ALACARTE = "isALaCarte";
private static final String FLOW_NAME = "flowName";
private static final String SERVICE_TYPE = "serviceType";
private static final String VNF_TYPE = "vnfType";
private static final String ERROR_CODE = "errorCode";
private static final String WORK_STEP = "workStep";
private static final String CLLI = "clli";
private static final String CLOUD_VERSION = "cloudVersion";
private String findFirstByModelNameURI = "/findFirstByModelNameOrderByModelVersionDesc";
private String findFirstByServiceModelUUIDAndActionURI = "/findFirstByServiceModelUUIDAndAction";
private String findFirstByModelVersionAndModelInvariantUUIDURI = "/findFirstByModelVersionAndModelInvariantUUID";
private String findByModelInvariantUUIDURI = "/findByModelInvariantUUIDOrderByModelVersionDesc";
private String findFirstByModelNameAndAction = "/findFirstByModelNameAndAction";
private String findFirstResourceByModelInvariantUUIDAndModelVersion = "/findFirstResourceByModelInvariantUUIDAndModelVersion";
private String findByModelInstanceNameAndVnfResources = "/findByModelInstanceNameAndVnfResources";
private String findFirstVnfRecipeByNfRoleAndAction = "/findFirstVnfRecipeByNfRoleAndAction";
private String findByModelCustomizationUUIDAndVfModuleModelUUID = "/findByModelCustomizationUUIDAndVfModuleModelUUID";
private String findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction = "/findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction";
private String findFirstVnfComponentsRecipeByVnfComponentTypeAndAction = "/findFirstVnfComponentsRecipeByVnfComponentTypeAndAction";
private String findVfModuleByModelInvariantUUIDOrderByModelVersionDesc = "/findByModelInvariantUUIDOrderByModelVersionDesc";
private String findFirstVfModuleByModelInvariantUUIDAndModelVersion = "/findFirstVfModuleByModelInvariantUUIDAndModelVersion";
private String findOneByBuildingBlockName = "/findOneByBuildingBlockName";
private String findOneByResourceTypeAndOrchestrationStatusAndTargetAction = "/findOneByResourceTypeAndOrchestrationStatusAndTargetAction";
private String findByAction = "/findByAction";
private String findVnfcInstanceGroupCustomizationByModelCustomizationUUID = "/findByModelCustomizationUUID";
private String findCollectionResourceInstanceGroupCustomizationByModelCustomizationUUID = "/findByModelCustomizationUUID";
private String findOneByActionAndRequestScopeAndIsAlacarte = "/findOneByActionAndRequestScopeAndIsAlacarte";
private String findOneByFlowNameAndServiceTypeAndVnfTypeAndErrorCodeAndWorkStep = "/findOneByFlowNameAndServiceTypeAndVnfTypeAndErrorCodeAndWorkStep";
private String findByClliAndCloudVersion = "/findByClliAndCloudVersion";
private String serviceURI;
private String vfModuleURI;
private String vnfResourceURI;
private String vfModuleCustomizationURI;
private String networkCollectionResourceCustomizationURI;
private String networkResourceCustomizationURI;
private String vnfResourceCustomizationURI;
private String collectionNetworkResourceCustomizationURI;
private String instanceGroupURI;
private String cloudifyManagerURI;
private String cloudSiteURI;
private final Client<Service> serviceClient;
private final Client<NetworkRecipe> networkRecipeClient;
private final Client<NetworkResourceCustomization> networkResourceCustomizationClient;
private final Client<VnfResource> vnfResourceClient;
private final Client<VnfResourceCustomization> vnfResourceCustomizationClient;
private final Client<VnfRecipe> vnfRecipeClient;
private final Client<VfModuleCustomization> vfModuleCustomizationClient;
private final Client<VfModule> vfModuleClient;
private final Client<VnfComponentsRecipe> vnfComponentsRecipeClient;
private final Client<OrchestrationFlow> orchestrationClient;
private final Client<NorthBoundRequest> northBoundRequestClient;
private final Client<RainyDayHandlerStatus> rainyDayHandlerStatusClient;
private final Client<BuildingBlockDetail> buildingBlockDetailClient;
private final Client<OrchestrationStatusStateTransitionDirective> orchestrationStatusStateTransitionDirectiveClient;
private final Client<VnfcInstanceGroupCustomization> vnfcInstanceGroupCustomizationClient;
private final Client<CollectionResourceInstanceGroupCustomization> collectionResourceInstanceGroupCustomizationClient;
private final Client<InstanceGroup> instanceGroupClient;
private final Client<NetworkCollectionResourceCustomization> networkCollectionResourceCustomizationClient;
private final Client<CollectionNetworkResourceCustomization> collectionNetworkResourceCustomizationClient;
private final Client<ServiceRecipe> serviceRecipeClient;
private final Client<CloudSite> cloudSiteClient;
private final Client<CloudifyManager> cloudifyManagerClient;
private final Client<ControllerSelectionReference> controllerSelectionReferenceClient;
@Value("${mso.catalog.db.spring.endpoint}")
private String endpoint;
@Value("${mso.db.auth}")
private String msoAdaptersAuth;
@PostConstruct
public void init(){
findFirstByModelNameURI = endpoint + SERVICE + SEARCH + findFirstByModelNameURI;
findFirstByModelVersionAndModelInvariantUUIDURI = endpoint + SERVICE + SEARCH + findFirstByModelVersionAndModelInvariantUUIDURI;
findByModelInvariantUUIDURI = endpoint + SERVICE + SEARCH + findByModelInvariantUUIDURI;
findFirstByServiceModelUUIDAndActionURI = endpoint + SERVICE_RECIPE + SEARCH + findFirstByServiceModelUUIDAndActionURI;
findFirstByModelNameAndAction = endpoint + NETWORK_RECIPE + SEARCH + findFirstByModelNameAndAction;
findFirstResourceByModelInvariantUUIDAndModelVersion = endpoint + VNF_RESOURCE + SEARCH + findFirstResourceByModelInvariantUUIDAndModelVersion;
findByModelInstanceNameAndVnfResources = endpoint + VNF_RESOURCE_CUSTOMIZATION + SEARCH + findByModelInstanceNameAndVnfResources;
findFirstVnfRecipeByNfRoleAndAction = endpoint + VNF_RECIPE + SEARCH + findFirstVnfRecipeByNfRoleAndAction;
findByModelCustomizationUUIDAndVfModuleModelUUID = endpoint + VFMODULE_CUSTOMIZATION + SEARCH + findByModelCustomizationUUIDAndVfModuleModelUUID;
findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction = endpoint + VNF_COMPONENTS_RECIPE + SEARCH + findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction;
findFirstVnfComponentsRecipeByVnfComponentTypeAndAction = endpoint + VNF_COMPONENTS_RECIPE + SEARCH + findFirstVnfComponentsRecipeByVnfComponentTypeAndAction;
findVfModuleByModelInvariantUUIDOrderByModelVersionDesc = endpoint + VFMODULE + SEARCH +findVfModuleByModelInvariantUUIDOrderByModelVersionDesc;
findFirstVfModuleByModelInvariantUUIDAndModelVersion = endpoint + VFMODULE + SEARCH + findFirstVfModuleByModelInvariantUUIDAndModelVersion;
findOneByBuildingBlockName = endpoint + BUILDING_BLOCK_DETAIL + SEARCH + findOneByBuildingBlockName;
findOneByResourceTypeAndOrchestrationStatusAndTargetAction = endpoint + ORCHESTRATION_STATUS_STATE_TRANSITION_DIRECTIVE + SEARCH + findOneByResourceTypeAndOrchestrationStatusAndTargetAction;
findByAction = endpoint + ORCHESTRATION_FLOW + SEARCH + findByAction;
findVnfcInstanceGroupCustomizationByModelCustomizationUUID = endpoint + VNFC_INSTANCE_GROUP_CUSTOMIZATION + SEARCH + findVnfcInstanceGroupCustomizationByModelCustomizationUUID;
findCollectionResourceInstanceGroupCustomizationByModelCustomizationUUID = endpoint + COLLECTION_RESOURCE_INSTANCE_GROUP_CUSTOMIZATION + SEARCH + findCollectionResourceInstanceGroupCustomizationByModelCustomizationUUID;
findOneByActionAndRequestScopeAndIsAlacarte = endpoint + NORTHBOUND_REQUEST_REF_LOOKUP + SEARCH + findOneByActionAndRequestScopeAndIsAlacarte;
findOneByFlowNameAndServiceTypeAndVnfTypeAndErrorCodeAndWorkStep = endpoint + RAINY_DAY_HANDLER_MACRO + SEARCH + findOneByFlowNameAndServiceTypeAndVnfTypeAndErrorCodeAndWorkStep;
findByClliAndCloudVersion = endpoint + CLOUD_SITE + SEARCH + findByClliAndCloudVersion;
serviceURI = endpoint + SERVICE + URI_SEPARATOR;
vfModuleURI = endpoint + VFMODULE + URI_SEPARATOR;
vnfResourceURI = endpoint + VNF_RESOURCE + URI_SEPARATOR;
vfModuleCustomizationURI = endpoint + VFMODULE_CUSTOMIZATION + URI_SEPARATOR;
networkCollectionResourceCustomizationURI = endpoint + NETWORK_COLLECTION_RESOURCE_CUSTOMIZATION + URI_SEPARATOR;
networkResourceCustomizationURI = endpoint + NETWORK_RESOURCE_CUSTOMIZATION + URI_SEPARATOR;
vnfResourceCustomizationURI = endpoint + VNF_RESOURCE_CUSTOMIZATION + URI_SEPARATOR;
collectionNetworkResourceCustomizationURI = endpoint + COLLECTION_NETWORK_RESOURCE_CUSTOMIZATION + URI_SEPARATOR;
instanceGroupURI = endpoint + INSTANCE_GROUP + URI_SEPARATOR;
cloudifyManagerURI = endpoint + CLOUDIFY_MANAGER + URI_SEPARATOR;
cloudSiteURI = endpoint + CLOUD_SITE + URI_SEPARATOR;
}
public CatalogDbClient() {
ClientHttpRequestFactory factory = new BufferingClientHttpRequestFactory(new HttpComponentsClientHttpRequestFactory());
ClientFactory clientFactory = Configuration.builder().setClientHttpRequestFactory(factory).setRestTemplateConfigurer(restTemplate -> {
restTemplate.getInterceptors().add((new SpringClientFilter()));
restTemplate.getInterceptors().add((request, body, execution) -> {
request.getHeaders().add(HttpHeaders.AUTHORIZATION, msoAdaptersAuth);
return execution.execute(request, body);
});
}).build().buildClientFactory();
serviceClient = clientFactory.create(Service.class);
networkRecipeClient = clientFactory.create(NetworkRecipe.class);
networkResourceCustomizationClient = clientFactory.create(NetworkResourceCustomization.class);
vnfResourceClient = clientFactory.create(VnfResource.class);
vnfResourceCustomizationClient = clientFactory.create(VnfResourceCustomization.class);
vnfRecipeClient = clientFactory.create(VnfRecipe.class);
orchestrationClient = clientFactory.create(OrchestrationFlow.class);
vfModuleCustomizationClient = clientFactory.create(VfModuleCustomization.class);
vfModuleClient = clientFactory.create(VfModule.class);
vnfComponentsRecipeClient = clientFactory.create(VnfComponentsRecipe.class);
northBoundRequestClient = clientFactory.create(NorthBoundRequest.class);
rainyDayHandlerStatusClient = clientFactory.create(RainyDayHandlerStatus.class);
buildingBlockDetailClient = clientFactory.create(BuildingBlockDetail.class);
orchestrationStatusStateTransitionDirectiveClient = clientFactory
.create(OrchestrationStatusStateTransitionDirective.class);
vnfcInstanceGroupCustomizationClient = clientFactory.create(VnfcInstanceGroupCustomization.class);
collectionResourceInstanceGroupCustomizationClient = clientFactory
.create(CollectionResourceInstanceGroupCustomization.class);
instanceGroupClient = clientFactory.create(InstanceGroup.class);
networkCollectionResourceCustomizationClient = clientFactory.create(NetworkCollectionResourceCustomization.class);
collectionNetworkResourceCustomizationClient = clientFactory.create(CollectionNetworkResourceCustomization.class);
cloudSiteClient = clientFactory.create(CloudSite.class);
cloudifyManagerClient = clientFactory.create(CloudifyManager.class);
serviceRecipeClient = clientFactory.create(ServiceRecipe.class);
controllerSelectionReferenceClient = clientFactory.create(ControllerSelectionReference.class);
}
public NetworkCollectionResourceCustomization getNetworkCollectionResourceCustomizationByID(String modelCustomizationUUID) {
NetworkCollectionResourceCustomization networkCollectionResourceCustomization =
this.getSingleResource(networkCollectionResourceCustomizationClient, getUri(networkCollectionResourceCustomizationURI + modelCustomizationUUID));
if (networkCollectionResourceCustomization != null) {
networkCollectionResourceCustomization.setModelCustomizationUUID(modelCustomizationUUID);
}
return networkCollectionResourceCustomization;
}
public Service getServiceByID(String modelUUID) {
Service service = getSingleResource(serviceClient,getUri(serviceURI + modelUUID));
if (service != null) {
service.setModelUUID(modelUUID);
}
return service;
}
public VfModule getVfModuleByModelUUID(String modelUUID) {
VfModule vfModule = getSingleResource(vfModuleClient,getUri(vfModuleURI + modelUUID));
if (vfModule != null) {
vfModule.setModelUUID(modelUUID);
}
return vfModule;
}
public VnfResource getVnfResourceByModelUUID(String modelUUID){
VnfResource vnfResource = this.getSingleResource(vnfResourceClient, getUri(vnfResourceURI + modelUUID));
if (vnfResource != null) {
vnfResource.setModelUUID(modelUUID);
}
return vnfResource;
}
public VnfResourceCustomization getVnfResourceCustomizationByModelCustomizationUUID(String modelCustomizationUUID){
VnfResourceCustomization vnfResourceCustomization = getSingleResource(vnfResourceCustomizationClient, getUri(vnfResourceCustomizationURI + modelCustomizationUUID));
if (vnfResourceCustomization != null) {
vnfResourceCustomization.setModelCustomizationUUID(modelCustomizationUUID);
}
return vnfResourceCustomization;
}
public CollectionNetworkResourceCustomization getCollectionNetworkResourceCustomizationByID(String modelCustomizationUUID) {
CollectionNetworkResourceCustomization collectionNetworkResourceCustomization =
this.getSingleResource(collectionNetworkResourceCustomizationClient,getUri(UriBuilder
.fromUri(collectionNetworkResourceCustomizationURI + modelCustomizationUUID).build().toString()));
if (collectionNetworkResourceCustomization != null) {
collectionNetworkResourceCustomization.setModelCustomizationUUID(modelCustomizationUUID);
}
return collectionNetworkResourceCustomization;
}
public InstanceGroup getInstanceGroupByModelUUID(String modelUUID) {
InstanceGroup instanceGroup = this.getSingleResource(instanceGroupClient, getUri(instanceGroupURI + modelUUID));
if (instanceGroup != null) {
instanceGroup.setModelUUID(modelUUID);
}
return instanceGroup;
}
public VfModuleCustomization getVfModuleCustomizationByModelCuztomizationUUID(String modelCustomizationUUID) {
VfModuleCustomization vfModuleCust = this.getSingleResource(vfModuleCustomizationClient, getUri(vfModuleCustomizationURI + modelCustomizationUUID));
if (vfModuleCust != null) {
vfModuleCust.setModelCustomizationUUID(modelCustomizationUUID);
}
return vfModuleCust;
}
public NetworkResourceCustomization getNetworkResourceCustomizationByModelCustomizationUUID(String modelCustomizationUUID){
NetworkResourceCustomization networkResourceCustomization =
this.getSingleResource(networkResourceCustomizationClient, getUri(networkResourceCustomizationURI + modelCustomizationUUID));
if (networkResourceCustomization != null) {
networkResourceCustomization.setModelCustomizationUUID(modelCustomizationUUID);
}
return networkResourceCustomization;
}
public BuildingBlockDetail getBuildingBlockDetail(String buildingBlockName) {
BuildingBlockDetail buildingBlockDetail = getSingleResource(buildingBlockDetailClient, getUri(UriBuilder
.fromUri(findOneByBuildingBlockName).queryParam(BUILDING_BLOCK_NAME, buildingBlockName).build().toString()));
if (buildingBlockDetail != null) {
buildingBlockDetail.setBuildingBlockName(buildingBlockName);
}
return buildingBlockDetail;
}
public OrchestrationStatusStateTransitionDirective getOrchestrationStatusStateTransitionDirective(
ResourceType resourceType, OrchestrationStatus orchestrationStatus, OrchestrationAction targetAction) {
return getSingleResource(orchestrationStatusStateTransitionDirectiveClient, UriBuilder
.fromUri(findOneByResourceTypeAndOrchestrationStatusAndTargetAction)
.queryParam(RESOURCE_TYPE, resourceType.name())
.queryParam(ORCHESTRATION_STATUS, orchestrationStatus.name())
.queryParam(TARGET_ACTION, targetAction.name()).build());
}
public List<OrchestrationFlow> getOrchestrationFlowByAction(String action) {
return this.getMultipleResources(orchestrationClient, UriBuilder
.fromUri(findByAction).queryParam(ACTION, action).build());
}
public List<VnfcInstanceGroupCustomization> getVnfcInstanceGroupsByVnfResourceCust(String modelCustomizationUUID) {
return this.getMultipleResources(vnfcInstanceGroupCustomizationClient, UriBuilder
.fromUri(findVnfcInstanceGroupCustomizationByModelCustomizationUUID)
.queryParam(MODEL_CUSTOMIZATION_UUID, modelCustomizationUUID).build());
}
public List<CollectionResourceInstanceGroupCustomization> getCollectionResourceInstanceGroupCustomizationByModelCustUUID(
String modelCustomizationUUID) {
return this.getMultipleResources(collectionResourceInstanceGroupCustomizationClient, UriBuilder
.fromUri(findCollectionResourceInstanceGroupCustomizationByModelCustomizationUUID)
.queryParam(MODEL_CUSTOMIZATION_UUID, modelCustomizationUUID).build());
}
public VfModuleCustomization getVfModuleCustomizationByModelCustomizationUUIDAndVfModuleModelUUID(String modelCustomizationUUID, String vfModuleModelUUID) {
return this.getSingleResource(vfModuleCustomizationClient, getUri(UriBuilder
.fromUri(findByModelCustomizationUUIDAndVfModuleModelUUID)
.queryParam(MODEL_CUSTOMIZATION_UUID,modelCustomizationUUID)
.queryParam(VF_MODULE_MODEL_UUID,vfModuleModelUUID).build().toString()));
}
public NorthBoundRequest getNorthBoundRequestByActionAndIsALaCarteAndRequestScope(String requestAction,
String resourceName, boolean aLaCarte) {
return this.getSingleResource(northBoundRequestClient, UriBuilder
.fromUri(findOneByActionAndRequestScopeAndIsAlacarte)
.queryParam(ACTION, requestAction).queryParam(REQUEST_SCOPE, resourceName)
.queryParam(IS_ALACARTE, aLaCarte).build());
}
public RainyDayHandlerStatus getRainyDayHandlerStatusByFlowNameAndServiceTypeAndVnfTypeAndErrorCodeAndWorkStep(
String flowName, String serviceType, String vnfType, String errorCode, String workStep) {
return this.getSingleResource(rainyDayHandlerStatusClient, UriBuilder
.fromUri(findOneByFlowNameAndServiceTypeAndVnfTypeAndErrorCodeAndWorkStep)
.queryParam(FLOW_NAME, flowName).queryParam(SERVICE_TYPE, serviceType)
.queryParam(VNF_TYPE, vnfType).queryParam(ERROR_CODE, errorCode).queryParam(WORK_STEP, workStep)
.build());
}
public ServiceRecipe getFirstByServiceModelUUIDAndAction(String modelUUID, String action){
return this.getSingleResource(serviceRecipeClient, getUri(UriBuilder
.fromUri(findFirstByServiceModelUUIDAndActionURI)
.queryParam(SERVICE_MODEL_UUID,modelUUID)
.queryParam(ACTION,action).build().toString()));
}
public NetworkRecipe getFirstNetworkRecipeByModelNameAndAction(String modelName, String action){
return this.getSingleResource(networkRecipeClient, UriBuilder
.fromUri(findFirstByModelNameAndAction)
.queryParam(MODEL_NAME,modelName)
.queryParam(ACTION,action).build());
}
public ControllerSelectionReference getControllerSelectionReferenceByVnfTypeAndActionCategory(String vnfType, String actionCategory) {
return this.getSingleResource(controllerSelectionReferenceClient, UriBuilder
.fromUri(endpoint + "/controllerSelectionReference/search/findControllerSelectionReferenceByVnfTypeAndActionCategory")
.queryParam("VNF_TYPE", vnfType).queryParam("ACTION_CATEGORY", actionCategory).build());
}
public Service getFirstByModelNameOrderByModelVersionDesc(String modelName){
return this.getSingleResource(serviceClient,UriBuilder
.fromUri(findFirstByModelNameURI)
.queryParam(MODEL_NAME,modelName).build());
}
public VnfResource getFirstVnfResourceByModelInvariantUUIDAndModelVersion(String modelInvariantUUID, String modelVersion){
return this.getSingleResource(vnfResourceClient, getUri(UriBuilder
.fromUri(findFirstResourceByModelInvariantUUIDAndModelVersion)
.queryParam(MODEL_INVARIANT_UUID,modelInvariantUUID)
.queryParam(MODEL_VERSION,modelVersion).build().toString()));
}
public VnfResourceCustomization getFirstVnfResourceCustomizationByModelInstanceNameAndVnfResources(String modelInstanceName, VnfResource vnfResource){
return this.getSingleResource(vnfResourceCustomizationClient, getUri(UriBuilder
.fromUri(findByModelInstanceNameAndVnfResources)
.queryParam(MODEL_INSTANCE_NAME,modelInstanceName)
.queryParam(VNF_RESOURCE_MODEL_UUID,vnfResource.getModelUUID()).build().toString()));
}
public VnfRecipe getFirstVnfRecipeByNfRoleAndAction(String nfRole, String action){
return this.getSingleResource(vnfRecipeClient,getUri(UriBuilder
.fromUri(findFirstVnfRecipeByNfRoleAndAction)
.queryParam(NF_ROLE,nfRole)
.queryParam(ACTION,action).build().toString()));
}
public VnfComponentsRecipe getFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction(String vfModuleModelUUID, String vnfComponentType, String action){
return this.getSingleResource(vnfComponentsRecipeClient,getUri(UriBuilder
.fromUri(findFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction)
.queryParam(VF_MODULE_MODEL_UUID,vfModuleModelUUID)
.queryParam(VNF_COMPONENT_TYPE,vnfComponentType)
.queryParam(ACTION,action).build().toString()));
}
public VnfComponentsRecipe getFirstVnfComponentsRecipeByVnfComponentTypeAndAction(String vnfComponentType, String action) {
return this.getSingleResource(vnfComponentsRecipeClient,getUri(UriBuilder
.fromUri(findFirstVnfComponentsRecipeByVnfComponentTypeAndAction)
.queryParam(VNF_COMPONENT_TYPE,vnfComponentType)
.queryParam(ACTION,action).build().toString()));
}
protected URI getUri(String template){
return URI.create(template);
}
public CloudifyManager getCloudifyManager(String id) {
return this.getSingleResource(cloudifyManagerClient,getUri(cloudifyManagerURI + id));
}
public CloudSite getCloudSite(String id){
return this.getSingleResource(cloudSiteClient, getUri(cloudSiteURI + id));
}
public CloudSite getCloudSiteByClliAndAicVersion (String clli, String cloudVersion){
return this.getSingleResource(cloudSiteClient, getUri(UriBuilder
.fromUri(findByClliAndCloudVersion)
.queryParam(CLLI,clli).queryParam(CLOUD_VERSION,cloudVersion).build().toString()));
}
public Service getServiceByModelVersionAndModelInvariantUUID(String modelVersion, String modelInvariantUUID) {
return this.getSingleResource(serviceClient, getUri(UriBuilder
.fromUri(findFirstByModelVersionAndModelInvariantUUIDURI)
.queryParam(MODEL_VERSION, modelVersion)
.queryParam(MODEL_INVARIANT_UUID, modelInvariantUUID).build().toString()));
}
public VfModule getVfModuleByModelInvariantUUIDAndModelVersion(String modelInvariantUUID, String modelVersion){
return this.getSingleResource(vfModuleClient,getUri(UriBuilder
.fromUri(findFirstVfModuleByModelInvariantUUIDAndModelVersion)
.queryParam(MODEL_INVARIANT_UUID, modelInvariantUUID)
.queryParam(MODEL_VERSION, modelVersion).build().toString()));
}
public List<Service> getServiceByModelInvariantUUIDOrderByModelVersionDesc(String modelInvariantUUID) {
return this.getMultipleResources(serviceClient, getUri(UriBuilder
.fromUri(findByModelInvariantUUIDURI)
.queryParam(MODEL_INVARIANT_UUID, modelInvariantUUID).build().toString()));
}
public List<VfModule> getVfModuleByModelInvariantUUIDOrderByModelVersionDesc(String modelInvariantUUID) {
return this.getMultipleResources(vfModuleClient, getUri(UriBuilder
.fromUri(findVfModuleByModelInvariantUUIDOrderByModelVersionDesc)
.queryParam(MODEL_INVARIANT_UUID, modelInvariantUUID).build().toString()));
}
private <T> T getSingleResource(Client<T> client, URI uri) {
return client.get(uri);
}
private <T> List<T> getMultipleResources(Client<T> client, URI uri) {
Iterable<T> iterator = client.getAll(uri);
List<T> list = new ArrayList<>();
Iterator<T> it = iterator.iterator();
it.forEachRemaining(list::add);
return list;
}
}
|