2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
21 package org.onap.so.adapters.catalogdb.rest;
24 Create an initial query to retrieve a VNF Resource definition (including a list of possible module types)
25 within the context of a given service. Input is a vnf resource model customization ID (new field for 1702),
26 or a composite key (from 1610) of service name, service version, vnf instance name
28 Returns a structure (JSON?) containing VNF RESOURCE attributes, plus a list of VF Module structures.
30 Query a NETWORK_RESOURCE from the MSO Catalog, based on a networkModelCustomizationUUID (new for 1702),
31 a network type (unique type identifier in 1610), or based on network role within a service.
33 Create Adapter framework for access to Catalog DB, including connection management,
34 login/password access, transaction logic, etc. This can be modeled after the Request DB Adapter
36 Update the MSO Catalog DB schema to include the new fields defined in this user story.
38 Note that the resourceModelCustomizationUUID (or vfModuleModelCustomizationUUID) will be unique keys (indexes)
39 on the VNF_RESOURCE and VF_MODULE tables respectively.
40 The previously constructed "vnf-type" and "vf-module-type" field may continue to be populated,
41 but should no longer be needed and can deprecate in future release.
43 For migration, a new randomly generated UUID field may be generated for the *ModelCustomizationUUID" fields
44 until such time that the model is redistributed from ASDC.
46 All other fields Check with Mike Z for appropriate value for the vfModuleLabel.
47 We might be able to derive it's value from the current vnf-type (using the "middle" piece that identifies the module type).
49 min and initial counts can be 0. max can be null to indicate no maximum.
51 Once the network-level distribution artifacts are defined, similar updates can be made to the NETWORK_RESOURCE table.
54 import java.util.ArrayList;
55 import java.util.List;
57 import javax.ws.rs.GET;
58 import javax.ws.rs.Path;
59 import javax.ws.rs.PathParam;
60 import javax.ws.rs.Produces;
61 import javax.ws.rs.QueryParam;
62 import javax.ws.rs.core.GenericEntity;
63 import javax.ws.rs.core.HttpHeaders;
64 import javax.ws.rs.core.MediaType;
65 import javax.ws.rs.core.Response;
67 import org.apache.http.HttpStatus;
68 import org.onap.so.adapters.catalogdb.catalogrest.CatalogQuery;
69 import org.onap.so.adapters.catalogdb.catalogrest.CatalogQueryException;
70 import org.onap.so.adapters.catalogdb.catalogrest.CatalogQueryExceptionCategory;
71 import org.onap.so.adapters.catalogdb.catalogrest.QueryAllottedResourceCustomization;
72 import org.onap.so.adapters.catalogdb.catalogrest.QueryResourceRecipe;
73 import org.onap.so.adapters.catalogdb.catalogrest.QueryServiceCsar;
74 import org.onap.so.adapters.catalogdb.catalogrest.QueryServiceMacroHolder;
75 import org.onap.so.adapters.catalogdb.catalogrest.QueryServiceNetworks;
76 import org.onap.so.adapters.catalogdb.catalogrest.QueryServiceVnfs;
77 import org.onap.so.adapters.catalogdb.catalogrest.QueryVfModule;
78 import org.onap.so.db.catalog.beans.AllottedResource;
79 import org.onap.so.db.catalog.beans.AllottedResourceCustomization;
80 import org.onap.so.db.catalog.beans.NetworkResource;
81 import org.onap.so.db.catalog.beans.NetworkResourceCustomization;
82 import org.onap.so.db.catalog.beans.Recipe;
83 import org.onap.so.db.catalog.beans.Service;
84 import org.onap.so.db.catalog.beans.ToscaCsar;
85 import org.onap.so.db.catalog.beans.VfModule;
86 import org.onap.so.db.catalog.beans.VfModuleCustomization;
87 import org.onap.so.db.catalog.beans.VnfResource;
88 import org.onap.so.db.catalog.beans.VnfResourceCustomization;
89 import org.onap.so.db.catalog.data.repository.AllottedResourceCustomizationRepository;
90 import org.onap.so.db.catalog.data.repository.AllottedResourceRepository;
91 import org.onap.so.db.catalog.data.repository.ArRecipeRepository;
92 import org.onap.so.db.catalog.data.repository.NetworkRecipeRepository;
93 import org.onap.so.db.catalog.data.repository.NetworkResourceCustomizationRepository;
94 import org.onap.so.db.catalog.data.repository.NetworkResourceRepository;
95 import org.onap.so.db.catalog.data.repository.ServiceRepository;
96 import org.onap.so.db.catalog.data.repository.ToscaCsarRepository;
97 import org.onap.so.db.catalog.data.repository.VFModuleRepository;
98 import org.onap.so.db.catalog.data.repository.VnfCustomizationRepository;
99 import org.onap.so.db.catalog.data.repository.VnfRecipeRepository;
100 import org.onap.so.db.catalog.data.repository.VnfResourceRepository;
101 import org.onap.so.db.catalog.rest.beans.ServiceMacroHolder;
102 import org.onap.so.logger.MessageEnum;
103 import org.onap.so.logger.MsoLogger;
104 import org.springframework.beans.factory.annotation.Autowired;
105 import org.springframework.stereotype.Component;
106 import org.springframework.transaction.annotation.Transactional;
109 * This class services calls to the REST interface for VF Modules (http://host:port/ecomp/mso/catalog/v1)
110 * Both XML and JSON can be produced/consumed. Set Accept: and Content-Type: headers appropriately. XML is the default.
111 * Requests respond synchronously only
113 @Path("/{version: v[0-9]+}")
115 public class CatalogDbAdapterRest {
116 private static final MsoLogger LOGGER = MsoLogger.getMsoLogger (MsoLogger.Catalog.RA,CatalogDbAdapterRest.class);
117 private static final boolean IS_ARRAY = true;
120 private VnfCustomizationRepository vnfCustomizationRepo;
123 private ServiceRepository serviceRepo;
126 private NetworkResourceCustomizationRepository networkCustomizationRepo;
129 private NetworkResourceRepository networkResourceRepo;
132 private AllottedResourceCustomizationRepository allottedCustomizationRepo;
135 private ToscaCsarRepository toscaCsarRepo;
138 private VFModuleRepository vfModuleRepo;
141 private VnfRecipeRepository vnfRecipeRepo;
144 private NetworkRecipeRepository networkRecipeRepo;
147 private ArRecipeRepository arRecipeRepo;
150 private VnfResourceRepository vnfResourceRepo;
153 private AllottedResourceRepository arResourceRepo;
155 private static final String NO_MATCHING_PARAMETERS = "no matching parameters";
157 public Response respond(String version, int respStatus, boolean isArray, CatalogQuery qryResp) {
160 //.entity(new GenericEntity<QueryServiceVnfs>(qryResp) {})
161 .entity(qryResp.toJsonString(version, isArray))
162 .header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
167 @Path("vnfResources/{vnfModelCustomizationUuid}")
168 @Transactional( readOnly = true)
169 @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
170 public Response serviceVnfs (
171 @PathParam("version") String version,
172 @PathParam("vnfModelCustomizationUuid") String vnfUuid
174 return serviceVnfsImpl (version, !IS_ARRAY, vnfUuid, null, null, null, null);
179 @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
180 @Transactional( readOnly = true)
181 public Response serviceVnfs(
182 @PathParam("version") String version,
183 @QueryParam("vnfModelCustomizationUuid") String vnfUuid,
184 @QueryParam("serviceModelUuid") String smUuid,
185 @QueryParam("serviceModelInvariantUuid") String smiUuid,
186 @QueryParam("serviceModelVersion") String smVer,
187 @QueryParam("serviceModelName") String smName
189 return serviceVnfsImpl (version, IS_ARRAY, vnfUuid, smUuid, smiUuid, smVer, smName);
192 public Response serviceVnfsImpl(String version, boolean isArray, String vnfUuid, String serviceModelUUID, String smiUuid, String smVer, String smName) {
193 QueryServiceVnfs qryResp = null;
194 int respStatus = HttpStatus.SC_OK;
195 List<VnfResourceCustomization> ret = new ArrayList<>();
196 Service service = null;
198 if (vnfUuid != null && !"".equals(vnfUuid))
199 ret = vnfCustomizationRepo.findByModelCustomizationUUID(vnfUuid);
200 else if (serviceModelUUID != null && !"".equals(serviceModelUUID))
201 service = serviceRepo.findFirstOneByModelUUIDOrderByModelVersionDesc(serviceModelUUID);
202 else if (smiUuid != null && !"".equals(smiUuid))
203 if (smVer != null && !"".equals(smVer))
204 service = serviceRepo.findByModelVersionAndModelInvariantUUID(smVer,smiUuid);
206 service = serviceRepo.findFirstByModelInvariantUUIDOrderByModelVersionDesc(smiUuid);
207 else if (smName != null && !"".equals(smName)) {
208 if (smVer != null && !"".equals(smVer))
209 service = serviceRepo.findByModelNameAndModelVersion(smName, smVer);
211 service = serviceRepo.findFirstByModelNameOrderByModelVersionDesc(smName);
214 throw(new Exception(NO_MATCHING_PARAMETERS));
217 if (service == null && ret.isEmpty()) {
218 respStatus = HttpStatus.SC_NOT_FOUND;
219 qryResp = new QueryServiceVnfs();
220 }else if( service == null && !ret.isEmpty()){
221 qryResp = new QueryServiceVnfs(ret);
222 } else if (service != null) {
223 qryResp = new QueryServiceVnfs(service.getVnfCustomizations());
225 LOGGER.debug ("serviceVnfs qryResp="+ qryResp);
226 return respond(version, respStatus, isArray, qryResp);
227 } catch (Exception e) {
228 LOGGER.error (MessageEnum.RA_QUERY_VNF_ERR, "", "", "queryServiceVnfs", MsoLogger.ErrorCode.BusinessProcesssError, "Exception - queryServiceVnfs", e);
229 CatalogQueryException excResp = new CatalogQueryException(e.getMessage(), CatalogQueryExceptionCategory.INTERNAL, Boolean.FALSE, null);
231 .status(HttpStatus.SC_INTERNAL_SERVER_ERROR)
232 .entity(new GenericEntity<CatalogQueryException>(excResp) {})
238 @Path("networkResources/{networkModelCustomizationUuid}")
239 @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
240 @Transactional( readOnly = true)
241 public Response serviceNetworks (
242 @PathParam("version") String version,
243 @PathParam("networkModelCustomizationUuid") String nUuid
245 return serviceNetworksImpl (version, !IS_ARRAY, nUuid, null, null, null, null);
249 @Path("serviceNetworks")
250 @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
251 @Transactional( readOnly = true)
252 public Response serviceNetworks (
253 @PathParam("version") String version,
254 @QueryParam("networkModelCustomizationUuid") String networkModelCustomizationUuid,
255 @QueryParam("networkType") String networkType,
256 @QueryParam("networkModelName") String networkModelName,
257 @QueryParam("serviceModelUuid") String serviceModelUuid,
258 @QueryParam("serviceModelInvariantUuid") String serviceModelInvariantUuid,
259 @QueryParam("serviceModelVersion") String serviceModelVersion,
260 @QueryParam("networkModelVersion") String networkModelVersion
262 if (networkModelName != null && !"".equals(networkModelName)) {
263 networkType = networkModelName;
265 return serviceNetworksImpl (version, IS_ARRAY, networkModelCustomizationUuid, networkType, serviceModelUuid, serviceModelInvariantUuid, serviceModelVersion);
268 public Response serviceNetworksImpl (String version, boolean isArray, String networkModelCustomizationUuid, String networkType, String serviceModelUuid, String serviceModelInvariantUuid, String serviceModelVersion) {
269 QueryServiceNetworks qryResp;
270 int respStatus = HttpStatus.SC_OK;
272 List<NetworkResourceCustomization> ret = new ArrayList<>();
273 Service service = null;
276 if (networkModelCustomizationUuid != null && !"".equals(networkModelCustomizationUuid)) {
277 uuid = networkModelCustomizationUuid;
278 ret = networkCustomizationRepo.findByModelCustomizationUUID(networkModelCustomizationUuid);
279 }else if (networkType != null && !"".equals(networkType)) {
281 NetworkResource networkResources = networkResourceRepo.findFirstByModelNameOrderByModelVersionDesc(networkType);
282 if(networkResources != null)
283 ret=networkResources.getNetworkResourceCustomization();
285 else if (serviceModelInvariantUuid != null && !"".equals(serviceModelInvariantUuid)) {
286 uuid = serviceModelInvariantUuid;
287 if (serviceModelVersion != null && !"".equals(serviceModelVersion)) {
288 service = serviceRepo.findByModelVersionAndModelInvariantUUID(serviceModelVersion, uuid);
291 service = serviceRepo.findFirstByModelInvariantUUIDOrderByModelVersionDesc(uuid);
293 }else if (serviceModelUuid != null && !"".equals(serviceModelUuid)) {
294 uuid = serviceModelUuid;
295 service = serviceRepo.findOneByModelUUID(serviceModelUuid);
298 throw(new Exception(NO_MATCHING_PARAMETERS));
302 ret = service.getNetworkCustomizations();
304 if (ret == null || ret.isEmpty()) {
305 LOGGER.debug ("serviceNetworks not found");
306 respStatus = HttpStatus.SC_NOT_FOUND;
307 qryResp = new QueryServiceNetworks();
309 LOGGER.debug ("serviceNetworks found");
310 qryResp = new QueryServiceNetworks(ret);
311 LOGGER.debug ("serviceNetworks qryResp="+ qryResp);
313 LOGGER.debug ("Query serviceNetworks exit");
314 return respond(version, respStatus, isArray, qryResp);
315 } catch (Exception e) {
316 LOGGER.error (MessageEnum.RA_QUERY_VNF_ERR, uuid, "", "queryServiceNetworks", MsoLogger.ErrorCode.BusinessProcesssError, "Exception - queryServiceNetworks", e);
317 CatalogQueryException excResp = new CatalogQueryException(e.getMessage(), CatalogQueryExceptionCategory.INTERNAL, Boolean.FALSE, null);
319 .status(HttpStatus.SC_INTERNAL_SERVER_ERROR)
320 .entity(new GenericEntity<CatalogQueryException>(excResp) {})
326 @Path("serviceResources")
327 @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
328 @Transactional(readOnly = true)
329 public Response serviceResources(
330 @PathParam("version") String version,
331 @QueryParam("serviceModelUuid") String modelUUID,
332 @QueryParam("serviceModelInvariantUuid") String modelInvariantUUID,
333 @QueryParam("serviceModelVersion") String modelVersion) {
334 QueryServiceMacroHolder qryResp;
335 int respStatus = HttpStatus.SC_OK;
337 ServiceMacroHolder ret = new ServiceMacroHolder();
340 if (modelUUID != null && !"".equals(modelUUID)) {
342 LOGGER.debug ("Query serviceMacroHolder getAllResourcesByServiceModelUuid serviceModelUuid: " + uuid);
343 Service serv =serviceRepo.findOneByModelUUID(uuid);
344 ret.setService(serv);
346 else if (modelInvariantUUID != null && !"".equals(modelInvariantUUID)) {
347 uuid = modelInvariantUUID;
348 if (modelVersion != null && !"".equals(modelVersion)) {
349 LOGGER.debug ("Query serviceMacroHolder getAllResourcesByServiceModelInvariantUuid serviceModelInvariantUuid: " + uuid+ " serviceModelVersion: "+ modelVersion);
350 Service serv = serviceRepo.findByModelVersionAndModelInvariantUUID(modelVersion, uuid);
351 ret.setService(serv);
354 LOGGER.debug ("Query serviceMacroHolder getAllResourcesByServiceModelInvariantUuid serviceModelUuid: " + uuid);
355 Service serv = serviceRepo.findFirstByModelInvariantUUIDOrderByModelVersionDesc(uuid);
356 ret.setService(serv);
360 throw(new Exception(NO_MATCHING_PARAMETERS));
363 if (ret.getService() == null) {
364 LOGGER.debug ("serviceMacroHolder not found");
365 respStatus = HttpStatus.SC_NOT_FOUND;
366 qryResp = new QueryServiceMacroHolder();
368 LOGGER.debug ("serviceMacroHolder found");
369 qryResp = new QueryServiceMacroHolder(ret);
370 LOGGER.debug ("serviceMacroHolder qryResp="+ qryResp);
372 LOGGER.debug ("Query serviceMacroHolder exit");
373 return respond(version, respStatus, IS_ARRAY, qryResp);
374 } catch (Exception e) {
375 LOGGER.error (MessageEnum.RA_QUERY_VNF_ERR, uuid, "", "queryServiceMacroHolder", MsoLogger.ErrorCode.BusinessProcesssError, "Exception - queryServiceMacroHolder", e);
376 CatalogQueryException excResp = new CatalogQueryException(e.getMessage(), CatalogQueryExceptionCategory.INTERNAL, Boolean.FALSE, null);
378 .status(HttpStatus.SC_INTERNAL_SERVER_ERROR)
379 .entity(new GenericEntity<CatalogQueryException>(excResp){} )
386 @Path("allottedResources/{arModelCustomizationUuid}")
387 @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
388 @Transactional( readOnly = true)
389 public Response serviceAllottedResources (
390 @PathParam("version") String version,
391 @PathParam("arModelCustomizationUuid") String aUuid
393 return serviceAllottedResourcesImpl(version, !IS_ARRAY, aUuid, null, null, null);
397 @Path("serviceAllottedResources")
398 @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
399 @Transactional( readOnly = true)
400 public Response serviceAllottedResources(
401 @PathParam("version") String version,
402 @QueryParam("serviceModelUuid") String smUuid,
403 @QueryParam("serviceModelInvariantUuid") String smiUuid,
404 @QueryParam("serviceModelVersion") String smVer,
405 @QueryParam("arModelCustomizationUuid") String aUuid
407 return serviceAllottedResourcesImpl(version, IS_ARRAY, aUuid, smUuid, smiUuid, smVer);
410 public Response serviceAllottedResourcesImpl(String version, boolean isArray, String aUuid, String smUuid, String serviceModelInvariantUuid, String smVer) {
411 QueryAllottedResourceCustomization qryResp;
412 int respStatus = HttpStatus.SC_OK;
414 List<AllottedResourceCustomization> ret = new ArrayList<>();
415 Service service = null;
417 if (smUuid != null && !"".equals(smUuid)) {
419 service = serviceRepo.findFirstOneByModelUUIDOrderByModelVersionDesc(uuid);
421 else if (serviceModelInvariantUuid != null && !"".equals(serviceModelInvariantUuid)) {
422 uuid = serviceModelInvariantUuid;
423 if (smVer != null && !"".equals(smVer)) {
424 service = serviceRepo.findByModelVersionAndModelInvariantUUID(smVer, uuid);
427 service = serviceRepo.findFirstByModelInvariantUUIDOrderByModelVersionDesc(uuid);
430 else if (aUuid != null && !"".equals(aUuid)) {
432 ret = allottedCustomizationRepo.findByModelCustomizationUUID(uuid);
435 throw(new Exception(NO_MATCHING_PARAMETERS));
439 ret=service.getAllottedCustomizations();
441 if (ret == null || ret.isEmpty()) {
442 LOGGER.debug ("AllottedResourceCustomization not found");
443 respStatus = HttpStatus.SC_NOT_FOUND;
444 qryResp = new QueryAllottedResourceCustomization();
446 qryResp = new QueryAllottedResourceCustomization(ret);
447 LOGGER.debug ("AllottedResourceCustomization qryResp="+ qryResp);
449 return respond(version, respStatus, isArray, qryResp);
450 } catch (Exception e) {
451 LOGGER.error (MessageEnum.RA_QUERY_VNF_ERR, uuid, "", "queryAllottedResourceCustomization", MsoLogger.ErrorCode.BusinessProcesssError, "Exception - queryAllottedResourceCustomization", e);
452 CatalogQueryException excResp = new CatalogQueryException(e.getMessage(), CatalogQueryExceptionCategory.INTERNAL, Boolean.FALSE, null);
454 .status(HttpStatus.SC_INTERNAL_SERVER_ERROR)
455 .entity(new GenericEntity<CatalogQueryException>(excResp) {})
462 @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
463 @Transactional( readOnly = true)
464 public Response vfModules(@QueryParam("vfModuleModelName") String vfModuleModelName) {
465 QueryVfModule qryResp;
466 int respStatus = HttpStatus.SC_OK;
467 List<VfModuleCustomization> ret = null;
469 if(vfModuleModelName != null && !"".equals(vfModuleModelName)){
470 VfModule vfModule = vfModuleRepo.findFirstByModelNameOrderByModelVersionDesc(vfModuleModelName);
472 ret = vfModule.getVfModuleCustomization();
474 throw(new Exception(NO_MATCHING_PARAMETERS));
477 if(ret == null || ret.isEmpty()){
478 LOGGER.debug ("vfModules not found");
479 respStatus = HttpStatus.SC_NOT_FOUND;
480 qryResp = new QueryVfModule();
482 qryResp = new QueryVfModule(ret);
483 LOGGER.debug ("vfModules tojsonstring is: "+ qryResp.JSON2(false, false));
487 .entity(qryResp.JSON2(false, false))
488 .header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
491 LOGGER.error (MessageEnum.RA_QUERY_VNF_ERR, vfModuleModelName, "", "queryVfModules", MsoLogger.ErrorCode.BusinessProcesssError, "Exception during query VfModules by vfModuleModuleName: ", e);
492 CatalogQueryException excResp = new CatalogQueryException(e.getMessage(), CatalogQueryExceptionCategory.INTERNAL, Boolean.FALSE, null);
494 .status(HttpStatus.SC_INTERNAL_SERVER_ERROR)
495 .entity(new GenericEntity<CatalogQueryException>(excResp) {})
500 * Get the tosca csar info from catalog
503 * @param smUuid service model uuid
504 * @return the tosca csar information of the serivce.
505 * @since ONAP Beijing Release
508 @Path("serviceToscaCsar")
509 @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
510 public Response serviceToscaCsar(@QueryParam("serviceModelUuid") String smUuid) {
511 int respStatus = HttpStatus.SC_OK;
514 if (smUuid != null && !"".equals(smUuid)) {
515 LOGGER.debug("Query Csar by service model uuid: " + smUuid);
516 ToscaCsar toscaCsar = toscaCsarRepo.findOne(smUuid);
517 if (toscaCsar != null) {
518 QueryServiceCsar serviceCsar = new QueryServiceCsar(toscaCsar);
519 entity = serviceCsar.JSON2(false, false);
521 respStatus = HttpStatus.SC_NOT_FOUND;
524 throw (new Exception("Incoming parameter is null or blank"));
526 LOGGER.debug("Query Csar exit");
530 .header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
532 } catch (Exception e) {
533 LOGGER.error(MessageEnum.RA_QUERY_VNF_ERR, smUuid, "", "ServiceToscaCsar",
534 MsoLogger.ErrorCode.BusinessProcesssError, "Exception during query csar by service model uuid: ", e);
535 CatalogQueryException excResp = new CatalogQueryException(e.getMessage(),
536 CatalogQueryExceptionCategory.INTERNAL, Boolean.FALSE, null);
538 .status(HttpStatus.SC_INTERNAL_SERVER_ERROR)
539 .entity(new GenericEntity<CatalogQueryException>(excResp) {
546 * Get the resource recipe info from catalog
549 * @param rmUuid resource model uuid
550 * @return the recipe information of the resource.
551 * @since ONAP Beijing Release
554 @Path("resourceRecipe")
555 @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
556 public Response resourceRecipe(@QueryParam("resourceModelUuid") String rmUuid, @QueryParam("action") String action) {
557 int respStatus = HttpStatus.SC_OK;
560 if (rmUuid != null && !"".equals(rmUuid)) {
561 LOGGER.debug("Query recipe by resource model uuid: " + rmUuid);
562 //check vnf and network and ar, the resource could be any resource.
563 VnfResource vnf = vnfResourceRepo.findResourceByModelUUID(rmUuid);
564 Recipe recipe = vnfRecipeRepo.findVnfRecipeByNfRoleAndAction(vnf.getModelName(), action);
565 if (null == recipe) {
566 NetworkResource nResource = networkResourceRepo.findResourceByModelUUID(rmUuid);
567 recipe = networkRecipeRepo.findByModelNameAndAction(nResource.getModelName(), action);
569 if (null == recipe) {
570 AllottedResource arResource = arResourceRepo.findResourceByModelUUID(rmUuid);
571 recipe = arRecipeRepo.findByModelNameAndAction(arResource.getModelName(), action);
573 if (recipe != null) {
574 QueryResourceRecipe resourceRecipe = new QueryResourceRecipe(recipe);
575 entity = resourceRecipe.JSON2(false, false);
577 respStatus = HttpStatus.SC_NOT_FOUND;
580 throw (new Exception("Incoming parameter is null or blank"));
582 LOGGER.debug("Query recipe exit");
586 .header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
588 } catch (Exception e) {
589 LOGGER.error(MessageEnum.RA_QUERY_VNF_ERR, rmUuid, "", "resourceRecipe",
590 MsoLogger.ErrorCode.BusinessProcesssError, "Exception during query recipe by resource model uuid: ", e);
591 CatalogQueryException excResp = new CatalogQueryException(e.getMessage(),
592 CatalogQueryExceptionCategory.INTERNAL, Boolean.FALSE, null);
594 .status(HttpStatus.SC_INTERNAL_SERVER_ERROR)
595 .entity(new GenericEntity<CatalogQueryException>(excResp) {