Example usage for javax.xml.namespace QName valueOf

List of usage examples for javax.xml.namespace QName valueOf

Introduction

In this page you can find the example usage for javax.xml.namespace QName valueOf.

Prototype

public static QName valueOf(String qNameAsString) 

Source Link

Document

<p><code>QName</code> derived from parsing the formatted <code>String</code>.</p> <p>If the <code>String</code> is <code>null</code> or does not conform to #toString() QName.toString() formatting, an <code>IllegalArgumentException</code> is thrown.</p> <p><em>The <code>String</code> <strong>MUST</strong> be in the form returned by #toString() QName.toString() .</em></p> <p>The commonly accepted way of representing a <code>QName</code> as a <code>String</code> was <a href="http://jclark.com/xml/xmlns.htm">defined</a> by James Clark.

Usage

From source file:org.artificer.repository.jcr.JCRRelationshipQueryTest.java

@Test
public void testGenericRelationshipAttributeQueries() throws Exception {
    XsdDocument xsdDoc = addXsdDoc();/*w  w  w .  j  a  v  a  2  s .c om*/
    WsdlDocument wsdlDoc1 = addWsdlDoc();
    WsdlDocument wsdlDoc2 = addWsdlDoc();
    WsdlDocument wsdlDoc3 = addWsdlDoc();

    Map<QName, String> otherAttributes = new HashMap<QName, String>();
    otherAttributes.put(QName.valueOf("FooKey"), "FooValue");
    ArtificerModelUtils.addGenericRelationship(xsdDoc, "relWithAttr", wsdlDoc1.getUuid(), otherAttributes,
            Collections.EMPTY_MAP);
    ArtificerModelUtils.addGenericRelationship(xsdDoc, "relWithAttr", wsdlDoc2.getUuid(), otherAttributes,
            Collections.EMPTY_MAP);
    Map<QName, String> otherAttributes2 = new HashMap<QName, String>();
    otherAttributes2.put(QName.valueOf("FooKey2"), "FooValue2");
    ArtificerModelUtils.addGenericRelationship(xsdDoc, "relWithAttr2", wsdlDoc3.getUuid(), otherAttributes2,
            Collections.EMPTY_MAP);

    xsdDoc = (XsdDocument) persistenceManager.updateArtifact(xsdDoc, ArtifactType.XsdDocument());

    // add custom properties only to one of the wsdls
    Property prop = new Property();
    prop.setPropertyName("FooProperty");
    prop.setPropertyValue("FooValue");
    wsdlDoc1.getProperty().add(prop);

    wsdlDoc1 = (WsdlDocument) persistenceManager.updateArtifact(wsdlDoc1, ArtifactType.WsdlDocument());

    ArtificerQuery query = queryManager
            .createQuery("/s-ramp/xsd/XsdDocument[relWithAttr[s-ramp:getRelationshipAttribute(., 'FooKey')]]");
    ArtifactSet artifactSet = query.executeQuery();
    Assert.assertNotNull(artifactSet);
    Assert.assertEquals(1, artifactSet.size());

    query = queryManager.createQuery(
            "/s-ramp/xsd/XsdDocument[relWithAttr[s-ramp:getRelationshipAttribute(., 'FooKey') = 'FooValue']]");
    artifactSet = query.executeQuery();
    Assert.assertNotNull(artifactSet);
    Assert.assertEquals(1, artifactSet.size());

    query = queryManager.createQuery(
            "/s-ramp/xsd/XsdDocument[relWithAttr[s-ramp:getRelationshipAttribute(., 'InvalidKey')]]");
    artifactSet = query.executeQuery();
    Assert.assertNotNull(artifactSet);
    Assert.assertEquals(0, artifactSet.size());

    query = queryManager.createQuery(
            "/s-ramp/xsd/XsdDocument[relWithAttr[s-ramp:getRelationshipAttribute(., 'FooKey') = 'FooValue' and @FooProperty = 'FooValue']]");
    artifactSet = query.executeQuery();
    Assert.assertNotNull(artifactSet);
    Assert.assertEquals(1, artifactSet.size());

    query = queryManager.createQuery(
            "/s-ramp/xsd/XsdDocument[relWithAttr[s-ramp:getRelationshipAttribute(., 'FooKey') = 'FooValue' and @InvalidProperty]]");
    artifactSet = query.executeQuery();
    Assert.assertNotNull(artifactSet);
    Assert.assertEquals(0, artifactSet.size());

    query = queryManager.createQuery(
            "/s-ramp/xsd/XsdDocument[relWithAttr[s-ramp:getRelationshipAttribute(., 'FooKey') = 'FooValue' or @FooProperty = 'FooValue']]");
    artifactSet = query.executeQuery();
    Assert.assertNotNull(artifactSet);
    Assert.assertEquals(1, artifactSet.size());

    query = queryManager.createQuery(
            "/s-ramp/xsd/XsdDocument[relWithAttr[s-ramp:getRelationshipAttribute(., 'FooKey') = 'InvalidValue' or @FooProperty = 'FooValue']]");
    artifactSet = query.executeQuery();
    Assert.assertNotNull(artifactSet);
    Assert.assertEquals(1, artifactSet.size());

    query = queryManager.createQuery(
            "/s-ramp/xsd/XsdDocument[relWithAttr[s-ramp:getRelationshipAttribute(., 'FooKey') = 'InvalidValue' or @FooProperty = 'FooValue']]");
    artifactSet = query.executeQuery();
    Assert.assertNotNull(artifactSet);
    Assert.assertEquals(1, artifactSet.size());

    query = queryManager.createQuery("/s-ramp/xsd/XsdDocument[@uuid = ?]/relWithAttr2");
    query.setString(xsdDoc.getUuid());
    artifactSet = query.executeQuery();
    Assert.assertNotNull(artifactSet);
    Assert.assertEquals(1, artifactSet.size());

    query = queryManager.createQuery(
            "/s-ramp/xsd/XsdDocument[@uuid = ?]/relWithAttr2[s-ramp:getRelationshipAttribute(., 'FooKey2')]");
    query.setString(xsdDoc.getUuid());
    artifactSet = query.executeQuery();
    Assert.assertNotNull(artifactSet);
    Assert.assertEquals(1, artifactSet.size());
    Assert.assertEquals(wsdlDoc3.getUuid(), artifactSet.iterator().next().getUuid());

    query = queryManager.createQuery(
            "/s-ramp/xsd/XsdDocument[@uuid = ?]/relWithAttr2[s-ramp:getRelationshipAttribute(., 'FooKey2') = 'FooValue2']");
    query.setString(xsdDoc.getUuid());
    artifactSet = query.executeQuery();
    Assert.assertNotNull(artifactSet);
    Assert.assertEquals(1, artifactSet.size());
    Assert.assertEquals(wsdlDoc3.getUuid(), artifactSet.iterator().next().getUuid());

    query = queryManager.createQuery(
            "/s-ramp/xsd/XsdDocument[@uuid = ?]/relWithAttr2[s-ramp:getRelationshipAttribute(., 'InvalidKey')]");
    query.setString(xsdDoc.getUuid());
    artifactSet = query.executeQuery();
    Assert.assertNotNull(artifactSet);
    Assert.assertEquals(0, artifactSet.size());
}

From source file:org.artificer.repository.jcr.JCRRelationshipQueryTest.java

@Test
public void testGenericTargetAttributeQueries() throws Exception {
    XsdDocument xsdDoc = addXsdDoc();/*ww w. j av a 2  s  . c  om*/
    WsdlDocument wsdlDoc1 = addWsdlDoc();
    WsdlDocument wsdlDoc2 = addWsdlDoc();
    WsdlDocument wsdlDoc3 = addWsdlDoc();

    Map<QName, String> otherAttributes = new HashMap<QName, String>();
    otherAttributes.put(QName.valueOf("FooKey"), "FooValue");
    ArtificerModelUtils.addGenericRelationship(xsdDoc, "relWithAttr", wsdlDoc1.getUuid(), Collections.EMPTY_MAP,
            otherAttributes);
    ArtificerModelUtils.addGenericRelationship(xsdDoc, "relWithAttr", wsdlDoc2.getUuid(), Collections.EMPTY_MAP,
            otherAttributes);
    Map<QName, String> otherAttributes2 = new HashMap<QName, String>();
    otherAttributes2.put(QName.valueOf("FooKey2"), "FooValue2");
    ArtificerModelUtils.addGenericRelationship(xsdDoc, "relWithAttr2", wsdlDoc3.getUuid(),
            Collections.EMPTY_MAP, otherAttributes2);

    xsdDoc = (XsdDocument) persistenceManager.updateArtifact(xsdDoc, ArtifactType.XsdDocument());

    // add custom properties only to one of the wsdls
    Property prop = new Property();
    prop.setPropertyName("FooProperty");
    prop.setPropertyValue("FooValue");
    wsdlDoc1.getProperty().add(prop);

    wsdlDoc1 = (WsdlDocument) persistenceManager.updateArtifact(wsdlDoc1, ArtifactType.WsdlDocument());

    ArtificerQuery query = queryManager
            .createQuery("/s-ramp/xsd/XsdDocument[relWithAttr[s-ramp:getTargetAttribute(., 'FooKey')]]");
    ArtifactSet artifactSet = query.executeQuery();
    Assert.assertNotNull(artifactSet);
    Assert.assertEquals(1, artifactSet.size());

    query = queryManager.createQuery(
            "/s-ramp/xsd/XsdDocument[relWithAttr[s-ramp:getTargetAttribute(., 'FooKey') = 'FooValue']]");
    artifactSet = query.executeQuery();
    Assert.assertNotNull(artifactSet);
    Assert.assertEquals(1, artifactSet.size());

    query = queryManager
            .createQuery("/s-ramp/xsd/XsdDocument[relWithAttr[s-ramp:getTargetAttribute(., 'InvalidKey')]]");
    artifactSet = query.executeQuery();
    Assert.assertNotNull(artifactSet);
    Assert.assertEquals(0, artifactSet.size());

    query = queryManager.createQuery(
            "/s-ramp/xsd/XsdDocument[relWithAttr[s-ramp:getTargetAttribute(., 'FooKey') = 'FooValue' and @FooProperty = 'FooValue']]");
    artifactSet = query.executeQuery();
    Assert.assertNotNull(artifactSet);
    Assert.assertEquals(1, artifactSet.size());

    query = queryManager.createQuery(
            "/s-ramp/xsd/XsdDocument[relWithAttr[s-ramp:getTargetAttribute(., 'FooKey') = 'FooValue' and @InvalidProperty]]");
    artifactSet = query.executeQuery();
    Assert.assertNotNull(artifactSet);
    Assert.assertEquals(0, artifactSet.size());

    query = queryManager.createQuery(
            "/s-ramp/xsd/XsdDocument[relWithAttr[s-ramp:getTargetAttribute(., 'FooKey') = 'FooValue' or @FooProperty = 'FooValue']]");
    artifactSet = query.executeQuery();
    Assert.assertNotNull(artifactSet);
    Assert.assertEquals(1, artifactSet.size());

    query = queryManager.createQuery(
            "/s-ramp/xsd/XsdDocument[relWithAttr[s-ramp:getTargetAttribute(., 'FooKey') = 'InvalidValue' or @FooProperty = 'FooValue']]");
    artifactSet = query.executeQuery();
    Assert.assertNotNull(artifactSet);
    Assert.assertEquals(1, artifactSet.size());

    query = queryManager.createQuery(
            "/s-ramp/xsd/XsdDocument[relWithAttr[s-ramp:getTargetAttribute(., 'FooKey') = 'InvalidValue' or @FooProperty = 'FooValue']]");
    artifactSet = query.executeQuery();
    Assert.assertNotNull(artifactSet);
    Assert.assertEquals(1, artifactSet.size());

    query = queryManager.createQuery("/s-ramp/xsd/XsdDocument[@uuid = ?]/relWithAttr2");
    query.setString(xsdDoc.getUuid());
    artifactSet = query.executeQuery();
    Assert.assertNotNull(artifactSet);
    Assert.assertEquals(1, artifactSet.size());

    query = queryManager.createQuery(
            "/s-ramp/xsd/XsdDocument[@uuid = ?]/relWithAttr2[s-ramp:getTargetAttribute(., 'FooKey2')]");
    query.setString(xsdDoc.getUuid());
    artifactSet = query.executeQuery();
    Assert.assertNotNull(artifactSet);
    Assert.assertEquals(1, artifactSet.size());
    Assert.assertEquals(wsdlDoc3.getUuid(), artifactSet.iterator().next().getUuid());

    query = queryManager.createQuery(
            "/s-ramp/xsd/XsdDocument[@uuid = ?]/relWithAttr2[s-ramp:getTargetAttribute(., 'FooKey2') = 'FooValue2']");
    query.setString(xsdDoc.getUuid());
    artifactSet = query.executeQuery();
    Assert.assertNotNull(artifactSet);
    Assert.assertEquals(1, artifactSet.size());
    Assert.assertEquals(wsdlDoc3.getUuid(), artifactSet.iterator().next().getUuid());

    query = queryManager.createQuery(
            "/s-ramp/xsd/XsdDocument[@uuid = ?]/relWithAttr2[s-ramp:getTargetAttribute(., 'InvalidKey')]");
    query.setString(xsdDoc.getUuid());
    artifactSet = query.executeQuery();
    Assert.assertNotNull(artifactSet);
    Assert.assertEquals(0, artifactSet.size());
}

From source file:org.artificer.repository.test.RelationshipQueryTest.java

@Test
public void testGenericRelationshipAttributeQueries() throws Exception {
    XsdDocument xsdDoc = addXsdDoc();/*w  w  w .j a  v a2  s  . com*/
    WsdlDocument wsdlDoc1 = addWsdlDoc();
    WsdlDocument wsdlDoc2 = addWsdlDoc();
    WsdlDocument wsdlDoc3 = addWsdlDoc();

    Map<QName, String> otherAttributes = new HashMap<QName, String>();
    otherAttributes.put(QName.valueOf("FooKey"), "FooValue");
    ArtificerModelUtils.addGenericRelationship(xsdDoc, "relWithAttr", wsdlDoc1.getUuid(), otherAttributes,
            Collections.EMPTY_MAP);
    ArtificerModelUtils.addGenericRelationship(xsdDoc, "relWithAttr", wsdlDoc2.getUuid(), otherAttributes,
            Collections.EMPTY_MAP);
    Map<QName, String> otherAttributes2 = new HashMap<QName, String>();
    otherAttributes2.put(QName.valueOf("FooKey2"), "FooValue2");
    ArtificerModelUtils.addGenericRelationship(xsdDoc, "relWithAttr2", wsdlDoc3.getUuid(), otherAttributes2,
            Collections.EMPTY_MAP);

    xsdDoc = (XsdDocument) persistenceManager.updateArtifact(xsdDoc, ArtifactType.XsdDocument());

    // add custom properties only to one of the wsdls
    Property prop = new Property();
    prop.setPropertyName("FooProperty");
    prop.setPropertyValue("FooValue");
    wsdlDoc1.getProperty().add(prop);

    wsdlDoc1 = (WsdlDocument) persistenceManager.updateArtifact(wsdlDoc1, ArtifactType.WsdlDocument());

    ArtificerQuery query = queryManager
            .createQuery("/s-ramp/xsd/XsdDocument[relWithAttr[s-ramp:getRelationshipAttribute(., 'FooKey')]]");
    PagedResult<ArtifactSummary> artifactSet = query.executeQuery();
    Assert.assertNotNull(artifactSet);
    Assert.assertEquals(1, artifactSet.getTotalSize());

    query = queryManager.createQuery(
            "/s-ramp/xsd/XsdDocument[relWithAttr[s-ramp:getRelationshipAttribute(., 'FooKey') = 'FooValue']]");
    artifactSet = query.executeQuery();
    Assert.assertNotNull(artifactSet);
    Assert.assertEquals(1, artifactSet.getTotalSize());

    query = queryManager.createQuery(
            "/s-ramp/xsd/XsdDocument[relWithAttr[s-ramp:getRelationshipAttribute(., 'InvalidKey')]]");
    artifactSet = query.executeQuery();
    Assert.assertNotNull(artifactSet);
    Assert.assertEquals(0, artifactSet.getTotalSize());

    query = queryManager.createQuery(
            "/s-ramp/xsd/XsdDocument[relWithAttr[s-ramp:getRelationshipAttribute(., 'FooKey') = 'FooValue' and @FooProperty = 'FooValue']]");
    artifactSet = query.executeQuery();
    Assert.assertNotNull(artifactSet);
    Assert.assertEquals(1, artifactSet.getTotalSize());

    query = queryManager.createQuery(
            "/s-ramp/xsd/XsdDocument[relWithAttr[s-ramp:getRelationshipAttribute(., 'FooKey') = 'FooValue' and @InvalidProperty]]");
    artifactSet = query.executeQuery();
    Assert.assertNotNull(artifactSet);
    Assert.assertEquals(0, artifactSet.getTotalSize());

    query = queryManager.createQuery(
            "/s-ramp/xsd/XsdDocument[relWithAttr[s-ramp:getRelationshipAttribute(., 'FooKey') = 'FooValue' or @FooProperty = 'FooValue']]");
    artifactSet = query.executeQuery();
    Assert.assertNotNull(artifactSet);
    Assert.assertEquals(1, artifactSet.getTotalSize());

    query = queryManager.createQuery(
            "/s-ramp/xsd/XsdDocument[relWithAttr[s-ramp:getRelationshipAttribute(., 'FooKey') = 'InvalidValue' or @FooProperty = 'FooValue']]");
    artifactSet = query.executeQuery();
    Assert.assertNotNull(artifactSet);
    Assert.assertEquals(1, artifactSet.getTotalSize());

    query = queryManager.createQuery(
            "/s-ramp/xsd/XsdDocument[relWithAttr[s-ramp:getRelationshipAttribute(., 'FooKey') = 'InvalidValue' or @FooProperty = 'FooValue']]");
    artifactSet = query.executeQuery();
    Assert.assertNotNull(artifactSet);
    Assert.assertEquals(1, artifactSet.getTotalSize());

    query = queryManager.createQuery("/s-ramp/xsd/XsdDocument[@uuid = ?]/relWithAttr2");
    query.setString(xsdDoc.getUuid());
    artifactSet = query.executeQuery();
    Assert.assertNotNull(artifactSet);
    Assert.assertEquals(1, artifactSet.getTotalSize());
    Assert.assertEquals(wsdlDoc3.getUuid(), artifactSet.getResults().get(0).getUuid());

    query = queryManager.createQuery(
            "/s-ramp/xsd/XsdDocument[@uuid = ?]/relWithAttr2[s-ramp:getRelationshipAttribute(., 'FooKey2')]");
    query.setString(xsdDoc.getUuid());
    artifactSet = query.executeQuery();
    Assert.assertNotNull(artifactSet);
    Assert.assertEquals(1, artifactSet.getTotalSize());
    Assert.assertEquals(wsdlDoc3.getUuid(), artifactSet.getResults().get(0).getUuid());

    query = queryManager.createQuery(
            "/s-ramp/xsd/XsdDocument[@uuid = ?]/relWithAttr2[s-ramp:getRelationshipAttribute(., 'FooKey2') = 'FooValue2']");
    query.setString(xsdDoc.getUuid());
    artifactSet = query.executeQuery();
    Assert.assertNotNull(artifactSet);
    Assert.assertEquals(1, artifactSet.getTotalSize());
    Assert.assertEquals(wsdlDoc3.getUuid(), artifactSet.getResults().get(0).getUuid());

    query = queryManager.createQuery(
            "/s-ramp/xsd/XsdDocument[@uuid = ?]/relWithAttr2[s-ramp:getRelationshipAttribute(., 'InvalidKey')]");
    query.setString(xsdDoc.getUuid());
    artifactSet = query.executeQuery();
    Assert.assertNotNull(artifactSet);
    Assert.assertEquals(0, artifactSet.getTotalSize());
}

From source file:org.artificer.repository.test.RelationshipQueryTest.java

@Test
public void testGenericTargetAttributeQueries() throws Exception {
    XsdDocument xsdDoc = addXsdDoc();/*from   www .  ja  v a 2  s .  co  m*/
    WsdlDocument wsdlDoc1 = addWsdlDoc();
    WsdlDocument wsdlDoc2 = addWsdlDoc();
    WsdlDocument wsdlDoc3 = addWsdlDoc();

    Map<QName, String> otherAttributes = new HashMap<QName, String>();
    otherAttributes.put(QName.valueOf("FooKey"), "FooValue");
    ArtificerModelUtils.addGenericRelationship(xsdDoc, "relWithAttr", wsdlDoc1.getUuid(), Collections.EMPTY_MAP,
            otherAttributes);
    ArtificerModelUtils.addGenericRelationship(xsdDoc, "relWithAttr", wsdlDoc2.getUuid(), Collections.EMPTY_MAP,
            otherAttributes);
    Map<QName, String> otherAttributes2 = new HashMap<QName, String>();
    otherAttributes2.put(QName.valueOf("FooKey2"), "FooValue2");
    ArtificerModelUtils.addGenericRelationship(xsdDoc, "relWithAttr2", wsdlDoc3.getUuid(),
            Collections.EMPTY_MAP, otherAttributes2);

    xsdDoc = (XsdDocument) persistenceManager.updateArtifact(xsdDoc, ArtifactType.XsdDocument());

    // add custom properties only to one of the wsdls
    Property prop = new Property();
    prop.setPropertyName("FooProperty");
    prop.setPropertyValue("FooValue");
    wsdlDoc1.getProperty().add(prop);

    wsdlDoc1 = (WsdlDocument) persistenceManager.updateArtifact(wsdlDoc1, ArtifactType.WsdlDocument());

    ArtificerQuery query = queryManager
            .createQuery("/s-ramp/xsd/XsdDocument[relWithAttr[s-ramp:getTargetAttribute(., 'FooKey')]]");
    PagedResult<ArtifactSummary> artifactSet = query.executeQuery();
    Assert.assertNotNull(artifactSet);
    Assert.assertEquals(1, artifactSet.getTotalSize());

    query = queryManager.createQuery(
            "/s-ramp/xsd/XsdDocument[relWithAttr[s-ramp:getTargetAttribute(., 'FooKey') = 'FooValue']]");
    artifactSet = query.executeQuery();
    Assert.assertNotNull(artifactSet);
    Assert.assertEquals(1, artifactSet.getTotalSize());

    query = queryManager
            .createQuery("/s-ramp/xsd/XsdDocument[relWithAttr[s-ramp:getTargetAttribute(., 'InvalidKey')]]");
    artifactSet = query.executeQuery();
    Assert.assertNotNull(artifactSet);
    Assert.assertEquals(0, artifactSet.getTotalSize());

    query = queryManager.createQuery(
            "/s-ramp/xsd/XsdDocument[relWithAttr[s-ramp:getTargetAttribute(., 'FooKey') = 'FooValue' and @FooProperty = 'FooValue']]");
    artifactSet = query.executeQuery();
    Assert.assertNotNull(artifactSet);
    Assert.assertEquals(1, artifactSet.getTotalSize());

    query = queryManager.createQuery(
            "/s-ramp/xsd/XsdDocument[relWithAttr[s-ramp:getTargetAttribute(., 'FooKey') = 'FooValue' and @InvalidProperty]]");
    artifactSet = query.executeQuery();
    Assert.assertNotNull(artifactSet);
    Assert.assertEquals(0, artifactSet.getTotalSize());

    query = queryManager.createQuery(
            "/s-ramp/xsd/XsdDocument[relWithAttr[s-ramp:getTargetAttribute(., 'FooKey') = 'FooValue' or @FooProperty = 'FooValue']]");
    artifactSet = query.executeQuery();
    Assert.assertNotNull(artifactSet);
    Assert.assertEquals(1, artifactSet.getTotalSize());

    query = queryManager.createQuery(
            "/s-ramp/xsd/XsdDocument[relWithAttr[s-ramp:getTargetAttribute(., 'FooKey') = 'InvalidValue' or @FooProperty = 'FooValue']]");
    artifactSet = query.executeQuery();
    Assert.assertNotNull(artifactSet);
    Assert.assertEquals(1, artifactSet.getTotalSize());

    query = queryManager.createQuery(
            "/s-ramp/xsd/XsdDocument[relWithAttr[s-ramp:getTargetAttribute(., 'FooKey') = 'InvalidValue' or @FooProperty = 'FooValue']]");
    artifactSet = query.executeQuery();
    Assert.assertNotNull(artifactSet);
    Assert.assertEquals(1, artifactSet.getTotalSize());

    query = queryManager.createQuery("/s-ramp/xsd/XsdDocument[@uuid = ?]/relWithAttr2");
    query.setString(xsdDoc.getUuid());
    artifactSet = query.executeQuery();
    Assert.assertNotNull(artifactSet);
    Assert.assertEquals(1, artifactSet.getTotalSize());

    query = queryManager.createQuery(
            "/s-ramp/xsd/XsdDocument[@uuid = ?]/relWithAttr2[s-ramp:getTargetAttribute(., 'FooKey2')]");
    query.setString(xsdDoc.getUuid());
    artifactSet = query.executeQuery();
    Assert.assertNotNull(artifactSet);
    Assert.assertEquals(1, artifactSet.getTotalSize());
    Assert.assertEquals(wsdlDoc3.getUuid(), artifactSet.getResults().get(0).getUuid());

    query = queryManager.createQuery(
            "/s-ramp/xsd/XsdDocument[@uuid = ?]/relWithAttr2[s-ramp:getTargetAttribute(., 'FooKey2') = 'FooValue2']");
    query.setString(xsdDoc.getUuid());
    artifactSet = query.executeQuery();
    Assert.assertNotNull(artifactSet);
    Assert.assertEquals(1, artifactSet.getTotalSize());
    Assert.assertEquals(wsdlDoc3.getUuid(), artifactSet.getResults().get(0).getUuid());

    query = queryManager.createQuery(
            "/s-ramp/xsd/XsdDocument[@uuid = ?]/relWithAttr2[s-ramp:getTargetAttribute(., 'InvalidKey')]");
    query.setString(xsdDoc.getUuid());
    artifactSet = query.executeQuery();
    Assert.assertNotNull(artifactSet);
    Assert.assertEquals(0, artifactSet.getTotalSize());
}

From source file:org.codice.ddf.security.claims.attributequery.common.AttributeQueryClaimsHandler.java

/**
 * Creates a dynamic service from the provided wsdl location.
 */// w  ww.  j  av a2  s.  c om
protected Service createService() {
    Service service = null;
    URL wsdlURL;
    if (StringUtils.isNotBlank(wsdlLocation) && StringUtils.isNotBlank(serviceName)) {
        try {
            URIResolver uriResolver = new URIResolver();
            uriResolver.resolve("", wsdlLocation, this.getClass());
            wsdlURL = uriResolver.isResolved() ? uriResolver.getURL() : new URL(wsdlLocation);
            service = Service.create(wsdlURL, QName.valueOf(serviceName));
        } catch (Exception e) {
            LOGGER.error("Unable to create service from WSDL location.", e);
        }
    }
    return service;
}

From source file:org.codice.ddf.security.claims.attributequery.common.AttributeQueryClaimsHandler.java

/**
 * Creates a dispatcher for dispatching requests.
 *//*from   w ww  .  ja v a  2s .  c om*/
protected Dispatch<StreamSource> createDispatcher(Service service) {
    Dispatch<StreamSource> dispatch = null;
    if (service != null) {
        dispatch = service.createDispatch(QName.valueOf(portName), StreamSource.class, Service.Mode.MESSAGE);
        dispatch.getRequestContext().put(Dispatch.ENDPOINT_ADDRESS_PROPERTY, externalAttributeStoreUrl);
        dispatch.getRequestContext().put("ws-security.signature.properties", signatureProperties);
        dispatch.getRequestContext().put("ws-security.encryption.properties", encryptionProperties);
        ((DispatchImpl) dispatch).getClient().getBus().getOutInterceptors().add(new LoggingInInterceptor());
        ((DispatchImpl) dispatch).getClient().getBus().getOutInterceptors().add(new LoggingOutInterceptor());
    }
    return dispatch;
}

From source file:org.codice.ddf.spatial.ogc.csw.catalog.endpoint.QueryFilterTransformerProvider.java

private List<QName> getNamespaces(ServiceReference<QueryFilterTransformer> reference) {
    Object id = reference.getProperty("id");
    List<QName> result = new ArrayList<>();
    if (id instanceof List) {
        List<String> namespaces = (List<String>) id;
        for (String namespace : namespaces) {
            result.add(QName.valueOf(namespace));
        }/*from www . j av a2  s  .co m*/
    } else if (id instanceof String) {
        result.add(QName.valueOf((String) id));
    } else {
        LOGGER.debug(
                "QueryFilterTransformer reference has a bad ID property. Must be of type String or List<String>");
        throw new IllegalArgumentException("id must be of type String or a list of Strings");
    }

    return result;
}

From source file:org.codice.ddf.spatial.ogc.wfs.transformer.handlebars.HandlebarsWfsFeatureTransformer.java

public void setFeatureType(String featureType) {
    LOGGER.trace("Setting feature type to: {}", featureType);
    this.featureType = featureType;
    featureTypeQName = QName.valueOf(featureType);
}

From source file:org.eclipse.swordfish.internal.core.interceptor.EndpointResolverInterceptor.java

private QName getInterfaceName(Exchange exchange) {
    QName interfaceName = (QName) exchange.getProperty(Endpoint.INTERFACE_NAME);
    if (interfaceName == null) {
        interfaceName = (QName) exchange.getProperty(MessageExchangeImpl.INTERFACE_NAME_PROP);
        if (interfaceName == null) {
            Map props = getTargetEndpointPrefereces(exchange);
            String interfaceNameString = props != null ? (String) props.get(Endpoint.INTERFACE_NAME) : null;
            interfaceName = interfaceNameString != null ? QName.valueOf(interfaceNameString) : null;
        }//from   w  ww  .j ava  2 s. c o  m
    }
    return interfaceName;
}

From source file:org.eclipse.swordfish.samples.dynamic.consumer.SimpleClient.java

public void sendRequestSynchronously() throws Exception {
    Channel dc = nmr.createChannel();
    Exchange ex = dc.createExchange(Pattern.InOut);
    Message msg = new MessageImpl();
    StreamSource src = new StreamSource(new ByteArrayInputStream(dataToSend.getBytes()));
    msg.setBody(src);//from   ww w . j a v a 2  s  .  com
    ex.setIn(msg);
    ex.setProperty(MessageExchangeImpl.INTERFACE_NAME_PROP, QName.valueOf(interfaceName));
    if (consumerPolicyName != null && consumerPolicyName.length() > 0) {
        ex.setProperty(ServiceResolver.POLICY_CONSUMER_NAME, QName.valueOf(consumerPolicyName));
    }
    ex.setOperation(QName.valueOf(operationName));

    // TODO please find more suitable solution
    Map<String, Object> targetProps = new HashMap<String, Object>();
    targetProps.put(Endpoint.ENDPOINT_NAME, "JustDummyEndpointName");
    ex.setTarget(nmr.getEndpointRegistry().lookup(targetProps));

    LOG.info("!!SimpleClient is sending synchronous request with in message " + dataToSend);

    dc.sendSync(ex);
    if (ex.getError() != null) {
        LOG.error("The invocation wasn't successful", ex.getError());
    }
    if (ex.getFault() != null && ex.getFault().getBody() != null) {
        LOG.error("The invocation wasn't successful " + ex.getFault().getBody().toString());
    }
    LOG.info("!!SimpleClient have received the response: "
            + new SourceTransformer().toString(ex.getOut().getBody(Source.class)));
}