package org.ovirt.engine.core.bll.adbroker;

import java.util.List;

import org.ovirt.engine.core.common.businessentities.LdapGroup;
import org.ovirt.engine.core.dal.dbbroker.DbFacade;

public class LdapSearchGroupsByQueryCommand extends LdapWithConfiguredCredentialsCommandBase {

    protected LdapQueryData getLdapQueryData() {
        return ((LdapSearchByQueryParameters) getParameters()).getLdapQueryData();
    }

    public LdapSearchGroupsByQueryCommand(LdapSearchByQueryParameters parameters) {
        super(parameters);
    }

    @Override
    protected void executeQuery(DirectorySearcher directorySearcher) {
        java.util.ArrayList<LdapGroup> groupList = new java.util.ArrayList<LdapGroup>();

        List<GroupSearchResult> searchResults = (List<GroupSearchResult>)directorySearcher.FindAll(getLdapQueryData());
        {
            for (GroupSearchResult searchResult : searchResults) {
                String distinguishedName = searchResult.getDistinguishedName();
                List<String> memberOf = searchResult.getMemberOf();
                if (distinguishedName != null) {
                    String groupName = LdapBrokerUtils.generateGroupDisplayValue(searchResult.getDistinguishedName());
                    LdapGroup group = new LdapGroup(searchResult.getGuid(), groupName, getDomain(),distinguishedName,memberOf);
                    initGroupFromDb(group);
                    groupList.add(group);
                }
            }
        }
        setReturnValue(groupList);
        setSucceeded(true);
    }

    private void initGroupFromDb(LdapGroup group) {
        LdapGroup dbGroup = DbFacade.getInstance().getAdGroupDao().get(group.getid());
    }
}

@@ -129,60 +129,8 @@
 oup;
-%0Aimport org.ovirt.engine.core.dal.dbbroker.DbFacade;
 %0A%0Apu
@@ -1300,52 +1300,8 @@
 f);%0A
-                    initGroupFromDb(group);%0A
     
@@ -1452,153 +1452,7 @@
    %7D
-%0A%0A    private void initGroupFromDb(LdapGroup group) %7B%0A        LdapGroup dbGroup = DbFacade.getInstance().getAdGroupDao().get(group.getid());%0A    %7D
 %0A%7D%0A

Remove LdapSeachGroupsByQuery.initFromDb