org.apache.axiom.om.OMNode Java Examples

The following examples show how to use org.apache.axiom.om.OMNode. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: OmLogger.java    From openxds with Apache License 2.0 6 votes vote down vote up
public OMElement add_name_value(OMElement parent, String name, OMElement value1, OMElement value2, OMElement value3) {
	OMElement ele = MetadataSupport.om_factory.createOMElement(name, null);
	OMNode val1 = value1;
	if (val1 == null)
		val1 = MetadataSupport.om_factory.createOMText("null");
	ele.addChild(val1);
	OMNode val2 = value2;
	if (val2 == null)
		val2 = MetadataSupport.om_factory.createOMText("null");
	ele.addChild(val2);
	OMNode val3 = value3;
	if (val3 == null)
		val3 = MetadataSupport.om_factory.createOMText("null");
	ele.addChild(val3);
	parent.addChild(ele);
	return ele;
}
 
Example #2
Source File: TestkitStructure.java    From openxds with Apache License 2.0 6 votes vote down vote up
List<String> getStepIds(File testplan) {
	ArrayList<String> ids = new ArrayList<String>();
	OMElement tplan;
	try {
		tplan = Util.parse_xml(testplan);
		AXIOMXPath xpathExpression = new AXIOMXPath ("//TestPlan/TestStep");
		List<OMNode> nodes = xpathExpression.selectNodes(tplan);

		for (int i=0; i<nodes.size(); i++) {
			OMElement testStep = (OMElement) nodes.get(i);
			ids.add(testStep.getAttributeValue(MetadataSupport.id_qname));
		}

	} catch (Exception e) {
		e.printStackTrace();
		System.err.println(ExceptionUtil.exception_details(e));
		System.exit(-1);
	}

	return ids;
}
 
Example #3
Source File: TenantWorkflowConfigHolder.java    From carbon-apimgt with Apache License 2.0 6 votes vote down vote up
private void loadProperties(OMElement executorElem, Object workflowClass) throws WorkflowException {

        for (Iterator it = executorElem.getChildrenWithName(PROP_Q); it.hasNext(); ) {
            OMElement propertyElem = (OMElement) it.next();
            OMAttribute attribute = propertyElem.getAttribute(ATT_NAME);
            if (attribute == null) {
                handleException("An Executor class property must specify the name attribute");
            } else {
                String propName = attribute.getAttributeValue();
                OMNode omElt = propertyElem.getFirstElement();
                if (omElt != null) {
                    setInstanceProperty(propName, omElt, workflowClass);
                } else if (propertyElem.getText() != null) {
                    String value = MiscellaneousUtil.resolve(propertyElem, secretResolver);
                    setInstanceProperty(propName, value, workflowClass);
                } else {
                    handleException("An Executor class property must specify " +
                            "name and text value, or a name and a child XML fragment");
                }
            }
        }
    }
 
Example #4
Source File: SwaggerUtils.java    From micro-integrator with Apache License 2.0 6 votes vote down vote up
/**
 * Util method to fetch a swagger resource from the registry.
 *
 * @param resourcePath registry path to the resource.
 * @return null if no resource found or the swagger as string.
 */
public static String fetchSwaggerFromRegistry(String resourcePath) {

    String defString = null;
    SynapseConfiguration synapseConfig =
            SynapseConfigUtils.getSynapseConfiguration(Constants.SUPER_TENANT_DOMAIN_NAME);
    Registry registry = synapseConfig.getRegistry();
    OMNode regContent = registry.lookup(resourcePath);

    if (regContent instanceof OMText) {
        defString = ((OMText) regContent).getText();
        byte[] decodedBytes = Base64.getDecoder().decode(defString);
        defString = new String(decodedBytes);
    }
    return defString;
}
 
Example #5
Source File: REQUESTHASHGenerator.java    From micro-integrator with Apache License 2.0 6 votes vote down vote up
/**
 * This is the implementation of the getDigest method and will implement the Extended DOMHASH algorithm based HTTP
 * request identifications. This will consider To address of the request, HTTP headers and XML Payload in generating
 * the digets. So, in effect this will uniquely identify the HTTP request with the same To address, Headers and
 * Payload.
 *
 * @param msgContext - MessageContext on which the XML node identifier will be generated
 * @return Object representing the DOMHASH value of the normalized XML node
 * @throws CachingException if there is an error in generating the digest key
 * @see org.wso2.caching.digest.DigestGenerator #getDigest(org.apache.axis2.context.MessageContext)
 */
public String getDigest(MessageContext msgContext) throws CachingException {
    OMNode body = msgContext.getEnvelope().getBody();
    String toAddress = null;
    if (msgContext.getTo() != null) {
        toAddress = msgContext.getTo().getAddress();
    }
    Map<String, String> headers = (Map) msgContext.getProperty(
            org.apache.axis2.context.MessageContext.TRANSPORT_HEADERS);
    if (body != null) {
        byte[] digest = null;
        if (toAddress != null) {
            digest = getDigest(body, toAddress, headers, MD5_DIGEST_ALGORITHM);
        } else {
            digest = getDigest(body, MD5_DIGEST_ALGORITHM);
        }
        return digest != null ? getStringRepresentation(digest) : null;
    } else {
        return null;
    }
}
 
Example #6
Source File: CloudControllerConfigParser.java    From attic-stratos with Apache License 2.0 6 votes vote down vote up
private static void extractIaasProviders(OMElement documentElement, List<OMNode> nodeList) {
    List<IaasProvider> iaasProviders = CloudControllerConfig.getInstance().getIaasProviders();

    if (iaasProviders == null) {
        CloudControllerConfig.getInstance().setIaasProviders((iaasProviders = new ArrayList<IaasProvider>()));
    }

    // this is a valid scenario. User can have 0..1 iaas provider elements
    // in cloud-controller xml.
    if (nodeList == null || nodeList.isEmpty()) {
        log.debug("No IaasProvider element found in " + FILE_NAME);
        return;
    }

    for (OMNode node : nodeList) {
        iaasProviders.add(IaasProviderConfigParser.getIaasProvider(FILE_NAME, documentElement, node, null));
    }
}
 
Example #7
Source File: HomeAttribute.java    From openxds with Apache License 2.0 6 votes vote down vote up
public void validate1(OMElement root) {
	String localname = root.getLocalName();
	
	if (isIdentifiable(localname)) {

		OMAttribute home_att = root.getAttribute(MetadataSupport.home_qname);

		if (home_att == null) {
			errs += "\nElement of type " + localname + " does not contain a home attribute";
		} else {
			String home1 = home_att.getAttributeValue();
			if (home1 == null) home1 = "";
			if ( !home1.equals(home))
				errs += "\nElement of type " + localname + " has home of [" + home1 + "] which does not match expected value of [" + home + "]"; 
		}
	}

	for (OMNode child=root.getFirstElement(); child != null; child=child.getNextOMSibling()) {
		OMElement child_e = (OMElement) child;
		validate1(child_e);
	}
}
 
Example #8
Source File: 103333429.java    From docs-apim with Apache License 2.0 6 votes vote down vote up
/**
    * This is the implementation of the getDigest method and will implement the Extended DOMHASH
    * algorithm based HTTP request identifications. This will consider To address of the request,
    * HTTP headers and XML Payload in generating the digets. So, in effect
    * this will uniquely identify the HTTP request with the same To address, Headers and Payload.
    * 
    * @param msgContext - MessageContext on which the XML node identifier will be generated
    * @return Object representing the DOMHASH value of the normalized XML node
    * @throws CachingException if there is an error in generating the digest key
    *
    * @see org.wso2.caching.digest.DigestGenerator
    *          #getDigest(org.apache.axis2.context.MessageContext) 
    */
   public String getDigest(MessageContext msgContext) throws CachingException {
	OMNode body = msgContext.getEnvelope().getBody();
	String toAddress = null;
	if (msgContext.getTo() != null) {
		toAddress = msgContext.getTo().getAddress();			
	}
	Map<String, String> headers = (Map) msgContext.getProperty(org.apache.axis2.context.MessageContext.TRANSPORT_HEADERS);
    if (body != null) {
    	byte[] digest = null;
    	if (toAddress != null) {
    		digest = getDigest(body, toAddress, headers, MD5_DIGEST_ALGORITHM);
    	} else {
    		digest = getDigest(body, MD5_DIGEST_ALGORITHM);
    	}
        return digest != null ? getStringRepresentation(digest) : null;
    } else {
    	return null;
    }
}
 
Example #9
Source File: Util.java    From openxds with Apache License 2.0 5 votes vote down vote up
public static String getAttributeValue(OMElement doc, String xpath) throws Exception {
	XPathEvaluator eval = new XPathEvaluator();
	List<OMNode> node_list = eval.evaluateXpath(xpath, doc, null);

	for (Iterator<?> it=node_list.iterator(); it.hasNext(); ) {
		OMAttribute attr = (OMAttribute) it.next();
		return attr.getAttributeValue();
	}
	throw new Exception("Path " + xpath + " not found");
}
 
Example #10
Source File: Util.java    From openxds with Apache License 2.0 5 votes vote down vote up
public static List<String> getAttributeValues(OMElement doc, String xpath) throws Exception {
	List<String> values = new ArrayList<String>();
	XPathEvaluator eval = new XPathEvaluator();
	List<OMNode> node_list = eval.evaluateXpath(xpath, doc, null);

	for (Iterator<?> it=node_list.iterator(); it.hasNext(); ) {
		OMAttribute attr = (OMAttribute) it.next();
		values.add(attr.getAttributeValue());
	}

	if (values.size() == 0)
		throw new Exception("No Values");

	return values;
}
 
Example #11
Source File: Util.java    From openxds with Apache License 2.0 5 votes vote down vote up
public static List<OMElement> getElements(OMElement doc, String xpath) throws Exception {
	XPathEvaluator eval = new XPathEvaluator();
	List<OMNode> node_list = eval.evaluateXpath(xpath, doc, null);
	List<OMElement> ele_list = new ArrayList<OMElement>();

	for (Iterator<?> it=node_list.iterator(); it.hasNext(); ) {
		OMNode node = (OMNode) it.next();
		if (! (node instanceof OMElement))
			continue;
		OMElement ele = (OMElement) node;
		ele_list.add(ele);
	}
	return ele_list;

}
 
Example #12
Source File: Util.java    From openxds with Apache License 2.0 5 votes vote down vote up
public static String getElementValue(OMElement doc, String xpath) throws Exception {
	XPathEvaluator eval = new XPathEvaluator();
	List<OMNode> node_list = eval.evaluateXpath(xpath, doc, null);

	for (Iterator<?> it=node_list.iterator(); it.hasNext(); ) {
		OMNode node = (OMNode) it.next();
		if (! (node instanceof OMElement))
			continue;
		OMElement ele = (OMElement) node;
		return ele.getText();
	}
	throw new Exception("Path " + xpath + " not found");
}
 
Example #13
Source File: HomeAttribute.java    From openxds with Apache License 2.0 5 votes vote down vote up
public void set(OMElement root) {
	String localname = root.getLocalName();

	if (isIdentifiable(localname)) 
		root.addAttribute("home", home, null);

	for (OMNode child=root.getFirstElement(); child != null; child=child.getNextOMSibling()) {
		if (child instanceof OMText) {
			continue;				
		}
		OMElement child_e = (OMElement) child;
		set(child_e);
	}
}
 
Example #14
Source File: ProvideAndRegisterDocumentSet.java    From openxds with Apache License 2.0 5 votes vote down vote up
static OMText getBinaryNode(OMElement document) {
	Iterator<OMNode> childrenIterator = document.getChildren();
	while (childrenIterator.hasNext())
	{
		OMNode container = childrenIterator.next();
		if (container instanceof OMText && StringUtils.isNotBlank(((OMText)container).getText()))
		{
			return (OMText)container;
		}
	}		
	return null;
}
 
Example #15
Source File: OmLogger.java    From openxds with Apache License 2.0 5 votes vote down vote up
public OMElement add_name_value(OMElement parent, String name, OMElement value1, OMElement value2) {
	OMElement ele = MetadataSupport.om_factory.createOMElement(name, null);
	OMNode val1 = value1;
	if (val1 == null)
		val1 = MetadataSupport.om_factory.createOMText("null");
	ele.addChild(val1);
	OMNode val2 = value2;
	if (val2 == null)
		val2 = MetadataSupport.om_factory.createOMText("null");
	ele.addChild(val2);
	parent.addChild(ele);
	return ele;
}
 
Example #16
Source File: OmLogger.java    From openxds with Apache License 2.0 5 votes vote down vote up
public OMElement create_name_value(String name, OMElement value) {
	OMNode val = value;
	OMElement ele = MetadataSupport.om_factory.createOMElement(name, null);
	if (val == null)
		val = MetadataSupport.om_factory.createOMText("null");
	ele.addChild(val);
	return ele;
}
 
Example #17
Source File: UtilsTestCase.java    From carbon-apimgt with Apache License 2.0 5 votes vote down vote up
@Test
    public void testSetSOAPFault() {
        SOAPEnvelope soapEnvelope = Mockito.mock(SOAPEnvelope.class);
        SOAPHeader soapHeader = Mockito.mock(SOAPHeader.class);
        Iterator iterator = Mockito.mock(Iterator.class);
        OMNode soapHeaderBlock = Mockito.mock(OMNode.class);
        Mockito.when(messageContext.getMessageID()).thenReturn("123");
        Mockito.when(messageContext.getEnvelope()).thenReturn(soapEnvelope);
        Mockito.when(soapEnvelope.getHeader()).thenReturn(soapHeader);
        Mockito.when(soapHeader.examineAllHeaderBlocks()).thenReturn(iterator);
        Mockito.when(iterator.hasNext()).thenReturn(true, false);
//        Mockito.when(iterator.next()).thenReturn(omelement);
        Mockito.when(iterator.next()).thenReturn(soapHeaderBlock);
        Utils.setSOAPFault(messageContext, "", "code", "detail");
        Assert.assertTrue(true);  // No error has occurred. hence test passes.
        
        //when messageContext.isSOAP11() is true
        Mockito.when(messageContext.isSOAP11()).thenReturn(true);
        Utils.setSOAPFault(messageContext, "", "code", "detail");
        Assert.assertTrue(true);  // No error has occurred. hence test passes.

        // when messageContext.getFaultTo() != null
        EndpointReference endpointReference = Mockito.mock(EndpointReference.class);
        Mockito.when(messageContext.getFaultTo()).thenReturn(endpointReference);
        Utils.setSOAPFault(messageContext, "", "code", "detail");
        Assert.assertTrue(true);  // No error has occurred. hence test passes.

        // when messageContext.getFaultTo() != null
        Mockito.when(messageContext.getFaultTo()).thenReturn(endpointReference);
        Utils.setSOAPFault(messageContext, "", "code", "detail");
        Assert.assertTrue(true);  // No error has occurred. hence test passes.

    }
 
Example #18
Source File: TestMicroIntegratorRegistry.java    From micro-integrator with Apache License 2.0 5 votes vote down vote up
@Test
public void testRegistryResourceRead() throws IOException {

    OMNode omNode = microIntegratorRegistry.lookup("gov:/custom/checkJsScript.js");
    String mediaType = ((DataHandler) ((OMTextImpl) omNode).getDataHandler()).getContentType();
    Assert.assertEquals("Media type should be as expected", "application/javascript", mediaType);
}
 
Example #19
Source File: MicroIntegratorRegistry.java    From micro-integrator with Apache License 2.0 5 votes vote down vote up
/**
 * Function to retrieve resource content as text
 *
 * @param url
 * @return
 * @throws IOException
 */
private OMNode readNonXML (URL url) throws IOException {

    URLConnection urlConnection = url.openConnection();
    urlConnection.connect();

    try (InputStream inputStream = urlConnection.getInputStream()) {

        if (inputStream == null) {
            return null;
        }

        String mediaType = DEFAULT_MEDIA_TYPE;
        Properties metadata = getMetadata(url.getPath());
        if (metadata != null) {
            mediaType = metadata.getProperty(METADATA_KEY_MEDIA_TYPE, DEFAULT_MEDIA_TYPE);
        }

        if (DEFAULT_MEDIA_TYPE.equals(mediaType)) {
            StringBuilder strBuilder = new StringBuilder();
            try (BufferedReader bReader = new BufferedReader(new InputStreamReader(inputStream))) {
                String line;
                while ((line = bReader.readLine()) != null) {
                    strBuilder.append(line);
                }
            }
            return OMAbstractFactory.getOMFactory().createOMText(strBuilder.toString());
        } else {
            return OMAbstractFactory.getOMFactory()
                    .createOMText(new DataHandler(new SynapseBinaryDataSource(inputStream, mediaType)), true);
        }
    }
}
 
Example #20
Source File: EntitlementMediator.java    From micro-integrator with Apache License 2.0 5 votes vote down vote up
/**
 * Create a new SOAP envelope and insert the
 * the given omElement into its body.
 *
 * @param synCtx - original message context
 * @return newCtx created by the iteration
 * @throws AxisFault      if there is a message creation failure
 * @throws JaxenException if the expression evauation failure
 */
private MessageContext getOMElementInserted(OMElement omElement, MessageContext synCtx)
        throws AxisFault, JaxenException {

    Iterator<OMNode> children = synCtx.getEnvelope().getBody().getChildren();
    while (children.hasNext()) {
        children.next().detach();
    }
    synCtx.getEnvelope().getBody().addChild(omElement);
    return synCtx;
}
 
Example #21
Source File: REQUESTHASHGenerator.java    From micro-integrator with Apache License 2.0 5 votes vote down vote up
/**
 * This is an overloaded method for the digest generation for OMNode and request.
 *
 * @param node            - OMNode to be subjected to the key generation
 * @param toAddress       - Request To address to be subjected to the key generation
 * @param headers         - Header parameters to be subjected to the key generation
 * @param digestAlgorithm - digest algorithm as a String
 * @return byte[] representing the calculated digest over the provided node
 * @throws CachingException if there is an error in generating the digest
 */
public byte[] getDigest(OMNode node, String toAddress, Map<String, String> headers,
                        String digestAlgorithm) throws CachingException {

    if (node.getType() == OMNode.ELEMENT_NODE) {
        return getDigest((OMElement) node, toAddress, headers, digestAlgorithm);
    } else if (node.getType() == OMNode.TEXT_NODE) {
        return getDigest((OMText) node, digestAlgorithm);
    } else if (node.getType() == OMNode.PI_NODE) {
        return getDigest((OMProcessingInstruction) node, digestAlgorithm);
    } else {
        return new byte[0];
    }
}
 
Example #22
Source File: DOMHASHGenerator.java    From micro-integrator with Apache License 2.0 5 votes vote down vote up
/**
 * Gets the valid element collection of an OMDocument. This returns only the OMElement and OMProcessingInstruction
 * nodes
 *
 * @param document - OMDocument of which the valid elements to be retrieved
 * @return the collection of OMProcessingInstructions and OMElements in the provided document
 */
public Collection getValidElements(OMDocument document) {

    ArrayList list = new ArrayList();
    Iterator itr = document.getChildren();
    while (itr.hasNext()) {
        OMNode node = (OMNode) itr.next();
        if (node.getType() == OMNode.ELEMENT_NODE || node.getType() == OMNode.PI_NODE) {
            list.add(node);
        }
    }

    return list;
}
 
Example #23
Source File: DOMHASHGenerator.java    From micro-integrator with Apache License 2.0 5 votes vote down vote up
/**
 * This is an overloaded method for the digest generation for OMNode.
 *
 * @param node            - OMNode to be subjected to the key generation
 * @param digestAlgorithm - digest algorithm as a String
 * @return byte[] representing the calculated digest over the provided node
 * @throws CachingException if there is an error in generating the digest
 */
public byte[] getDigest(OMNode node, String digestAlgorithm) throws CachingException {

    if (node.getType() == OMNode.ELEMENT_NODE) {
        return getDigest((OMElement) node, digestAlgorithm);
    } else if (node.getType() == OMNode.TEXT_NODE) {
        return getDigest((OMText) node, digestAlgorithm);
    } else if (node.getType() == OMNode.PI_NODE) {
        return getDigest((OMProcessingInstruction) node, digestAlgorithm);
    } else {
        return new byte[0];
    }
}
 
Example #24
Source File: HttpRequestHashGenerator.java    From micro-integrator with Apache License 2.0 5 votes vote down vote up
/**
 * This is an overloaded method for the digest generation for OMNode and request.
 *
 * @param node            - OMNode to be subjected to the key generation
 * @param toAddress       - Request To address to be subjected to the key generation
 * @param headers         - Header parameters to be subjected to the key generation
 * @param digestAlgorithm - digest algorithm as a String
 * @return byte[] representing the calculated digest over the provided node
 * @throws CachingException if there is an error in generating the digest
 */
public byte[] getDigest(OMNode node, String toAddress, Map<String, String> headers,
                        String digestAlgorithm) throws CachingException {

    if (node.getType() == OMNode.ELEMENT_NODE) {
        return getDigest((OMElement) node, toAddress, headers, digestAlgorithm);
    } else if (node.getType() == OMNode.TEXT_NODE) {
        return getDigest((OMText) node, digestAlgorithm);
    } else if (node.getType() == OMNode.PI_NODE) {
        return getDigest((OMProcessingInstruction) node, digestAlgorithm);
    } else {
        return new byte[0];
    }
}
 
Example #25
Source File: HttpRequestHashGenerator.java    From micro-integrator with Apache License 2.0 5 votes vote down vote up
/**
 * This is an overloaded method for the digest generation for OMNode.
 *
 * @param node            - OMNode to be subjected to the key generation
 * @param digestAlgorithm - digest algorithm as a String
 * @return byte[] c node
 * @throws CachingException if there is an error in generating the digest
 */
public byte[] getDigest(OMNode node, String digestAlgorithm) throws CachingException {

    if (node.getType() == OMNode.ELEMENT_NODE) {
        return getDigest(node, digestAlgorithm);
    } else if (node.getType() == OMNode.TEXT_NODE) {
        return getDigest((OMText) node, digestAlgorithm);
    } else if (node.getType() == OMNode.PI_NODE) {
        return getDigest((OMProcessingInstruction) node, digestAlgorithm);
    } else {
        return new byte[0];
    }
}
 
Example #26
Source File: 103333429.java    From docs-apim with Apache License 2.0 5 votes vote down vote up
/**
    * This is an overloaded method for the digest generation for OMNode and request
    *
    * @param node              - OMNode to be subjected to the key generation
    * @param toAddress         - Request To address to be subjected to the key generation
    * @param headers           - Header parameters to be subjected to the key generation
    * @param digestAlgorithm   - digest algorithm as a String
    * @return byte[] representing the calculated digest over the provided node
    * @throws CachingException if there is an error in generating the digest
    */
public byte[] getDigest(OMNode node, String toAddress, Map<String, String> headers, 
		String digestAlgorithm) throws CachingException {

       if (node.getType() == OMNode.ELEMENT_NODE) {
           return getDigest((OMElement) node, toAddress, headers, digestAlgorithm);
       } else if (node.getType() == OMNode.TEXT_NODE) {
           return getDigest((OMText) node, digestAlgorithm);
       } else if (node.getType() == OMNode.PI_NODE) {
           return getDigest((OMProcessingInstruction) node, digestAlgorithm);
       } else {
           return new byte[0];
       }
   }
 
Example #27
Source File: IaasProviderConfigParser.java    From attic-stratos with Apache License 2.0 4 votes vote down vote up
public static IaasProvider getIaasProvider(final String fileName, final OMElement elt, final OMNode item, List<IaasProvider> iaases) {

        IaasProvider iaas = null;

        if (item.getType() == OMNode.ELEMENT_NODE) {

            OMElement iaasElt = (OMElement) item;

            if (iaases != null) {
                // check whether this is a reference to a predefined IaaS.
                for (IaasProvider iaasProvider : iaases) {
                    if (iaasProvider.getType()
                            .equals(iaasElt.getAttribute(new QName(
                                    CloudControllerConstants.TYPE_ATTR))
                                    .getAttributeValue())) {
                        iaas = new IaasProvider(iaasProvider);
                        break;
                    }
                }
            }

            if (iaas == null) {
                iaas = new IaasProvider();
            }

            if (iaas.getType() == null) {
                iaas.setType(iaasElt.getAttribute(new QName(CloudControllerConstants.TYPE_ATTR))
                        .getAttributeValue());
            }

            if ("".equals(iaas.getType())) {
                String msg =
                        "'" + CloudControllerConstants.IAAS_PROVIDER_ELEMENT + "' element's '" +
                                CloudControllerConstants.TYPE_ATTR +
                                "' attribute should be specified!";

                handleException(msg);

            }

            // this is not mandatory
            String name =
                    (iaasElt.getAttribute(new QName(CloudControllerConstants.NAME_ATTR)) == null)
                            ? iaas.getName()
                            : iaasElt.getAttributeValue(new QName(
                            CloudControllerConstants.NAME_ATTR));

            iaas.setName(name);

            String xpath = CloudControllerConstants.IAAS_PROVIDER_ELEMENT_XPATH;

            // load other elements
            loadClassName(fileName, iaas, iaasElt);
            loadProvider(fileName, iaas, iaasElt);
            loadProperties(fileName, iaasElt, iaas.getProperties());
            loadTemplate(fileName, iaas, iaasElt);
            loadIdentity(fileName, elt, iaas, iaasElt);
            loadCredentials(fileName, elt, iaas, iaasElt, xpath);
        }

        return iaas;
    }
 
Example #28
Source File: AxiomXpathParserTest.java    From attic-stratos with Apache License 2.0 4 votes vote down vote up
public void testGetMatchingNodes() {
    List<OMNode> list = AxiomXpathParserUtil.getMatchingNodes("/cloudController/iaasProviders/iaasProvider/provider", docElt);
    assertEquals(1, list.size());
    assertEquals(1, CloudControllerConfig.getInstance().getIaasProviders().size());
}
 
Example #29
Source File: SoapTransportCommandProcessor.java    From cougar with Apache License 2.0 4 votes vote down vote up
public WorkAroundOMChildrenNamespaceIterator(OMNode currentChild, String uri) {
    super(currentChild, uri);
}
 
Example #30
Source File: CheckAggregateContentTestCase.java    From product-ei with Apache License 2.0 4 votes vote down vote up
@Test(groups = {"wso2.esb"}, description = "Check the content of the aggregation specified by an xpath")
public void test() throws IOException, XMLStreamException {


    String Response = aggregatedRequestClient.getResponse();
    Assert.assertNotNull(Response);
    OMElement Response2 = AXIOMUtil.stringToOM(Response);


    OMElement responseParts = Response2.getFirstElement().getFirstElement();
    String singleResponse = responseParts.toString();

    Assert.assertTrue(singleResponse.contains("return"), "return child message does not exist in the aggregated response");
    Assert.assertTrue(singleResponse.contains("change"), "change child message does not exist in the aggregated response");
    Assert.assertTrue(singleResponse.contains("earnings"), "earnings child message does not exist in the aggregated response");
    Assert.assertTrue(singleResponse.contains("high"), "high child message does not exist in the aggregated response");
    Assert.assertTrue(singleResponse.contains("last"), "last child message does not exist in the aggregated response");
    Assert.assertTrue(singleResponse.contains("lastTradeTimestamp"), "lastTradeTimestamp child message does not exist in the aggregated response");
    Assert.assertTrue(singleResponse.contains("low"), "low child message does not exist in the aggregated response");
    Assert.assertTrue(singleResponse.contains("marketCap"), "marketCap child message does not exist in the aggregated response");
    Assert.assertTrue(singleResponse.contains("open"), "open child message does not exist in the aggregated response");
    Assert.assertTrue(singleResponse.contains("name"), "name child message does not exist in the aggregated response");
    Assert.assertTrue(singleResponse.contains("open"), "open child message does not exist in the aggregated response");
    Assert.assertTrue(singleResponse.contains("peRatio"), "PerRatio child message does not exist in the aggregated response");
    Assert.assertTrue(singleResponse.contains("percentageChange"), "PercentageChange child message does not exist in the aggregated response");
    Assert.assertTrue(singleResponse.contains("symbol"), "symbol child message does not exist in the aggregated response");
    Assert.assertTrue(singleResponse.contains("volume"), "volume child message does not exist in the aggregated response");
    Assert.assertTrue(singleResponse.contains("getQuoteResponse"), "getQuoteResponse child message does not exist in the aggregated response");


    OMNode content = responseParts.getNextOMSibling();

    for (int count = 0; count < no_of_requests - 1; count++) {

        Assert.assertNotNull(content);
        singleResponse = content.toString();
        Assert.assertTrue(singleResponse.contains("return"), "return child message does not exist in the aggregated response");
        Assert.assertTrue(singleResponse.contains("change"), "change child message does not exist in the aggregated response");
        Assert.assertTrue(singleResponse.contains("earnings"), "earinings child message does not exist in the aggregated response");
        Assert.assertTrue(singleResponse.contains("high"), "high child message does not exist in the aggregated response");
        Assert.assertTrue(singleResponse.contains("last"), "last child message does not exist in the aggregated response");
        Assert.assertTrue(singleResponse.contains("lastTradeTimestamp"), "lastTradeTimestamp child message does not exist in the aggregated response");
        Assert.assertTrue(singleResponse.contains("low"), "low child message does not exist in the aggregated response");
        Assert.assertTrue(singleResponse.contains("marketCap"), "marketCap child message does not exist in the aggregated response");
        Assert.assertTrue(singleResponse.contains("open"), "open child message does not exist in the aggregated response");
        Assert.assertTrue(singleResponse.contains("name"), "name child message does not exist in the aggregated response");
        Assert.assertTrue(singleResponse.contains("open"), "open child message does not exist in the aggregated response");
        Assert.assertTrue(singleResponse.contains("peRatio"), "PerRatio child message does not exist in the aggregated response");
        Assert.assertTrue(singleResponse.contains("percentageChange"), "PercentageChange child message does not exist in the aggregated response");
        Assert.assertTrue(singleResponse.contains("symbol"), "symbol child message does not exist in the aggregated response");
        Assert.assertTrue(singleResponse.contains("volume"), "volume child message does not exist in the aggregated response");
        Assert.assertTrue(singleResponse.contains("getQuoteResponse"), "getQuoteResponse child message does not exist in the aggregated response");
        content = content.getNextOMSibling();

    }


}