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

The following examples show how to use org.apache.axiom.om.OMElement#declareNamespace() . 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: XdsRegistryLifeCycleServiceTest.java    From openxds with Apache License 2.0 6 votes vote down vote up
/**
	 * Create a new SubmitObjectsRequest as an Axiom OMElement
	 * 
	 * @param submissionSet
	 *            The xds submission set for the request
	 * @param documentEntries
	 *            The xds document entries for the request
	 * @param connection
	 *            The connection that will be used for the request
	 * @throws XdsRimException
	 *             When the metadata cannot be encoded into a valid ebRIM
	 *             XML
	 */
private OMElement getsubmitObjectsRequest() {
	
	OMElement submitObjectsRequest = helper.omFactory.createOMElement("SubmitObjectsRequest", helper.nsLcm);
	submitObjectsRequest.declareNamespace(helper.ns);
	submitObjectsRequest.declareNamespace(helper.nsXsi);
	submitObjectsRequest.declareNamespace(helper.nsLcm);
	submitObjectsRequest.declareNamespace(helper.nsRim);		
	submitObjectsRequest.declareNamespace(helper.nsRs);
	//submitObjectsRequest.addAttribute("schemaLocation", XDS_b_REGISTRY_SCHEMA_LOCATION, nsXsi);
	try {
		OMElement registryObjectList = helper.omFactory().createOMElement("RegistryObjectList", helper.nsRim);
		submitObjectsRequest.addChild(registryObjectList);
		String docId = "urn:uuid:0520abda-8944-4463-b715-844a6785f2ab";
		registryObjectList.addChild(getExtrinsicObject(docId, "text/xml"));
		String setId = "urn:uuid:08e6330f-1a7d-4099-be06-96cf8e6edae2";
		registryObjectList.addChild(getRegistryPackage(setId));
		RimAxiom.addRimClassificationElement(registryObjectList, "cl-ss0", setId, XDS_SUBMISSION_SET, helper.nsRim);
		// Link the document entries to the submission set
		RimAxiom.addRimSubmissionDocumentAssociationElement(registryObjectList, setId, docId, helper.nsRim);

	} catch (Exception e) {
		log.debug(e.getMessage());
	}
	return submitObjectsRequest;
}
 
Example 2
Source File: DiscoveryOMUtils.java    From carbon-commons with Apache License 2.0 6 votes vote down vote up
private static OMElement serializeQNamesList(QName[] qnames, QName topElement,
                                            OMFactory factory) {

    OMElement wrapperElement = factory.createOMElement(topElement);
    StringBuffer qnamesTxt = new StringBuffer();
    boolean firstEntry = true;
    for (QName qname : qnames) {
        if (!firstEntry) {
            qnamesTxt.append(" ");
        }

        OMNamespace ns = wrapperElement.declareNamespace(qname.getNamespaceURI(),
                qname.getPrefix());
        qnamesTxt.append(ns.getPrefix() + ":" + qname.getLocalPart());
        firstEntry = false;
    }
    wrapperElement.setText(qnamesTxt.toString());
    return wrapperElement;
}
 
Example 3
Source File: DataTypesTestCase.java    From micro-integrator with Apache License 2.0 5 votes vote down vote up
/**
 * Method to test insertion of timestamp value.
 *
 * @throws Exception
 */
@Test(groups = {
        "wso2.dss" }, description = "insert null value as timestamp value and check it's successful", alwaysRun = true)
public void insertTimestampNullTest() throws Exception {
    OMElement insertTimeStampPayload = fac.createOMElement("addDeveloper", omNs);

    OMNamespace nullNameSpace = fac.createOMNamespace("http://www.w3.org/2001/XMLSchema-instance", "xsi");
    insertTimeStampPayload.declareNamespace(nullNameSpace);

    OMElement devId = fac.createOMElement("devId", omNs);
    devId.setText(2 + "");
    insertTimeStampPayload.addChild(devId);

    OMElement devName = fac.createOMElement("devName", omNs);
    devName.setText("name2");
    insertTimeStampPayload.addChild(devName);

    OMElement devdob = fac.createOMElement("devdob", omNs);
    OMAttribute nullAttribute = fac.createOMAttribute("nil", nullNameSpace, "true");
    devdob.addAttribute(nullAttribute);
    insertTimeStampPayload.addChild(devdob);

    new AxisServiceClient().sendRobust(insertTimeStampPayload, getServiceUrlHttp(serviceName), "addDeveloper");

    OMElement getDeveloperByIdPayload = fac.createOMElement("select_developers_by_id_operation", omNs);
    getDeveloperByIdPayload.addChild(devId);

    //retrieve and see whether inserted correctly
    OMElement responseProduct = new AxisServiceClient()
            .sendReceive(getDeveloperByIdPayload, getServiceUrlHttp(serviceName),
                    "select_developers_by_id_operation");
    assertNotNull(responseProduct, "Response null " + responseProduct);
    assertTrue(responseProduct.toString().contains("<devdob"), "'devdob' should have exist in the response");
    log.info("Insert TimeStamp Operation Success");
}
 
Example 4
Source File: DataTypesTestCase.java    From product-ei with Apache License 2.0 5 votes vote down vote up
/**
 * Method to test insertion of timestamp value.
 *
 * @throws Exception
 */
@Test(groups = {"wso2.dss"}, description = "insert null value as timestamp value and check it's successful", alwaysRun = true)
public void insertTimestampNullTest() throws Exception {
    OMElement insertTimeStampPayload = fac.createOMElement("addDeveloper", omNs);

    OMNamespace nullNameSpace = fac.createOMNamespace("http://www.w3.org/2001/XMLSchema-instance", "xsi");
    insertTimeStampPayload.declareNamespace(nullNameSpace);

    OMElement devId = fac.createOMElement("devId", omNs);
    devId.setText(2 + "");
    insertTimeStampPayload.addChild(devId);

    OMElement devName = fac.createOMElement("devName", omNs);
    devName.setText("name2");
    insertTimeStampPayload.addChild(devName);

    OMElement devdob = fac.createOMElement("devdob", omNs);
    OMAttribute nullAttribute = fac.createOMAttribute("nil", nullNameSpace,"true");
    devdob.addAttribute(nullAttribute);
    insertTimeStampPayload.addChild(devdob);

    new AxisServiceClient().sendRobust(insertTimeStampPayload, getServiceUrlHttp(serviceName), "addDeveloper");

    OMElement getDeveloperByIdPayload = fac.createOMElement("select_developers_by_id_operation", omNs);
    getDeveloperByIdPayload.addChild(devId);

    //retrieve and see whether inserted correctly
    OMElement responseProduct = new AxisServiceClient().sendReceive(getDeveloperByIdPayload, getServiceUrlHttp(serviceName), "select_developers_by_id_operation");
    assertNotNull(responseProduct, "Response null " + responseProduct);
    assertTrue(responseProduct.toString().contains("<devdob"), "'devdob' should have exist in the response");
    log.info("Insert TimeStamp Operation Success");
}
 
Example 5
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 6
Source File: XdsRegistryLifeCycleServiceTest.java    From openxds with Apache License 2.0 5 votes vote down vote up
public OMElement getApproveObjectsRequest() {
	OMElement req = helper.omFactory.createOMElement("ApproveObjectsRequest", helper.nsLcm);
	req.declareNamespace(helper.ns);
	req.declareNamespace(helper.nsXsi);
	req.declareNamespace(helper.nsLcm);
	req.declareNamespace(helper.nsRim);		
	req.declareNamespace(helper.nsRs);
	String docId = "urn:uuid:0520abda-8944-4463-b715-844a6785f2ab";
	String setId = "urn:uuid:08e6330f-1a7d-4099-be06-96cf8e6edae2";
	List<String> uuids = new ArrayList<String>();
	uuids.add(docId);
	uuids.add(setId);
	req.addChild(makeObjectRefList(uuids));
	return req;
}
 
Example 7
Source File: XdsRegistryLifeCycleServiceTest.java    From openxds with Apache License 2.0 5 votes vote down vote up
public OMElement getDeprecateObjectsRequest() {
	OMElement req = helper.omFactory.createOMElement("DeprecateObjectsRequest", helper.nsLcm);
	req.declareNamespace(helper.ns);
	req.declareNamespace(helper.nsXsi);
	req.declareNamespace(helper.nsLcm);
	req.declareNamespace(helper.nsRim);		
	req.declareNamespace(helper.nsRs);
	String docId = "urn:uuid:0520abda-8944-4463-b715-844a6785f2ab";
	String setId = "urn:uuid:08e6330f-1a7d-4099-be06-96cf8e6edae2";
	List<String> uuids = new ArrayList<String>();
	uuids.add(docId);
	uuids.add(setId);
	req.addChild(makeObjectRefList(uuids));
	return req;
}
 
Example 8
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 9
Source File: Sq.java    From openxds with Apache License 2.0 5 votes vote down vote up
protected ArrayList<OMElement> build_objectref_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", "ObjectRef", 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 10
Source File: IdParser.java    From openxds with Apache License 2.0 5 votes vote down vote up
public OMElement getApproveObjectsRequest(List uuids) {
	OMElement req = MetadataSupport.om_factory.createOMElement("ApproveObjectsRequest", MetadataSupport.ebLcm3);
	req.declareNamespace(MetadataSupport.ebRSns3);
	req.declareNamespace(MetadataSupport.ebRIMns3);
	req.declareNamespace(MetadataSupport.ebLcm3);
	req.declareNamespace(MetadataSupport.xdsB);
	req.addChild(mk_object_ref_list(uuids));
	return req;
}