@Test public void testParseStorageResponse() { Storage results; OpenStackParser parser = new OpenStackParser(); try { results = parser.parseStorageResponse(STORAGERESPONSE); assertEquals("This is yet, another volume.", results.getDescription()); assertEquals("5aa119a8-d25b-45a7-8d1b-88e127885635", results.getHref()); assertEquals("vol-003", results.getName()); assertEquals("1", results.getSize()); assertEquals(StorageType.DATABLOCK, results.getType()); results = parser.parseStorageResponse( STORAGEMALFORMEDRESPONSE); fail(); } catch (OCCIException e) { assertTrue(true); } }
public Storage parseStorageResponse (String response) throws OCCIException { String id, name, size; Storage ret = null; SAXBuilder builder = new SAXBuilder(); builder.setValidation(false); builder.setIgnoringElementContentWhitespace(true); Document xmldoc; log.info("[OpenStackParser] Parsing storage response..."); try { xmldoc = builder.build(new StringReader(response)); XPath xpath = XPath.newInstance(" xpath.addNamespace("ns", BLOCKNAMESPACE); xpath.addNamespace("atom", ATOMNAMESPACE); xpath.addNamespace("os-vol-host-attr", OSVOLHOSTATTRNAMESPACE); xpath.addNamespace("os-vol-image-meta", OSVOLIMAGEMETANAMESPACE); xpath.addNamespace("os-vol-tenant-attr", OSVOLTENANTATTRNAMESPACE); Element result = (Element)xpath.selectSingleNode(xmldoc); id = result.getAttributeValue("id"); name = result.getAttributeValue("name"); size = result.getAttributeValue("size"); if (id != null && name != null && size != null) { ret = new Storage(); ret.setDescription( result.getAttributeValue("description")); ret.setHref(id); ret.setName(name); ret.setSize(size); ret.setType(StorageType.DATABLOCK); } 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] Storage response parsed..."); return ret; }
OpenStackParser { public Storage parseStorageResponse (String response) throws OCCIException { String id, name, size; Storage ret = null; SAXBuilder builder = new SAXBuilder(); builder.setValidation(false); builder.setIgnoringElementContentWhitespace(true); Document xmldoc; log.info("[OpenStackParser] Parsing storage response..."); try { xmldoc = builder.build(new StringReader(response)); XPath xpath = XPath.newInstance(" xpath.addNamespace("ns", BLOCKNAMESPACE); xpath.addNamespace("atom", ATOMNAMESPACE); xpath.addNamespace("os-vol-host-attr", OSVOLHOSTATTRNAMESPACE); xpath.addNamespace("os-vol-image-meta", OSVOLIMAGEMETANAMESPACE); xpath.addNamespace("os-vol-tenant-attr", OSVOLTENANTATTRNAMESPACE); Element result = (Element)xpath.selectSingleNode(xmldoc); id = result.getAttributeValue("id"); name = result.getAttributeValue("name"); size = result.getAttributeValue("size"); if (id != null && name != null && size != null) { ret = new Storage(); ret.setDescription( result.getAttributeValue("description")); ret.setHref(id); ret.setName(name); ret.setSize(size); ret.setType(StorageType.DATABLOCK); } 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] Storage response parsed..."); return ret; } }
OpenStackParser { public Storage parseStorageResponse (String response) throws OCCIException { String id, name, size; Storage ret = null; SAXBuilder builder = new SAXBuilder(); builder.setValidation(false); builder.setIgnoringElementContentWhitespace(true); Document xmldoc; log.info("[OpenStackParser] Parsing storage response..."); try { xmldoc = builder.build(new StringReader(response)); XPath xpath = XPath.newInstance(" xpath.addNamespace("ns", BLOCKNAMESPACE); xpath.addNamespace("atom", ATOMNAMESPACE); xpath.addNamespace("os-vol-host-attr", OSVOLHOSTATTRNAMESPACE); xpath.addNamespace("os-vol-image-meta", OSVOLIMAGEMETANAMESPACE); xpath.addNamespace("os-vol-tenant-attr", OSVOLTENANTATTRNAMESPACE); Element result = (Element)xpath.selectSingleNode(xmldoc); id = result.getAttributeValue("id"); name = result.getAttributeValue("name"); size = result.getAttributeValue("size"); if (id != null && name != null && size != null) { ret = new Storage(); ret.setDescription( result.getAttributeValue("description")); ret.setHref(id); ret.setName(name); ret.setSize(size); ret.setType(StorageType.DATABLOCK); } 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] Storage response parsed..."); return ret; }  }
OpenStackParser { public Storage parseStorageResponse (String response) throws OCCIException { String id, name, size; Storage ret = null; SAXBuilder builder = new SAXBuilder(); builder.setValidation(false); builder.setIgnoringElementContentWhitespace(true); Document xmldoc; log.info("[OpenStackParser] Parsing storage response..."); try { xmldoc = builder.build(new StringReader(response)); XPath xpath = XPath.newInstance(" xpath.addNamespace("ns", BLOCKNAMESPACE); xpath.addNamespace("atom", ATOMNAMESPACE); xpath.addNamespace("os-vol-host-attr", OSVOLHOSTATTRNAMESPACE); xpath.addNamespace("os-vol-image-meta", OSVOLIMAGEMETANAMESPACE); xpath.addNamespace("os-vol-tenant-attr", OSVOLTENANTATTRNAMESPACE); Element result = (Element)xpath.selectSingleNode(xmldoc); id = result.getAttributeValue("id"); name = result.getAttributeValue("name"); size = result.getAttributeValue("size"); if (id != null && name != null && size != null) { ret = new Storage(); ret.setDescription( result.getAttributeValue("description")); ret.setHref(id); ret.setName(name); ret.setSize(size); ret.setType(StorageType.DATABLOCK); } 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] Storage 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 Storage parseStorageResponse (String response) throws OCCIException { String id, name, size; Storage ret = null; SAXBuilder builder = new SAXBuilder(); builder.setValidation(false); builder.setIgnoringElementContentWhitespace(true); Document xmldoc; log.info("[OpenStackParser] Parsing storage response..."); try { xmldoc = builder.build(new StringReader(response)); XPath xpath = XPath.newInstance(" xpath.addNamespace("ns", BLOCKNAMESPACE); xpath.addNamespace("atom", ATOMNAMESPACE); xpath.addNamespace("os-vol-host-attr", OSVOLHOSTATTRNAMESPACE); xpath.addNamespace("os-vol-image-meta", OSVOLIMAGEMETANAMESPACE); xpath.addNamespace("os-vol-tenant-attr", OSVOLTENANTATTRNAMESPACE); Element result = (Element)xpath.selectSingleNode(xmldoc); id = result.getAttributeValue("id"); name = result.getAttributeValue("name"); size = result.getAttributeValue("size"); if (id != null && name != null && size != null) { ret = new Storage(); ret.setDescription( result.getAttributeValue("description")); ret.setHref(id); ret.setName(name); ret.setSize(size); ret.setType(StorageType.DATABLOCK); } 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] Storage 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; }