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

The following examples show how to use org.apache.axiom.om.OMElement#addAttribute() . 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: ParamParserTest.java    From openxds with Apache License 2.0 6 votes vote down vote up
void addSlot(String name, String value_string1, String value_string2) {
	OMElement slot = om_factory().createOMElement("Slot", null);
	adhocquery.addChild(slot);
	slot.addAttribute("name", name, null);
	OMElement valuelist = om_factory().createOMElement("ValueList", null);
	slot.addChild(valuelist);
	
	OMElement value1 = om_factory().createOMElement("Value", null);
	valuelist.addChild(value1);
	OMText text1 = om_factory().createOMText(value_string1);
	value1.addChild(text1);
	
	OMElement value2 = om_factory().createOMElement("Value", null);
	valuelist.addChild(value2);
	OMText text2 = om_factory().createOMText(value_string2);
	value2.addChild(text2);
}
 
Example 2
Source File: ConfigSerializer.java    From micro-integrator with Apache License 2.0 6 votes vote down vote up
public static OMElement serializeConfig(Config config) {
	OMFactory fac = OMAbstractFactory.getOMFactory();
	OMElement configEl = fac.createOMElement(new QName(DBSFields.CONFIG));
	String configId = config.getConfigId();
	if (configId != null) {
		configEl.addAttribute(DBSFields.ID, config.getConfigId(), null);
	}
	OMElement propEl;
	for (Entry<String, String> entry : config.getProperties().entrySet()) {
		propEl = fac.createOMElement(new QName(DBSFields.PROPERTY));
		propEl.addAttribute(DBSFields.NAME, entry.getKey(), null);
		propEl.setText(entry.getValue());
		configEl.addChild(propEl);
	}
	return configEl;
}
 
Example 3
Source File: ParameterUtil.java    From micro-integrator with Apache License 2.0 6 votes vote down vote up
/**
 * Create an Axis2 parameter based using param name, value and whether it is locked
 *
 * @param name - name of the parameter
 * @param value - value of the parameter
 * @param locked - whether it is a locked param
 * @return Parameter instance
 * @throws AxisFault - error while creating param
 */
public static Parameter createParameter(String name, String value, boolean locked) throws AxisFault {
    OMFactory fac = OMAbstractFactory.getOMFactory();
    OMNamespace ns = fac.createOMNamespace("", "");
    OMElement paramEle = fac.createOMElement("parameter", ns);

    if (name == null) {
        throw new AxisFault("Parameter name is madatory.");
    }
    paramEle.addAttribute("name", name, ns);
    if (locked) {
        paramEle.addAttribute("locked", "true", ns);
    }
    if (value != null && value.length() != 0) {
        paramEle.setText(value);
    }
    return createParameter(paramEle);
}
 
Example 4
Source File: RealmConfigXMLProcessor.java    From micro-integrator with Apache License 2.0 6 votes vote down vote up
private static void addPropertyElements(OMFactory factory, OMElement parent, String className, String description, Map<String, String> properties) {
    if (className != null) {
        parent.addAttribute("class", className, (OMNamespace) null);
    }

    if (description != null) {
        parent.addAttribute("Description", description, (OMNamespace) null);
    }

    Iterator ite = properties.entrySet().iterator();

    while (ite.hasNext()) {
        Entry<String, String> entry = (Entry) ite.next();
        String name = (String) entry.getKey();
        String value = (String) entry.getValue();
        if (value != null) {
            value = resolveSystemProperty(value);
        }
        OMElement propElem = factory.createOMElement(new QName("Property"));
        OMAttribute propAttr = factory.createOMAttribute("name", (OMNamespace) null, name);
        propElem.addAttribute(propAttr);
        propElem.setText(value);
        parent.addChild(propElem);
    }

}
 
Example 5
Source File: UserStoreConfigXMLProcessor.java    From micro-integrator with Apache License 2.0 6 votes vote down vote up
/**
 * Add all the user store property elements
 *
 * @param factory
 * @param parent
 * @param className
 * @param properties
 */
private static void addPropertyElements(OMFactory factory, OMElement parent, String className,
                                        Map<String, String> properties) {
    if (className != null) {
        parent.addAttribute(UserCoreConstants.RealmConfig.ATTR_NAME_CLASS, className, null);
    }
    Iterator<Map.Entry<String, String>> ite = properties.entrySet().iterator();
    while (ite.hasNext()) {
        Map.Entry<String, String> entry = ite.next();
        String name = entry.getKey();
        String value = entry.getValue();
        OMElement propElem = factory.createOMElement(new QName(
                UserCoreConstants.RealmConfig.LOCAL_NAME_PROPERTY));
        OMAttribute propAttr = factory.createOMAttribute(
                UserCoreConstants.RealmConfig.ATTR_NAME_PROP_NAME, null, name);
        propElem.addAttribute(propAttr);
        propElem.setText(value);
        parent.addChild(propElem);
    }
}
 
Example 6
Source File: SqlRepairTest.java    From openxds with Apache License 2.0 5 votes vote down vote up
OMElement build_test_data(String sql, String return_type) {
	OMElement doc = om_factory().createOMElement("AdhocQueryRequest", null);
	OMElement ro = om_factory().createOMElement("ResponseOption", null);
	doc.addChild(ro);
	ro.addAttribute("returnType", return_type, null);
	OMElement sqlquery = om_factory().createOMElement("SQLQuery", null);
	ro.addChild(sqlquery);
	OMText text = om_factory().createOMText(sql);
	sqlquery.addChild(text);
	return doc;
}
 
Example 7
Source File: FIXClient.java    From micro-integrator with Apache License 2.0 5 votes vote down vote up
private static OMElement getBody(OMFactory factory, String text, String mode, String qtyValue) {
    OMElement body = factory.createOMElement("body", null);

    OMElement clordID = factory.createOMElement("field", null);
    clordID.addAttribute(factory.createOMAttribute("id", null, "11"));
    factory.createOMText(clordID, "122333");
    body.addChild(clordID);

    OMElement handleIns = factory.createOMElement("field", null);
    handleIns.addAttribute(factory.createOMAttribute("id", null, "21"));
    factory.createOMText(handleIns, "1");
    body.addChild(handleIns);

    OMElement qty = factory.createOMElement("field", null);
    qty.addAttribute(factory.createOMAttribute("id", null, "38"));
    factory.createOMText(qty, qtyValue);
    body.addChild(qty);

    OMElement ordType = factory.createOMElement("field", null);
    ordType.addAttribute(factory.createOMAttribute("id", null, "40"));
    factory.createOMText(ordType, "1");
    body.addChild(ordType);

    OMElement side = factory.createOMElement("field", null);
    side.addAttribute(factory.createOMAttribute("id", null, "54"));
    factory.createOMText(side, mode);
    body.addChild(side);

    OMElement symbol = factory.createOMElement("field", null);
    symbol.addAttribute(factory.createOMAttribute("id", null, "55"));
    factory.createOMText(symbol, text);
    body.addChild(symbol);

    OMElement timeInForce = factory.createOMElement("field", null);
    timeInForce.addAttribute(factory.createOMAttribute("id", null, "59"));
    factory.createOMText(timeInForce, "0");
    body.addChild(timeInForce);

    return body;
}
 
Example 8
Source File: PolicyUtil.java    From micro-integrator with Apache License 2.0 5 votes vote down vote up
public static OMElement getWrapper(String name) {
    OMFactory fac = OMAbstractFactory.getOMFactory();
    OMNamespace namespace = fac.createOMNamespace("", name);
    OMElement element = fac.createOMElement("Policy", namespace);
    OMAttribute attribute = fac.createOMAttribute("name", namespace, name);
    element.addAttribute(attribute);

    return element;
}
 
Example 9
Source File: XdsRegistryLifeCycleServiceImpl.java    From openxds with Apache License 2.0 5 votes vote down vote up
public OMElement submitObjects(OMElement request, RegistryLifeCycleContext context)  throws RegistryLifeCycleException {
	RequestContext omarContext;
	RegistryResponse omarResponse = null;
	OMElement response;
	
	final String contextId = "org:openhealthexchange:openxds:registry:adapter:omar31:XdsRegistryLifeCycleManager:submitObjects:context";
	try {
		InputStream is = new ByteArrayInputStream(request.toString().getBytes("UTF-8"));
		Object registryRequest = helper.getUnmarsheller().unmarshal(is);
		//Creating context with request.
		omarContext = new CommonRequestContext(contextId,(RegistryRequestType) registryRequest);
		//Adding RegistryOperator role for the user.
		omarContext.setUser(AuthenticationServiceImpl.getInstance().registryOperator);
		
		// Sending request to OMAR methods.
		omarResponse = lcm.submitObjects(omarContext);
		//Create RegistryResponse as OMElement
		response = helper.omFactory().createOMElement("RegistryResponse", helper.nsRs);
		response.declareNamespace(helper.nsRs);
		response.declareNamespace(helper.nsXsi);
		response.addAttribute("status", omarResponse.getStatus(), null);
	}
	catch (Exception e) {
		e.printStackTrace();
		throw new RegistryLifeCycleException(e.getMessage());
	}

	return response;
}
 
Example 10
Source File: OAuthMediatorSerializer.java    From micro-integrator with Apache License 2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
public OMElement serializeSpecificMediator(Mediator mediator) {

    if (!(mediator instanceof OAuthMediator)) {
        handleException("Unsupported mediator passed in for serialization : "
                + mediator.getType());
    }

    OAuthMediator oauth = null;
    OMElement oauthElem = null;

    oauth = (OAuthMediator) mediator;
    oauthElem = fac.createOMElement("oauthService", synNS);
    saveTracingState(oauthElem, oauth);
    oauthElem.addAttribute(fac.createOMAttribute("remoteServiceUrl", nullNS, oauth
            .getRemoteServiceUrl()));
    if (oauth.getUsername() != null) {
        oauthElem.addAttribute(fac.createOMAttribute("username", nullNS, oauth.getUsername()));
    }
    if (oauth.getPassword() != null) {
        oauthElem.addAttribute(fac.createOMAttribute("password", nullNS, oauth.getPassword()));
    }
    oauth = (OAuthMediator) mediator;

    serializeComments(oauthElem, ((OAuthMediator) mediator).getCommentsList());

    return oauthElem;
}
 
Example 11
Source File: TranslateToV2.java    From openxds with Apache License 2.0 5 votes vote down vote up
protected void copy_attributes(OMElement from, OMElement to) {
		String element_name = from.getLocalName();
		for (Iterator it=from.getAllAttributes(); it.hasNext();  ) {
			OMAttribute from_a = (OMAttribute) it.next();
			String name = from_a.getLocalName();
			String value = from_a.getAttributeValue();
			OMNamespace xml_namespace = MetadataSupport.xml_namespace;
			OMNamespace namespace = null;
			if (name.endsWith("status"))
				value = translate_att(value);
			else if (name.endsWith("associationType"))
				value = translate_att(value);
			else if (name.equals("minorVersion"))
				continue;
			else if (name.equals("majorVersion"))
				continue;
			else if (name.equals("lang"))
				namespace = xml_namespace;
			else if (name.equals("objectType") && value.startsWith("urn:oasis:names:tc:ebxml-regrep:ObjectType:RegistryObject:")) {
				String[] parts = value.split(":");
				value = parts[parts.length-1];
			}
//			else if (name.equals("objectType") && ! value.startsWith("urn:oasis:names:tc:ebxml-regrep:ObjectType:RegistryObject:"))
//			value = "urn:oasis:names:tc:ebxml-regrep:ObjectType:RegistryObject:" + value;
			OMAttribute to_a = MetadataSupport.om_factory.createOMAttribute(name, namespace, value);
			to.addAttribute(to_a);
		}
		
	}
 
Example 12
Source File: OperationSerializer.java    From micro-integrator with Apache License 2.0 5 votes vote down vote up
public static OMElement serializeOperation(Operation operation) {
	OMFactory fac = DBUtils.getOMFactory();
	OMElement opEl = fac.createOMElement(new QName(DBSFields.OPERATION));
	opEl.addAttribute(DBSFields.NAME, operation.getName(), null);
	String description = operation.getDescription();
	if (!DBUtils.isEmptyString(description)) {
		OMElement desEl = fac.createOMElement(new QName(DBSFields.DESCRIPTION));
		desEl.setText(description);
		opEl.addChild(desEl);
	}
	QuerySerializer.serializeCallQuery(operation.getCallQuery(), opEl, fac);
	return opEl;
}
 
Example 13
Source File: ParamParserTest.java    From openxds with Apache License 2.0 5 votes vote down vote up
void addSlot(String name, String value_string) {
	OMElement slot = om_factory().createOMElement("Slot", null);
	adhocquery.addChild(slot);
	slot.addAttribute("name", name, null);
	OMElement valuelist = om_factory().createOMElement("ValueList", null);
	slot.addChild(valuelist);
	OMElement value = om_factory().createOMElement("Value", null);
	valuelist.addChild(value);
	OMText text = om_factory().createOMText(value_string);
	value.addChild(text);
}
 
Example 14
Source File: Sq.java    From openxds with Apache License 2.0 5 votes vote down vote up
protected ArrayList<OMElement> build_query_wrapper(String query_id) {
	OMElement query = MetadataSupport.om_factory.createOMElement("AdhocQueryRequest", MetadataSupport.ebQns3);
	query.declareNamespace(MetadataSupport.ebRIMns3);
	OMElement response_option = MetadataSupport.om_factory.createOMElement("ResponseOption", MetadataSupport.ebQns3);
	query.addChild(response_option);
	response_option.addAttribute("returnComposedObjects", "true", null);
	response_option.addAttribute("returnType", "LeafClass", null);
	OMElement adhoc_query = MetadataSupport.om_factory.createOMElement("AdhocQuery", MetadataSupport.ebRIMns3);
	query.addChild(adhoc_query);
	adhoc_query.addAttribute("id", query_id, null);
	ArrayList<OMElement> elements = new ArrayList<OMElement>();
	elements.add(query);
	elements.add(adhoc_query);
	return elements;
}
 
Example 15
Source File: Metadata.java    From openxds with Apache License 2.0 5 votes vote down vote up
public OMElement addInternalClassification(OMElement classifiedObject,
		String classificationNode) {
	OMElement classification = MetadataSupport.om_factory.createOMElement(
			"Classification", null);
	classification.addAttribute("classificationNode", classificationNode,
			null);
	this.add_classification(classifiedObject, classification);
	return classification;
}
 
Example 16
Source File: TestSupport.java    From openxds with Apache License 2.0 4 votes vote down vote up
OMAttribute add_att(String name, String value, OMElement parent) {
	OMAttribute att = fac().createOMAttribute(name, null, value);
	parent.addAttribute(att);
	return att;
}
 
Example 17
Source File: BackendRegistry.java    From openxds with Apache License 2.0 4 votes vote down vote up
void insert_version_info(OMElement parent) {
	if (MetadataSupport.firstChildWithLocalName(parent, "VersionInfo") != null) return;
	OMElement vi = MetadataSupport.om_factory.createOMElement("VersionInfo", MetadataSupport.ebRIMns3);
	vi.addAttribute("versionName", "1.1", null);
	parent.addChild(vi);
}
 
Example 18
Source File: QuerySerializer.java    From micro-integrator with Apache License 2.0 4 votes vote down vote up
private static void serializePatternValidator(PatternValidator validator,
                                                 OMElement queryParamEl, OMFactory fac) {
   	OMElement valEl = fac.createOMElement(new QName(DBSFields.VALIDATE_PATTERN));
   	valEl.addAttribute(DBSFields.PATTERN, validator.getPattern().pattern(), null);
	queryParamEl.addChild(valEl);
}
 
Example 19
Source File: RimAxiom.java    From openxds with Apache License 2.0 3 votes vote down vote up
/**
 * Add a new ebXML Classification element to the parent element.
 *
 * @param parent The parent element this should be added to
 * @param classId The classification id
 * @param id The id of the registry object being classified
 * @param value The classification code asigned ot the registry object
 * @param scheme The classification scheme/axis that the code applies to
 * @param display A human-friendly display name for the code value
 * @param codingScheme The coding scheme from which the code value is drawn
 * @param rimNameSpace the rim name space of the root element
 * @return The new classification element
 */
public static OMElement addRimClassificationElement(OMElement parent, String classId, String id, String value,
                   String scheme, String display, String codingScheme, OMNamespace rimNameSpace) {
    OMElement classElement = addRimElement(parent, "Classification", rimNameSpace);
    classElement.addAttribute("id", classId, null);
    classElement.addAttribute("classificationScheme", scheme, null);
    classElement.addAttribute("classifiedObject", id, null);
    classElement.addAttribute("nodeRepresentation", value, null);
    addRimSlotElement(classElement, "codingScheme", codingScheme, rimNameSpace);
    addRimNameElement(classElement, display, rimNameSpace);
    return classElement;
}
 
Example 20
Source File: RimAxiom.java    From openxds with Apache License 2.0 3 votes vote down vote up
/**
 * Add a new ebXML Name element to the parent element.
 *
 * @param parent The parent element this should be added to
 * @param name The name data to put in the element
 * @param rimNameSpace the rim name space of the root element
 * @return The new name element
 */
public static OMElement addRimNameElement(OMElement parent, String name, OMNamespace rimNameSpace)  {
    OMElement nameElement = addRimElement(parent, "Name", rimNameSpace);
    OMElement localized = addRimElement(nameElement, "LocalizedString", rimNameSpace);
    localized.addAttribute("value", trimRimString(name, RIM_LONG_NAME), null);
    return nameElement;
}