private LdapSyncRequest getLdapRequest(LdapSyncRequest request, LdapSyncSpecEntity spec) {

    switch (spec.getSyncType()) {
      case ALL:
        return new LdapSyncRequest(LdapSyncSpecEntity.SyncType.ALL, spec.getPostProcessExistingUsers());
      case EXISTING:
        return new LdapSyncRequest(LdapSyncSpecEntity.SyncType.EXISTING, spec.getPostProcessExistingUsers());
      case SPECIFIC:
        Set<String> principalNames = new HashSet<>(spec.getPrincipalNames());
        if (request == null ) {
          request = new LdapSyncRequest(LdapSyncSpecEntity.SyncType.SPECIFIC, principalNames, spec.getPostProcessExistingUsers());
        } else {
          request.addPrincipalNames(principalNames);
        }
    }
    return request;
  }
Update the given request with the given ldap event spec.

@param request  the sync request; may be null
@param spec     the specification of what to sync

@return the updated sync request or a new sync request if the given request is null
ambari-server/src/main/java/org/apache/ambari/server/controller/internal/LdapSyncEventResourceProvider.java