@Override
 public Set<String> getAllPublishingEnvironments(String site) {
   SiteService siteService = _servicesManager.getService(SiteService.class);
   Map<String, PublishingChannelGroupConfigTO> groupConfigTOs =
       siteService.getPublishingChannelGroupConfigs(site);
   Set<String> environments = new HashSet<String>();
   if (groupConfigTOs != null && groupConfigTOs.size() > 0) {
     for (PublishingChannelGroupConfigTO groupConfigTO : groupConfigTOs.values()) {
       if (StringUtils.isNotEmpty(groupConfigTO.getName())) {
         environments.add(groupConfigTO.getName());
       }
     }
   }
   return environments;
 }
  @Override
  public Set<PublishingTargetItem> getAllTargetsForSite(String site) {
    PersistenceManagerService persistenceManagerService =
        _servicesManager.getService(PersistenceManagerService.class);
    SiteService siteService = _servicesManager.getService(SiteService.class);
    Map<String, PublishingChannelGroupConfigTO> groupConfigTOs =
        siteService.getPublishingChannelGroupConfigs(site);
    Set<PublishingTargetItem> targets = new HashSet<PublishingTargetItem>();
    Map<String, PublishingTargetItem> targetMap = new HashMap<String, PublishingTargetItem>();
    if (groupConfigTOs != null && groupConfigTOs.size() > 0) {
      for (PublishingChannelGroupConfigTO groupConfigTO : groupConfigTOs.values()) {
        List<PublishingChannelConfigTO> channelConfigTOs = groupConfigTO.getChannels();
        if (channelConfigTOs != null && channelConfigTOs.size() > 0) {
          for (PublishingChannelConfigTO channelConfigTO : channelConfigTOs) {
            DeploymentEndpointConfigTO endpoint =
                siteService.getDeploymentEndpoint(site, channelConfigTO.getName());
            if (endpoint != null) {
              PublishingTargetItem targetItem = targetMap.get(endpoint.getName());
              if (targetItem == null) {
                targetItem = new PublishingTargetItem();
                targetItem.setId(endpoint.getName());
                targetItem.setName(endpoint.getName());
                targetItem.setTarget(endpoint.getTarget());
                targetItem.setType(endpoint.getType());
                targetItem.setServerUrl(endpoint.getServerUrl());
                targetItem.setStatusUrl(endpoint.getStatusUrl());
                targetItem.setVersionUrl(endpoint.getVersionUrl());
                targetItem.setPassword(endpoint.getPassword());
                targetItem.setExcludePattern(endpoint.getExcludePattern());
                targetItem.setIncludePattern(endpoint.getIncludePattern());
                targetItem.setBucketSize(endpoint.getBucketSize());
                targetItem.setSiteId(endpoint.getSiteId());
                targets.add(targetItem);

                targetMap.put(endpoint.getName(), targetItem);
              }
              targetItem.addEnvironment(groupConfigTO.getName());
            }
          }
        }
      }
    }
    return targets;
  }