2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Copyright (C) 2018 IBM.
8 * ================================================================================
9 * Licensed under the Apache License, Version 2.0 (the "License");
10 * you may not use this file except in compliance with the License.
11 * You may obtain a copy of the License at
13 * http://www.apache.org/licenses/LICENSE-2.0
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
20 * ============LICENSE_END=========================================================
23 package org.onap.so.adapters.catalogdb.rest;
26 Create an initial query to retrieve a VNF Resource definition (including a list of possible module types)
27 within the context of a given service. Input is a vnf resource model customization ID (new field for 1702),
28 or a composite key (from 1610) of service name, service version, vnf instance name
30 Returns a structure (JSON?) containing VNF RESOURCE attributes, plus a list of VF Module structures.
32 Query a NETWORK_RESOURCE from the MSO Catalog, based on a networkModelCustomizationUUID (new for 1702),
33 a network type (unique type identifier in 1610), or based on network role within a service.
35 Create Adapter framework for access to Catalog DB, including connection management,
36 login/password access, transaction logic, etc. This can be modeled after the Request DB Adapter
38 Update the MSO Catalog DB schema to include the new fields defined in this user story.
40 Note that the resourceModelCustomizationUUID (or vfModuleModelCustomizationUUID) will be unique keys (indexes)
41 on the VNF_RESOURCE and VF_MODULE tables respectively.
42 The previously constructed "vnf-type" and "vf-module-type" field may continue to be populated,
43 but should no longer be needed and can deprecate in future release.
45 For migration, a new randomly generated UUID field may be generated for the *ModelCustomizationUUID" fields
46 until such time that the model is redistributed from ASDC.
48 All other fields Check with Mike Z for appropriate value for the vfModuleLabel.
49 We might be able to derive it's value from the current vnf-type (using the "middle" piece that identifies the module type).
51 min and initial counts can be 0. max can be null to indicate no maximum.
53 Once the network-level distribution artifacts are defined, similar updates can be made to the NETWORK_RESOURCE table.
56 import org.apache.http.HttpStatus;
57 import org.onap.so.adapters.catalogdb.catalogrest.CatalogQuery;
58 import org.onap.so.adapters.catalogdb.catalogrest.CatalogQueryException;
59 import org.onap.so.adapters.catalogdb.catalogrest.CatalogQueryExceptionCategory;
60 import org.onap.so.adapters.catalogdb.catalogrest.QueryAllottedResourceCustomization;
61 import org.onap.so.adapters.catalogdb.catalogrest.QueryResourceRecipe;
62 import org.onap.so.adapters.catalogdb.catalogrest.QueryServiceCsar;
63 import org.onap.so.adapters.catalogdb.catalogrest.QueryServiceMacroHolder;
64 import org.onap.so.adapters.catalogdb.catalogrest.QueryServiceNetworks;
65 import org.onap.so.adapters.catalogdb.catalogrest.QueryServiceVnfs;
66 import org.onap.so.adapters.catalogdb.catalogrest.QueryVfModule;
67 import org.onap.so.db.catalog.beans.AllottedResource;
68 import org.onap.so.db.catalog.beans.AllottedResourceCustomization;
69 import org.onap.so.db.catalog.beans.NetworkResource;
70 import org.onap.so.db.catalog.beans.NetworkResourceCustomization;
71 import org.onap.so.db.catalog.beans.Recipe;
72 import org.onap.so.db.catalog.beans.Service;
73 import org.onap.so.db.catalog.beans.ToscaCsar;
74 import org.onap.so.db.catalog.beans.VfModule;
75 import org.onap.so.db.catalog.beans.VfModuleCustomization;
76 import org.onap.so.db.catalog.beans.VnfRecipe;
77 import org.onap.so.db.catalog.beans.VnfResource;
78 import org.onap.so.db.catalog.beans.VnfResourceCustomization;
79 import org.onap.so.db.catalog.data.repository.AllottedResourceCustomizationRepository;
80 import org.onap.so.db.catalog.data.repository.AllottedResourceRepository;
81 import org.onap.so.db.catalog.data.repository.ArRecipeRepository;
82 import org.onap.so.db.catalog.data.repository.NetworkRecipeRepository;
83 import org.onap.so.db.catalog.data.repository.NetworkResourceCustomizationRepository;
84 import org.onap.so.db.catalog.data.repository.NetworkResourceRepository;
85 import org.onap.so.db.catalog.data.repository.ServiceRepository;
86 import org.onap.so.db.catalog.data.repository.ToscaCsarRepository;
87 import org.onap.so.db.catalog.data.repository.VFModuleRepository;
88 import org.onap.so.db.catalog.data.repository.VnfCustomizationRepository;
89 import org.onap.so.db.catalog.data.repository.VnfRecipeRepository;
90 import org.onap.so.db.catalog.data.repository.VnfResourceRepository;
91 import org.onap.so.db.catalog.rest.beans.ServiceMacroHolder;
92 import org.slf4j.Logger;
93 import org.slf4j.LoggerFactory;
94 import org.springframework.beans.factory.annotation.Autowired;
95 import org.springframework.stereotype.Component;
96 import org.springframework.transaction.annotation.Transactional;
98 import javax.ws.rs.GET;
99 import javax.ws.rs.Path;
100 import javax.ws.rs.PathParam;
101 import javax.ws.rs.Produces;
102 import javax.ws.rs.QueryParam;
103 import javax.ws.rs.core.GenericEntity;
104 import javax.ws.rs.core.HttpHeaders;
105 import javax.ws.rs.core.MediaType;
106 import javax.ws.rs.core.Response;
107 import java.util.ArrayList;
108 import java.util.List;
111 * This class services calls to the REST interface for VF Modules (http://host:port/ecomp/mso/catalog/v1)
112 * Both XML and JSON can be produced/consumed. Set Accept: and Content-Type: headers appropriately. XML is the default.
113 * Requests respond synchronously only
115 @Path("/{version: v[0-9]+}")
117 public class CatalogDbAdapterRest {
118 protected static Logger logger = LoggerFactory.getLogger(CatalogDbAdapterRest.class);
119 private static final boolean IS_ARRAY = true;
120 private static final String NETWORK_SERVICE = "network service";
123 private VnfCustomizationRepository vnfCustomizationRepo;
126 private ServiceRepository serviceRepo;
129 private NetworkResourceCustomizationRepository networkCustomizationRepo;
132 private NetworkResourceRepository networkResourceRepo;
135 private AllottedResourceCustomizationRepository allottedCustomizationRepo;
138 private ToscaCsarRepository toscaCsarRepo;
141 private VFModuleRepository vfModuleRepo;
144 private VnfRecipeRepository vnfRecipeRepo;
147 private NetworkRecipeRepository networkRecipeRepo;
150 private ArRecipeRepository arRecipeRepo;
153 private VnfResourceRepository vnfResourceRepo;
156 private AllottedResourceRepository arResourceRepo;
158 private static final String NO_MATCHING_PARAMETERS = "no matching parameters";
160 public Response respond(String version, int respStatus, boolean isArray, CatalogQuery qryResp) {
163 //.entity(new GenericEntity<QueryServiceVnfs>(qryResp) {})
164 .entity(qryResp.toJsonString(version, isArray))
165 .header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
170 @Path("vnfResources/{vnfModelCustomizationUuid}")
171 @Transactional( readOnly = true)
172 @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
173 public Response serviceVnfs (
174 @PathParam("version") String version,
175 @PathParam("vnfModelCustomizationUuid") String vnfUuid
177 return serviceVnfsImpl (version, !IS_ARRAY, vnfUuid, null, null, null, null);
182 @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
183 @Transactional( readOnly = true)
184 public Response serviceVnfs(
185 @PathParam("version") String version,
186 @QueryParam("vnfModelCustomizationUuid") String vnfUuid,
187 @QueryParam("serviceModelUuid") String smUuid,
188 @QueryParam("serviceModelInvariantUuid") String smiUuid,
189 @QueryParam("serviceModelVersion") String smVer,
190 @QueryParam("serviceModelName") String smName
192 return serviceVnfsImpl (version, IS_ARRAY, vnfUuid, smUuid, smiUuid, smVer, smName);
195 public Response serviceVnfsImpl(String version, boolean isArray, String vnfUuid, String serviceModelUUID, String smiUuid, String smVer, String smName) {
196 QueryServiceVnfs qryResp = null;
197 int respStatus = HttpStatus.SC_OK;
198 List<VnfResourceCustomization> ret = new ArrayList<>();
199 Service service = null;
201 if (vnfUuid != null && !"".equals(vnfUuid))
202 ret = vnfCustomizationRepo.findByModelCustomizationUUID(vnfUuid);
203 else if (serviceModelUUID != null && !"".equals(serviceModelUUID))
204 service = serviceRepo.findFirstOneByModelUUIDOrderByModelVersionDesc(serviceModelUUID);
205 else if (smiUuid != null && !"".equals(smiUuid))
206 if (smVer != null && !"".equals(smVer))
207 service = serviceRepo.findFirstByModelVersionAndModelInvariantUUID(smVer,smiUuid);
209 service = serviceRepo.findFirstByModelInvariantUUIDOrderByModelVersionDesc(smiUuid);
210 else if (smName != null && !"".equals(smName)) {
211 if (smVer != null && !"".equals(smVer))
212 service = serviceRepo.findByModelNameAndModelVersion(smName, smVer);
214 service = serviceRepo.findFirstByModelNameOrderByModelVersionDesc(smName);
217 throw(new Exception(NO_MATCHING_PARAMETERS));
220 if (service == null && ret.isEmpty()) {
221 respStatus = HttpStatus.SC_NOT_FOUND;
222 qryResp = new QueryServiceVnfs();
223 }else if( service == null && !ret.isEmpty()){
224 qryResp = new QueryServiceVnfs(ret);
225 } else if (service != null) {
226 qryResp = new QueryServiceVnfs(service.getVnfCustomizations());
228 logger.debug ("serviceVnfs qryResp= {}", qryResp);
229 return respond(version, respStatus, isArray, qryResp);
230 } catch (Exception e) {
231 logger.error("Exception - queryServiceVnfs", e);
232 CatalogQueryException excResp = new CatalogQueryException(e.getMessage(), CatalogQueryExceptionCategory.INTERNAL, Boolean.FALSE, null);
234 .status(HttpStatus.SC_INTERNAL_SERVER_ERROR)
235 .entity(new GenericEntity<CatalogQueryException>(excResp) {})
241 @Path("networkResources/{networkModelCustomizationUuid}")
242 @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
243 @Transactional( readOnly = true)
244 public Response serviceNetworks (
245 @PathParam("version") String version,
246 @PathParam("networkModelCustomizationUuid") String nUuid
248 return serviceNetworksImpl (version, !IS_ARRAY, nUuid, null, null, null, null);
252 @Path("serviceNetworks")
253 @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
254 @Transactional( readOnly = true)
255 public Response serviceNetworks (
256 @PathParam("version") String version,
257 @QueryParam("networkModelCustomizationUuid") String networkModelCustomizationUuid,
258 @QueryParam("networkType") String networkType,
259 @QueryParam("networkModelName") String networkModelName,
260 @QueryParam("serviceModelUuid") String serviceModelUuid,
261 @QueryParam("serviceModelInvariantUuid") String serviceModelInvariantUuid,
262 @QueryParam("serviceModelVersion") String serviceModelVersion,
263 @QueryParam("networkModelVersion") String networkModelVersion
265 if (networkModelName != null && !"".equals(networkModelName)) {
266 networkType = networkModelName;
268 return serviceNetworksImpl (version, IS_ARRAY, networkModelCustomizationUuid, networkType, serviceModelUuid, serviceModelInvariantUuid, serviceModelVersion);
271 public Response serviceNetworksImpl (String version, boolean isArray, String networkModelCustomizationUuid, String networkType, String serviceModelUuid, String serviceModelInvariantUuid, String serviceModelVersion) {
272 QueryServiceNetworks qryResp;
273 int respStatus = HttpStatus.SC_OK;
275 List<NetworkResourceCustomization> ret = new ArrayList<>();
276 Service service = null;
279 if (networkModelCustomizationUuid != null && !"".equals(networkModelCustomizationUuid)) {
280 uuid = networkModelCustomizationUuid;
281 ret = networkCustomizationRepo.findByModelCustomizationUUID(networkModelCustomizationUuid);
282 }else if (networkType != null && !"".equals(networkType)) {
284 NetworkResource networkResources = networkResourceRepo.findFirstByModelNameOrderByModelVersionDesc(networkType);
285 if(networkResources != null)
286 ret=networkResources.getNetworkResourceCustomization();
288 else if (serviceModelInvariantUuid != null && !"".equals(serviceModelInvariantUuid)) {
289 uuid = serviceModelInvariantUuid;
290 if (serviceModelVersion != null && !"".equals(serviceModelVersion)) {
291 service = serviceRepo.findFirstByModelVersionAndModelInvariantUUID(serviceModelVersion, uuid);
294 service = serviceRepo.findFirstByModelInvariantUUIDOrderByModelVersionDesc(uuid);
296 }else if (serviceModelUuid != null && !"".equals(serviceModelUuid)) {
297 uuid = serviceModelUuid;
298 service = serviceRepo.findOneByModelUUID(serviceModelUuid);
301 throw(new Exception(NO_MATCHING_PARAMETERS));
305 ret = service.getNetworkCustomizations();
307 if (ret == null || ret.isEmpty()) {
308 logger.debug ("serviceNetworks not found");
309 respStatus = HttpStatus.SC_NOT_FOUND;
310 qryResp = new QueryServiceNetworks();
312 qryResp = new QueryServiceNetworks(ret);
313 logger.debug ("serviceNetworks found qryResp= {}", qryResp);
315 return respond(version, respStatus, isArray, qryResp);
316 } catch (Exception e) {
317 logger.error ("Exception - queryServiceNetworks", e);
318 CatalogQueryException excResp = new CatalogQueryException(e.getMessage(), CatalogQueryExceptionCategory.INTERNAL, Boolean.FALSE, null);
320 .status(HttpStatus.SC_INTERNAL_SERVER_ERROR)
321 .entity(new GenericEntity<CatalogQueryException>(excResp) {})
327 @Path("serviceResources")
328 @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
329 @Transactional(readOnly = true)
330 public Response serviceResources(
331 @PathParam("version") String version,
332 @QueryParam("serviceModelUuid") String modelUUID,
333 @QueryParam("serviceModelInvariantUuid") String modelInvariantUUID,
334 @QueryParam("serviceModelVersion") String modelVersion) {
335 QueryServiceMacroHolder qryResp;
336 int respStatus = HttpStatus.SC_OK;
338 ServiceMacroHolder ret = new ServiceMacroHolder();
341 if (modelUUID != null && !"".equals(modelUUID)) {
343 logger.debug ("Query serviceMacroHolder getAllResourcesByServiceModelUuid serviceModelUuid: {}" , uuid);
344 Service serv =serviceRepo.findOneByModelUUID(uuid);
347 ret.setNetworkResourceCustomizations(new ArrayList(serv.getNetworkCustomizations()));
348 ret.setVnfResourceCustomizations(new ArrayList(serv.getVnfCustomizations()));
349 ret.setAllottedResourceCustomizations(new ArrayList(serv.getAllottedCustomizations()));
351 ret.setService(serv);
353 else if (modelInvariantUUID != null && !"".equals(modelInvariantUUID)) {
354 uuid = modelInvariantUUID;
355 if (modelVersion != null && !"".equals(modelVersion)) {
356 logger.debug ("Query serviceMacroHolder getAllResourcesByServiceModelInvariantUuid serviceModelInvariantUuid: {} serviceModelVersion: {}",uuid, modelVersion);
357 Service serv = serviceRepo.findFirstByModelVersionAndModelInvariantUUID(modelVersion, uuid);
359 ret.setService(serv);
362 logger.debug ("Query serviceMacroHolder getAllResourcesByServiceModelInvariantUuid serviceModelUuid: {}" , uuid);
363 Service serv = serviceRepo.findFirstByModelInvariantUUIDOrderByModelVersionDesc(uuid);
364 ret.setService(serv);
368 throw(new Exception(NO_MATCHING_PARAMETERS));
371 if (ret.getService() == null) {
372 logger.debug ("serviceMacroHolder not found");
373 respStatus = HttpStatus.SC_NOT_FOUND;
374 qryResp = new QueryServiceMacroHolder();
376 qryResp = new QueryServiceMacroHolder(ret);
377 logger.debug ("serviceMacroHolder qryResp= {}", qryResp);
379 return respond(version, respStatus, IS_ARRAY, qryResp);
380 } catch (Exception e) {
381 logger.error ("Exception - queryServiceMacroHolder", e);
382 CatalogQueryException excResp = new CatalogQueryException(e.getMessage(), CatalogQueryExceptionCategory.INTERNAL, Boolean.FALSE, null);
384 .status(HttpStatus.SC_INTERNAL_SERVER_ERROR)
385 .entity(new GenericEntity<CatalogQueryException>(excResp){} )
392 @Path("allottedResources/{arModelCustomizationUuid}")
393 @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
394 @Transactional( readOnly = true)
395 public Response serviceAllottedResources (
396 @PathParam("version") String version,
397 @PathParam("arModelCustomizationUuid") String aUuid
399 return serviceAllottedResourcesImpl(version, !IS_ARRAY, aUuid, null, null, null);
403 @Path("serviceAllottedResources")
404 @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
405 @Transactional( readOnly = true)
406 public Response serviceAllottedResources(
407 @PathParam("version") String version,
408 @QueryParam("serviceModelUuid") String smUuid,
409 @QueryParam("serviceModelInvariantUuid") String smiUuid,
410 @QueryParam("serviceModelVersion") String smVer,
411 @QueryParam("arModelCustomizationUuid") String aUuid
413 return serviceAllottedResourcesImpl(version, IS_ARRAY, aUuid, smUuid, smiUuid, smVer);
416 public Response serviceAllottedResourcesImpl(String version, boolean isArray, String aUuid, String smUuid, String serviceModelInvariantUuid, String smVer) {
417 QueryAllottedResourceCustomization qryResp;
418 int respStatus = HttpStatus.SC_OK;
420 List<AllottedResourceCustomization> ret = new ArrayList<>();
421 Service service = null;
423 if (smUuid != null && !"".equals(smUuid)) {
425 service = serviceRepo.findFirstOneByModelUUIDOrderByModelVersionDesc(uuid);
427 else if (serviceModelInvariantUuid != null && !"".equals(serviceModelInvariantUuid)) {
428 uuid = serviceModelInvariantUuid;
429 if (smVer != null && !"".equals(smVer)) {
430 service = serviceRepo.findFirstByModelVersionAndModelInvariantUUID(smVer, uuid);
433 service = serviceRepo.findFirstByModelInvariantUUIDOrderByModelVersionDesc(uuid);
436 else if (aUuid != null && !"".equals(aUuid)) {
438 ret = allottedCustomizationRepo.findByModelCustomizationUUID(uuid);
441 throw(new Exception(NO_MATCHING_PARAMETERS));
445 ret=service.getAllottedCustomizations();
447 if (ret == null || ret.isEmpty()) {
448 logger.debug ("AllottedResourceCustomization not found");
449 respStatus = HttpStatus.SC_NOT_FOUND;
450 qryResp = new QueryAllottedResourceCustomization();
452 qryResp = new QueryAllottedResourceCustomization(ret);
453 logger.debug ("AllottedResourceCustomization qryResp= {}", qryResp);
455 return respond(version, respStatus, isArray, qryResp);
456 } catch (Exception e) {
457 logger.error ("Exception - queryAllottedResourceCustomization", e);
458 CatalogQueryException excResp = new CatalogQueryException(e.getMessage(), CatalogQueryExceptionCategory.INTERNAL, Boolean.FALSE, null);
460 .status(HttpStatus.SC_INTERNAL_SERVER_ERROR)
461 .entity(new GenericEntity<CatalogQueryException>(excResp) {})
468 @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
469 @Transactional( readOnly = true)
470 public Response vfModules(@QueryParam("vfModuleModelName") String vfModuleModelName) {
471 QueryVfModule qryResp;
472 int respStatus = HttpStatus.SC_OK;
473 List<VfModuleCustomization> ret = null;
475 if(vfModuleModelName != null && !"".equals(vfModuleModelName)){
476 VfModule vfModule = vfModuleRepo.findFirstByModelNameOrderByModelVersionDesc(vfModuleModelName);
478 ret = vfModule.getVfModuleCustomization();
480 throw(new Exception(NO_MATCHING_PARAMETERS));
483 if(ret == null || ret.isEmpty()){
484 logger.debug ("vfModules not found");
485 respStatus = HttpStatus.SC_NOT_FOUND;
486 qryResp = new QueryVfModule();
488 qryResp = new QueryVfModule(ret);
489 if(logger.isDebugEnabled())
490 logger.debug ("vfModules tojsonstring is: {}", qryResp.JSON2(false, false));
494 .entity(qryResp.JSON2(false, false))
495 .header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
498 logger.error ("Exception during query VfModules by vfModuleModuleName: ", e);
499 CatalogQueryException excResp = new CatalogQueryException(e.getMessage(), CatalogQueryExceptionCategory.INTERNAL, Boolean.FALSE, null);
501 .status(HttpStatus.SC_INTERNAL_SERVER_ERROR)
502 .entity(new GenericEntity<CatalogQueryException>(excResp) {})
507 * Get the tosca csar info from catalog
510 * @param smUuid service model uuid
511 * @return the tosca csar information of the serivce.
512 * @since ONAP Beijing Release
515 @Path("serviceToscaCsar")
516 @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
517 public Response serviceToscaCsar(@QueryParam("serviceModelUuid") String smUuid) {
518 int respStatus = HttpStatus.SC_OK;
521 if (smUuid != null && !"".equals(smUuid)) {
522 logger.debug("Query Csar by service model uuid: {}",smUuid);
524 Service service = serviceRepo.findFirstOneByModelUUIDOrderByModelVersionDesc(smUuid);
526 if (service != null) {
527 ToscaCsar toscaCsar = service.getCsar();
528 if (toscaCsar != null) {
529 QueryServiceCsar serviceCsar = new QueryServiceCsar(toscaCsar);
530 entity = serviceCsar.JSON2(false, false);
532 respStatus = HttpStatus.SC_NOT_FOUND;
535 respStatus = HttpStatus.SC_NOT_FOUND;
539 throw (new Exception("Incoming parameter is null or blank"));
544 .header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
546 } catch (Exception e) {
547 logger.error("Exception during query csar by service model uuid: ", e);
548 CatalogQueryException excResp = new CatalogQueryException(e.getMessage(),
549 CatalogQueryExceptionCategory.INTERNAL, Boolean.FALSE, null);
551 .status(HttpStatus.SC_INTERNAL_SERVER_ERROR)
552 .entity(new GenericEntity<CatalogQueryException>(excResp) {
559 * Get the resource recipe info from catalog
562 * @param rmUuid resource model uuid
563 * @return the recipe information of the resource.
564 * @since ONAP Beijing Release
567 @Path("resourceRecipe")
568 @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
569 public Response resourceRecipe(@QueryParam("resourceModelUuid") String rmUuid, @QueryParam("action") String action) {
570 int respStatus = HttpStatus.SC_OK;
573 if (rmUuid != null && !"".equals(rmUuid)) {
574 logger.debug("Query recipe by resource model uuid: {}", rmUuid);
575 //check vnf and network and ar, the resource could be any resource.
576 Recipe recipe = null;
578 VnfResource vnf = vnfResourceRepo.findResourceByModelUUID(rmUuid);
580 recipe = vnfRecipeRepo.findFirstVnfRecipeByNfRoleAndActionAndVersionStr(vnf.getModelName(), action, vnf.getModelVersion());
582 // for network service fetch the default recipe
583 if (recipe == null && vnf.getSubCategory().equalsIgnoreCase(NETWORK_SERVICE)) {
584 recipe = vnfRecipeRepo.findFirstVnfRecipeByNfRoleAndAction("NS_DEFAULT", action);
589 if (null == recipe) {
590 NetworkResource nResource = networkResourceRepo.findResourceByModelUUID(rmUuid);
592 if(nResource != null) {
593 recipe = networkRecipeRepo.findFirstByModelNameAndActionAndVersionStr(nResource.getModelName(), action, nResource.getModelVersion());
595 // for network fetch the default recipe
596 if (recipe == null) {
597 recipe = networkRecipeRepo.findFirstByModelNameAndAction("SDNC_DEFAULT", action);
602 if (null == recipe) {
603 AllottedResource arResource = arResourceRepo.findResourceByModelUUID(rmUuid);
604 if (arResource != null) {
605 recipe = arRecipeRepo.findByModelNameAndActionAndVersion(arResource.getModelName(), action, arResource.getModelVersion());
608 if (recipe != null) {
609 QueryResourceRecipe resourceRecipe = new QueryResourceRecipe(recipe);
610 entity = resourceRecipe.JSON2(false, false);
612 respStatus = HttpStatus.SC_NOT_FOUND;
615 throw new Exception("Incoming parameter is null or blank");
620 .header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
622 } catch (Exception e) {
623 logger.error("Exception during query recipe by resource model uuid: ", e);
624 CatalogQueryException excResp = new CatalogQueryException(e.getMessage(),
625 CatalogQueryExceptionCategory.INTERNAL, Boolean.FALSE, null);
627 .status(HttpStatus.SC_INTERNAL_SERVER_ERROR)
628 .entity(new GenericEntity<CatalogQueryException>(excResp) {