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

The following examples show how to use org.apache.axiom.om.OMElement#getAttributeValue() . 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: LogModel.java    From openxds with Apache License 2.0 6 votes vote down vote up
public boolean isPass(String subtest_name) throws XdsInternalException, XdsException {
	OMElement log = get_log(subtest_name);
	String eleName = log.getLocalName();
	if (eleName.equals("TestResults")) {
		String status =  log.getAttributeValue(new QName("status"));
		if (status == null || status.equals("")) throw new XdsException("isPass: no status found for subtest " + subtest_name);
		return status.equals("Pass");
	}
	else if (eleName.equals("XdsEvsResult")) {
		OMElement resultEle = MetadataSupport.firstChildWithLocalName(log, "Result");
		String result = (resultEle != null) ? resultEle.getText() : null;
		if (result == null || result.equals("")) throw new XdsInternalException("EVS has empty Result element");
		return result.equals("Pass");
	}
	throw new XdsInternalException("Not TestResults or XdsEvsRequest");
}
 
Example 2
Source File: QueryFactory.java    From micro-integrator with Apache License 2.0 6 votes vote down vote up
private static WithParam createWithParam(OMElement el) throws DataServiceFault {
	String name = el.getAttributeValue(new QName("name"));
       if (name != null) {
           name = name.trim();
       }
	String paramType = "column";
	String param = el.getAttributeValue(new QName(paramType));
	String originalParam = null;
       if (param == null) {
           paramType = "query-param";
           param = el.getAttributeValue(new QName(paramType));
           if (param != null) {
               param = param.trim();
           }
       }
	if (param == null) {
		throw new DataServiceFault("Invalid param type in with-param element:-\n " + el);
	} else {
		originalParam = param;
		/* 'toLowerCase' - workaround for different character case issues in column names */
		param = param.toLowerCase();
	}
	WithParam withParam = new WithParam(name, originalParam, param, paramType);
	return withParam;
}
 
Example 3
Source File: RealmConfigXMLProcessor.java    From micro-integrator with Apache License 2.0 6 votes vote down vote up
private Map<String, String> getChildPropertyElements(OMElement omElement, SecretResolver secretResolver) {
    Map<String, String> map = new HashMap();
    String propName;
    String propValue;
    for (Iterator ite = omElement.getChildrenWithName(new QName("Property")); ite.hasNext(); map.put(propName.trim(), propValue.trim())) {
        OMElement propElem = (OMElement) ite.next();
        propName = propElem.getAttributeValue(new QName("name"));
        propValue = propElem.getText();
        if (secretResolver != null && secretResolver.isInitialized()) {
            if (secretResolver.isTokenProtected("UserManager.Configuration.Property." + propName)) {
                propValue = secretResolver.resolve("UserManager.Configuration.Property." + propName);
            }

            if (secretResolver.isTokenProtected("UserStoreManager.Property." + propName)) {
                propValue = secretResolver.resolve("UserStoreManager.Property." + propName);
            }
        }
    }

    return map;
}
 
Example 4
Source File: PolicyAttributeBuilder.java    From carbon-identity-framework with Apache License 2.0 5 votes vote down vote up
/**
 * This searches through  attribute values in the attribute elements to extract the policy meta data
 *
 * @param omElement         apply element as an OMElement
 * @param values            set of String objects
 * @param searchDesignators states where,  to find designators which are involved in creating
 *                          attribute values
 * @return AttributeValueDTO object which holds the policy meta data in String format
 */
public List<String> searchAttributeValues(OMElement omElement, List<String> values,
                                          boolean searchDesignators) {

    if (values != null) {
        Iterator iterator = omElement.
                getChildrenWithLocalName(PDPConstants.ATTRIBUTE_VALUE);
        while (iterator.hasNext()) {
            OMElement attributeElement = (OMElement) iterator.next();
            if (attributeElement != null) {
                String dataType = attributeElement.
                        getAttributeValue(new QName(PDPConstants.DATA_TYPE));   // TODO
                values.add(attributeElement.getText());
            }
        }
    }

    Iterator iterator1 = omElement.getChildrenWithLocalName(PDPConstants.APPLY_ELEMENT);
    while (iterator1.hasNext()) {
        OMElement applyElement = (OMElement) iterator1.next();
        searchAttributeValues(applyElement, values, searchDesignators);

        AttributeDTO attributeDTO = new AttributeDTO();
        if (searchDesignators) {
            if (version == XACMLConstants.XACML_VERSION_3_0) {
                searchXACML3Designator(applyElement, attributeDTO);
            } else {
                searchDesignatorOrSelector(applyElement, attributeDTO);
            }
        }
        if (attributeDTO.getCategory() != null || attributeDTO.getAttributeId() != null ||
                attributeDTO.getAttributeDataType() != null) {
            values = null;
        }
    }

    return values;
}
 
Example 5
Source File: ESBIntegrationTest.java    From product-ei with Apache License 2.0 5 votes vote down vote up
protected void addInboundEndpoint(OMElement inboundEndpoint) throws Exception {
	String inboundName = inboundEndpoint.getAttributeValue(new QName("name"));
	if (inboundEndpointList == null) {
		inboundEndpointList = new ArrayList<String>();
	}
	inboundEndpointList.add(inboundName);
	esbUtils.addInboundEndpoint(contextUrls.getBackEndUrl(), sessionCookie, inboundEndpoint);
}
 
Example 6
Source File: IdIndex.java    From openxds with Apache License 2.0 5 votes vote down vote up
public String getSubmissionSetPatientId() {
	OMElement ss = m.getSubmissionSet();
	if (ss == null)
		return null;
	String ss_id = ss.getAttributeValue(MetadataSupport.id_qname);
	if (ss_id == null)
		return null;
	return getExternalIdentifierValue(ss_id, "urn:uuid:6b5aea1a-874d-4603-a4bc-96a0a7b38446");
}
 
Example 7
Source File: ConfigFactory.java    From micro-integrator with Apache License 2.0 5 votes vote down vote up
private static boolean isODataEnable(OMElement configEl) {
	String odataConfig = configEl.getAttributeValue(new QName(DBSFields.ENABLE_ODATA));
	if (odataConfig == null) {
		return false;
	} else {
		return Boolean.valueOf(odataConfig);
	}
}
 
Example 8
Source File: AuthenticationMethodNameTranslatorImpl.java    From carbon-identity-framework with Apache License 2.0 5 votes vote down vote up
private void processAcrEntry(OMElement amrEntryElement, Map<String, String> acrExternalToInternalMap,
        Map<String, Set<String>> acrInternalToExternalMap) {

    String uri = amrEntryElement.getAttributeValue(URI_ATTR_QNAME);
    String level = amrEntryElement.getAttributeValue(LEVEL_ATTR_QNAME);
    acrExternalToInternalMap.put(uri, level);
    Set<String> externalMappings = acrInternalToExternalMap.get(level);
    if (externalMappings == null) {
        externalMappings = new HashSet<>();
        acrInternalToExternalMap.put(level, externalMappings);
    }
    externalMappings.add(uri);
    acrExternalToInternalMap.put(uri, level);
}
 
Example 9
Source File: IdIndex.java    From openxds with Apache License 2.0 5 votes vote down vote up
public String getNameValue(String id) {
	OMElement name_ele = getName(id);
	if (name_ele == null)
		return null;
	OMElement loc_st = MetadataSupport.firstChildWithLocalName(name_ele, "LocalizedString"); 
	if (loc_st == null)
		return null;
	return loc_st.getAttributeValue(MetadataSupport.value_qname);
}
 
Example 10
Source File: ESBIntegrationTest.java    From micro-integrator with Apache License 2.0 5 votes vote down vote up
protected void addSequenceTemplate(OMElement sequenceTemplate) throws Exception {
    String name = sequenceTemplate.getAttributeValue(new QName("name"));
    if (esbUtils.isSequenceTemplateExist(contextUrls.getBackEndUrl(), sessionCookie, name)) {
        esbUtils.deleteSequenceTemplate(contextUrls.getBackEndUrl(), sessionCookie, name);
    }
    esbUtils.addSequenceTemplate(contextUrls.getBackEndUrl(), sessionCookie, setEndpoints(sequenceTemplate));

    if (sequenceTemplateList == null) {
        sequenceTemplateList = new ArrayList<String>();
    }
    sequenceTemplateList.add(name);
}
 
Example 11
Source File: ESBIntegrationTest.java    From micro-integrator with Apache License 2.0 5 votes vote down vote up
protected void addMessageProcessor(OMElement messageProcessorConfig) throws Exception {
    String messageProcessorName = messageProcessorConfig.getAttributeValue(new QName("name"));
    if (esbUtils.isMessageProcessorExist(contextUrls.getBackEndUrl(), sessionCookie, messageProcessorName)) {
        esbUtils.deleteMessageProcessor(contextUrls.getBackEndUrl(), sessionCookie, messageProcessorName);
    }
    esbUtils.addMessageProcessor(contextUrls.getBackEndUrl(), sessionCookie, setEndpoints(messageProcessorConfig));
    if (messageProcessorsList == null) {
        messageProcessorsList = new ArrayList<String>();
    }
    messageProcessorsList.add(messageProcessorName);
}
 
Example 12
Source File: Attribute.java    From openxds with Apache License 2.0 5 votes vote down vote up
void validate_ss_slots_are_legal() throws MetadataException {
	String ss_id = m.getSubmissionSetId();

	List slots = m.getSlots(ss_id);
	for (int j=0; j<slots.size(); j++) {
		OMElement slot = (OMElement) slots.get(j);

		String slot_name = slot.getAttributeValue(MetadataSupport.slot_name_qname);
		if (slot_name == null) slot_name = "";
		if ( ! legal_ss_slot_name(slot_name))
			err("Submission Set " + ss_id + ": " + slot_name + " is not a legal slot name for a Submission Set");
	}
}
 
Example 13
Source File: ESBJAVA3470.java    From product-ei with Apache License 2.0 5 votes vote down vote up
protected void addProxyService(OMElement proxyConfig) throws Exception {
    String proxyName = proxyConfig.getAttributeValue(new QName("name"));
    if (esbUtils.isProxyServiceExist(context.getContextUrls().getBackEndUrl(), sessionCookie, proxyName)) {
        esbUtils.deleteProxyService(context.getContextUrls().getBackEndUrl(), sessionCookie, proxyName);
    }
    esbUtils.addProxyService(context.getContextUrls().getBackEndUrl(), sessionCookie, setEndpoints(proxyConfig));
}
 
Example 14
Source File: Metadata.java    From openxds with Apache License 2.0 5 votes vote down vote up
public List<OMElement> getExternalIdentifiers(OMElement registry_object,
		String id_scheme) {
	List<OMElement> results = new ArrayList<OMElement>();
	QName idscheme = MetadataSupport.identificationscheme_qname;
	for (Iterator it = registry_object.getChildElements(); it.hasNext();) {
		OMElement ele = (OMElement) it.next();
		if (!ele.getLocalName().equals("ExternalIdentifier"))
			continue;
		String this_id_scheme = ele.getAttributeValue(idscheme);
		if (id_scheme == null || id_scheme.equals(this_id_scheme))
			results.add(ele);
	}
	return results;
}
 
Example 15
Source File: IdentityConfigParser.java    From carbon-identity with Apache License 2.0 5 votes vote down vote up
private void buildEventListenerData() {
    OMElement eventListeners = this.getConfigElement(IdentityConstants.EVENT_LISTENERS);
    if (eventListeners != null) {
        Iterator<OMElement> eventListener = eventListeners.getChildrenWithName(
                new QName(IdentityCoreConstants.IDENTITY_DEFAULT_NAMESPACE, IdentityConstants.EVENT_LISTENER));

        if (eventListener != null) {
            while (eventListener.hasNext()) {
                OMElement eventListenerElement = eventListener.next();
                String eventListenerType = eventListenerElement.getAttributeValue(new QName(
                        IdentityConstants.EVENT_LISTENER_TYPE));
                String eventListenerName = eventListenerElement.getAttributeValue(new QName(
                        IdentityConstants.EVENT_LISTENER_NAME));
                int order = Integer.parseInt(eventListenerElement.getAttributeValue(new QName(
                        IdentityConstants.EVENT_LISTENER_ORDER)));
                String enable = eventListenerElement.getAttributeValue(new QName(
                        IdentityConstants.EVENT_LISTENER_ENABLE));

                if (StringUtils.isBlank(eventListenerType) || StringUtils.isBlank(eventListenerName)) {
                    throw IdentityRuntimeException.error("eventListenerType or eventListenerName is not defined " +
                            "correctly");
                }
                IdentityEventListenerConfigKey configKey = new IdentityEventListenerConfigKey(eventListenerType, eventListenerName);
                IdentityEventListenerConfig identityEventListenerConfig = new IdentityEventListenerConfig(enable, order, configKey);
                eventListenerConfiguration.put(configKey, identityEventListenerConfig);

            }
        }

    }
}
 
Example 16
Source File: AMQPConsumer.java    From product-ei with Apache License 2.0 5 votes vote down vote up
/**
 * @param payload XML message content came inside the JMS message
 * @throws XMLStreamException on error
 */
private void parseOrder(String payload) throws XMLStreamException {
    InputStream is = new ByteArrayInputStream(payload.getBytes());
    javax.xml.stream.XMLStreamReader parser = XMLInputFactory
            .newInstance().createXMLStreamReader(is);
    StAXSOAPModelBuilder builder = new StAXSOAPModelBuilder(parser,
            null);
    SOAPEnvelope envelope = (SOAPEnvelope) builder.getDocumentElement();
    // retrieve SOAP body
    SOAPBody soapBody = envelope.getBody();
    OMElement messageNode = soapBody.getFirstChildWithName(new QName(
            FIX_MSG));
    Iterator<?> messageElements = (Iterator<?>) messageNode
            .getChildElements();
    while (messageElements.hasNext()) {
        OMElement node = (OMElement) messageElements.next();
        if (node.getQName().getLocalPart().equals(FIX_MSG_BODY)) {
            Iterator<?> bodyElements = (Iterator<?>) node.getChildElements();
            while (bodyElements.hasNext()) {
                OMElement bodyNode = (OMElement) bodyElements.next();
                String tag = bodyNode
                        .getAttributeValue(new QName(FIX_MSG_ID));
                String value = bodyNode.getText();
                if (tag.equals(FIX_MSG_SYMBOL)) {
                    inSymbol = value;
                } else if (tag.equals(FIX_MSG_CLORDID)) {
                    inClOrderID = value;
                } else if (tag.equals(FIX_MSG_ORDQTY)) {
                    inQty = value;
                }
            }
        }
    }
}
 
Example 17
Source File: Metadata.java    From openxds with Apache License 2.0 5 votes vote down vote up
public boolean hasClassification(OMElement obj, String uuid) {
	if (obj == null)
		return false;
	if (uuid == null)
		return false;
	for (OMElement classif_ele : MetadataSupport.childrenWithLocalName(obj,
			"Classification")) {
		String classification_node = classif_ele
				.getAttributeValue(MetadataSupport.classificationnode_qname);
		if (uuid.equals(classification_node))
			return true;
	}
	return false;
}
 
Example 18
Source File: ESBIntegrationTest.java    From product-ei with Apache License 2.0 4 votes vote down vote up
protected boolean isInboundEndpointDeployed(OMElement inboundEndpoint) throws Exception {
	String inboundName = inboundEndpoint.getAttributeValue(new QName("name"));
	return esbUtils.isInboundEndpointExist(contextUrls.getBackEndUrl(), sessionCookie, inboundName);
}
 
Example 19
Source File: TranslateToV3.java    From openxds with Apache License 2.0 4 votes vote down vote up
OMElement add_id(OMElement ele) {
	String att_value = ele.getAttributeValue(id_qname);
	if (att_value == null || att_value.equals(""))
		ele.addAttribute("id", new_id(), null);
	return ele;
}
 
Example 20
Source File: Attribute.java    From openxds with Apache License 2.0 4 votes vote down vote up
void validate_doc_slots() throws MetadataException {
	List doc_ids = m.getExtrinsicObjectIds();
	
	for (int i=0; i<doc_ids.size(); i++) {
		String id = (String) doc_ids.get(i);
		OMElement docEle = m.getObjectById(id);
		List slots = m.getSlots(id);
		List ext_ids = m.getExternalIdentifiers(id);

		String objType = docEle.getAttributeValue(MetadataSupport.object_type_qname);
		boolean isODD = false;
		if (objType.equals(MetadataSupport.XDSDocumentEntry_objectType_odd_uuid)) {
			isODD = true;
		}

		//                      				name						multi	required		number
		validate_slot("Document", id, slots, 	"creationTime", 			false, 	!isODD, 		true);
		validate_slot("Document", id, slots, 	"intendedRecipient",		true, 	false, 			false);
		validate_slot("Document", id, slots, 	"languageCode",				false, 	true, 			false);
		validate_slot("Document", id, slots, 	"legalAuthenticator",		false, 	false, 			false);
		validate_slot("Document", id, slots, 	"serviceStartTime",			false, 	false, 			true);
		validate_slot("Document", id, slots, 	"serviceStopTime",			false, 	false, 			true);
		validate_slot("Document", id, slots, 	"sourcePatientInfo",		true, 	false, 			false);

		validate_slot("Document", id, slots, 	"hash",			 			false, 	!(isODD || isPnR), false);
		validate_slot("Document", id, slots, 	"size",						false, 	!(isODD || isPnR), true);

		// These are tricky since the validation is based on the metadata format (xds.a or xds.b) instead of
		// on the transaction. All Stored Queries are encoded in ebRIM 3.0 (xds.b format) but they could
		// represent an xds.a registry.  The use of is_submit below is an adequate stop-gap measure
		if (xds_b) {
			validate_slot("Document", id, slots, 	"URI",					true, 	false, 		false);
			validate_slot("Document", id, slots, 	"repositoryUniqueId",	false, 	is_submit && !isPnR, 		false);
			if (m.getSlot(id, "URI") != null)
				m.getURIAttribute(docEle);
		}
		else {
			validate_slot("Document", id, slots, 	"URI",					true, 	is_submit && !isPnR, 		false);
			m.getURIAttribute(docEle);
		}

	}
}