package org.ovirt.engine.core.bll;

import org.ovirt.engine.core.common.businessentities.VM;
import org.ovirt.engine.core.common.queries.GetVdsByVdsIdParameters;
import org.ovirt.engine.core.common.queries.GetVmByVmIdParameters;
import org.ovirt.engine.core.common.queries.VdcQueryType;
import org.ovirt.engine.core.compat.Guid;
import org.ovirt.engine.core.compat.NGuid;

public class GetVdsCertificateSubjectByVmIdQuery <P extends GetVmByVmIdParameters> extends QueriesCommandBase<P> {
    public GetVdsCertificateSubjectByVmIdQuery(P parameters) {
        super(parameters);
    }

    @Override
    protected void executeQueryCommand() {
        Object returnValue = null;
        Guid vmId = getParameters().getId();
        if (vmId != null) {
            VM vm = getDbFacade().getVmDAO().get(vmId);
            if (vm != null) {
                NGuid vdsId = vm.getrun_on_vds();
                if (vdsId != null) {
                    returnValue = Backend.getInstance().runInternalQuery(VdcQueryType.GetVdsCertificateSubjectByVdsId, new GetVdsByVdsIdParameters(vdsId.getValue()));
                }
            }
        }
        getQueryReturnValue().setReturnValue(returnValue);
    }
}

@@ -214,32 +214,97 @@
 VmIdParameters;%0A
+import org.ovirt.engine.core.common.queries.VdcQueryReturnValue;%0A
 import org.ovirt
@@ -345,16 +345,16 @@
 ryType;%0A
-
 import o
@@ -712,14 +712,78 @@
     
-Object
+getQueryReturnValue().setSucceeded(false);%0A        VdcQueryReturnValue
  ret
@@ -1246,32 +1246,147 @@
     %7D%0A        %7D%0A
+        if (returnValue != null) %7B%0A            getQueryReturnValue().setSucceeded(returnValue.getSucceeded());%0A    
         getQuery
@@ -1425,18 +1425,45 @@
 urnValue
-);
+.getReturnValue());%0A        %7D
 %0A    %7D%0A%7D

fix GetVdsCertificateSubject query