Change the header to SO
[so.git] / adapters / mso-catalog-db-adapter / src / main / java / org / openecomp / mso / adapters / catalogdb / CatalogDbAdapterRest.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP - SO
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
10  *
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  *
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=========================================================
19  */
20 package org.openecomp.mso.adapters.catalogdb;
21
22 /*
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
26
27 Returns a structure (JSON?) containing VNF RESOURCE attributes, plus a list of VF Module structures.
28
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.
31
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
34
35 Update the MSO Catalog DB schema to include the new fields defined in this user story.
36
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.
41
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.
44
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).
47
48 min and initial counts can be 0. max can be null to indicate no maximum.
49
50 Once the network-level distribution artifacts are defined, similar updates can be made to the NETWORK_RESOURCE table.
51 */
52
53 import java.util.ArrayList;
54 import java.util.List;
55 import javax.ws.rs.GET;
56 import javax.ws.rs.HEAD;
57 import javax.ws.rs.Path;
58 import javax.ws.rs.PathParam;
59 import javax.ws.rs.Produces;
60 import javax.ws.rs.QueryParam;
61 import javax.ws.rs.core.Response;
62 import javax.ws.rs.core.GenericEntity;
63 import javax.ws.rs.core.HttpHeaders;
64 import javax.ws.rs.core.MediaType;
65 import org.apache.http.HttpStatus;
66
67 import org.openecomp.mso.logger.MessageEnum;
68 import org.openecomp.mso.logger.MsoLogger;
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.CatalogQuery;
72 import org.openecomp.mso.adapters.catalogdb.catalogrest.QueryServiceVnfs;
73 import org.openecomp.mso.adapters.catalogdb.catalogrest.QueryServiceNetworks;
74 import org.openecomp.mso.adapters.catalogdb.catalogrest.QueryServiceMacroHolder;
75 import org.openecomp.mso.adapters.catalogdb.catalogrest.QueryAllottedResourceCustomization;
76 import org.openecomp.mso.adapters.catalogdb.catalogrest.QueryVfModule;
77 import org.openecomp.mso.db.catalog.CatalogDatabase;
78 import org.openecomp.mso.db.catalog.beans.VnfResourceCustomization;
79 import org.openecomp.mso.db.catalog.beans.VfModuleCustomization;
80 import org.openecomp.mso.db.catalog.beans.NetworkResourceCustomization;
81 import org.openecomp.mso.db.catalog.beans.ServiceMacroHolder;
82 import org.openecomp.mso.db.catalog.beans.AllottedResourceCustomization;
83
84 /**
85  * This class services calls to the REST interface for VF Modules (http://host:port/ecomp/mso/catalog/v1)
86  * Both XML and JSON can be produced/consumed.  Set Accept: and Content-Type: headers appropriately.  XML is the default.
87  * Requests respond synchronously only
88  */
89 @Path("/{version: v[0-9]+}")
90 public class CatalogDbAdapterRest {
91         private static MsoLogger LOGGER = MsoLogger.getMsoLogger (MsoLogger.Catalog.RA);
92         private static final boolean IS_ARRAY = true;
93
94         public Response respond(String version, int respStatus, boolean isArray, CatalogQuery qryResp) {
95                 return Response
96                                 .status(respStatus)
97                                 //.entity(new GenericEntity<QueryServiceVnfs>(qryResp) {})
98                                 .entity(qryResp.toJsonString(version, isArray))
99                                 .header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
100                                 .build();
101         }
102
103         @HEAD
104         @GET
105         @Path("healthcheck")
106         @Produces(MediaType.TEXT_HTML)
107         public Response healthcheck (
108                         @PathParam("version") String version
109         ) {
110                 String CHECK_HTML = "<!DOCTYPE html><html><head><meta charset=\"ISO-8859-1\"><title>Health Check</title></head><body>Application "+ version+ " ready</body></html>";
111                 return Response.ok().entity(CHECK_HTML).build();
112         }
113
114         @GET
115         @Path("vnfResources/{vnfModelCustomizationUuid}")
116         @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
117         public Response serviceVnfs (
118                         @PathParam("version") String version,
119                         @PathParam("vnfModelCustomizationUuid") String vnfUuid
120         ) {
121                 return serviceVnfsImpl (version, !IS_ARRAY, vnfUuid, null, null, null, null);
122         }
123
124         @GET
125         @Path("serviceVnfs")
126         @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
127         public Response serviceVnfs(
128                         @PathParam("version") String version,
129                         @QueryParam("vnfModelCustomizationUuid") String vnfUuid,
130                         @QueryParam("serviceModelUuid") String smUuid,
131                         @QueryParam("serviceModelInvariantUuid") String smiUuid,
132                         @QueryParam("serviceModelVersion") String smVer,
133                         @QueryParam("serviceModelName") String smName
134         ) {
135                 return serviceVnfsImpl (version, IS_ARRAY, vnfUuid, smUuid, smiUuid, smVer, smName);
136         }
137
138         public Response serviceVnfsImpl(String version, boolean isArray, String vnfUuid, String smUuid, String smiUuid, String smVer, String smName) {
139                 QueryServiceVnfs qryResp;
140                 int respStatus = HttpStatus.SC_OK;
141                 String uuid = "";
142                 List<VnfResourceCustomization> ret;
143
144                 try (CatalogDatabase db = CatalogDatabase.getInstance()) {
145                         if (vnfUuid != null && !vnfUuid.equals("")) {
146                                 uuid = vnfUuid;
147                                 LOGGER.debug ("Query serviceVnfs getAllVnfsByVnfModelCustomizationUuid vnfModelCustomizationUuid: " + uuid);
148                                 ret = db.getAllVnfsByVnfModelCustomizationUuid(uuid);
149                         }
150                         else if (smUuid != null && !smUuid.equals("")) {
151                                 uuid = smUuid;
152                                 LOGGER.debug ("Query serviceVnfs getAllVnfsByServiceModelUuid serviceModelUuid: " + uuid);
153                                 ret = db.getAllVnfsByServiceModelUuid(uuid);
154                         }
155                         else if (smiUuid != null && !smiUuid.equals("")) {
156                                 uuid = smiUuid;
157                                 if (smVer != null && !smVer.equals("")) {
158                                         LOGGER.debug ("Query serviceVnfs getAllNetworksByServiceModelInvariantUuid serviceModelInvariantUuid: " + uuid+ " serviceModelVersion: "+ smVer);
159                                         ret = db.getAllVnfsByServiceModelInvariantUuid(uuid, smVer);
160                                 }
161                                 else {
162                                         LOGGER.debug ("Query serviceVnfs getAllNetworksByServiceModelInvariantUuid serviceModelUuid: " + uuid);
163                                         ret = db.getAllVnfsByServiceModelInvariantUuid(uuid);
164                                 }
165                         }
166                         else if (smName != null && !smName.equals("")) {
167                                 if (smVer != null && !smVer.equals("")) {
168                                         LOGGER.debug ("Query serviceVnfs getAllVnfsByServiceName serviceModelInvariantName: " + smName+ " serviceModelVersion: "+ smVer);
169                                         ret = db.getAllVnfsByServiceName(smName, smVer);
170                                 }
171                                 else {
172                                         LOGGER.debug ("Query serviceVnfs getAllVnfsByServiceName serviceModelName: " + smName);
173                                         ret = db.getAllVnfsByServiceName(smName);
174                                 }
175                         }
176                         else {
177                                 throw(new Exception("no matching parameters"));
178                         }
179
180                         if (ret == null || ret.isEmpty()) {
181                                 LOGGER.debug ("serviceVnfs not found");
182                                 respStatus = HttpStatus.SC_NOT_FOUND;
183                                 qryResp = new QueryServiceVnfs();
184                         } else {
185                                 LOGGER.debug ("serviceVnfs found");
186                                 qryResp = new QueryServiceVnfs(ret);
187                                 LOGGER.debug ("serviceVnfs qryResp="+ qryResp);
188                         }
189                         LOGGER.debug ("Query serviceVnfs exit");
190                         return respond(version, respStatus, isArray, qryResp);
191                 } catch (Exception e) {
192                         LOGGER.error (MessageEnum.RA_QUERY_VNF_ERR,  uuid, "", "queryServiceVnfs", MsoLogger.ErrorCode.BusinessProcesssError, "Exception - queryServiceVnfs", e);
193                         CatalogQueryException excResp = new CatalogQueryException(e.getMessage(), CatalogQueryExceptionCategory.INTERNAL, Boolean.FALSE, null);
194                         return Response
195                                 .status(HttpStatus.SC_INTERNAL_SERVER_ERROR)
196                                 .entity(new GenericEntity<CatalogQueryException>(excResp) {})
197                                 .build();
198                 }
199         }
200
201         @GET
202         @Path("networkResources/{networkModelCustomizationUuid}")
203         @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
204         public Response serviceNetworks (
205                         @PathParam("version") String version,
206                         @PathParam("networkModelCustomizationUuid") String nUuid
207         ) {
208                 return serviceNetworksImpl (version, !IS_ARRAY, nUuid, null, null, null, null);
209         }
210
211         @GET
212         @Path("serviceNetworks")
213         @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
214         public Response serviceNetworks (
215                         @PathParam("version") String version,
216                         @QueryParam("networkModelCustomizationUuid") String nUuid,
217                         @QueryParam("networkType") String nType,
218                 @QueryParam("networkModelName") String nModelName,
219                         @QueryParam("serviceModelUuid") String smUuid,
220                         @QueryParam("serviceModelInvariantUuid") String smiUuid,
221                 @QueryParam("serviceModelVersion") String smVer,
222                 @QueryParam("networkModelVersion") String nmVer
223         ) {
224                 if (nModelName != null && !nModelName.equals("")) {
225                         nType = nModelName;
226                 }
227                 return serviceNetworksImpl (version, IS_ARRAY, nUuid, nType, smUuid, smiUuid, smVer);
228         }
229
230         public Response serviceNetworksImpl (String version, boolean isArray, String nUuid, String nType, String smUuid, String smiUuid, String smVer) {
231                 QueryServiceNetworks qryResp;
232                 int respStatus = HttpStatus.SC_OK;
233                 String uuid = "";
234                 List<NetworkResourceCustomization> ret;
235
236                 try (CatalogDatabase db = CatalogDatabase.getInstance()) {
237                         if (nUuid != null && !nUuid.equals("")) {
238                                 uuid = nUuid;
239                                 LOGGER.debug ("Query serviceNetworks getAllNetworksByNetworkModelCustomizationUuid networkModelCustomizationUuid: " + uuid);
240                                 ret = db.getAllNetworksByNetworkModelCustomizationUuid(uuid);
241                         }
242                         else if (smUuid != null && !smUuid.equals("")) {
243                                 uuid = smUuid;
244                                 LOGGER.debug ("Query serviceNetworks getAllNetworksByServiceModelUuid serviceModelUuid: " + uuid);
245                                 ret = db.getAllNetworksByServiceModelUuid(uuid);
246                         }
247                         else if (nType != null && !nType.equals("")) {
248                                 uuid = nType;
249                                 LOGGER.debug ("Query serviceNetworks getAllNetworksByNetworkType serviceModelUuid: " + uuid);
250                                 ret = db.getAllNetworksByNetworkType(uuid);
251                         }
252                         else if (smiUuid != null && !smiUuid.equals("")) {
253                                 uuid = smiUuid;
254                                 if (smVer != null && !smVer.equals("")) {
255                                         LOGGER.debug ("Query serviceNetworks getAllNetworksByServiceModelInvariantUuid serviceModelInvariantUuid: " + uuid+ " serviceModelVersion: "+ smVer);
256                                         ret = db.getAllNetworksByServiceModelInvariantUuid(uuid, smVer);
257                                 }
258                                 else {
259                                         LOGGER.debug ("Query serviceNetworks getAllNetworksByServiceModelInvariantUuid serviceModelUuid: " + uuid);
260                                         ret = db.getAllNetworksByServiceModelInvariantUuid(uuid);
261                                 }
262                         }
263                         else {
264                                 throw(new Exception("no matching parameters"));
265                         }
266
267                         if (ret == null || ret.isEmpty()) {
268                                 LOGGER.debug ("serviceNetworks not found");
269                                 respStatus = HttpStatus.SC_NOT_FOUND;
270                                 qryResp = new QueryServiceNetworks();
271                         } else {
272                                 LOGGER.debug ("serviceNetworks found");
273                                 qryResp = new QueryServiceNetworks(ret);
274                                 LOGGER.debug ("serviceNetworks qryResp="+ qryResp);
275                         }
276                         LOGGER.debug ("Query serviceNetworks exit");
277                         return respond(version, respStatus, isArray, qryResp);
278                 } catch (Exception e) {
279                         LOGGER.error (MessageEnum.RA_QUERY_VNF_ERR,  uuid, "", "queryServiceNetworks", MsoLogger.ErrorCode.BusinessProcesssError, "Exception - queryServiceNetworks", e);
280                         CatalogQueryException excResp = new CatalogQueryException(e.getMessage(), CatalogQueryExceptionCategory.INTERNAL, Boolean.FALSE, null);
281                         return Response
282                                 .status(HttpStatus.SC_INTERNAL_SERVER_ERROR)
283                                 .entity(new GenericEntity<CatalogQueryException>(excResp) {})
284                                 .build();
285                 }
286         }
287
288         @GET
289         @Path("serviceResources")
290         @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
291         public Response serviceResources(
292                         @PathParam("version") String version,
293                         @QueryParam("serviceModelUuid") String smUuid,
294                         @QueryParam("serviceModelInvariantUuid") String smiUuid,
295                         @QueryParam("serviceModelVersion") String smVer) {
296                 QueryServiceMacroHolder qryResp;
297                 int respStatus = HttpStatus.SC_OK;
298                 String uuid = "";
299                 ServiceMacroHolder ret;
300
301                 try (CatalogDatabase db = CatalogDatabase.getInstance()) {
302                         if (smUuid != null && !smUuid.equals("")) {
303                                 uuid = smUuid;
304                                 LOGGER.debug ("Query serviceMacroHolder getAllResourcesByServiceModelUuid serviceModelUuid: " + uuid);
305                                 ret = db.getAllResourcesByServiceModelUuid(uuid);
306                         }
307                         else if (smiUuid != null && !smiUuid.equals("")) {
308                                 uuid = smiUuid;
309                                 if (smVer != null && !smVer.equals("")) {
310                                         LOGGER.debug ("Query serviceMacroHolder getAllResourcesByServiceModelInvariantUuid serviceModelInvariantUuid: " + uuid+ " serviceModelVersion: "+ smVer);
311                                         ret = db.getAllResourcesByServiceModelInvariantUuid(uuid, smVer);
312                                 }
313                                 else {
314                                         LOGGER.debug ("Query serviceMacroHolder getAllResourcesByServiceModelInvariantUuid serviceModelUuid: " + uuid);
315                                         ret = db.getAllResourcesByServiceModelInvariantUuid(uuid);
316                                 }
317                         }
318                         else {
319                                 throw(new Exception("no matching parameters"));
320                         }
321
322                         if (ret == null) {
323                                 LOGGER.debug ("serviceMacroHolder not found");
324                                 respStatus = HttpStatus.SC_NOT_FOUND;
325                                 qryResp = new QueryServiceMacroHolder();
326                         } else {
327                                 LOGGER.debug ("serviceMacroHolder found");
328                                 qryResp = new QueryServiceMacroHolder(ret);
329                                 LOGGER.debug ("serviceMacroHolder qryResp="+ qryResp);
330                         }
331                         LOGGER.debug ("Query serviceMacroHolder exit");
332                         return respond(version, respStatus, IS_ARRAY, qryResp);
333                 } catch (Exception e) {
334                         LOGGER.error (MessageEnum.RA_QUERY_VNF_ERR,  uuid, "", "queryServiceMacroHolder", MsoLogger.ErrorCode.BusinessProcesssError, "Exception - queryServiceMacroHolder", e);
335                         CatalogQueryException excResp = new CatalogQueryException(e.getMessage(), CatalogQueryExceptionCategory.INTERNAL, Boolean.FALSE, null);
336                         return Response
337                                 .status(HttpStatus.SC_INTERNAL_SERVER_ERROR)
338                                 .entity(new GenericEntity<CatalogQueryException>(excResp) {})
339                                 .build();
340                 }
341         }
342
343         @GET
344         @Path("allottedResources/{arModelCustomizationUuid}")
345         @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
346         public Response serviceAllottedResources (
347                         @PathParam("version") String version,
348                         @PathParam("arModelCustomizationUuid") String aUuid
349         ) {
350                 return serviceAllottedResourcesImpl(version, !IS_ARRAY, aUuid, null, null, null);
351         }
352
353         @GET
354         @Path("serviceAllottedResources")
355         @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
356         public Response serviceAllottedResources(
357                         @PathParam("version") String version,
358                         @QueryParam("serviceModelUuid") String smUuid,
359                         @QueryParam("serviceModelInvariantUuid") String smiUuid,
360                         @QueryParam("serviceModelVersion") String smVer,
361                         @QueryParam("arModelCustomizationUuid") String aUuid
362         ) {
363                 return serviceAllottedResourcesImpl(version, IS_ARRAY, aUuid, smUuid, smiUuid, smVer);
364         }
365
366         public Response serviceAllottedResourcesImpl(String version, boolean isArray, String aUuid, String smUuid, String smiUuid, String smVer) {
367                 QueryAllottedResourceCustomization qryResp;
368                 int respStatus = HttpStatus.SC_OK;
369                 String uuid = "";
370                 List<AllottedResourceCustomization > ret;
371
372                 try (CatalogDatabase db = CatalogDatabase.getInstance()) {
373                         if (smUuid != null && !smUuid.equals("")) {
374                                 uuid = smUuid;
375                                 LOGGER.debug ("Query AllottedResourceCustomization getAllAllottedResourcesByServiceModelUuid serviceModelUuid: " + uuid);
376                                 ret = db.getAllAllottedResourcesByServiceModelUuid(uuid);
377                         }
378                         else if (smiUuid != null && !smiUuid.equals("")) {
379                                 uuid = smiUuid;
380                                 if (smVer != null && !smVer.equals("")) {
381                                         LOGGER.debug ("Query AllottedResourceCustomization getAllAllottedResourcesByServiceModelInvariantUuid serviceModelInvariantUuid: " + uuid+ " serviceModelVersion: "+ smVer);
382                                         ret = db.getAllAllottedResourcesByServiceModelInvariantUuid(uuid, smVer);
383                                 }
384                                 else {
385                                         LOGGER.debug ("Query AllottedResourceCustomization getAllAllottedResourcesByServiceModelInvariantUuid serviceModelUuid: " + uuid);
386                                         ret = db.getAllAllottedResourcesByServiceModelInvariantUuid(uuid);
387                                 }
388                         }
389                         else if (aUuid != null && !aUuid.equals("")) {
390                                 uuid = aUuid;
391                                 LOGGER.debug ("Query AllottedResourceCustomization getAllAllottedResourcesByArModelCustomizationUuid serviceModelUuid: " + uuid);
392                                 ret = db.getAllAllottedResourcesByArModelCustomizationUuid(uuid);
393                         }
394                         else {
395                                 throw(new Exception("no matching parameters"));
396                         }
397
398                         if (ret == null || ret.isEmpty()) {
399                                 LOGGER.debug ("AllottedResourceCustomization not found");
400                                 respStatus = HttpStatus.SC_NOT_FOUND;
401                                 qryResp = new QueryAllottedResourceCustomization();
402                         } else {
403                                 LOGGER.debug ("AllottedResourceCustomization found");
404                                 qryResp = new QueryAllottedResourceCustomization(ret);
405                                 LOGGER.debug ("AllottedResourceCustomization qryResp="+ qryResp);
406                         }
407                         LOGGER.debug ("Query AllottedResourceCustomization exit");
408                         return respond(version, respStatus, isArray, qryResp);
409                 } catch (Exception e) {
410                         LOGGER.error (MessageEnum.RA_QUERY_VNF_ERR,  uuid, "", "queryAllottedResourceCustomization", MsoLogger.ErrorCode.BusinessProcesssError, "Exception - queryAllottedResourceCustomization", e);
411                         CatalogQueryException excResp = new CatalogQueryException(e.getMessage(), CatalogQueryExceptionCategory.INTERNAL, Boolean.FALSE, null);
412                         return Response
413                                 .status(HttpStatus.SC_INTERNAL_SERVER_ERROR)
414                                 .entity(new GenericEntity<CatalogQueryException>(excResp) {})
415                                 .build();
416                 }
417         }
418         
419         // Added for DHV in 1702.  Might be a temporary solution!
420         // Changing to use QueryVfModule so the modelCustomizationUuid is included in response
421         @GET
422         @Path("vfModules")
423         @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
424         public Response vfModules(@QueryParam("vfModuleModelName") String vfModuleModelName) {
425                 QueryVfModule qryResp;
426                 int respStatus = HttpStatus.SC_OK;
427                 List<VfModuleCustomization> ret = null;
428                 CatalogDatabase db = CatalogDatabase.getInstance();
429
430                 try{
431                         if(vfModuleModelName != null && !vfModuleModelName.equals("")){
432                                 LOGGER.debug ("Query vfModules by vfModuleModuleName: " + vfModuleModelName);
433                                 VfModuleCustomization vfModule = db.getVfModuleCustomizationByModelName(vfModuleModelName);
434                                 if(vfModule != null){
435                                         ret = new ArrayList<VfModuleCustomization>(1);
436                                         ret.add(vfModule);
437                                 }
438                         }else{
439                                 throw(new Exception("Incoming parameter is null or blank"));
440                         }
441                         if(ret == null || ret.isEmpty()){
442                                 LOGGER.debug ("vfModules not found");
443                                 respStatus = HttpStatus.SC_NOT_FOUND;
444                                 qryResp = new QueryVfModule();
445                         }else{
446                                 LOGGER.debug ("vfModules found");
447                                 qryResp = new QueryVfModule(ret);
448                                 LOGGER.debug ("vfModules query Results is: "+ qryResp);
449                                 LOGGER.debug ("vfModules tojsonstring is: "+ qryResp.JSON2(false, false));
450                         }
451                         LOGGER.debug ("Query vfModules exit");
452                         return Response
453                                         .status(respStatus)
454                                         .entity(qryResp.JSON2(false, false)) 
455                                         .header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
456                                         .build();
457                 }catch(Exception e){
458                         LOGGER.error (MessageEnum.RA_QUERY_VNF_ERR,  vfModuleModelName, "", "queryVfModules", MsoLogger.ErrorCode.BusinessProcesssError, "Exception during query VfModules by vfModuleModuleName: ", e);
459                         CatalogQueryException excResp = new CatalogQueryException(e.getMessage(), CatalogQueryExceptionCategory.INTERNAL, Boolean.FALSE, null);
460                         return Response
461                                         .status(HttpStatus.SC_INTERNAL_SERVER_ERROR)
462                                         .entity(new GenericEntity<CatalogQueryException>(excResp) {})
463                                         .build();
464                 }finally {
465                         db.close();
466                 }
467         }
468
469 }