Example usage for java.net URI create

List of usage examples for java.net URI create

Introduction

In this page you can find the example usage for java.net URI create.

Prototype

public static URI create(String str) 

Source Link

Document

Creates a URI by parsing the given string.

Usage

From source file:io.joynr.messaging.bounceproxy.IsCreateChannelHttpRequest.java

@Override
public boolean matches(Object argument) {

    HttpRequest request = (HttpRequest) argument;

    // check if tracking ID is sent in header
    Header trackingIdHeader = request.getFirstHeader("X-Atmosphere-tracking-id");
    if (trackingIdHeader == null) {
        // no tracking ID header set at all
        return false;
    } else {/*from  ww  w  .  j  a  va2 s  .co m*/
        if (!trackingIdHeader.getValue().equals(trackingId)) {
            // wrong tracking ID header set
            return false;
        }
    }

    // check if channel ID is sent as query parameter ccid
    List<NameValuePair> queryParameters = URLEncodedUtils.parse(URI.create(request.getRequestLine().getUri()),
            "UTF-8");
    for (NameValuePair queryParameter : queryParameters) {
        if (queryParameter.getName().equals("ccid") && queryParameter.getValue().equals(ccid)) {
            // right channel ID sent
            return true;
        } else {
            // wrong channel ID sent
            return false;
        }
    }
    // no query parameter with ccid sent at all
    return false;
}

From source file:com.fujitsu.dc.client.http.HttpMkColMethod.java

/**
 * This is the parameterized constructor calling its parent constructor and setting URI after formatting it.
 * @param uri Target URL string/*from   w  w  w  .jav  a 2  s.co m*/
 */
public HttpMkColMethod(final String uri) {
    super();
    setURI(URI.create(uri));
}

From source file:cf.client.DefaultUaa.java

public DefaultUaa(HttpClient httpClient, String uaaUri) {
    this(httpClient, URI.create(uaaUri));
}

From source file:com.fujitsu.dc.client.http.HttpMergeMethod.java

/**
 * This is the parameterized constructor calling its parent constructor and setting URI after formatting it.
 * @param uri Target URL string//from   w  ww  .  j a va 2s .  co  m
 */
public HttpMergeMethod(final String uri) {
    super();
    setURI(URI.create(uri));
}

From source file:com.liquid.wallpapers.free.dao.wallpapers.parsing.JsonWallpaperParser.java

@Override
public List<Wallpaper> parse(String data) throws ParseException {
    try {//from ww w  . java 2s .co m
        JSONArray array = new JSONArray(data);
        List<Wallpaper> wallpapers = new ArrayList<Wallpaper>();

        for (int i = 0; i < array.length(); i++) {
            JSONObject jsonWallpaper = array.getJSONObject(i);

            wallpapers.add(new Wallpaper(jsonWallpaper.getString(Messages.getString("JsonWallpaperParser.0")), //$NON-NLS-1$
                    jsonWallpaper.getString(Messages.getString("JsonWallpaperParser.1")), URI //$NON-NLS-1$
                            .create(jsonWallpaper.getString(Messages.getString("JsonWallpaperParser.2"))), //$NON-NLS-1$
                    URI.create(jsonWallpaper.getString(Messages.getString("JsonWallpaperParser.3"))), URI //$NON-NLS-1$
                            .create(jsonWallpaper.getString(Messages.getString("JsonWallpaperParser.4"))), //$NON-NLS-1$
                    jsonWallpaper.getString(Messages.getString("JsonWallpaperParser.5")))); //$NON-NLS-1$
        }

        return wallpapers;
    } catch (JSONException ex) {
        throw new ParseException(ex.getMessage(), 0);
    }
}

From source file:com.cloudera.nav.plugin.client.PluginConfigurationFactory.java

/**
 * Create a PluginConfiguration from the properties contained in the
 * given filePath/*from w w w .j  a v a 2s  .co m*/
 *
 * @param filePath
 * @return
 */
public PluginConfigurations readConfigurations(String filePath) {
    try {
        PropertiesConfiguration props = new PropertiesConfiguration(filePath);
        PluginConfigurations config = new PluginConfigurations();
        config.setApplicationUrl(props.getString(APP_URL));
        config.setFileFormat(FileFormat.valueOf(props.getString(FILE_FORMAT, FileFormat.JSON.name())));
        config.setMetadataParentUri(URI.create(props.getString(METADATA_URI)));
        config.setNamespace(props.getString(NAMESPACE));
        config.setNavigatorUrl(props.getString(NAV_URL));
        config.setUsername(props.getString(USERNAME));
        config.setPassword(props.getString(PASSWORD));
        return config;
    } catch (ConfigurationException e) {
        throw Throwables.propagate(e);
    }
}

From source file:com.fujitsu.dc.client.http.HttpPropfindMethod.java

/**
 * This is the parameterized constructor calling its parent constructor and setting URI after formatting it.
 * @param uri Target URL string//  w w  w .ja  v a 2  s . c o  m
 */
public HttpPropfindMethod(final String uri) {
    super();
    setURI(URI.create(uri));
}

From source file:com.fujitsu.dc.client.http.HttpPropPatchMethod.java

/**
 * This is the parameterized constructor calling its parent constructor and setting URI after formatting it.
 * @param uri Target URL string//ww w.  j a  v  a2s.c  om
 */
public HttpPropPatchMethod(final String uri) {
    super();
    setURI(URI.create(uri));
}

From source file:org.springframework.cloud.dataflow.rest.util.HttpClientConfigurerTests.java

/**
 * Basic test ensuring that the {@link HttpClient} is built successfully with
 * null username and password.//from  www .j a v  a2  s . c  o m
 */
@Test
public void testThatHttpClientWithProxyIsCreatedWithNullUsernameAndPassword() throws Exception {
    final URI targetHost = new URI("http://test.com");
    final HttpClientConfigurer builder = HttpClientConfigurer.create(targetHost);
    builder.withProxyCredentials(URI.create("https://spring.io"), null, null);
    builder.buildHttpClient();
}

From source file:com.sap.core.odata.fit.ref.contentnegotiation.ContentNegotiationGetRequestTest.java

@Test
public void acceptHeaderAppAtomXml() throws Exception {
    HttpGet get = new HttpGet(URI.create(getEndpoint() + "Rooms('1')"));
    get.setHeader(HttpHeaders.ACCEPT, HttpContentType.APPLICATION_ATOM_XML);
    final HttpResponse response = new DefaultHttpClient().execute(get);

    final String contentType = response.getFirstHeader(HttpHeaders.CONTENT_TYPE).getValue();
    assertEquals(ContentType.create(HttpContentType.APPLICATION_ATOM_XML_ENTRY_UTF8),
            ContentType.create(contentType));

    assertNotNull(StringHelper.inputStreamToString(response.getEntity().getContent()));
}