mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
Merge remote-tracking branch 'origin/4.14'
This commit is contained in:
commit
cbbb4016af
@ -55,6 +55,10 @@ public class LdapListConfigurationCmd extends BaseListCmd {
|
||||
@Parameter(name = ApiConstants.DOMAIN_ID, type = CommandType.UUID, required = false, entityType = DomainResponse.class, description = "linked domain")
|
||||
private Long domainId;
|
||||
|
||||
@Parameter(name = ApiConstants.LIST_ALL, type = CommandType.BOOLEAN, description = "If set to true, "
|
||||
+ " and no domainid specified, list all LDAP configurations irrespective of the linked domain", since = "4.13.2")
|
||||
private Boolean listAll;
|
||||
|
||||
public LdapListConfigurationCmd() {
|
||||
super();
|
||||
}
|
||||
@ -117,4 +121,8 @@ public class LdapListConfigurationCmd extends BaseListCmd {
|
||||
public void setDomainId(final Long domainId) {
|
||||
this.domainId = domainId;
|
||||
}
|
||||
|
||||
public boolean listAll() {
|
||||
return listAll != null && listAll;
|
||||
}
|
||||
}
|
||||
|
||||
@ -310,7 +310,8 @@ public class LdapManagerImpl implements LdapManager, LdapValidator {
|
||||
final String hostname = cmd.getHostname();
|
||||
final int port = cmd.getPort();
|
||||
final Long domainId = cmd.getDomainId();
|
||||
final Pair<List<LdapConfigurationVO>, Integer> result = _ldapConfigurationDao.searchConfigurations(hostname, port, domainId);
|
||||
final boolean listAll = cmd.listAll();
|
||||
final Pair<List<LdapConfigurationVO>, Integer> result = _ldapConfigurationDao.searchConfigurations(hostname, port, domainId, listAll);
|
||||
return new Pair<List<? extends LdapConfigurationVO>, Integer>(result.first(), result.second());
|
||||
}
|
||||
|
||||
|
||||
@ -37,5 +37,9 @@ public interface LdapConfigurationDao extends GenericDao<LdapConfigurationVO, Lo
|
||||
|
||||
LdapConfigurationVO find(String hostname, int port, Long domainId);
|
||||
|
||||
LdapConfigurationVO find(String hostname, int port, Long domainId, boolean listAll);
|
||||
|
||||
Pair<List<LdapConfigurationVO>, Integer> searchConfigurations(String hostname, int port, Long domainId);
|
||||
|
||||
Pair<List<LdapConfigurationVO>, Integer> searchConfigurations(String hostname, int port, Long domainId, boolean listAll);
|
||||
}
|
||||
@ -46,6 +46,7 @@ public class LdapConfigurationDaoImpl extends GenericDaoBase<LdapConfigurationVO
|
||||
listGlobalConfigurationsSearch.and("port", listGlobalConfigurationsSearch.entity().getPort(), Op.EQ);
|
||||
listGlobalConfigurationsSearch.and("domain_id", listGlobalConfigurationsSearch.entity().getDomainId(),SearchCriteria.Op.NULL);
|
||||
listGlobalConfigurationsSearch.done();
|
||||
|
||||
listDomainConfigurationsSearch = createSearchBuilder();
|
||||
listDomainConfigurationsSearch.and("hostname", listDomainConfigurationsSearch.entity().getHostname(), Op.EQ);
|
||||
listDomainConfigurationsSearch.and("port", listDomainConfigurationsSearch.entity().getPort(), Op.EQ);
|
||||
@ -62,23 +63,38 @@ public class LdapConfigurationDaoImpl extends GenericDaoBase<LdapConfigurationVO
|
||||
|
||||
@Override
|
||||
public LdapConfigurationVO find(String hostname, int port, Long domainId) {
|
||||
SearchCriteria<LdapConfigurationVO> sc = getSearchCriteria(hostname, port, domainId);
|
||||
SearchCriteria<LdapConfigurationVO> sc = getSearchCriteria(hostname, port, domainId, false);
|
||||
return findOneBy(sc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public LdapConfigurationVO find(String hostname, int port, Long domainId, boolean listAll) {
|
||||
SearchCriteria<LdapConfigurationVO> sc = getSearchCriteria(hostname, port, domainId, listAll);
|
||||
return findOneBy(sc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Pair<List<LdapConfigurationVO>, Integer> searchConfigurations(final String hostname, final int port, final Long domainId) {
|
||||
SearchCriteria<LdapConfigurationVO> sc = getSearchCriteria(hostname, port, domainId);
|
||||
SearchCriteria<LdapConfigurationVO> sc = getSearchCriteria(hostname, port, domainId, false);
|
||||
return searchAndCount(sc, null);
|
||||
}
|
||||
|
||||
private SearchCriteria<LdapConfigurationVO> getSearchCriteria(String hostname, int port, Long domainId) {
|
||||
@Override
|
||||
public Pair<List<LdapConfigurationVO>, Integer> searchConfigurations(final String hostname, final int port, final Long domainId, final boolean listAll) {
|
||||
SearchCriteria<LdapConfigurationVO> sc = getSearchCriteria(hostname, port, domainId, listAll);
|
||||
return searchAndCount(sc, null);
|
||||
}
|
||||
|
||||
private SearchCriteria<LdapConfigurationVO> getSearchCriteria(String hostname, int port, Long domainId,boolean listAll) {
|
||||
SearchCriteria<LdapConfigurationVO> sc;
|
||||
if (domainId == null) {
|
||||
sc = listGlobalConfigurationsSearch.create();
|
||||
} else {
|
||||
if (domainId != null) {
|
||||
// If domainid is present, ignore listall
|
||||
sc = listDomainConfigurationsSearch.create();
|
||||
sc.setParameters("domain_id", domainId);
|
||||
} else if (listAll) {
|
||||
sc = listDomainConfigurationsSearch.create();
|
||||
} else {
|
||||
sc = listGlobalConfigurationsSearch.create();
|
||||
}
|
||||
if (hostname != null) {
|
||||
sc.setParameters("hostname", hostname);
|
||||
@ -88,4 +104,4 @@ public class LdapConfigurationDaoImpl extends GenericDaoBase<LdapConfigurationVO
|
||||
}
|
||||
return sc;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user