docs: protected void buildJsonGalleryList() {
  
          String lastUsed = getSettings().getLastUsedGallery("" + getGalleryTypeId());
          // check the value of last Used, if gallery is opened for the first time
          if (CmsStringUtil.isEmpty(lastUsed)) {
              // start gallery settings for this gallery type for the current user
              String startGallerySetting = getSettings().getUserSettings().getStartGallery(
                  getGalleryTypeName(),
                  getCms());
              if (startGallerySetting != null) {
                  // handle the case, "global settings" are selected
                  if (startGallerySetting.equals(CmsWorkplace.INPUT_DEFAULT)) {
                      // get selected value from workplace xml settings
                      String preselectedValue = OpenCms.getWorkplaceManager().getDefaultUserSettings().getStartGallery(
                          getGalleryTypeName());
                      if (preselectedValue != null) {
                          startGallerySetting = preselectedValue;
                      }
                  }
                  // checks if the resource exists
                  String sitePath = getCms().getRequestContext().removeSiteRoot(startGallerySetting);
                  if (getCms().existsResource(sitePath)) {
                      lastUsed = sitePath;
                  }
              }
          }
          JSONArray galleries = new JSONArray();
          Iterator<CmsResource> i = getGalleries().iterator();
          boolean isFirst = true;
          while (i.hasNext()) {
              CmsResource res = i.next();
              String path = getCms().getSitePath(res);
              JSONObject jsonObj = new JSONObject();
              // 1: gallery title
              String title = "";
              try {
                  // read the gallery title
                  title = getCms().readPropertyObject(path, CmsPropertyDefinition.PROPERTY_TITLE, false).getValue("");
              } catch (CmsException e) {
                  // error reading title property
                  if (LOG.isErrorEnabled()) {
                      LOG.error(e.getLocalizedMessage(), e);
                  }
              }
              try {
                  jsonObj.put("title", title);
                  // 2: gallery path
                  jsonObj.put("path", path);
                  // 3: active flag
                  boolean active = false;
                  if ((CmsStringUtil.isEmpty(lastUsed) && isFirst) || path.equals(lastUsed)) {
                      // TODO: adjust logic to get active gallery
                      active = true;
                  }
                  jsonObj.put("active", active);
                  galleries.put(jsonObj);
              } catch (JSONException e) {
                  if (LOG.isErrorEnabled()) {
                      LOG.error(e.getLocalizedMessage(), e);
                  }
              }
              isFirst = false;
          }
          JspWriter out = getJsp().getJspContext().getOut();
          try {
              out.print(galleries.toString());
          } catch (IOException e) {
              if (LOG.isErrorEnabled()) {
                  LOG.error(e.getLocalizedMessage(), e);
              }
          }
      }