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

The following examples show how to use org.apache.axiom.om.OMElement#detach() . 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: LBService1.java    From micro-integrator with Apache License 2.0 6 votes vote down vote up
public OMElement sleepOperation(OMElement param) throws AxisFault {

        param.build();
        param.detach();

        OMElement timeElement = param.getFirstChildWithName(new QName("load"));
        String time = timeElement.getText();
        try {
            Thread.sleep(Long.parseLong(time));
        } catch (InterruptedException e) {
            throw new AxisFault("Service is interrupted while sleeping.");
        }

        String sName = System.getProperty("server_name");
        if (sName != null) {
            timeElement.setText("Response from server: " + sName);
        } else {
            timeElement.setText("Response from anonymous server");
        }
        return param;
    }
 
Example 2
Source File: LBService2.java    From micro-integrator with Apache License 2.0 6 votes vote down vote up
public OMElement setClientName(OMElement name) {

        name.build();
        name.detach();

        String cName = name.getText();
        serviceContext.setProperty("cName", cName);

        String sName = "anonymous";
        Object s = System.getProperty("server_name");
        if (s != null) {
            sName = (String) s;
        }

        String msg = "Server " + sName + " started a session with client " + cName;
        System.out.println(msg);
        name.setText(msg);

        return name;
    }
 
Example 3
Source File: LBService1.java    From micro-integrator with Apache License 2.0 6 votes vote down vote up
public OMElement sampleOperation(OMElement param) {
    param.build();
    param.detach();

    String sName = "";
    if (System.getProperty("test_mode") != null) {
        sName = org.apache.axis2.context.MessageContext.getCurrentMessageContext().getTo().getAddress();
    } else {
        sName = System.getProperty("server_name");
    }
    if (sName != null) {
        param.setText("Response from server: " + sName);
    } else {
        param.setText("Response from anonymous server");
    }
    return param;
}
 
Example 4
Source File: LBService1.java    From micro-integrator with Apache License 2.0 6 votes vote down vote up
public OMElement loadOperation(OMElement param) throws AxisFault {

        param.build();
        param.detach();

        OMElement loadElement = param.getFirstChildWithName(new QName("load"));
        String l = loadElement.getText();
        long load = Long.parseLong(l);

        for (long i = 0; i < load; i++) {
            System.out.println("Iteration: " + i);
        }

        String sName = System.getProperty("server_name");
        if (sName != null) {
            loadElement.setText("Response from server: " + sName);
        } else {
            loadElement.setText("Response from anonymous server");
        }
        return param;
    }
 
Example 5
Source File: LBService1.java    From product-ei with Apache License 2.0 6 votes vote down vote up
public OMElement sampleOperation(OMElement param) {
    param.build();
    param.detach();
    
    String sName = "";
    if (System.getProperty("test_mode") != null) {
        sName = org.apache.axis2.context.MessageContext.getCurrentMessageContext().getTo().getAddress();
    } else {
        sName = System.getProperty("server_name");
    }
    if (sName != null) {
        param.setText("Response from server: " + sName);
    } else {
        param.setText("Response from anonymous server");
    }
    return param;
}
 
Example 6
Source File: LBService1.java    From product-ei with Apache License 2.0 6 votes vote down vote up
public OMElement sleepOperation(OMElement param) throws AxisFault {

        param.build();
        param.detach();

        OMElement timeElement = param.getFirstChildWithName(new QName("load"));
        String time = timeElement.getText();
        try {
            Thread.sleep(Long.parseLong(time));
        } catch (InterruptedException e) {
            throw new AxisFault("Service is interrupted while sleeping.");
        }

        String sName = System.getProperty("server_name");
        if (sName != null) {
            timeElement.setText("Response from server: " + sName);
        } else {
            timeElement.setText("Response from anonymous server");
        }
        return param;
    }
 
Example 7
Source File: TableReportMetaDataHandler.java    From carbon-commons with Apache License 2.0 6 votes vote down vote up
private void removeTableMetadata(String reportName) {
    Iterator iterator = reportsElement.getChildElements();
    boolean isTableFound = false;

    while (iterator.hasNext()) {
        OMElement reportElement = (OMElement) iterator.next();
        String reportType = reportElement.getAttributeValue(new QName(TYPE));
        if (reportType.equalsIgnoreCase(ReportConstants.TABLE_TYPE)) {
            Iterator tableIterator = reportElement.getChildElements();
            while (tableIterator.hasNext()) {
                OMElement tableReportElement = (OMElement) tableIterator.next();
                String tableName = tableReportElement.getAttributeValue(new QName(NAME));
                if (tableName.equalsIgnoreCase(reportName)) {
                    reportElement.detach();
                    isTableFound = true;
                    return;
                }
            }
        }

        if (isTableFound) break;
    }
}
 
Example 8
Source File: LBService1.java    From micro-integrator with Apache License 2.0 6 votes vote down vote up
public OMElement sleepOperation(OMElement param) throws AxisFault {

        param.build();
        param.detach();

        OMElement timeElement = param.getFirstChildWithName(new QName("load"));
        String time = timeElement.getText();
        try {
            Thread.sleep(Long.parseLong(time));
        } catch (InterruptedException e) {
            throw new AxisFault("Service is interrupted while sleeping.");
        }

        String sName = System.getProperty("server_name");
        if (sName != null) {
            timeElement.setText("Response from server: " + sName);
        } else {
            timeElement.setText("Response from anonymous server");
        }
        return param;
    }
 
Example 9
Source File: LBService1.java    From product-ei with Apache License 2.0 6 votes vote down vote up
public OMElement loadOperation(OMElement param) throws AxisFault {

        param.build();
        param.detach();

        OMElement loadElement = param.getFirstChildWithName(new QName("load"));
        String l = loadElement.getText();
        long load = Long.parseLong(l);

        for (long i = 0; i < load; i++) {
            System.out.println("Iteration: " + i);
        }

        String sName = System.getProperty("server_name");
        if (sName != null) {
            loadElement.setText("Response from server: " + sName);
        } else {
            loadElement.setText("Response from anonymous server");
        }
        return param;
    }
 
Example 10
Source File: LBService1.java    From micro-integrator with Apache License 2.0 6 votes vote down vote up
public OMElement loadOperation(OMElement param) throws AxisFault {

        param.build();
        param.detach();

        OMElement loadElement = param.getFirstChildWithName(new QName("load"));
        String l = loadElement.getText();
        long load = Long.parseLong(l);

        for (long i = 0; i < load; i++) {
            System.out.println("Iteration: " + i);
        }

        String sName = System.getProperty("server_name");
        if (sName != null) {
            loadElement.setText("Response from server: " + sName);
        } else {
            loadElement.setText("Response from anonymous server");
        }
        return param;
    }
 
Example 11
Source File: MetadataModel.java    From openxds with Apache License 2.0 5 votes vote down vote up
public MetadataModel removeClassifications(String classificationScheme) {
	List cls = m.findClassifications(me, classificationScheme);
	for (int i=0; i<cls.size(); i++) {
		OMElement cl = (OMElement) cls.get(i);
		cl.detach();
	}
	return this;
}
 
Example 12
Source File: Metadata.java    From openxds with Apache License 2.0 5 votes vote down vote up
public void rmObject(OMElement ele) {
	if (ele.getParent() != null)
		ele.detach();
	List<List<OMElement>> containers = this.get_metadata_containers();
	for (List<OMElement> container : containers)
		container.remove(ele);
}
 
Example 13
Source File: Metadata.java    From openxds with Apache License 2.0 5 votes vote down vote up
/**
 * Move top-level classifications under the objects they classification.
 * Classification object can be top-level objects or nested inside the
 * objects they classify. Move all top-level classifications under the
 * objects they classify.
 */
public void embedClassifications() throws MetadataException {
	for (OMElement classification : classifications) {
		String classified_object_id = classification
				.getAttributeValue(MetadataSupport.classified_object_qname);
		OMElement classified_object = this
				.getObjectById(classified_object_id);
		classification.detach();
		classified_object.addChild(classification);
		allObjects.remove(classification);
	}
	classifications.clear();
}
 
Example 14
Source File: LBService2.java    From micro-integrator with Apache License 2.0 4 votes vote down vote up
public OMElement loadOperation(OMElement topParam) {

        topParam.build();
        topParam.detach();

        OMElement param = topParam.getFirstChildWithName(new QName("load"));
        String l = param.getText();
        long load = Long.parseLong(l);

        for (long i = 0; i < load; i++) {
            System.out.println("Iteration: " + i);
        }

        Long c = null;
        Object o = serviceContext.getProperty("count");
        if (o == null) {
            c = new Long(1);
            serviceContext.setProperty("count", c);
        } else {
            c = (Long) o;
            c = new Long(c.longValue() + 1);
            serviceContext.setProperty("count", c);
        }

        String cName = "anonymous";
        Object cn = serviceContext.getProperty("cName");
        if (cn != null) {
            cName = (String) cn;

        }

        String sName = "anonymous";
        Object s = System.getProperty("server_name");
        if (s != null) {
            sName = (String) s;
        }

        String msg = "Server: " + sName + " processed the request " + c.toString() + " from client: " + cName;
        System.out.println(msg);

        param.setText(msg);

        return topParam;
    }
 
Example 15
Source File: ParameterUtil.java    From micro-integrator with Apache License 2.0 4 votes vote down vote up
/**
 * Create an Axis2 parameter using the given OMElement
 *
 * @param parameterElement The OMElement of the parameter
 * @return Axis2 parameter with an the given OMElement
 * @throws AxisFault If the <code>parameterElement</code> is malformed
 */
public static Parameter createParameter(OMElement parameterElement) throws AxisFault {
    if(parameterElement.getParent() instanceof OMDocument) {
        parameterElement.detach();  //To enable a unified way of accessing the parameter via xpath.
    }
    Parameter parameter = new Parameter();
    //setting parameterElement
    parameter.setParameterElement(parameterElement);

    //setting parameter Name
    OMAttribute paraName = parameterElement.getAttribute(new QName("name"));
    if (paraName == null) {
        throw new AxisFault(Messages.getMessage(DeploymentErrorMsgs.BAD_PARAMETER_ARGUMENT));
    }
    parameter.setName(paraName.getAttributeValue());

    //setting parameter Value (the chiled elemnt of the parameter)
    OMElement paraValue = parameterElement.getFirstElement();
    if (paraValue != null) {
        parameter.setValue(parameterElement);
        parameter.setParameterType(Parameter.OM_PARAMETER);
    } else {
        String paratextValue = parameterElement.getText();
        parameter.setValue(paratextValue);
        parameter.setParameterType(Parameter.TEXT_PARAMETER);
    }

    //setting locking attribute
    OMAttribute paraLocked = parameterElement.getAttribute(new QName("locked"));
    parameter.setParameterElement(parameterElement);

    if (paraLocked != null) {
        String lockedValue = paraLocked.getAttributeValue();
        if ("true".equals(lockedValue)) {

            parameter.setLocked(true);

        } else {
            parameter.setLocked(false);
        }
    }
    return parameter;
}
 
Example 16
Source File: Metadata.java    From openxds with Apache License 2.0 4 votes vote down vote up
public void rmObjectRefs() {
	for (OMElement or : objectRefs) {
		if (or.getParent() != null)
			or.detach();
	}
}
 
Example 17
Source File: LBService2.java    From micro-integrator with Apache License 2.0 4 votes vote down vote up
public OMElement sleepOperation(OMElement topParam) {

        topParam.build();
        topParam.detach();

        OMElement param = topParam.getFirstChildWithName(new QName("load"));
        String l = param.getText();
        long time = Long.parseLong(l);

        try {
            Thread.sleep(time);
        } catch (InterruptedException e) {
            e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
        }

        Long c = null;
        Object o = serviceContext.getProperty("count");
        if (o == null) {
            c = new Long(1);
            serviceContext.setProperty("count", c);
        } else {
            c = (Long) o;
            c = new Long(c.longValue() + 1);
            serviceContext.setProperty("count", c);
        }

        String cName = "anonymous";
        Object cn = serviceContext.getProperty("cName");
        if (cn != null) {
            cName = (String) cn;

        }

        String sName = "anonymous";
        Object s = System.getProperty("server_name");
        if (s != null) {
            sName = (String) s;
        }

        String msg = "Server: " + sName + " processed the request " + c.toString() + " from client: " + cName;
        System.out.println(msg);

        param.setText(msg);

        return topParam;
    }
 
Example 18
Source File: LBService2.java    From micro-integrator with Apache License 2.0 4 votes vote down vote up
public OMElement sleepOperation(OMElement topParam) {

        topParam.build();
        topParam.detach();

        OMElement param = topParam.getFirstChildWithName(new QName("load"));
        String l = param.getText();
        long time = Long.parseLong(l);

        try {
            Thread.sleep(time);
        } catch (InterruptedException e) {
            e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
        }

        Long c = null;
        Object o = serviceContext.getProperty("count");
        if (o == null) {
            c = new Long(1);
            serviceContext.setProperty("count", c);
        } else {
            c = (Long) o;
            c = new Long(c.longValue() + 1);
            serviceContext.setProperty("count", c);
        }

        String cName = "anonymous";
        Object cn = serviceContext.getProperty("cName");
        if (cn != null) {
            cName = (String) cn;

        }

        String sName = "anonymous";
        Object s = System.getProperty("server_name");
        if (s != null) {
            sName = (String) s;
        }

        String msg = "Server: " + sName + " processed the request " + c.toString() + " from client: " + cName;
        System.out.println(msg);

        param.setText(msg);

        return topParam;
    }
 
Example 19
Source File: LBService1.java    From micro-integrator with Apache License 2.0 3 votes vote down vote up
public OMElement setClientName(OMElement cName) {

        cName.build();
        cName.detach();

        cName.setText("Sessions are not supported in this service.");

        return cName;
    }
 
Example 20
Source File: LBService1.java    From micro-integrator with Apache License 2.0 3 votes vote down vote up
public OMElement setClientName(OMElement cName) {

        cName.build();
        cName.detach();

        cName.setText("Sessions are not supported in this service.");

        return cName;
    }