List of usage examples for java.net URI URI
public URI(String str) throws URISyntaxException
From source file:org.chaplib.TestHttpResourceFactory.java
@Test public void nonequalURIsResultInDifferentHttpResources() throws Exception { URI uri2 = new URI("http://foo.example.com/bar/baz/quxx"); assertFalse(impl.get(uri) == impl.get(uri2)); }
From source file:cool.pandora.modeller.util.ResourceObjectNode.java
/** * ResourceObjectNode./*w ww . j av a 2 s .c om*/ * * @param resourceURI String * @param resourceProperty String */ ResourceObjectNode(final String resourceURI, final String resourceProperty) { try { final String resource = ModellerClient.doGetContainerResources(new URI(resourceURI)); final Model model = ModelFactory.createDefaultModel(); model.read(new ByteArrayInputStream(resource != null ? resource.getBytes() : new byte[0]), null, "TTL"); this.resourceValue = getValue(model, resourceProperty); } catch (final ModellerClientFailedException e) { System.out.println(getMessage(e)); } catch (final URISyntaxException e) { e.printStackTrace(); } }
From source file:de.tu_berlin.dima.aim3.naivebayes.io.BinaryInputFormat.java
public BinaryInputFormat(String pathString) throws IOException, URISyntaxException { fs = FileSystem.get(new URI(pathString)); Path path = new Path(pathString); final FileStatus pathFile = fs.getFileStatus(path); if (pathFile.isDir()) { // input is directory. list all contained files final FileStatus[] dir = fs.listStatus(path); for (int i = 0; i < dir.length; i++) { if (!dir[i].isDir()) { String fileName = dir[i].getPath().getName(); if (fileName.startsWith(".") == false) { files.add(dir[i]);/*from w w w . ja v a 2 s. c om*/ } } } } else { files.add(pathFile); } getNextReader(); }
From source file:org.opencredo.couchdb.transformer.CouchDbUrlToDocumentTransformerNamespaceTest.java
@Test public void transformStringId() throws Exception { URI uri = new URI("http://test"); DummyDocument document = new DummyDocument("test"); when(documentOperations.readDocument(eq(uri), eq(DummyDocument.class))).thenReturn(document); Object response = messagingTemplate.convertSendAndReceive(uri, DummyDocument.class); assertThat(response, instanceOf(DummyDocument.class)); DummyDocument responseDocument = (DummyDocument) response; assertThat(responseDocument, equalTo(document)); }
From source file:org.commonjava.aprox.dotmaven.settings.AbstractSettingsTest.java
protected final String getDotMavenUrl(final String path) throws URISyntaxException, MalformedURLException { final String mavdavPath = PathUtils.normalize("/../mavdav", path); System.out.println("Resolving dotMaven URL. Base URL: '" + client.getBaseUrl() + "'\ndotMaven path: '" + mavdavPath + "'"); final URI result = resolve(new URI(client.getBaseUrl()), new URI(mavdavPath)); System.out.println("Resulting URI: '" + result.toString() + "'"); final String url = result.toURL().toExternalForm(); System.out.println("Resulting URL: '" + url + "'"); return url;/*from w w w .java 2 s . c om*/ }
From source file:de.betterform.connector.file.FileURIResolver.java
/** * Performs link traversal of the <code>file</code> URI and returns the * result as a DOM document.//from w w w . java 2s .c om * * @return a DOM node parsed from the <code>file</code> URI. * @throws XFormsException if any error occurred during link traversal. */ public Object resolve() throws XFormsException { try { // create uri URI uri = new URI(getURI()); // use scheme specific part in order to handle UNC names String fileName = uri.getSchemeSpecificPart(); if (LOGGER.isDebugEnabled()) { LOGGER.debug("loading file '" + fileName + "'"); } // create file File file = new File(fileName); // check for directory if (file.isDirectory()) { return FileURIResolver.buildDirectoryListing(file); } // parse file DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); factory.setNamespaceAware(true); factory.setValidating(false); Document document = factory.newDocumentBuilder().parse(file); /* Document document = CacheManager.getDocument(file); if(document == null) { document = DOMResource.newDocumentBuilder().parse(file); CacheManager.putIntoFileCache(file, document); } */ // check for fragment identifier if (uri.getFragment() != null) { return document.getElementById(uri.getFragment()); } return document; } catch (Exception e) { //todo: improve error handling as files might fail due to missing DTDs or Schemas - this won't be detected very well throw new XFormsException(e); } }
From source file:com.expedia.seiso.web.hateoas.link.PaginationLinkBuilderTests.java
@Before public void setUp() throws Exception { val uri = new URI("https://seiso.example.com/v2/cars/find-by-name"); this.uriComponents = UriComponentsBuilder.fromUri(uri).build(); this.params = new LinkedMultiValueMap<String, String>(); params.set("name", "honda"); this.builder = paginationLinkBuilder(3, 20, 204); }
From source file:ca.sfu.federation.action.ShowHelpWebSiteAction.java
/** * Handle action performed event./* w w w. j ava 2 s . co m*/ * @param ae Event */ public void actionPerformed(ActionEvent ae) { try { URI uri = new URI(ApplicationContext.PROJECT_HELP_WEBSITE_URL); // open the default web browser for the HTML page logger.log(Level.INFO, "Opening desktop browser to {0}", uri.toString()); Desktop.getDesktop().browse(uri); } catch (Exception ex) { String stack = ExceptionUtils.getFullStackTrace(ex); logger.log(Level.WARNING, "Could not open browser for help web site {0}\n\n{1}", new Object[] { ApplicationContext.PROJECT_HELP_WEBSITE_URL, stack }); } }
From source file:de.hanbei.resources.http.HttpResourceLocator.java
public InputStream getResource(String name) { HttpClient client = new DefaultHttpClient(); try {/* w w w . j av a 2s. c om*/ URI resourceUri = new URI(name); HttpGet get = new HttpGet(resourceBase.resolve(resourceUri)); HttpResponse response = client.execute(get); if (200 == response.getStatusLine().getStatusCode()) { return response.getEntity().getContent(); } else { LOGGER.warn("Resource {} not found on base {}", name, resourceBase); return null; } } catch (URISyntaxException e) { // exceptions are allowed as null will be returned. } catch (ClientProtocolException e) { } catch (IOException e) { } finally { client.getConnectionManager().shutdown(); } LOGGER.warn("Resource {} not found on base {}", name, resourceBase); return null; }
From source file:in.rab.ordboken.CookieSerializer.java
public String saveToString() { try {/* w w w .jav a 2s. c om*/ URI uri = new URI("http://" + mDomain); List<HttpCookie> cookies = mCookieStore.get(uri); JSONObject obj = new JSONObject(); JSONArray cookieStrings = new JSONArray(); for (HttpCookie cookie : cookies) { cookieStrings.put(cookie.toString()); } obj.put("cookies", cookieStrings); return obj.toString(); } catch (Exception e) { return null; } }