auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
protected void executeCommand() { START VmTemplateHandler.lockVmTemplateInTransaction(diskImage.getit_guid(), getCompensationContext()); END TransactionSupport.executeInNewTransaction(new TransactionMethod<Void>() { @Override public Void runInTransaction() { VdcReturnValueBase retVal = Backend.getInstance().runInternalAction(VdcActionType .MoveOrCopyImageGroup, createMoveorCopyImageGroupParams()); handleResult(retVal); updateDatabase(); return null; } }); VmTemplateHandler.UnLockVmTemplate(diskImage.getit_guid()); } You don't need a transaction here

Target:
protected void executeCommand() { VmTemplateHandler.lockVmTemplateInTransaction(diskImage.getit_guid(), getCompensationContext()); VdcReturnValueBase retVal = Backend.getInstance().runInternalAction(VdcActionType.MoveOrCopyImageGroup, createMoveorCopyImageGroupParams()); handleResult(retVal); VmTemplateHandler.UnLockVmTemplate(diskImage.getit_guid()); }
Source:
protected void EndWithFailure() { // we are setting 'Vm' since VmId is overriden and 'Vm' is null // (since 'Vm' is dependant on 'mVmId', which is not set here). setVm(DbFacade.getInstance().getVmDAO().getById(getVmId())); // next line is for retrieving the VmPool (and Vm, implicitly) from // the DB so we won't get a log-deadlock because of the transaction. vm_pools vmPool = getVmPool(); START END setSucceeded(Backend.getInstance().endAction(VdcActionType.RunVm, getParameters().getImagesParameters().get(0), getCompensationContext()).getSucceeded()); if (!getSucceeded()) { log.warn("AttachUserToVmFromPoolAndRunCommand::EndWitFailure: EndAction of RunVm Failed"); } detachUserFromVmFromPool(); } why endAction of RunVm will not be called automatically ?

Target:
protected void EndWithFailure() { setSucceeded(Backend.getInstance().endAction(VdcActionType.RunVm, getParameters().getImagesParameters().get(0), getCompensationContext()).getSucceeded()); if (!getSucceeded()) { log.warn("AttachUserToVmFromPoolAndRunCommand::EndWitFailure: EndAction of RunVm Failed"); } detachUserFromVmFromPool(); }
Source:
protected static boolean CanAttachNonPrestartedVmToUser(Guid vm_guid) { START java.util.ArrayList<String> messages = new java.util.ArrayList<String>(); END return IsVmFree(vm_guid, messages); } During rebase, just pass a new ArrayList() to IsVmfree no need for variable

Target:
protected static boolean CanAttachNonPrestartedVmToUser(Guid vm_guid) { return IsVmFree(vm_guid, new java.util.ArrayList<String>()); }
Source:
public void testGetAllForTemplateWithPermissionsForUnprivilegedUser() { List<VmNetworkInterface> result = dao.getAllForTemplate(TEMPLATE_ID, UNPRIVILEGED_USER_ID, true); assertNotNull(result); START assertTrue(result.size() == 0); END } Why not check isEmpty()?

Target:
public void testGetAllForTemplateWithPermissionsForUnprivilegedUser() { List<VmNetworkInterface> result = dao.getAllForTemplate(TEMPLATE_ID, UNPRIVILEGED_USER_ID, true); assertNotNull(result); assertTrue(result.isEmpty()); }
Source:
private ReportInit() { START AsyncDataProvider.GetRedirectServletReportsPage(new AsyncQuery(this, END new INewAsyncCallback() { @Override public void OnSuccess(Object target, Object returnValue) { setReportBaseUrl((String) returnValue); } })); } please move this tot he init() method

Target:
private ReportInit() { }
Source:
protected boolean canDoAction() { START return (!QuotaHelper.getInstance().checkQuotaValidationForAddEdit(getParameters().getQuota(), END getReturnValue().getCanDoActionMessages())); } why you return not of the check? IIRC it will return true if quota is valid, and then you should return true for the CDA

Target:
protected boolean canDoAction() { return (QuotaHelper.getInstance().checkQuotaValidationForAddEdit(getParameters().getQuota(), getReturnValue().getCanDoActionMessages())); }
Source:
public AddQuotaCommand(T parameters) { super(parameters); START setStoragePoolId(parameters.getStoragePoolId()); END } the storage pool should be set from the quota object, i don't see a reason to send it separately, apply also for update and remove

Target:
public AddQuotaCommand(T parameters) { super(parameters); }
Source:
protected boolean canDoAction() { START if (getParameters() == null) { END return false; } else if (!QuotaHelper.getInstance().checkQuotaValidationForAddEdit(getParameters().getQuota(), getReturnValue().getCanDoActionMessages())) { return false; } return true; } i think this check is not needed, don't think the factory will create the command with null params, and if you decide to keep this check, you have to add error message.

Target:
protected boolean canDoAction() { return (!QuotaHelper.getInstance().checkQuotaValidationForAddEdit(getParameters().getQuota(), getReturnValue().getCanDoActionMessages())); }
Source:
public GetVmConfigurationBySnapshotQueryParams(Guid snapshotSourceId) { START super(); END this.snapshotSourceId = snapshotSourceId; } ain't the super call redundant ?

Target:
public GetVmConfigurationBySnapshotQueryParams(Guid snapshotSourceId) { this.snapshotSourceId = snapshotSourceId; }
Source:
protected void executeQueryCommand() { String configuration = getConfigurationFromDb(getParameters().getSnapshotSourceId()); VM result = new VM(); if (configuration != null) { START new SnapshotsManager().updateVmFromConfiguration(result,configuration); END } getQueryReturnValue().setReturnValue(result); } looking at SnapshotsManager seems quite stateless, so perhaps worth "singletonize" it

Target:
protected void executeQueryCommand() { String configuration = getConfigurationFromDb(getParameters().getSnapshotSourceId()); VM result = null; if (configuration != null) { result = new VM(); new SnapshotsManager().updateVmFromConfiguration(result,configuration); } getQueryReturnValue().setReturnValue(result); }
Source:
private GetVmConfigurationBySnapshotQuery<GetVmConfigurationBySnapshotQueryParams> setupQueryBySnapshotId(Guid snapshotId) { GetVmConfigurationBySnapshotQueryParams queryParams = getQueryParameters(); when(queryParams.getSnapshotId()).thenReturn(snapshotId); GetVmConfigurationBySnapshotQuery<GetVmConfigurationBySnapshotQueryParams> executeQuery = getQuery(); START return executeQuery; END } Why call executeQuery?

Target:
private GetVmConfigurationBySnapshotQuery<GetVmConfigurationBySnapshotQueryParams> setupQueryBySnapshotId(Guid snapshotId) { GetVmConfigurationBySnapshotQueryParams queryParams = getQueryParameters(); when(queryParams.getSnapshotId()).thenReturn(snapshotId); GetVmConfigurationBySnapshotQuery<GetVmConfigurationBySnapshotQueryParams> query = getQuery(); return query; }
Source:
START protected void removeVmRelatedEntitiesFromDb() { END RemoveVmUsers(); RemoveVmNetwork(); new SnapshotsManager().removeSnapshots(getVmId()); // It is the responsibility of this command to erase the images , as it is also creates them removeVmImages(); RemoveVmStatic(); } Why copy & paste instead of calling super.remove in the end (after images remove)?

Target:
protected void removeVmRelatedEntitiesFromDb() { removeVmImages(); super.removeVmRelatedEntitiesFromDb(); }
Source:
START public void setVmId(Guid value) { END privateVmId = value; } Why did you change to public?

Target:
private void setVmId(Guid value) { privateVmId = value; }
Source:
protected VdcReturnValueBase checkAndPerformRollbackUsingCommand(VdcActionType commandType, VdcActionParametersBase params, CommandContext context) { START VdcReturnValueBase result = new VdcReturnValueBase(); END if (canPerformRollbackUsingCommand(commandType, params)) { result = runInternalCommandOnRollback(commandType, params, context); } else { result.setSucceeded(false); } return result; } No need to instantiate a variable when a line under you might override it. Move the instantiate to the 'else' clause.

Target:
protected VdcReturnValueBase checkAndPerformRollbackUsingCommand(VdcActionType commandType, VdcActionParametersBase params, CommandContext context) { VdcReturnValueBase result = null; if (canPerformRollbackUsingCommand(commandType, params)) { result = runInternalCommandOnRollback(commandType, params, context); } else { result = new VdcReturnValueBase(); result.setSucceeded(false); } return result; }
Source:
protected VdcReturnValueBase attemptRollback(VdcActionType commandType, VdcActionParametersBase params, START CommandContext context) { END if (canPerformRollbackUsingCommand(commandType, params)) { params.setExecutionReason(CommandExecutionReason.ROLLBACK_FLOW); return Backend.getInstance().runInternalAction(commandType, params); } return new VdcReturnValueBase(); } Shouldn't you do something with the context?

Target:
protected VdcReturnValueBase attemptRollback(VdcActionType commandType, VdcActionParametersBase params, CommandContext context) { if (canPerformRollbackUsingCommand(commandType, params)) { params.setExecutionReason(CommandExecutionReason.ROLLBACK_FLOW); return Backend.getInstance().runInternalAction(commandType, params, context); } return new VdcReturnValueBase(); }
Source:
public static ServicePolicyInterface getServicePolicyForVds(VDS vds) { ServicePolicyInterface retVal = null; Guid vdsGroupId = vds.getvds_group_id(); VDSGroup vdsGroup = vdsGroupDao.get(vdsGroupId); START END if (vdsGroup != null) { // In here we will test if the cluster is a gluster cluster, or a virt one, and create the policy accordingly retVal = virtServicePolicy; } return retVal; } I don't think a Cluster can be removed while the Host is during monitor, therefore the cluster should be not Null.

Target:
public static ServicePolicyInterface getServicePolicyForVds(VDS vds) { Guid vdsGroupId = vds.getvds_group_id(); VDSGroup vdsGroup = vdsGroupDao.get(vdsGroupId); // In here we will test if the cluster is a gluster cluster, or a virt one, and return the policy accordingly // In the meantime we return the virt one return virtServicePolicy; }
Source:
public String getSpecParams() { START this.specParams = VmDeviceCommonUtils.appendDeviceIdToSpecParams(this.getId().getDeviceId(), this.specParams); END return this.specParams; } "this." is redundant here .

Target:
public String getSpecParams() { specParams = VmDeviceCommonUtils.appendDeviceIdToSpecParams(this.getId().getDeviceId(), specParams); return this.specParams; }
Source:
private VmInfoBuilderBase createBuilder() { START if (VmDeviceCommonUtils.isOldClusterVersion(vm.getvds_group_compatibility_version())) END // backward compatibility for 3.0 return new VmOldInfoBuilder(vm, createInfo); else return new VmInfoBuilder(vm, createInfo); } please wrap the if-else block with brackets {}.

Target:
private VmInfoBuilderBase createBuilder() { if (VmDeviceCommonUtils.isOldClusterVersion(vm.getvds_group_compatibility_version())) { // backward compatibility for 3.0 return new VmOldInfoBuilder(vm, createInfo); } else { return new VmInfoBuilder(vm, createInfo); } }
Source:
START private XmlRpcStruct[] getVmInfo(List<String> vmsToUpdate) { END return (XmlRpcStruct[]) (new FullListVdsCommand<VdsIdAndVdsVDSCommandParametersBase>( new FullListVDSCommandParameters(_vds.getId(), vmsToUpdate)).ExecuteWithReturnValue()); } you should wrap this call, since a specific failure will cause all of the refresh to fail.

Target:
private XmlRpcStruct[] getVmInfo(List<String> vmsToUpdate) { return (XmlRpcStruct[]) (new FullListVdsCommand<FullListVDSCommandParameters>( new FullListVDSCommandParameters(_vds.getId(), vmsToUpdate)).ExecuteWithReturnValue()); }
Source:
public VM(VmStatic vmStatic, VmDynamic vmDynamic, VmStatistics vmStatistics) { mDiskMap = new java.util.HashMap<String, DiskImage>(); mCdPath = ""; mFloppyPath = ""; mRunAndPause = false; _diskSize = 0; mVmStatic = vmStatic; mVmDynamic = vmDynamic; mVmStatistics = vmStatistics; if (mVmStatic != null) { START mVmStatic.setImages(new java.util.ArrayList<DiskImage>()); END mVmStatic.setInterfaces(new java.util.ArrayList<VmNetworkInterface>()); } } please omit the java.util. prefix. The ArrayList is already imported (from both lines)

Target:
public VM(VmStatic vmStatic, VmDynamic vmDynamic, VmStatistics vmStatistics) { mDiskMap = new java.util.HashMap<String, DiskImage>(); mCdPath = ""; mFloppyPath = ""; mRunAndPause = false; _diskSize = 0; mVmStatic = vmStatic; mVmDynamic = vmDynamic; mVmStatistics = vmStatistics; if (mVmStatic != null) { mVmStatic.setImages(new ArrayList<DiskImage>()); mVmStatic.setInterfaces(new ArrayList<VmNetworkInterface>()); } }
Source:
protected void executeCommand() { START updateDefaultQuota(); END getStoragePoolDAO().updatePartial(getStoragePool()); if (getStoragePool().getstatus() == StoragePoolStatus.Up) { if (!StringHelper.EqOp(_oldStoragePool.getname(), getStoragePool().getname())) { runVdsCommand(VDSCommandType.SetStoragePoolDescription, new SetStoragePoolDescriptionVDSCommandParameters(getStoragePool().getId(), getStoragePool().getname())); } } updateStoragePoolFormatType(); setSucceeded(true); } Perform update only at case of vdsm call successes, also use only one time updatePartia() . Also change updatePartial() , can also update storage pool format type

Target:
protected void executeCommand() { updateDefaultQuota(); if (_oldStoragePool.getstatus() == StoragePoolStatus.Up) { if (!StringHelper.EqOp(_oldStoragePool.getname(), getStoragePool().getname())) { runVdsCommand(VDSCommandType.SetStoragePoolDescription, new SetStoragePoolDescriptionVDSCommandParameters( getStoragePool().getId(), getStoragePool().getname()) ); getStoragePoolDAO().updatePartial(getStoragePool()); } } updateStoragePoolFormatType(); setSucceeded(true); }
Source:
protected boolean isOsSupported(VM vm) { START String[] oses = Config.<String> GetValue(ConfigValues.HotPlugSupportedOsList).split(","); END for (String os : oses) { if (os.equalsIgnoreCase(vm.getguest_os())) { return true; } } addCanDoActionMessage(VdcBllMessages.ACTION_TYPE_FAILED_GUEST_OS_VERSION_IS_NOT_SUPPORTED); return false; } why not to have it static ? the list is not expected to change during run, so no need to parse it for each command.

Target:
protected boolean isOsSupported(VM vm) { for (String os : oses) { if (os.equalsIgnoreCase(vm.getguest_os())) { return true; } } addCanDoActionMessage(VdcBllMessages.ACTION_TYPE_FAILED_GUEST_OS_VERSION_IS_NOT_SUPPORTED); return false; }
Source:
public boolean canMoveToMaintenance(VDS vds) { // In this case, if all the services can move the VDS to maintenance then we return true boolean retVal = true; for ( MonitoringStrategy monitoringStrategy : strategies ) { retVal = retVal && monitoringStrategy.canMoveToMaintenance(vds); START if (retVal) { END break; } } return retVal; } shouldn't braek if retVal is false? actually (and this is just my opinion) i think it would be easier to understand if you return false once one is false: for ( MonitoringStrategy monitoringStrategy : strategies ) { if (!monitoringStrategy.canMoveToMaintenance(vds)) return false; } return true;

Target:
public boolean canMoveToMaintenance(VDS vds) { // In this case, if all the services can move the VDS to maintenance then we return true for ( MonitoringStrategy monitoringStrategy : strategies ) { if (!monitoringStrategy.canMoveToMaintenance(vds)) { return false; } } return true; }
Source:
START public boolean isMonitoringNeeded(VDS vds) { END // In this case, if one of the services needs monitoring then we return true boolean retVal = false; for ( MonitoringStrategy monitoringStrategy : strategies ) { retVal = retVal || monitoringStrategy.isMonitoringNeeded(vds); if (retVal) { break; } } return retVal; } same opinion here :) (though break logic here seems correct)

Target:
public boolean isMonitoringNeeded(VDS vds) { // In this case, if one of the services needs monitoring then we return true for ( MonitoringStrategy monitoringStrategy : strategies ) { if (monitoringStrategy.isMonitoringNeeded(vds)) { return true; } } return false; }
Source:
START protected DiskImage createImage() { END final DiskImage diskImage = new DiskImage(); diskImage.setimage_group_id(Guid.NewGuid()); diskImage.setstorage_ids(new ArrayList<Guid>(Arrays.asList(new Guid()))); return diskImage; } minor: This can be private method

Target:
private DiskImage createImage() { final DiskImage diskImage = new DiskImage(); diskImage.setimage_group_id(Guid.NewGuid()); diskImage.setstorage_ids(new ArrayList<Guid>(Arrays.asList(new Guid()))); return diskImage; }
Source:
START protected VmDevice createDiskVmDevice(final DiskImage diskImage) { END final VmDevice vmDevice = new VmDevice(); vmDevice.setIsPlugged(true); vmDevice.setId(new VmDeviceId(diskImage.getimage_group_id(), Guid.NewGuid())); return vmDevice; } minor: This can be private method

Target:
private VmDevice createDiskVmDevice(final DiskImage diskImage) { final VmDevice vmDevice = new VmDevice(); vmDevice.setIsPlugged(true); vmDevice.setId(new VmDeviceId(diskImage.getimage_group_id(), Guid.NewGuid())); return vmDevice; }
Source:
private boolean checkVmIsDown() { return Config.<Boolean> GetValue( START ConfigValues.LiveSnapshotEnabled, getStoragePool().getcompatibility_version().getValue()); END } shouldnt it return !(getConfig)?

Target:
private boolean checkVmIsDown() { return !Config.<Boolean> GetValue( ConfigValues.LiveSnapshotEnabled, getStoragePool().getcompatibility_version().getValue()); }
Source:
public List<PermissionSubject> getPermissionCheckSubjects() { if (disk != null) { if (disk.getVmEntityType() == VmEntityType.VM) { START return Collections.singletonList(new PermissionSubject(getParameters().getStorageDomainId(), END VdcObjectType.Storage, ActionGroup.CONFIGURE_VM_STORAGE)); } if (disk.getVmEntityType() == VmEntityType.TEMPLATE) { return Collections.singletonList(new PermissionSubject(disk.getvm_guid(), VdcObjectType.VmTemplate, ActionGroup.DELETE_TEMPLATE)); } } return null; } permission should be on vm and not storage

Target:
public List<PermissionSubject> getPermissionCheckSubjects() { if (disk != null) { if (disk.getVmEntityType() == VmEntityType.VM) { return Collections.singletonList(new PermissionSubject(disk.getvm_guid(), VdcObjectType.VM, ActionGroup.CONFIGURE_VM_STORAGE)); } if (disk.getVmEntityType() == VmEntityType.TEMPLATE) { return Collections.singletonList(new PermissionSubject(disk.getvm_guid(), VdcObjectType.VmTemplate, ActionGroup.DELETE_TEMPLATE)); } } return null; }
Source:
protected void executeQueryCommand() { String suggestedDiskName = null; if (getParameters().getVmId() == null) { getQueryReturnValue().setReturnValue(suggestedDiskName); } else { START VM vm = DbFacade.getInstance().getVmDAO().getById(getParameters().getVmId()); END suggestedDiskName = ImagesHandler.getDefaultDiskAlias(vm.getvm_name(), VmHandler.getCorrectDriveForDisk(vm)); } getQueryReturnValue().setReturnValue(suggestedDiskName); } you need to check that vm != null as well.

Target:
protected void executeQueryCommand() { String suggestedDiskName = null; if (getParameters().getVmId() == null) { getQueryReturnValue().setReturnValue(suggestedDiskName); } else { VM vm = DbFacade.getInstance().getVmDAO().getById(getParameters().getVmId()); if (vm != null) { suggestedDiskName = ImagesHandler.getDefaultDiskAlias(vm.getvm_name(), VmHandler.getCorrectDriveForDisk(vm)); } getQueryReturnValue().setReturnValue(suggestedDiskName); } }
Source:
protected boolean canDoAction() { START if (getGlusterVolume().isOnline()) { END addCanDoActionMessage(VdcBllMessages.ACTION_TYPE_FAILED_GLUSTER_VOLUME_ALREADY_STARTED); return false; } return super.canDoAction(); } maybe add a check that getGlusterVolume exists (not null)

Target:
protected boolean canDoAction() { if(! super.canDoAction()) { return false; } if (getGlusterVolume().isOnline()) { addCanDoActionMessage(VdcBllMessages.ACTION_TYPE_FAILED_GLUSTER_VOLUME_ALREADY_STARTED); return false; } return true; }
Source:
public StatusOnlyReturnForXmlRpc glusterVolumeStart(String volumeName, Boolean force) { try { START return new StatusOnlyReturnForXmlRpc(vdsServer.glusterVolumeStart(volumeName, force.toString())); END } catch (UndeclaredThrowableException ute) { throw new XmlRpcRunTimeException(ute); } } I think the "force" variable should be passed to the vdsServer method as it is, instead of converting to string.

Target:
public StatusOnlyReturnForXmlRpc glusterVolumeStart(String volumeName, Boolean force) { try { return new StatusOnlyReturnForXmlRpc(vdsServer.glusterVolumeStart(volumeName, force)); } catch (UndeclaredThrowableException ute) { throw new XmlRpcRunTimeException(ute); } }
Source:
public StopGlusterVolumeCommand(GlusterVolumeActionParameters params) { super(params); START setGlusterVolumeId(getParameters().getVolumeId()); END } i think that the gluster volume id is already set in the super constructor.

Target:
public StopGlusterVolumeCommand(GlusterVolumeActionParameters params) { super(params); }
Source:
public void testRemove() { assertEquals(dao.remove(existingAsyncTask.gettask_id()), 1); async_tasks result = dao.get(existingAsyncTask.gettask_id()); assertNull(result); START END assertEquals(dao.remove(existingAsyncTask.gettask_id()), 0); } consider testing with get()!=null too, so your test isn't completely dependent on remove()

Target:
public void testRemove() { async_tasks result = dao.get(existingAsyncTask.gettask_id()); assertNotNull(result); assertEquals(dao.remove(existingAsyncTask.gettask_id()), 1); result = dao.get(existingAsyncTask.gettask_id()); assertNull(result); assertEquals(dao.remove(existingAsyncTask.gettask_id()), 0); }
Source:
START public static Guid getGuidValue(NGuid id) { END if (id == null) { return null; } return id.getValue(); } you could do this in a single line

Target:
public static Guid getGuidValue(NGuid id) { return id == null ? null : id.getValue(); }
Source:
public List<PermissionSubject> getPermissionCheckSubjects() { if (listPermissionSubjects == null) { START listPermissionSubjects = super.getPermissionCheckSubjects(); END Guid diskId = _oldDisk == null ? null : _oldDisk.getimage_group_id(); listPermissionSubjects.add(new PermissionSubject(diskId, VdcObjectType.Disk, ActionGroup.EDIT_DISK_PROPERTIES)); listPermissionSubjects = QuotaHelper.getInstance().addQuotaPermissionSubject(listPermissionSubjects, getStoragePool(), getQuotaId()); } return listPermissionSubjects; } should require permission on disk only, calling super will add requirement for vm as well

Target:
public List<PermissionSubject> getPermissionCheckSubjects() { if (listPermissionSubjects == null) { listPermissionSubjects = new ArrayList<PermissionSubject>(); Guid diskId = _oldDisk == null ? null : _oldDisk.getimage_group_id(); listPermissionSubjects.add(new PermissionSubject(diskId, VdcObjectType.Disk, ActionGroup.EDIT_DISK_PROPERTIES)); listPermissionSubjects = QuotaHelper.getInstance().addQuotaPermissionSubject(listPermissionSubjects, getStoragePool(), getQuotaId()); } return listPermissionSubjects; }
Source:
private Quota generateQuotaForNewStoragePool() { START boolean isDefaultQuota = (getStoragePool().getQuotaEnforcementType() == QuotaEnforcementTypeEnum.DISABLED); END Quota defaultStoragePoolQuota = getQuotaHelper().getUnlimitedQuota(getStoragePool(), isDefaultQuota); return defaultStoragePoolQuota; } I think this boolean should be removed now, We should add a default quota every time we create a DC, and keep its flag all the time until someone edit it. So the creation of the quota should be all the time with defaultQuota = true

Target:
private Quota generateQuotaForNewStoragePool() { return getQuotaHelper().getUnlimitedQuota(getStoragePool(), true); }
Source:
protected VMs mapCollection(List<org.ovirt.engine.core.common.businessentities.VM> entities) { VMs collection = new VMs(); for (org.ovirt.engine.core.common.businessentities.VM entity : entities) { VM vm = map(entity); collection.getVMs().add(addLinks(populate(vm, entity))); START setPayload(vm); END } return collection; } Better to put the call 'setPayload(vm)' inside the method populate(). That's what this method is for - it adds any information you want to the collection objects after they have been mapped.

Target:
protected VMs mapCollection(List<org.ovirt.engine.core.common.businessentities.VM> entities) { VMs collection = new VMs(); for (org.ovirt.engine.core.common.businessentities.VM entity : entities) { VM vm = map(entity); collection.getVMs().add(addLinks(populate(vm, entity))); } return collection; }
Source:
public static ArrayList<Guid> getStorageIdList(String storageIds) { ArrayList<String> storageStringList = splitStringList(storageIds); START ArrayList<Guid> storageGuidsList = new ArrayList<Guid>(); END if (!(storageStringList == null || storageStringList.isEmpty())) { for (String storageGuidString : storageStringList) { storageGuidsList.add(Guid.createGuidFromString(storageGuidString)); } } // If list is empty return empty guid. if (storageGuidsList.isEmpty()) { storageGuidsList.add(Guid.Empty); } return storageGuidsList; } no need check for storageStringList.isEmpty()

Target:
public static ArrayList<Guid> getStorageIdList(String storageIds) { ArrayList<String> storageStringList = splitStringList(storageIds); ArrayList<Guid> storageGuidsList = new ArrayList<Guid>(); if (storageStringList != null) { for (String storageGuidString : storageStringList) { storageGuidsList.add(Guid.createGuidFromString(storageGuidString)); } } // If list is empty return empty guid. if (storageGuidsList.isEmpty()) { storageGuidsList.add(Guid.Empty); } return storageGuidsList; }
Source:
START public Guid getId() { END return clusterId; } Should'nt the getter name be getClusteId if the field name is clusterId?

Target:
public Guid getId() { return id; }
Source:
public String toString() { return String.format("%s, ticket=%s, validTime=%s,m userName=%s, userId=%s", super.toString(), getTicket(), getValidTime(), START getUserName(), getUserId().toString()); END } no need to explicit call toString on getUserId() here, this way its null safe

Target:
public String toString() { return String.format("%s, ticket=%s, validTime=%s,m userName=%s, userId=%s", super.toString(), getTicket(), getValidTime(), getUserName(), getUserId()); }
Source:
public List<PermissionSubject> getPermissionCheckSubjects() { List<PermissionSubject> permissionList = super.getPermissionCheckSubjects(); START if (getParameters().getInterface().isPromisc()) { END permissionList.add(new PermissionSubject(getVm().getstorage_pool_id(), VdcObjectType.StoragePool, ActionGroup.PROMISC)); } return permissionList; } same answer

Target:
public List<PermissionSubject> getPermissionCheckSubjects() { List<PermissionSubject> permissionList = super.getPermissionCheckSubjects(); if (getParameters().getInterface() != null && getVm() != null && getParameters().getInterface().isPromisc()) { permissionList.add(new PermissionSubject(getVm().getstorage_pool_id(), VdcObjectType.StoragePool, ActionGroup.PROMISC)); } return permissionList; }
Source:
private static void assertCorrectSnapshots(DiskImage disk) { for (int i = 0; i < NUM_DISKS_OF_EACH_KIND; ++i) { START assertEquals("Wrong snapshot " + i + " for disk ", disk.getId(), disk.getSnapshots().get(i).getImageId()); END } } You compare disk id to image id, which is not the same thing.

Target:
private static void assertCorrectSnapshots(DiskImage disk) { for (int i = 0; i < NUM_DISKS_OF_EACH_KIND; ++i) { assertEquals("Wrong snapshot " + i + " for disk ", disk.getId(), disk.getSnapshots().get(i).getId()); } }
Source:
protected boolean matchEntity(DiskImage entity, Guid id) { START return id != null && (id.equals(entity.getId()) || id.equals(entity.getImageId()) || id.equals(entity.getvm_snapshot_id())); END } Now that the disk identifier is it's ID, I think it's better not to compare to imageId anymore

Target:
protected boolean matchEntity(DiskImage entity, Guid id) { return id != null && (id.equals(entity.getId()) || id.equals(entity.getvm_snapshot_id())); }
Source:
public boolean getTaskGroupSuccess() { boolean childrenTasksSuccess = taskGroupSuccess; for (VdcActionParametersBase childParameters : getImagesParameters()) { START childrenTasksSuccess &= childParameters.getTaskGroupSuccess(); END } return childrenTasksSuccess; } you can break this loop once reached a failed childParameters.getTaskGroupSuccess()

Target:
public boolean getTaskGroupSuccess() { boolean childrenTasksSuccess = taskGroupSuccess; for (VdcActionParametersBase childParameters : getImagesParameters()) { childrenTasksSuccess &= childParameters.getTaskGroupSuccess(); if (!childrenTasksSuccess) { break; } } return childrenTasksSuccess; }
Source:
private static void updateOption(VdcOption option) { Map<String, Object> values = _vdcOptionCache.get(option.getoption_name()); START if (values != null) { END values.put(option.getversion(), GetValue(option)); } else { values = new HashMap<String, Object>(); values.put(option.getversion(), GetValue(option)); _vdcOptionCache.put(option.getoption_name(), values); } } I would consider rewriting as: if (values == null) { values = new HashMap<String, Object>(); _vdcOptionCache.put(option.getoption_name(), values); } values.put(option.getversion(), GetValue(option));

Target:
private static void updateOption(VdcOption option) { Map<String, Object> values = _vdcOptionCache.get(option.getoption_name()); if (values == null) { values = new HashMap<String, Object>(); _vdcOptionCache.put(option.getoption_name(), values); } values.put(option.getversion(), GetValue(option)); }
Source:
START private static boolean isReloadable(String optionName) throws SecurityException, NoSuchFieldException { END return ConfigValues.class.getField(optionName).isAnnotationPresent(Reloadable.class); } Why specify SecurityException? It is unchekced..

Target:
private static boolean isReloadable(String optionName) throws NoSuchFieldException { return ConfigValues.class.getField(optionName).isAnnotationPresent(Reloadable.class); }
Source:
protected VDSGroup lookupClusterById(String id) { GetVdsGroupByIdParameters params = new GetVdsGroupByIdParameters(Guid.createGuidFromString(id)); START params.setFiltered(SessionUtils.isFiltered()); END return getEntity(VDSGroup.class, VdcQueryType.GetVdsGroupById, params, id); } why this is not in getEntity()? it would solve this in generic way...

Target:
protected VDSGroup lookupClusterById(String id) { return getEntity(VDSGroup.class, VdcQueryType.GetVdsGroupById, new GetVdsGroupByIdParameters(Guid.createGuidFromString(id)), id); }
Source:
public Roles list() { MultilevelAdministrationByAdElementIdParameters params = new MultilevelAdministrationByAdElementIdParameters(principalId); START params.setFiltered(SessionUtils.isFiltered()); END return mapCollection(getBackendCollection(VdcQueryType.GetPermissionsByAdElementId, params)); } why this is not in getBackendCollection()? it would solve this in generic way...

Target:
public Roles list() { return mapCollection(getBackendCollection(VdcQueryType.GetPermissionsByAdElementId, new MultilevelAdministrationByAdElementIdParameters(principalId))); }
Source:
public DataCenter get() { StoragePoolQueryParametersBase params = new StoragePoolQueryParametersBase(guid); START params.setFiltered(SessionUtils.isFiltered()); END return performGet(VdcQueryType.GetStoragePoolById, params); } why this is not in performGet()? it would solve this in generic way...

Target:
public DataCenter get() { return performGet(VdcQueryType.GetStoragePoolById, new StoragePoolQueryParametersBase(guid)); }
Source:
START public void setOnlyReloadable(String parseOptionKey) { END if (Boolean.parseBoolean(parseOptionKey)) { onlyReloadable = true; } else { onlyReloadable = false; } } just a matter of taste, maybe you tought about it already: onlyReloadable = Boolean.parseBoolean(parseOptionKey));

Target:
public void setOnlyReloadable(String parseOptionKey) { onlyReloadable = Boolean.parseBoolean(parseOptionKey); }
Source:
public void removeBrick(Guid brickId) { getCallsHandler().executeModification("DeleteGlusterVolumeBrick", START getCustomMapSqlParameterSource().addValue("id", brickId.getUuid())); END } why its needed to cal getUuid() on guids? i don't remember we need/use it

Target:
public void removeBrick(Guid brickId) { getCallsHandler().executeModification("DeleteGlusterVolumeBrick", getCustomMapSqlParameterSource().addValue("id", brickId)); }
Source:
private boolean correctStorageDomainFormat() { final Set<StorageFormatType> supportedStorageFormats = getSupportedStorageFormatSet(getVds().getvds_group_compatibility_version()); final StorageFormatType storageFormat = getStorageDomain().getStorageFormat(); START final StorageType storageType = getStorageDomain().getstorage_type(); END if (!supportedStorageFormats.contains(storageFormat)) { return false; } if ((storageFormat == StorageFormatType.V2) && (storageType != StorageType.ISCSI) && (storageType != StorageType.FCP)) { return false; } return true; } storageType can be initialized inside the if command since it is only used for storage type V2

Target:
private boolean correctStorageDomainFormat() { final Set<StorageFormatType> supportedStorageFormats = getSupportedStorageFormatSet(getVds().getvds_group_compatibility_version()); final StorageFormatType storageFormat = getStorageDomain().getStorageFormat(); if (!supportedStorageFormats.contains(storageFormat)) { return false; } if (storageFormat == StorageFormatType.V2) { final StorageType storageType = getStorageDomain().getstorage_type(); if (storageType != StorageType.ISCSI && storageType != StorageType.FCP) { return false } } return true; }
Source:
protected boolean isVersionSupportedForShareable() { return Config.<Boolean> GetValue(ConfigValues.ShareableDiskEnabled, START getStoragePool().getcompatibility_version().getValue()); END } no way for storage pool to be null? (LUN disk, floating..)

Target:
protected boolean isVersionSupportedForShareable() { return getStoragePool() != null ?Config.<Boolean> GetValue(ConfigValues.ShareableDiskEnabled, getStoragePool().getcompatibility_version().getValue()) : true; }
Source:
public AbstractDiskVmCommand(T parameters) { super(parameters); if (parameters.getDiskInfo() != null && DiskStorageType.IMAGE == parameters.getDiskInfo().getDiskStorageType()) { setQuotaId(((DiskImage) parameters.getDiskInfo()).getQuotaId()); START } END if (getVm() != null) { setStoragePoolId(getVm().getstorage_pool_id()); } } I don't like an idea to put that query at constarctor, first of all all AddDiskCommand will do an unneeded query, second we don't need a poolId for DetachDiskFromVmCommand and for UpdateVmDiskCommand, HotPlug and UnPlug, so putting at constractor is wrong

Target:
public AbstractDiskVmCommand(T parameters) { super(parameters); if (parameters.getDiskInfo() != null && DiskStorageType.IMAGE == parameters.getDiskInfo().getDiskStorageType()) { setQuotaId(((DiskImage) parameters.getDiskInfo()).getQuotaId()); } }
Source:
protected boolean isDiskExist(Disk disk) { START if (disk == null || isDiskExistInVm(disk)) { END addCanDoActionMessage(VdcBllMessages.ACTION_TYPE_FAILED_DISK_NOT_EXIST); return false; } return true; } there was a NOT ('!') before the check.. i think still relevant, no?

Target:
protected boolean isDiskExist(Disk disk) { if (disk == null || !isDiskExistInVm(disk)) { addCanDoActionMessage(VdcBllMessages.ACTION_TYPE_FAILED_DISK_NOT_EXIST); return false; } return true; }
Source:
private void RemoveVdsFromCollection() { // ResourceManager.Instance.removeVds(VdsId); VDSReturnValue returnValue = Backend.getInstance().getResourceManager() START .RunVdsCommand(VDSCommandType.RemoveVds, new RemoveVdsVDSCommandParameters(getVdsId())); END } on your next rebase, returnValue is not needed any more, no point to keep it

Target:
private void RemoveVdsFromCollection() { // ResourceManager.Instance.removeVds(VdsId); Backend.getInstance().getResourceManager() .RunVdsCommand(VDSCommandType.RemoveVds, new RemoveVdsVDSCommandParameters(getVdsId())); }
Source:
private void RemoveVdsFromCollection() { // ResourceManager.Instance.removeVds(VdsId); VDSReturnValue returnValue = Backend.getInstance().getResourceManager() .RunVdsCommand(VDSCommandType.RemoveVds, new RemoveVdsVDSCommandParameters(getVdsId())); if (!returnValue.getSucceeded()) { START errorType = AuditLogType.USER_FAILED_REMOVE_VDS; END } } this is not good enough, if for some reason the execution will fail before this method is called, or will fail not because of this run, there will be no error for audit log failure.

Target:
private void RemoveVdsFromCollection() { // ResourceManager.Instance.removeVds(VdsId); VDSReturnValue returnValue = Backend.getInstance().getResourceManager() .RunVdsCommand(VDSCommandType.RemoveVds, new RemoveVdsVDSCommandParameters(getVdsId())); }
Source:
protected void addVmPayload() { VmPayload payload = getParameters().getVmPayload(); if (payload != null) { VmDeviceUtils.addManagedDevice(new VmDeviceId(Guid.NewGuid(), getParameters().getVmId()), VmDeviceType.DISK, payload.getType(), payload.getSpecParams(), true, true, START ""); END } } please remove alias setting (should be encapsulated in addManagedDevice

Target:
protected void addVmPayload() { VmPayload payload = getParameters().getVmPayload(); if (payload != null) { VmDeviceUtils.addManagedDevice(new VmDeviceId(Guid.NewGuid(), getParameters().getVmId()), VmDeviceType.DISK, payload.getType(), payload.getSpecParams(), true, true); } }
Source:
public static VmDevice addNetworkInterfaceDevice(VmDeviceId id, boolean plugged) { START return addManagedDevice(id, VmDeviceType.INTERFACE, VmDeviceType.BRIDGE, null, plugged, false, ""); END } please remove alias setting (should be encapsulated in addManagedDevice

Target:
public static VmDevice addNetworkInterfaceDevice(VmDeviceId id, boolean plugged) { return addManagedDevice(id, VmDeviceType.INTERFACE, VmDeviceType.BRIDGE, null, plugged, false); }
Source:
private static <T extends VmBase> void addImportedDisks(T entity, List<VmDevice> vmDeviceToUpdate) { final Guid id = entity.getId(); for (BaseDisk disk : getDisks(entity.getImages())) { Guid deviceId = disk.getId(); VmDevice vmDevice = addManagedDevice(new VmDeviceId(deviceId, id), VmDeviceType.DISK, VmDeviceType.DISK, null, true, false, START ""); END updateVmDevice(entity, vmDevice, deviceId, vmDeviceToUpdate); } } please remove alias setting (should be encapsulated in addManagedDevice

Target:
private static <T extends VmBase> void addImportedDisks(T entity, List<VmDevice> vmDeviceToUpdate) { final Guid id = entity.getId(); for (BaseDisk disk : getDisks(entity.getImages())) { Guid deviceId = disk.getId(); VmDevice vmDevice = addManagedDevice(new VmDeviceId(deviceId, id), VmDeviceType.DISK, VmDeviceType.DISK, null, true, false); updateVmDevice(entity, vmDevice, deviceId, vmDeviceToUpdate); } }
Source:
private static <T extends VmBase> void addImportedInterfaces(T entity, List<VmDevice> vmDeviceToUpdate) { final Guid id = entity.getId(); for (VmNetworkInterface iface : entity.getInterfaces()) { Guid deviceId = iface.getId(); VmDevice vmDevice = addManagedDevice(new VmDeviceId(deviceId, id), VmDeviceType.INTERFACE, VmDeviceType.BRIDGE, null, true, false, START ""); END updateVmDevice(entity, vmDevice, deviceId, vmDeviceToUpdate); } } please remove alias setting (should be encapsulated in addManagedDevice

Target:
private static <T extends VmBase> void addImportedInterfaces(T entity, List<VmDevice> vmDeviceToUpdate) { final Guid id = entity.getId(); for (VmNetworkInterface iface : entity.getInterfaces()) { Guid deviceId = iface.getId(); VmDevice vmDevice = addManagedDevice(new VmDeviceId(deviceId, id), VmDeviceType.INTERFACE, VmDeviceType.BRIDGE, null, true, false); updateVmDevice(entity, vmDevice, deviceId, vmDeviceToUpdate); } }
Source:
private static void addUsbSlots(VmBase vm, int numOfSlots) { for (int index = 1; index <= numOfSlots; index++) { VmDeviceUtils.addManagedDevice(new VmDeviceId(Guid.NewGuid(), vm.getId()), VmDeviceType.REDIR, VmDeviceType.SPICEVMC, getUsbSlotSpecParams(), true, false, START ""); END } } please remove alias setting (should be encapsulated in addManagedDevice

Target:
private static void addUsbSlots(VmBase vm, int numOfSlots) { for (int index = 1; index <= numOfSlots; index++) { VmDeviceUtils.addManagedDevice(new VmDeviceId(Guid.NewGuid(), vm.getId()), VmDeviceType.REDIR, VmDeviceType.SPICEVMC, getUsbSlotSpecParams(), true, false); } }
Source:
private static void addEmptyCD(Guid dstId) { VmDeviceUtils.addManagedDevice(new VmDeviceId(Guid.NewGuid(), dstId), VmDeviceType.DISK, VmDeviceType.CDROM, Collections.<String, Object> singletonMap(VdsProperties.Path, ""), true, true, START ""); END } please remove alias setting (should be encapsulated in addManagedDevice

Target:
private static void addEmptyCD(Guid dstId) { VmDeviceUtils.addManagedDevice(new VmDeviceId(Guid.NewGuid(), dstId), VmDeviceType.DISK, VmDeviceType.CDROM, Collections.<String, Object> singletonMap(VdsProperties.Path, ""), true, true); }
Source:
START public Response remove(GlusterBricks bricks) { END for (GlusterBrick brick : bricks.getGlusterBricks()) { validateParameters(brick, "id"); } return performAction(VdcActionType.GlusterVolumeRemoveBricks, new GlusterVolumeRemoveBricksParameters(asGuid(getVolumeId()), mapBricks(asGuid(getVolumeId()), bricks))); } potential NPE on bricks.getGlusterBricks(), check isSet() first

Target:
public Response remove(GlusterBricks bricks) { if (bricks.getGlusterBricks().size() > 0) { for (GlusterBrick brick : bricks.getGlusterBricks()) { validateParameters(brick, "id"); } } return performAction(VdcActionType.GlusterVolumeRemoveBricks, new GlusterVolumeRemoveBricksParameters(asGuid(getVolumeId()), mapBricks(asGuid(getVolumeId()), bricks))); }
Source:
public void replaceBrick(GlusterBrickEntity oldBrick, GlusterBrickEntity newBrick) { getCallsHandler().executeModification("UpdateGlusterVolumeBrick", getCustomMapSqlParameterSource().addValue("id", oldBrick.getId()) .addValue("new_id", newBrick.getId()) .addValue("new_server_id", newBrick.getServerId()) .addValue("new_brick_dir", newBrick.getBrickDirectory()) START .addValue("new_brick_order", oldBrick.getBrickOrder()) END .addValue("new_status", EnumUtils.nameOrNull(newBrick.getStatus()))); } Since replace brick keeps order of new brick same as old brick, the parameter "new_brick_order" need not be passed to the SP.

Target:
public void replaceBrick(GlusterBrickEntity oldBrick, GlusterBrickEntity newBrick) { getCallsHandler().executeModification("UpdateGlusterVolumeBrick", getCustomMapSqlParameterSource().addValue("id", oldBrick.getId()) .addValue("new_id", newBrick.getId()) .addValue("new_server_id", newBrick.getServerId()) .addValue("new_status", EnumUtils.nameOrNull(newBrick.getStatus()))); }
Source:
START private ArrayList<String> split(String str) { END if (StringHelper.isNullOrEmpty(str)) { return null; } return new ArrayList<String>(Arrays.asList(str.split(SEPARATOR))); } not needed

Target:
private ArrayList<String> split(String str) { if (StringUtils.isEmpty(str)) { return null; } return new ArrayList<String>(Arrays.asList(str.split(SEPARATOR))); }
Source:
private void setVmTemplateIdParameter() { Map<Boolean, VmTemplate> templateMap = // Direct LUN can not be on template so we can consider the disk as disk image. getDbFacade().getVmTemplateDAO().getAllForImage(((DiskImage) disk).getImageId()); START if (!templateMap.values().isEmpty()) { END setVmTemplateId(templateMap.values().iterator().next().getId()); } } the common way of writing these is !templateMap().isEmpty()

Target:
private void setVmTemplateIdParameter() { Map<Boolean, VmTemplate> templateMap = // Disk image is the only disk type that can be part of the template disks. getDbFacade().getVmTemplateDAO().getAllForImage(((DiskImage) disk).getImageId()); if (!templateMap.isEmpty()) { setVmTemplateId(templateMap.values().iterator().next().getId()); } }
Source:
public static String map(org.ovirt.engine.core.common.businessentities.DisplayType type, String incoming) { START if (type==null) { END return null; } else { switch(type) { case vnc: return DisplayType.VNC.value(); case qxl: return DisplayType.SPICE.value(); default: return null; } } } i think test failed as it was suppose to fail, it shouldn't be NULL, iirc in GUI default display type for host is QXL and for desktop VNC

Target:
public static String map(org.ovirt.engine.core.common.businessentities.DisplayType type, String incoming) { switch(type) { case vnc: return DisplayType.VNC.value(); case qxl: return DisplayType.SPICE.value(); default: return null; } }
Source:
public <E extends Enum<E>> List<E> validateEnums(Class<E> clz, List<String> names) { ArrayList<E> enumList = new ArrayList<E>(); String reason = localize(Messages.INVALID_ENUM_REASON); String detail = localize(Messages.INVALID_ENUM_DETAIL); for (String name : names) { START enumList.add(EnumValidator.validateEnum(reason, detail, clz, name)); END } return enumList; } why simply not call BaseBackendResource.validateEnum(Class<E> clz, String name)? (instead of EnumValidator.validateEnum(reason, detail, clz, name), this why we will not have to maintain localization in two places)

Target:
public <E extends Enum<E>> List<E> validateEnums(Class<E> clz, List<String> names) { ArrayList<E> enumList = new ArrayList<E>(); for (String name : names) { enumList.add(validateEnum(clz, name)); } return enumList; }
Source:
private ValidationResult() { START this(null); END } Please remember this ctor changed.

Target:
public ValidationResult() { message = null; }
Source:
public boolean hasVolumeOnServer(Guid vdsId) { if (getGlusterBrickDao().getGlusterVolumeBricksByServerId(vdsId).size() > 0) { return true; } else { return false; START } END } well this is just a matter of style, but the above can be written also like this: return getGlusterBrickDao().getGlusterVolumeBricksByServerId(vdsId).size() > 0

Target:
public boolean hasVolumeOnServer(Guid vdsId) { return (getGlusterBrickDao().getGlusterVolumeBricksByServerId(vdsId).size() > 0); }
Source:
protected void executeCommand() { START vds_spm_id_map newMap = new vds_spm_id_map(getVds().getstorage_pool_id(), getVdsId(), 0); END DbFacade.getInstance().getVdsSpmIdMapDAO().save(newMap); if (getParameters().isCompensationEnabled()) { getCompensationContext().snapshotNewEntity(newMap); getCompensationContext().stateChanged(); } setSucceeded(true); } please also add a constructor with out spm_id

Target:
protected void executeCommand() { vds_spm_id_map newMap = new vds_spm_id_map(getVds().getstorage_pool_id(), getVdsId()); DbFacade.getInstance().getVdsSpmIdMapDAO().save(newMap); if (getParameters().isCompensationEnabled()) { getCompensationContext().snapshotNewEntity(newMap); getCompensationContext().stateChanged(); } setSucceeded(true); }
Source:
public Response head() { START appMode = getCurrent().get(ApplicationMode.class); END API api = null; if(appMode == ApplicationMode.GlusterOnly) { api = getApi(); } else { api = getGlusterApi(); } return getResponseBuilder(api).build(); } not needed, defined in class

Target:
public Response head() { appMode = getCurrent().get(ApplicationMode.class); API api = null; if(appMode == ApplicationMode.GlusterOnly) { api = getGlusterApi(); } else { api = getApi(); } return getResponseBuilder(api).build(); }
Source:
public Map<String, String> getJobMessageProperties() { if (jobProperties == null) { jobProperties = new HashMap<String, String>(); jobProperties.put(VdcObjectType.VDS.name().toLowerCase(), START (getVdsName() == null) ? "" : getVdsName()); END jobProperties.put(VdcObjectType.Storage.name().toLowerCase(), getStorageDomainName()); } return jobProperties; } No one is passing to command a storageDomain, it is usually ""

Target:
public Map<String, String> getJobMessageProperties() { if (jobProperties == null) { jobProperties = new HashMap<String, String>(); jobProperties.put(VdcObjectType.VDS.name().toLowerCase(), (getVdsName() == null) ? "" : getVdsName()); } return jobProperties; }
Source:
private void assertCanDoActionMessage(VdcBllMessages msg) { assertTrue("canDoAction failed for the wrong reason", command.getReturnValue() .getCanDoActionMessages() START .contains(msg.toString())); END } use name() instead. toString() can be overridden

Target:
private void assertCanDoActionMessage(VdcBllMessages msg) { assertTrue("canDoAction failed for the wrong reason", command.getReturnValue() .getCanDoActionMessages() .contains(msg.name())); }
Source:
protected void setActionMessageParameters() { if (getVdsGroup().supportsGlusterService() || getVdsGroup(getParameters().getClusterId()).supportsGlusterService()) { START addCanDoActionMessage(VdcBllMessages.VAR__ACTION__MOVE); END addCanDoActionMessage(VdcBllMessages.VAR__TYPE__HOST); } } Why set the messages only when the cluster supports gluster? This looks like a generic "Move Host" command, and setting corresponding messages (VAR__ACTION__MOVE and VAR__TYPE__HOST) should be ok irrespective of whether the cluster supports gluster or not.

Target:
protected void setActionMessageParameters() { addCanDoActionMessage(VdcBllMessages.VAR__ACTION__MOVE); addCanDoActionMessage(VdcBllMessages.VAR__TYPE__HOST); }