List of usage examples for org.apache.commons.httpclient HttpURL HttpURL
public HttpURL(char[] paramArrayOfChar, String paramString) throws URIException, NullPointerException
From source file:org.apache.cocoon.components.source.impl.WebDAVSource.java
/** * Get a collection child.// w w w. jav a2s. c o m * * @see org.apache.excalibur.source.TraversableSource#getChild(java.lang.String) */ public Source getChild(String childName) throws SourceException { if (!isCollection()) { throw new SourceException(getSecureURI() + " is not a collection."); } try { HttpURL childURL; if (this.url instanceof HttpsURL) { childURL = new HttpsURL((HttpsURL) this.url, childName); } else { childURL = new HttpURL(this.url, childName); } return WebDAVSource.newWebDAVSource(childURL, this.protocol, getLogger(), eventfactory); } catch (URIException e) { throw new SourceException("Failed to create child", e); } }
From source file:org.apache.cocoon.components.source.impl.WebDAVSource.java
/** * Get the collection children.//from ww w . j av a2 s .co m * * @see org.apache.excalibur.source.TraversableSource#getChildren() */ public Collection getChildren() throws SourceException { initResource(WebdavResource.BASIC, DepthSupport.DEPTH_1); ArrayList children = new ArrayList(); try { WebdavResource[] resources = this.resource.listWebdavResources(); for (int i = 0; i < resources.length; i++) { HttpURL childURL; if (this.url instanceof HttpsURL) { childURL = new HttpsURL((HttpsURL) this.url, resources[i].getName()); } else { childURL = new HttpURL(this.url, resources[i].getName()); } WebDAVSource src = WebDAVSource.newWebDAVSource(resources[i], childURL, this.protocol, getLogger(), this.eventfactory); src.enableLogging(getLogger()); children.add(src); } } catch (HttpException e) { if (getLogger().isDebugEnabled()) { final String message = "Unable to get WebDAV children. Server responded " + e.getReasonCode() + " (" + e.getReason() + ") - " + e.getMessage(); getLogger().debug(message); } throw new SourceException("Failed to get WebDAV collection children.", e); } catch (SourceException e) { throw e; } catch (IOException e) { throw new SourceException("Failed to get WebDAV collection children.", e); } return children; }
From source file:org.apache.cocoon.components.source.impl.WebDAVSource.java
/** * Get the parent./* w w w .jav a 2 s . co m*/ * * @see org.apache.excalibur.source.TraversableSource#getParent() */ public Source getParent() throws SourceException { String path; if (this.url.getEscapedPath().endsWith("/")) { path = ".."; } else { path = "."; } try { HttpURL parentURL; if (url instanceof HttpsURL) { parentURL = new HttpsURL((HttpsURL) this.url, path); } else { parentURL = new HttpURL(this.url, path); } return WebDAVSource.newWebDAVSource(parentURL, this.protocol, getLogger(), eventfactory); } catch (URIException e) { throw new SourceException("Failed to create parent", e); } }
From source file:org.apache.webdav.ant.Utils.java
public static HttpURL createHttpURL(HttpURL base, String relative) throws URIException { if (base instanceof HttpsURL) { return new HttpsURL((HttpsURL) base, relative); } else {//from www . java 2s . c om return new HttpURL(base, relative); } }
From source file:org.apache.webdav.lib.WebdavResource.java
/** * 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./* w ww. ja va 2 s . c o m*/ * @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); }
From source file:org.apache.webdav.lib.WebdavResource.java
/** * 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//from w ww. ja v a 2 s . co m * @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); }
From source file:org.apache.webdav.lib.WebdavResource.java
/** * Set the HttpURL for this WebdavResource. * * @param httpURL The specified HttpURL. * @param additionalPath The added relative path. * @exception HttpException//from w w w . j av a 2 s .c o m * @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); }
From source file:org.jdesktop.wonderland.modules.webdav.common.WebdavContentCollection.java
protected HttpURL getChildURL(HttpURL parent, String childPath) throws URIException { if (childPath.startsWith("/")) { childPath = childPath.substring(1); }//from w w w . ja v a 2 s .c om if (!parent.getPath().endsWith("/")) { parent.setPath(parent.getPath() + "/"); } return new HttpURL(parent, childPath); }
From source file:pl.nask.hsn2.NewUrlObject.java
public NewUrlObject(String url, String origin, String type) throws URIException { this.originalUrl = url; this.origin = origin; this.type = type; String scheme = getSchemeFromUri(); if (scheme != null) { if (scheme.equals("https")) { this.uri = new HttpsURL(originalUrl, Charset.forName("UTF-8").name());//Default charset is UTF-8 but this isn't handled correctly in getters methods!!! } else if (scheme.equals("http")) { this.uri = new HttpURL(originalUrl, Charset.forName("UTF-8").name()); } else {//from w w w . jav a 2 s . c o m this.uri = new URI(originalUrl, false, Charset.forName("UTF-8").name()); } } else { throw new URIException("Can't find scheme (protocol name)."); } }
From source file:smartrics.rest.fitnesse.fixture.support.http.URIBuilder.java
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);// w ww. j a va 2 s . com } } buffer.append(path); if (queryString != null) { buffer.append('?'); buffer.append(queryString); } String charset = params.getUriCharset(); return new HttpURL(buffer.toString(), charset); }