Java Code Examples for org.apache.axiom.om.OMElement#getChildElements()

The following examples show how to use org.apache.axiom.om.OMElement#getChildElements() . 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: EbXML21QuerySupport.java    From openxds with Apache License 2.0 6 votes vote down vote up
public List<String> getIdsFromAdhocQueryResponse(OMElement rr) {
	List<String> ids = new ArrayList<String>();
	
	OMElement rol = MetadataSupport.firstChildWithLocalName(rr, "RegistryObjectList") ;
	if (rol == null)
		return ids;
	
	for (Iterator<OMElement> it=rol.getChildElements(); it.hasNext();) {
		OMElement ele = (OMElement) it.next();
		if (sqs.return_leaf_class && ele.getLocalName().equals("ObjectRef"))
			continue;
		ids.add(ele.getAttributeValue(MetadataSupport.id_qname));			
	}
	
	return ids;
}
 
Example 2
Source File: Validator.java    From openxds with Apache License 2.0 6 votes vote down vote up
void validate_internal_classifications(OMElement e) throws MetadataValidationException, MetadataException {
	String e_id = e.getAttributeValue(MetadataSupport.id_qname);
	if (e_id == null || e_id.equals(""))
		return;
	for (Iterator it=e.getChildElements(); it.hasNext(); ) {
		OMElement child = (OMElement) it.next();
		OMAttribute classified_object_att = child.getAttribute(MetadataSupport.classified_object_qname);
		if (classified_object_att != null) {
			String value = classified_object_att.getAttributeValue();
			if ( !e_id.equals(value)) {
				throw new MetadataValidationException("Classification " + m.getIdentifyingString(child) + 
						"\n   is nested inside " + m.getIdentifyingString(e) +
						"\n   but classifies object " + m.getIdentifyingString(value));
			}
		}
	}
}
 
Example 3
Source File: CompositeReportMetaDataHandler.java    From carbon-commons with Apache License 2.0 6 votes vote down vote up
private void removeCompositeMetadata(String repName) {
    Iterator iterator = reportsElement.getChildElements();
    boolean isChartFound = false;

    while (iterator.hasNext()) {
        OMElement reportElement = (OMElement) iterator.next();
        String reportType = reportElement.getAttributeValue(new QName(TYPE));
        if (reportType.equalsIgnoreCase(ReportConstants.COMPOSITE_TYPE)) {
            Iterator compositeIterator = reportElement.getChildElements();
            while (compositeIterator.hasNext()) {
                OMElement compositeElement = (OMElement) compositeIterator.next();
                String reportName = compositeElement.getAttributeValue(new QName(NAME));
                if (reportName.equalsIgnoreCase(repName)) {
                    reportElement.detach();
                    isChartFound = true;
                    return;
                }
            }

        }

        if (isChartFound) break;
    }
}
 
Example 4
Source File: ChartMetaDataHandler.java    From carbon-commons with Apache License 2.0 6 votes vote down vote up
private String getDsName() {
    Iterator iterator = reportsElement.getChildElements();
    boolean isTableFound = false;

    while (iterator.hasNext()) {
        OMElement reportElement = (OMElement) iterator.next();
        String reportType = reportElement.getAttributeValue(new QName(TYPE));
        String dsName = reportElement.getAttributeValue(new QName(DS_NAME));
        if (reportType.equalsIgnoreCase(this.reportType)) {
            Iterator chartIterator = reportElement.getChildElements();
            while (chartIterator.hasNext()) {
                OMElement chartReportElement = (OMElement) chartIterator.next();
                String chartName = chartReportElement.getAttributeValue(new QName(NAME));
                if (chartName.equalsIgnoreCase(chartReport.getReportName())) {
                    return dsName;
                }
            }
        }
    }
    return null;
}
 
Example 5
Source File: InboundProvisioningConfig.java    From carbon-identity with Apache License 2.0 6 votes vote down vote up
public static InboundProvisioningConfig build(OMElement inboundProvisioningConfigOM) {
    InboundProvisioningConfig inboundProvisioningConfig = new InboundProvisioningConfig();

    if (inboundProvisioningConfigOM == null) {
        return inboundProvisioningConfig;
    }

    Iterator<?> iter = inboundProvisioningConfigOM.getChildElements();

    while (iter.hasNext()) {
        OMElement element = (OMElement) (iter.next());
        String elementName = element.getLocalName();

        if ("ProvisioningUserStore".equals(elementName)) {
            inboundProvisioningConfig.setProvisioningUserStore(element.getText());
        } else if ("IsProvisioningEnabled".equals(elementName) && element.getText() != null) {
            inboundProvisioningConfig.setProvisioningEnabled(Boolean.parseBoolean(element.getText()));
        } else if ("IsDumbModeEnabled".equals(elementName) && element.getText() != null) {
            inboundProvisioningConfig.setDumbMode(Boolean.parseBoolean(element.getText()));
        }
    }

    return inboundProvisioningConfig;
}
 
Example 6
Source File: MetadataFinder.java    From carbon-commons with Apache License 2.0 6 votes vote down vote up
public static String findReportType(String reportName) throws ReportingException {
    if (loadMetaData()) {
        Iterator iterator = reportsElement.getChildElements();

        while (iterator.hasNext()) {
            OMElement reportElement = (OMElement) iterator.next();
            String reportType = reportElement.getAttributeValue(new QName(TYPE));
            Iterator reportIterator = reportElement.getChildElements();
            while (reportIterator.hasNext()) {
                OMElement specificReportElement = (OMElement) reportIterator.next();
                String aReportName = specificReportElement.getAttributeValue(new QName(NAME));
                if (aReportName.equalsIgnoreCase(reportName)) {
                    return reportType;
                }
            }


        }
        return null;
    } else return null;
}
 
Example 7
Source File: RoleMapping.java    From carbon-identity-framework with Apache License 2.0 6 votes vote down vote up
public static RoleMapping build(OMElement roleMappingOM) {
    RoleMapping roleMapping = new RoleMapping();

    Iterator<?> iter = roleMappingOM.getChildElements();

    while (iter.hasNext()) {
        OMElement element = (OMElement) (iter.next());
        String elementName = element.getLocalName();

        if ("localRole".equals(elementName)) {
            roleMapping.setLocalRole(LocalRole.build(element));
        }
        if ("remoteRole".equals(elementName)) {
            roleMapping.setRemoteRole(element.getText());
        }
    }

    return roleMapping;
}
 
Example 8
Source File: WSXACMLEntitlementServiceClient.java    From micro-integrator with Apache License 2.0 6 votes vote down vote up
/**
 * Format the sent in request as required by OpenSAML
 *
 * @param xacmlRequest : received XACML request
 * @return formatted request
 * @throws Exception
 */
private String formatRequest(String xacmlRequest) throws EntitlementProxyException {

    xacmlRequest = xacmlRequest.replace("\n", "");

    OMElement omElemnt = null;
    try {
        omElemnt = AXIOMUtil.stringToOM(xacmlRequest);
        omElemnt.setNamespace(xacmlContextNS);
        Iterator childIterator = omElemnt.getChildElements();
        setXACMLNamespace(childIterator);
        return omElemnt.toString();

    } catch (Exception e) {
        log.error("Error occurred while formatting the XACML request", e);
        throw new EntitlementProxyException("Error occurred while formatting the XACML request", e);
    }

}
 
Example 9
Source File: WSXACMLMessageReceiver.java    From carbon-identity-framework with Apache License 2.0 6 votes vote down vote up
/**
 * Format the sent in response as required by OpenSAML
 *
 * @param xacmlResponse : received XACML response
 * @return formatted response
 */
private String formatResponse(String xacmlResponse) throws Exception {

    xacmlResponse = xacmlResponse.replace("\n", "");
    OMElement omElemnt;

    try {
        omElemnt = org.apache.axiom.om.util.AXIOMUtil.stringToOM(xacmlResponse);
        omElemnt.setNamespace(xacmlContextNS);
        if (omElemnt.getChildren() != null) {
            Iterator childIterator = omElemnt.getChildElements();
            setXACMLNamespace(childIterator);
        }
    } catch (Exception e) {
        log.error("Error while generating the OMElement from the XACML request.", e);
        throw new Exception("Error while generating the OMElement from the XACML request.", e);
    }

    return omElemnt.toString();
}
 
Example 10
Source File: MetadataSupport.java    From openxds with Apache License 2.0 5 votes vote down vote up
/**
 * Get child of ele with matching name and id attribute.
 * @param ele
 * @param localName
 * @param id
 * @return
 */
public static OMElement getChild(OMElement ele, String localName, String id) {
	for (Iterator it=ele.getChildElements(); it.hasNext(); ) {
		OMElement child = (OMElement) it.next();
		if (child.getLocalName().equals(localName)) {
			String idAttVal = child.getAttributeValue(MetadataSupport.id_qname);
			if (idAttVal != null && idAttVal.equals(id))
				return child;
		}
	}
	return null;
}
 
Example 11
Source File: Metadata.java    From openxds with Apache License 2.0 5 votes vote down vote up
public OMElement findSlot(OMElement registry_object, String slot_name) {
	for (Iterator it = registry_object.getChildElements(); it.hasNext();) {
		OMElement s = (OMElement) it.next();
		if (!s.getLocalName().equals("Slot"))
			continue;
		String val = s.getAttributeValue(MetadataSupport.slot_name_qname);
		if (val != null && val.equals(slot_name))
			return s;
	}
	return null;
}
 
Example 12
Source File: ServiceFinder.java    From openxds with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
String getMethodName(OMElement serviceEle, String action) throws Exception {
	for (Iterator<OMElement> it=serviceEle.getChildElements(); it.hasNext(); ) {
		OMElement ele = it.next();
		if ( !"operation".equals(ele.getLocalName()))
			continue;
		OMElement actionMappingEle = MetadataSupport.firstChildWithLocalName(ele, "actionMapping");
		if (actionMappingEle == null)
			continue;
		String actionMapping = actionMappingEle.getText();
		if (action.equals(actionMapping))
			return ele.getAttributeValue(nameQName);
	}
	throw new Exception("Cannot find method name for service = " + serviceEle.getAttributeValue(nameQName) + " action = " + action);
}
 
Example 13
Source File: CrossGatewayQueryTest.java    From openxds with Apache License 2.0 5 votes vote down vote up
/**
 * This test initiate a FindDocuments Cross-Gateway Query (XGQ) to the XDS
 * 	Registry server's Initiating Gateway for a pre-determined Patient ID.
 * 	Request LeafClass (full metadata) be returned.
 * @throws Exception
 */
@Test
public void testIGFindDocsLeafClass() throws Exception {
	//1. Submit one or more document first for the default patientId
	
	//2. Generate StoredQuery request message
	String message = findDocumentsQuery(patientId, "Approved", "LeafClass");
	OMElement request = OMUtil.xmlStringToOM(message);			
	System.out.println("Request:\n" +request);

	//3. Send a StoredQuery
	ServiceClient sender = getIGQueryServiceClient();															 
	OMElement response = sender.sendReceive( request );		
	assertNotNull(response); 

	//4. Verify the response is correct
	OMAttribute status = response.getAttribute(new QName("status"));
	assertEquals("urn:oasis:names:tc:ebxml-regrep:ResponseStatusType:Success", status.getAttributeValue()); 
	
	//5. Verify document count
	NodeList count = getNodeCount(response, "ExtrinsicObject");
	String result = response.toString();
	System.out.println("Result:\n" +result);

	assertTrue(count.getLength() >= 1); 

	System.out.println("Result:\n" +result);
	
	//6. Verify all ExtrinsicObject have a home attribute from the XGQ response
	OMElement registry_object_list = MetadataSupport.firstChildWithLocalName(response, "RegistryObjectList"); 
	for (Iterator it=registry_object_list.getChildElements(); it.hasNext(); ) {
		OMElement registry_object = (OMElement) it.next();

		String objectHome = registry_object.getAttributeValue(MetadataSupport.home_qname);
		assertTrue("homeId is NULL", objectHome!=null && !objectHome.equals("")); 
	}    	

}
 
Example 14
Source File: JustInTimeProvisioningConfig.java    From carbon-identity-framework with Apache License 2.0 5 votes vote down vote up
public static JustInTimeProvisioningConfig build(OMElement justInTimeProvisioningConfigOM) {
    JustInTimeProvisioningConfig justInTimeProvisioningConfig = new JustInTimeProvisioningConfig();

    if (justInTimeProvisioningConfigOM == null) {
        return justInTimeProvisioningConfig;
    }

    Iterator<?> iter = justInTimeProvisioningConfigOM.getChildElements();

    while (iter.hasNext()) {
        OMElement element = (OMElement) (iter.next());
        String elementName = element.getLocalName();

        if ("UserStoreClaimUri".equals(elementName)) {
            justInTimeProvisioningConfig.setUserStoreClaimUri(element.getText());
        } else if ("ProvisioningUserStore".equals(elementName)) {
            justInTimeProvisioningConfig.setProvisioningUserStore(element.getText());
        } else if ("IsProvisioningEnabled".equals(elementName)) {
            if (element.getText() != null && element.getText().trim().length() > 0) {
                justInTimeProvisioningConfig.setProvisioningEnabled(Boolean
                        .parseBoolean(element.getText()));
            }
        } else if (IdentityApplicationConstants.IS_PASSWORD_PROVISIONING_ENABLED_ELEMENT.equals(elementName)) {
            if (StringUtils.isNotEmpty(element.getText())) {
                justInTimeProvisioningConfig
                        .setPasswordProvisioningEnabled(Boolean.parseBoolean(element.getText()));
            }
        } else if (IdentityApplicationConstants.ALLOW_MODIFY_USERNAME_ELEMENT.equals(elementName)) {
            if (StringUtils.isNotEmpty(element.getText())) {
                justInTimeProvisioningConfig.setModifyUserNameAllowed(Boolean.parseBoolean(element.getText()));
            }
        } else if (IdentityApplicationConstants.PROMPT_CONSENT_ELEMENT.equals(elementName)) {
            if (StringUtils.isNotEmpty(element.getText())) {
                justInTimeProvisioningConfig.setPromptConsent(Boolean.parseBoolean(element.getText()));
            }
        }
    }

    return justInTimeProvisioningConfig;
}
 
Example 15
Source File: WebQuery.java    From micro-integrator with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
public void runPostQuery(Object result, XMLStreamWriter xmlWriter,
                         InternalParamCollection params, int queryLevel) throws DataServiceFault {

    Variable scrapedOutput = (Variable) result;
    try {
        OMElement resultEl = AXIOMUtil.stringToOM(scrapedOutput != null ? scrapedOutput.toString() : null);
        OMElement entryEl, fieldEl;
        DataEntry dataEntry;
        boolean useColumnNumbers = this.isUsingColumnNumbers();
        int i;
        for (Iterator<OMElement> recordItr = resultEl.getChildElements(); recordItr.hasNext();) {
            entryEl = recordItr.next();
            dataEntry = new DataEntry();
            i = 1;
            for (Iterator<OMElement> fieldItr = entryEl.getChildElements(); fieldItr.hasNext();) {
                fieldEl = fieldItr.next();
                dataEntry.addValue(useColumnNumbers ? Integer.toString(i) :
                        fieldEl.getLocalName(), new ParamValue(fieldEl.getText()));
                i++;
            }
            this.writeResultEntry(xmlWriter, dataEntry, params, queryLevel);
        }
    } catch (Exception e) {
        throw new DataServiceFault(e, "Error in executing web scraping query");
    }
}
 
Example 16
Source File: IdentityConfigParser.java    From carbon-identity-framework with Apache License 2.0 5 votes vote down vote up
private void readChildElements(OMElement serverConfig, Stack<String> nameStack) {
    for (Iterator childElements = serverConfig.getChildElements(); childElements.hasNext(); ) {
        OMElement element = (OMElement) childElements.next();
        nameStack.push(element.getLocalName());
        if (elementHasText(element)) {
            String key = getKey(nameStack);
            Object currentObject = configuration.get(key);
            String value = replaceSystemProperty(element.getText());
            if (secretResolver != null && secretResolver.isInitialized() &&
                    secretResolver.isTokenProtected(key)) {
                value = secretResolver.resolve(key);
            }
            if (currentObject == null) {
                configuration.put(key, value);
            } else if (currentObject instanceof ArrayList) {
                ArrayList list = (ArrayList) currentObject;
                if (!list.contains(value)) {
                    list.add(value);
                    configuration.put(key, list);
                }
            } else {
                if (!value.equals(currentObject)) {
                    ArrayList arrayList = new ArrayList(2);
                    arrayList.add(currentObject);
                    arrayList.add(value);
                    configuration.put(key, arrayList);
                }
            }
        }
        readChildElements(element, nameStack);
        nameStack.pop();
    }
}
 
Example 17
Source File: APIDescriptionGenUtil.java    From carbon-apimgt with Apache License 2.0 5 votes vote down vote up
/**
 * The method to extract the tier attributes from each tier level policy definitions
 * @param policy  Tier level policy
 * @return Attributes map
 * @throws APIManagementException
 */
public static Map<String, Object> getTierAttributes(OMElement policy) throws APIManagementException {
    Map<String, Object> attributesMap = new HashMap<String, Object>();
    OMElement attributes = null;

    try {
        OMElement tier = policy.getFirstChildWithName(APIConstants.POLICY_ELEMENT).getFirstChildWithName
                (APIConstants.THROTTLE_CONTROL_ELEMENT).getFirstChildWithName(APIConstants.POLICY_ELEMENT)
                .getFirstChildWithName(APIConstants.POLICY_ELEMENT);
        if (tier != null) {
            attributes = tier.getFirstChildWithName(APIConstants.THROTTLE_ATTRIBUTES_ELEMENT);
        }
        if (attributes == null) {
            return attributesMap;
        } else {
            for (Iterator childElements = attributes.getChildElements(); childElements.hasNext(); ) {
                OMElement element = (OMElement) childElements.next();
                String displayName = element.getAttributeValue(
                        new QName(APIConstants.THROTTLE_ATTRIBUTE_DISPLAY_NAME));
                String localName = element.getLocalName();
                String attrName = (displayName != null ? displayName : localName); //If displayName not defined,
                // use the attribute name
                String attrValue = element.getText();
                attributesMap.put(attrName, attrValue);
            }
        }
    } catch (NullPointerException e) {
        String errorMessage = "Policy could not be parsed correctly based on " +
                "http://schemas.xmlsoap.org/ws/2004/09/policy specification";
        log.error(errorMessage, e);
        throw new APIManagementException(errorMessage + e.getMessage());
    }
    return attributesMap;
}
 
Example 18
Source File: InboundAuthenticationRequestConfig.java    From carbon-identity-framework with Apache License 2.0 4 votes vote down vote up
public static InboundAuthenticationRequestConfig build(
        OMElement inboundAuthenticationRequestConfigOM) {

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

    InboundAuthenticationRequestConfig inboundAuthenticationRequestConfig;
    inboundAuthenticationRequestConfig = new InboundAuthenticationRequestConfig();

    Iterator<?> members = inboundAuthenticationRequestConfigOM.getChildElements();

    while (members.hasNext()) {
        OMElement member = (OMElement) members.next();

        if ("InboundAuthKey".equalsIgnoreCase(member.getLocalName())) {
            inboundAuthenticationRequestConfig.setInboundAuthKey(member.getText());
        } else if ("InboundAuthType".equalsIgnoreCase(member.getLocalName())) {
            inboundAuthenticationRequestConfig.setInboundAuthType(member.getText());
        } else if ("InboundConfigType".equalsIgnoreCase(member.getLocalName())) {
            inboundAuthenticationRequestConfig.setInboundConfigType(member.getText());
        } else if ("friendlyName".equalsIgnoreCase(member.getLocalName())) {
            inboundAuthenticationRequestConfig.setFriendlyName(member.getText());
        } else if ("Properties".equalsIgnoreCase(member.getLocalName())) {
            Iterator<?> propertiesIter = member.getChildElements();
            List<Property> propertiesArrList = new ArrayList<Property>();

            if (propertiesIter != null) {
                while (propertiesIter.hasNext()) {
                    OMElement propertiesElement = (OMElement) (propertiesIter.next());
                    Property prop = Property.build(propertiesElement);
                    if (prop != null) {
                        propertiesArrList.add(prop);
                    }
                }
            }
            if (CollectionUtils.isNotEmpty(propertiesArrList)) {
                Property[] propertiesArr = propertiesArrList.toArray(new Property[0]);
                inboundAuthenticationRequestConfig.setProperties(propertiesArr);
            }
        }
    }
    return inboundAuthenticationRequestConfig;
}
 
Example 19
Source File: APIManagerConfiguration.java    From carbon-apimgt with Apache License 2.0 4 votes vote down vote up
private void setEventHubConfiguration(OMElement omElement) {

        EventHubConfigurationDto eventHubConfigurationDto = new EventHubConfigurationDto();
        OMElement enableElement = omElement.getFirstChildWithName(new QName(APIConstants.KeyManager.ENABLE));
        if (enableElement != null && Boolean.parseBoolean(enableElement.getText())) {
            eventHubConfigurationDto.setEnabled(true);
            OMElement serviceUrl = omElement.getFirstChildWithName(new QName(APIConstants.KeyManager.SERVICE_URL));
            if (serviceUrl != null) {
                eventHubConfigurationDto.setServiceUrl(
                        APIUtil.replaceSystemProperty(serviceUrl.getText()).concat(APIConstants.INTERNAL_WEB_APP_EP));
            }
            OMElement initDelay = omElement.getFirstChildWithName(new QName(APIConstants.KeyManager.INIT_DELAY));
            if (initDelay != null) {
                eventHubConfigurationDto.setInitDelay(Integer.parseInt(initDelay.getText()));
            }
            OMElement usernameElement = omElement.getFirstChildWithName(new QName(APIConstants.KeyManager.USERNAME));
            if (usernameElement != null) {
                eventHubConfigurationDto.setUsername(usernameElement.getText());
            }
            OMElement passwordElement = omElement.getFirstChildWithName(new QName(APIConstants.KeyManager.PASSWORD));
            if (passwordElement != null) {
                String password = MiscellaneousUtil.resolve(passwordElement, secretResolver);
                eventHubConfigurationDto.setPassword(APIUtil.replaceSystemProperty(password).toCharArray());
            }

            OMElement configurationRetrieverElement =
                    omElement.getFirstChildWithName(new QName(APIConstants.KeyManager.EVENT_RECEIVER_CONFIGURATION));
            if (configurationRetrieverElement != null) {
                EventHubConfigurationDto.EventHubReceiverConfiguration eventHubReceiverConfiguration =
                        new EventHubConfigurationDto.EventHubReceiverConfiguration();
                Iterator receiverConnectionDetailsElements = configurationRetrieverElement.getChildElements();
                Properties properties = new Properties();
                while (receiverConnectionDetailsElements.hasNext()) {
                    OMElement element = (OMElement) receiverConnectionDetailsElements.next();
                    String value = MiscellaneousUtil.resolve(element, secretResolver);
                    properties.put(element.getLocalName(), APIUtil.replaceSystemProperty(value));
                }
                eventHubReceiverConfiguration.setJmsConnectionParameters(properties);
                eventHubConfigurationDto.setEventHubReceiverConfiguration(eventHubReceiverConfiguration);
            }
            OMElement eventPublisherElement =
                    omElement.getFirstChildWithName(new QName(APIConstants.KeyManager.EVENT_PUBLISHER_CONFIGURATIONS));
            EventHubConfigurationDto.EventHubPublisherConfiguration eventHubPublisherConfiguration =
                    new EventHubConfigurationDto.EventHubPublisherConfiguration();
            if (eventPublisherElement != null) {
                OMElement receiverUrlGroupElement = eventPublisherElement.getFirstChildWithName(new
                        QName
                        (APIConstants.AdvancedThrottleConstants.DATA_PUBLISHER_CONFIGURAION_REVEIVER_URL_GROUP));
                if (receiverUrlGroupElement != null) {
                    eventHubPublisherConfiguration
                            .setReceiverUrlGroup(APIUtil.replaceSystemProperty(receiverUrlGroupElement
                                    .getText()));
                }
                OMElement authUrlGroupElement = eventPublisherElement.getFirstChildWithName(new QName
                        (APIConstants.AdvancedThrottleConstants.DATA_PUBLISHER_CONFIGURAION_AUTH_URL_GROUP));
                if (authUrlGroupElement != null) {
                    eventHubPublisherConfiguration
                            .setAuthUrlGroup(APIUtil.replaceSystemProperty(authUrlGroupElement.getText()));
                }
                OMElement eventTypeElement = eventPublisherElement.getFirstChildWithName(
                        new QName(APIConstants.AdvancedThrottleConstants.DATA_PUBLISHER_CONFIGURAION_TYPE));
                if (eventTypeElement != null) {
                    eventHubPublisherConfiguration.setType(eventTypeElement.getText().trim());
                }
                eventHubConfigurationDto.setEventHubPublisherConfiguration(eventHubPublisherConfiguration);
            }
        }
        this.eventHubConfigurationDto = eventHubConfigurationDto;
    }
 
Example 20
Source File: ValidPathAxis2RepoTestCase.java    From product-ei with Apache License 2.0 3 votes vote down vote up
@BeforeClass(alwaysRun = true)
public void setEnvironment() throws Exception {

    super.init();

    String urlAxis2Xml = getESBResourceLocation() +"/mediatorconfig/callout/client_repo/conf";
    String uriSynapse = getESBResourceLocation()+ "/mediatorconfig/callout/ValidPath_Axis2Repo.xml";

    OMElement lineItem = AXIOMUtil.stringToOM(FileManager.readFile(uriSynapse));

    Iterator sequenceElements = lineItem.getChildElements();      // get all sequence elements


    while (sequenceElements.hasNext()) {

        OMElement sequenceElement = (OMElement) sequenceElements.next();

        Iterator callOutElements = sequenceElement.getChildrenWithLocalName("callout");        // get all callout elements


        while (callOutElements.hasNext()) {

            OMElement callOutElement = (OMElement) callOutElements.next();

            Iterator configElments = callOutElement.getChildrenWithLocalName("configuration");        // get configuration elements


            while (configElments.hasNext()) {

                OMElement configElment = (OMElement) configElments.next();           //this is the configuration element

                configElment.getAttribute(new QName("repository")).setAttributeValue(urlAxis2Xml);    // gets the attribute of repository and changes it to a different path
            }
        }
    }

    updateESBConfiguration(lineItem);
}