/** * Sets the URI for this method. * * @param uri URI to be set * * @throws URIException if a URI cannot be set * * @since 3.0 */ public void setURI(URI uri) throws URIException { // only set the host if specified by the URI if (uri.isAbsoluteURI()) { this.httphost = new HttpHost(uri); } // set the path, defaulting to root setPath( uri.getPath() == null ? "/" : uri.getEscapedPath() ); setQueryString(uri.getEscapedQuery()); }
/** * Get a random path relative to the current entity. Whenever possible, use * a suffix exist in the children according to a priority of * staticSuffixList. * * @param node the node used to construct the random path * @param uri The uri of the current entity. * @return A random path (eg /folder1/folder2/1234567.chm) relative the * entity. * @throws URIException if unable to decode the path of the given URI */ private String getRandomPathSuffix(StructuralNode node, URI uri) throws URIException { String resultSuffix = getChildSuffix(node, true); String path = ""; path = (uri.getPath() == null) ? "" : uri.getPath(); path = path + (path.endsWith("/") ? "" : "/") + Long.toString(getRndPositiveLong()); path = path + resultSuffix; return path; }
/** * Return if this request header is a image request basing on the path * suffix. */ @Override public boolean isImage() { if (getURI() == null) { return false; } try { // ZAP: prevents a NullPointerException when no path exists final String path = getURI().getPath(); if (path != null) { return (patternImage.matcher(path).find()); } } catch (URIException e) { log.error(e.getMessage(), e); } return false; }
/** * * @param msg */ @Override public void setMessage(HttpMessage msg) { /* * For a URL like: http://www.example.com/aaa/bbb/ccc?ddd=eee&fff=ggg * Add the following: * parameter position * aaa 1 * bbb 2 * ccc 3 */ try { if (msg.getRequestHeader().getURI().getPath() != null) { String[] paths = msg.getRequestHeader().getURI().getPath().toString().split("/"); int i = 0; for (String path : paths) { if (path.length() > 0) { stringParam.add(new NameValuePair(NameValuePair.TYPE_URL_PATH, path, path, i)); } i++; } } } catch (URIException e) { // Ignore } }
@Autowired public OpenMrsHttpClientImpl(@Value("${openmrs.url}") String openmrsUrl) throws URIException { Validate.notEmpty( openmrsUrl, "Did not find property for OpenMRS Url (openmrs.url). Cannot use the Motech Atom Feed module until this property is set"); httpClient = new HttpClient(new MultiThreadedHttpConnectionManager()); URI uri = new URI(openmrsUrl, false); openmrsPath = uri.getPath(); httpClient.getHostConfiguration().setHost(uri); }
child = iter.next(); try { if (child.getURI().getPath().endsWith(suffix)) { return suffix;
protected String getScriptBasedFormURL(HttpMethod initmethod, String pathQuery) throws URIException { URI initmethodURI = initmethod.getURI(); int queryIndex = pathQuery.indexOf('?'); if (queryIndex >= 0) { if (queryIndex > 0) { // update path String newPath = pathQuery.substring(0, queryIndex); if (newPath.startsWith("/")) { // absolute path initmethodURI.setPath(newPath); } else { String currentPath = initmethodURI.getPath(); int folderIndex = currentPath.lastIndexOf('/'); if (folderIndex >= 0) { // replace relative path initmethodURI.setPath(currentPath.substring(0, folderIndex + 1) + newPath); } else { // should not happen initmethodURI.setPath('/' + newPath); } } } initmethodURI.setQuery(pathQuery.substring(queryIndex + 1)); } return initmethodURI.getURI(); }
private File getOutputFile(HttpMessage msg) { String filename = ""; try { filename = msg.getRequestHeader().getURI().getPath(); int pos = filename.lastIndexOf("/"); filename = filename.substring(pos); } catch (Exception e) { } JFileChooser chooser = new JFileChooser(extension.getModel().getOptionsParam().getUserDirectory()); if (filename.length() > 0) { chooser.setSelectedFile(new File(filename)); } File file = null; int rc = chooser.showSaveDialog(extension.getView().getMainFrame()); if(rc == JFileChooser.APPROVE_OPTION) { file = chooser.getSelectedFile(); if (file == null) { return file; } extension.getModel().getOptionsParam().setUserDirectory(chooser.getCurrentDirectory()); return file; } return file; }
String path = msg.getRequestHeader().getURI().getPath(); String challenge = path.substring(path.indexOf(getPrefix()) + getPrefix().length() + 1); if (challenge.charAt(challenge.length() - 1) == '/') {
@Override public HttpMessage handleShortcut(HttpMessage msg) throws ApiException { try { if (msg.getRequestHeader().getURI().getPath().startsWith("/" + OTHER_PROXY_PAC)) { return this.handleApiOther(msg, OTHER_PROXY_PAC, null); } else if (msg.getRequestHeader().getURI().getPath().startsWith("/" + OTHER_SET_PROXY)) { JSONObject params = new JSONObject(); params.put(PARAM_PROXY_DETAILS, msg.getRequestBody().toString()); return this.handleApiOther(msg, OTHER_SET_PROXY, params); } else if (msg.getRequestHeader().getURI().getPath().startsWith("/" + OTHER_SCRIPT_JS)) { return this.handleApiOther(msg, OTHER_SCRIPT_JS, null); } } catch (URIException e) { logger.error(e.getMessage(), e); throw new ApiException(ApiException.Type.INTERNAL_ERROR); } throw new ApiException (ApiException.Type.URL_NOT_FOUND, msg.getRequestHeader().getURI().toString()); }
path = message.getRequestHeader().getURI().getPath(); } catch (URIException e) { } finally {
try { URI uri = msg.getRequestHeader().getURI(); String[] paths = msg.getRequestHeader().getURI().getPath().toString().split("/");
try { String url = msg.getRequestHeader().getURI().toString(); String path = msg.getRequestHeader().getURI().getPath(); LOGGER.debug("Callback received for URL : " + url + " path : " + path + " from "
StringBuilder sb = new StringBuilder(); String nodeName; String uriPath = baseRef.getURI().getPath(); if (uriPath == null) { uriPath = "";
/** * Sets the URI for this method. * * @param uri URI to be set * * @throws URIException if a URI cannot be set * * @since 3.0 */ public void setURI(URI uri) throws URIException { // only set the host if specified by the URI if (uri.isAbsoluteURI()) { this.httphost = new HttpHost(uri); } // set the path, defaulting to root setPath( uri.getPath() == null ? "/" : uri.getEscapedPath() ); setQueryString(uri.getEscapedQuery()); }
/** * Sets the URI for this method. * * @param uri URI to be set * * @throws URIException if a URI cannot be set * * @since 3.0 */ @Override public void setURI(URI uri) throws URIException { // only set the host if specified by the URI if (uri.isAbsoluteURI()) { this.httphost = new HttpHost(uri); } // set the path, defaulting to root setPath( uri.getPath() == null ? "/" : uri.getEscapedPath() ); setQueryString(uri.getEscapedQuery()); }
/** * Sets the URI for this method. * * @param uri URI to be set * * @throws URIException if a URI cannot be set * * @since 3.0 */ public void setURI(URI uri) throws URIException { // only set the host if specified by the URI if (uri.isAbsoluteURI()) { this.httphost = new HttpHost(uri); } // set the path, defaulting to root setPath( uri.getPath() == null ? "/" : uri.getEscapedPath() ); setQueryString(uri.getEscapedQuery()); }
/** * Sets the URI for this method. * * @param uri URI to be set * * @throws URIException if a URI cannot be set * * @since 3.0 */ public void setURI(URI uri) throws URIException { // only set the host if specified by the URI if (uri.isAbsoluteURI()) { this.httphost = new HttpHost(uri); } // set the path, defaulting to root setPath( uri.getPath() == null ? "/" : uri.getEscapedPath() ); setQueryString(uri.getEscapedQuery()); }
/** * Sets the URI for this method. * * @param uri URI to be set * * @throws URIException if a URI cannot be set * * @since 3.0 */ public void setURI(URI uri) throws URIException { // only set the host if specified by the URI if (uri.isAbsoluteURI()) { this.httphost = new HttpHost(uri); } // set the path, defaulting to root setPath( uri.getPath() == null ? "/" : uri.getEscapedPath() ); setQueryString(uri.getEscapedQuery()); }
@SuppressWarnings("deprecation") public void setURI(org.apache.commons.httpclient.HttpMethodBase m, URI uri) throws URIException { HostConfiguration conf = m.getHostConfiguration(); if (uri.isAbsoluteURI()) { conf.setHost(new HttpHost(uri)); m.setHostConfiguration(conf); } m.setPath(uri.getPath() != null ? uri.getEscapedPath() : "/"); m.setQueryString(uri.getQuery()); }