List of usage examples for java.net URI toString
public String toString()
From source file:edu.stanford.junction.Junction.java
public static URI getWebInvitation(String webUrl, URI inviteUri) { // TODO: Improve me; look for query parameters etc. return URI.create(webUrl + "?jxuri=" + URLEncoder.encode(inviteUri.toString())); }
From source file:org.mule.tools.rhinodo.impl.NodeModuleImplBuilder.java
private static NodeModuleImpl extractFromPackageJson(URI root) { if (root == null) { throw new IllegalArgumentException("Error validating rootDirectory"); }//from w w w . j a va 2 s. co m URI packageJson; try { packageJson = new URI(root.toString() + "/" + "package.json"); } catch (URISyntaxException e) { throw new RuntimeException(e); } boolean exists; if ("file".equals(packageJson.getScheme())) { exists = new File(packageJson).exists(); } else { throw new IllegalStateException( String.format("Error: scheme [%s] not supported.", packageJson.getScheme())); } if (!exists) { throw new IllegalStateException(String.format("Error: package.json not found at [%s].", packageJson)); } return NodeModuleImpl.create(root, NodeModuleImplBuilder.<String, String>getPackageJSONMap(new File(packageJson.getPath()))); }
From source file:Neo4JDataExporter.java
public static URI createNode() { final String nodeEntryPointUri = SERVER_ROOT_URI + "node"; // http://localhost:7474/db/data/node WebResource resource = Client.create().resource(nodeEntryPointUri); // POST {} to the node entry point URI ClientResponse response = resource.accept(MediaType.APPLICATION_JSON).type(MediaType.APPLICATION_JSON) .entity("{}").post(ClientResponse.class); final URI location = response.getLocation(); System.out.println(String.format("POST to [%s], status code [%d], location header [%s]", nodeEntryPointUri, response.getStatus(), location.toString())); response.close();/*w w w. java2 s .c om*/ return location; }
From source file:org.altchain.neo4j.database.Database.java
public static void addMetadataToProperty(URI relationshipUri, String name, String value) throws URISyntaxException { URI propertyUri = new URI(relationshipUri.toString() + "/properties"); String entity = toJsonNameValuePairCollection(name, value); WebResource resource = Client.create().resource(propertyUri); ClientResponse response = resource.accept(MediaType.APPLICATION_JSON).type(MediaType.APPLICATION_JSON) .entity(entity).put(ClientResponse.class); logger.debug(//w w w.java 2 s . co m String.format("PUT [%s] to [%s], status code [%d]", entity, propertyUri, response.getStatus())); response.close(); }
From source file:ch.ethz.inf.vs.hypermedia.client.Utils.java
public static String resolve(String base, String... relativePaths) throws URISyntaxException { URI uri = new URI(base); for (String relativePath : relativePaths) { if (relativePath != null) { uri = URIUtils.resolve(uri, relativePath); }/*from w ww . jav a 2 s. co m*/ } return uri.toString(); }
From source file:org.altchain.neo4j.database.Database.java
public static void addProperty(URI nodeUri, String propertyName, Object propertyValue) { // START SNIPPET: addProp String propertyUri = nodeUri.toString() + "/properties/" + propertyName; // http://localhost:7474/db/data/node/{node_id}/properties/{property_name} WebResource resource = Client.create().resource(propertyUri); ClientResponse response = null;/*from w w w . j a va2 s . c om*/ if (propertyValue.getClass() == String.class) { response = resource.accept(MediaType.APPLICATION_JSON).type(MediaType.APPLICATION_JSON) .entity("\"" + propertyValue + "\"").put(ClientResponse.class); } else { response = resource.accept(MediaType.APPLICATION_JSON).type(MediaType.APPLICATION_JSON) .entity(propertyValue.toString()).put(ClientResponse.class); } logger.debug(String.format("PUT to [%s], status code [%d]", propertyUri, response.getStatus())); response.close(); }
From source file:com.microsoft.tfs.client.common.ui.teamexplorer.helpers.ArtifactLinkHelpers.java
private static void openCommitLink(final ArtifactID artifact) { final String[] parts = artifact.getToolSpecificID().split("/"); //$NON-NLS-1$ if (parts.length != 3) { return;/* www .j a v a 2 s. co m*/ } final String projectID = parts[0]; final String repositoryID = parts[1]; final String commitID = parts[2]; final TFSServer server = TFSCommonUIClientPlugin.getDefault().getProductPlugin().getServerManager() .getDefaultServer(); final TFSTeamProjectCollection collection = server.getConnection(); final ProjectInfo[] projects = server.getProjectCache().getTeamProjects(); String projectName = null; for (final ProjectInfo proj : projects) { if (proj.getGUID().equals(projectID)) { projectName = proj.getName(); break; } } if (projectName != null) { final boolean isHosted = collection.getServerCapabilities().contains(ServerCapabilities.HOSTED); final TSWAHyperlinkBuilder builder = new TSWAHyperlinkBuilder(collection, isHosted); final URI uri = builder.getGitCommitURL(projectName, repositoryID, commitID); BrowserFacade.launchURL(uri, uri.toString()); } }
From source file:Main.java
public static Document parseXmlFile(URI uri, boolean validating) throws SAXException, IOException, ParserConfigurationException { DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); factory.setValidating(validating);// w w w. ja v a2 s.c o m Document doc = factory.newDocumentBuilder().parse(uri.toString()); return doc; }
From source file:cool.pandora.modeller.ui.handlers.iiif.PatchSequenceHandler.java
private static InputStream getSequenceMetadata(final ArrayList<String> resourceIDList, final String collectionPredicate, final URI resourceContainerIRI) { final RDFCollectionWriter collectionWriter; collectionWriter = RDFCollectionWriter.collection().idList(resourceIDList) .collectionPredicate(collectionPredicate).resourceContainerIRI(resourceContainerIRI.toString()) .build();// w w w.j av a 2 s. c om 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:eu.eubrazilcc.lvl.core.util.UrlUtils.java
/** * Returns a list of name-value pairs as built from the URI's query portion. * @param uri - input URI//from w w w . j a va2 s.co m * @return a list of name-value pairs as built from the URI's query portion. * @throws IllegalArgumentException If a malformed URI occurs. */ public static Map<String, String> getQueryParams(final URI uri) { checkArgument(uri != null, "Uninitialized URI"); try { final URI nUri = uri.normalize(); final URL url = nUri.isAbsolute() ? nUri.toURL() : new URL(new URL("http://example.org/"), nUri.toString()); final String query = new URL(URLDecoder.decode(url.toString(), defaultCharset().name())).getQuery(); final Map<String, String> map = newHashMap(); final List<NameValuePair> pairs = URLEncodedUtils.parse(query, defaultCharset()); final Iterator<NameValuePair> iterator = pairs.iterator(); while (iterator.hasNext()) { final NameValuePair pair = iterator.next(); map.put(pair.getName(), pair.getValue()); } return map; } catch (MalformedURLException | UnsupportedEncodingException e) { throw new IllegalArgumentException("Malformed URI", e); } }