OpenStackParser { public String[] parseAuthorizationResponse (String response) { List result; HashMap<String, String> urls = new HashMap<String, String>(); String[] openStackServices = {"nova", "cinder", "neutron"}; String[] ret = new String[6]; SAXBuilder builder = new SAXBuilder(); builder.setValidation(false); builder.setIgnoringElementContentWhitespace(true); Document xmldoc; String url; log.info("[OpenStackParser] Parsing authorization response..."); try { xmldoc = builder.build(new StringReader(response)); XPath xpath = XPath.newInstance(" xpath.addNamespace("ns", KEYSTONENAMESPACE); ret[0] = ((Attribute)xpath.selectSingleNode(xmldoc)).getValue(); for (String service : openStackServices) { xpath = XPath.newInstance(" "\"]/ns:endpoint/@publicURL"); xpath.addNamespace("ns", KEYSTONENAMESPACE); result = xpath.selectNodes(xmldoc); for (Object obj : result) { Attribute attribute = (Attribute)obj; url = attribute.getValue(); if (url != null && !url.contains("/v3") && !url.contains("/v1")) { urls.put(service, url); } } } xmldoc = builder.build(new StringReader(response)); xpath = XPath.newInstance(" xpath.addNamespace("ns", KEYSTONENAMESPACE); ret[1] = ((Attribute)xpath.selectSingleNode(xmldoc)).getValue(); xmldoc = builder.build(new StringReader(response)); xpath = XPath.newInstance(" xpath.addNamespace("ns", KEYSTONENAMESPACE); ret[2] = ((Attribute)xpath.selectSingleNode(xmldoc)).getValue(); ret[3] = urls.get("nova"); ret[4] = urls.get("cinder"); ret[5] = urls.get("neutron"); } catch (JDOMException e) { log.error(e.getMessage()); } catch (IOException e) { log.error(e.getMessage()); } log.debug("[OpenStackParser] Authorization 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; }
@Test public void testParseAuthorizationResponse() { String[] results; OpenStackParser parser = new OpenStackParser(); results = parser.parseAuthorizationResponse(AUTHORIZATIONRESPONSE); assertEquals(6, results.length); assertEquals("aaaaa-bbbbb-ccccc-dddd", results[0]); assertEquals("demo", results[1]); assertEquals("9a6590b2ab024747bc2167c4e064d00d", results[2]); assertEquals( "http: results[3]); assertEquals( "http: results[4]); assertEquals("http: }