Java Code Examples for org.apache.axiom.om.OMFactory#createOMElement()

The following examples show how to use org.apache.axiom.om.OMFactory#createOMElement() . 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: TableReportMetaDataHandler.java    From carbon-commons with Apache License 2.0 6 votes vote down vote up
private void createTableReportColumnData(int id, ColumnDTO column) {
    OMFactory fac = OMAbstractFactory.getOMFactory();
    OMElement columnElement = fac.createOMElement(new QName(COLUMN));

    OMElement columnId = fac.createOMElement(new QName(COLUMN_ID));
    columnId.setText(String.valueOf(id));
    columnElement.addChild(columnId);

    OMElement columnTable = fac.createOMElement(new QName(COLUMN_DATA_TABLE));
    columnTable.setText(column.getColumnFamilyName());
    columnElement.addChild(columnTable);

    OMElement columnField = fac.createOMElement(new QName(COLUMN_DATA_FIELD));
    columnField.setText(column.getColumnName());
    columnElement.addChild(columnField);

    OMElement primaryColElement = fac.createOMElement(new QName(PRIMARY_COLUMN));
    if (column.isPrimaryColumn()) {
        primaryColElement.setText(PRIMARY_COLUMN_TRUE);
    } else {
        primaryColElement.setText(PRIMARY_COLUMN_FALSE);
    }
    columnElement.addChild(primaryColElement);

    tableReportElement.addChild(columnElement);
}
 
Example 2
Source File: QuerySerializer.java    From micro-integrator with Apache License 2.0 6 votes vote down vote up
private static void serializeGSpreadQueryProps(GSpreadQuery gspreadQuery, OMElement queryEl, OMFactory fac) {
	OMElement gspreadEl = fac.createOMElement(new QName(DBSFields.GSPREAD));
	OMElement worksheetnumberEl = fac.createOMElement(
			new QName(DBConstants.GSpread.WORKSHEET_NUMBER));
	OMElement hasheaderEl = fac.createOMElement(new QName(DBConstants.GSpread.HAS_HEADER));
	OMElement startingrowEl = fac.createOMElement(
			new QName(DBConstants.GSpread.STARTING_ROW));
	OMElement maxrowcountEl = fac.createOMElement(
			new QName(DBConstants.GSpread.MAX_ROW_COUNT));
	worksheetnumberEl.setText(String.valueOf(gspreadQuery.getWorksheetNumber()));
	hasheaderEl.setText(String.valueOf(gspreadQuery.isHasHeader()));
	startingrowEl.setText(String.valueOf(gspreadQuery.getStartingRow()));
	maxrowcountEl.setText(String.valueOf(gspreadQuery.getMaxRowCount()));
	gspreadEl.addChild(worksheetnumberEl);
	gspreadEl.addChild(hasheaderEl);
	gspreadEl.addChild(startingrowEl);
	gspreadEl.addChild(maxrowcountEl);
	queryEl.addChild(gspreadEl);
}
 
Example 3
Source File: CallOutMediatorWithMTOMTestCase.java    From product-ei with Apache License 2.0 6 votes vote down vote up
public void sendUsingMTOM(String fileName, String targetEPR) throws IOException {
    OMFactory factory = OMAbstractFactory.getOMFactory();
    OMNamespace ns = factory.createOMNamespace("http://services.samples", "m0");
    OMElement payload = factory.createOMElement("uploadFileUsingMTOM", ns);
    OMElement request = factory.createOMElement("request", ns);
    OMElement image = factory.createOMElement("image", ns);

    FileDataSource fileDataSource = new FileDataSource(new File(fileName));
    DataHandler dataHandler = new DataHandler(fileDataSource);
    OMText textData = factory.createOMText(dataHandler, true);
    image.addChild(textData);
    request.addChild(image);
    payload.addChild(request);

    ServiceClient serviceClient = new ServiceClient();
    Options options = new Options();
    options.setTo(new EndpointReference(targetEPR));
    options.setAction("urn:uploadFileUsingMTOM");
    options.setProperty(Constants.Configuration.ENABLE_MTOM, Constants.VALUE_TRUE);
    options.setCallTransportCleanup(true);
    serviceClient.setOptions(options);
    OMElement response = serviceClient.sendReceive(payload);
    Assert.assertTrue(response.toString().contains(
            "<m:testMTOM xmlns:m=\"http://services.samples/xsd\">" + "<m:test1>testMTOM</m:test1></m:testMTOM>"));
}
 
Example 4
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 5
Source File: HeaderFactory.java    From garoon-google with MIT License 6 votes vote down vote up
/**
 * ヘッダ内のログイン情報に関するノードを生成します。
 * @return org.apache.axiom.om.OMElement ログイン情報
 */
private static OMElement getSecurityElement(String username, String password) {
    OMFactory omFactory = OMAbstractFactory.getOMFactory();
    OMNamespace securityNs = omFactory.createOMNamespace("http://schemas.xmlsoap.org/ws/2002/12/secext", "");
    OMElement securityElement = omFactory.createOMElement("Security", securityNs);

    OMElement usernameTokenElement = omFactory.createOMElement("UsernameToken", securityNs);

    OMElement usernameElement = omFactory.createOMElement("Username", securityNs);
    usernameElement.addChild(omFactory.createOMText(usernameElement, username));

    OMElement passwordElement = omFactory.createOMElement("Password", securityNs);
    passwordElement.addChild(omFactory.createOMText(passwordElement, password));

    usernameTokenElement.addChild(usernameElement);
    usernameTokenElement.addChild(passwordElement);
    securityElement.addChild(usernameTokenElement);

    return securityElement;
}
 
Example 6
Source File: MultipleServicesGeneratorTestCase.java    From micro-integrator with Apache License 2.0 5 votes vote down vote up
private OMElement getPayloadService2() {
    OMFactory fac = OMAbstractFactory.getOMFactory();
    OMNamespace omNs = fac.createOMNamespace("http://wso2.example.org", "wso2");

    OMElement payload = fac.createOMElement("select_with_key_REG_PROPERTY_operation", omNs);
    OMElement id = fac.createOMElement("REG_ID", omNs);
    id.setText("1");
    payload.addChild(id);
    return payload;
}
 
Example 7
Source File: TcpClient.java    From product-ei with Apache License 2.0 5 votes vote down vote up
private OMElement createStandardRequest(String symbol) {
    OMFactory fac = OMAbstractFactory.getOMFactory();
    OMNamespace omNs = fac.createOMNamespace("http://services.samples", "ns");
    OMElement method = fac.createOMElement("getQuote", omNs);
    OMElement value1 = fac.createOMElement("request", omNs);
    OMElement value2 = fac.createOMElement("symbol", omNs);

    value2.addChild(fac.createOMText(value1, symbol));
    value1.addChild(value2);
    method.addChild(value1);

    return method;
}
 
Example 8
Source File: StockQuoteHandler.java    From micro-integrator with Apache License 2.0 5 votes vote down vote up
/**
 * Create a new custom quote request with a body as follows
 * <m0:CheckPriceRequest xmlns:m0="http://services.samples">
 *   <m0:Code>symbol</m0:Code>
 * </m0:CheckPriceRequest>
 * @param symbol the stock symbol
 * @return OMElement for SOAP body
 */
public static OMElement createCustomQuoteRequest(String symbol) {
    OMFactory factory   = OMAbstractFactory.getOMFactory();
    OMNamespace ns      = factory.createOMNamespace(
        "http://services.samples", "m0");
    OMElement chkPrice  = factory.createOMElement("CheckPriceRequest", ns);
    OMElement code      = factory.createOMElement("Code", ns);
    chkPrice.addChild(code);
    code.setText(symbol);
    return chkPrice;
}
 
Example 9
Source File: ESBJAVA2006RetryOnSOAPFaultTestCase.java    From micro-integrator with Apache License 2.0 5 votes vote down vote up
public OMElement getThrowAxisFaultRequest() {
    OMFactory factory = OMAbstractFactory.getOMFactory();
    OMNamespace ns = factory.createOMNamespace("http://processor.message.mediator.carbon.wso2.org", "proc");
    OMElement throwFault = factory.createOMElement("throwAxisFault", ns);
    OMElement str = factory.createOMElement("s", ns);
    str.setText("Throw_Fault");
    throwFault.addChild(str);

    return throwFault;
}
 
Example 10
Source File: SQLDriverGspreadSheetTestCase.java    From micro-integrator with Apache License 2.0 5 votes vote down vote up
private OMElement getPayload() {
    OMFactory fac = OMAbstractFactory.getOMFactory();
    OMNamespace omNs = fac
            .createOMNamespace("http://ws.wso2.org/dataservice/samples" + "/gspread_sql_driver_sample_service",
                    "gsp");
    return fac.createOMElement("getCustomersSQL", omNs);
}
 
Example 11
Source File: RequestUtil.java    From micro-integrator with Apache License 2.0 5 votes vote down vote up
private OMElement getCustomPayload(String symbol) {
    OMFactory fac = OMAbstractFactory.getOMFactory();
    OMNamespace omNs = fac.createOMNamespace("http://services.samples", "ns");
    OMElement payload = fac.createOMElement("getQuote", omNs);
    OMElement request = fac.createOMElement("request", omNs);
    OMElement symbols = fac.createOMElement("symbols", omNs);

    OMElement company = fac.createOMElement("company", omNs);
    company.setText(symbol);

    symbols.addChild(company);
    request.addChild(symbols);
    payload.addChild(request);
    return payload;
}
 
Example 12
Source File: DigestAuthMediator.java    From carbon-apimgt with Apache License 2.0 5 votes vote down vote up
/**
 * Generates fault payload
 * @param errorMessage
 * @param errorDesc
 * @return
 */
protected OMElement getFaultPayload(String errorMessage, String errorDesc) {
    OMFactory fac = OMAbstractFactory.getOMFactory();
    OMNamespace ns = fac
            .createOMNamespace(APISecurityConstants.API_SECURITY_NS, APISecurityConstants.API_SECURITY_NS_PREFIX);
    OMElement payload = fac.createOMElement("fault", ns);
    OMElement errorMessageElement = fac.createOMElement("message", ns);
    errorMessageElement.setText(errorMessage);
    OMElement errorDetail = fac.createOMElement("description", ns);
    errorDetail.setText(errorDesc);
    payload.addChild(errorMessageElement);
    payload.addChild(errorDetail);
    return payload;
}
 
Example 13
Source File: Sample153TestCase.java    From product-ei with Apache License 2.0 5 votes vote down vote up
private OMElement getPayload() {
    OMFactory fac = OMAbstractFactory.getOMFactory();
    OMNamespace omNs = fac.createOMNamespace("http://services.samples", "ns");
    OMElement method = fac.createOMElement("getQuote", omNs);
    OMElement value1 = fac.createOMElement("request", omNs);
    OMElement value2 = fac.createOMElement("symbol", omNs);

    value2.addChild(fac.createOMText(value1, "Secured"));
    value1.addChild(value2);
    method.addChild(value1);

    return method;
}
 
Example 14
Source File: APIGatewayAdminTest.java    From carbon-apimgt with Apache License 2.0 5 votes vote down vote up
@Test
public void getSequenceForTenant() throws Exception {
    RESTAPIAdminServiceProxy restapiAdminServiceProxy = Mockito.mock(RESTAPIAdminServiceProxy.class);
    EndpointAdminServiceProxy endpointAdminServiceProxy = Mockito.mock(EndpointAdminServiceProxy.class);
    SequenceAdminServiceProxy sequenceAdminServiceProxy = Mockito.mock(SequenceAdminServiceProxy.class);
    OMFactory fac = OMAbstractFactory.getOMFactory();
    OMElement test1 = fac.createOMElement("test1", "", "");
    Mockito.when(sequenceAdminServiceProxy.getSequence(name)).thenReturn(test1);
    APIGatewayAdmin apiGatewayAdmin = new APIGatewayAdminWrapper(restapiAdminServiceProxy, endpointAdminServiceProxy,
            sequenceAdminServiceProxy);
    Assert.assertEquals(apiGatewayAdmin.getSequence(name), test1);
}
 
Example 15
Source File: QuerySerializer.java    From micro-integrator with Apache License 2.0 5 votes vote down vote up
private static void serializeQueryParams(List<QueryParam> queryParams,
		OMElement queryEl, OMFactory fac) {
	OMElement queryParamEl;
	String paramType, sqlType, type;
	int ordinal;
	ParamValue defaultValue;
	for (QueryParam queryParam : queryParams) {
		queryParamEl = fac.createOMElement(new QName(DBSFields.PARAM));
		queryParamEl.addAttribute(DBSFields.NAME, queryParam.getName(), null);
		paramType = queryParam.getParamType();
		if (paramType != null) {
			queryParamEl.addAttribute(DBSFields.PARAM_TYPE, paramType, null);
		}
		sqlType = queryParam.getSqlType();
		if (sqlType != null) {
			queryParamEl.addAttribute(DBSFields.SQL_TYPE, sqlType, null);
		}
		type = queryParam.getType();
		if (type != null) {
			queryParamEl.addAttribute(DBSFields.TYPE, type, null);
		}
		ordinal = queryParam.getOrdinal();
		if (ordinal > 0) {
			queryParamEl.addAttribute(DBSFields.ORDINAL, String.valueOf(ordinal), null);
		}
		defaultValue = queryParam.getDefaultValue();
		if (defaultValue != null && defaultValue.getScalarValue() != null) {
			queryParamEl.addAttribute(DBSFields.ORDINAL, defaultValue.getScalarValue(), null);
		}
		/* add validators */
		serializeValidators(queryParam.getValidators(), queryParamEl, fac);
		/* add queryParam to query */
		queryEl.addChild(queryParamEl);
	}	
}
 
Example 16
Source File: AxisServiceClientUtils.java    From product-ei with Apache License 2.0 5 votes vote down vote up
private static OMElement createPayLoad() {
    OMFactory fac = OMAbstractFactory.getOMFactory();
    OMNamespace omNs = fac.createOMNamespace("http://test.com", "test");
    OMElement method = fac.createOMElement("add", omNs);
    OMElement valueOfa = fac.createOMElement("a", omNs);
    OMElement valueOfb = fac.createOMElement("b", omNs);
    valueOfa.addChild(fac.createOMText(valueOfa, "200"));
    valueOfb.addChild(fac.createOMText(valueOfb, "220"));
    method.addChild(valueOfa);
    method.addChild(valueOfb);

    return method;
}
 
Example 17
Source File: Utils.java    From product-ei with Apache License 2.0 5 votes vote down vote up
public static OMElement getSimpleQuoteRequest(String symbol) {
    OMFactory fac = OMAbstractFactory.getOMFactory();
    OMNamespace omNs = fac.createOMNamespace("http://services.samples", "ns");
    OMElement omGetQuote = fac.createOMElement("getSimpleQuote", omNs);
    OMElement value1 = fac.createOMElement("symbol", omNs);

    value1.addChild(fac.createOMText(omGetQuote, symbol));
    omGetQuote.addChild(value1);

    return omGetQuote;
}
 
Example 18
Source File: StockQuoteHandler.java    From micro-integrator with Apache License 2.0 5 votes vote down vote up
/**
 * Create a new full quote request with a body as follows
 *  <m:GetFullQuote xmlns:m="http://services.samples">
 *      <m:request>
 *          <m:symbol>IBM</m:symbol>
 *      </m:request>
 *  </m:GetFullQuote>
 * @param symbol the stock symbol
 * @return OMElement for SOAP body
 */
public static OMElement createFullQuoteRequest(String symbol) {
    OMFactory factory   = OMAbstractFactory.getOMFactory();
    OMNamespace ns      = factory.createOMNamespace("http://services.samples", "m0");
    OMElement getQuote  = factory.createOMElement("getFullQuote", ns);
    OMElement request   = factory.createOMElement("request", ns);
    OMElement symb      = factory.createOMElement("symbol", ns);
    request.addChild(symb);
    getQuote.addChild(request);
    symb.setText(symbol);
    return getQuote;
}
 
Example 19
Source File: DBUtils.java    From micro-integrator with Apache License 2.0 5 votes vote down vote up
/**
 * Creates OMElement using error details.
 */
public static OMElement createDSFaultOM(String msg) {
    OMFactory fac = OMAbstractFactory.getOMFactory();
    OMElement ele = fac.createOMElement(new QName(
            DBConstants.WSO2_DS_NAMESPACE, DBConstants.DS_FAULT_ELEMENT));
    ele.setText(msg);
    return ele;
}
 
Example 20
Source File: MultipleServicesGeneratorTestCase.java    From micro-integrator with Apache License 2.0 4 votes vote down vote up
private OMElement getPayloadService1() {
    OMFactory fac = OMAbstractFactory.getOMFactory();
    OMNamespace omNs = fac.createOMNamespace("http://wso2.example.org", "wso2");
    return fac.createOMElement("select_all_REG_PATH_operation", omNs);
}