当前位置: 首页>>代码示例>>Java>>正文


Java HttpURL.getURI方法代码示例

本文整理汇总了Java中org.apache.commons.httpclient.HttpURL.getURI方法的典型用法代码示例。如果您正苦于以下问题:Java HttpURL.getURI方法的具体用法?Java HttpURL.getURI怎么用?Java HttpURL.getURI使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.commons.httpclient.HttpURL的用法示例。


在下文中一共展示了HttpURL.getURI方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: resourceExists

import org.apache.commons.httpclient.HttpURL; //导入方法依赖的package包/类
/**
 * Returns <code>true</code> if the resource given as URL does exist.
 * @param client
 * @param httpURL
 * @return <code>true</code>if the resource exists
 * @throws IOException
 * @throws HttpException
 */
public static boolean resourceExists(HttpClient client, HttpURL httpURL)
   throws IOException, HttpException
{
   HeadMethod head = new HeadMethod(httpURL.getURI());
   head.setFollowRedirects(true);
   int status = client.executeMethod(head);
   
   switch (status) {
      case WebdavStatus.SC_OK:
         return true;
      case WebdavStatus.SC_NOT_FOUND:
         return false;
      default:
         HttpException ex = new HttpException();
         ex.setReasonCode(status);
         ex.setReason(head.getStatusText());
         throw ex;
   }
}
 
开发者ID:integrated,项目名称:jakarta-slide-webdavclient,代码行数:28,代码来源:Utils.java

示例2: putFile

import org.apache.commons.httpclient.HttpURL; //导入方法依赖的package包/类
public static void putFile(HttpClient client, 
                           HttpURL url, 
                           InputStream is,
                           String contentType,
                           String lockToken)
   throws IOException, HttpException
{
   PutMethod put = new PutMethod(url.getURI());
   generateIfHeader(put, lockToken);
   put.setRequestHeader("Content-Type", contentType);
   put.setRequestBody(is);
   put.setFollowRedirects(true);
   int status = client.executeMethod(put);
   switch (status) {
      case WebdavStatus.SC_OK:
      case WebdavStatus.SC_CREATED:
      case WebdavStatus.SC_NO_CONTENT:
         return;
      default:
         HttpException ex = new HttpException();
         ex.setReason(put.getStatusText());
         ex.setReasonCode(status);
         throw ex;
   }
}
 
开发者ID:integrated,项目名称:jakarta-slide-webdavclient,代码行数:26,代码来源:Utils.java

示例3: unlockResource

import org.apache.commons.httpclient.HttpURL; //导入方法依赖的package包/类
public static void unlockResource(HttpClient client, HttpURL url, 
                                  String lockToken)
   throws IOException, HttpException
{
   UnlockMethod unlock = new UnlockMethod(url.getURI(), lockToken);
   unlock.setFollowRedirects(true);
   int status = client.executeMethod(unlock);
   
   switch (status) {
      case WebdavStatus.SC_OK:
      case WebdavStatus.SC_NO_CONTENT:
         return;
      
      default:
         HttpException ex = new HttpException();
         ex.setReasonCode(status);
         ex.setReason(unlock.getStatusText());
         throw ex;
   }
}
 
开发者ID:integrated,项目名称:jakarta-slide-webdavclient,代码行数:21,代码来源:Utils.java

示例4: copyResource

import org.apache.commons.httpclient.HttpURL; //导入方法依赖的package包/类
public static void copyResource(HttpClient client, HttpURL url, 
                                String destination, int depth, boolean overwrite)
   throws IOException, HttpException 
{
   CopyMethod copy = new CopyMethod(
           url.getURI(), 
           destination, 
           overwrite, 
           depth);
   copy.setFollowRedirects(true);
   int status = client.executeMethod(copy);
   switch (status) {
      case WebdavStatus.SC_OK:
      case WebdavStatus.SC_CREATED:
      case WebdavStatus.SC_NO_CONTENT:
          return;
      
      default:
          HttpException ex = new HttpException();
          ex.setReasonCode(status);
          ex.setReason(copy.getStatusText());
          throw ex;
   }
}
 
开发者ID:integrated,项目名称:jakarta-slide-webdavclient,代码行数:25,代码来源:Utils.java

示例5: moveResource

import org.apache.commons.httpclient.HttpURL; //导入方法依赖的package包/类
public static void moveResource(HttpClient client, HttpURL url, 
                                   String destination, boolean overwrite)
      throws IOException, HttpException 
   {
      MoveMethod move = new MoveMethod(url.getURI(), destination, overwrite);
      move.setFollowRedirects(true);
      int status = client.executeMethod(move);
      switch (status) {
         case WebdavStatus.SC_OK:
         case WebdavStatus.SC_CREATED:
         case WebdavStatus.SC_NO_CONTENT:
             return;

         default:
             HttpException ex = new HttpException();
             ex.setReasonCode(status);
             ex.setReason(move.getStatusText());
             throw ex;
   }
}
 
开发者ID:integrated,项目名称:jakarta-slide-webdavclient,代码行数:21,代码来源:Utils.java

示例6: collectionExists

import org.apache.commons.httpclient.HttpURL; //导入方法依赖的package包/类
public static boolean collectionExists(HttpClient client, HttpURL httpURL)
   throws IOException, HttpException
{
   Vector props = new Vector(1);
   props.add(RESOURCETYPE);
   PropFindMethod propFind = new PropFindMethod(httpURL.getURI(), 
                                                 0, PropFindMethod.BY_NAME);
   propFind.setFollowRedirects(true);
   propFind.setPropertyNames(props.elements());
   int status = client.executeMethod(propFind);
   switch (status) {
      case WebdavStatus.SC_MULTI_STATUS:
         Property p = findProperty(propFind, RESOURCETYPE, httpURL.getPath());
         if (p instanceof ResourceTypeProperty) {
            return ((ResourceTypeProperty)p).isCollection();
         } else {
            throw new WebdavException("PROPFFIND does not return resourcetype");
         }
      case WebdavStatus.SC_NOT_FOUND:
         return false;
      default:
         HttpException ex = new HttpException();
         ex.setReasonCode(status);
         ex.setReason(propFind.getStatusText());
         throw ex;
   }
}
 
开发者ID:integrated,项目名称:jakarta-slide-webdavclient,代码行数:28,代码来源:Utils.java

示例7: getLastModified

import org.apache.commons.httpclient.HttpURL; //导入方法依赖的package包/类
public static long getLastModified(HttpClient client, HttpURL url)
   throws IOException, HttpException
{
   Vector props = new Vector(1);
   props.add(GETLASTMODIFIED);
   PropFindMethod propFind = new PropFindMethod(url.getURI(), 0);
   propFind.setPropertyNames(props.elements());
   propFind.setFollowRedirects(true);
   
   int status = client.executeMethod(propFind);
   switch (status) {
      case WebdavStatus.SC_MULTI_STATUS:
         Property p = findProperty(propFind, GETLASTMODIFIED, url.getPath());
         if (p != null) {
            try {
               Date d = GETLASTMODIFIED_FORMAT.parse(p.getPropertyAsString());
               return d.getTime();
            } 
            catch (ParseException e) {
               throw new HttpException("Invalid lastmodified property: " +
                     p.getPropertyAsString());
            }
         } 
         throw new HttpException("PROPFIND does not return lastmodified.");
      default:
         HttpException ex = new HttpException();
         ex.setReasonCode(status);
         ex.setReason(propFind.getStatusText());
         throw ex;
   }
}
 
开发者ID:integrated,项目名称:jakarta-slide-webdavclient,代码行数:32,代码来源:Utils.java

示例8: assureExistingCollection

import org.apache.commons.httpclient.HttpURL; //导入方法依赖的package包/类
/**
 * 
 * @param client
 * @param httpURL
 * @param lockToken the locktoken to be used or <code>null</code> if 
 *         none is to be used
 * @throws IOException
 * @throws HttpException
 */
public static boolean assureExistingCollection(HttpClient client, 
                                               HttpURL httpURL,
                                               String lockToken)
   throws IOException, HttpException
{
   String path = httpURL.getPath();
   if (!path.endsWith("/")) {
      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 " + 
                                              newColl);
         ex.setReasonCode(status);
         ex.setReason(mkcol.getStatusText());
         throw ex;
      }
   }
   return created;
}
 
开发者ID:integrated,项目名称:jakarta-slide-webdavclient,代码行数:48,代码来源:Utils.java

示例9: readCollection

import org.apache.commons.httpclient.HttpURL; //导入方法依赖的package包/类
protected void readCollection(HttpURL collURL) 
      throws URIException
{
   if (!collURL.getPath().endsWith(SEPARATOR)) {
      collURL = Utils.createHttpURL(collURL, "");
      collURL.setPath(collURL.getPath() + SEPARATOR);
   }
   
   // get a list of all resources from the given URL
   PropFindMethod propFind = new PropFindMethod(collURL.getURI(),
                                                DepthSupport.DEPTH_1,
                                                PropFindMethod.BY_NAME);
   propFind.setPropertyNames(propertyNames.elements());
   propFind.setFollowRedirects(true);
   try {
      this.client.executeMethod(propFind);
   } 
   catch (IOException e) {
      Utils.makeBuildException("Can't read collection content!", e);
   }
   
   List subCollections = new ArrayList();
   this.properties.storeProperties(propFind);
   
   // this collection
   addResource(collURL.getPath(), true);
   
   // for each content element, check resource type and classify
   for (Enumeration e = propFind.getAllResponseURLs(); e.hasMoreElements(); ) 
   {
      String href = (String) e.nextElement();
      
      ResourceTypeProperty property = 
                             this.properties.getResourceType(collURL, href);
      
      if (property != null) {
         if (property.isCollection()) {
            if (!href.endsWith(SEPARATOR)) href = href + SEPARATOR;
            // the collection URL itself may be in the list of 
            // response URL; filter them out to avoid recursion 
            HttpURL sub = Utils.createHttpURL(collURL, href);
            if (!sub.equals(collURL)) {
               subCollections.add(Utils.createHttpURL(collURL, href));
            }
         } else {
            addResource(href, false);
         }
      } else {
         throw new BuildException("Can't determine resourcetype.");
      }
   }
   
   // read all sub collections
   for(Iterator i = subCollections.iterator(); i.hasNext();) {
      readCollection((HttpURL)i.next());
   }
}
 
开发者ID:integrated,项目名称:jakarta-slide-webdavclient,代码行数:58,代码来源:CollectionScanner.java

示例10: proppatch

import org.apache.commons.httpclient.HttpURL; //导入方法依赖的package包/类
protected void proppatch(HttpURL url, String logName)
   throws IOException, HttpException
{
   log(logName, ifVerbose());
   PropPatchMethod propPatch = new PropPatchMethod(url.getURI());
   if (this.locktoken != null) {
      Utils.generateIfHeader(propPatch, this.locktoken);
   }
   
   int c = 1;
   for(Iterator i = toRemove.iterator(); i.hasNext(); ) {
      Remove r = (Remove)i.next();
      propPatch.addPropertyToRemove(r.name, 
            r.abbrev != null ? r.abbrev : "NS"+(c++), 
            r.namespace);
   }
   for(Iterator i = toSet.iterator(); i.hasNext(); ) {
      Set a = (Set)i.next();
      propPatch.addPropertyToSet(a.name, 
            a.getValue(), 
            a.abbrev != null ? a.abbrev : "NS"+(c++), 
            a.namespace);
   }
   
   int status = getHttpClient().executeMethod(propPatch);
   count++;
   
   switch (status) {
      case WebdavStatus.SC_OK:
         // ok
         break;
      case WebdavStatus.SC_MULTI_STATUS:
         for(Enumeration e = propPatch.getResponses(); e.hasMoreElements();) {
            ResponseEntity response = (ResponseEntity)e.nextElement();
            
            if (response.getStatusCode() > 400) {
               throw Utils.makeBuildException("Error while PROPPATCH",
                     propPatch.getResponses());
            }
         }
         break;
         
      default:
         HttpException ex = new HttpException();
         ex.setReasonCode(status);
         throw ex;
   }
}
 
开发者ID:integrated,项目名称:jakarta-slide-webdavclient,代码行数:49,代码来源:Proppatch.java

示例11: WebdavFile

import org.apache.commons.httpclient.HttpURL; //导入方法依赖的package包/类
/**
 * @param httpUrl Webdav URL
 */
public WebdavFile(HttpURL httpUrl) throws URIException {
  super(httpUrl.getURI());
  this.httpUrl = httpUrl;
}
 
开发者ID:integrated,项目名称:jakarta-slide-webdavclient,代码行数:8,代码来源:WebdavFile.java


注:本文中的org.apache.commons.httpclient.HttpURL.getURI方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。