Exemplo n.º 1
0
  private void generateDocs(DOMFace rootEle) throws Exception {
    DOMFace allDocs = rootEle.createChild("documents", DOMFace.class);
    for (AttachmentRecord att : ngp.getAllAttachments()) {

      // first check if this license has access
      if (att.getVisibility() == 1) {
        // public document, so everyone can get it
      } else if (isMember) {
        // members can access everything
      } else if (att.roleCanAccess(license.getRole())) {
        // license role has access
      } else {
        // no access, so skip to next attachment
        continue;
      }

      DOMFace oneDoc = allDocs.createChild("doc", DOMFace.class);
      oneDoc.setAttribute("id", att.getId());
      oneDoc.setScalar("universalid", att.getUniversalId());
      oneDoc.setScalar("name", att.getNiceName());
      oneDoc.setScalar("size", Long.toString(att.getFileSize(ngp)));
      setScalarTime(oneDoc, "modifiedtime", att.getModifiedDate());
      oneDoc.setScalar("modifieduser", att.getModifiedBy());
    }
  }
Exemplo n.º 2
0
  private void generateResponse() throws Exception {

    String lic = ar.reqParam("lic");
    license = ngp.getLicense(lic);
    if (license == null) {
      throw new Exception("Can not access this page, license id is no longer valid: " + lic);
    }
    String lRole = license.getRole();
    if (lRole.equals(ngp.getPrimaryRole().getName())) {
      isMember = true;
    }
    if (lRole.equals(ngp.getSecondaryRole().getName())) {
      isMember = true;
      isAdmin = true;
    }

    Document mainDoc = DOMUtils.createDocument("case");
    DOMFace rootEle = new DOMFace(mainDoc, mainDoc.getDocumentElement(), null);

    generateDocs(rootEle);
    generateNotes(rootEle);
    generateGoals(rootEle);

    DOMUtils.writeDom(mainDoc, ar.w);
  }