@Test public void testParseImageCollectionResponse() { StorageCollection results; OpenStackParser parser = new OpenStackParser(); try { results = parser.parseImageCollectionResponse(IMAGECOLLECTIONRESPONSE); assertEquals(2, results.getStorage().size()); assertEquals("1bea47ed-f6a9-463b-b423-14b9cca9ad27", results.getStorage().get(0).getHref()); assertEquals("781b3762-9469-4cec-b58d-3349e5de4e9c", results.getStorage().get(1).getHref()); assertEquals("cirros-0.3.2-x86_64-disk", results.getStorage().get(0).getName()); assertEquals("F17-x86_64-cfntools", results.getStorage().get(1).getName()); results = parser.parseImageCollectionResponse( IMAGECOLLECTIONMALFORMEDRESPONSE); fail(); } catch (OCCIException e) { assertTrue(true); } }
public StorageCollection parseImageCollectionResponse (String response) throws OCCIException { StorageCollection ret = new StorageCollection(); Gson gson = new Gson(); Link link; log.info("[OpenStackParser] Parsing image collection response..."); ImageCollection col = gson.fromJson(response, ImageCollection.class); for (Image img : col.getImages()) { link = new Link(); link.setHref(img.getId().toString()); link.setName(img.getName()); if (img.getId() != null && img.getName() != null) { ret.getStorage().add(link); } else { OCCIException exception = new OCCIException(); exception.setMessage(MALFORMEDRESPONSE); log.error(MALFORMEDRESPONSE); throw exception; } } log.debug("[OpenStackParser] Image collection response parsed..."); return ret; }
OpenStackParser { public StorageCollection parseImageCollectionResponse (String response) throws OCCIException { StorageCollection ret = new StorageCollection(); Gson gson = new Gson(); Link link; log.info("[OpenStackParser] Parsing image collection response..."); ImageCollection col = gson.fromJson(response, ImageCollection.class); for (Image img : col.getImages()) { link = new Link(); link.setHref(img.getId().toString()); link.setName(img.getName()); if (img.getId() != null && img.getName() != null) { ret.getStorage().add(link); } else { OCCIException exception = new OCCIException(); exception.setMessage(MALFORMEDRESPONSE); log.error(MALFORMEDRESPONSE); throw exception; } } log.debug("[OpenStackParser] Image collection response parsed..."); return ret; } }
OpenStackParser { public StorageCollection parseImageCollectionResponse (String response) throws OCCIException { StorageCollection ret = new StorageCollection(); Gson gson = new Gson(); Link link; log.info("[OpenStackParser] Parsing image collection response..."); ImageCollection col = gson.fromJson(response, ImageCollection.class); for (Image img : col.getImages()) { link = new Link(); link.setHref(img.getId().toString()); link.setName(img.getName()); if (img.getId() != null && img.getName() != null) { ret.getStorage().add(link); } else { OCCIException exception = new OCCIException(); exception.setMessage(MALFORMEDRESPONSE); log.error(MALFORMEDRESPONSE); throw exception; } } log.debug("[OpenStackParser] Image collection response parsed..."); return ret; }  }
OpenStackParser { public StorageCollection parseImageCollectionResponse (String response) throws OCCIException { StorageCollection ret = new StorageCollection(); Gson gson = new Gson(); Link link; log.info("[OpenStackParser] Parsing image collection response..."); ImageCollection col = gson.fromJson(response, ImageCollection.class); for (Image img : col.getImages()) { link = new Link(); link.setHref(img.getId().toString()); link.setName(img.getName()); if (img.getId() != null && img.getName() != null) { ret.getStorage().add(link); } else { OCCIException exception = new OCCIException(); exception.setMessage(MALFORMEDRESPONSE); log.error(MALFORMEDRESPONSE); throw exception; } } log.debug("[OpenStackParser] Image collection response parsed..."); return ret; }  String[] parseAuthorizationResponse(String response); String[][] parseNetworkCollectionResponse(String response); String[] parseCreatedNetworkResponse(String response); NetworkCollection parseSubnetCollectionResponse(String response); Network parseSubnetResponse(String response); StorageCollection parseStorageCollectionResponse(String response); Storage parseStorageResponse(String response); StorageCollection parseImageCollectionResponse(String response); Storage parseImageResponse(String response); ComputeCollection parseComputeCollectionResponse(String response); Compute parseComputeResponse(String response); String parseComputeInstanceTypeId(
    		String response,
    		HashMap<String, InstanceType> instanceTypes); List<Disk> parseAttachedStoragesResponse(String response); List<Nic> parseVirtualInterfacesResponse(String response); InstanceTypeCollection parseInstanceTypeCollectionResponse(String response); InstanceType parseInstanceTypeResponse(String response); Quota parseComputeQuotaResponse(String response); int parseStorageQuotaResponse(String response); ComputeState fromOpenStackComputeState(String state); String toOpenStackComputeState(ComputeState state); }
OpenStackParser { public StorageCollection parseImageCollectionResponse (String response) throws OCCIException { StorageCollection ret = new StorageCollection(); Gson gson = new Gson(); Link link; log.info("[OpenStackParser] Parsing image collection response..."); ImageCollection col = gson.fromJson(response, ImageCollection.class); for (Image img : col.getImages()) { link = new Link(); link.setHref(img.getId().toString()); link.setName(img.getName()); if (img.getId() != null && img.getName() != null) { ret.getStorage().add(link); } else { OCCIException exception = new OCCIException(); exception.setMessage(MALFORMEDRESPONSE); log.error(MALFORMEDRESPONSE); throw exception; } } log.debug("[OpenStackParser] Image collection response parsed..."); return ret; }  String[] parseAuthorizationResponse(String response); String[][] parseNetworkCollectionResponse(String response); String[] parseCreatedNetworkResponse(String response); NetworkCollection parseSubnetCollectionResponse(String response); Network parseSubnetResponse(String response); StorageCollection parseStorageCollectionResponse(String response); Storage parseStorageResponse(String response); StorageCollection parseImageCollectionResponse(String response); Storage parseImageResponse(String response); ComputeCollection parseComputeCollectionResponse(String response); Compute parseComputeResponse(String response); String parseComputeInstanceTypeId(
    		String response,
    		HashMap<String, InstanceType> instanceTypes); List<Disk> parseAttachedStoragesResponse(String response); List<Nic> parseVirtualInterfacesResponse(String response); InstanceTypeCollection parseInstanceTypeCollectionResponse(String response); InstanceType parseInstanceTypeResponse(String response); Quota parseComputeQuotaResponse(String response); int parseStorageQuotaResponse(String response); ComputeState fromOpenStackComputeState(String state); String toOpenStackComputeState(ComputeState state); static final String KEYSTONENAMESPACE; static final String QUANTUMNAMESPACE; static final String PROVIDERNAMESPACE; static final String ROUTERNAMESPACE; static final String XSINAMESPACE; static final String VOLUMENAMESPACE; static final String ATOMNAMESPACE; static final String COMPUTENAMESPACE; static final String VIFNAMESPACE; static final String COMMONNAMESPACE; static final String BLOCKNAMESPACE; static final String OSVOLHOSTATTRNAMESPACE; static final String OSVOLIMAGEMETANAMESPACE; static final String OSVOLTENANTATTRNAMESPACE; }