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=========================================================
20 package org.openecomp.mso.adapters.catalogdb;
23 Create an initial query to retrieve a VNF Resource definition (including a list of possible module types)
24 within the context of a given service. Input is a vnf resource model customization ID (new field for 1702),
25 or a composite key (from 1610) of service name, service version, vnf instance name
27 Returns a structure (JSON?) containing VNF RESOURCE attributes, plus a list of VF Module structures.
29 Query a NETWORK_RESOURCE from the MSO Catalog, based on a networkModelCustomizationUUID (new for 1702),
30 a network type (unique type identifier in 1610), or based on network role within a service.
32 Create Adapter framework for access to Catalog DB, including connection management,
33 login/password access, transaction logic, etc. This can be modeled after the Request DB Adapter
35 Update the MSO Catalog DB schema to include the new fields defined in this user story.
37 Note that the resourceModelCustomizationUUID (or vfModuleModelCustomizationUUID) will be unique keys (indexes)
38 on the VNF_RESOURCE and VF_MODULE tables respectively.
39 The previously constructed "vnf-type" and "vf-module-type" field may continue to be populated,
40 but should no longer be needed and can deprecate in future release.
42 For migration, a new randomly generated UUID field may be generated for the *ModelCustomizationUUID" fields
43 until such time that the model is redistributed from ASDC.
45 All other fields Check with Mike Z for appropriate value for the vfModuleLabel.
46 We might be able to derive it's value from the current vnf-type (using the "middle" piece that identifies the module type).
48 min and initial counts can be 0. max can be null to indicate no maximum.
50 Once the network-level distribution artifacts are defined, similar updates can be made to the NETWORK_RESOURCE table.
53 import java.util.ArrayList;
54 import java.util.List;
56 import javax.ws.rs.GET;
57 import javax.ws.rs.HEAD;
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.openecomp.mso.adapters.catalogdb.catalogrest.CatalogQuery;
69 import org.openecomp.mso.adapters.catalogdb.catalogrest.CatalogQueryException;
70 import org.openecomp.mso.adapters.catalogdb.catalogrest.CatalogQueryExceptionCategory;
71 import org.openecomp.mso.adapters.catalogdb.catalogrest.QueryAllottedResourceCustomization;
72 import org.openecomp.mso.adapters.catalogdb.catalogrest.QueryResourceRecipe;
73 import org.openecomp.mso.adapters.catalogdb.catalogrest.QueryServiceCsar;
74 import org.openecomp.mso.adapters.catalogdb.catalogrest.QueryServiceMacroHolder;
75 import org.openecomp.mso.adapters.catalogdb.catalogrest.QueryServiceNetworks;
76 import org.openecomp.mso.adapters.catalogdb.catalogrest.QueryServiceVnfs;
77 import org.openecomp.mso.adapters.catalogdb.catalogrest.QueryVfModule;
78 import org.openecomp.mso.db.catalog.CatalogDatabase;
79 import org.openecomp.mso.db.catalog.beans.AllottedResourceCustomization;
80 import org.openecomp.mso.db.catalog.beans.NetworkResourceCustomization;
81 import org.openecomp.mso.db.catalog.beans.Recipe;
82 import org.openecomp.mso.db.catalog.beans.ServiceMacroHolder;
83 import org.openecomp.mso.db.catalog.beans.ToscaCsar;
84 import org.openecomp.mso.db.catalog.beans.VfModuleCustomization;
85 import org.openecomp.mso.db.catalog.beans.VnfResourceCustomization;
86 import org.openecomp.mso.logger.MessageEnum;
87 import org.openecomp.mso.logger.MsoLogger;
90 * This class services calls to the REST interface for VF Modules (http://host:port/ecomp/mso/catalog/v1)
91 * Both XML and JSON can be produced/consumed. Set Accept: and Content-Type: headers appropriately. XML is the default.
92 * Requests respond synchronously only
94 @Path("/{version: v[0-9]+}")
95 public class CatalogDbAdapterRest {
96 private static MsoLogger LOGGER = MsoLogger.getMsoLogger (MsoLogger.Catalog.RA);
97 private static final boolean IS_ARRAY = true;
99 public Response respond(String version, int respStatus, boolean isArray, CatalogQuery qryResp) {
102 //.entity(new GenericEntity<QueryServiceVnfs>(qryResp) {})
103 .entity(qryResp.toJsonString(version, isArray))
104 .header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
111 @Produces(MediaType.TEXT_HTML)
112 public Response healthcheck (
113 @PathParam("version") String version
115 String CHECK_HTML = "<!DOCTYPE html><html><head><meta charset=\"ISO-8859-1\"><title>Health Check</title></head><body>Application "+ version+ " ready</body></html>";
116 return Response.ok().entity(CHECK_HTML).build();
120 @Path("vnfResources/{vnfModelCustomizationUuid}")
121 @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
122 public Response serviceVnfs (
123 @PathParam("version") String version,
124 @PathParam("vnfModelCustomizationUuid") String vnfUuid
126 return serviceVnfsImpl (version, !IS_ARRAY, vnfUuid, null, null, null, null);
131 @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
132 public Response serviceVnfs(
133 @PathParam("version") String version,
134 @QueryParam("vnfModelCustomizationUuid") String vnfUuid,
135 @QueryParam("serviceModelUuid") String smUuid,
136 @QueryParam("serviceModelInvariantUuid") String smiUuid,
137 @QueryParam("serviceModelVersion") String smVer,
138 @QueryParam("serviceModelName") String smName
140 return serviceVnfsImpl (version, IS_ARRAY, vnfUuid, smUuid, smiUuid, smVer, smName);
143 public Response serviceVnfsImpl(String version, boolean isArray, String vnfUuid, String smUuid, String smiUuid, String smVer, String smName) {
144 QueryServiceVnfs qryResp;
145 int respStatus = HttpStatus.SC_OK;
147 List<VnfResourceCustomization> ret;
149 try (CatalogDatabase db = CatalogDatabase.getInstance()) {
150 if (vnfUuid != null && !"".equals(vnfUuid)) {
152 LOGGER.debug ("Query serviceVnfs getAllVnfsByVnfModelCustomizationUuid vnfModelCustomizationUuid: " + uuid);
153 ret = db.getAllVnfsByVnfModelCustomizationUuid(uuid);
155 else if (smUuid != null && !"".equals(smUuid)) {
157 LOGGER.debug ("Query serviceVnfs getAllVnfsByServiceModelUuid serviceModelUuid: " + uuid);
158 ret = db.getAllVnfsByServiceModelUuid(uuid);
160 else if (smiUuid != null && !"".equals(smiUuid)) {
162 if (smVer != null && !"".equals(smVer)) {
163 LOGGER.debug ("Query serviceVnfs getAllNetworksByServiceModelInvariantUuid serviceModelInvariantUuid: " + uuid+ " serviceModelVersion: "+ smVer);
164 ret = db.getAllVnfsByServiceModelInvariantUuid(uuid, smVer);
167 LOGGER.debug ("Query serviceVnfs getAllNetworksByServiceModelInvariantUuid serviceModelUuid: " + uuid);
168 ret = db.getAllVnfsByServiceModelInvariantUuid(uuid);
171 else if (smName != null && !"".equals(smName)) {
172 if (smVer != null && !"".equals(smVer)) {
173 LOGGER.debug ("Query serviceVnfs getAllVnfsByServiceName serviceModelInvariantName: " + smName+ " serviceModelVersion: "+ smVer);
174 ret = db.getAllVnfsByServiceName(smName, smVer);
177 LOGGER.debug ("Query serviceVnfs getAllVnfsByServiceName serviceModelName: " + smName);
178 ret = db.getAllVnfsByServiceName(smName);
182 throw(new Exception("no matching parameters"));
185 if (ret == null || ret.isEmpty()) {
186 LOGGER.debug ("serviceVnfs not found");
187 respStatus = HttpStatus.SC_NOT_FOUND;
188 qryResp = new QueryServiceVnfs();
190 LOGGER.debug ("serviceVnfs found");
191 qryResp = new QueryServiceVnfs(ret);
192 LOGGER.debug ("serviceVnfs qryResp="+ qryResp);
194 LOGGER.debug ("Query serviceVnfs exit");
195 return respond(version, respStatus, isArray, qryResp);
196 } catch (Exception e) {
197 LOGGER.error (MessageEnum.RA_QUERY_VNF_ERR, uuid, "", "queryServiceVnfs", MsoLogger.ErrorCode.BusinessProcesssError, "Exception - queryServiceVnfs", e);
198 CatalogQueryException excResp = new CatalogQueryException(e.getMessage(), CatalogQueryExceptionCategory.INTERNAL, Boolean.FALSE, null);
200 .status(HttpStatus.SC_INTERNAL_SERVER_ERROR)
201 .entity(new GenericEntity<CatalogQueryException>(excResp) {})
207 @Path("networkResources/{networkModelCustomizationUuid}")
208 @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
209 public Response serviceNetworks (
210 @PathParam("version") String version,
211 @PathParam("networkModelCustomizationUuid") String nUuid
213 return serviceNetworksImpl (version, !IS_ARRAY, nUuid, null, null, null, null);
217 @Path("serviceNetworks")
218 @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
219 public Response serviceNetworks (
220 @PathParam("version") String version,
221 @QueryParam("networkModelCustomizationUuid") String nUuid,
222 @QueryParam("networkType") String nType,
223 @QueryParam("networkModelName") String nModelName,
224 @QueryParam("serviceModelUuid") String smUuid,
225 @QueryParam("serviceModelInvariantUuid") String smiUuid,
226 @QueryParam("serviceModelVersion") String smVer,
227 @QueryParam("networkModelVersion") String nmVer
229 if (nModelName != null && !"".equals(nModelName)) {
232 return serviceNetworksImpl (version, IS_ARRAY, nUuid, nType, smUuid, smiUuid, smVer);
235 public Response serviceNetworksImpl (String version, boolean isArray, String nUuid, String nType, String smUuid, String smiUuid, String smVer) {
236 QueryServiceNetworks qryResp;
237 int respStatus = HttpStatus.SC_OK;
239 List<NetworkResourceCustomization> ret;
241 try (CatalogDatabase db = CatalogDatabase.getInstance()) {
242 if (nUuid != null && !"".equals(nUuid)) {
244 LOGGER.debug ("Query serviceNetworks getAllNetworksByNetworkModelCustomizationUuid networkModelCustomizationUuid: " + uuid);
245 ret = db.getAllNetworksByNetworkModelCustomizationUuid(uuid);
247 else if (smUuid != null && !"".equals(smUuid)) {
249 LOGGER.debug ("Query serviceNetworks getAllNetworksByServiceModelUuid serviceModelUuid: " + uuid);
250 ret = db.getAllNetworksByServiceModelUuid(uuid);
252 else if (nType != null && !"".equals(nType)) {
254 LOGGER.debug ("Query serviceNetworks getAllNetworksByNetworkType serviceModelUuid: " + uuid);
255 ret = db.getAllNetworksByNetworkType(uuid);
257 else if (smiUuid != null && !"".equals(smiUuid)) {
259 if (smVer != null && !"".equals(smVer)) {
260 LOGGER.debug ("Query serviceNetworks getAllNetworksByServiceModelInvariantUuid serviceModelInvariantUuid: " + uuid+ " serviceModelVersion: "+ smVer);
261 ret = db.getAllNetworksByServiceModelInvariantUuid(uuid, smVer);
264 LOGGER.debug ("Query serviceNetworks getAllNetworksByServiceModelInvariantUuid serviceModelUuid: " + uuid);
265 ret = db.getAllNetworksByServiceModelInvariantUuid(uuid);
269 throw(new Exception("no matching parameters"));
272 if (ret == null || ret.isEmpty()) {
273 LOGGER.debug ("serviceNetworks not found");
274 respStatus = HttpStatus.SC_NOT_FOUND;
275 qryResp = new QueryServiceNetworks();
277 LOGGER.debug ("serviceNetworks found");
278 qryResp = new QueryServiceNetworks(ret);
279 LOGGER.debug ("serviceNetworks qryResp="+ qryResp);
281 LOGGER.debug ("Query serviceNetworks exit");
282 return respond(version, respStatus, isArray, qryResp);
283 } catch (Exception e) {
284 LOGGER.error (MessageEnum.RA_QUERY_VNF_ERR, uuid, "", "queryServiceNetworks", MsoLogger.ErrorCode.BusinessProcesssError, "Exception - queryServiceNetworks", e);
285 CatalogQueryException excResp = new CatalogQueryException(e.getMessage(), CatalogQueryExceptionCategory.INTERNAL, Boolean.FALSE, null);
287 .status(HttpStatus.SC_INTERNAL_SERVER_ERROR)
288 .entity(new GenericEntity<CatalogQueryException>(excResp) {})
294 @Path("serviceResources")
295 @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
296 public Response serviceResources(
297 @PathParam("version") String version,
298 @QueryParam("serviceModelUuid") String smUuid,
299 @QueryParam("serviceModelInvariantUuid") String smiUuid,
300 @QueryParam("serviceModelVersion") String smVer) {
301 QueryServiceMacroHolder qryResp;
302 int respStatus = HttpStatus.SC_OK;
304 ServiceMacroHolder ret;
306 try (CatalogDatabase db = CatalogDatabase.getInstance()) {
307 if (smUuid != null && !"".equals(smUuid)) {
309 LOGGER.debug ("Query serviceMacroHolder getAllResourcesByServiceModelUuid serviceModelUuid: " + uuid);
310 ret = db.getAllResourcesByServiceModelUuid(uuid);
312 else if (smiUuid != null && !"".equals(smiUuid)) {
314 if (smVer != null && !"".equals(smVer)) {
315 LOGGER.debug ("Query serviceMacroHolder getAllResourcesByServiceModelInvariantUuid serviceModelInvariantUuid: " + uuid+ " serviceModelVersion: "+ smVer);
316 ret = db.getAllResourcesByServiceModelInvariantUuid(uuid, smVer);
319 LOGGER.debug ("Query serviceMacroHolder getAllResourcesByServiceModelInvariantUuid serviceModelUuid: " + uuid);
320 ret = db.getAllResourcesByServiceModelInvariantUuid(uuid);
324 throw(new Exception("no matching parameters"));
328 LOGGER.debug ("serviceMacroHolder not found");
329 respStatus = HttpStatus.SC_NOT_FOUND;
330 qryResp = new QueryServiceMacroHolder();
332 LOGGER.debug ("serviceMacroHolder found");
333 qryResp = new QueryServiceMacroHolder(ret);
334 LOGGER.debug ("serviceMacroHolder qryResp="+ qryResp);
336 LOGGER.debug ("Query serviceMacroHolder exit");
337 return respond(version, respStatus, IS_ARRAY, qryResp);
338 } catch (Exception e) {
339 LOGGER.error (MessageEnum.RA_QUERY_VNF_ERR, uuid, "", "queryServiceMacroHolder", MsoLogger.ErrorCode.BusinessProcesssError, "Exception - queryServiceMacroHolder", e);
340 CatalogQueryException excResp = new CatalogQueryException(e.getMessage(), CatalogQueryExceptionCategory.INTERNAL, Boolean.FALSE, null);
342 .status(HttpStatus.SC_INTERNAL_SERVER_ERROR)
343 .entity(new GenericEntity<CatalogQueryException>(excResp) {})
349 @Path("allottedResources/{arModelCustomizationUuid}")
350 @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
351 public Response serviceAllottedResources (
352 @PathParam("version") String version,
353 @PathParam("arModelCustomizationUuid") String aUuid
355 return serviceAllottedResourcesImpl(version, !IS_ARRAY, aUuid, null, null, null);
359 @Path("serviceAllottedResources")
360 @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
361 public Response serviceAllottedResources(
362 @PathParam("version") String version,
363 @QueryParam("serviceModelUuid") String smUuid,
364 @QueryParam("serviceModelInvariantUuid") String smiUuid,
365 @QueryParam("serviceModelVersion") String smVer,
366 @QueryParam("arModelCustomizationUuid") String aUuid
368 return serviceAllottedResourcesImpl(version, IS_ARRAY, aUuid, smUuid, smiUuid, smVer);
371 public Response serviceAllottedResourcesImpl(String version, boolean isArray, String aUuid, String smUuid, String smiUuid, String smVer) {
372 QueryAllottedResourceCustomization qryResp;
373 int respStatus = HttpStatus.SC_OK;
375 List<AllottedResourceCustomization > ret;
377 try (CatalogDatabase db = CatalogDatabase.getInstance()) {
378 if (smUuid != null && !"".equals(smUuid)) {
380 LOGGER.debug ("Query AllottedResourceCustomization getAllAllottedResourcesByServiceModelUuid serviceModelUuid: " + uuid);
381 ret = db.getAllAllottedResourcesByServiceModelUuid(uuid);
383 else if (smiUuid != null && !"".equals(smiUuid)) {
385 if (smVer != null && !"".equals(smVer)) {
386 LOGGER.debug ("Query AllottedResourceCustomization getAllAllottedResourcesByServiceModelInvariantUuid serviceModelInvariantUuid: " + uuid+ " serviceModelVersion: "+ smVer);
387 ret = db.getAllAllottedResourcesByServiceModelInvariantUuid(uuid, smVer);
390 LOGGER.debug ("Query AllottedResourceCustomization getAllAllottedResourcesByServiceModelInvariantUuid serviceModelUuid: " + uuid);
391 ret = db.getAllAllottedResourcesByServiceModelInvariantUuid(uuid);
394 else if (aUuid != null && !"".equals(aUuid)) {
396 LOGGER.debug ("Query AllottedResourceCustomization getAllAllottedResourcesByArModelCustomizationUuid serviceModelUuid: " + uuid);
397 ret = db.getAllAllottedResourcesByArModelCustomizationUuid(uuid);
400 throw(new Exception("no matching parameters"));
403 if (ret == null || ret.isEmpty()) {
404 LOGGER.debug ("AllottedResourceCustomization not found");
405 respStatus = HttpStatus.SC_NOT_FOUND;
406 qryResp = new QueryAllottedResourceCustomization();
408 LOGGER.debug ("AllottedResourceCustomization found");
409 qryResp = new QueryAllottedResourceCustomization(ret);
410 LOGGER.debug ("AllottedResourceCustomization qryResp="+ qryResp);
412 LOGGER.debug ("Query AllottedResourceCustomization exit");
413 return respond(version, respStatus, isArray, qryResp);
414 } catch (Exception e) {
415 LOGGER.error (MessageEnum.RA_QUERY_VNF_ERR, uuid, "", "queryAllottedResourceCustomization", MsoLogger.ErrorCode.BusinessProcesssError, "Exception - queryAllottedResourceCustomization", e);
416 CatalogQueryException excResp = new CatalogQueryException(e.getMessage(), CatalogQueryExceptionCategory.INTERNAL, Boolean.FALSE, null);
418 .status(HttpStatus.SC_INTERNAL_SERVER_ERROR)
419 .entity(new GenericEntity<CatalogQueryException>(excResp) {})
424 // Added for DHV in 1702. Might be a temporary solution!
425 // Changing to use QueryVfModule so the modelCustomizationUuid is included in response
428 @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
429 public Response vfModules(@QueryParam("vfModuleModelName") String vfModuleModelName) {
430 QueryVfModule qryResp;
431 int respStatus = HttpStatus.SC_OK;
432 List<VfModuleCustomization> ret = null;
434 try (CatalogDatabase db = CatalogDatabase.getInstance()) {
435 if (vfModuleModelName != null && !"".equals(vfModuleModelName)) {
436 LOGGER.debug("Query vfModules by vfModuleModuleName: " + vfModuleModelName);
437 VfModuleCustomization vfModule = db.getVfModuleCustomizationByModelName(vfModuleModelName);
438 if (vfModule != null) {
439 ret = new ArrayList<>(1);
443 throw (new Exception("Incoming parameter is null or blank"));
445 if (ret == null || ret.isEmpty()) {
446 LOGGER.debug("vfModules not found");
447 respStatus = HttpStatus.SC_NOT_FOUND;
448 qryResp = new QueryVfModule();
450 LOGGER.debug("vfModules found");
451 qryResp = new QueryVfModule(ret);
452 LOGGER.debug("vfModules query Results is: " + qryResp);
453 LOGGER.debug("vfModules tojsonstring is: " + qryResp.JSON2(false, false));
455 LOGGER.debug("Query vfModules exit");
458 .entity(qryResp.JSON2(false, false))
459 .header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
461 } catch (Exception e) {
462 LOGGER.error(MessageEnum.RA_QUERY_VNF_ERR, vfModuleModelName, "", "queryVfModules",
463 MsoLogger.ErrorCode.BusinessProcesssError, "Exception during query VfModules by vfModuleModuleName: ",
465 CatalogQueryException excResp = new CatalogQueryException(e.getMessage(),
466 CatalogQueryExceptionCategory.INTERNAL, Boolean.FALSE, null);
468 .status(HttpStatus.SC_INTERNAL_SERVER_ERROR)
469 .entity(new GenericEntity<CatalogQueryException>(excResp) {
476 * Get the tosca csar info from catalog
479 * @param smUuid service model uuid
480 * @return the tosca csar information of the serivce.
481 * @since ONAP Beijing Release
484 @Path("serviceToscaCsar")
485 @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
486 public Response serviceToscaCsar(@QueryParam("serviceModelUuid") String smUuid) {
487 int respStatus = HttpStatus.SC_OK;
489 try (CatalogDatabase db = CatalogDatabase.getInstance()) {
490 if (smUuid != null && !"".equals(smUuid)) {
491 LOGGER.debug("Query Csar by service model uuid: " + smUuid);
492 ToscaCsar toscaCsar = db.getToscaCsarByServiceModelUUID(smUuid);
493 if (toscaCsar != null) {
494 QueryServiceCsar serviceCsar = new QueryServiceCsar(toscaCsar);
495 entity = serviceCsar.JSON2(false, false);
497 respStatus = HttpStatus.SC_NOT_FOUND;
500 throw (new Exception("Incoming parameter is null or blank"));
502 LOGGER.debug("Query Csar exit");
506 .header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
508 } catch (Exception e) {
509 LOGGER.error(MessageEnum.RA_QUERY_VNF_ERR, smUuid, "", "ServiceToscaCsar",
510 MsoLogger.ErrorCode.BusinessProcesssError, "Exception during query csar by service model uuid: ", e);
511 CatalogQueryException excResp = new CatalogQueryException(e.getMessage(),
512 CatalogQueryExceptionCategory.INTERNAL, Boolean.FALSE, null);
514 .status(HttpStatus.SC_INTERNAL_SERVER_ERROR)
515 .entity(new GenericEntity<CatalogQueryException>(excResp) {
522 * Get the resource recipe info from catalog
525 * @param rmUuid resource model uuid
526 * @return the recipe information of the resource.
527 * @since ONAP Beijing Release
530 @Path("resourceRecipe")
531 @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
532 public Response resourceRecipe(@QueryParam("resourceModelUuid") String rmUuid, @QueryParam("action") String action) {
533 int respStatus = HttpStatus.SC_OK;
535 try (CatalogDatabase db = CatalogDatabase.getInstance()) {
536 if (rmUuid != null && !"".equals(rmUuid)) {
537 LOGGER.debug("Query recipe by resource model uuid: " + rmUuid);
538 //check vnf and network and ar, the resource could be any resource.
539 Recipe recipe = db.getVnfRecipeByModuleUuid(rmUuid, action);
540 if (null == recipe) {
541 recipe = db.getNetworkRecipeByModuleUuid(rmUuid, action);
543 if (null == recipe) {
544 recipe = db.getArRecipeByModuleUuid(rmUuid, action);
546 if (recipe != null) {
547 QueryResourceRecipe resourceRecipe = new QueryResourceRecipe(recipe);
548 entity = resourceRecipe.JSON2(false, false);
550 respStatus = HttpStatus.SC_NOT_FOUND;
553 throw (new Exception("Incoming parameter is null or blank"));
555 LOGGER.debug("Query recipe exit");
559 .header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
561 } catch (Exception e) {
562 LOGGER.error(MessageEnum.RA_QUERY_VNF_ERR, rmUuid, "", "resourceRecipe",
563 MsoLogger.ErrorCode.BusinessProcesssError, "Exception during query recipe by resource model uuid: ", e);
564 CatalogQueryException excResp = new CatalogQueryException(e.getMessage(),
565 CatalogQueryExceptionCategory.INTERNAL, Boolean.FALSE, null);
567 .status(HttpStatus.SC_INTERNAL_SERVER_ERROR)
568 .entity(new GenericEntity<CatalogQueryException>(excResp) {