@Test public void testParseCreatedNetworkResponse() { String[] results; OpenStackParser parser = new OpenStackParser(); try { results = parser.parseCreatedNetworkResponse(NETWORKRESPONSE); assertEquals(2, results.length); assertEquals("d32019d3-bc6e-4319-9c1d-6722fc136a22", results[0]); assertEquals("ACTIVE", results[1]); results = parser.parseCreatedNetworkResponse( NETWORKMALFORMEDRESPONSE); fail(); } catch (OCCIException e) { assertTrue(true); } }
public String[] parseCreatedNetworkResponse(String response) throws OCCIException { String[] ret = new String[2]; XPath xpath; SAXBuilder builder = new SAXBuilder(); builder.setValidation(false); builder.setIgnoringElementContentWhitespace(true); Document xmldoc; Element id, status; log.info("[OpenStackParser] Parsing created network response..."); try { xmldoc = builder.build(new StringReader(response)); xpath = XPath.newInstance(" xpath.addNamespace("ns", QUANTUMNAMESPACE); xpath.addNamespace("provider", PROVIDERNAMESPACE); xpath.addNamespace("quantum", QUANTUMNAMESPACE); xpath.addNamespace("router", ROUTERNAMESPACE); xpath.addNamespace("xsi", XSINAMESPACE); id = (Element)xpath.selectSingleNode(xmldoc); xpath = XPath.newInstance(" xpath.addNamespace("ns", QUANTUMNAMESPACE); xpath.addNamespace("provider", PROVIDERNAMESPACE); xpath.addNamespace("quantum", QUANTUMNAMESPACE); xpath.addNamespace("router", ROUTERNAMESPACE); xpath.addNamespace("xsi", XSINAMESPACE); status = (Element)xpath.selectSingleNode(xmldoc); if (id != null && status != null) { ret[0] = id.getValue(); ret[1] = status.getValue(); } 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] Created network response parsed..."); return ret; }
OpenStackParser { public String[] parseCreatedNetworkResponse(String response) throws OCCIException { String[] ret = new String[2]; XPath xpath; SAXBuilder builder = new SAXBuilder(); builder.setValidation(false); builder.setIgnoringElementContentWhitespace(true); Document xmldoc; Element id, status; log.info("[OpenStackParser] Parsing created network response..."); try { xmldoc = builder.build(new StringReader(response)); xpath = XPath.newInstance(" xpath.addNamespace("ns", QUANTUMNAMESPACE); xpath.addNamespace("provider", PROVIDERNAMESPACE); xpath.addNamespace("quantum", QUANTUMNAMESPACE); xpath.addNamespace("router", ROUTERNAMESPACE); xpath.addNamespace("xsi", XSINAMESPACE); id = (Element)xpath.selectSingleNode(xmldoc); xpath = XPath.newInstance(" xpath.addNamespace("ns", QUANTUMNAMESPACE); xpath.addNamespace("provider", PROVIDERNAMESPACE); xpath.addNamespace("quantum", QUANTUMNAMESPACE); xpath.addNamespace("router", ROUTERNAMESPACE); xpath.addNamespace("xsi", XSINAMESPACE); status = (Element)xpath.selectSingleNode(xmldoc); if (id != null && status != null) { ret[0] = id.getValue(); ret[1] = status.getValue(); } 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] Created network response parsed..."); return ret; } }
OpenStackParser { public String[] parseCreatedNetworkResponse(String response) throws OCCIException { String[] ret = new String[2]; XPath xpath; SAXBuilder builder = new SAXBuilder(); builder.setValidation(false); builder.setIgnoringElementContentWhitespace(true); Document xmldoc; Element id, status; log.info("[OpenStackParser] Parsing created network response..."); try { xmldoc = builder.build(new StringReader(response)); xpath = XPath.newInstance(" xpath.addNamespace("ns", QUANTUMNAMESPACE); xpath.addNamespace("provider", PROVIDERNAMESPACE); xpath.addNamespace("quantum", QUANTUMNAMESPACE); xpath.addNamespace("router", ROUTERNAMESPACE); xpath.addNamespace("xsi", XSINAMESPACE); id = (Element)xpath.selectSingleNode(xmldoc); xpath = XPath.newInstance(" xpath.addNamespace("ns", QUANTUMNAMESPACE); xpath.addNamespace("provider", PROVIDERNAMESPACE); xpath.addNamespace("quantum", QUANTUMNAMESPACE); xpath.addNamespace("router", ROUTERNAMESPACE); xpath.addNamespace("xsi", XSINAMESPACE); status = (Element)xpath.selectSingleNode(xmldoc); if (id != null && status != null) { ret[0] = id.getValue(); ret[1] = status.getValue(); } 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] Created network response parsed..."); return ret; }  }
OpenStackParser { public String[] parseCreatedNetworkResponse(String response) throws OCCIException { String[] ret = new String[2]; XPath xpath; SAXBuilder builder = new SAXBuilder(); builder.setValidation(false); builder.setIgnoringElementContentWhitespace(true); Document xmldoc; Element id, status; log.info("[OpenStackParser] Parsing created network response..."); try { xmldoc = builder.build(new StringReader(response)); xpath = XPath.newInstance(" xpath.addNamespace("ns", QUANTUMNAMESPACE); xpath.addNamespace("provider", PROVIDERNAMESPACE); xpath.addNamespace("quantum", QUANTUMNAMESPACE); xpath.addNamespace("router", ROUTERNAMESPACE); xpath.addNamespace("xsi", XSINAMESPACE); id = (Element)xpath.selectSingleNode(xmldoc); xpath = XPath.newInstance(" xpath.addNamespace("ns", QUANTUMNAMESPACE); xpath.addNamespace("provider", PROVIDERNAMESPACE); xpath.addNamespace("quantum", QUANTUMNAMESPACE); xpath.addNamespace("router", ROUTERNAMESPACE); xpath.addNamespace("xsi", XSINAMESPACE); status = (Element)xpath.selectSingleNode(xmldoc); if (id != null && status != null) { ret[0] = id.getValue(); ret[1] = status.getValue(); } 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] Created network 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 String[] parseCreatedNetworkResponse(String response) throws OCCIException { String[] ret = new String[2]; XPath xpath; SAXBuilder builder = new SAXBuilder(); builder.setValidation(false); builder.setIgnoringElementContentWhitespace(true); Document xmldoc; Element id, status; log.info("[OpenStackParser] Parsing created network response..."); try { xmldoc = builder.build(new StringReader(response)); xpath = XPath.newInstance(" xpath.addNamespace("ns", QUANTUMNAMESPACE); xpath.addNamespace("provider", PROVIDERNAMESPACE); xpath.addNamespace("quantum", QUANTUMNAMESPACE); xpath.addNamespace("router", ROUTERNAMESPACE); xpath.addNamespace("xsi", XSINAMESPACE); id = (Element)xpath.selectSingleNode(xmldoc); xpath = XPath.newInstance(" xpath.addNamespace("ns", QUANTUMNAMESPACE); xpath.addNamespace("provider", PROVIDERNAMESPACE); xpath.addNamespace("quantum", QUANTUMNAMESPACE); xpath.addNamespace("router", ROUTERNAMESPACE); xpath.addNamespace("xsi", XSINAMESPACE); status = (Element)xpath.selectSingleNode(xmldoc); if (id != null && status != null) { ret[0] = id.getValue(); ret[1] = status.getValue(); } 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] Created network 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; }