org.apache.axiom.om.OMAttribute Java Examples

The following examples show how to use org.apache.axiom.om.OMAttribute. 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: MergePatientTest.java    From openxds with Apache License 2.0 6 votes vote down vote up
public int verifyDocuments(String patientId) throws Exception {
	String message = findDocumentsQuery(patientId + "^^^IHENA&1.3.6.1.4.1.21367.2010.1.2.300&ISO");
	OMElement request = OMUtil.xmlStringToOM(message);			

	ServiceClient sender = getRegistryServiceClient();															 
	OMElement response = sender.sendReceive( request );
	assertNotNull(response); 

	// Verify the response is correct
	OMAttribute status = response.getAttribute(new QName("status"));
	assertEquals("urn:oasis:names:tc:ebxml-regrep:ResponseStatusType:Success", status.getAttributeValue()); 
	System.out.println("Response:\n" +response.toString());
	
	OMElement robList = MetadataSupport.firstChildWithLocalName(response, "RegistryObjectList");
	List objects = MetadataSupport.childrenWithLocalName(robList, "ObjectRef");
	return objects.size();
}
 
Example #2
Source File: ExposeSOAPasSOAPTest.java    From product-ei with Apache License 2.0 6 votes vote down vote up
@Test(description = "4.1.1.1.14")
public void testPublishingWSDLModifyUserWSDLPortAddres() throws IOException, XMLStreamException {
    String url = getProxyServiceURLHttp("4_1_1_1_14_Proxy_PublishWSDLModifyUserWSDLPortAddress");
    String backendURL = "http://ei-backend.scenarios.wso2.org:8080/axis2/services/SimpleStockQuoteService";

    RESTClient restClient = new RESTClient();
    HttpResponse response = restClient.doGet(url + "?wsdl", null);
    Assert.assertEquals(HTTPUtils.getHTTPResponseCode(response), 200, "Response failed");

    OMElement responseOM = HTTPUtils.getOMFromResponse(response);
    OMElement serviceElement = responseOM.getFirstChildWithName(new QName(WSDL_NS, "service"));
    Assert.assertNotNull(serviceElement, "Unable to extract service element from WSDL");

    OMElement portElement = serviceElement.getFirstChildWithName(new QName(WSDL_NS, "port"));
    Assert.assertNotNull(portElement, "Unable to extract port element from WSDL");

    if (portElement.getFirstElement() != null) {
        Assert.assertEquals(portElement.getFirstElement().getLocalName(), "address", "address not available under " +
                "port in the WSDL");
        OMAttribute locationAttr = portElement.getFirstElement().getAttribute(new QName("location"));
        Assert.assertTrue(locationAttr.getAttributeValue().trim().startsWith(backendURL), "Service location " +
                "modified by the EI");
        return;
    }
    Assert.fail("Expected \"address\" element not found under port tag");
}
 
Example #3
Source File: ExposeSOAPasSOAPTest.java    From micro-integrator with Apache License 2.0 6 votes vote down vote up
@Test(description = "4.1.1.1.13")
public void testPublishingWSDLUseOriginalwsdl() throws IOException, XMLStreamException {
    String url = getProxyServiceURLHttp("4_1_1_1_13_Proxy_UseOriginalWSDL");
    String originalServiceName = "SimpleStockQuoteService";

    RESTClient restClient = new RESTClient();
    HttpResponse response = restClient.doGet(url + "?wsdl", null);
    Assert.assertEquals(HTTPUtils.getHTTPResponseCode(response), 200, "Response failed");

    OMElement responseOM = HTTPUtils.getOMFromResponse(response);
    OMElement serviceElement = responseOM.getFirstChildWithName(new QName(WSDL_NS, "service"));
    Assert.assertNotNull(serviceElement, "Unable to extract service element from WSDL");

    OMAttribute serviceNameAttr = serviceElement.getAttribute(new QName("name"));
    Assert.assertNotNull(serviceNameAttr, "Unable to extract service name attribute");
    Assert.assertEquals(serviceNameAttr.getAttributeValue(), originalServiceName, "Original Service name not " +
            "available");
}
 
Example #4
Source File: ExposeSOAPasSOAPTest.java    From product-ei with Apache License 2.0 6 votes vote down vote up
@Test(description = "4.1.1.1.13")
public void testPublishingWSDLUseOriginalwsdl() throws IOException, XMLStreamException {
    String url = getProxyServiceURLHttp("4_1_1_1_13_Proxy_UseOriginalWSDL");
    String originalServiceName = "SimpleStockQuoteService";

    RESTClient restClient = new RESTClient();
    HttpResponse response = restClient.doGet(url + "?wsdl", null);
    Assert.assertEquals(HTTPUtils.getHTTPResponseCode(response), 200, "Response failed");

    OMElement responseOM = HTTPUtils.getOMFromResponse(response);
    OMElement serviceElement = responseOM.getFirstChildWithName(new QName(WSDL_NS, "service"));
    Assert.assertNotNull(serviceElement, "Unable to extract service element from WSDL");

    OMAttribute serviceNameAttr = serviceElement.getAttribute(new QName("name"));
    Assert.assertNotNull(serviceNameAttr, "Unable to extract service name attribute");
    Assert.assertEquals(serviceNameAttr.getAttributeValue(), originalServiceName, "Original Service name not " +
            "available");
}
 
Example #5
Source File: XMLToJsonTestCase.java    From micro-integrator with Apache License 2.0 6 votes vote down vote up
private OMElement getPayload() {
    OMFactory fac = OMAbstractFactory.getOMFactory();
    OMNamespace omNsa = fac.createOMNamespace("testns1", "a");
    OMNamespace omNsb = fac.createOMNamespace("testns2", "b");
    OMNamespace omNsc = fac.createOMNamespace("testns3", "c");
    OMElement payload = fac.createOMElement("test", omNsa);
    OMElement p1 = fac.createOMElement("testb", omNsb);
    OMAttribute a1 = fac.createOMAttribute("attrb1", omNsa, "a");
    a1.setAttributeValue("v1");
    p1.addAttribute(a1);
    OMAttribute a2 = fac.createOMAttribute("attrb2", omNsb, "b");
    a2.setAttributeValue("v2");
    p1.addAttribute(a2);
    OMElement p2 = fac.createOMElement("testc", omNsc);
    p1.addChild(p2);
    payload.addChild(p1);
    return payload;
}
 
Example #6
Source File: XMLComparator.java    From micro-integrator with Apache License 2.0 6 votes vote down vote up
private static boolean compareAttributes(OMElement elementOne, OMElement elementTwo) {
    int elementOneAttribCount = 0;
    int elementTwoAttribCount = 0;
    Iterator attributes = elementOne.getAllAttributes();
    while (attributes.hasNext()) {
        OMAttribute omAttribute = (OMAttribute) attributes.next();
        OMAttribute attr = elementTwo.getAttribute(omAttribute.getQName());
        if (attr == null) {
            return false;
        }
        elementOneAttribCount++;
    }

    Iterator elementTwoIter = elementTwo.getAllAttributes();
    while (elementTwoIter.hasNext()) {
        elementTwoIter.next();
        elementTwoAttribCount++;

    }

    return elementOneAttribCount == elementTwoAttribCount;
}
 
Example #7
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 #8
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 #9
Source File: HomeAttribute.java    From openxds with Apache License 2.0 6 votes vote down vote up
public void validate1(OMElement root) {
	String localname = root.getLocalName();
	
	if (isIdentifiable(localname)) {

		OMAttribute home_att = root.getAttribute(MetadataSupport.home_qname);

		if (home_att == null) {
			errs += "\nElement of type " + localname + " does not contain a home attribute";
		} else {
			String home1 = home_att.getAttributeValue();
			if (home1 == null) home1 = "";
			if ( !home1.equals(home))
				errs += "\nElement of type " + localname + " has home of [" + home1 + "] which does not match expected value of [" + home + "]"; 
		}
	}

	for (OMNode child=root.getFirstElement(); child != null; child=child.getNextOMSibling()) {
		OMElement child_e = (OMElement) child;
		validate1(child_e);
	}
}
 
Example #10
Source File: Metadata.java    From openxds with Apache License 2.0 6 votes vote down vote up
public OMAttribute getUniqueIdAttribute(String id) throws MetadataException {
	OMAttribute att;
	att = id_index().getExternalIdentifierAttribute(id,
			MetadataSupport.XDSDocumentEntry_uniqueid_uuid);
	if (att != null && !att.equals(""))
		return att;
	att = id_index().getExternalIdentifierAttribute(id,
			MetadataSupport.XDSSubmissionSet_uniqueid_uuid);
	if (att != null && !att.equals(""))
		return att;
	att = id_index().getExternalIdentifierAttribute(id,
			MetadataSupport.XDSFolder_uniqueid_uuid);
	if (att != null && !att.equals(""))
		return att;
	return null;
}
 
Example #11
Source File: Validator.java    From openxds with Apache License 2.0 6 votes vote down vote up
void validate_internal_classifications(OMElement e) throws MetadataValidationException, MetadataException {
	String e_id = e.getAttributeValue(MetadataSupport.id_qname);
	if (e_id == null || e_id.equals(""))
		return;
	for (Iterator it=e.getChildElements(); it.hasNext(); ) {
		OMElement child = (OMElement) it.next();
		OMAttribute classified_object_att = child.getAttribute(MetadataSupport.classified_object_qname);
		if (classified_object_att != null) {
			String value = classified_object_att.getAttributeValue();
			if ( !e_id.equals(value)) {
				throw new MetadataValidationException("Classification " + m.getIdentifyingString(child) + 
						"\n   is nested inside " + m.getIdentifyingString(e) +
						"\n   but classifies object " + m.getIdentifyingString(value));
			}
		}
	}
}
 
Example #12
Source File: DiscoveryOMUtils.java    From carbon-commons with Apache License 2.0 6 votes vote down vote up
public static Probe getProbeFromOM(OMElement probeElement) throws DiscoveryException {
    validateTopElement(DiscoveryConstants.PROBE, probeElement);

    Probe probe = new Probe();
    probe.setTypes(getTypes(probeElement));
    probe.setScopes(getScopes(probeElement));

    OMElement scopesElement = probeElement.getFirstChildWithName(DiscoveryConstants.SCOPES);
    if (scopesElement != null) {
        OMAttribute attr = scopesElement.getAttribute(DiscoveryConstants.ATTR_MATCH_BY);
        if (attr != null && attr.getAttributeValue() != null) {
            try {
                probe.setMatchBy(new URI(attr.getAttributeValue()));
            } catch (URISyntaxException e) {
                throw new DiscoveryException("Invalid URI value for the MatchBy attribute", e);
            }
        }
    }
    return probe;
}
 
Example #13
Source File: SoapTransportCommandProcessorTest.java    From cougar with Apache License 2.0 6 votes vote down vote up
private void assertAttributes(OMElement expectedElement, OMElement actualElement) {
	Iterator expectedIt = expectedElement.getAllAttributes();
	Iterator actualIt = actualElement.getAllAttributes();
	while (expectedIt.hasNext()) {
		assertTrue(actualIt.hasNext());
		OMAttribute expectedAttribute = (OMAttribute)expectedIt.next();
		OMAttribute actualAttribute = (OMAttribute)actualIt.next();
		assertEquals(expectedAttribute.getAttributeType(), actualAttribute.getAttributeType());
		assertEquals(expectedAttribute.getAttributeValue(), actualAttribute.getAttributeValue());
		if (expectedAttribute.getNamespace() == null) {
			assertNull(actualAttribute.getNamespace());
		} else {
			assertEquals(expectedAttribute.getNamespace().getNamespaceURI(), actualAttribute.getNamespace().getNamespaceURI());
		}
	}
	assertFalse(actualIt.hasNext());
}
 
Example #14
Source File: HttpRequestHashGenerator.java    From micro-integrator with Apache License 2.0 6 votes vote down vote up
/**
 * Gets the collection of attributes which are none namespace declarations for an OMElement sorted according to the
 * expanded names of the attributes.
 *
 * @param element - OMElement of which the none ns declaration attributes to be retrieved
 * @return the collection of attributes which are none namespace declarations
 */
public Collection getAttributesWithoutNS(OMElement element) {

    SortedMap map = new TreeMap();
    Iterator itr = element.getAllAttributes();
    while (itr.hasNext()) {
        OMAttribute attribute = (OMAttribute) itr.next();

        if (!(attribute.getLocalName().equals("xmlns") ||
                attribute.getLocalName().startsWith("xmlns:"))) {

            map.put(getExpandedName(attribute), attribute);
        }
    }

    return map.values();
}
 
Example #15
Source File: DOMHASHGenerator.java    From micro-integrator with Apache License 2.0 6 votes vote down vote up
/**
 * Gets the collection of attributes which are none namespace declarations for an OMElement sorted according to the
 * expanded names of the attributes.
 *
 * @param element - OMElement of which the none ns declaration attributes to be retrieved
 * @return the collection of attributes which are none namespace declarations
 */
public Collection getAttributesWithoutNS(OMElement element) {

    SortedMap map = new TreeMap();

    Iterator itr = element.getAllAttributes();
    while (itr.hasNext()) {
        OMAttribute attribute = (OMAttribute) itr.next();

        if (!(attribute.getLocalName().equals("xmlns") ||
                attribute.getLocalName().startsWith("xmlns:"))) {

            map.put(getExpandedName(attribute), attribute);
        }
    }

    return map.values();
}
 
Example #16
Source File: DataSourceUtils.java    From micro-integrator with Apache License 2.0 6 votes vote down vote up
private static void secureLoadOMElement(OMElement element) {
	String alias = MiscellaneousUtil.getProtectedToken(element.getText());
	if (alias != null && !alias.isEmpty()) {
		element.setText(loadFromSecureVault(alias));
	} else {
		OMAttribute secureAttr = element.getAttribute(new QName(DataSourceConstants.SECURE_VAULT_NS,
				DataSourceConstants.SECRET_ALIAS_ATTR_NAME));
		if (secureAttr != null) {
			element.setText(loadFromSecureVault(secureAttr.getAttributeValue()));
			element.removeAttribute(secureAttr);
		}
	}
	Iterator<OMElement> childNodes = element.getChildElements();
	while (childNodes.hasNext()) {
		OMElement tmpNode = childNodes.next();
		secureLoadOMElement(tmpNode);
	}
}
 
Example #17
Source File: Response.java    From openxds with Apache License 2.0 6 votes vote down vote up
public OMElement toXml() {
	OMElement doc = MetadataSupport.om_factory.createOMElement("ValidateTestResponse", null);
	OMAttribute status_att = MetadataSupport.om_factory.createOMAttribute("status", null, status);
	doc.addAttribute(status_att);

	if (errors != null) {
		for ( String error_text : errors) {
			OMElement error_ele = MetadataSupport.om_factory.createOMElement("Error", null);
			error_ele.setText(error_text);
			doc.addChild(error_ele);
		}
	}

	if (warnings != null) {
		for ( String warning_text : warnings) {
			OMElement warning_ele = MetadataSupport.om_factory.createOMElement("Warning", null);
			warning_ele.setText(warning_text);
			doc.addChild(warning_ele);
		}
	}

	return doc;
}
 
Example #18
Source File: TenantWorkflowConfigHolder.java    From carbon-apimgt with Apache License 2.0 6 votes vote down vote up
private void loadProperties(OMElement executorElem, Object workflowClass) throws WorkflowException {

        for (Iterator it = executorElem.getChildrenWithName(PROP_Q); it.hasNext(); ) {
            OMElement propertyElem = (OMElement) it.next();
            OMAttribute attribute = propertyElem.getAttribute(ATT_NAME);
            if (attribute == null) {
                handleException("An Executor class property must specify the name attribute");
            } else {
                String propName = attribute.getAttributeValue();
                OMNode omElt = propertyElem.getFirstElement();
                if (omElt != null) {
                    setInstanceProperty(propName, omElt, workflowClass);
                } else if (propertyElem.getText() != null) {
                    String value = MiscellaneousUtil.resolve(propertyElem, secretResolver);
                    setInstanceProperty(propName, value, workflowClass);
                } else {
                    handleException("An Executor class property must specify " +
                            "name and text value, or a name and a child XML fragment");
                }
            }
        }
    }
 
Example #19
Source File: QueryTest.java    From openxds with Apache License 2.0 6 votes vote down vote up
@Test
public void testFindDocuments_MultipleStatus() throws Exception {
	//Generate StoredQuery request message
	patientId = XdsTest.patientId;
	String message = findDocumentsQuery(patientId);
	OMElement request = OMUtil.xmlStringToOM(message);			
	System.out.println("Request:\n" +request);

	//3. Send a StoredQuery
	ServiceClient sender = getRegistryServiceClient();															 
	OMElement response = sender.sendReceive( request );
	assertNotNull(response); 

	//4. Verify the response is correct
	OMAttribute status = response.getAttribute(new QName("status"));
	assertEquals("urn:oasis:names:tc:ebxml-regrep:ResponseStatusType:Success", status.getAttributeValue()); 

	String result = response.toString();
	System.out.println("Result:\n" +result);
}
 
Example #20
Source File: XdsTest.java    From openxds with Apache License 2.0 5 votes vote down vote up
/**
 * Submit one document to support ProvideAndRegisterDocumentSet-b (ITI-41)
 * 
 * @return XDSDocumentEntry.uuid
 * @throws  
 * @throws Exception 
 */
protected String submitOneDocument(String patientId) throws Exception {		
	String message = IOUtils.toString( ProvideAndRegisterDocumentSetTest.class.getResourceAsStream("/data/submit_document.xml"));
	String document = IOUtils.toString(ProvideAndRegisterDocumentSetTest.class.getResourceAsStream("/data/referral_summary.xml"));
	//replace document and submission set uniqueId variables with actual uniqueIds. 
	message = message.replace("$XDSDocumentEntry.uniqueId", "2.16.840.1.113883.3.65.2." + System.currentTimeMillis());
	message = message.replace("$XDSSubmissionSet.uniqueId", "1.3.6.1.4.1.21367.2009.1.2.108." + System.currentTimeMillis());
	//replace the document uuid.
	String uuid = "urn:uuid:" + UUID.randomUUID().toString();
	message = message.replace("$doc1", uuid);
	//replace the patient id
	if (patientId != null) 
		message = message.replace("$patientId", patientId);

	
	ServiceClient sender = getRepositoryServiceClient();			
	
	OMElement request = OMUtil.xmlStringToOM(message);			
	
	//Add a document
	request = addOneDocument(request, document, uuid);
       
	System.out.println("Request:\n" +request);

	OMElement response = sender.sendReceive( request );
	assertNotNull(response); 

	OMAttribute status = response.getAttribute(new QName("status"));
	assertEquals("urn:oasis:names:tc:ebxml-regrep:ResponseStatusType:Success", status.getAttributeValue());

	String result = response.toString();
	System.out.println("Result:\n" +result);
	
	return uuid;
}
 
Example #21
Source File: ProvideAndRegisterDocumentSetTest.java    From openxds with Apache License 2.0 5 votes vote down vote up
@Test
public void testTranformWithReplaceDocument() throws Exception {
	//First submit a document
	String doc_uuid = submitOneDocument(patientId);

	//Then add a transform with replace doc
	String message = IOUtils.toString( ProvideAndRegisterDocumentSetTest.class.getResourceAsStream("/data/document_trans_replace.xml"));
	String document1 = IOUtils.toString(ProvideAndRegisterDocumentSetTest.class.getResourceAsStream("/data/medical_summary.xml"));
	//replace document and submission set uniqueId variables with actual uniqueIds. 
	message = message.replace("$XDSDocumentEntry.uniqueId", "2.16.840.1.113883.3.65.2." + System.currentTimeMillis());
	message = message.replace("$XDSSubmissionSet.uniqueId", "1.3.6.1.4.1.21367.2009.1.2.108." + System.currentTimeMillis());
	message = message.replace("$patientId", patientId);
	//populate the document uuid to be transformed and replaced
	message = message.replace("$tran_rplc_doc_uuid", doc_uuid);

	ServiceClient sender = getRepositoryServiceClient();			
	
	OMElement request = OMUtil.xmlStringToOM(message);			
	
	//Add a transformation document
	request = addOneDocument(request, document1, "doc1");

	System.out.println("Request:\n" +request);
	OMElement response = sender.sendReceive( request );
	assertNotNull(response); 

	OMAttribute status = response.getAttribute(new QName("status"));
	assertEquals("urn:oasis:names:tc:ebxml-regrep:ResponseStatusType:Success", status.getAttributeValue());

	String result = response.toString();
	System.out.println("Result:\n" +result);
}
 
Example #22
Source File: IdParser.java    From openxds with Apache License 2.0 5 votes vote down vote up
private OMElement mk_object_ref_list(List uuids) {
	OMElement object_ref_list = MetadataSupport.om_factory.createOMElement("ObjectRefList", MetadataSupport.ebRIMns3);
	for (Iterator it=uuids.iterator(); it.hasNext(); ) {
		String uuid = (String) it.next();
		OMAttribute att = MetadataSupport.om_factory.createOMAttribute("id", null, uuid);
		OMElement object_ref = MetadataSupport.om_factory.createOMElement("ObjectRef", MetadataSupport.ebRIMns3);
		object_ref.addAttribute(att);
		object_ref_list.addChild(object_ref);
	}
	return object_ref_list;
}
 
Example #23
Source File: RegistryResponseParser.java    From openxds with Apache License 2.0 5 votes vote down vote up
String get_att(OMElement ele, String name) {
	OMAttribute att = ele.getAttribute(new QName(name));
	if (att == null)
		return null;
	return att.getAttributeValue();

}
 
Example #24
Source File: RegistrytStoredQueryTest.java    From openxds with Apache License 2.0 5 votes vote down vote up
@Test
public void testGetFoldersAndContents() throws Exception {
	//1. Submit a document first for a random patientId
	String patientId = generateAPatientId();
	String folderUniqueId = submitOneDocument2Folder(patientId);
	
	//2. Generate StoredQuery request message
	String message = GetFoldersAndContentsQuery(folderUniqueId, true);
	OMElement request = OMUtil.xmlStringToOM(message);			
	System.out.println("Request:\n" +request);

	//3. Send a StoredQuery
	ServiceClient sender = getRegistryServiceClient();															 
	OMElement response = sender.sendReceive( request );
	assertNotNull(response); 

	//4. Verify the response is correct
	OMAttribute status = response.getAttribute(new QName("status"));
	assertEquals("urn:oasis:names:tc:ebxml-regrep:ResponseStatusType:Success", status.getAttributeValue()); 
	
	//5. Verify that the given PatientId is found from the StoredQuery response. 
	NodeList nodes = getPatientIdNodes(response, patientId, "getFolders");
	assertTrue(nodes.getLength() == 1); 
	
	NodeList asso_nodes = getPatientIdNodes(response, patientId, "getAssociations");
	assertTrue(asso_nodes.getLength() == 1); 

	String result = response.toString();
	System.out.println("Result:\n" +result);
}
 
Example #25
Source File: CrossGatewayQueryTest.java    From openxds with Apache License 2.0 5 votes vote down vote up
/**
 * This test issues a FindDocuments Cross Gateway Query (XGQ)
 *  to the XDS Registry's Receiving Gateway requesting ObjectRefs (document references) be returned. 
 * @throws Exception
 */
@Test
public void testFindDocsObjectRef() throws Exception {
	//1. Submit a document first for a random patientId
	String patientId = generateAPatientId();
	String uuids = submitMultipleDocuments(patientId);
	
	//2. Generate StoredQuery request message
	String message = findDocumentsQuery(patientId, "Approved", "ObjectRef");
	OMElement request = OMUtil.xmlStringToOM(message);			
	System.out.println("Request:\n" +request);

	//3. Send a StoredQuery
	ServiceClient sender = getRegistryGateWayClient();															 
	OMElement response = sender.sendReceive( request );
	assertNotNull(response); 
	
	//4. Verify the response is correct
	OMAttribute status = response.getAttribute(new QName("status"));
	assertEquals("urn:oasis:names:tc:ebxml-regrep:ResponseStatusType:Success", status.getAttributeValue()); 
	
	//5. Verify that the 2 ObjectRefs found from the StoredQuery response. 
	NodeList count = getNodeCount(response, "ObjectRef");
	assertTrue(count.getLength() == 2); 
	
	String result = response.toString();
	System.out.println("Result:\n" +result);
}
 
Example #26
Source File: ProvideAndRegisterDocumentSetTest.java    From openxds with Apache License 2.0 5 votes vote down vote up
/**
 * Test method for ProvideAndRegisterDocumentSet-b (ITI-41)
 * 
 * @throws  
 * @throws Exception 
 */
@Test
public void testSubmitDocument() throws Exception {
	createPatient(patientId);
	
	String message = IOUtils.toString( ProvideAndRegisterDocumentSetTest.class.getResourceAsStream("/data/submit_document.xml"));
	String document = IOUtils.toString(ProvideAndRegisterDocumentSetTest.class.getResourceAsStream("/data/referral_summary.xml"));
	//replace document and submission set uniqueId variables with actual uniqueIds. 
	message = message.replace("$XDSDocumentEntry.uniqueId", "2.16.840.1.113883.3.65.2." + System.currentTimeMillis());
	message = message.replace("$XDSSubmissionSet.uniqueId", "1.3.6.1.4.1.21367.2009.1.2.108." + System.currentTimeMillis());
	message = message.replace("$patientId", patientId);
	//replace the document uuid.
	String uuid = getUUID();
	message = message.replace("$doc1", uuid);
	
	ServiceClient sender = getRepositoryServiceClient();			
	
	OMElement request = OMUtil.xmlStringToOM(message);			
	
	//Add a document
	request = addOneDocument(request, document, uuid);
       
	System.out.println("Request:\n" +request);

	OMElement response = sender.sendReceive( request );
	assertNotNull(response); 

	OMAttribute status = response.getAttribute(new QName("status"));
	assertEquals("urn:oasis:names:tc:ebxml-regrep:ResponseStatusType:Success", status.getAttributeValue());

	String result = response.toString();
	System.out.println("Result:\n" +result);
}
 
Example #27
Source File: ProvideAndRegisterDocumentSetTest.java    From openxds with Apache License 2.0 5 votes vote down vote up
@Test
public void testAddendumDocument() throws Exception {
	//First submit a document
	String doc_uuid = submitOneDocument(patientId);
	
	//Then add an Addendum
	String message = IOUtils.toString( ProvideAndRegisterDocumentSetTest.class.getResourceAsStream("/data/document_addendum.xml"));
	String document1 = IOUtils.toString(ProvideAndRegisterDocumentSetTest.class.getResourceAsStream("/data/referral_summary.xml"));
	//replace document , submission set variables with actual uniqueIds. 
	message = message.replace("$XDSDocumentEntry.uniqueId", "2.16.840.1.113883.3.65.2." + System.currentTimeMillis());
	message = message.replace("$XDSSubmissionSet.uniqueId", "1.3.6.1.4.1.21367.2009.1.2.108." + System.currentTimeMillis());
	message = message.replace("$patientId", patientId);
	//populate the document uuid to be appended.
	message = message.replace("$appendum_doc_uuid", doc_uuid);
	
	ServiceClient sender = getRepositoryServiceClient();			
	
	OMElement request = OMUtil.xmlStringToOM(message);			
	
	//Add a referral summary document
	request = addOneDocument(request, document1, "doc1");

	System.out.println("Request:\n" +request);
	OMElement response = sender.sendReceive( request );
	assertNotNull(response); 

	OMAttribute status = response.getAttribute(new QName("status"));
	assertEquals("urn:oasis:names:tc:ebxml-regrep:ResponseStatusType:Success", status.getAttributeValue());

	String result = response.toString();
	System.out.println("Result:\n" +result);
}
 
Example #28
Source File: XdsTest.java    From openxds with Apache License 2.0 5 votes vote down vote up
protected String submitOneDocument2Folder(String patientId) throws Exception {
	String message = IOUtils.toString( ProvideAndRegisterDocumentSetTest.class.getResourceAsStream("/data/add_document2_folder.xml"));
	String document1 = IOUtils.toString(ProvideAndRegisterDocumentSetTest.class.getResourceAsStream("/data/referral_summary.xml"));
	//replace document , submission set and folder uniqueId variables with actual uniqueIds. 
	message = message.replace("$XDSDocumentEntry.uniqueId", "2.16.840.1.113883.3.65.2." + System.currentTimeMillis());
	message = message.replace("$XDSSubmissionSet.uniqueId", "1.3.6.1.4.1.21367.2009.1.2.108." + System.currentTimeMillis());
	String folderUniqueId = "2.16.840.1.113883.3.65.3." + System.currentTimeMillis();
	message = message.replace("$folder_uniqueid", folderUniqueId);
	//replace the documentId doc1 with an UUID
	String uuid = "urn:uuid:" + UUID.randomUUID().toString();
	message = message.replace("doc1", uuid);
	//replace the patient id
	message = message.replace("$patientId", patientId);
	
	ServiceClient sender = getRepositoryServiceClient();			
	
	OMElement request = OMUtil.xmlStringToOM(message);			
	
	//Add a referral summary document
	request = addOneDocument(request, document1, uuid);
	
       System.out.println("Request:\n" +request);
	OMElement response = sender.sendReceive( request );
	assertNotNull(response); 

	OMAttribute status = response.getAttribute(new QName("status"));
	assertEquals("urn:oasis:names:tc:ebxml-regrep:ResponseStatusType:Success", status.getAttributeValue());

	String result = response.toString();
	System.out.println("Result:\n" +result);

	return folderUniqueId;
}
 
Example #29
Source File: XdsTest.java    From openxds with Apache License 2.0 5 votes vote down vote up
/**
 * Submits new document and replaces the document
 * 
 * @param patientId
 * @return Document UUID
 * @throws Exception
 */

public String replaceDocument(String patientId) throws Exception {
	//First submit a document
	String doc_uuid = submitOneDocument(patientId);

	//Then add a replacement doc
	String message = IOUtils.toString( ProvideAndRegisterDocumentSetTest.class.getResourceAsStream("/data/document_replacement.xml"));
	String document1 = IOUtils.toString(ProvideAndRegisterDocumentSetTest.class.getResourceAsStream("/data/medical_summary.xml"));
	//replace document and submission set variables with actual uniqueIds. 
	message = message.replace("$XDSDocumentEntry.uniqueId", "2.16.840.1.113883.3.65.2." + System.currentTimeMillis());
	message = message.replace("$XDSSubmissionSet.uniqueId", "1.3.6.1.4.1.21367.2009.1.2.108." + System.currentTimeMillis());
	message = message.replace("$patientId", patientId);
	//populate the document uuid to be replaced.
	message = message.replace("$rplc_doc_uuid", doc_uuid);
	
	ServiceClient sender = getRepositoryServiceClient();			
	
	OMElement request = OMUtil.xmlStringToOM(message);			
	
	//Add a medical summary document
	request = addOneDocument(request, document1, "doc1");

	System.out.println("Request:\n" +request);
	OMElement response = sender.sendReceive( request );
	assertNotNull(response); 

	OMAttribute status = response.getAttribute(new QName("status"));
	assertEquals("urn:oasis:names:tc:ebxml-regrep:ResponseStatusType:Success", status.getAttributeValue());
	
	String result = response.toString();
	System.out.println("Result:\n" +result);
	
	return doc_uuid;
}
 
Example #30
Source File: FileBasedConfigurationBuilder.java    From carbon-identity with Apache License 2.0 5 votes vote down vote up
private String processAuthEndpointQueryParamElem(OMElement authEndpointQueryParamElem) {

        OMAttribute nameAttr = authEndpointQueryParamElem.getAttribute(new QName(
                FrameworkConstants.Config.ATTR_AUTH_ENDPOINT_QUERY_PARAM_NAME));

        if (nameAttr == null) {
            log.warn("Each Authentication Endpoint Query Param should have a unique name attribute. This Query Param will skipped.");
            return null;
        }

        return nameAttr.getAttributeValue();
    }