Change the header to SO
[so.git] / adapters / mso-vnf-adapter / src / main / java / org / openecomp / mso / adapters / vnf / VolumeAdapterRest.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
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.getModelCustomizationUuid(),
179                                                         req.getVolumeGroupParams(), //inputs,
180                                                         req.getFailIfExists(), //failIfExists,
181                                                         req.getSuppressBackout(), //backout,
182                                                         req.getMsoRequest(), // msoRequest,
183                                                         stackId,
184                                                         outputs,
185                                                         vnfRollback);
186                                 }
187                                 VolumeGroupRollback rb = new VolumeGroupRollback(
188                                                 req.getVolumeGroupId(),
189                                                 stackId.value,
190                                                 true,                                           // TODO boolean volumeGroupCreated, when would it be false?
191                                                 req.getTenantId(),
192                                                 req.getCloudSiteId(),
193                                                 req.getMsoRequest(),
194                                                 req.getMessageId());
195                                 response = new CreateVolumeGroupResponse(
196                                                 req.getVolumeGroupId(),
197                                                 stackId.value,
198                                                 true,                                           // TODO boolean volumeGroupCreated, when would it be false?
199                                                 outputs.value,
200                                                 rb,
201                                                 req.getMessageId());
202                         } catch (VnfException e) {
203                                 eresp = new VolumeGroupExceptionResponse(
204                                         e.getMessage(), MsoExceptionCategory.INTERNAL, true, req.getMessageId());
205                         }
206                         if (!req.isSynchronous()) {
207                                 // This is asynch, so POST response back to caller
208                                 BpelRestClient bpelClient = new BpelRestClient();
209                                 bpelClient.bpelPost(getResponse(), req.getNotificationUrl(), sendxml);
210                         }
211                         LOGGER.debug ("CreateVFModule VolumesTask exit: code=" + getStatusCode() + ", resp="+ getResponse());
212                 }
213         }
214
215         @DELETE
216         @Path("{aaiVolumeGroupId}")
217         @Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
218         @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
219         public Response deleteVNFVolumes(
220                 @PathParam("aaiVolumeGroupId") String aaiVolumeGroupId,
221                 final DeleteVolumeGroupRequest req
222                 )
223         {
224                 LOGGER.debug("deleteVNFVolumes enter: " + req.toJsonString());
225                 if (aaiVolumeGroupId == null || !aaiVolumeGroupId.equals(req.getVolumeGroupId())) {
226                         return Response
227                                 .status(HttpStatus.SC_BAD_REQUEST)
228                                 .type(MediaType.TEXT_PLAIN)
229                                 .entity("VolumeGroupId in URL does not match content")
230                                 .build();
231                 }
232                 DeleteVNFVolumesTask task = new DeleteVNFVolumesTask(req);
233                 if (req.isSynchronous()) {
234                         // This is a synchronous request
235                         task.run();
236                         return Response
237                                 .status(task.getStatusCode())
238                                 .entity(task.getGenericEntityResponse())
239                                 .build();
240                 } else {
241                         // This is an asynchronous request
242                         try {
243                                 Thread t1 = new Thread(task);
244                                 t1.start();
245                         } catch (Exception e) {
246                                 // problem handling create, send generic failure as sync resp to caller
247                                 LOGGER.error (MessageEnum.RA_DELETE_VNF_ERR, "", "deleteVNFVolumes", MsoLogger.ErrorCode.BusinessProcesssError, "Exception - deleteVNFVolumes", e);
248                                 return Response.serverError().build();
249                         }
250                         // send sync response (ACK) to caller
251                         LOGGER.debug ("deleteVNFVolumes exit");
252                         return Response.status(HttpStatus.SC_ACCEPTED).build();
253                 }
254         }
255
256         public class DeleteVNFVolumesTask implements Runnable {
257                 private final DeleteVolumeGroupRequest req;
258                 private DeleteVolumeGroupResponse response = null;
259                 private VolumeGroupExceptionResponse eresp = null;
260                 private boolean sendxml;
261
262                 public DeleteVNFVolumesTask(DeleteVolumeGroupRequest req) {
263                         this.req = req;
264                         this.sendxml = true; // can be set with a field or header later
265                 }
266                 public int getStatusCode() {
267                         return (response != null) ? HttpStatus.SC_OK : HttpStatus.SC_BAD_REQUEST;
268                 }
269                 public Object getGenericEntityResponse() {
270                         return (response != null)
271                                 ? new GenericEntity<DeleteVolumeGroupResponse>(response) {}
272                                 : new GenericEntity<VolumeGroupExceptionResponse>(eresp) {};
273                 }
274                 private String getResponse() {
275                         if (response != null) {
276                                 return sendxml ? response.toXmlString() : response.toJsonString();
277                         } else {
278                                 return sendxml ? eresp.toXmlString() : eresp.toJsonString();
279                         }
280                 }
281                 @Override
282                 public void run() {
283                         LOGGER.debug("DeleteVNFVolumesTask start");
284                         try {
285                                 if (!req.getCloudSiteId().equals(TESTING_KEYWORD)) {
286                                         vnfAdapter.deleteVnf(req.getCloudSiteId(), req.getTenantId(), req.getVolumeGroupStackId(), req.getMsoRequest());
287                                 }
288                                 response = new DeleteVolumeGroupResponse(true, req.getMessageId());
289                         } catch (VnfException e) {
290                                 eresp = new VolumeGroupExceptionResponse(e.getMessage(), MsoExceptionCategory.INTERNAL, true, req.getMessageId());
291                         }
292                         if (!req.isSynchronous()) {
293                                 // This is asynch, so POST response back to caller
294                                 BpelRestClient bpelClient = new BpelRestClient();
295                                 bpelClient.bpelPost(getResponse(), req.getNotificationUrl(), sendxml);
296                         }
297                         LOGGER.debug("DeleteVNFVolumesTask exit: code=" + getStatusCode() + ", resp="+ getResponse());
298                 }
299         }
300
301         @DELETE
302         @Path("{aaiVolumeGroupId}/rollback")
303         @Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
304         @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
305         public Response rollbackVNFVolumes(
306                 @PathParam("aaiVolumeGroupId") String aaiVolumeGroupId,
307                 final RollbackVolumeGroupRequest req
308                 )
309         {
310                 LOGGER.debug("rollbackVNFVolumes enter: " + req.toJsonString());
311                 if (aaiVolumeGroupId == null || req.getVolumeGroupRollback() == null || !aaiVolumeGroupId.equals(req.getVolumeGroupRollback().getVolumeGroupId())) {
312                         return Response
313                                 .status(HttpStatus.SC_BAD_REQUEST)
314                                 .type(MediaType.TEXT_PLAIN)
315                                 .entity("VolumeGroupId in URL does not match content")
316                                 .build();
317                 }
318                 RollbackVNFVolumesTask task = new RollbackVNFVolumesTask(req);
319                 if (req.isSynchronous()) {
320                         // This is a synchronous request
321                         task.run();
322                         return Response
323                                 .status(task.getStatusCode())
324                                 .entity(task.getGenericEntityResponse())
325                                 .build();
326                 } else {
327                         // This is an asynchronous request
328                         try {
329                                 Thread t1 = new Thread(task);
330                                 t1.start();
331                         } catch (Exception e) {
332                                 // problem handling create, send generic failure as sync resp to caller
333                                 LOGGER.error (MessageEnum.RA_ROLLBACK_VNF_ERR, "", "rollbackVNFVolumes", MsoLogger.ErrorCode.BusinessProcesssError, "Exception - rollbackVNFVolumes", e);
334                                 return Response.serverError().build();
335                         }
336                         // send sync response (ACK) to caller
337                         LOGGER.debug("rollbackVNFVolumes exit");
338                         return Response.status(HttpStatus.SC_ACCEPTED).build();
339                 }
340         }
341
342         public class RollbackVNFVolumesTask implements Runnable {
343                 private final RollbackVolumeGroupRequest req;
344                 private RollbackVolumeGroupResponse response = null;
345                 private VolumeGroupExceptionResponse eresp = null;
346                 private boolean sendxml;
347
348                 public RollbackVNFVolumesTask(RollbackVolumeGroupRequest req) {
349                         this.req = req;
350                         this.sendxml = true; // can be set with a field or header later
351                 }
352                 public int getStatusCode() {
353                         return (response != null) ? HttpStatus.SC_OK : HttpStatus.SC_BAD_REQUEST;
354                 }
355                 public Object getGenericEntityResponse() {
356                         return (response != null)
357                                 ? new GenericEntity<RollbackVolumeGroupResponse>(response) {}
358                                 : new GenericEntity<VolumeGroupExceptionResponse>(eresp) {};
359                 }
360                 private String getResponse() {
361                         if (response != null) {
362                                 return sendxml ? response.toXmlString() : response.toJsonString();
363                         } else {
364                                 return sendxml ? eresp.toXmlString() : eresp.toJsonString();
365                         }
366                 }
367                 @Override
368                 public void run() {
369                         LOGGER.debug("DeleteVNFVolumesTask start");
370                         try {
371                                 VolumeGroupRollback vgr = req.getVolumeGroupRollback();
372                                 VnfRollback vrb = new VnfRollback(
373                                                 vgr.getVolumeGroupStackId(), vgr.getTenantId(), vgr.getCloudSiteId(), true, true,
374                                                 vgr.getMsoRequest(), null, null, null, null);
375                                 vnfAdapter.rollbackVnf(vrb);
376                                 response = new RollbackVolumeGroupResponse(true, req.getMessageId());
377                         } catch (VnfException e) {
378                                 eresp = new VolumeGroupExceptionResponse(e.getMessage(), MsoExceptionCategory.INTERNAL, true, req.getMessageId());
379                         }
380                         if (!req.isSynchronous()) {
381                                 // This is asynch, so POST response back to caller
382                                 BpelRestClient bpelClient = new BpelRestClient();
383                                 bpelClient.bpelPost(getResponse(), req.getNotificationUrl(), sendxml);
384                         }
385                         LOGGER.debug("DeleteVNFVolumesTask exit: code=" + getStatusCode() + ", resp="+ getResponse());
386                 }
387
388         }
389
390         @PUT
391         @Path("{aaiVolumeGroupId}")
392         @Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
393         @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
394         public Response updateVNFVolumes(
395                 @PathParam("aaiVolumeGroupId") String aaiVolumeGroupId,
396                 final UpdateVolumeGroupRequest req
397                 )
398         {
399                 LOGGER.debug("updateVNFVolumes enter: " + req.toJsonString());
400                 if (aaiVolumeGroupId == null || !aaiVolumeGroupId.equals(req.getVolumeGroupId())) {
401                         return Response
402                                 .status(HttpStatus.SC_BAD_REQUEST)
403                                 .type(MediaType.TEXT_PLAIN)
404                                 .entity("VolumeGroupId in URL does not match content")
405                                 .build();
406                 }
407                 UpdateVNFVolumesTask task = new UpdateVNFVolumesTask(req);
408                 if (req.isSynchronous()) {
409                         // This is a synchronous request
410                         task.run();
411                         return Response
412                                 .status(task.getStatusCode())
413                                 .entity(task.getGenericEntityResponse())
414                                 .build();
415                 } else {
416                         // This is an asynchronous request
417                 try {
418                         Thread t1 = new Thread(task);
419                         t1.start();
420                 } catch (Exception e) {
421                         // problem handling create, send generic failure as sync resp to caller
422                         LOGGER.error (MessageEnum.RA_UPDATE_VNF_ERR, "", "updateVNFVolumes", MsoLogger.ErrorCode.BusinessProcesssError, "Exception - updateVNFVolumes", e);
423                         return Response.serverError().build();
424                 }
425                 // send sync response (ACK) to caller
426                 LOGGER.debug ("updateVNFVolumes exit");
427                 return Response.status(HttpStatus.SC_ACCEPTED).build();
428                 }
429         }
430
431         public class UpdateVNFVolumesTask implements Runnable {
432                 private final UpdateVolumeGroupRequest req;
433                 private UpdateVolumeGroupResponse response = null;
434                 private VolumeGroupExceptionResponse eresp = null;
435                 private boolean sendxml;
436
437                 public UpdateVNFVolumesTask(UpdateVolumeGroupRequest req) {
438                         this.req = req;
439                         this.sendxml = true; // can be set with a field or header later
440                 }
441                 public int getStatusCode() {
442                         return (response != null) ? HttpStatus.SC_OK : HttpStatus.SC_BAD_REQUEST;
443                 }
444                 public Object getGenericEntityResponse() {
445                         return (response != null)
446                                 ? new GenericEntity<UpdateVolumeGroupResponse>(response) {}
447                                 : new GenericEntity<VolumeGroupExceptionResponse>(eresp) {};
448                 }
449                 private String getResponse() {
450                         if (response != null) {
451                                 return sendxml ? response.toXmlString() : response.toJsonString();
452                         } else {
453                                 return sendxml ? eresp.toXmlString() : eresp.toJsonString();
454                         }
455                 }
456                 @Override
457                 public void run() {
458                         LOGGER.debug("UpdateVNFVolumesTask start");
459                         try {
460                                 @SuppressWarnings("unused")
461                                 Holder<String> stackId = new Holder<String> ();
462                                 Holder<Map<String, String>> outputs = new Holder<Map <String, String>> ();
463                                 Holder<VnfRollback> vnfRollback = new Holder<VnfRollback> ();
464                                 String completeVnfVfModuleType = req.getVnfType() + "::" + req.getVfModuleType();
465                                 LOGGER.debug("in updateVfModuleVolume - completeVnfVfModuleType=" + completeVnfVfModuleType);
466
467                                 if (req.getCloudSiteId().equals(TESTING_KEYWORD)) {
468                                         outputs.value = testMap();
469                                 } else {
470                                         //vnfAdapter.updateVnf(
471                                         //              req.getCloudSiteId(),
472                                         //              req.getTenantId(),
473                                         //              req.getVnfType(),
474                                         //              req.getVnfVersion(),
475                                         //              req.getVfModuleType(),
476                                         //              "VOLUME",                       // request type is VOLUME
477                                         //              req.getVolumeGroupStackId(),
478                                         //              req.getVolumeGroupParams(),
479                                         //              req.getMsoRequest(),
480                                         //              outputs,
481                                         //              vnfRollback);
482                                         vnfAdapter.updateVfModule (req.getCloudSiteId(),
483                                                         req.getTenantId(),
484                                                         //req.getVnfType(),
485                                                         completeVnfVfModuleType,
486                                                         req.getVnfVersion(),
487                                                         req.getVolumeGroupStackId(),
488                                                         "VOLUME",
489                                                         null,
490                                                         null,
491                                                         req.getVolumeGroupStackId(),
492                                                         req.getModelCustomizationUuid(),
493                                                         req.getVolumeGroupParams(),
494                                                         req.getMsoRequest(),
495                                                         outputs,
496                                                         vnfRollback);
497                                 }
498                                 response = new UpdateVolumeGroupResponse(
499                                                 req.getVolumeGroupId(), req.getVolumeGroupStackId(),
500                                                 outputs.value, req.getMessageId());
501                         } catch (VnfException e) {
502                                 eresp = new VolumeGroupExceptionResponse(e.getMessage(), MsoExceptionCategory.INTERNAL, true, req.getMessageId());
503                         }
504                         if (!req.isSynchronous()) {
505                                 // This is asynch, so POST response back to caller
506                                 BpelRestClient bpelClient = new BpelRestClient();
507                                 bpelClient.bpelPost(getResponse(), req.getNotificationUrl(), sendxml);
508                         }
509                         LOGGER.debug("UpdateVNFVolumesTask exit: code=" + getStatusCode() + ", resp="+ getResponse());
510                 }
511         }
512
513         @GET
514         @Path("{aaiVolumeGroupId}")
515         @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
516         public Response queryVNFVolumes(
517                 @PathParam("aaiVolumeGroupId") String aaiVolumeGroupId,
518                 @QueryParam("cloudSiteId") String cloudSiteId,
519                 @QueryParam("tenantId") String tenantId,
520                 @QueryParam("volumeGroupStackId") String volumeGroupStackId,
521                 @QueryParam("skipAAI") Boolean skipAAI,
522                 @QueryParam("msoRequest.requestId") String requestId,
523                 @QueryParam("msoRequest.serviceInstanceId") String serviceInstanceId
524                 )
525         {
526         //This request responds synchronously only
527         LOGGER.debug ("queryVNFVolumes enter:" + aaiVolumeGroupId + " " + volumeGroupStackId);
528         MsoRequest msoRequest = new MsoRequest(requestId, serviceInstanceId);
529
530         try {
531                 int respStatus = HttpStatus.SC_OK;
532                 QueryVolumeGroupResponse qryResp = new QueryVolumeGroupResponse(aaiVolumeGroupId, volumeGroupStackId, null, null);
533                 Holder<Boolean> vnfExists = new Holder<Boolean>();
534                 Holder<String> vfModuleId = new Holder<String>();
535                 Holder<VnfStatus> status = new Holder<VnfStatus>();
536                 Holder<Map<String, String>> outputs = new Holder<Map<String, String>>();
537                         if (cloudSiteId != null && cloudSiteId.equals(TESTING_KEYWORD)) {
538                                 if (tenantId != null && tenantId.equals(TESTING_KEYWORD)) {
539                                         throw new VnfException("testing.");
540                                 }
541                                 vnfExists.value = true;
542                                 vfModuleId.value = TESTING_KEYWORD;
543                                 status.value = VnfStatus.ACTIVE;
544                                 outputs.value = testMap();
545                         } else {
546                                 vnfAdapter.queryVnf(cloudSiteId, tenantId, volumeGroupStackId, msoRequest, vnfExists, vfModuleId, status, outputs);
547                         }
548                 if (!vnfExists.value) {
549                         LOGGER.debug ("VNFVolumes not found");
550                         qryResp.setVolumeGroupStatus(status.value);
551                         respStatus = HttpStatus.SC_NOT_FOUND;
552                 } else {
553                         LOGGER.debug ("VNFVolumes found " + vfModuleId.value + ", status=" + status.value);
554                         qryResp.setVolumeGroupStatus(status.value);
555                         qryResp.setVolumeGroupOutputs(outputs.value);
556                 }
557                 LOGGER.debug("Query queryVNFVolumes exit");
558                 return Response
559                         .status(respStatus)
560                         .entity(new GenericEntity<QueryVolumeGroupResponse>(qryResp) {})
561                         .build();
562         } catch (VnfException e) {
563                 LOGGER.error(MessageEnum.RA_QUERY_VNF_ERR,  aaiVolumeGroupId, "", "queryVNFVolumes", MsoLogger.ErrorCode.BusinessProcesssError, "VnfException - queryVNFVolumes", e);
564                 VolumeGroupExceptionResponse excResp = new VolumeGroupExceptionResponse(e.getMessage(), MsoExceptionCategory.INTERNAL, Boolean.FALSE, null);
565                 LOGGER.debug("Query queryVNFVolumes exit");
566                 return Response
567                         .status(HttpStatus.SC_INTERNAL_SERVER_ERROR)
568                         .entity(new GenericEntity<VolumeGroupExceptionResponse>(excResp) {})
569                         .build();
570                 }
571         }
572     public static Map<String, String> testMap() {
573                 Map<String, String> m = new HashMap<String, String>();
574                 m.put("mickey", "7");
575                 m.put("clyde", "10");
576                 m.put("wayne", "99");
577                 return m;
578     }
579 }