Java Code Examples for java.net.URI.create()

The following are Jave code examples for showing how to use create() of the java.net.URI class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: fresco_floodlight   File: OFSwitch.java   View Source Code Vote up 6 votes
@Override
public void updateControllerConnections(OFBsnControllerConnectionsReply controllerCxnsReply) {

	// Instantiate clean map, can't use a builder here since we need to call temp.get()
	Map<URI,Map<OFAuxId, OFBsnControllerConnection>> temp = new ConcurrentHashMap<URI,Map<OFAuxId, OFBsnControllerConnection>>();

	List<OFBsnControllerConnection> controllerCxnUpdates = controllerCxnsReply.getConnections();
	for(OFBsnControllerConnection update : controllerCxnUpdates) {
		URI uri = URI.create(update.getUri());

		Map<OFAuxId, OFBsnControllerConnection> cxns = temp.get(uri);

		// Add to nested map
		if(cxns != null){
			cxns.put(update.getAuxiliaryId(), update);
		} else{
			cxns = new ConcurrentHashMap<OFAuxId, OFBsnControllerConnection>();
			cxns.put(update.getAuxiliaryId(), update);
			temp.put(uri, cxns);
		}
	}

	this.controllerConnections = ImmutableMap.<URI,Map<OFAuxId, OFBsnControllerConnection>>copyOf(temp);
}
 
Example 2
Project: ingest-core   File: MetadataDocumentMessageBuilder.java   View Source Code Vote up 5 votes
public MetadataDocumentMessage build() {
    // todo - here, we make link with DUMMY_BASE_URI and then take it out again so clients can fill in domain - must be a better way of doing this!
    RepositoryLinkBuilder rlb = new RepositoryLinkBuilder(mappings.getMetadataFor(documentType),
                                                          new BaseUri(URI.create(DUMMY_BASE_URI)));
    Link link = rlb
            .slash(metadataDocId)
            .withRel(mappings.getMetadataFor(documentType).getItemResourceRel());
    String callbackLink = link.withSelfRel().getHref().replace(DUMMY_BASE_URI, "");

    return new MetadataDocumentMessage(documentType.getSimpleName().toLowerCase(), metadataDocId, metadataDocUuid, callbackLink);
}
 
Example 3
Project: JRediClients   File: BinaryJedis.java   View Source Code Vote up 5 votes
public BinaryJedis(final String host) {
	URI uri = URI.create(host);
	if (uri.getScheme() != null && uri.getScheme().equals("redis")) {
		initializeClientFromURI(uri);
	} else {
		client = new Client(host);
	}
}
 
Example 4
Project: mxisd   File: UserDirectoryController.java   View Source Code Vote up 5 votes
@RequestMapping(path = "/search", method = RequestMethod.POST)
public String search(HttpServletRequest request, @RequestParam("access_token") String accessToken) throws IOException {
    UserDirectorySearchRequest searchQuery = parser.parse(request, UserDirectorySearchRequest.class);
    URI target = URI.create(request.getRequestURL().toString());
    UserDirectorySearchResult result = mgr.search(target, accessToken, searchQuery.getSearchTerm());
    return gson.toJson(result);
}
 
Example 5
Project: minijax   File: ServletRequestContextTest.java   View Source Code Vote up 5 votes
@Test(expected = UnsupportedOperationException.class)
public void testGetRequest() throws IOException {
    final MockHttpServletRequest mockRequest = new MockHttpServletRequest("GET", URI.create("/"));
    try (final MinijaxRequestContext context = new MinijaxRequestContext(null, mockRequest, null)) {
        context.getRequest();
    }
}
 
Example 6
Project: javaide   File: TestJavacParser.java   View Source Code Vote up 5 votes
public void test2() {
    Context context = new Context();
    DiagnosticCollector<JavaFileObject> diagnostics = new DiagnosticCollector<>();
    context.put(DiagnosticListener.class, diagnostics);
    Options.instance(context).put("allowStringFolding", "false");
    JCTree.JCCompilationUnit unit;
    JavacFileManager fileManager = new JavacFileManager(context, true, UTF_8);
    try {
        fileManager.setLocation(StandardLocation.PLATFORM_CLASS_PATH, ImmutableList.<File>of());
    } catch (IOException e) {
        // impossible
        throw new IOError(e);
    }
    SimpleJavaFileObject source =
            new SimpleJavaFileObject(URI.create("source"), JavaFileObject.Kind.SOURCE) {
                @Override
                public CharSequence getCharContent(boolean ignoreEncodingErrors) throws IOException {
                    return src;
                }
            };
    Log.instance(context).useSource(source);
    ParserFactory parserFactory = ParserFactory.instance(context);
    Parser parser =
            parserFactory.newParser(
                    src,
        /*keepDocComments=*/ true,
        /*keepEndPos=*/ true,
        /*keepLineMap=*/ true);
    unit = parser.parseCompilationUnit();
    unit.sourcefile = source;
}
 
Example 7
Project: hadoop   File: TestHftpFileSystem.java   View Source Code Vote up 5 votes
@Test
public void testHsftpCustomUriPortWithDefaultPorts() throws IOException {
  Configuration conf = new Configuration();
  URI uri = URI.create("hsftp://localhost:123");
  HsftpFileSystem fs = (HsftpFileSystem) FileSystem.get(uri, conf);

  assertEquals(DFSConfigKeys.DFS_NAMENODE_HTTPS_PORT_DEFAULT,
      fs.getDefaultPort());

  assertEquals(uri, fs.getUri());
  assertEquals("127.0.0.1:123", fs.getCanonicalServiceName());
}
 
Example 8
Project: xlight_android_native   File: WsURLStreamHandlerImpl.java   View Source Code Vote up 5 votes
private URI _getSpecURI(String spec) {
    URI specURI = URI.create(spec);

    if (_scheme.indexOf(':') == -1) {
        return specURI;
    }
    
    String schemeSpecificPart = specURI.getSchemeSpecificPart();
    return URI.create(schemeSpecificPart);
}
 
Example 9
Project: verify-hub   File: SamlMessageSenderApiResourceTest.java   View Source Code Vote up 5 votes
@Test
public void sendUnsignedJsonAuthnResponseFromHub_shouldRespondWithNextLocation() throws Exception {
    SessionId sessionId = SessionId.createNewSessionId();
    URI nextLocationUri = URI.create("http://blah");
    String requestId = UUID.randomUUID().toString();

    Function<OutboundResponseFromHub, String> outboundResponseFromHubToStringTransformer =
            new HubTransformersFactory().getOutboundResponseFromHubToStringTransformer(
                    new HardCodedKeyStore(HUB_ENTITY_ID),
                    getKeyStore(),
                    new IdpHardCodedEntityToEncryptForLocator(),
                    SIGNATURE_ALGORITHM,
                    DIGEST_ALGORITHM);
    OutboundResponseFromHub authnResponseFromHub = anAuthnResponse()
            .withInResponseTo(requestId)
            .withIssuerId(HUB_ENTITY_ID)
            .withTransactionIdaStatus(TransactionIdaStatus.Success)
            .buildOutboundResponseFromHub();
    String samlString = outboundResponseFromHubToStringTransformer.apply(authnResponseFromHub);

    AuthnResponseFromHubContainerDto authnResponseFromHubContainerDto = new AuthnResponseFromHubContainerDto(
            samlString,
            nextLocationUri,
            com.google.common.base.Optional.absent(),
            authnResponseFromHub.getId());

    policyStubRule.anAuthnResponseFromHubToRp(sessionId, authnResponseFromHubContainerDto);

    javax.ws.rs.core.Response response = getResponseFromSamlProxy(Urls.SamlProxyUrls.SEND_RESPONSE_FROM_HUB_API_RESOURCE, sessionId);
    assertThat(response.readEntity(SamlMessageSenderHandler.SamlMessage.class).getPostEndpoint()).isEqualTo(nextLocationUri.toASCIIString());
}
 
Example 10
Project: flume-release-1.7.0   File: TestDatasetSink.java   View Source Code Vote up 5 votes
@Test
public void testMiniClusterStore() throws EventDeliveryException, IOException {
  // setup a minicluster
  MiniDFSCluster cluster = new MiniDFSCluster
      .Builder(new Configuration())
      .build();

  FileSystem dfs = cluster.getFileSystem();
  Configuration conf = dfs.getConf();

  URI hdfsUri = URI.create(
      "dataset:" + conf.get("fs.defaultFS") + "/tmp/repo" + DATASET_NAME);
  try {
    // create a repository and dataset in HDFS
    Datasets.create(hdfsUri, DESCRIPTOR);

    // update the config to use the HDFS repository
    config.put(DatasetSinkConstants.CONFIG_KITE_DATASET_URI, hdfsUri.toString());

    DatasetSink sink = sink(in, config);

    // run the sink
    sink.start();
    sink.process();
    sink.stop();

    Assert.assertEquals(
        Sets.newHashSet(expected),
        read(Datasets.load(hdfsUri)));
    Assert.assertEquals("Should have committed", 0, remaining(in));

  } finally {
    if (Datasets.exists(hdfsUri)) {
      Datasets.delete(hdfsUri);
    }
    cluster.shutdown();
  }
}
 
Example 11
Project: jpms-module-names   File: Generator.java   View Source Code Vote up 4 votes
URI toMvnRepositoryURI() {
  var base = "https://mvnrepository.com/artifact/";
  return URI.create(base + String.join("/", group, artifact));
}
 
Example 12
Project: yaacc-code   File: MusicAllTitleItemBrowser.java   View Source Code Vote up 4 votes
@Override
public DIDLObject browseMeta(YaaccContentDirectory contentDirectory,
                             String myId) {
    Item result = null;
    String[] projection = {MediaStore.Audio.Media._ID,
            MediaStore.Audio.Media.DISPLAY_NAME,
            MediaStore.Audio.Media.MIME_TYPE, MediaStore.Audio.Media.SIZE,
            MediaStore.Audio.Media.ALBUM, MediaStore.Audio.Media.ALBUM_ID,
            MediaStore.Audio.Media.TITLE, MediaStore.Audio.Media.ARTIST,
            MediaStore.Audio.Media.DURATION};
    String selection = MediaStore.Audio.Media._ID + "=?";
    String[] selectionArgs = new String[]{myId
            .substring(ContentDirectoryIDs.MUSIC_ALL_TITLES_ITEM_PREFIX
                    .getId().length())};
    Cursor mediaCursor = contentDirectory
            .getContext()
            .getContentResolver()
            .query(MediaStore.Audio.Media.EXTERNAL_CONTENT_URI, projection,
                    selection, selectionArgs, null);

    if (mediaCursor != null) {
        mediaCursor.moveToFirst();
        String id = mediaCursor.getString(mediaCursor
                .getColumnIndex(MediaStore.Audio.Media._ID));
        String name = mediaCursor.getString(mediaCursor
                .getColumnIndex(MediaStore.Audio.Media.DISPLAY_NAME));
        Long size = Long.valueOf(mediaCursor.getString(mediaCursor
                .getColumnIndex(MediaStore.Audio.Media.SIZE)));

        String album = mediaCursor.getString(mediaCursor
                .getColumnIndex(MediaStore.Audio.Media.ALBUM));
        String albumId = mediaCursor.getString(mediaCursor
                .getColumnIndex(MediaStore.Audio.Media.ALBUM_ID));
        String title = mediaCursor.getString(mediaCursor
                .getColumnIndex(MediaStore.Audio.Media.TITLE));
        String artist = mediaCursor.getString(mediaCursor
                .getColumnIndex(MediaStore.Audio.Media.ARTIST));
        String duration = mediaCursor.getString(mediaCursor
                .getColumnIndex(MediaStore.Audio.Media.DURATION));
        duration = contentDirectory.formatDuration(duration);
        Log.d(getClass().getName(),
                "Mimetype: "
                        + mediaCursor.getString(mediaCursor
                        .getColumnIndex(MediaStore.Audio.Media.MIME_TYPE)));

        MimeType mimeType = MimeType.valueOf(mediaCursor
                .getString(mediaCursor
                        .getColumnIndex(MediaStore.Audio.Media.MIME_TYPE)));
        // file parameter only needed for media players which decide
        // the
        // ability of playing a file by the file extension

        String uri = getUriString(contentDirectory, id, mimeType);
        URI albumArtUri = URI.create("http://"
                + contentDirectory.getIpAddress() + ":"
                + YaaccUpnpServerService.PORT + "/?album=" + albumId);
        Res resource = new Res(mimeType, size, uri);
        resource.setDuration(duration);
        MusicTrack musicTrack = new MusicTrack(
                ContentDirectoryIDs.MUSIC_ALL_TITLES_ITEM_PREFIX.getId()
                        + id,
                ContentDirectoryIDs.MUSIC_ALL_TITLES_FOLDER.getId(), title
                + "-(" + name + ")", "", album, artist, resource);
        musicTrack
                .replaceFirstProperty(new UPNP.ALBUM_ART_URI(albumArtUri));
        result = musicTrack;
        Log.d(getClass().getName(), "MusicTrack: " + id + " Name: " + name
                + " uri: " + uri);

        mediaCursor.close();
    } else {
        Log.d(getClass().getName(), "Item " + myId + "  not found.");
    }

    return result;
}
 
Example 13
Project: openjdk-jdk10   File: T7086601b.java   View Source Code Vote up 4 votes
public JavaSource() {
    super(URI.create("myfo:/Test.java"), JavaFileObject.Kind.SOURCE);
    source = bodyTemplate.replace("#A1", a1.typeStr)
                     .replace("#A2", a2.typeStr).replace("#A3", a3.typeStr)
                     .replace("#MC", mck.invokeString);
}
 
Example 14
Project: encdroidMC   File: HttpPropFind.java   View Source Code Vote up 4 votes
public HttpPropFind(final String uri)
{
	this(URI.create(uri));
}
 
Example 15
Project: minijax   File: MockHttpServletRequestTest.java   View Source Code Vote up 4 votes
@Test(expected = UnsupportedOperationException.class)
public void testIsRequestedSessionIdFromUrl() {
    final MockHttpServletRequest r = new MockHttpServletRequest("GET", URI.create("/"));
    r.isRequestedSessionIdFromUrl();
}
 
Example 16
Project: neoscada   File: MqttExporter.java   View Source Code Vote up 4 votes
/**
 * @return default mqtt uri given through system property
 */
private URI getDefaultUri ()
{
    return URI.create ( System.getProperty ( "org.eclipse.scada.da.server.mqtt.exporter.uri", "tcp://localhost:1883" ) );
}
 
Example 17
Project: minijax   File: MockHttpServletRequestTest.java   View Source Code Vote up 4 votes
@Test(expected = UnsupportedOperationException.class)
public void testGetProtocol() {
    final MockHttpServletRequest r = new MockHttpServletRequest("GET", URI.create("/"));
    r.getProtocol();
}
 
Example 18
Project: universal-resolver   File: ClientUniResolver.java   View Source Code Vote up 3 votes
@Override
public DDO resolve(String identifier) throws ResolutionException {

	// prepare HTTP request

	String uriString = this.getResolverUri().toString();
	if (! uriString.endsWith("/")) uriString += "/";
	uriString += identifier;

	HttpGet httpGet = new HttpGet(URI.create(uriString));

	// retrieve DDO

	DDO ddo;

	try (CloseableHttpResponse httpResponse = (CloseableHttpResponse) this.getHttpClient().execute(httpGet)) {

		if (httpResponse.getStatusLine().getStatusCode() == 404) return null;
		if (httpResponse.getStatusLine().getStatusCode() > 200) throw new ResolutionException("Cannot retrieve DDO for " + identifier + " from " + uriString + ": " + httpResponse.getStatusLine());

		HttpEntity httpEntity = httpResponse.getEntity();

		ddo = DDO.fromString(EntityUtils.toString(httpEntity));
		EntityUtils.consume(httpEntity);
	} catch (IOException ex) {

		throw new ResolutionException("Cannot retrieve DDO for " + identifier + " from " + uriString + ": " + ex.getMessage(), ex);
	}

	if (log.isDebugEnabled()) log.debug("Retrieved DDO for " + identifier + " (" + uriString + "): " + ddo);

	// done

	return ddo;
}
 
Example 19
Project: aos-MediaLib   File: XMLRPCClient.java   View Source Code Vote up 2 votes
/**
 * Convenience XMLRPCClient constructor. Creates new instance based on server URL
 * @param XMLRPC server URL
 */
public XMLRPCClient(URL url) {
	this(URI.create(url.toExternalForm()));
}
 
Example 20
Project: fuck_zookeeper   File: Util.java   View Source Code Vote up 2 votes
/**
 * Given two directory files the method returns a well-formed 
 * logfile provider URI. This method is for backward compatibility with the
 * existing code that only supports logfile persistence and expects these two
 * parameters passed either on the command-line or in the configuration file.
 * 
 * @param dataDir snapshot directory
 * @param dataLogDir transaction log directory
 * @return logfile provider URI
 */
public static URI makeFileLoggerURL(File dataDir, File dataLogDir){
    return URI.create(makeURIString(dataDir.getPath(),dataLogDir.getPath(),null));
}