public static boolean hasAuthorization(String serviceName, Long clusterResourceId,
                                         Set<RoleAuthorization> clusterLevelAuthorizations,
                                         Set<RoleAuthorization> serviceLevelAuthorizations) {
    if (null == clusterResourceId) {
      // Do not let clusterResourceId be null because that indicates we don't care about which cluster
      // we are checking authorization for, but we do.  Setting this to -1 ensures that no cluster
      // will match will will give only Ambari administrators access to this.
      clusterResourceId = -1L;
    }

    return AuthorizationHelper.isAuthorized(ResourceType.CLUSTER, clusterResourceId,
        (StringUtils.isEmpty(serviceName) || "AMBARI".equals(serviceName))
            ? clusterLevelAuthorizations
            : serviceLevelAuthorizations);
  }
Tests if the authenticated user is authorized to for either service- or cluster-level access to
alert data.
<p/>
If the service name is null or empty, the alert is considered to be a cluster-level alert,
else it is considered to be a service-level alert.
<p/>
If the clusterResourceId is null, no cluster is assume and the alert is considered to be an
Ambari-level alert.

@param serviceName                the name of the relevant service - null or empty indicates a cluster-level alert
@param clusterResourceId          the resource id of the relevant cluster
@param clusterLevelAuthorizations the set of cluster-level authorizations to check for
@param serviceLevelAuthorizations the set of service-level authorizations to check for
@return true if the authenticated user is authorized; otherwise false
ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AlertResourceProviderUtils.java