code: public static IndexedContainer getAvailableSitesContainer(CmsObject cms, String captionPropertyName) {
  
          CmsSiteSelectorOptionBuilder optBuilder = new CmsSiteSelectorOptionBuilder(cms);
          optBuilder.addNormalSites(true, (new CmsUserSettings(cms)).getStartFolder());
          optBuilder.addSharedSite();
          IndexedContainer availableSites = new IndexedContainer();
          availableSites.addContainerProperty(captionPropertyName, String.class, null);
          for (CmsSiteSelectorOption option : optBuilder.getOptions()) {
              Item siteItem = availableSites.addItem(option.getSiteRoot());
              siteItem.getItemProperty(captionPropertyName).setValue(option.getMessage());
          }
          String currentSiteRoot = cms.getRequestContext().getSiteRoot();
          if (!availableSites.containsId(currentSiteRoot)) {
              availableSites.addItem(currentSiteRoot).getItemProperty(captionPropertyName).setValue(currentSiteRoot);
          }
          return availableSites;
      }
docs: Builds an IndexedContainer containing the sites selectable by the current user.<p>
  
  @param cms the CMS context
  @param captionPropertyName the name of the property used to store captions
  
  @return the container with the available sites