Exemplo n.º 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());
  }