List of usage examples for java.net URI toString
public String toString()
From source file:URIUtils.java
/** * Resolves a URI reference against a base URI. Work-around for bug in * java.net.URI (<http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4708535>) * * @param baseURI the base URI/*from w w w. j a v a2 s . c o m*/ * @param reference the URI reference * @return the resulting URI */ public static URI resolve(final URI baseURI, URI reference) { if (baseURI == null) { throw new IllegalArgumentException("Base URI may nor be null"); } if (reference == null) { throw new IllegalArgumentException("Reference URI may nor be null"); } boolean emptyReference = reference.toString().length() == 0; if (emptyReference) { reference = URI.create("#"); } URI resolved = baseURI.resolve(reference); if (emptyReference) { String resolvedString = resolved.toString(); resolved = URI.create(resolvedString.substring(0, resolvedString.indexOf('#'))); } return resolved; }
From source file:com.cloud.utils.UriUtils.java
public static String formNfsUri(String host, String path) { try {//from ww w. j av a 2 s. co m URI uri = new URI("nfs", host, path, null); return uri.toString(); } catch (URISyntaxException e) { throw new CloudRuntimeException("Unable to form nfs URI: " + host + " - " + path); } }
From source file:org.altchain.neo4j.database.Database.java
public static URI createNode() { final String nodeEntryPointUri = SERVER_ROOT_URI + "node"; WebResource resource = Client.create().resource(nodeEntryPointUri); ClientResponse response = resource.accept(MediaType.APPLICATION_JSON).type(MediaType.APPLICATION_JSON) .entity("{}").post(ClientResponse.class); final URI location = response.getLocation(); logger.debug(String.format("POST to [%s], status code [%d], location header [%s]", nodeEntryPointUri, response.getStatus(), location.toString())); response.close();//from w ww. ja va2s. c o m return location; }
From source file:com.cloud.utils.UriUtils.java
public static String formIscsiUri(String host, String iqn, Integer lun) { try {/*www . jav a 2 s . c om*/ String path = iqn; if (lun != null) { path += "/" + lun.toString(); } URI uri = new URI("iscsi", host, path, null); return uri.toString(); } catch (URISyntaxException e) { throw new CloudRuntimeException("Unable to form iscsi URI: " + host + " - " + iqn + " - " + lun); } }
From source file:cool.pandora.modeller.ui.handlers.common.TextSequenceMetadata.java
/** * getTextSequenceMetadata.//from ww w. j av a 2s . co m * * @param resourceIDList Map * @param pageId String * @param canvasRegionURI String * @param collectionPredicate String * @param resourceContainerIRI URI * @return InputStream */ public static InputStream getTextSequenceMetadata(final Map<String, List<String>> resourceIDList, final String pageId, final String canvasRegionURI, final String collectionPredicate, final URI resourceContainerIRI) { final ArrayList<String> idList = new ArrayList<>(resourceIDList.get(pageId)); final TextCollectionWriter collectionWriter; collectionWriter = TextCollectionWriter.collection().idList(idList).collectionPredicate(collectionPredicate) .resourceContainerIRI(resourceContainerIRI.toString()).canvasURI(canvasRegionURI).build(); final String collection = collectionWriter.render(); final MetadataTemplate metadataTemplate; final List<CollectionScope.Prefix> prefixes = Arrays.asList(new CollectionScope.Prefix(FedoraPrefixes.RDFS), new CollectionScope.Prefix(FedoraPrefixes.MODE)); final CollectionScope scope = new CollectionScope().fedoraPrefixes(prefixes).sequenceGraph(collection); metadataTemplate = MetadataTemplate.template().template("template/sparql-update-seq" + ".mustache") .scope(scope).throwExceptionOnFailure().build(); final String metadata = unescapeXml(metadataTemplate.render()); return IOUtils.toInputStream(metadata, UTF_8); }
From source file:com.collective.celos.Util.java
public static String augmentHdfsPath(String hdfsPrefix, String path) throws URISyntaxException { if (hdfsPrefix.isEmpty() || hdfsPrefix.equals("/")) { return path; }/*from w ww. j ava2s.c om*/ for (String ch : conversions.keySet()) { path = path.replace(ch.toString(), conversions.get(ch).toString()); } URI oldUri = URI.create(path); String host = oldUri.getHost(); if (oldUri.getRawSchemeSpecificPart().startsWith("///") && host == null) { host = ""; } URI newUri = new URI(oldUri.getScheme(), oldUri.getUserInfo(), host, oldUri.getPort(), hdfsPrefix + oldUri.getPath(), oldUri.getQuery(), oldUri.getFragment()); path = newUri.toString(); for (String ch : backConversions.keySet()) { path = path.replace(ch.toString(), backConversions.get(ch).toString()); } return path; }
From source file:org.webinos.android.util.ModuleUtils.java
public static File getResource(URI httpUri, boolean download) throws IOException { String cacheFilename = getResourceUriHash(httpUri.toString()); File cachedFile = new File(resourceDir, cacheFilename); if (cachedFile.exists()) return cachedFile; if (download) return downloadResource(httpUri, cacheFilename); return null;//from www. j a va 2s. c o m }
From source file:com.vmware.identity.openidconnect.protocol.ProviderMetadataMapper.java
public static ProviderMetadata parse(JSONObject json) throws ParseException { Validate.notNull(json, "json"); URI issuerURI = JSONUtils.getURI(json, "issuer"); URI authorizationEndpointURI = JSONUtils.getURI(json, "authorization_endpoint"); URI tokenEndpointURI = JSONUtils.getURI(json, "token_endpoint"); URI endSessionEndpointURI = JSONUtils.getURI(json, "end_session_endpoint"); URI jwkSetURI = JSONUtils.getURI(json, "jwks_uri"); return new ProviderMetadata(new Issuer(issuerURI.toString()), authorizationEndpointURI, tokenEndpointURI, endSessionEndpointURI, jwkSetURI); }
From source file:eu.stratosphere.runtime.fs.hdfs.DistributedFileSystem.java
private static final String getMissingAuthorityErrorPrefix(URI path) { return "The given HDFS file URI (" + path.toString() + ") did not describe the HDFS Namenode." + " The attempt to use a default HDFS configuration, as specified in the '" + ConfigConstants.HDFS_DEFAULT_CONFIG + "' or '" + ConfigConstants.HDFS_SITE_CONFIG + "' config parameter failed due to the following problem: "; }
From source file:org.eel.kitchen.jsonschema.uri.URIManagerTest.java
private static void checkMsg(final Message msg, final String message, final URI uri) { assertSame(msg.getDomain(), Domain.REF_RESOLVING); assertEquals(msg.getKeyword(), "N/A"); // FIXME... assertEquals(msg.getMessage(), message); assertEquals(msg.getInfo("uri").textValue(), uri.toString()); }