List of usage examples for java.net URI getQuery
public String getQuery()
From source file:com.microsoft.tfs.core.util.URIUtils.java
/** * Ensures that the specified {@link URI} has any trailing slashes REMOVED. * VisualStudio uses server URIs that lack trailing slashes, this is for * compatibility. However, a path of only / will be maintained. * * @param uri/*from w w w. j ava 2 s . com*/ * a {@link URI} to check (must not be <code>null</code>) * @return a {@link URI} as described above (never <code>null</code>) */ public static URI removeTrailingSlash(final URI uri) { Check.notNull(uri, "uri"); //$NON-NLS-1$ if (uri.isOpaque()) { return uri; } String path = uri.getPath(); if (path == null) { path = "/"; //$NON-NLS-1$ } else if (!path.equals("/")) //$NON-NLS-1$ { while (path.endsWith("/")) //$NON-NLS-1$ { path = path.substring(0, path.length() - 1); } } return newURI(uri.getScheme(), uri.getAuthority(), path, uri.getQuery(), uri.getFragment()); }
From source file:lucee.commons.net.http.httpclient.HTTPResponse4Impl.java
public URL getTargetURL() { URL start = getURL();/*w w w . j a v a2 s. c om*/ HttpUriRequest req = (HttpUriRequest) context.getAttribute(ExecutionContext.HTTP_REQUEST); URI uri = req.getURI(); String path = uri.getPath(); String query = uri.getQuery(); if (!StringUtil.isEmpty(query)) path += "?" + query; URL _url = start; try { _url = new URL(start.getProtocol(), start.getHost(), start.getPort(), path); } catch (MalformedURLException e) { } return _url; }
From source file:org.cloudfoundry.identity.uaa.login.saml.FixedHttpMetaDataProvider.java
/** * If a custom socket factory has been set, only * return a relative URL so that the custom factory is retained. * This works around// w w w .jav a2 s.c o m * https://issues.apache.org/jira/browse/HTTPCLIENT-646 {@inheritDoc} */ @Override public String getMetadataURI() { if (isSocketFactorySet()) { java.net.URI uri; try { uri = new java.net.URI(super.getMetadataURI()); String result = uri.getPath(); if (uri.getQuery() != null && uri.getQuery().trim().length() > 0) { result = result + "?" + uri.getQuery(); } return result; } catch (URISyntaxException e) { // this can never happen, satisfy compiler throw new IllegalArgumentException(e); } } else { return super.getMetadataURI(); } }
From source file:com.cognifide.qa.bb.proxy.analyzer.predicate.RequestPredicateImpl.java
@Override public boolean accepts(HttpRequest request) { boolean result = false; URI uri = URI.create(request.getUri()); String path = uri.getPath();/* w w w. ja v a 2 s . co m*/ if (path != null && path.startsWith(urlPrefix)) { String query = uri.getQuery(); if (expectedParams.isEmpty() && StringUtils.isEmpty(query)) { result = true; } else if (StringUtils.isNotEmpty(query)) { List<NameValuePair> params = URLEncodedUtils.parse(query, Charsets.UTF_8); result = hasAllExpectedParams(expectedParams, params); } } return result; }
From source file:org.apache.activemq.artemis.utils.uri.URISchema.java
public void populateObject(URI uri, T bean) throws Exception { setData(uri, bean, parseQuery(uri.getQuery(), null)); }
From source file:de.betterform.connector.xmlrpc.XMLRPCURIResolver.java
/** * Parses the URI into three elements./* ww w. java 2 s. co m*/ * The xmlrpc URL, the function and the params * * @return a Vector */ private Vector parseURI(URI uri) { String host = uri.getHost(); int port = uri.getPort(); String path = uri.getPath(); String query = uri.getQuery(); /* Split the path up into basePath and function */ int finalSlash = path.lastIndexOf('/'); String basePath = ""; if (finalSlash > 0) { basePath = path.substring(1, finalSlash); } String function = path.substring(finalSlash + 1, path.length()); String rpcURL = "http://" + host + ":" + port + "/" + basePath; log.debug("New URL = " + rpcURL); log.debug("Function = " + function); Hashtable paramHash = new Hashtable(); if (query != null) { String[] params = query.split("&"); for (int i = 0; i < params.length; i++) { log.debug("params[" + i + "] = " + params[i]); String[] keyval = params[i].split("="); log.debug("\t" + keyval[0] + " -> " + keyval[1]); paramHash.put(keyval[0], keyval[1]); } } Vector ret = new Vector(); ret.add(rpcURL); ret.add(function); ret.add(paramHash); return ret; }
From source file:com.mgmtp.perfload.perfalyzer.normalization.MeasuringNormalizingStrategy.java
@Override public List<ChannelData> normalizeLine(final String line) { tokenizer.reset(line);/*from www .jav a2 s.c o m*/ String[] tokens = tokenizer.getTokenArray(); List<ChannelData> channelDataList = newArrayListWithExpectedSize(3); ZonedDateTime timestamp; try { timestamp = ZonedDateTime.parse(tokens[3]); } catch (IllegalArgumentException ex) { log.error("Invalid data line: {}", line); return channelDataList; } if (!timestampNormalizer.isInRange(timestamp)) { log.trace("Skipping measuring entry. Timestamp not in time range of test: " + timestamp); return channelDataList; } StrBuilder sb = new StrBuilder(200); long normalizedTimestamp = timestampNormalizer.normalizeTimestamp(timestamp, 0L); String responseTimeFirstByte = tokens[MEASURING_RAW_COL_RESPONSE_TIME_FIRST_BYTE]; String responseTime = tokens[MEASURING_RAW_COL_RESPONSE_TIME]; String operation = tokens[MEASURING_RAW_COL_OPERATION]; if (operation == null || operation.isEmpty()) { return channelDataList; } String result = tokens[MEASURING_RAW_COL_RESULT]; String errorMsg = tokens[MEASURING_RAW_COL_ERROR_MSG]; String type = tokens[MEASURING_RAW_COL_REQUEST_TYPE]; String uriString = tokens[MEASURING_RAW_COL_URI]; String uriAlias = tokens[MEASURING_RAW_COL_URI_ALIAS]; String uriPath; try { URI uri = new URI(uriString); uriPath = uri.getPath(); String query = uri.getQuery(); if (query != null) { uriPath += '?' + query; } } catch (URISyntaxException ex) { // this can happen for agent measurings and custom request types uriPath = uriString; } if (uriString.equals(uriAlias)) { uriAlias = uriPath; } String executionId = tokens[MEASURING_RAW_COL_EXECUTION_ID]; String requestId = tokens[MEASURING_RAW_COL_REQUEST_ID]; appendEscapedAndQuoted(sb, DELIMITER, normalizedTimestamp); appendEscapedAndQuoted(sb, DELIMITER, responseTimeFirstByte); appendEscapedAndQuoted(sb, DELIMITER, responseTime); appendEscapedAndQuoted(sb, DELIMITER, operation); appendEscapedAndQuoted(sb, DELIMITER, type); appendEscapedAndQuoted(sb, DELIMITER, uriPath); appendEscapedAndQuoted(sb, DELIMITER, uriAlias); appendEscapedAndQuoted(sb, DELIMITER, result); appendEscapedAndQuoted(sb, DELIMITER, errorMsg); appendEscapedAndQuoted(sb, DELIMITER, executionId); appendEscapedAndQuoted(sb, DELIMITER, requestId); String resultLine = sb.toString(); channelDataList.add(new ChannelData(CHANNEL_BASE_NAME, operation, resultLine)); return channelDataList; }
From source file:org.accelio.jxio.tests.benchmarks.jxioConnection.StreamClient.java
public StreamClient(URI uri, String type, int index, int repeats) { this.uri = uri; this.type = type; name = "[" + type + " StreamClient_" + index + "]"; bytes = Long.parseLong(uri.getQuery().split("size=")[1]); this.repeats = repeats; }
From source file:edu.ucsb.eucalyptus.cloud.ws.HttpTransfer.java
public HttpMethodBase constructHttpMethod(String verb, String addr, String eucaOperation, String eucaHeader) { String date = new Date().toString(); String httpVerb = verb;/* w w w . j av a 2 s . c om*/ String addrPath; try { java.net.URI addrUri = new URL(addr).toURI(); addrPath = addrUri.getPath().toString(); String query = addrUri.getQuery(); if (query != null) { addrPath += "?" + query; } } catch (Exception ex) { LOG.error(ex, ex); return null; } String data = httpVerb + "\n" + date + "\n" + addrPath + "\n"; HttpMethodBase method = null; if (httpVerb.equals("PUT")) { method = new PutMethodWithProgress(addr); } else if (httpVerb.equals("DELETE")) { method = new DeleteMethod(addr); } else { method = new GetMethod(addr); } method.setRequestHeader("Authorization", "Euca"); method.setRequestHeader("Date", date); //method.setRequestHeader("Expect", "100-continue"); method.setRequestHeader(StorageProperties.EUCALYPTUS_OPERATION, eucaOperation); if (eucaHeader != null) { method.setRequestHeader(StorageProperties.EUCALYPTUS_HEADER, eucaHeader); } try { PrivateKey ccPrivateKey = SystemCredentials.lookup(Storage.class).getPrivateKey(); Signature sign = Signature.getInstance("SHA1withRSA"); sign.initSign(ccPrivateKey); sign.update(data.getBytes()); byte[] sig = sign.sign(); method.setRequestHeader("EucaSignature", new String(Base64.encode(sig))); } catch (Exception ex) { LOG.error(ex, ex); } return method; }
From source file:de.betterform.connector.xmlrpc.XMLRPCSubmissionHandler.java
/** * Parses the URI into three elements./* ww w . j av a 2 s .c om*/ * The xmlrpc URL, the function and the params * * @return a Vector */ private Vector parseURI(URI uri) { String host = uri.getHost(); int port = uri.getPort(); String path = uri.getPath(); String query = uri.getQuery(); /* Split the path up into basePath and function */ int finalSlash = path.lastIndexOf('/'); String basePath = ""; if (finalSlash > 0) { basePath = path.substring(1, finalSlash); } String function = path.substring(finalSlash + 1, path.length()); String rpcURL = "http://" + host + ":" + port + "/" + basePath; log.debug("New URL = " + rpcURL); log.debug("Function = " + function); Hashtable paramHash = new Hashtable(); if (query != null) { String[] params = query.split("&"); for (int i = 0; i < params.length; i++) { log.debug("params[" + i + "] = " + params[i]); String[] keyval = params[i].split("="); log.debug("\t" + keyval[0] + " -> " + keyval[1]); paramHash.put(keyval[0], keyval[1]); } } Vector ret = new Vector(); ret.add(rpcURL); ret.add(function); ret.add(paramHash); return ret; }