List of usage examples for java.net URI equals
public boolean equals(Object ob)
From source file:com.microsoft.tfs.client.common.server.ServerManager.java
public final TFSServer getServer(URI uri) { Check.notNull(uri, "uri"); //$NON-NLS-1$ uri = URIUtils.removeTrailingSlash(uri); synchronized (lock) { if (defaultServer != null && uri.equals(URIUtils.removeTrailingSlash(defaultServer.getConnection().getBaseURI()))) { return defaultServer; }//from w w w . j a va2 s. c o m return null; } }
From source file:net.ripe.rpki.validator.fetchers.ValidatingCertificateRepositoryObjectFetcher.java
private ManifestCms getManifestValidatedForCrl(final URI crlUri, CertificateRepositoryObjectValidationContext context, ValidationResult result, final X509Crl crl) { ValidationLocation savedCurrentLocation = result.getCurrentLocation(); result.setLocation(new ValidationLocation(context.getManifestURI())); try {/* w ww. java2 s .co m*/ ManifestCms manifest = fetcher.getManifest(context.getManifestURI(), context, result); if (manifest == null) { return null; } manifest.validate(context.getManifestURI().toString(), context, new CrlLocator() { @Override public X509Crl getCrl(URI uri, CertificateRepositoryObjectValidationContext context, ValidationResult result) { Validate.isTrue(uri.equals(crlUri)); return crl; } }, options, result); if (result.hasFailureForCurrentLocation()) { return null; } return manifest; } finally { result.setLocation(savedCurrentLocation); } }
From source file:org.esigate.impl.UrlRewriter.java
/** * Fixes a referer url in a request.//www .jav a2 s . c om * * @param referer * the url to fix (can be anything found in an html page, relative, absolute, empty...) * @param baseUrl * The base URL selected for this request. * @param visibleBaseUrl * The base URL viewed by the browser. * * @return the fixed url. */ public String rewriteReferer(String referer, String baseUrl, String visibleBaseUrl) { URI uri = UriUtils.createURI(referer); // Base url should end with / if (!baseUrl.endsWith("/")) { baseUrl = baseUrl + "/"; } URI baseUri = UriUtils.createURI(baseUrl); // If no visible url base is defined, use base url as visible base url if (!visibleBaseUrl.endsWith("/")) { visibleBaseUrl = visibleBaseUrl + "/"; } URI visibleBaseUri = UriUtils.createURI(visibleBaseUrl); // Relativize url to visible base url URI relativeUri = visibleBaseUri.relativize(uri); // If the url is unchanged do nothing if (relativeUri.equals(uri)) { LOG.debug("url kept unchanged: [{}]", referer); return referer; } // Else rewrite replacing baseUrl by visibleBaseUrl URI result = baseUri.resolve(relativeUri); LOG.debug("referer fixed: [{}] -> [{}]", referer, result); return result.toString(); }
From source file:org.esigate.impl.UrlRewriter.java
/** * Fixes an url according to the chosen mode. * // ww w. j a v a 2s. co m * @param url * the url to fix (can be anything found in an html page, relative, absolute, empty...) * @param requestUrl * The incoming request URL (could be absolute or relative to visible base url). * @param baseUrl * The base URL selected for this request. * @param visibleBaseUrl * The base URL viewed by the browser. * @param absolute * Should the rewritten urls contain the scheme host and port * * @return the fixed url. */ public String rewriteUrl(String url, String requestUrl, String baseUrl, String visibleBaseUrl, boolean absolute) { // Base url should end with / if (!baseUrl.endsWith("/")) { baseUrl = baseUrl + "/"; } URI baseUri = UriUtils.createURI(baseUrl); // If no visible url base is defined, use base url as visible base url if (!visibleBaseUrl.endsWith("/")) { visibleBaseUrl = visibleBaseUrl + "/"; } URI visibleBaseUri = UriUtils.createURI(visibleBaseUrl); // Build the absolute Uri of the request sent to the backend URI requestUri; if (requestUrl.startsWith(visibleBaseUrl)) { requestUri = UriUtils.createURI(requestUrl); } else { requestUri = UriUtils.concatPath(baseUri, requestUrl); } // Interpret the url relatively to the request url (may be relative) URI uri = UriUtils.resolve(url, requestUri); // Normalize the path (remove . or .. if possible) uri = uri.normalize(); // Try to relativize url to base url URI relativeUri = baseUri.relativize(uri); // If the url is unchanged do nothing if (relativeUri.equals(uri)) { LOG.debug("url kept unchanged: [{}]", url); return url; } // Else rewrite replacing baseUrl by visibleBaseUrl URI result = visibleBaseUri.resolve(relativeUri); // If mode relative, remove all the scheme://host:port to keep only a url relative to server root (starts with // "/") if (!absolute) { result = UriUtils.removeServer(result); } LOG.debug("url fixed: [{}] -> [{}]", url, result); return result.toString(); }
From source file:de.ii.ldproxy.rest.LdProxyServiceResourceFactory.java
@Override public Response getResponseForParams(Collection<Service> services, UriInfo uriInfo) { if (uriInfo.getQueryParameters().containsKey(PARAM_WFS_URL)) { try {/* w w w . j av a 2s . c o m*/ URI wfsUri = WFSAdapter.parseAndCleanWfsUrl(uriInfo.getQueryParameters().getFirst(PARAM_WFS_URL)); for (Service service : services) { URI serviceWfsUri = ((LdProxyService) service).getWfsAdapter().getUrls().get("default") .get(WFS.METHOD.GET); if (wfsUri.equals(serviceWfsUri)) { URI serviceUri = new URIBuilder().setPath(getPath(uriInfo) + service.getId() + "/").build(); return Response.status(Response.Status.TEMPORARY_REDIRECT) .header("Location", serviceUri.toString()).build(); } } } catch (URISyntaxException e) { //ignore } return Response.status(Response.Status.NOT_FOUND).build(); } return null; }
From source file:be.solidx.hot.nio.http.SSLContextBuilder.java
private InputStream getInputStream(URI uri) throws IOException { InputStream jksFileInputStream; if (uri.getScheme() != null && uri.equals("file")) { jksFileInputStream = new FileInputStream(new File(uri)); } else {/*ww w .ja v a 2s . c om*/ if (uri.isAbsolute()) { jksFileInputStream = getClass().getResourceAsStream(uri.getPath()); } else { jksFileInputStream = getClass().getClassLoader().getResourceAsStream(uri.getPath()); } } return jksFileInputStream; }
From source file:org.fcrepo.apix.integration.LoaderIT.java
private long countServiceRegistryEntries(final URI canonicalURI) { return serviceRegistry.list().stream().map(serviceRegistry::getService).map(Service::canonicalURI) .filter(u -> canonicalURI.equals(u)).count(); }
From source file:org.openhab.binding.gpioremotecontrol.internal.GpioRemoteControlBinding.java
private void removeUnusedConnections() { try {/*from w w w . j a v a2 s . c o m*/ for (GpioRemoteControlBindingProvider provider : providers) { keyLoop: for (URI keyUri : provider.getClientMap().keySet()) { for (String itemName : provider.getItemNames()) { URI uri = new URI("ws://" + provider.getConfig(itemName).getHostWithPort()); if (uri.equals(keyUri)) { continue keyLoop; } provider.getClientMap().get(keyUri).close(); //Close unused connection provider.getClientMap().remove(keyUri); //If non Item uses the URI, remove the connection } } } } catch (URISyntaxException e) { e.printStackTrace(); } catch (Exception e) { logger.debug("Exception in removeUnusedConnections. Shit happens..."); } }
From source file:savant.ucscexplorer.UCSCExplorerPlugin.java
private void loadSelectedTracks() throws Throwable { TrackAdapter[] existingTracks = TrackUtils.getTracks(); List<MappedTable> newTracks = new ArrayList<MappedTable>(); List<TrackDef> selectedTracks = new ArrayList<TrackDef>(); for (Component c : groupsPanel.getComponents()) { if (c instanceof GroupPanel) { selectedTracks.addAll(((GroupPanel) c).getSelectedTracks()); }// w w w . j av a 2 s . c om } UCSCDataSourcePlugin ucsc = getUCSCPlugin(); for (TrackDef t : selectedTracks) { MappedTable table = ucsc.getTableWithStandardMapping(t); if (table.isMapped()) { table.getMapping().save(ucsc); } else { LOG.warn(t + " was not successfully mapped."); } URI mappedURI = table.getURI(); for (TrackAdapter t2 : existingTracks) { if (mappedURI.equals(t2.getDataSource().getURI())) { // Track already exists. Drop it from our list. table = null; LOG.info(mappedURI + " already found in loaded tracks."); break; } } if (table != null) { newTracks.add(table); } } LOG.info("After eliminating duplicates, " + newTracks.size() + " new tracks to be loaded."); if (newTracks.size() > 0) { for (MappedTable mt : newTracks) { TrackUtils.createTrack(mt.getURI()); } } // Success. Let's clear away the selections. for (Component c : groupsPanel.getComponents()) { if (c instanceof GroupPanel) { ((GroupPanel) c).clearSelectedTracks(); } } }
From source file:software.coolstuff.springframework.owncloud.service.impl.rest.OwncloudRestResourceServiceImpl.java
private boolean isResolvedToRootURI(URI path) { URI userRoot = getUserRoot(); if (path.isAbsolute()) { return userRoot.equals(path); }/* w w w . j a v a 2 s. co m*/ return userRoot.equals(resolveAsDirectoryURI(path)); }