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;
27 import java.util.ArrayList;
28 import java.util.List;
29 import javax.ws.rs.GET;
30 import javax.ws.rs.Path;
31 import javax.ws.rs.PathParam;
32 import javax.ws.rs.Produces;
33 import javax.ws.rs.QueryParam;
34 import javax.ws.rs.core.GenericEntity;
35 import javax.ws.rs.core.HttpHeaders;
36 import javax.ws.rs.core.MediaType;
37 import javax.ws.rs.core.Response;
38 import org.apache.http.HttpStatus;
39 import org.onap.so.adapters.catalogdb.catalogrest.CatalogQuery;
40 import org.onap.so.adapters.catalogdb.catalogrest.CatalogQueryException;
41 import org.onap.so.adapters.catalogdb.catalogrest.CatalogQueryExceptionCategory;
42 import org.onap.so.adapters.catalogdb.catalogrest.QueryAllottedResourceCustomization;
43 import org.onap.so.adapters.catalogdb.catalogrest.QueryResourceRecipe;
44 import org.onap.so.adapters.catalogdb.catalogrest.QueryServiceCsar;
45 import org.onap.so.adapters.catalogdb.catalogrest.QueryServiceMacroHolder;
46 import org.onap.so.adapters.catalogdb.catalogrest.QueryServiceNetworks;
47 import org.onap.so.adapters.catalogdb.catalogrest.QueryServiceVnfs;
48 import org.onap.so.adapters.catalogdb.catalogrest.QueryVfModule;
49 import org.onap.so.db.catalog.beans.AllottedResource;
50 import org.onap.so.db.catalog.beans.AllottedResourceCustomization;
51 import org.onap.so.db.catalog.beans.InstanceGroup;
52 import org.onap.so.db.catalog.beans.NetworkResource;
53 import org.onap.so.db.catalog.beans.NetworkResourceCustomization;
54 import org.onap.so.db.catalog.beans.Recipe;
55 import org.onap.so.db.catalog.beans.Service;
56 import org.onap.so.db.catalog.beans.ToscaCsar;
57 import org.onap.so.db.catalog.beans.VfModule;
58 import org.onap.so.db.catalog.beans.VfModuleCustomization;
59 import org.onap.so.db.catalog.beans.VnfRecipe;
60 import org.onap.so.db.catalog.beans.VnfResource;
61 import org.onap.so.db.catalog.beans.VnfResourceCustomization;
62 import org.onap.so.db.catalog.data.repository.AllottedResourceCustomizationRepository;
63 import org.onap.so.db.catalog.data.repository.AllottedResourceRepository;
64 import org.onap.so.db.catalog.data.repository.ArRecipeRepository;
65 import org.onap.so.db.catalog.data.repository.InstanceGroupRepository;
66 import org.onap.so.db.catalog.data.repository.NetworkRecipeRepository;
67 import org.onap.so.db.catalog.data.repository.NetworkResourceCustomizationRepository;
68 import org.onap.so.db.catalog.data.repository.NetworkResourceRepository;
69 import org.onap.so.db.catalog.data.repository.ServiceRepository;
70 import org.onap.so.db.catalog.data.repository.ToscaCsarRepository;
71 import org.onap.so.db.catalog.data.repository.VFModuleRepository;
72 import org.onap.so.db.catalog.data.repository.VnfCustomizationRepository;
73 import org.onap.so.db.catalog.data.repository.VnfRecipeRepository;
74 import org.onap.so.db.catalog.data.repository.VnfResourceRepository;
75 import org.onap.so.db.catalog.rest.beans.ServiceMacroHolder;
76 import org.slf4j.Logger;
77 import org.slf4j.LoggerFactory;
78 import org.springframework.beans.factory.annotation.Autowired;
79 import org.springframework.stereotype.Component;
80 import org.springframework.transaction.annotation.Transactional;
83 @Path("/{version: v[0-9]+}")
85 public class CatalogDbAdapterRest {
86 protected static Logger logger = LoggerFactory.getLogger(CatalogDbAdapterRest.class);
87 private static final boolean IS_ARRAY = true;
88 private static final String NETWORK_SERVICE = "network service";
91 private VnfCustomizationRepository vnfCustomizationRepo;
94 private ServiceRepository serviceRepo;
97 private NetworkResourceCustomizationRepository networkCustomizationRepo;
100 private NetworkResourceRepository networkResourceRepo;
103 private AllottedResourceCustomizationRepository allottedCustomizationRepo;
106 private ToscaCsarRepository toscaCsarRepo;
109 private VFModuleRepository vfModuleRepo;
112 private VnfRecipeRepository vnfRecipeRepo;
115 private NetworkRecipeRepository networkRecipeRepo;
118 private ArRecipeRepository arRecipeRepo;
121 private VnfResourceRepository vnfResourceRepo;
124 private AllottedResourceRepository arResourceRepo;
127 private InstanceGroupRepository instanceGroupRepository;
129 private static final String NO_MATCHING_PARAMETERS = "no matching parameters";
131 public Response respond(String version, int respStatus, boolean isArray, CatalogQuery qryResp) {
132 return Response.status(respStatus).entity(qryResp.toJsonString(version, isArray))
133 .header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON).build();
137 @Path("vnfResources/{vnfModelCustomizationUuid}")
138 @Transactional(readOnly = true)
139 @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
140 public Response serviceVnfs(@PathParam("version") String version,
141 @PathParam("vnfModelCustomizationUuid") String vnfUuid) {
142 return serviceVnfsImpl(version, !IS_ARRAY, vnfUuid, null, null, null, null);
147 @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
148 @Transactional(readOnly = true)
149 public Response serviceVnfs(@PathParam("version") String version,
150 @QueryParam("vnfModelCustomizationUuid") String vnfUuid, @QueryParam("serviceModelUuid") String smUuid,
151 @QueryParam("serviceModelInvariantUuid") String smiUuid, @QueryParam("serviceModelVersion") String smVer,
152 @QueryParam("serviceModelName") String smName) {
153 return serviceVnfsImpl(version, IS_ARRAY, vnfUuid, smUuid, smiUuid, smVer, smName);
156 public Response serviceVnfsImpl(String version, boolean isArray, String vnfUuid, String serviceModelUUID,
157 String smiUuid, String smVer, String smName) {
158 QueryServiceVnfs qryResp = null;
159 int respStatus = HttpStatus.SC_OK;
160 List<VnfResourceCustomization> ret = new ArrayList<>();
161 Service service = null;
163 if (vnfUuid != null && !"".equals(vnfUuid))
164 ret = vnfCustomizationRepo.findByModelCustomizationUUID(vnfUuid);
165 else if (serviceModelUUID != null && !"".equals(serviceModelUUID))
166 service = serviceRepo.findFirstOneByModelUUIDOrderByModelVersionDesc(serviceModelUUID);
167 else if (smiUuid != null && !"".equals(smiUuid))
168 if (smVer != null && !"".equals(smVer))
169 service = serviceRepo.findFirstByModelVersionAndModelInvariantUUID(smVer, smiUuid);
171 service = serviceRepo.findFirstByModelInvariantUUIDOrderByModelVersionDesc(smiUuid);
172 else if (smName != null && !"".equals(smName)) {
173 if (smVer != null && !"".equals(smVer))
174 service = serviceRepo.findByModelNameAndModelVersion(smName, smVer);
176 service = serviceRepo.findFirstByModelNameOrderByModelVersionDesc(smName);
178 throw (new Exception(NO_MATCHING_PARAMETERS));
181 if (service == null && ret.isEmpty()) {
182 respStatus = HttpStatus.SC_NOT_FOUND;
183 qryResp = new QueryServiceVnfs();
184 } else if (service == null && !ret.isEmpty()) {
185 qryResp = new QueryServiceVnfs(ret);
186 } else if (service != null) {
187 qryResp = new QueryServiceVnfs(service.getVnfCustomizations());
189 logger.debug("serviceVnfs qryResp= {}", qryResp);
190 return respond(version, respStatus, isArray, qryResp);
191 } catch (Exception e) {
192 logger.error("Exception - queryServiceVnfs", e);
193 CatalogQueryException excResp = new CatalogQueryException(e.getMessage(),
194 CatalogQueryExceptionCategory.INTERNAL, Boolean.FALSE, null);
195 return Response.status(HttpStatus.SC_INTERNAL_SERVER_ERROR)
196 .entity(new GenericEntity<CatalogQueryException>(excResp) {}).build();
201 @Path("networkResources/{networkModelCustomizationUuid}")
202 @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
203 @Transactional(readOnly = true)
204 public Response serviceNetworks(@PathParam("version") String version,
205 @PathParam("networkModelCustomizationUuid") String nUuid) {
206 return serviceNetworksImpl(version, !IS_ARRAY, nUuid, null, null, null, null);
210 @Path("serviceNetworks")
211 @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
212 @Transactional(readOnly = true)
213 public Response serviceNetworks(@PathParam("version") String version,
214 @QueryParam("networkModelCustomizationUuid") String networkModelCustomizationUuid,
215 @QueryParam("networkType") String networkType, @QueryParam("networkModelName") String networkModelName,
216 @QueryParam("serviceModelUuid") String serviceModelUuid,
217 @QueryParam("serviceModelInvariantUuid") String serviceModelInvariantUuid,
218 @QueryParam("serviceModelVersion") String serviceModelVersion,
219 @QueryParam("networkModelVersion") String networkModelVersion) {
220 if (networkModelName != null && !"".equals(networkModelName)) {
221 networkType = networkModelName;
223 return serviceNetworksImpl(version, IS_ARRAY, networkModelCustomizationUuid, networkType, serviceModelUuid,
224 serviceModelInvariantUuid, serviceModelVersion);
227 public Response serviceNetworksImpl(String version, boolean isArray, String networkModelCustomizationUuid,
228 String networkType, String serviceModelUuid, String serviceModelInvariantUuid, String serviceModelVersion) {
229 QueryServiceNetworks qryResp;
230 int respStatus = HttpStatus.SC_OK;
232 List<NetworkResourceCustomization> ret = new ArrayList<>();
233 Service service = null;
236 if (networkModelCustomizationUuid != null && !"".equals(networkModelCustomizationUuid)) {
237 uuid = networkModelCustomizationUuid;
238 ret = networkCustomizationRepo.findByModelCustomizationUUID(networkModelCustomizationUuid);
239 } else if (networkType != null && !"".equals(networkType)) {
241 NetworkResource networkResources =
242 networkResourceRepo.findFirstByModelNameOrderByModelVersionDesc(networkType);
243 if (networkResources != null)
244 ret = networkResources.getNetworkResourceCustomization();
245 } else if (serviceModelInvariantUuid != null && !"".equals(serviceModelInvariantUuid)) {
246 uuid = serviceModelInvariantUuid;
247 if (serviceModelVersion != null && !"".equals(serviceModelVersion)) {
248 service = serviceRepo.findFirstByModelVersionAndModelInvariantUUID(serviceModelVersion, uuid);
250 service = serviceRepo.findFirstByModelInvariantUUIDOrderByModelVersionDesc(uuid);
252 } else if (serviceModelUuid != null && !"".equals(serviceModelUuid)) {
253 uuid = serviceModelUuid;
254 service = serviceRepo.findOneByModelUUID(serviceModelUuid);
256 throw (new Exception(NO_MATCHING_PARAMETERS));
260 ret = service.getNetworkCustomizations();
262 if (ret == null || ret.isEmpty()) {
263 logger.debug("serviceNetworks not found");
264 respStatus = HttpStatus.SC_NOT_FOUND;
265 qryResp = new QueryServiceNetworks();
267 qryResp = new QueryServiceNetworks(ret);
268 logger.debug("serviceNetworks found qryResp= {}", qryResp);
270 return respond(version, respStatus, isArray, qryResp);
271 } catch (Exception e) {
272 logger.error("Exception - queryServiceNetworks", e);
273 CatalogQueryException excResp = new CatalogQueryException(e.getMessage(),
274 CatalogQueryExceptionCategory.INTERNAL, Boolean.FALSE, null);
275 return Response.status(HttpStatus.SC_INTERNAL_SERVER_ERROR)
276 .entity(new GenericEntity<CatalogQueryException>(excResp) {}).build();
281 @Path("serviceResources")
282 @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
283 @Transactional(readOnly = true)
284 public Response serviceResources(@PathParam("version") String version,
285 @QueryParam("serviceModelUuid") String modelUUID,
286 @QueryParam("serviceModelInvariantUuid") String modelInvariantUUID,
287 @QueryParam("serviceModelVersion") String modelVersion) {
289 QueryServiceMacroHolder qryResp;
290 int respStatus = HttpStatus.SC_OK;
292 ServiceMacroHolder ret = new ServiceMacroHolder();
295 if (modelUUID != null && !"".equals(modelUUID)) {
297 logger.debug("Query serviceMacroHolder getAllResourcesByServiceModelUuid serviceModelUuid: {}", uuid);
298 Service serv = serviceRepo.findOneByModelUUID(uuid);
301 ret.setNetworkResourceCustomizations(new ArrayList(serv.getNetworkCustomizations()));
302 ret.setVnfResourceCustomizations(new ArrayList(serv.getVnfCustomizations()));
303 ret.setAllottedResourceCustomizations(new ArrayList(serv.getAllottedCustomizations()));
305 ret.setService(serv);
306 } else if (modelInvariantUUID != null && !"".equals(modelInvariantUUID)) {
307 uuid = modelInvariantUUID;
308 if (modelVersion != null && !"".equals(modelVersion)) {
310 "Query serviceMacroHolder getAllResourcesByServiceModelInvariantUuid serviceModelInvariantUuid: {} serviceModelVersion: {}",
312 Service serv = serviceRepo.findFirstByModelVersionAndModelInvariantUUID(modelVersion, uuid);
314 ret.setService(serv);
317 "Query serviceMacroHolder getAllResourcesByServiceModelInvariantUuid serviceModelUuid: {}",
319 Service serv = serviceRepo.findFirstByModelInvariantUUIDOrderByModelVersionDesc(uuid);
320 ret.setService(serv);
323 throw (new Exception(NO_MATCHING_PARAMETERS));
326 if (ret.getService() == null) {
327 logger.debug("serviceMacroHolder not found");
328 respStatus = HttpStatus.SC_NOT_FOUND;
329 qryResp = new QueryServiceMacroHolder();
331 qryResp = new QueryServiceMacroHolder(ret);
332 logger.debug("serviceMacroHolder qryResp= {}", qryResp);
334 return respond(version, respStatus, IS_ARRAY, qryResp);
335 } catch (Exception e) {
336 logger.error("Exception - queryServiceMacroHolder", e);
337 CatalogQueryException excResp = new CatalogQueryException(e.getMessage(),
338 CatalogQueryExceptionCategory.INTERNAL, Boolean.FALSE, null);
339 return Response.status(HttpStatus.SC_INTERNAL_SERVER_ERROR)
340 .entity(new GenericEntity<CatalogQueryException>(excResp) {}).build();
346 @Path("allottedResources/{arModelCustomizationUuid}")
347 @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
348 @Transactional(readOnly = true)
349 public Response serviceAllottedResources(@PathParam("version") String version,
350 @PathParam("arModelCustomizationUuid") String aUuid) {
351 return serviceAllottedResourcesImpl(version, !IS_ARRAY, aUuid, null, null, null);
355 @Path("serviceAllottedResources")
356 @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
357 @Transactional(readOnly = true)
358 public Response serviceAllottedResources(@PathParam("version") String version,
359 @QueryParam("serviceModelUuid") String smUuid, @QueryParam("serviceModelInvariantUuid") String smiUuid,
360 @QueryParam("serviceModelVersion") String smVer, @QueryParam("arModelCustomizationUuid") String aUuid) {
361 return serviceAllottedResourcesImpl(version, IS_ARRAY, aUuid, smUuid, smiUuid, smVer);
364 public Response serviceAllottedResourcesImpl(String version, boolean isArray, String aUuid, String smUuid,
365 String serviceModelInvariantUuid, String smVer) {
366 QueryAllottedResourceCustomization qryResp;
367 int respStatus = HttpStatus.SC_OK;
369 List<AllottedResourceCustomization> ret = new ArrayList<>();
370 Service service = null;
372 if (smUuid != null && !"".equals(smUuid)) {
374 service = serviceRepo.findFirstOneByModelUUIDOrderByModelVersionDesc(uuid);
375 } else if (serviceModelInvariantUuid != null && !"".equals(serviceModelInvariantUuid)) {
376 uuid = serviceModelInvariantUuid;
377 if (smVer != null && !"".equals(smVer)) {
378 service = serviceRepo.findFirstByModelVersionAndModelInvariantUUID(smVer, uuid);
380 service = serviceRepo.findFirstByModelInvariantUUIDOrderByModelVersionDesc(uuid);
382 } else if (aUuid != null && !"".equals(aUuid)) {
384 ret = allottedCustomizationRepo.findByModelCustomizationUUID(uuid);
386 throw (new Exception(NO_MATCHING_PARAMETERS));
390 ret = service.getAllottedCustomizations();
392 if (ret == null || ret.isEmpty()) {
393 logger.debug("AllottedResourceCustomization not found");
394 respStatus = HttpStatus.SC_NOT_FOUND;
395 qryResp = new QueryAllottedResourceCustomization();
397 qryResp = new QueryAllottedResourceCustomization(ret);
398 logger.debug("AllottedResourceCustomization qryResp= {}", qryResp);
400 return respond(version, respStatus, isArray, qryResp);
401 } catch (Exception e) {
402 logger.error("Exception - queryAllottedResourceCustomization", e);
403 CatalogQueryException excResp = new CatalogQueryException(e.getMessage(),
404 CatalogQueryExceptionCategory.INTERNAL, Boolean.FALSE, null);
405 return Response.status(HttpStatus.SC_INTERNAL_SERVER_ERROR)
406 .entity(new GenericEntity<CatalogQueryException>(excResp) {}).build();
412 @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
413 @Transactional(readOnly = true)
414 public Response vfModules(@QueryParam("vfModuleModelName") String vfModuleModelName) {
415 QueryVfModule qryResp;
416 int respStatus = HttpStatus.SC_OK;
417 List<VfModuleCustomization> ret = null;
419 if (vfModuleModelName != null && !"".equals(vfModuleModelName)) {
420 VfModule vfModule = vfModuleRepo.findFirstByModelNameOrderByModelVersionDesc(vfModuleModelName);
421 if (vfModule != null)
422 ret = vfModule.getVfModuleCustomization();
424 throw (new Exception(NO_MATCHING_PARAMETERS));
427 if (ret == null || ret.isEmpty()) {
428 logger.debug("vfModules not found");
429 respStatus = HttpStatus.SC_NOT_FOUND;
430 qryResp = new QueryVfModule();
432 qryResp = new QueryVfModule(ret);
433 if (logger.isDebugEnabled())
434 logger.debug("vfModules tojsonstring is: {}", qryResp.JSON2(false, false));
436 return Response.status(respStatus).entity(qryResp.JSON2(false, false))
437 .header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON).build();
438 } catch (Exception e) {
439 logger.error("Exception during query VfModules by vfModuleModuleName: ", e);
440 CatalogQueryException excResp = new CatalogQueryException(e.getMessage(),
441 CatalogQueryExceptionCategory.INTERNAL, Boolean.FALSE, null);
442 return Response.status(HttpStatus.SC_INTERNAL_SERVER_ERROR)
443 .entity(new GenericEntity<CatalogQueryException>(excResp) {}).build();
448 * Get the tosca csar info from catalog <br>
450 * @param smUuid service model uuid
451 * @return the tosca csar information of the serivce.
452 * @since ONAP Beijing Release
455 @Path("serviceToscaCsar")
456 @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
457 public Response serviceToscaCsar(@QueryParam("serviceModelUuid") String smUuid) {
458 int respStatus = HttpStatus.SC_OK;
461 if (smUuid != null && !"".equals(smUuid)) {
462 logger.debug("Query Csar by service model uuid: {}", smUuid);
464 Service service = serviceRepo.findFirstOneByModelUUIDOrderByModelVersionDesc(smUuid);
466 if (service != null) {
467 ToscaCsar toscaCsar = service.getCsar();
468 if (toscaCsar != null) {
469 QueryServiceCsar serviceCsar = new QueryServiceCsar(toscaCsar);
470 entity = serviceCsar.JSON2(false, false);
472 respStatus = HttpStatus.SC_NOT_FOUND;
475 respStatus = HttpStatus.SC_NOT_FOUND;
479 throw (new Exception("Incoming parameter is null or blank"));
481 return Response.status(respStatus).entity(entity)
482 .header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON).build();
483 } catch (Exception e) {
484 logger.error("Exception during query csar by service model uuid: ", e);
485 CatalogQueryException excResp = new CatalogQueryException(e.getMessage(),
486 CatalogQueryExceptionCategory.INTERNAL, Boolean.FALSE, null);
487 return Response.status(HttpStatus.SC_INTERNAL_SERVER_ERROR)
488 .entity(new GenericEntity<CatalogQueryException>(excResp) {}).build();
493 * Get the resource recipe info from catalog <br>
495 * @param rmUuid resource model uuid
496 * @return the recipe information of the resource.
497 * @since ONAP Beijing Release
500 @Path("resourceRecipe")
501 @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
502 public Response resourceRecipe(@QueryParam("resourceModelUuid") String rmUuid,
503 @QueryParam("action") String action) {
504 int respStatus = HttpStatus.SC_OK;
507 if (rmUuid != null && !"".equals(rmUuid)) {
508 logger.debug("Query recipe by resource model uuid: {}", rmUuid);
509 // check vnf and network and ar, the resource could be any resource.
510 Recipe recipe = null;
512 VnfResource vnf = vnfResourceRepo.findResourceByModelUUID(rmUuid);
514 recipe = vnfRecipeRepo.findFirstVnfRecipeByNfRoleAndActionAndVersionStr(vnf.getModelName(), action,
515 vnf.getModelVersion());
517 // for network service fetch the default recipe
518 if (recipe == null && vnf.getSubCategory().equalsIgnoreCase(NETWORK_SERVICE)) {
519 recipe = vnfRecipeRepo.findFirstVnfRecipeByNfRoleAndAction("NS_DEFAULT", action);
524 if (null == recipe) {
525 NetworkResource nResource = networkResourceRepo.findResourceByModelUUID(rmUuid);
527 if (nResource != null) {
528 recipe = networkRecipeRepo.findFirstByModelNameAndActionAndVersionStr(nResource.getModelName(),
529 action, nResource.getModelVersion());
531 // for network fetch the default recipe
532 if (recipe == null) {
533 recipe = networkRecipeRepo.findFirstByModelNameAndAction("SDNC_DEFAULT", action);
538 if (null == recipe) {
539 AllottedResource arResource = arResourceRepo.findResourceByModelUUID(rmUuid);
540 if (arResource != null) {
541 recipe = arRecipeRepo.findByModelNameAndActionAndVersion(arResource.getModelName(), action,
542 arResource.getModelVersion());
546 if (null == recipe) {
547 InstanceGroup grpResource = instanceGroupRepository.findByModelUUID(rmUuid);
548 if (grpResource != null) {
549 recipe = vnfRecipeRepo.findFirstVnfRecipeByNfRoleAndActionAndVersionStr(
550 grpResource.getModelName(), action, grpResource.getModelVersion());
555 if (recipe != null) {
556 QueryResourceRecipe resourceRecipe = new QueryResourceRecipe(recipe);
557 entity = resourceRecipe.JSON2(false, false);
559 respStatus = HttpStatus.SC_NOT_FOUND;
562 throw new Exception("Incoming parameter is null or blank");
564 return Response.status(respStatus).entity(entity)
565 .header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON).build();
566 } catch (Exception e) {
567 logger.error("Exception during query recipe by resource model uuid: ", e);
568 CatalogQueryException excResp = new CatalogQueryException(e.getMessage(),
569 CatalogQueryExceptionCategory.INTERNAL, Boolean.FALSE, null);
570 return Response.status(HttpStatus.SC_INTERNAL_SERVER_ERROR)
571 .entity(new GenericEntity<CatalogQueryException>(excResp) {}).build();