Initial OpenECOMP MSO commit
[so.git] / adapters / mso-vnf-adapter / src / main / java / org / openecomp / mso / adapters / vnf / VolumeAdapterRest.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * OPENECOMP - MSO
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
21 package org.openecomp.mso.adapters.vnf;
22
23
24 import java.util.HashMap;
25 import java.util.Map;
26
27 import javax.ws.rs.Consumes;
28 import javax.ws.rs.DELETE;
29 import javax.ws.rs.GET;
30 import javax.ws.rs.POST;
31 import javax.ws.rs.PUT;
32 import javax.ws.rs.Path;
33 import javax.ws.rs.PathParam;
34 import javax.ws.rs.Produces;
35 import javax.ws.rs.QueryParam;
36 import javax.ws.rs.core.GenericEntity;
37 import javax.ws.rs.core.MediaType;
38 import javax.ws.rs.core.Response;
39 import javax.xml.ws.Holder;
40
41 import org.apache.http.HttpStatus;
42
43 import org.openecomp.mso.adapters.vnf.exceptions.VnfException;
44 import org.openecomp.mso.adapters.vnfrest.CreateVolumeGroupRequest;
45 import org.openecomp.mso.adapters.vnfrest.CreateVolumeGroupResponse;
46 import org.openecomp.mso.adapters.vnfrest.DeleteVolumeGroupRequest;
47 import org.openecomp.mso.adapters.vnfrest.DeleteVolumeGroupResponse;
48 import org.openecomp.mso.adapters.vnfrest.QueryVolumeGroupResponse;
49 import org.openecomp.mso.adapters.vnfrest.RollbackVolumeGroupRequest;
50 import org.openecomp.mso.adapters.vnfrest.RollbackVolumeGroupResponse;
51 import org.openecomp.mso.adapters.vnfrest.UpdateVolumeGroupRequest;
52 import org.openecomp.mso.adapters.vnfrest.UpdateVolumeGroupResponse;
53 import org.openecomp.mso.adapters.vnfrest.VolumeGroupExceptionResponse;
54 import org.openecomp.mso.adapters.vnfrest.VolumeGroupRollback;
55 import org.openecomp.mso.cloud.CloudConfigFactory;
56 import org.openecomp.mso.entity.MsoRequest;
57 import org.openecomp.mso.logger.MessageEnum;
58 import org.openecomp.mso.logger.MsoLogger;
59 import org.openecomp.mso.openstack.beans.VnfRollback;
60 import org.openecomp.mso.openstack.beans.VnfStatus;
61 import org.openecomp.mso.openstack.exceptions.MsoExceptionCategory;
62 import org.openecomp.mso.properties.MsoPropertiesFactory;
63
64 /**
65  * This class services calls to the REST interface for VNF Volumes (http://host:port/vnfs/rest/v1/volume-groups)
66  * Both XML and JSON can be produced/consumed.  Set Accept: and Content-Type: headers appropriately.  XML is the default.
67  * For testing, call with cloudSiteId = ___TESTING___
68  * To test exceptions, also set tenantId = ___TESTING___
69  */
70 @Path("/v1/volume-groups")
71 public class VolumeAdapterRest {
72         private static final MsoLogger LOGGER = MsoLogger.getMsoLogger(MsoLogger.Catalog.RA);
73         private static final String TESTING_KEYWORD = "___TESTING___";
74         private final CloudConfigFactory cloudConfigFactory = new CloudConfigFactory();
75         private final MsoPropertiesFactory msoPropertiesFactory = new MsoPropertiesFactory();
76         private final MsoVnfAdapter vnfAdapter = new MsoVnfAdapterImpl(msoPropertiesFactory, cloudConfigFactory);
77
78         @POST
79         @Path("")
80         @Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
81         @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
82         public Response createVNFVolumes(final CreateVolumeGroupRequest req) {
83                 LOGGER.debug("createVNFVolumes enter: " + req.toJsonString());
84                 CreateVNFVolumesTask task = new CreateVNFVolumesTask(req);
85                 if (req.isSynchronous()) {
86                         // This is a synchronous request
87                         task.run();
88                         return Response
89                                 .status(task.getStatusCode())
90                                 .entity(task.getGenericEntityResponse())
91                                 .build();
92                 } else {
93                         // This is an asynchronous request
94                         try {
95                                 Thread t1 = new Thread(task);
96                                 t1.start();
97                         } catch (Exception e) {
98                                 // problem handling create, send generic failure as sync resp to caller
99                                 LOGGER.error (MessageEnum.RA_CREATE_VNF_ERR, "", "createVNFVolumes", MsoLogger.ErrorCode.BusinessProcesssError, "Exception - createVNFVolumes", e);
100                                 return Response.serverError().build();
101                         }
102                         // send sync response (ACK) to caller
103                         LOGGER.debug ("createVNFVolumes exit");
104                         return Response.status(HttpStatus.SC_ACCEPTED).build();
105                 }
106         }
107
108         public class CreateVNFVolumesTask implements Runnable {
109                 private final CreateVolumeGroupRequest req;
110                 private CreateVolumeGroupResponse response = null;
111                 private VolumeGroupExceptionResponse eresp = null;
112                 private boolean sendxml;
113
114                 public CreateVNFVolumesTask(CreateVolumeGroupRequest req) {
115                         this.req = req;
116                         this.sendxml = true; // can be set with a field or header later
117                 }
118                 public int getStatusCode() {
119                         return (response != null) ? HttpStatus.SC_OK : HttpStatus.SC_BAD_REQUEST;
120                 }
121                 public Object getGenericEntityResponse() {
122                         return (response != null)
123                                 ? new GenericEntity<CreateVolumeGroupResponse>(response) {}
124                                 : new GenericEntity<VolumeGroupExceptionResponse>(eresp) {};
125                 }
126                 private String getResponse() {
127                         if (response != null) {
128                                 return sendxml ? response.toXmlString() : response.toJsonString();
129                         } else {
130                                 return sendxml ? eresp.toXmlString() : eresp.toJsonString();
131                         }
132                 }
133                 @Override
134                 public void run() {
135                         LOGGER.debug ("CreateVFModule VolumesTask start");
136                         try {
137                                 // Synchronous Web Service Outputs
138                                 Holder<String> stackId = new Holder<String>();
139                                 Holder<Map<String, String>> outputs = new Holder<Map<String, String>>();
140                                 Holder<VnfRollback> vnfRollback = new Holder<VnfRollback>();
141                                 String completeVnfVfModuleType = req.getVnfType() + "::" + req.getVfModuleType();
142                                 LOGGER.debug("in createVfModuleVolumes - completeVnfVfModuleType=" + completeVnfVfModuleType);
143
144                                 String cloudsite = req.getCloudSiteId();
145                                 if (cloudsite != null && cloudsite.equals(TESTING_KEYWORD)) {
146                                         String tenant = req.getTenantId();
147                                         if (tenant != null && tenant.equals(TESTING_KEYWORD)) {
148                                                 throw new VnfException("testing.");
149                                         }
150                                         stackId.value = "479D3D8B-6360-47BC-AB75-21CC91981484";
151                                         outputs.value = testMap();
152                                 } else {
153 //                                      vnfAdapter.createVnf(
154 //                                                      req.getCloudSiteId(),
155 //                                                      req.getTenantId(),
156 //                                                      req.getVnfType(),
157 //                                                      req.getVnfVersion(),
158 //                                                      req.getVolumeGroupName(),
159 //                                                      "VOLUME",                       // request type is VOLUME
160 //                                                      null,                           // not sure about this
161 //                                                      req.getVolumeGroupParams(),
162 //                                                      req.getFailIfExists(),
163 //                                                      req.getSuppressBackout(),
164 //                                                      req.getMsoRequest(),
165 //                                                      stackId,
166 //                                                      outputs,
167 //                                                      vnfRollback);
168                                         vnfAdapter.createVfModule(
169                                                         req.getCloudSiteId(), //cloudSiteId, 
170                                                         req.getTenantId(), //tenantId, 
171                                                         //req.getVnfType(), //vnfType, 
172                                                         completeVnfVfModuleType,
173                                                         req.getVnfVersion(), //vnfVersion, 
174                                                         req.getVolumeGroupName(), //vnfName, 
175                                                         "VOLUME", //requestType, 
176                                                         null, //volumeGroupHeatStackId, 
177                                                         null, //baseVfHeatStackId, 
178                                                         req.getVolumeGroupParams(), //inputs, 
179                                                         req.getFailIfExists(), //failIfExists, 
180                                                         req.getSuppressBackout(), //backout, 
181                                                         req.getMsoRequest(), // msoRequest, 
182                                                         stackId, 
183                                                         outputs, 
184                                                         vnfRollback);
185                                 }
186                                 VolumeGroupRollback rb = new VolumeGroupRollback(
187                                                 req.getVolumeGroupId(),
188                                                 stackId.value,
189                                                 true,                                           // TODO boolean volumeGroupCreated, when would it be false?
190                                                 req.getTenantId(),
191                                                 req.getCloudSiteId(),
192                                                 req.getMsoRequest(),
193                                                 req.getMessageId());
194                                 response = new CreateVolumeGroupResponse(
195                                                 req.getVolumeGroupId(),
196                                                 stackId.value,
197                                                 true,                                           // TODO boolean volumeGroupCreated, when would it be false?
198                                                 outputs.value,
199                                                 rb,
200                                                 req.getMessageId());
201                         } catch (VnfException e) {
202                                 eresp = new VolumeGroupExceptionResponse(
203                                         e.getMessage(), MsoExceptionCategory.INTERNAL, true, req.getMessageId());
204                         }
205                         if (!req.isSynchronous()) {
206                                 // This is asynch, so POST response back to caller
207                                 BpelRestClient bpelClient = new BpelRestClient();
208                                 bpelClient.bpelPost(getResponse(), req.getNotificationUrl(), sendxml);
209                         }
210                         LOGGER.debug ("CreateVFModule VolumesTask exit: code=" + getStatusCode() + ", resp="+ getResponse());
211                 }
212         }
213
214         @DELETE
215         @Path("{aaiVolumeGroupId}")
216         @Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
217         @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
218         public Response deleteVNFVolumes(
219                 @PathParam("aaiVolumeGroupId") String aaiVolumeGroupId,
220                 final DeleteVolumeGroupRequest req
221                 )
222         {
223                 LOGGER.debug("deleteVNFVolumes enter: " + req.toJsonString());
224                 if (aaiVolumeGroupId == null || !aaiVolumeGroupId.equals(req.getVolumeGroupId())) {
225                         return Response
226                                 .status(HttpStatus.SC_BAD_REQUEST)
227                                 .type(MediaType.TEXT_PLAIN)
228                                 .entity("VolumeGroupId in URL does not match content")
229                                 .build();
230                 }
231                 DeleteVNFVolumesTask task = new DeleteVNFVolumesTask(req);
232                 if (req.isSynchronous()) {
233                         // This is a synchronous request
234                         task.run();
235                         return Response
236                                 .status(task.getStatusCode())
237                                 .entity(task.getGenericEntityResponse())
238                                 .build();
239                 } else {
240                         // This is an asynchronous request
241                         try {
242                                 Thread t1 = new Thread(task);
243                                 t1.start();
244                         } catch (Exception e) {
245                                 // problem handling create, send generic failure as sync resp to caller
246                                 LOGGER.error (MessageEnum.RA_DELETE_VNF_ERR, "", "deleteVNFVolumes", MsoLogger.ErrorCode.BusinessProcesssError, "Exception - deleteVNFVolumes", e);
247                                 return Response.serverError().build();
248                         }
249                         // send sync response (ACK) to caller
250                         LOGGER.debug ("deleteVNFVolumes exit");
251                         return Response.status(HttpStatus.SC_ACCEPTED).build();
252                 }
253         }
254
255         public class DeleteVNFVolumesTask implements Runnable {
256                 private final DeleteVolumeGroupRequest req;
257                 private DeleteVolumeGroupResponse response = null;
258                 private VolumeGroupExceptionResponse eresp = null;
259                 private boolean sendxml;
260
261                 public DeleteVNFVolumesTask(DeleteVolumeGroupRequest req) {
262                         this.req = req;
263                         this.sendxml = true; // can be set with a field or header later
264                 }
265                 public int getStatusCode() {
266                         return (response != null) ? HttpStatus.SC_OK : HttpStatus.SC_BAD_REQUEST;
267                 }
268                 public Object getGenericEntityResponse() {
269                         return (response != null)
270                                 ? new GenericEntity<DeleteVolumeGroupResponse>(response) {}
271                                 : new GenericEntity<VolumeGroupExceptionResponse>(eresp) {};
272                 }
273                 private String getResponse() {
274                         if (response != null) {
275                                 return sendxml ? response.toXmlString() : response.toJsonString();
276                         } else {
277                                 return sendxml ? eresp.toXmlString() : eresp.toJsonString();
278                         }
279                 }
280                 @Override
281                 public void run() {
282                         LOGGER.debug("DeleteVNFVolumesTask start");
283                         try {
284                                 if (!req.getCloudSiteId().equals(TESTING_KEYWORD)) {
285                                         vnfAdapter.deleteVnf(req.getCloudSiteId(), req.getTenantId(), req.getVolumeGroupStackId(), req.getMsoRequest());
286                                 }
287                                 response = new DeleteVolumeGroupResponse(true, req.getMessageId());
288                         } catch (VnfException e) {
289                                 eresp = new VolumeGroupExceptionResponse(e.getMessage(), MsoExceptionCategory.INTERNAL, true, req.getMessageId());
290                         }
291                         if (!req.isSynchronous()) {
292                                 // This is asynch, so POST response back to caller
293                                 BpelRestClient bpelClient = new BpelRestClient();
294                                 bpelClient.bpelPost(getResponse(), req.getNotificationUrl(), sendxml);
295                         }
296                         LOGGER.debug("DeleteVNFVolumesTask exit: code=" + getStatusCode() + ", resp="+ getResponse());
297                 }
298         }
299
300         @DELETE
301         @Path("{aaiVolumeGroupId}/rollback")
302         @Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
303         @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
304         public Response rollbackVNFVolumes(
305                 @PathParam("aaiVolumeGroupId") String aaiVolumeGroupId,
306                 final RollbackVolumeGroupRequest req
307                 )
308         {
309                 LOGGER.debug("rollbackVNFVolumes enter: " + req.toJsonString());
310                 if (aaiVolumeGroupId == null || req.getVolumeGroupRollback() == null || !aaiVolumeGroupId.equals(req.getVolumeGroupRollback().getVolumeGroupId())) {
311                         return Response
312                                 .status(HttpStatus.SC_BAD_REQUEST)
313                                 .type(MediaType.TEXT_PLAIN)
314                                 .entity("VolumeGroupId in URL does not match content")
315                                 .build();
316                 }
317                 RollbackVNFVolumesTask task = new RollbackVNFVolumesTask(req);
318                 if (req.isSynchronous()) {
319                         // This is a synchronous request
320                         task.run();
321                         return Response
322                                 .status(task.getStatusCode())
323                                 .entity(task.getGenericEntityResponse())
324                                 .build();
325                 } else {
326                         // This is an asynchronous request
327                         try {
328                                 Thread t1 = new Thread(task);
329                                 t1.start();
330                         } catch (Exception e) {
331                                 // problem handling create, send generic failure as sync resp to caller
332                                 LOGGER.error (MessageEnum.RA_ROLLBACK_VNF_ERR, "", "rollbackVNFVolumes", MsoLogger.ErrorCode.BusinessProcesssError, "Exception - rollbackVNFVolumes", e);
333                                 return Response.serverError().build();
334                         }
335                         // send sync response (ACK) to caller
336                         LOGGER.debug("rollbackVNFVolumes exit");
337                         return Response.status(HttpStatus.SC_ACCEPTED).build();
338                 }
339         }
340
341         public class RollbackVNFVolumesTask implements Runnable {
342                 private final RollbackVolumeGroupRequest req;
343                 private RollbackVolumeGroupResponse response = null;
344                 private VolumeGroupExceptionResponse eresp = null;
345                 private boolean sendxml;
346
347                 public RollbackVNFVolumesTask(RollbackVolumeGroupRequest req) {
348                         this.req = req;
349                         this.sendxml = true; // can be set with a field or header later
350                 }
351                 public int getStatusCode() {
352                         return (response != null) ? HttpStatus.SC_OK : HttpStatus.SC_BAD_REQUEST;
353                 }
354                 public Object getGenericEntityResponse() {
355                         return (response != null)
356                                 ? new GenericEntity<RollbackVolumeGroupResponse>(response) {}
357                                 : new GenericEntity<VolumeGroupExceptionResponse>(eresp) {};
358                 }
359                 private String getResponse() {
360                         if (response != null) {
361                                 return sendxml ? response.toXmlString() : response.toJsonString();
362                         } else {
363                                 return sendxml ? eresp.toXmlString() : eresp.toJsonString();
364                         }
365                 }
366                 @Override
367                 public void run() {
368                         LOGGER.debug("DeleteVNFVolumesTask start");
369                         try {
370                                 VolumeGroupRollback vgr = req.getVolumeGroupRollback();
371                                 VnfRollback vrb = new VnfRollback(
372                                                 vgr.getVolumeGroupStackId(), vgr.getTenantId(), vgr.getCloudSiteId(), true, true,
373                                                 vgr.getMsoRequest(), null, null, null);
374                                 vnfAdapter.rollbackVnf(vrb);
375                                 response = new RollbackVolumeGroupResponse(true, req.getMessageId());
376                         } catch (VnfException e) {
377                                 eresp = new VolumeGroupExceptionResponse(e.getMessage(), MsoExceptionCategory.INTERNAL, true, req.getMessageId());
378                         }
379                         if (!req.isSynchronous()) {
380                                 // This is asynch, so POST response back to caller
381                                 BpelRestClient bpelClient = new BpelRestClient();
382                                 bpelClient.bpelPost(getResponse(), req.getNotificationUrl(), sendxml);
383                         }
384                         LOGGER.debug("DeleteVNFVolumesTask exit: code=" + getStatusCode() + ", resp="+ getResponse());
385                 }
386         }
387
388         @PUT
389         @Path("{aaiVolumeGroupId}")
390         @Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
391         @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
392         public Response updateVNFVolumes(
393                 @PathParam("aaiVolumeGroupId") String aaiVolumeGroupId,
394                 final UpdateVolumeGroupRequest req
395                 )
396         {
397                 LOGGER.debug("updateVNFVolumes enter: " + req.toJsonString());
398                 if (aaiVolumeGroupId == null || !aaiVolumeGroupId.equals(req.getVolumeGroupId())) {
399                         return Response
400                                 .status(HttpStatus.SC_BAD_REQUEST)
401                                 .type(MediaType.TEXT_PLAIN)
402                                 .entity("VolumeGroupId in URL does not match content")
403                                 .build();
404                 }
405                 UpdateVNFVolumesTask task = new UpdateVNFVolumesTask(req);
406                 if (req.isSynchronous()) {
407                         // This is a synchronous request
408                         task.run();
409                         return Response
410                                 .status(task.getStatusCode())
411                                 .entity(task.getGenericEntityResponse())
412                                 .build();
413                 } else {
414                         // This is an asynchronous request
415                 try {
416                         Thread t1 = new Thread(task);
417                         t1.start();
418                 } catch (Exception e) {
419                         // problem handling create, send generic failure as sync resp to caller
420                         LOGGER.error (MessageEnum.RA_UPDATE_VNF_ERR, "", "updateVNFVolumes", MsoLogger.ErrorCode.BusinessProcesssError, "Exception - updateVNFVolumes", e);
421                         return Response.serverError().build();
422                 }
423                 // send sync response (ACK) to caller
424                 LOGGER.debug ("updateVNFVolumes exit");
425                 return Response.status(HttpStatus.SC_ACCEPTED).build();
426                 }
427         }
428
429         public class UpdateVNFVolumesTask implements Runnable {
430                 private final UpdateVolumeGroupRequest req;
431                 private UpdateVolumeGroupResponse response = null;
432                 private VolumeGroupExceptionResponse eresp = null;
433                 private boolean sendxml;
434
435                 public UpdateVNFVolumesTask(UpdateVolumeGroupRequest req) {
436                         this.req = req;
437                         this.sendxml = true; // can be set with a field or header later
438                 }
439                 public int getStatusCode() {
440                         return (response != null) ? HttpStatus.SC_OK : HttpStatus.SC_BAD_REQUEST;
441                 }
442                 public Object getGenericEntityResponse() {
443                         return (response != null)
444                                 ? new GenericEntity<UpdateVolumeGroupResponse>(response) {}
445                                 : new GenericEntity<VolumeGroupExceptionResponse>(eresp) {};
446                 }
447                 private String getResponse() {
448                         if (response != null) {
449                                 return sendxml ? response.toXmlString() : response.toJsonString();
450                         } else {
451                                 return sendxml ? eresp.toXmlString() : eresp.toJsonString();
452                         }
453                 }
454                 @Override
455                 public void run() {
456                         LOGGER.debug("UpdateVNFVolumesTask start");
457                         try {
458                                 @SuppressWarnings("unused")
459                                 Holder<String> stackId = new Holder<String> ();
460                                 Holder<Map<String, String>> outputs = new Holder<Map <String, String>> ();
461                                 Holder<VnfRollback> vnfRollback = new Holder<VnfRollback> ();
462                                 String completeVnfVfModuleType = req.getVnfType() + "::" + req.getVfModuleType();
463                                 LOGGER.debug("in updateVfModuleVolume - completeVnfVfModuleType=" + completeVnfVfModuleType);
464
465                                 if (req.getCloudSiteId().equals(TESTING_KEYWORD)) {
466                                         outputs.value = testMap();
467                                 } else {
468                                         //vnfAdapter.updateVnf(
469                                         //              req.getCloudSiteId(),
470                                         //              req.getTenantId(),
471                                         //              req.getVnfType(),
472                                         //              req.getVnfVersion(),
473                                         //              req.getVfModuleType(),
474                                         //              "VOLUME",                       // request type is VOLUME
475                                         //              req.getVolumeGroupStackId(),
476                                         //              req.getVolumeGroupParams(),
477                                         //              req.getMsoRequest(),
478                                         //              outputs,
479                                         //              vnfRollback);
480                                         vnfAdapter.updateVfModule (req.getCloudSiteId(),
481                                                         req.getTenantId(),
482                                                         //req.getVnfType(),
483                                                         completeVnfVfModuleType,
484                                                         req.getVnfVersion(),
485                                                         req.getVolumeGroupStackId(),
486                                                         "VOLUME",
487                                                         null,
488                                                         null,
489                                                         req.getVolumeGroupStackId(),
490                                                         req.getVolumeGroupParams(),
491                                                         req.getMsoRequest(),
492                                                         outputs,
493                                                         vnfRollback); 
494                                 }
495                                 response = new UpdateVolumeGroupResponse(
496                                                 req.getVolumeGroupId(), req.getVolumeGroupStackId(),
497                                                 outputs.value, req.getMessageId());
498                         } catch (VnfException e) {
499                                 eresp = new VolumeGroupExceptionResponse(e.getMessage(), MsoExceptionCategory.INTERNAL, true, req.getMessageId());
500                         }
501                         if (!req.isSynchronous()) {
502                                 // This is asynch, so POST response back to caller
503                                 BpelRestClient bpelClient = new BpelRestClient();
504                                 bpelClient.bpelPost(getResponse(), req.getNotificationUrl(), sendxml);
505                         }
506                         LOGGER.debug("UpdateVNFVolumesTask exit: code=" + getStatusCode() + ", resp="+ getResponse());
507                 }
508         }
509
510         @GET
511         @Path("{aaiVolumeGroupId}")
512         @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
513         public Response queryVNFVolumes(
514                 @PathParam("aaiVolumeGroupId") String aaiVolumeGroupId,
515                 @QueryParam("cloudSiteId") String cloudSiteId,
516                 @QueryParam("tenantId") String tenantId,
517                 @QueryParam("volumeGroupStackId") String volumeGroupStackId,
518                 @QueryParam("skipAAI") Boolean skipAAI,
519                 @QueryParam("msoRequest.requestId") String requestId,
520                 @QueryParam("msoRequest.serviceInstanceId") String serviceInstanceId
521                 )
522         {
523         //This request responds synchronously only
524         LOGGER.debug ("queryVNFVolumes enter:" + aaiVolumeGroupId + " " + volumeGroupStackId);
525         MsoRequest msoRequest = new MsoRequest(requestId, serviceInstanceId);
526
527         try {
528                 int respStatus = HttpStatus.SC_OK;
529                 QueryVolumeGroupResponse qryResp = new QueryVolumeGroupResponse(aaiVolumeGroupId, volumeGroupStackId, null, null);
530                 Holder<Boolean> vnfExists = new Holder<Boolean>();
531                 Holder<String> vfModuleId = new Holder<String>();
532                 Holder<VnfStatus> status = new Holder<VnfStatus>();
533                 Holder<Map<String, String>> outputs = new Holder<Map<String, String>>();
534                         if (cloudSiteId != null && cloudSiteId.equals(TESTING_KEYWORD)) {
535                                 if (tenantId != null && tenantId.equals(TESTING_KEYWORD)) {
536                                         throw new VnfException("testing.");
537                                 }
538                                 vnfExists.value = true;
539                                 vfModuleId.value = TESTING_KEYWORD;
540                                 status.value = VnfStatus.ACTIVE;
541                                 outputs.value = testMap();
542                         } else {
543                                 vnfAdapter.queryVnf(cloudSiteId, tenantId, volumeGroupStackId, msoRequest, vnfExists, vfModuleId, status, outputs);
544                         }
545                 if (!vnfExists.value) {
546                         LOGGER.debug ("VNFVolumes not found");
547                         qryResp.setVolumeGroupStatus(status.value);
548                         respStatus = HttpStatus.SC_NOT_FOUND;
549                 } else {
550                         LOGGER.debug ("VNFVolumes found " + vfModuleId.value + ", status=" + status.value);
551                         qryResp.setVolumeGroupStatus(status.value);
552                         qryResp.setVolumeGroupOutputs(outputs.value);
553                 }
554                 LOGGER.debug("Query queryVNFVolumes exit");
555                 return Response
556                         .status(respStatus)
557                         .entity(new GenericEntity<QueryVolumeGroupResponse>(qryResp) {})
558                         .build();
559         } catch (VnfException e) {
560                 LOGGER.error(MessageEnum.RA_QUERY_VNF_ERR,  aaiVolumeGroupId, "", "queryVNFVolumes", MsoLogger.ErrorCode.BusinessProcesssError, "VnfException - queryVNFVolumes", e);
561                 VolumeGroupExceptionResponse excResp = new VolumeGroupExceptionResponse(e.getMessage(), MsoExceptionCategory.INTERNAL, Boolean.FALSE, null);
562                 LOGGER.debug("Query queryVNFVolumes exit");
563                 return Response
564                         .status(HttpStatus.SC_INTERNAL_SERVER_ERROR)
565                         .entity(new GenericEntity<VolumeGroupExceptionResponse>(excResp) {})
566                         .build();
567                 }
568         }
569     public static Map<String, String> testMap() {
570                 Map<String, String> m = new HashMap<String, String>();
571                 m.put("mickey", "7");
572                 m.put("clyde", "10");
573                 m.put("wayne", "99");
574                 return m;
575     }
576 }