private Set<ClusterResponse> getClusters(ClusterRequest request)
      throws AmbariException, AuthorizationException {

    Set<ClusterResponse> response = new HashSet<>();

    if (LOG.isDebugEnabled()) {
      LOG.debug("Received a getClusters request, clusterName={}, clusterId={}, stackInfo={}",
        request.getClusterName(), request.getClusterId(), request.getStackVersion());
    }

    Cluster singleCluster = null;
    try {
      if (request.getClusterName() != null) {
        singleCluster = clusters.getCluster(request.getClusterName());
      } else if (request.getClusterId() != null) {
        singleCluster = clusters.getClusterById(request.getClusterId());
      }
    }
    catch(ClusterNotFoundException e) {
      // the user shouldn't know the difference between a cluster that does not exist or one that
      // he doesn't have access to.
      if (AuthorizationHelper.isAuthorized(ResourceType.AMBARI, null, RoleAuthorization.AMBARI_ADD_DELETE_CLUSTERS)) {
        throw e;
      } else {
        throw new AuthorizationException();
      }
    }

    if (singleCluster != null) {
      ClusterResponse cr = singleCluster.convertToResponse();
      cr.setDesiredConfigs(singleCluster.getDesiredConfigs());
      cr.setDesiredServiceConfigVersions(singleCluster.getActiveServiceConfigVersions());
      cr.setCredentialStoreServiceProperties(getCredentialStoreServiceProperties());

     // If the user is authorized to view information about this cluster, add it to the response
// TODO: Uncomment this when the UI doesn't require view access for View-only users.
//      if (AuthorizationHelper.isAuthorized(ResourceType.CLUSTER, cr.getResourceId(),
//          RoleAuthorization.AUTHORIZATIONS_VIEW_CLUSTER)) {
      response.add(cr);
//      }
//      else {
//        // the user shouldn't know the difference between a cluster that does not exist or one that
//        // he doesn't have access to.
//        throw new AuthorizationException();
//      }

      return response;
    }


    Map<String, Cluster> allClusters = clusters.getClusters();
    for (Cluster c : allClusters.values()) {

// TODO: Uncomment this when the UI doesn't require view access for View-only users.
//       If the user is authorized to view information about this cluster, add it to the response
//       if (AuthorizationHelper.isAuthorized(ResourceType.CLUSTER, c.getResourceId(),
//        RoleAuthorization.AUTHORIZATIONS_VIEW_CLUSTER)) {
      ClusterResponse cr = c.convertToResponse();
      cr.setDesiredConfigs(c.getDesiredConfigs());
      cr.setDesiredServiceConfigVersions(c.getActiveServiceConfigVersions());
      cr.setCredentialStoreServiceProperties(getCredentialStoreServiceProperties());
      response.add(cr);
//       }
    }
    StringBuilder builder = new StringBuilder();
    if (LOG.isDebugEnabled()) {
      clusters.debugDump(builder);
      LOG.debug("Cluster State for cluster {}", builder);
    }
    return response;
  }
Creates a configuration.
<p>
This implementation ensures the authenticated user is authorized to create the new configuration
based on the details of what properties are being changed and the authorizations the authenticated
user has been granted.
<p>
Example
<ul>
<li>
If the user is attempting to change a service-level configuration that user must be granted the
<code>SERVICE_MODIFY_CONFIGS</code> privilege (authorization)
</li>
<li>
If the user is attempting to change the cluster-wide value to enable or disable auto-start
(<code>cluster-env/recovery_enabled</code>), that user must be granted the
<code>CLUSTER_MANAGE_AUTO_START</code> privilege (authorization)
</li>
</ul>

@param request the request object which defines the configuration.
@throws AmbariException when the configuration cannot be created.
ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementControllerImpl.java