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.cleverbus.core.common.spring.SpringQNameConverter.java

@Override
public QName convert(String source) {
    return QName.valueOf(source);
}

From source file:Main.java

public static String convertToXpath(String qname) {
    QName name = QName.valueOf(qname);
    if ("".equals(name.getNamespaceURI())) {
        return "//" + name.getLocalPart();
    } else {//from   ww  w  .ja  v  a2 s.  c om
        return "//*[local-name()='" + name.getLocalPart() + "' and namespace-uri()='" + name.getNamespaceURI()
                + "']";
    }
}

From source file:com.centeractive.ws.builder.core.WsdlParser.java

public SoapBuilderFinderResult binding(final String bindingName) {
    Preconditions.checkNotNull(bindingName);
    return new SoapBuilderFinderResult() {
        @Override//w  w w . j  a  v  a 2 s  . c  o  m
        public SoapBuilder builder() {
            return getBuilder(QName.valueOf(bindingName), SoapContext.DEFAULT);
        }

        @Override
        public SoapBuilder builder(final SoapContext context) {
            return getBuilder(QName.valueOf(bindingName), context);
        }

        @Override
        public SoapOperationFinder operation() {
            return builder().operation();
        }
    };
}

From source file:eu.esdihumboldt.hale.io.csv.writer.internal.CSVInstanceWriter.java

/**
 * @see eu.esdihumboldt.hale.common.core.io.impl.AbstractIOProvider#execute(eu.esdihumboldt.hale.common.core.io.ProgressIndicator,
 *      eu.esdihumboldt.hale.common.core.io.report.IOReporter)
 *//*from www  .j  a  v  a  2 s . c  o m*/
@Override
protected IOReport execute(ProgressIndicator progress, IOReporter reporter)
        throws IOProviderConfigurationException, IOException {

    boolean solveNestedProperties = getParameter(InstanceTableIOConstants.SOLVE_NESTED_PROPERTIES)
            .as(Boolean.class, false);
    // XXX what does "solve nested properties" mean?

    // get separation, quote and escape sign
    sep = CSVUtil.getSep(this);
    quote = CSVUtil.getQuote(this);
    esc = CSVUtil.getEscape(this);

    List<String> headerRow = new ArrayList<String>();

    // get the parameter to get the type definition
    String exportType = getParameter(InstanceTableIOConstants.EXPORT_TYPE).as(String.class);
    QName selectedTypeName = null;

    if (exportType != null && !exportType.equals("") && !exportType.equals(" ")) {
        selectedTypeName = QName.valueOf(exportType);
    }

    // get all instances of the selected Type
    InstanceCollection instances = getInstanceCollection(selectedTypeName);
    Iterator<Instance> instanceIterator = instances.iterator();
    Instance instance = null;
    try {
        instance = instanceIterator.next();
    } catch (NoSuchElementException e) {
        reporter.error(new IOMessageImpl("There are no instances for the selected type.", e));
        return reporter;
    }

    // get definition of current instance (only this properties with this
    // definition type will be written to csv file)
    TypeDefinition definition = instance.getDefinition();

    // first csv file doesn't have a header row, so it' necessary to write
    // it to a temp directory
    File tempDir = Files.createTempDir();
    File tempFile = new File(tempDir, "tempInstances.csv");

    // write instances to csv file (without header)
    CSVWriter writer = new CSVWriter(new OutputStreamWriter(new FileOutputStream(tempFile)), sep, quote, esc);
    writeLine(solveNestedProperties, headerRow, instance, writer);

    while (instanceIterator.hasNext()) {
        Instance nextInst = instanceIterator.next();
        if (nextInst.getDefinition().equals(definition)) {

            writeLine(solveNestedProperties, headerRow, nextInst, writer);
        }
    }
    writer.close();

    // header is only finished if all properties have been processed
    // insert header to temp file and write it to output
    insertHeader(tempFile, getTarget().getOutput(), headerRow);

    FileUtils.deleteDirectory(tempDir);

    reporter.setSuccess(true);
    return reporter;
}

From source file:com.dulion.astatium.mesh.shredder.ContextManager.java

List<Context> findContexts(String name) {
    return unmodifiableList(contextMap.get(QName.valueOf(name)));
}

From source file:org.apache.servicemix.camel.JbiEndpoint.java

@SuppressWarnings("unchecked")
private void parseUri(String uri) {
    destinationUri = uri;/*  w w  w . ja  v a  2 s  .c  o m*/
    try {
        int idx = destinationUri.indexOf('?');
        if (idx > 0) {
            Map params = URISupport.parseQuery(destinationUri.substring(idx + 1));
            mep = (String) params.get("mep");
            if (mep != null && !mep.startsWith("http://www.w3.org/ns/wsdl/")) {
                mep = "http://www.w3.org/ns/wsdl/" + mep;
            }
            String oper = (String) params.get("operation");
            if (StringUtils.hasLength(oper)) {
                operation = QName.valueOf(oper);
            }
            this.destinationUri = destinationUri.substring(0, idx);

            String filter = (String) params.get("headerFilterStrategy");
            if (StringUtils.hasLength(filter)) {
                Registry registry = jbiComponent.getCamelContext().getRegistry();
                if (filter.indexOf('#') != -1) {
                    filter = filter.substring(1);
                }
                Object object = registry.lookup(filter);
                if (object instanceof HeaderFilterStrategy) {
                    headerFilterStrategy = (HeaderFilterStrategy) object;
                }
                params.remove("headerFilterStrategy");
            }
            String convert = (String) params.get("convertExceptions");
            if (StringUtils.hasLength(convert)) {
                this.setConvertExceptions(Boolean.valueOf(convert));
                params.remove("convertExceptions");
            }
            String serialization = (String) params.get("serialization");
            if (StringUtils.hasLength(serialization)) {
                this.setStrictSerialization(STRICT_SERIALIZATION.equalsIgnoreCase(serialization));
                params.remove("serialization");
            }
            timeout = parseLong("timeout", (String) params.get("timeout"));
            String endpointUri = this.destinationUri + URISupport.createQueryString(params);
            this.setEndpointUri(endpointUri);
        }
    } catch (URISyntaxException e) {
        throw new JbiException(e);
    }
}

From source file:com.telefonica.euro_iaas.sdc.puppetwrapper.auth.OpenStackAuthenticationProviderTest.java

@Test
public void shouldCreatesNewTokenAndValidateWhenAdminTokenIsNotAuthorized()
        throws AuthenticationConnectionException {
    // given//from  w w w.j a  va  2  s .  c  om

    String adminToken = "fa63ea912a2a579c2542dbb90951d500";

    OpenStackAuthenticationProvider openStackAuthenticationProvider = new OpenStackAuthenticationProvider();
    openStackAuthenticationProvider.setAdminPass("admin");
    openStackAuthenticationProvider.setAdminTenant("00000000000000000000000000000001");
    openStackAuthenticationProvider.setAdminUser("admin");
    openStackAuthenticationProvider.setKeystoneURL("http://keystone.test");
    openStackAuthenticationProvider.setThresholdString("1");
    openStackAuthenticationToken = mock(OpenStackAuthenticationToken.class);
    openStackAuthenticationProvider.oSAuthToken = openStackAuthenticationToken;
    Client client = mock(Client.class);
    openStackAuthenticationProvider.setClient(client);
    WebTarget webResource = mock(WebTarget.class);
    Invocation.Builder builder = mock(Invocation.Builder.class);
    WebTarget webResource2 = mock(WebTarget.class);
    Invocation.Builder builder2 = mock(Invocation.Builder.class);
    Response clientResponse = mock(Response.class);
    Response response401 = mock(Response.class);
    AuthenticateResponse authenticateResponse = mock(AuthenticateResponse.class);

    // when
    when(openStackAuthenticationToken.getCredentials()).thenReturn(new String[] { adminToken, "string2" });
    when(client.target("http://keystone.test")).thenReturn(webResource).thenReturn(webResource2);
    when(webResource.path(any(String.class))).thenReturn(webResource);
    when(webResource.request()).thenReturn(builder);
    when(builder.header(anyString(), anyString())).thenReturn(builder);
    when(builder.header(eq("X-Auth-Token"), anyString())).thenReturn(builder);
    when(builder.get()).thenReturn(response401);
    when(response401.getStatus()).thenReturn(401);

    when(webResource2.path(any(String.class))).thenReturn(webResource2);
    when(webResource2.request()).thenReturn(builder2);
    when(builder2.header(anyString(), anyString())).thenReturn(builder2);
    when(builder2.header(eq("X-Auth-Token"), anyString())).thenReturn(builder2);
    when(builder2.get(AuthenticateResponse.class)).thenReturn(authenticateResponse);

    Token validToken = mock(Token.class);
    TenantForAuthenticateResponse tenantForAuthenticateResponse = mock(TenantForAuthenticateResponse.class);
    UserForAuthenticateResponse userForAuthenticateResponse = mock(UserForAuthenticateResponse.class);
    when(authenticateResponse.getToken()).thenReturn(validToken);
    when(validToken.getTenant()).thenReturn(tenantForAuthenticateResponse);
    when(tenantForAuthenticateResponse.getId()).thenReturn("user tenantId");
    when(authenticateResponse.getUser()).thenReturn(userForAuthenticateResponse);
    when(userForAuthenticateResponse.getRoles()).thenReturn(null);
    Map<QName, String> collection = new HashMap<QName, String>();
    collection.put(QName.valueOf("username"), "value");
    when(userForAuthenticateResponse.getOtherAttributes()).thenReturn(collection);

    PaasManagerUser paasManagerUser = openStackAuthenticationProvider.authenticationFiware("user token",
            "user tenantId");

    // then
    assertNotNull(paasManagerUser);
    verify(openStackAuthenticationToken, times(2)).getCredentials();
}

From source file:com.ibm.soatf.component.soap.builder.Wsdl.java

public SoapBuilder getBuilder(String bindingName, SoapContext context) {
    if (bindingName == null) {
        throw new SoapBuilderException("BindingName cannot be null");
    }// ww w. j a  v  a2  s.c o m
    return getBuilder(QName.valueOf(bindingName), context);
}

From source file:com.sap.dirigible.runtime.agent.WsApplyHandler.java

private void addWebService(String remoteFile, HttpServletRequest request) throws IOException {

    logger.debug("entering: " + this.getClass().getCanonicalName() + " -> " //$NON-NLS-1$ //$NON-NLS-2$
            + "addWebService"); //$NON-NLS-1$

    InputStream wsMetaDataIn = getRemoteFile(remoteFile, request);

    // {"address":"/publish_address","wsdl":"/projectXXX/fileXXX.wsdl","serviceName":"{http://example.com}ServiceXXX","processorType":"CAMEL","processor":"direct:camel_idXXX"}

    String wsMetaData = IOUtils.toString(wsMetaDataIn);

    logger.debug("WS Metadata: " + wsMetaData); //$NON-NLS-1$

    JsonParser parser = new JsonParser();
    JsonObject wsService = (JsonObject) parser.parse(wsMetaData);
    String address = wsService.get(PARAMETER_ADDRESS).getAsString();
    String wsdl = wsService.get(PARAMETER_WSDL).getAsString();
    String serviceName = wsService.get(PARAMETER_SERVICE_NAME).getAsString();
    QName serviceQName = QName.valueOf(serviceName);
    String processorType = wsService.get(PARAMETER_PROCESSOR_TYPE).getAsString();
    String processor = wsService.get(PARAMETER_PROCESSOR).getAsString();
    InputStream wsdlIn = getRemoteFile(wsdl, request);
    File wsdlFile = createTempWsdlFile(wsdl, wsdlIn);

    try {//  w w w  .  j a v a  2s . c  om
        // create provider service implementor - retrieve and redirect the
        // message
        Object implementor = new WsEndpointProviderImplementor(getConfigurationAgent(), processorType,
                processor);

        // stop the endpoint if already published
        stopIfPublished(address);

        EndpointImpl jaxwsEndpoint = new EndpointImpl(CXFBusFactory.getDefaultBus(), implementor, (String) null,
                wsdlFile.getCanonicalPath());
        jaxwsEndpoint.setServiceName(serviceQName);
        jaxwsEndpoint.setAddress(address);
        jaxwsEndpoint.getProperties().put(ConfigurationCommands.PROPERTY_REPOSITORY_LOCATION, remoteFile);
        jaxwsEndpoint.getProperties().put(ConfigurationCommands.PROPERTY_EXPOSED_AT, new Date());
        jaxwsEndpoint.publish();

        logger.debug(String.format(
                ENDPOINT_WITH_PROCESSOR_TYPE_S_AND_PROCESSOR_S_AND_FORMAT_S_AND_Q_NAME_S_AT_ADDRESS_S_HAS_BEEN_PUBLISHED_SUCCESSFULLY,
                processorType, processor, serviceQName.toString(), address));
    } finally {
        clean(wsdlFile);
    }

    logger.debug("exiting: " + this.getClass().getCanonicalName() + " -> " //$NON-NLS-1$ //$NON-NLS-2$
            + "addWebService"); //$NON-NLS-1$
}

From source file:com.centeractive.ws.builder.core.WsdlParser.java

public SoapBuilder getBuilder(String bindingName) {
    return getBuilder(QName.valueOf(bindingName));
}