@Test public void testParseAttachedStoragesResponse() { List<Compute.Disk> results; OpenStackParser parser = new OpenStackParser(); try { results = parser.parseAttachedStoragesResponse(VOLUMEATTACHMENTRESPONSE); assertEquals(2, results.size()); assertEquals("a26887c6-c47b-4654-abb5-dfadf7d3f803", results.get(0).getStorage().getHref()); assertEquals("a26887c6-c47b-4654-abb5-dfadf7d3f804", results.get(1).getStorage().getHref()); assertEquals("/dev/sdd", results.get(0).getTarget()); assertEquals("/dev/sdc", results.get(1).getTarget()); results = parser.parseAttachedStoragesResponse( VOLUMEATTACHMENTMALFORMEDRESPONSE); fail(); } catch (OCCIException e) { assertTrue(true); } }
public List<Disk> parseAttachedStoragesResponse (String response) throws OCCIException { List<Disk> ret = null; Disk disk; Link link; SAXBuilder builder = new SAXBuilder(); builder.setValidation(false); builder.setIgnoringElementContentWhitespace(true); Document xmldoc; log.info("[OpenStackParser] Parsing attached storages response..."); try { xmldoc = builder.build(new StringReader(response)); XPath xpath = XPath.newInstance(" List volumeIdList = xpath.selectNodes(xmldoc); xpath = XPath.newInstance(" List deviceList = xpath.selectNodes(xmldoc); if (volumeIdList.size() == deviceList.size()) { ret = new ArrayList<Disk>(); for (int i = 0 ; i < volumeIdList.size() ; i++) { disk = new Disk(); link = new Link(); link.setHref(((Attribute)volumeIdList.get(i)).getValue()); disk.setStorage(link); disk.setTarget(((Attribute)deviceList.get(i)).getValue()); ret.add(disk); } } else { OCCIException exception = new OCCIException(); exception.setMessage(MALFORMEDRESPONSE); log.error(MALFORMEDRESPONSE); throw exception; } } catch (JDOMException e) { log.error(e.getMessage()); } catch (IOException e) { log.error(e.getMessage()); } log.debug("[OpenStackParser] Attached storages response parsed..."); return ret; }
OpenStackParser { public List<Disk> parseAttachedStoragesResponse (String response) throws OCCIException { List<Disk> ret = null; Disk disk; Link link; SAXBuilder builder = new SAXBuilder(); builder.setValidation(false); builder.setIgnoringElementContentWhitespace(true); Document xmldoc; log.info("[OpenStackParser] Parsing attached storages response..."); try { xmldoc = builder.build(new StringReader(response)); XPath xpath = XPath.newInstance(" List volumeIdList = xpath.selectNodes(xmldoc); xpath = XPath.newInstance(" List deviceList = xpath.selectNodes(xmldoc); if (volumeIdList.size() == deviceList.size()) { ret = new ArrayList<Disk>(); for (int i = 0 ; i < volumeIdList.size() ; i++) { disk = new Disk(); link = new Link(); link.setHref(((Attribute)volumeIdList.get(i)).getValue()); disk.setStorage(link); disk.setTarget(((Attribute)deviceList.get(i)).getValue()); ret.add(disk); } } else { OCCIException exception = new OCCIException(); exception.setMessage(MALFORMEDRESPONSE); log.error(MALFORMEDRESPONSE); throw exception; } } catch (JDOMException e) { log.error(e.getMessage()); } catch (IOException e) { log.error(e.getMessage()); } log.debug("[OpenStackParser] Attached storages response parsed..."); return ret; } }
OpenStackParser { public List<Disk> parseAttachedStoragesResponse (String response) throws OCCIException { List<Disk> ret = null; Disk disk; Link link; SAXBuilder builder = new SAXBuilder(); builder.setValidation(false); builder.setIgnoringElementContentWhitespace(true); Document xmldoc; log.info("[OpenStackParser] Parsing attached storages response..."); try { xmldoc = builder.build(new StringReader(response)); XPath xpath = XPath.newInstance(" List volumeIdList = xpath.selectNodes(xmldoc); xpath = XPath.newInstance(" List deviceList = xpath.selectNodes(xmldoc); if (volumeIdList.size() == deviceList.size()) { ret = new ArrayList<Disk>(); for (int i = 0 ; i < volumeIdList.size() ; i++) { disk = new Disk(); link = new Link(); link.setHref(((Attribute)volumeIdList.get(i)).getValue()); disk.setStorage(link); disk.setTarget(((Attribute)deviceList.get(i)).getValue()); ret.add(disk); } } else { OCCIException exception = new OCCIException(); exception.setMessage(MALFORMEDRESPONSE); log.error(MALFORMEDRESPONSE); throw exception; } } catch (JDOMException e) { log.error(e.getMessage()); } catch (IOException e) { log.error(e.getMessage()); } log.debug("[OpenStackParser] Attached storages response parsed..."); return ret; }  }
OpenStackParser { public List<Disk> parseAttachedStoragesResponse (String response) throws OCCIException { List<Disk> ret = null; Disk disk; Link link; SAXBuilder builder = new SAXBuilder(); builder.setValidation(false); builder.setIgnoringElementContentWhitespace(true); Document xmldoc; log.info("[OpenStackParser] Parsing attached storages response..."); try { xmldoc = builder.build(new StringReader(response)); XPath xpath = XPath.newInstance(" List volumeIdList = xpath.selectNodes(xmldoc); xpath = XPath.newInstance(" List deviceList = xpath.selectNodes(xmldoc); if (volumeIdList.size() == deviceList.size()) { ret = new ArrayList<Disk>(); for (int i = 0 ; i < volumeIdList.size() ; i++) { disk = new Disk(); link = new Link(); link.setHref(((Attribute)volumeIdList.get(i)).getValue()); disk.setStorage(link); disk.setTarget(((Attribute)deviceList.get(i)).getValue()); ret.add(disk); } } else { OCCIException exception = new OCCIException(); exception.setMessage(MALFORMEDRESPONSE); log.error(MALFORMEDRESPONSE); throw exception; } } catch (JDOMException e) { log.error(e.getMessage()); } catch (IOException e) { log.error(e.getMessage()); } log.debug("[OpenStackParser] Attached storages 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 List<Disk> parseAttachedStoragesResponse (String response) throws OCCIException { List<Disk> ret = null; Disk disk; Link link; SAXBuilder builder = new SAXBuilder(); builder.setValidation(false); builder.setIgnoringElementContentWhitespace(true); Document xmldoc; log.info("[OpenStackParser] Parsing attached storages response..."); try { xmldoc = builder.build(new StringReader(response)); XPath xpath = XPath.newInstance(" List volumeIdList = xpath.selectNodes(xmldoc); xpath = XPath.newInstance(" List deviceList = xpath.selectNodes(xmldoc); if (volumeIdList.size() == deviceList.size()) { ret = new ArrayList<Disk>(); for (int i = 0 ; i < volumeIdList.size() ; i++) { disk = new Disk(); link = new Link(); link.setHref(((Attribute)volumeIdList.get(i)).getValue()); disk.setStorage(link); disk.setTarget(((Attribute)deviceList.get(i)).getValue()); ret.add(disk); } } else { OCCIException exception = new OCCIException(); exception.setMessage(MALFORMEDRESPONSE); log.error(MALFORMEDRESPONSE); throw exception; } } catch (JDOMException e) { log.error(e.getMessage()); } catch (IOException e) { log.error(e.getMessage()); } log.debug("[OpenStackParser] Attached storages 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; }