code: public static List<CmsResource> getGalleries(int galleryTypeId, CmsObject cms) {
  
          List<CmsResource> galleries = new ArrayList<CmsResource>();
          try {
              // get the galleries of the current site
              galleries = cms.readResources("/", CmsResourceFilter.ONLY_VISIBLE_NO_DELETED.addRequireType(galleryTypeId));
          } catch (CmsException e) {
              // error reading resources with filter
              LOG.error(e.getLocalizedMessage(), e);
          }
  
          // if the current site is NOT the root site - add all other galleries from the system path
          if (!cms.getRequestContext().getSiteRoot().equals("")) {
              List<CmsResource> systemGalleries = null;
              try {
                  // get the galleries in the /system/ folder
                  systemGalleries = cms.readResources(
                      CmsWorkplace.VFS_PATH_SYSTEM,
                      CmsResourceFilter.ONLY_VISIBLE_NO_DELETED.addRequireType(galleryTypeId));
              } catch (CmsException e) {
                  // error reading resources with filter
                  LOG.error(e.getLocalizedMessage(), e);
              }
  
              if ((systemGalleries != null) && (systemGalleries.size() > 0)) {
                  // add the found system galleries to the result
                  galleries.addAll(systemGalleries);
              }
          }
  
          // return the found galleries
          return galleries;
      }
docs: Returns a list of galleries which have the required gallery type id.<p>
  
  @param galleryTypeId type id of the gallery
  @param cms the initialized CmsObject for the current user
  @return a list of galleries