Examples of HttpURL


Examples of org.apache.commons.httpclient.HttpURL

     * @return the value 0 if the argument is equal.
     */
    public int compareToWebdavResource(WebdavResource another) {

        try {
            HttpURL anotherUrl = another.getHttpURL();

            String thisHost = httpURL.getHost();
            String anotherHost= anotherUrl.getHost();
            if (!thisHost.equalsIgnoreCase(anotherHost))
                return thisHost.compareTo(anotherHost);

            int thisPort = httpURL.getPort();
            int anotherPort= anotherUrl.getPort();
            if (thisPort != anotherPort)
                return (thisPort < anotherPort) ? -1 : 1;

            boolean thisCollection = isCollection();
            boolean anotherCollection = another.isCollection();
            if (thisCollection && !anotherCollection)
                return -1;
            if (anotherCollection && !thisCollection)
                return 1;

            String thisPath = httpURL.getPathQuery();
            String anotherPath= anotherUrl.getPathQuery();
            return thisPath.compareTo(anotherPath);
        } catch (Exception e) {
            // FIXME: not to return 0.
        }

View Full Code Here

Examples of org.apache.commons.httpclient.HttpURL

   * @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));
  }
View Full Code Here

Examples of org.apache.commons.httpclient.HttpURL

   * @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()));
  }
View Full Code Here

Examples of org.apache.commons.httpclient.HttpURL

        return sResult;
    }

    private static HttpURL uriToHttpURL(String uri) throws URIException {
        return uri.startsWith("https") ? new HttpsURL(uri.toCharArray())
                                       : new HttpURL(uri.toCharArray());
    }
View Full Code Here

Examples of org.apache.commons.httpclient.HttpURL

        final SimpleHttpServerConnection conn,
        final SimpleRequest request) throws IOException
    {
        Log wireLog = LogFactory.getLog("httpclient.wire");
       
        URI url = new HttpURL(request.getRequestLine().getUri());

        HttpClient client = new HttpClient();
        HostConfiguration hc = new HostConfiguration();
        hc.setHost(url);
        client.setHostConfiguration(hc);
       
        //TODO support other methods
        HttpMethod method = new GetMethod(url.getPathQuery());
        Header[] headers = request.getHeaders();
        for (int i=0; i<headers.length; i++) {
            method.addRequestHeader(headers[i]);
        }
        if (method instanceof EntityEnclosingMethod) {
View Full Code Here

Examples of org.apache.commons.httpclient.HttpURL

        }

    }

    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);
        }
View Full Code Here

Examples of org.apache.commons.httpclient.HttpURL

        try {
            if (containingDir == null) {
                throw new IOException("Containing directory is null:");
            }
            WebdavFile newFolder = null;
            HttpURL url = null;

            url = this.uriToHttpURL(containingDir.getPath() +
                                    WebdavFile.davSeparator + newFolderString);
            // Need to add user info so has access for queries
            url.setUserinfo(username, password);
            newFolder = new WebdavFile(url, this.rootURL);
            //System.out.println("new folder : " + newFolder.toString());

            this.connect();
            if (this.webdavResource.mkcolMethod(
View Full Code Here

Examples of org.apache.commons.httpclient.HttpURL

    public File[] getFiles(File dir, boolean useFileHiding) {
        try {

            String filenames[] = null;
            WebdavFile files[] = null;
            HttpURL url = null;
            String path = null;
            String localDir = null;

            this.connect();
            // Now we try to list files

            path = dir.getPath();
            //System.out.println("getFiles : RAW PATH : '" + path + "'");

            // If path contains the server preamble, we need to extract that
            // and have the path only
            if (path.startsWith("http")) {
                //System.out.println("getFiles : preample : " + this.uri);
                path = path.replaceAll(this.uri, "");
            }
            if (!path.endsWith("/")) {
                path = path + "/";
            }

            //System.out.println("getFiles : path : " + path);

            this.webdavResource.setPath(path);
            filenames = this.webdavResource.list();
            files = new WebdavFile[filenames.length];
            for (int i = 0; i < filenames.length; i++) {
                //System.out.println("file : " + filenames[i]);
                // Lets try to construct a uri from the dir
                // given and the current file

                localDir = dir.getPath();
                if (!localDir.endsWith("/")) localDir = localDir + "/";

                String filepath =  localDir + filenames[i];
                //System.out.println("getFiles : file fullpath : " + filepath);
                url = this.uriToHttpURL(filepath);
                // Need to add user info so has access for queries
                url.setUserinfo(username, password);
                files[i] = new WebdavFile(url, this.rootURL);
            }
            return files;
        } catch (Exception e) {
            System.err.println(e.toString());
View Full Code Here

Examples of org.apache.commons.httpclient.HttpURL

                return null;
            }
        }
        public File getParentFile() {
            try {
                HttpURL httpURL = null;
                String parent = null;
                parent = this.getParent();
                if (parent == null) {
                    //System.out.println("getParentFile : at root so return null");
                    return null;
                } else {
                    httpURL = this.rootUrl;
                    httpURL.setPath(parent);
                    //System.out.println("getParentFile : set path to " + parent);
                    return new WebdavFile(httpURL, this.rootUrl);
                }
            } catch (Exception e) {
                System.err.println(e.toString());
View Full Code Here

Examples of org.apache.commons.httpclient.HttpURL

         path = path + "/";
      }
      Stack toBeCreated = new Stack();
     
      while (!path.equals("/")) {
         HttpURL parent = Utils.createHttpURL(httpURL, path);
         if (!collectionExists(client, parent)) {
            toBeCreated.push(path);
            path = path.substring(0, path.lastIndexOf("/", path.length()-2)+1);
         } else {
            break;
         }
      }

      boolean created = !toBeCreated.empty();
      while(!toBeCreated.empty()) {
         HttpURL newColl = Utils.createHttpURL(httpURL, (String)toBeCreated.pop());
         MkcolMethod mkcol = new MkcolMethod(newColl.getURI());
         mkcol.setFollowRedirects(true);
         generateIfHeader(mkcol, lockToken);
         int status = client.executeMethod(mkcol);
         if (status != WebdavStatus.SC_CREATED) {
            HttpException ex = new HttpException("Can't create collection " +
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.