示例#1
0
  public void addResourceTo(
      DavContext ctxt, DavResource rs, DavContext.RequestProp props, boolean includeChildren)
      throws DavException {
    if (!rs.isValid()) {
      addStatus(ctxt, rs.getUri(), HttpServletResponse.SC_NOT_FOUND);
      return;
    }
    Element top = getTop(DavElements.E_MULTISTATUS).addElement(DavElements.E_RESPONSE);
    rs.getProperty(DavElements.E_HREF).toElement(ctxt, top, false);

    Collection<QName> propNames;

    if (props.isAllProp()) propNames = rs.getAllPropertyNames();
    else propNames = props.getProps();

    PropStat propstat = new PropStat();
    Map<QName, DavException> errPropMap = props.getErrProps();
    for (QName name : propNames) {
      ResourceProperty prop = rs.getProperty(name, props);
      if (errPropMap.containsKey(name)) {
        DavException ex = errPropMap.get(name);
        propstat.add(name, null, ex.getStatus());
      } else if (prop == null) {
        if (!ctxt.isBrief()) propstat.add(name, null, HttpServletResponse.SC_NOT_FOUND);
      } else {
        propstat.add(prop);
      }
    }

    propstat.toResponse(ctxt, top, props.isNameOnly());
  }
示例#2
0
 public void addResources(
     DavContext ctxt, Collection<DavResource> rss, DavContext.RequestProp props)
     throws DavException {
   ctxt.setStatus(DavProtocol.STATUS_MULTI_STATUS);
   boolean first = true;
   for (DavResource rs : rss) {
     if (first) ctxt.setDavCompliance(DavProtocol.getComplianceString(rs.getComplianceList()));
     addResourceTo(ctxt, rs, props, false);
     first = false;
   }
 }
示例#3
0
  /* Convenience method to gather requested properties from the resource and
   * append them to the response.
   */
  public void addResource(
      DavContext ctxt, DavResource rs, DavContext.RequestProp props, boolean includeChildren)
      throws DavException {
    ctxt.setStatus(DavProtocol.STATUS_MULTI_STATUS);
    ctxt.setDavCompliance(DavProtocol.getComplianceString(rs.getComplianceList()));
    addResourceTo(ctxt, rs, props, includeChildren);

    if (rs.isCollection() && includeChildren)
      for (DavResource child : rs.getChildren(ctxt))
        addResource(ctxt, child, props, includeChildren);
  }