package com.continuuity.passport.http.server;

import com.continuuity.passport.core.meta.VPC;
import com.continuuity.passport.impl.DataManagementServiceImpl;
import com.google.gson.Gson;

import javax.ws.rs.GET;
import javax.ws.rs.HeaderParam;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.Response;
import java.util.List;

/**
 *
 */
@Path("passport/v1/vpc")
public class VPCHandler {

  @GET
  @Produces("application/json")
  public Response getVPC(@HeaderParam("X-Continuuity-ApiKey") String apiKey){
    try{
      List<VPC> vpcList = DataManagementServiceImpl.getInstance().getVPC(apiKey);
      Gson gson = new Gson();
      if (vpcList.isEmpty()) {
        return Response.ok("[]").build();
      }
      else {
        return Response.ok(gson.toJson(vpcList)).build();
      }
    }
    catch(Exception e){
      return Response.status(Response.Status.BAD_REQUEST)
        .entity(Utils.getJson("FAILED", "VPC get Failed", e))
        .build();
    }
  }

}

@@ -624,38 +624,8 @@
 y);%0A
-      Gson gson = new Gson();%0A
     
@@ -651,16 +651,16 @@
 ty()) %7B%0A
+
         
@@ -726,46 +726,412 @@
     
-return Response.ok(gson.toJson(vpcList
+StringBuilder returnJson = new StringBuilder();%0A        returnJson.append(%22%5B%22);%0A        boolean first = true;%0A        for(VPC vpc : vpcList) %7B%0A          if (first) %7B%0A            first= false;%0A          %7D%0A          else %7B%0A            returnJson.append(%22,%22);%0A          %7D%0A          returnJson.append(vpc.toString());%0A%0A        %7D%0A        returnJson.append(%22%5D%22);%0A        return Response.ok(returnJson.toString(
 )).b

Handle Vpc list