package org.ovirt.engine.core.vdsbroker.irsbroker;

import java.util.ArrayList;

import org.ovirt.engine.core.common.errors.VDSError;
import org.ovirt.engine.core.common.errors.VdcBllErrors;
import org.ovirt.engine.core.common.vdscommands.GetImagesListVDSCommandParameters;
import org.ovirt.engine.core.compat.Guid;
import org.ovirt.engine.core.vdsbroker.vdsbroker.StatusForXmlRpc;

public class GetImagesListVDSCommand<P extends GetImagesListVDSCommandParameters>
        extends IrsBrokerCommand<P> {
    private ImagesListReturnForXmlRpc _result;

    public GetImagesListVDSCommand(P parameters) {
        super(parameters);
    }

    @Override
    protected void executeIrsBrokerCommand() {
        _result = getIrsProxy().getImagesList(getParameters().getStorageDomainId().toString());
        proceedProxyReturnValue();
        ArrayList<Guid> tempRetValue = new ArrayList<Guid>(_result.getImageList().length);
        for (String id : _result.getImageList()) {
            tempRetValue.add(new Guid(id));
        }
        setReturnValue(tempRetValue);
    }

    @Override
    protected StatusForXmlRpc getReturnStatus() {
        return _result.mStatus;
    }

    @Override
    protected Object getReturnValueFromBroker() {
        return _result;
    }

    @Override
    protected void proceedProxyReturnValue() {
        VdcBllErrors returnStatus = GetReturnValueFromStatus(getReturnStatus());
        switch (returnStatus) {
        case GetStorageDomainListError:
            getVDSReturnValue().setVdsError(new VDSError(returnStatus, getReturnStatus().mMessage));
            getVDSReturnValue().setSucceeded(false);
            break;
        default:
            super.proceedProxyReturnValue();
            break;
        }
    }
}

@@ -78,118 +78,8 @@
 t;%0A%0A
-import org.ovirt.engine.core.common.errors.VDSError;%0Aimport org.ovirt.engine.core.common.errors.VdcBllErrors;%0A
 impo
@@ -424,17 +424,16 @@
 rXmlRpc 
-_
 result;%0A
@@ -587,17 +587,16 @@
         
-_
 result =
@@ -768,17 +768,16 @@
 t%3CGuid%3E(
-_
 result.g
@@ -824,17 +824,16 @@
 ng id : 
-_
 result.g
@@ -1023,25 +1023,24 @@
      return 
-_
 result.mStat
@@ -1133,9 +1133,8 @@
 urn 
-_
 resu
@@ -1146,492 +1146,7 @@
    %7D
-%0A%0A    @Override%0A    protected void proceedProxyReturnValue() %7B%0A        VdcBllErrors returnStatus = GetReturnValueFromStatus(getReturnStatus());%0A        switch (returnStatus) %7B%0A        case GetStorageDomainListError:%0A            getVDSReturnValue().setVdsError(new VDSError(returnStatus, getReturnStatus().mMessage));%0A            getVDSReturnValue().setSucceeded(false);%0A            break;%0A        default:%0A            super.proceedProxyReturnValue();%0A            break;%0A        %7D%0A    %7D
 %0A%7D%0A

remove handling GetStorageDomainListError after getImagesList