Exemple #1
0
  private void addFolder(ContentCollection n, ResourceDefinition rp, int depth)
      throws SDataException {
    put("available", n.isAvailable());
    put("hidden", n.isHidden());
    if (!n.isHidden()) {
      Time releaseDate = n.getReleaseDate();
      if (releaseDate != null) {
        put("releaseDate", releaseDate.getTime());
      }
      Time retractDate = n.getRetractDate();
      if (retractDate != null) {
        put("retractDate", retractDate.getTime());
      }
    }

    ContentCollection cc = (ContentCollection) n;
    put("members", cc.getMemberCount());
    if (depth >= 0) {

      Map<String, Object> nodes = new HashMap<String, Object>();
      // list of IDs
      List<?> l = cc.getMembers();

      int i = 0;
      for (int k = 0; k < l.size(); k++) {
        String memberID = (String) l.get(k);
        ContentEntity cn = null;
        try {
          cn = contentHostingService.getResource(memberID);
        } catch (Exception idex) {
          try {
            String collectionPath = memberID;
            if (!collectionPath.endsWith("/")) {
              collectionPath = collectionPath + "/";
            }
            cn = contentHostingService.getCollection(collectionPath);
          } catch (Exception ex) {

          }
        }
        if (cn != null) {

          try {
            Map<String, Object> m = new CHSNodeMap(cn, depth, rp);
            m.put("position", String.valueOf(i));
            nodes.put(getName(cn), m);
          } catch (SDataAccessException sdae) {
            // hide the item from the list
            continue;
          }
        }
        i++;
      }
      put("nitems", nodes.size());
      put("items", nodes);
    }
  }
  public static org.sakaiproject.content.api.ContentCollection getCollection(
      java.lang.String param0)
      throws org.sakaiproject.exception.IdUnusedException, org.sakaiproject.exception.TypeException,
          org.sakaiproject.exception.PermissionException {
    org.sakaiproject.content.api.ContentHostingService service = getInstance();
    if (service == null) return null;

    return service.getCollection(param0);
  }