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.VnfResource;
77 import org.onap.so.db.catalog.beans.VnfResourceCustomization;
78 import org.onap.so.db.catalog.data.repository.AllottedResourceCustomizationRepository;
79 import org.onap.so.db.catalog.data.repository.AllottedResourceRepository;
80 import org.onap.so.db.catalog.data.repository.ArRecipeRepository;
81 import org.onap.so.db.catalog.data.repository.NetworkRecipeRepository;
82 import org.onap.so.db.catalog.data.repository.NetworkResourceCustomizationRepository;
83 import org.onap.so.db.catalog.data.repository.NetworkResourceRepository;
84 import org.onap.so.db.catalog.data.repository.ServiceRepository;
85 import org.onap.so.db.catalog.data.repository.ToscaCsarRepository;
86 import org.onap.so.db.catalog.data.repository.VFModuleRepository;
87 import org.onap.so.db.catalog.data.repository.VnfCustomizationRepository;
88 import org.onap.so.db.catalog.data.repository.VnfRecipeRepository;
89 import org.onap.so.db.catalog.data.repository.VnfResourceRepository;
90 import org.onap.so.db.catalog.rest.beans.ServiceMacroHolder;
91 import org.slf4j.Logger;
92 import org.slf4j.LoggerFactory;
93 import org.springframework.beans.factory.annotation.Autowired;
94 import org.springframework.stereotype.Component;
95 import org.springframework.transaction.annotation.Transactional;
97 import javax.ws.rs.GET;
98 import javax.ws.rs.Path;
99 import javax.ws.rs.PathParam;
100 import javax.ws.rs.Produces;
101 import javax.ws.rs.QueryParam;
102 import javax.ws.rs.core.GenericEntity;
103 import javax.ws.rs.core.HttpHeaders;
104 import javax.ws.rs.core.MediaType;
105 import javax.ws.rs.core.Response;
106 import java.util.ArrayList;
107 import java.util.List;
110 * This class services calls to the REST interface for VF Modules (http://host:port/ecomp/mso/catalog/v1)
111 * Both XML and JSON can be produced/consumed. Set Accept: and Content-Type: headers appropriately. XML is the default.
112 * Requests respond synchronously only
114 @Path("/{version: v[0-9]+}")
116 public class CatalogDbAdapterRest {
117 protected static Logger logger = LoggerFactory.getLogger(CatalogDbAdapterRest.class);
118 private static final boolean IS_ARRAY = true;
121 private VnfCustomizationRepository vnfCustomizationRepo;
124 private ServiceRepository serviceRepo;
127 private NetworkResourceCustomizationRepository networkCustomizationRepo;
130 private NetworkResourceRepository networkResourceRepo;
133 private AllottedResourceCustomizationRepository allottedCustomizationRepo;
136 private ToscaCsarRepository toscaCsarRepo;
139 private VFModuleRepository vfModuleRepo;
142 private VnfRecipeRepository vnfRecipeRepo;
145 private NetworkRecipeRepository networkRecipeRepo;
148 private ArRecipeRepository arRecipeRepo;
151 private VnfResourceRepository vnfResourceRepo;
154 private AllottedResourceRepository arResourceRepo;
156 private static final String NO_MATCHING_PARAMETERS = "no matching parameters";
158 public Response respond(String version, int respStatus, boolean isArray, CatalogQuery qryResp) {
161 //.entity(new GenericEntity<QueryServiceVnfs>(qryResp) {})
162 .entity(qryResp.toJsonString(version, isArray))
163 .header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
168 @Path("vnfResources/{vnfModelCustomizationUuid}")
169 @Transactional( readOnly = true)
170 @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
171 public Response serviceVnfs (
172 @PathParam("version") String version,
173 @PathParam("vnfModelCustomizationUuid") String vnfUuid
175 return serviceVnfsImpl (version, !IS_ARRAY, vnfUuid, null, null, null, null);
180 @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
181 @Transactional( readOnly = true)
182 public Response serviceVnfs(
183 @PathParam("version") String version,
184 @QueryParam("vnfModelCustomizationUuid") String vnfUuid,
185 @QueryParam("serviceModelUuid") String smUuid,
186 @QueryParam("serviceModelInvariantUuid") String smiUuid,
187 @QueryParam("serviceModelVersion") String smVer,
188 @QueryParam("serviceModelName") String smName
190 return serviceVnfsImpl (version, IS_ARRAY, vnfUuid, smUuid, smiUuid, smVer, smName);
193 public Response serviceVnfsImpl(String version, boolean isArray, String vnfUuid, String serviceModelUUID, String smiUuid, String smVer, String smName) {
194 QueryServiceVnfs qryResp = null;
195 int respStatus = HttpStatus.SC_OK;
196 List<VnfResourceCustomization> ret = new ArrayList<>();
197 Service service = null;
199 if (vnfUuid != null && !"".equals(vnfUuid))
200 ret = vnfCustomizationRepo.findByModelCustomizationUUID(vnfUuid);
201 else if (serviceModelUUID != null && !"".equals(serviceModelUUID))
202 service = serviceRepo.findFirstOneByModelUUIDOrderByModelVersionDesc(serviceModelUUID);
203 else if (smiUuid != null && !"".equals(smiUuid))
204 if (smVer != null && !"".equals(smVer))
205 service = serviceRepo.findFirstByModelVersionAndModelInvariantUUID(smVer,smiUuid);
207 service = serviceRepo.findFirstByModelInvariantUUIDOrderByModelVersionDesc(smiUuid);
208 else if (smName != null && !"".equals(smName)) {
209 if (smVer != null && !"".equals(smVer))
210 service = serviceRepo.findByModelNameAndModelVersion(smName, smVer);
212 service = serviceRepo.findFirstByModelNameOrderByModelVersionDesc(smName);
215 throw(new Exception(NO_MATCHING_PARAMETERS));
218 if (service == null && ret.isEmpty()) {
219 respStatus = HttpStatus.SC_NOT_FOUND;
220 qryResp = new QueryServiceVnfs();
221 }else if( service == null && !ret.isEmpty()){
222 qryResp = new QueryServiceVnfs(ret);
223 } else if (service != null) {
224 qryResp = new QueryServiceVnfs(service.getVnfCustomizations());
226 logger.debug ("serviceVnfs qryResp= {}", qryResp);
227 return respond(version, respStatus, isArray, qryResp);
228 } catch (Exception e) {
229 logger.error("Exception - queryServiceVnfs", e);
230 CatalogQueryException excResp = new CatalogQueryException(e.getMessage(), CatalogQueryExceptionCategory.INTERNAL, Boolean.FALSE, null);
232 .status(HttpStatus.SC_INTERNAL_SERVER_ERROR)
233 .entity(new GenericEntity<CatalogQueryException>(excResp) {})
239 @Path("networkResources/{networkModelCustomizationUuid}")
240 @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
241 @Transactional( readOnly = true)
242 public Response serviceNetworks (
243 @PathParam("version") String version,
244 @PathParam("networkModelCustomizationUuid") String nUuid
246 return serviceNetworksImpl (version, !IS_ARRAY, nUuid, null, null, null, null);
250 @Path("serviceNetworks")
251 @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
252 @Transactional( readOnly = true)
253 public Response serviceNetworks (
254 @PathParam("version") String version,
255 @QueryParam("networkModelCustomizationUuid") String networkModelCustomizationUuid,
256 @QueryParam("networkType") String networkType,
257 @QueryParam("networkModelName") String networkModelName,
258 @QueryParam("serviceModelUuid") String serviceModelUuid,
259 @QueryParam("serviceModelInvariantUuid") String serviceModelInvariantUuid,
260 @QueryParam("serviceModelVersion") String serviceModelVersion,
261 @QueryParam("networkModelVersion") String networkModelVersion
263 if (networkModelName != null && !"".equals(networkModelName)) {
264 networkType = networkModelName;
266 return serviceNetworksImpl (version, IS_ARRAY, networkModelCustomizationUuid, networkType, serviceModelUuid, serviceModelInvariantUuid, serviceModelVersion);
269 public Response serviceNetworksImpl (String version, boolean isArray, String networkModelCustomizationUuid, String networkType, String serviceModelUuid, String serviceModelInvariantUuid, String serviceModelVersion) {
270 QueryServiceNetworks qryResp;
271 int respStatus = HttpStatus.SC_OK;
273 List<NetworkResourceCustomization> ret = new ArrayList<>();
274 Service service = null;
277 if (networkModelCustomizationUuid != null && !"".equals(networkModelCustomizationUuid)) {
278 uuid = networkModelCustomizationUuid;
279 ret = networkCustomizationRepo.findByModelCustomizationUUID(networkModelCustomizationUuid);
280 }else if (networkType != null && !"".equals(networkType)) {
282 NetworkResource networkResources = networkResourceRepo.findFirstByModelNameOrderByModelVersionDesc(networkType);
283 if(networkResources != null)
284 ret=networkResources.getNetworkResourceCustomization();
286 else if (serviceModelInvariantUuid != null && !"".equals(serviceModelInvariantUuid)) {
287 uuid = serviceModelInvariantUuid;
288 if (serviceModelVersion != null && !"".equals(serviceModelVersion)) {
289 service = serviceRepo.findFirstByModelVersionAndModelInvariantUUID(serviceModelVersion, uuid);
292 service = serviceRepo.findFirstByModelInvariantUUIDOrderByModelVersionDesc(uuid);
294 }else if (serviceModelUuid != null && !"".equals(serviceModelUuid)) {
295 uuid = serviceModelUuid;
296 service = serviceRepo.findOneByModelUUID(serviceModelUuid);
299 throw(new Exception(NO_MATCHING_PARAMETERS));
303 ret = service.getNetworkCustomizations();
305 if (ret == null || ret.isEmpty()) {
306 logger.debug ("serviceNetworks not found");
307 respStatus = HttpStatus.SC_NOT_FOUND;
308 qryResp = new QueryServiceNetworks();
310 qryResp = new QueryServiceNetworks(ret);
311 logger.debug ("serviceNetworks found qryResp= {}", qryResp);
313 return respond(version, respStatus, isArray, qryResp);
314 } catch (Exception e) {
315 logger.error ("Exception - queryServiceNetworks", e);
316 CatalogQueryException excResp = new CatalogQueryException(e.getMessage(), CatalogQueryExceptionCategory.INTERNAL, Boolean.FALSE, null);
318 .status(HttpStatus.SC_INTERNAL_SERVER_ERROR)
319 .entity(new GenericEntity<CatalogQueryException>(excResp) {})
325 @Path("serviceResources")
326 @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
327 @Transactional(readOnly = true)
328 public Response serviceResources(
329 @PathParam("version") String version,
330 @QueryParam("serviceModelUuid") String modelUUID,
331 @QueryParam("serviceModelInvariantUuid") String modelInvariantUUID,
332 @QueryParam("serviceModelVersion") String modelVersion) {
333 QueryServiceMacroHolder qryResp;
334 int respStatus = HttpStatus.SC_OK;
336 ServiceMacroHolder ret = new ServiceMacroHolder();
339 if (modelUUID != null && !"".equals(modelUUID)) {
341 logger.debug ("Query serviceMacroHolder getAllResourcesByServiceModelUuid serviceModelUuid: {}" , uuid);
342 Service serv =serviceRepo.findOneByModelUUID(uuid);
345 ret.setNetworkResourceCustomizations(new ArrayList(serv.getNetworkCustomizations()));
346 ret.setVnfResourceCustomizations(new ArrayList(serv.getVnfCustomizations()));
347 ret.setAllottedResourceCustomizations(new ArrayList(serv.getAllottedCustomizations()));
349 ret.setService(serv);
351 else if (modelInvariantUUID != null && !"".equals(modelInvariantUUID)) {
352 uuid = modelInvariantUUID;
353 if (modelVersion != null && !"".equals(modelVersion)) {
354 logger.debug ("Query serviceMacroHolder getAllResourcesByServiceModelInvariantUuid serviceModelInvariantUuid: {} serviceModelVersion: {}",uuid, modelVersion);
355 Service serv = serviceRepo.findFirstByModelVersionAndModelInvariantUUID(modelVersion, uuid);
357 ret.setService(serv);
360 logger.debug ("Query serviceMacroHolder getAllResourcesByServiceModelInvariantUuid serviceModelUuid: {}" , uuid);
361 Service serv = serviceRepo.findFirstByModelInvariantUUIDOrderByModelVersionDesc(uuid);
362 ret.setService(serv);
366 throw(new Exception(NO_MATCHING_PARAMETERS));
369 if (ret.getService() == null) {
370 logger.debug ("serviceMacroHolder not found");
371 respStatus = HttpStatus.SC_NOT_FOUND;
372 qryResp = new QueryServiceMacroHolder();
374 qryResp = new QueryServiceMacroHolder(ret);
375 logger.debug ("serviceMacroHolder qryResp= {}", qryResp);
377 return respond(version, respStatus, IS_ARRAY, qryResp);
378 } catch (Exception e) {
379 logger.error ("Exception - queryServiceMacroHolder", e);
380 CatalogQueryException excResp = new CatalogQueryException(e.getMessage(), CatalogQueryExceptionCategory.INTERNAL, Boolean.FALSE, null);
382 .status(HttpStatus.SC_INTERNAL_SERVER_ERROR)
383 .entity(new GenericEntity<CatalogQueryException>(excResp){} )
390 @Path("allottedResources/{arModelCustomizationUuid}")
391 @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
392 @Transactional( readOnly = true)
393 public Response serviceAllottedResources (
394 @PathParam("version") String version,
395 @PathParam("arModelCustomizationUuid") String aUuid
397 return serviceAllottedResourcesImpl(version, !IS_ARRAY, aUuid, null, null, null);
401 @Path("serviceAllottedResources")
402 @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
403 @Transactional( readOnly = true)
404 public Response serviceAllottedResources(
405 @PathParam("version") String version,
406 @QueryParam("serviceModelUuid") String smUuid,
407 @QueryParam("serviceModelInvariantUuid") String smiUuid,
408 @QueryParam("serviceModelVersion") String smVer,
409 @QueryParam("arModelCustomizationUuid") String aUuid
411 return serviceAllottedResourcesImpl(version, IS_ARRAY, aUuid, smUuid, smiUuid, smVer);
414 public Response serviceAllottedResourcesImpl(String version, boolean isArray, String aUuid, String smUuid, String serviceModelInvariantUuid, String smVer) {
415 QueryAllottedResourceCustomization qryResp;
416 int respStatus = HttpStatus.SC_OK;
418 List<AllottedResourceCustomization> ret = new ArrayList<>();
419 Service service = null;
421 if (smUuid != null && !"".equals(smUuid)) {
423 service = serviceRepo.findFirstOneByModelUUIDOrderByModelVersionDesc(uuid);
425 else if (serviceModelInvariantUuid != null && !"".equals(serviceModelInvariantUuid)) {
426 uuid = serviceModelInvariantUuid;
427 if (smVer != null && !"".equals(smVer)) {
428 service = serviceRepo.findFirstByModelVersionAndModelInvariantUUID(smVer, uuid);
431 service = serviceRepo.findFirstByModelInvariantUUIDOrderByModelVersionDesc(uuid);
434 else if (aUuid != null && !"".equals(aUuid)) {
436 ret = allottedCustomizationRepo.findByModelCustomizationUUID(uuid);
439 throw(new Exception(NO_MATCHING_PARAMETERS));
443 ret=service.getAllottedCustomizations();
445 if (ret == null || ret.isEmpty()) {
446 logger.debug ("AllottedResourceCustomization not found");
447 respStatus = HttpStatus.SC_NOT_FOUND;
448 qryResp = new QueryAllottedResourceCustomization();
450 qryResp = new QueryAllottedResourceCustomization(ret);
451 logger.debug ("AllottedResourceCustomization qryResp= {}", qryResp);
453 return respond(version, respStatus, isArray, qryResp);
454 } catch (Exception e) {
455 logger.error ("Exception - queryAllottedResourceCustomization", e);
456 CatalogQueryException excResp = new CatalogQueryException(e.getMessage(), CatalogQueryExceptionCategory.INTERNAL, Boolean.FALSE, null);
458 .status(HttpStatus.SC_INTERNAL_SERVER_ERROR)
459 .entity(new GenericEntity<CatalogQueryException>(excResp) {})
466 @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
467 @Transactional( readOnly = true)
468 public Response vfModules(@QueryParam("vfModuleModelName") String vfModuleModelName) {
469 QueryVfModule qryResp;
470 int respStatus = HttpStatus.SC_OK;
471 List<VfModuleCustomization> ret = null;
473 if(vfModuleModelName != null && !"".equals(vfModuleModelName)){
474 VfModule vfModule = vfModuleRepo.findFirstByModelNameOrderByModelVersionDesc(vfModuleModelName);
476 ret = vfModule.getVfModuleCustomization();
478 throw(new Exception(NO_MATCHING_PARAMETERS));
481 if(ret == null || ret.isEmpty()){
482 logger.debug ("vfModules not found");
483 respStatus = HttpStatus.SC_NOT_FOUND;
484 qryResp = new QueryVfModule();
486 qryResp = new QueryVfModule(ret);
487 if(logger.isDebugEnabled())
488 logger.debug ("vfModules tojsonstring is: {}", qryResp.JSON2(false, false));
492 .entity(qryResp.JSON2(false, false))
493 .header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
496 logger.error ("Exception during query VfModules by vfModuleModuleName: ", e);
497 CatalogQueryException excResp = new CatalogQueryException(e.getMessage(), CatalogQueryExceptionCategory.INTERNAL, Boolean.FALSE, null);
499 .status(HttpStatus.SC_INTERNAL_SERVER_ERROR)
500 .entity(new GenericEntity<CatalogQueryException>(excResp) {})
505 * Get the tosca csar info from catalog
508 * @param smUuid service model uuid
509 * @return the tosca csar information of the serivce.
510 * @since ONAP Beijing Release
513 @Path("serviceToscaCsar")
514 @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
515 public Response serviceToscaCsar(@QueryParam("serviceModelUuid") String smUuid) {
516 int respStatus = HttpStatus.SC_OK;
519 if (smUuid != null && !"".equals(smUuid)) {
520 logger.debug("Query Csar by service model uuid: {}",smUuid);
521 ToscaCsar toscaCsar = toscaCsarRepo.findOne(smUuid);
522 if (toscaCsar != null) {
523 QueryServiceCsar serviceCsar = new QueryServiceCsar(toscaCsar);
524 entity = serviceCsar.JSON2(false, false);
526 respStatus = HttpStatus.SC_NOT_FOUND;
529 throw (new Exception("Incoming parameter is null or blank"));
534 .header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
536 } catch (Exception e) {
537 logger.error("Exception during query csar by service model uuid: ", e);
538 CatalogQueryException excResp = new CatalogQueryException(e.getMessage(),
539 CatalogQueryExceptionCategory.INTERNAL, Boolean.FALSE, null);
541 .status(HttpStatus.SC_INTERNAL_SERVER_ERROR)
542 .entity(new GenericEntity<CatalogQueryException>(excResp) {
549 * Get the resource recipe info from catalog
552 * @param rmUuid resource model uuid
553 * @return the recipe information of the resource.
554 * @since ONAP Beijing Release
557 @Path("resourceRecipe")
558 @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
559 public Response resourceRecipe(@QueryParam("resourceModelUuid") String rmUuid, @QueryParam("action") String action) {
560 int respStatus = HttpStatus.SC_OK;
563 if (rmUuid != null && !"".equals(rmUuid)) {
564 logger.debug("Query recipe by resource model uuid: {}", rmUuid);
565 //check vnf and network and ar, the resource could be any resource.
566 VnfResource vnf = vnfResourceRepo.findResourceByModelUUID(rmUuid);
567 Recipe recipe = vnfRecipeRepo.findFirstVnfRecipeByNfRoleAndAction(vnf.getModelName(), action);
568 if (null == recipe) {
569 NetworkResource nResource = networkResourceRepo.findResourceByModelUUID(rmUuid);
570 recipe = networkRecipeRepo.findFirstByModelNameAndAction(nResource.getModelName(), action);
572 if (null == recipe) {
573 AllottedResource arResource = arResourceRepo.findResourceByModelUUID(rmUuid);
574 recipe = arRecipeRepo.findByModelNameAndAction(arResource.getModelName(), action);
576 if (recipe != null) {
577 QueryResourceRecipe resourceRecipe = new QueryResourceRecipe(recipe);
578 entity = resourceRecipe.JSON2(false, false);
580 respStatus = HttpStatus.SC_NOT_FOUND;
583 throw new Exception("Incoming parameter is null or blank");
588 .header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
590 } catch (Exception e) {
591 logger.error("Exception during query recipe by resource model uuid: ", e);
592 CatalogQueryException excResp = new CatalogQueryException(e.getMessage(),
593 CatalogQueryExceptionCategory.INTERNAL, Boolean.FALSE, null);
595 .status(HttpStatus.SC_INTERNAL_SERVER_ERROR)
596 .entity(new GenericEntity<CatalogQueryException>(excResp) {