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.wso2.carbon.connector.integration.test.delicious.DeliciousConnectoreIntegrationTest.java

/**
 * Positive test case for deletePost method with optional parameters.
 *//*from   w w w. j  av a2  s. c o m*/
@Test(priority = 5, groups = {
        "wso2.esb" }, description = "delicious {deletePost} integration test with optional parameters")
public void testDeliciousdeletePostWithoptionalParameters() throws Exception {

    String jsonRequestFilePath = pathToResourcesDirectory + "optional/deletePost.txt";

    String rawString = ConnectorIntegrationUtil.getFileContent(jsonRequestFilePath);
    rawString = rawString.replace("bookmarkurl", connectorProperties.getProperty("inputurl"));
    final String jsonString = addCredentials(rawString);

    ConnectorIntegrationUtil responseConnector = new ConnectorIntegrationUtil();
    OMElement omElementC = responseConnector.getXmlResponse("POST", getProxyServiceURL("delicious"),
            jsonString);

    String parameters = "&url=" + connectorProperties.getProperty("inputurl");
    ConnectorIntegrationUtil responseDirect = new ConnectorIntegrationUtil();
    OMElement omElementD = responseDirect.sendXMLRequestWithBasic(
            connectorProperties.getProperty("Apiurl") + "/v1/posts/get?" + parameters, "", validAuthorization);

    Assert.assertTrue(omElementD.getAttributeValue(QName.valueOf("code")).equals("no bookmarks"));

}

From source file:org.wso2.carbon.connector.integration.test.delicious.DeliciousConnectorIntegrationTest.java

/**
 * Positive test case for addNewPost method with mandatory parameters.
 *///ww w. j  a  v a 2 s  .c o  m
@Test(priority = 1, groups = {
        "wso2.esb" }, description = "delicious {addNewPost} integration test with mandatory parameters")
public void testDeliciousaddNewPostWithMandatoryParameters() throws Exception {

    String jsonRequestFilePath = pathToResourcesDirectory + "addNewPost.txt";

    String rawString = ConnectorIntegrationUtil.getFileContent(jsonRequestFilePath);
    rawString = rawString.replace("test_url", connectorProperties.getProperty("inputDescription"));
    rawString = rawString.replace("bookmarkurl", connectorProperties.getProperty("inputurl"));
    final String jsonString = addCredentials(rawString);

    ConnectorIntegrationUtil responseConnector = new ConnectorIntegrationUtil();
    OMElement omElementC = responseConnector.getXmlResponse("POST", getProxyServiceURL("delicious"),
            jsonString);

    ConnectorIntegrationUtil responseDirect = new ConnectorIntegrationUtil();
    OMElement omElementD = responseDirect.sendXMLRequestWithBasic(
            connectorProperties.getProperty("Apiurl") + "/v1/posts/recent?&count=1", "", validAuthorization);

    Assert.assertTrue(omElementD.getFirstElement().getAttributeValue(QName.valueOf("description"))
            .equals(connectorProperties.getProperty("inputDescription")));
}

From source file:org.wso2.carbon.connector.integration.test.delicious.DeliciousConnectorIntegrationTest.java

/**
 * Positive test case for deletePost method with mandatory parameters.
 *//*from w  w  w.  ja  v a 2 s  .c om*/
@Test(priority = 2, groups = {
        "wso2.esb" }, description = "delicious {deletePost} integration test with mandatory parameters")
public void testDeliciousdeletePostWithMandatoryParameters() throws Exception {

    String jsonRequestFilePath = pathToResourcesDirectory + "deletePost.txt";

    String rawString = ConnectorIntegrationUtil.getFileContent(jsonRequestFilePath);
    rawString = rawString.replace("bookmarkurl", connectorProperties.getProperty("inputurl"));
    final String jsonString = addCredentials(rawString);

    ConnectorIntegrationUtil responseConnector = new ConnectorIntegrationUtil();
    OMElement omElementC = responseConnector.getXmlResponse("POST", getProxyServiceURL("delicious"),
            jsonString);

    String parameters = "&url=" + connectorProperties.getProperty("inputurl");
    ConnectorIntegrationUtil responseDirect = new ConnectorIntegrationUtil();
    OMElement omElementD = responseDirect.sendXMLRequestWithBasic(
            connectorProperties.getProperty("Apiurl") + "/v1/posts/get?" + parameters, "", validAuthorization);

    Assert.assertTrue(omElementD.getAttributeValue(QName.valueOf("code")).equals("no bookmarks"));
}

From source file:org.wso2.carbon.connector.integration.test.delicious.DeliciousConnectorIntegrationTest.java

/**
 * Positive test case for setTagsBundles method with mandatory parameters.
 *//*from ww w  .  j  a  v a 2s  . co m*/
@Test(priority = 1, groups = {
        "wso2.esb" }, description = "delicious {setTagsBundles} integration test with mandatory parameters")
public void testDelicioussetTagsBundlesWithMandatoryParameters() throws Exception {

    String jsonRequestFilePath = pathToResourcesDirectory + "setTagsBundles.txt";

    String rawString = ConnectorIntegrationUtil.getFileContent(jsonRequestFilePath);
    final String jsonString = addCredentials(rawString);

    ConnectorIntegrationUtil responseConnector = new ConnectorIntegrationUtil();
    OMElement omElementC = responseConnector.getXmlResponse("POST", getProxyServiceURL("delicious"),
            jsonString);

    String parameters = "&bundle=" + connectorProperties.getProperty("bundle");
    ConnectorIntegrationUtil responseDirect = new ConnectorIntegrationUtil();
    OMElement omElementD = responseDirect.sendXMLRequestWithBasic(
            connectorProperties.getProperty("Apiurl") + "/v1/tags/bundles/all?" + parameters, "",
            validAuthorization);

    Assert.assertTrue(omElementD.getFirstElement().getAttributeValue(QName.valueOf("name"))
            .equals(connectorProperties.getProperty("bundle")));
}

From source file:org.wso2.carbon.connector.integration.test.delicious.DeliciousConnectorIntegrationTest.java

/**
 * Oauth Negetive test case for postGetAll method with Negetive parameters.
 *///from   w  ww . j  a v a  2s . c  o  m
@Test(priority = 2, groups = {
        "wso2.esb" }, description = "delicious {postGetAll} integration test with Negetive parameters")
public void testOauthDeliciouspostGetAllWithNegetiveParameters() throws Exception {

    String jsonRequestFilePath = pathToResourcesDirectory + "negative/postGetAllwithOauth.txt";

    String rawString = ConnectorIntegrationUtil.getFileContent(jsonRequestFilePath);
    rawString = rawString.replace("clientId", connectorProperties.getProperty("invalidclient_id"));
    rawString = rawString.replace("address", connectorProperties.getProperty("Apiurl"));
    rawString = rawString.replace("clientSecret", connectorProperties.getProperty("invalidclient_secret"));
    final String jsonString = addCredentials(rawString);

    ConnectorIntegrationUtil responseDirect = new ConnectorIntegrationUtil();
    OMElement omElementD = responseDirect.sendXMLRequestWithBasic(
            connectorProperties.getProperty("Apiurl") + "/v1/posts/all", "", invalidAuthorization);

    Assert.assertTrue(omElementD.getAttributeValue(QName.valueOf("code")).equals("access denied"));
}

From source file:org.wso2.carbon.connector.integration.test.delicious.DeliciousConnectorIntegrationTest.java

/**
 * Positive test case for addNewPost method with Optional parameters.
 *//*from   w  w w .  j  a  v  a2  s  .  co  m*/
@Test(priority = 3, groups = {
        "wso2.esb" }, description = "delicious {addNewPost} integration test with Optional parameters")
public void testDeliciousaddNewPostWithOptionalParameters() throws Exception {

    String jsonRequestFilePath = pathToResourcesDirectory + "optional/addNewPost.txt";

    String rawString = ConnectorIntegrationUtil.getFileContent(jsonRequestFilePath);
    rawString = rawString.replace("test_url", connectorProperties.getProperty("inputDescriptionWithOptional"));
    rawString = rawString.replace("bookmarkurl", connectorProperties.getProperty("inputurl"));
    final String jsonString = addCredentials(rawString);

    ConnectorIntegrationUtil responseConnector = new ConnectorIntegrationUtil();
    OMElement omElementC = responseConnector.getXmlResponse("POST", getProxyServiceURL("delicious"),
            jsonString);

    ConnectorIntegrationUtil responseDirect = new ConnectorIntegrationUtil();

    OMElement omElementD = responseDirect.sendXMLRequestWithBasic(
            connectorProperties.getProperty("Apiurl") + "/v1/posts/recent?&count=1", "", validAuthorization);

    Assert.assertTrue(omElementD.getFirstElement().getAttributeValue(QName.valueOf("description"))
            .equals(connectorProperties.getProperty("inputDescriptionWithOptional")));
}

From source file:org.wso2.carbon.connector.integration.test.delicious.DeliciousConnectorIntegrationTest.java

/**
 * Positive test case for deletePost method with optional parameters.
 *///from w w  w. j ava 2  s. c  om
@Test(priority = 5, groups = {
        "wso2.esb" }, description = "delicious {deletePost} integration test with optional parameters")
public void testDeliciousdeletePostWithoptionalParameters() throws Exception {

    String jsonRequestFilePath = pathToResourcesDirectory + "optional/deletePost.txt";

    String rawString = ConnectorIntegrationUtil.getFileContent(jsonRequestFilePath);
    rawString = rawString.replace("bookmarkurl", connectorProperties.getProperty("inputurl"));
    final String jsonString = addCredentials(rawString);

    ConnectorIntegrationUtil responseConnector = new ConnectorIntegrationUtil();
    OMElement omElementC = responseConnector.getXmlResponse("POST", getProxyServiceURL("delicious"),
            jsonString);

    String parameters = "&url=" + connectorProperties.getProperty("inputurl");
    ConnectorIntegrationUtil responseDirect = new ConnectorIntegrationUtil();
    OMElement omElementD = responseDirect.sendXMLRequestWithBasic(
            connectorProperties.getProperty("Apiurl") + "/v1/posts/get?" + parameters, "", validAuthorization);

    Assert.assertTrue(omElementD.getAttributeValue(QName.valueOf("code")).equals("no bookmarks"));
}

From source file:org.wso2.carbon.discovery.util.Util.java

/**
 * Convert an array of strings into an array of QName instances. The string
 * values should be in a format which can be reliably converted into the QName
 * type using the QName.valueOf() method.
 *
 * @param array An array of strings - must not be null
 * @return An array of QName instances/*from   w w w  .j  av a2 s. c o  m*/
 */
public static QName[] toQNameArray(String[] array) {
    QName[] qnames = new QName[array.length];
    for (int i = 0; i < array.length; i++) {
        qnames[i] = QName.valueOf(array[i]);
    }
    return qnames;
}

From source file:org.wso2.carbon.humantask.core.api.client.TaskOperationsImpl.java

/**
 * Applies to both tasks and notifications.
 * Returns the rendering  types available for the task or notification.
 *
 * @param taskIdURI : task identifier/*from  w  w  w  . jav a  2 s .c  o  m*/
 * @return : Array of QNames
 * @throws IllegalArgumentFault
 */
public QName[] getRenderingTypes(URI taskIdURI) throws IllegalArgumentFault {
    try {
        final Long taskId = validateTaskId(taskIdURI);

        TaskDAO task = HumanTaskServiceComponent.getHumanTaskServer().getTaskEngine().getScheduler()
                .execTransaction(new Callable<TaskDAO>() {
                    public TaskDAO call() throws Exception {

                        HumanTaskEngine engine = HumanTaskServiceComponent.getHumanTaskServer().getTaskEngine();
                        HumanTaskDAOConnection daoConn = engine.getDaoConnectionFactory().getConnection();
                        TaskDAO task = daoConn.getTask(taskId);
                        validateTaskTenant(task);
                        return task;
                    }
                });
        HumanTaskBaseConfiguration taskConfiguration = HumanTaskServiceComponent.getHumanTaskServer()
                .getTaskStoreManager().getHumanTaskStore(task.getTenantId())
                .getTaskConfiguration(QName.valueOf(task.getName()));
        List<QName> renderingTypes = taskConfiguration.getRenderingTypes();
        QName[] types = new QName[renderingTypes.size()];
        types = renderingTypes.toArray(types);
        return types;
    } catch (Exception ex) {
        log.error(ex);
        throw new IllegalArgumentFault(ex);
    }
}

From source file:org.wso2.carbon.humantask.core.api.client.TaskOperationsImpl.java

/**
 * Returns the rendering specified by the type parameter.
 * @param taskIdURI task identifier//from   w  ww .ja  v  a 2  s  .  c o  m
 * @param qName rendering type
 * @return rendering string
 * @throws IllegalArgumentFault
 */
public Object getRendering(final URI taskIdURI, final QName qName) throws IllegalArgumentFault {
    final Long taskId = validateTaskId(taskIdURI);
    try {
        String rendering = HumanTaskServiceComponent.getHumanTaskServer().getTaskEngine().getScheduler()
                .execTransaction(new Callable<String>() {
                    public String call() throws Exception {
                        HumanTaskEngine engine = HumanTaskServiceComponent.getHumanTaskServer().getTaskEngine();
                        HumanTaskDAOConnection daoConn = engine.getDaoConnectionFactory().getConnection();
                        TaskDAO task = daoConn.getTask(taskId);
                        validateTaskTenant(task);
                        HumanTaskBaseConfiguration taskConfiguration = HumanTaskServiceComponent
                                .getHumanTaskServer().getTaskStoreManager()
                                .getHumanTaskStore(task.getTenantId())
                                .getTaskConfiguration(QName.valueOf(task.getName()));
                        return CommonTaskUtil.getRendering(task, taskConfiguration, qName);

                    }
                });
        return rendering;
    } catch (Exception e) {
        log.error(e);
        throw new IllegalArgumentFault(e);
    }
}