List of usage examples for java.net URI getFragment
public String getFragment()
From source file:com.vp9.plugin.WebSocket.java
/** * Create the uri.// w ww . j a v a 2 s . c o m * @param uriString * @return * @throws URISyntaxException */ private URI createURI(String uriString) throws URISyntaxException { URI uri = new URI(uriString); int port = uri.getPort(); if (port == -1) { if ("ws".equals(uri.getScheme())) { port = 80; } else if ("wss".equals(uri.getScheme())) { port = 443; } uri = URIUtils.createURI(uri.getScheme(), uri.getHost(), port, uri.getPath(), uri.getQuery(), uri.getFragment()); } return uri; }
From source file:org.apache.stratos.integration.common.extensions.StratosServerExtension.java
private int startActiveMQServer() throws AutomationFrameworkException { try {/* w w w. jav a 2s . c o m*/ String activemqBindAddress = getParameters().get(Util.ACTIVEMQ_BIND_ADDRESS); if (activemqBindAddress == null) { throw new AutomationFrameworkException("ActiveMQ bind address not found in automation.xml"); } URI givenURI = new URI(activemqBindAddress); int initAMQPort = givenURI.getPort(); // dynamically pick an open port starting from initial port given in automation.xml while (!Util.isPortAvailable(initAMQPort)) { initAMQPort++; } URI dynamicURL = new URI(givenURI.getScheme(), givenURI.getUserInfo(), givenURI.getHost(), initAMQPort, givenURI.getPath(), givenURI.getQuery(), givenURI.getFragment()); long time1 = System.currentTimeMillis(); log.info("Starting ActiveMQ with dynamic bind address: " + dynamicURL.toString()); broker.setDataDirectory(StratosServerExtension.class.getResource(File.separator).getPath() + File.separator + ".." + File.separator + "activemq-data"); broker.setBrokerName("testBroker"); broker.addConnector(dynamicURL.toString()); broker.start(); long time2 = System.currentTimeMillis(); log.info(String.format("ActiveMQ started in %d sec", (time2 - time1) / 1000)); return initAMQPort; } catch (Exception e) { throw new AutomationFrameworkException("Could not start ActiveMQ", e); } }
From source file:org.eclipse.orion.server.git.objects.Status.java
private URI statusToCommitLocation(URI u, String ref) throws URISyntaxException { String uriPath = u.getPath(); String prefix = uriPath.substring(0, uriPath.indexOf(GitServlet.GIT_URI)); uriPath = uriPath.substring(prefix.length() + (GitServlet.GIT_URI + '/' + Status.RESOURCE).length()); uriPath = prefix + GitServlet.GIT_URI + '/' + Commit.RESOURCE + '/' + ref + uriPath; return new URI(u.getScheme(), u.getUserInfo(), u.getHost(), u.getPort(), uriPath, u.getQuery(), u.getFragment()); }
From source file:org.eclipse.orion.server.git.objects.Status.java
private URI statusToDiffLocation(URI u, String diffType) throws URISyntaxException { String uriPath = u.getPath(); String prefix = uriPath.substring(0, uriPath.indexOf(GitServlet.GIT_URI)); uriPath = uriPath.substring(prefix.length() + (GitServlet.GIT_URI + '/' + Status.RESOURCE).length()); uriPath = prefix + GitServlet.GIT_URI + '/' + Diff.RESOURCE + '/' + diffType + uriPath; return new URI(u.getScheme(), u.getUserInfo(), u.getHost(), u.getPort(), uriPath, u.getQuery(), u.getFragment()); }
From source file:org.soyatec.windowsazure.authenticate.SharedKeyCredentialsWrapper.java
/** * Replace the uri container name.//from w w w.j av a2s. c om * * @param uri * @param containerName * @return The uri after be replaced the container name with the input * containerName. */ private URI replaceContainerName(URI uri, String containerName) { if (containerName == null) { return uri; } try { String host = uri.getPath(); String[] temp = host.split("/"); temp[0] = containerName; return URIUtils.createURI(uri.getScheme(), uri.getHost(), uri.getPort(), join("/", temp), (uri.getQuery() == null ? Utilities.emptyString() : uri.getQuery()), uri.getFragment()); } catch (URISyntaxException e) { Logger.error("", e); } return uri; }
From source file:org.apache.taverna.robundle.manifest.Manifest.java
public PathMetadata getAggregation(URI uri) { uri = relativeToBundleRoot(uri);//from www . j av a 2 s .c om PathMetadata metadata = aggregates.get(uri); if (metadata == null) { metadata = new PathMetadata(); if (!uri.isAbsolute() && uri.getFragment() == null) { Path path = uriToBundlePath(bundle, uri); metadata.setFile(path); metadata.setMediatype(guessMediaType(path)); } else { metadata.setUri(uri); } aggregates.put(uri, metadata); } return metadata; }
From source file:org.codice.ddf.catalog.content.impl.FileSystemStorageProvider.java
private Path getContentItemDir(URI contentUri) { List<String> pathParts = getContentFilePathParts(contentUri.getSchemeSpecificPart(), contentUri.getFragment()); return Paths.get(baseContentDirectory.toAbsolutePath().toString(), pathParts.toArray(new String[pathParts.size()])); }
From source file:com.reelfx.model.PostProcessor.java
/** * s/*from w w w . ja v a 2s . co m*/ * * @param url */ private void setPostURI(String url) { try { URI given = new URI(url); String query = given.getQuery() == null ? "" : given.getQuery(); query = query + (query.isEmpty() ? "" : "&") + (Applet.API_KEY.isEmpty() ? "" : "api_key=" + Applet.API_KEY); postUrl = new URI(given.getScheme(), given.getAuthority(), given.getPath(), query, given.getFragment()); } catch (Exception e) { logger.error("Error occurred while processing the post URL (received: " + url + ")", e); fireProcessUpdate(POST_FAILED); } }
From source file:net.jotel.ws.client.WebSocketClient.java
public static void validateWebSocketUri(URI uri) throws WebSocketException { if (uri == null) { throw new WebSocketException("URI is empty!"); }//from www . j av a 2 s .c om if (!uri.isAbsolute()) { throw new WebSocketException("Absolute URI required!"); } if (!StringUtils.equalsIgnoreCase("ws", uri.getScheme()) && !StringUtils.equalsIgnoreCase("wss", uri.getScheme())) { throw new WebSocketException("Unsupported URI scheme!"); } if (StringUtils.isNotEmpty(uri.getFragment())) { throw new WebSocketException("URI fragment is not allowed!"); } if (StringUtils.isBlank(uri.getHost())) { throw new WebSocketException("URI host component is empty!"); } }
From source file:com.mellanox.jxio.ServerPortal.java
private URI replaceIPinURI(URI uriForForward, String uriIPAddress) { URI newUri = null;/* www .jav a 2s . c o m*/ try { newUri = new URI(uriForForward.getScheme(), uriForForward.getUserInfo(), new URI(uriIPAddress).getHost(), uriForForward.getPort(), uriForForward.getPath(), uriForForward.getQuery(), uriForForward.getFragment()); } catch (URISyntaxException e) { e.printStackTrace(); LOG.error(this.toLogString() + "URISyntaxException occured while trying to create a new URI"); } return newUri; }