docs: protected void buildJsonResourceItems(List<CmsResource> resourceitems, String parentFolder) {
  
          if (resourceitems == null) {
              resourceitems = new ArrayList<CmsResource>();
          }
  
          boolean isPublishEnabled = false;
          boolean hasDirectPublish = false;
          boolean hasWritePermission = false;
          if (CmsStringUtil.isNotEmpty(parentFolder)) {
              // check if there are changes in the currently selected gallery and the user has direct edit permissions
              try {
                  if ((OpenCms.getPublishManager().getPublishList(
                      getCms(),
                      getCms().readResource(parentFolder),
                      false).size() > 0)) {
                      isPublishEnabled = true;
                  }
              } catch (CmsException e) {
                  // ignore, gallery can not be published
              }
              // check if the user has direst publish permissions,
              // used to enable the gallerypublish button, if user has enough permissions
              try {
                  if (getCms().hasPermissions(
                      getCms().readResource(parentFolder),
                      CmsPermissionSet.ACCESS_DIRECT_PUBLISH,
                      false,
                      CmsResourceFilter.ALL)) {
                      hasDirectPublish = true;
                  }
              } catch (CmsException e) {
                  // ignore, no publish permissions for gallery
              }
              try {
                  // check if the user has write permissions,
                  // used to display the upload buttons
                  if (getCms().hasPermissions(
                      getCms().readResource(parentFolder),
                      CmsPermissionSet.ACCESS_WRITE,
                      false,
                      CmsResourceFilter.ALL)) {
                      hasWritePermission = true;
                  }
              } catch (CmsException e) {
                  // ignore, no write permissions for gallery
              }
          }
          JSONObject publishInfo = new JSONObject();
          try {
              publishInfo.put("publishable", isPublishEnabled);
              publishInfo.put("directpublish", hasDirectPublish);
              publishInfo.put("writepermission", hasWritePermission);
          } catch (JSONException e) {
              // ignore
          }
          JSONArray items = new JSONArray();
          items.put(publishInfo);
          Iterator<CmsResource> i = resourceitems.iterator();
          while (i.hasNext()) {
              CmsResource res = i.next();
              // build a JSON object from the item and add it to the list
              items.put(buildJsonItemObject(res));
          }
          JspWriter out = getJsp().getJspContext().getOut();
          try {
              // print the JSON array
              out.print(items.toString());
          } catch (IOException e) {
              if (LOG.isErrorEnabled()) {
                  LOG.error(e.getLocalizedMessage(), e);
              }
          }
      }