List of usage examples for java.net URI URI
public URI(String str) throws URISyntaxException
From source file:com.ettrema.httpclient.CopyMethod.java
public CopyMethod(String uri, String newUri) throws URISyntaxException { setURI(new URI(uri)); this.newUri = newUri; addHeader("Destination", newUri); }
From source file:com.ettrema.httpclient.MoveMethod.java
public MoveMethod(String uri, String newUri) throws URISyntaxException { setURI(new URI(uri)); this.newUri = newUri; addHeader("Destination", newUri); }
From source file:kontrol.HttpUtil.java
public static boolean exists(String url) { try {/*from w w w . ja v a 2s.c o m*/ return getCookielessHttpClient(1000).execute(new HttpHead(new URI(url)), new BasicHttpContext()) .getStatusLine().getStatusCode() < 400; } catch (URISyntaxException e) { log.warn(e.getMessage()); return false; } catch (ClientProtocolException e) { log.warn(e.getMessage()); return false; } catch (IOException e) { log.warn(e.getMessage()); return false; } }
From source file:com.ettrema.httpclient.UnLockMethod.java
public UnLockMethod(String uri, String lockToken) throws URISyntaxException { setURI(new URI(uri)); this.lockToken = lockToken; addHeader("Lock-Token", lockToken); }
From source file:com.microsoft.azuretools.adauth.ResponseUtils.java
public static AuthorizationResult parseAuthorizeResponse(String webAuthenticationResult, CallState callState) throws URISyntaxException, UnsupportedEncodingException { AuthorizationResult result = null;/*from w w w .ja v a 2 s.com*/ URI resultUri = new URI(webAuthenticationResult); // NOTE: The Fragment property actually contains the leading '#' character and that must be dropped String resultData = resultUri.getQuery(); if (resultData != null && !resultData.isEmpty()) { // Remove the leading '?' first Map<String, String> map = UriUtils.formQueryStirng(resultData); if (map.containsKey(OAuthHeader.CorrelationId)) { String correlationIdHeader = (map.get(OAuthHeader.CorrelationId)).trim(); try { UUID correlationId = UUID.fromString(correlationIdHeader); if (!correlationId.equals(callState.correlationId)) { log.log(Level.WARNING, "Returned correlation id '" + correlationId + "' does not match the sent correlation id '" + callState.correlationId + "'"); } } catch (IllegalArgumentException ex) { log.log(Level.WARNING, "Returned correlation id '" + correlationIdHeader + "' is not in GUID format."); } } if (map.containsKey(OAuthReservedClaim.Code)) { result = new AuthorizationResult(map.get(OAuthReservedClaim.Code)); } else if (map.containsKey(OAuthReservedClaim.Error)) { result = new AuthorizationResult(map.get(OAuthReservedClaim.Error), map.get(OAuthReservedClaim.ErrorDescription), map.get(OAuthReservedClaim.ErrorSubcode)); } else { result = new AuthorizationResult(AuthError.AuthenticationFailed, AuthErrorMessage.AuthorizationServerInvalidResponse); } } return result; }
From source file:net.refractions.udig.document.source.ShpDocUtils.java
/** * Gets the relative path with the url as the parent path and the absolute path as the child * path.//from ww w . j a va 2s. c om * * @param url * @param absolutePath * @return relative path */ public static String getRelativePath(URL url, String absolutePath) { if (absolutePath != null && absolutePath.trim().length() > 0) { try { final File parentFile = new File(new URI(url.toString())); final File parentDir = parentFile.getParentFile(); final File childFile = new File(absolutePath); return parentDir.toURI().relativize(childFile.toURI()).getPath(); } catch (URISyntaxException e) { // Should not happen as shapefile should be a valid file e.printStackTrace(); } } return null; }
From source file:biz.gabrys.lesscss.extended.compiler.source.FtpSourceFactory.java
public FtpSource createAbsoluteSource(final LessSource source, final String importAbsolutePath) { try {/*w w w .j ava2 s. c om*/ final URI importUri = new URI(importAbsolutePath).normalize(); return new FtpSource(importUri.toURL(), source.getEncoding()); } catch (final URISyntaxException e) { throw new SourceFactoryException("Cannot normalize URL", e); } catch (final MalformedURLException e) { throw new SourceFactoryException("Cannot create relative URL", e); } }
From source file:com.opengamma.web.bundle.BundleParserTest.java
public void testParser() throws Exception { InputStream xmlStream = getClass().getResourceAsStream("uiResourceConfig.xml"); UriProvider uriProvider = new UriProvider() { @Override//from w w w.j a v a2s . c o m public URI getUri(String resourceReference) { try { return new URI(resourceReference); } catch (URISyntaxException ex) { throw new OpenGammaRuntimeException("Invalid URI for resource " + resourceReference); } } }; BundleParser bundleParser = new BundleParser(uriProvider, ""); BundleManager bundleManager = bundleParser.parse(xmlStream); assertNotNull(bundleManager); List<Fragment> cssBundleCommon = bundleManager.getBundle("cssBundleCommon.css").getAllFragments(); assertNotNull(cssBundleCommon); assertEquals(2, cssBundleCommon.size()); assertEquals(new Fragment(new URI("styles/common/og.common.buttons.css"), "/styles/common/og.common.buttons.css"), cssBundleCommon.get(0)); assertEquals(new Fragment(new URI("styles/common/og.common.core.css"), "/styles/common/og.common.core.css"), cssBundleCommon.get(1)); List<Fragment> cssUtil = bundleManager.getBundle("cssUtil.css").getAllFragments(); assertNotNull(cssUtil); assertEquals(2, cssUtil.size()); assertEquals(new Fragment(new URI("styles/common/util/og.common.reset.css"), "/styles/common/util/og.common.reset.css"), cssUtil.get(0)); assertEquals(new Fragment(new URI("styles/common/util/og.common.links.css"), "/styles/common/util/og.common.links.css"), cssUtil.get(1)); List<Fragment> jsBundleCommon = bundleManager.getBundle("jsBundleCommon.js").getAllFragments(); assertNotNull(jsBundleCommon); assertEquals(3, jsBundleCommon.size()); assertEquals(new Fragment(new URI("scripts/og/common/og.common.core.js"), "/scripts/og/common/og.common.core.js"), jsBundleCommon.get(0)); assertEquals(new Fragment(new URI("scripts/og/common/og.common.init.js"), "/scripts/og/common/og.common.init.js"), jsBundleCommon.get(1)); assertEquals(new Fragment(new URI("scripts/og/common/og.common.jquery.rest.js"), "/scripts/og/common/og.common.jquery.rest.js"), jsBundleCommon.get(2)); List<Fragment> cssOgCommon = bundleManager.getBundle("ogCommon.css").getAllFragments(); assertNotNull(cssOgCommon); assertEquals(cssBundleCommon.size() + cssUtil.size(), cssOgCommon.size()); int i = 0; for (Fragment fragment : cssBundleCommon) { assertEquals(fragment, cssOgCommon.get(i++)); } for (Fragment fragment : cssUtil) { assertEquals(fragment, cssOgCommon.get(i++)); } List<Fragment> jsOgCommon = bundleManager.getBundle("ogCommon.js").getAllFragments(); assertNotNull(jsOgCommon); assertEquals(jsBundleCommon.size(), jsOgCommon.size()); int j = 0; for (Fragment fragment : jsBundleCommon) { assertEquals(fragment, jsOgCommon.get(j++)); } IOUtils.closeQuietly(xmlStream); }
From source file:biz.gabrys.lesscss.extended.compiler.source.HttpSourceFactory.java
public HttpSource createAbsoluteSource(final LessSource source, final String importAbsolutePath) { try {//from ww w . jav a 2 s . c o m final URI importUri = new URI(importAbsolutePath).normalize(); return new HttpSource(importUri.toURL()); } catch (final URISyntaxException e) { throw new SourceFactoryException("Cannot normalize URL", e); } catch (final MalformedURLException e) { throw new SourceFactoryException("Cannot create relative URL", e); } }
From source file:com.yahoo.research.scoring.classifier.NutchOnlineClassifier.java
public static void main(String[] args) { try {/*from w w w . j ava 2 s . co m*/ URI urlTmp = new URI("http://www.google.com"); System.out.println(urlTmp.getPath()); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } }