Пример #1
0
 /**
  * Converts the given {@link Response} to a {@link de.aflx.sardine.DavResource}.
  *
  * @param response The response complex type of the multistatus
  * @throws java.net.URISyntaxException If parsing the href from the response element fails
  */
 public DavResource(Response response) throws URISyntaxException {
   this.href = new URI(response.getHref());
   // this.href = new URI(response.getHref().get(0));
   this.creation = SardineUtil.parseDate(this.getCreationDate(response));
   this.modified = SardineUtil.parseDate(this.getModifiedDate(response));
   this.contentType = this.getContentType(response);
   this.contentLength = this.getContentLength(response);
   this.etag = this.getEtag(response);
   this.customProps = this.getCustomProps(response);
 }
Пример #2
0
 /**
  * Retrieves modifieddate from props. If it is not available return null.
  *
  * @param response The response complex type of the multistatus
  * @return Null if not found in props
  */
 private String getModifiedDate(Response response) {
   Propstat list = response.getPropstat();
   if (list.equals("") || null == list) {
     return null;
   }
   return list.getProp().getGetlastmodified();
   /*if (list.isEmpty()) {
   	return null;
   }
         for(Propstat propstat: list) {
             Getlastmodified glm = propstat.getProp().getGetlastmodified();
             if ((glm != null) && (glm.getContent().size() == 1)) {
                 return glm.getContent().get(0);
             }
         }
   return null; */
 }
Пример #3
0
 /**
  * Retrieves content-length from props. If it is not available return {@link
  * #DEFAULT_CONTENT_LENGTH}.
  *
  * @param response The response complex type of the multistatus
  * @return contentlength
  */
 private String getEtag(Response response) {
   Propstat list = response.getPropstat();
   if (list.equals("") || null == list) {
     return null;
   }
   return list.getProp().getGetetag();
   /*List<Propstat> list = response.getPropstat();
   if (list.isEmpty()) {
             return null;
         }
         for(Propstat propstat: list) {
             Getetag etag = propstat.getProp().getGetetag();
             if ((etag != null) && (etag.getContent().size() == 1))
             {
                 return etag.getContent().get(0);
             }
         }
   return null;*/
 }
Пример #4
0
 /**
  * Retrieves creationdate from props. If it is not available return null.
  *
  * @param response The response complex type of the multistatus
  * @return Null if not found in props
  */
 private String getCreationDate(Response response) {
   Propstat list = response.getPropstat();
   if (list.equals("") || null == list) {
     return null;
   }
   return list.getProp().getCreationdate();
   /*List<Propstat> list = response.getPropstat();
         if (list.isEmpty()) {
             return null;
         }
         for(Propstat propstat: list) {
             Creationdate gcd = propstat.getProp().getCreationdate();
             if ((gcd != null) && (gcd.getContent().size() == 1))
             {
                 return gcd.getContent().get(0);
             }
         }
   return null;*/
 }
Пример #5
0
  /**
   * Retrieves the content-type from prop or set it to {@link #DEFAULT_CONTENT_TYPE}. If isDirectory
   * always set the content-type to {@link #HTTPD_UNIX_DIRECTORY_CONTENT_TYPE}.
   *
   * @param response The response complex type of the multistatus
   * @return the content type.
   */
  private String getContentType(Response response) {
    Propstat list = response.getPropstat();
    if (list.equals("") || null == list) {
      return null;
    }

    String type = list.getProp().getGetcontenttype();

    // If there is no content type set in the properties, we will parse the href
    if (null == type) {
      if (this.getHref().toString().endsWith("/")) {
        type = HTTPD_UNIX_DIRECTORY_CONTENT_TYPE;
      } else {
        type = DEFAULT_CONTENT_TYPE;
      }
    }

    return type;
    /*// Make sure that directories have the correct content type.
    List<Propstat> list = response.getPropstat();
    if (list.isEmpty()) {
    	return null;
    }
          for(Propstat propstat: list) {
              Resourcetype resourcetype = propstat.getProp().getResourcetype();
              if ((resourcetype != null) && (resourcetype.getCollection() != null))
              {
                  // Need to correct the contentType to identify as a directory.
                  return HTTPD_UNIX_DIRECTORY_CONTENT_TYPE;
              }
              else
              {
                  Getcontenttype gtt = propstat.getProp().getGetcontenttype();
                  if ((gtt != null) && (gtt.getContent().size() == 1))
                  {
                      return gtt.getContent().get(0);
                  }
              }
          }
    return DEFAULT_CONTENT_TYPE;*/
  }