/** * Construct a HTTP URL with a given relative URL string. * * @param base the base HttpURL * @param relative the relative HTTP URL string * @throws URIException If {@link #checkValid()} fails */ public HttpURL(HttpURL base, String relative) throws URIException { this(base, new HttpURL(relative)); }
@Override public boolean execute() throws Exception { if (_controllerHost == null) { _controllerHost = NetUtil.getHostAddress(); } String stateValue = _state.toLowerCase(); if (!stateValue.equals("enable") && !stateValue.equals("disable") && !stateValue.equals("drop")) { throw new IllegalArgumentException( "Invalid value for state: " + _state + "\n Value must be one of enable|disable|drop"); } HttpClient httpClient = new HttpClient(); HttpURL url = new HttpURL(_controllerHost, Integer.parseInt(_controllerPort), URI_TABLES_PATH + _tableName); url.setQuery("state", stateValue); GetMethod httpGet = new GetMethod(url.getEscapedURI()); int status = httpClient.executeMethod(httpGet); if (status != 200) { throw new RuntimeException("Failed to change table state, error: " + httpGet.getResponseBodyAsString()); } return true; }
/** * Construct a HTTP URL with a given relative URL string. * * @param base the base HttpURL * @param relative the relative HTTP URL string * @throws URIException If {@link #checkValid()} fails */ public HttpURL(HttpURL base, String relative) throws URIException { this(base, new HttpURL(relative)); }
/** * Construct a HTTP URL with a given relative URL string. * * @param base the base HttpURL * @param relative the relative HTTP URL string * @throws URIException If {@link #checkValid()} fails */ public HttpURL(HttpURL base, String relative) throws URIException { this(base, new HttpURL(relative)); }
/** * Construct a HTTP URL with a given relative URL string. * * @param base the base HttpURL * @param relative the relative HTTP URL string * @throws URIException If {@link #checkValid()} fails */ public HttpURL(HttpURL base, String relative) throws URIException { this(base, new HttpURL(relative)); }
/** * @param pathname complete path to element * @param user user name * @param pass password */ public WebdavFile(String pathname, String user, String pass) throws URIException { this(new HttpURL(user, pass, null, -1, pathname)); }
/** * Construct a HTTP URL with a given relative URL string. * * @param base the base HttpURL * @param relative the relative HTTP URL string * @throws URIException If {@link #checkValid()} fails */ public HttpURL(HttpURL base, String relative) throws URIException { this(base, new HttpURL(relative)); }
/** * @param url file url * @param user user name * @param pass password */ public WebdavFile(URL url, String user, String pass) throws URIException { this(url.getProtocol().equals("https") ? new HttpsURL(user, pass, url.getHost(), url.getPort(), url.getPath()) : new HttpURL(user, pass, url.getHost(), url.getPort(), url.getPath())); } /**
private static HttpURL uriToHttpURL(String uri) throws URIException { HttpURL url = null; if (uri.startsWith("http://")) { url = new HttpURL(uri); } else if (uri.startsWith("https://")) { url = new HttpsURL(uri); } else { throw new URIException("Unknown protocol in URL " + uri); } return url; }
/** * Converts a String url to an HttpURL * * @param url String url to convert to an HttpURL * @return an HttpURL object created from the String url * @throws URIException */ private HttpURL urlToHttpURL( String url ) throws URIException { if ( url.startsWith( "https" ) ) { return new HttpsURL( url ); } else { return new HttpURL( url ); } }
@Override protected URI createUri(String uriString, boolean escaped) throws URIException { boolean useNewHttpUriFactory = config.getAsBoolean("http.client.use.new.http.uri.factory", false); if (useNewHttpUriFactory) { return new HttpURL(uriString); } return super.createUri(uriString, escaped); }
/** * Set the HttpURL of this WebdavResource. * It must be put an escaped http URL as an argument. * * @param escapedHttpURL The escaped http URL string. * @exception HttpException * @exception IOException * @see #setHttpURL(HttpURL) * @see #setUserInfo(java.lang.String, java.lang.String) * @see #setPath(java.lang.String) */ public void setHttpURL(String escapedHttpURL) throws HttpException, IOException { setHttpURL(escapedHttpURL.startsWith("https") ? new HttpsURL(escapedHttpURL) : new HttpURL(escapedHttpURL)); }
/** * Set the HttpURL for this WebdavResource. * * @param httpURL The specified HttpURL. * @param additionalPath The added relative path. * @exception HttpException * @exception IOException * @see #setHttpURL(java.lang.String) * @see #setUserInfo(java.lang.String, java.lang.String) * @see #setPath(java.lang.String) */ public void setHttpURL(HttpURL httpURL, String additionalPath) throws HttpException, IOException { setHttpURL(httpURL instanceof HttpsURL ? new HttpsURL((HttpsURL) httpURL, additionalPath) : new HttpURL(httpURL, additionalPath), defaultAction, defaultDepth); }
/** * Set the HttpURL for this WebdavResource. * It must be put an escaped path part of the http URL as an argument. * * @param httpURL The specified HttpURL. * @param additionalPath The added relative path. * @param action The action to decide, which properties to find. * @param depth The depth. * @exception HttpException * @exception IOException * @see #setHttpURL(java.lang.String) * @see #setUserInfo(java.lang.String, java.lang.String) * @see #setPath(java.lang.String) * @see #setDefaultAction(int) */ public void setHttpURL (HttpURL httpURL, String additionalPath, int action, int depth) throws HttpException, IOException { setHttpURL(httpURL instanceof HttpsURL ? new HttpsURL((HttpsURL) httpURL, additionalPath) : new HttpURL(httpURL, additionalPath), action, depth); }
/** * Set the HttpURL for this WebdavResource. * It must be put an escaped path part of the http URL as an argument. * * @param httpURL The specified HttpURL. * @param additionalPath The added relative path. * @param action The action to decide, which properties to find. * @exception HttpException * @exception IOException * @see #setHttpURL(java.lang.String) * @see #setUserInfo(java.lang.String, java.lang.String) * @see #setPath(java.lang.String) * @see #setDefaultAction(int) */ public void setHttpURL (HttpURL httpURL, String additionalPath, int action) throws HttpException, IOException { setHttpURL(httpURL instanceof HttpsURL ? new HttpsURL((HttpsURL) httpURL, additionalPath) : new HttpURL(httpURL, additionalPath), action, defaultDepth); }
public URI getURI(String scheme, String host, int port, String path, String queryString, HttpMethodParams params) throws URIException { HttpHost httphost = new HttpHost(host, port); StringBuffer buffer = new StringBuffer(); if (httphost != null) { buffer.append(httphost.getProtocol().getScheme()); buffer.append("://"); buffer.append(httphost.getHostName()); int p = httphost.getPort(); if (p != -1 && p != httphost.getProtocol().getDefaultPort()) { buffer.append(":"); buffer.append(p); } } buffer.append(path); if (queryString != null) { buffer.append('?'); buffer.append(queryString); } String charset = params.getUriCharset(); return new HttpURL(buffer.toString(), charset); }
/** * Get the HttpURL except for userinfo. * * @return httpURL the http URL. */ public HttpURL getHttpURLExceptForUserInfo() throws URIException { return httpURL instanceof HttpsURL ? new HttpsURL(httpURL.getRawURI()) : new HttpURL(httpURL.getRawURI()); }
HttpURL httpURL = new HttpURL(host); hostConfiguration.setHost(httpURL);
HttpURL httpURL = new HttpURL(host); hostConfiguration.setHost(httpURL);
HttpURL httpURL = new HttpURL(host); hostConfiguration.setHost(httpURL);