auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
public MoveOrCopyImageGroupParameters(Guid containerId, Guid imageGroupId, Guid imageId, Guid destImageGroupId, Guid destImageId, Guid storageDomainId, ImageOperation operation) { START this(containerId, imageGroupId, imageId, storageDomainId, operation); END setEntityId(destImageId); setDestImageGroupId(destImageGroupId); setDestinationImageId(destImageId); } I suppose it intention to overwrite entityId, which was set to imageId at constructor? Code becomes illogical

Target:
public MoveOrCopyImageGroupParameters(Guid containerId, Guid imageGroupId, Guid imageId, Guid destImageGroupId, Guid destImageId, Guid storageDomainId, ImageOperation operation) { this(containerId, imageGroupId, imageId, storageDomainId, operation); setDestImageGroupId(destImageGroupId); setDestinationImageId(destImageId); }
Source:
private void updateDiskVmSnapshotId() { Guid snapshotId = getSnapshotDao().getId(getVmId(), SnapshotType.ACTIVE); if (disk.getDiskStorageType() == DiskStorageType.IMAGE) { DiskImage diskImage = ((DiskImage) disk); getImageDao().updateImageVmSnapshotId(diskImage.getImageId(), START snapshotId); END diskImage.setvm_snapshot_id(snapshotId); } else { throw new VdcBLLException(VdcBllErrors.StorageException, "update of snapshot id was initiated for unsupported disk type"); } } Again what reason for that line. Lets think: line before we update entry at DB, why I need to update an object which is not updated at DB any more. Why? These is example of dead code. Dead code should not be written

Target:
private void updateDiskVmSnapshotId() { Guid snapshotId = getSnapshotDao().getId(getVmId(), SnapshotType.ACTIVE); if (disk.getDiskStorageType() == DiskStorageType.IMAGE) { DiskImage diskImage = ((DiskImage) disk); getImageDao().updateImageVmSnapshotId(diskImage.getImageId(), snapshotId); } else { throw new VdcBLLException(VdcBllErrors.StorageException, "update of snapshot id was initiated for unsupported disk type"); } }
Source:
public AddDiskCommand(T parameters) { super(parameters); parameters.getDiskInfo().setId(Guid.NewGuid()); parameters.setEntityId(parameters.getDiskInfo().getId()); START isAddToVm = !Guid.Empty.equals(parameters.getVmId()); END } this should not be a member. A function at most (as it is computed from the value of another member) or just inline it

Target:
public AddDiskCommand(T parameters) { super(parameters); parameters.getDiskInfo().setId(Guid.NewGuid()); parameters.setEntityId(parameters.getDiskInfo().getId()); }
Source:
public static String map(org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeType glusterVolumeType, String template) { switch (glusterVolumeType) { START case DISTRIBUTE: END return GlusterVolumeType.DISTRIBUTE.name(); case REPLICATE: return GlusterVolumeType.REPLICATE.name(); case DISTRIBUTED_REPLICATE: return GlusterVolumeType.DISTRIBUTED_REPLICATE.name(); case STRIPE: return GlusterVolumeType.STRIPE.name(); case DISTRIBUTED_STRIPE: return GlusterVolumeType.DISTRIBUTED_STRIPE.name(); default: return null; } } If you use .value() instead of .name(), you won't have to .toLowerCase() it later (same is true for all places below that use .name())

Target:
public static String map(org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeType glusterVolumeType, String template) { switch (glusterVolumeType) { case DISTRIBUTE: return GlusterVolumeType.DISTRIBUTE.value(); case REPLICATE: return GlusterVolumeType.REPLICATE.value(); case DISTRIBUTED_REPLICATE: return GlusterVolumeType.DISTRIBUTED_REPLICATE.value(); case STRIPE: return GlusterVolumeType.STRIPE.value(); case DISTRIBUTED_STRIPE: return GlusterVolumeType.DISTRIBUTED_STRIPE.value(); default: return null; } }
Source:
public boolean validate(ConfigKey key, String value) { // check if value is file path if (StringUtils.isNotBlank(value) && new File(value).exists()) { return true; } // The only valid value is "Interactive" START if (StringUtils.isNotBlank(value) && value.equals(INTERACTIVE_MODE)) { END return true; } // or if we have the password in --admin-pass-file if (StringUtils.isNotBlank(parser.getAdminPassFile()) && new File(parser.getAdminPassFile()).exists()) { return true; } return false; } Use "equalsIgnoreCase" here.

Target:
public boolean validate(ConfigKey key, String value) { // check if value is file path if (StringUtils.isNotBlank(value) && new File(value).exists()) { return true; } // The only valid value is "Interactive" if (StringUtils.isNotBlank(value) && value.equalsIgnoreCase(INTERACTIVE_MODE)) { return true; } // or if we have the password in --admin-pass-file if (StringUtils.isNotBlank(parser.getAdminPassFile()) && new File(parser.getAdminPassFile()).exists()) { return true; } return false; }
Source:
protected boolean validateImageNotInTemplate() { START if (!hasImages()) { END return true; } return getVmTemplateDAO().get(getRepresentativeSourceImageId()) == null; } you should check hasImages in canDoAction and if not skip all these validations

Target:
protected boolean validateImageNotInTemplate() { return getVmTemplateDAO().get(getRepresentativeSourceImageId()) == null; }
Source:
protected boolean InitializeVds() { boolean returnValue = true; if (getVds() == null) { List<VDS> runningVdss = getAllRunningVdssInPool(); setVds(runningVdss.isEmpty() ? null : runningVdss.get(0)); START if (getVds() == null) { END returnValue = false; addCanDoActionMessage(VdcBllMessages.ACTION_TYPE_FAILED_NO_VDS_IN_POOL); } } return returnValue; } don't like this block, it's unreadable. why not try the follwoing: if (runningVDSs.isEmpty) { returnValue = false; addCanDoActionMessage(VdcBllMessages.ACTION_TYPE_FAILED_NO_VDS_IN_POOL); } else { setVds(runningVdss); }

Target:
protected boolean InitializeVds() { boolean returnValue = true; if (getVds() == null) { List<VDS> runningVdss = getAllRunningVdssInPool(); if (runningVdss.isEmpty()) { returnValue = false; addCanDoActionMessage(VdcBllMessages.ACTION_TYPE_FAILED_NO_VDS_IN_POOL); } else { setVds(runningVdss.get(0)); } } return returnValue; }
Source:
public String extractPasswordValue(String value) throws IOException { String password = null; START if (StringUtils.isNotBlank(value) && value.equals(INTERACTIVE_MODE)) { END password = EngineConfigLogic.startPasswordDialog(null); } else { password = EngineConfigLogic.getPassFromFile((StringUtils.isNotBlank(value)) ? value : parser.getAdminPassFile()); } return password; } If you use "equalsIgnoreCase" here it makes it more user friendly.

Target:
public String extractPasswordValue(String value) throws IOException { String password = null; if (StringUtils.isNotBlank(value) && value.equalsIgnoreCase(INTERACTIVE_MODE)) { password = EngineConfigLogic.startPasswordDialog(null); } else { password = EngineConfigLogic.getPassFromFile((StringUtils.isNotBlank(value)) ? value : parser.getAdminPassFile()); } return password; }
Source:
private XmlRpcStruct generateOptions() { XmlRpcStruct options = new XmlRpcStruct(); options.add(VdsProperties.connectivityCheck, Boolean.toString(getParameters().isCheckConnectivity())); // VDSM uses the connectivity timeout only if 'connectivityCheck' is set to true if (getParameters().isCheckConnectivity()) { int connectivityTimeout = getParameters().getConectivityTimeout(); START if (connectivityTimeout <= 0) { END connectivityTimeout = Config.<Integer> GetValue(ConfigValues.NetworkConnectivityCheckTimeoutInSeconds); } options.add(VdsProperties.connectivityTimeout, connectivityTimeout); } return options; } Why is this still needed? We don't trust other half of engine? ;)

Target:
private XmlRpcStruct generateOptions() { XmlRpcStruct options = new XmlRpcStruct(); options.add(VdsProperties.connectivityCheck, Boolean.toString(getParameters().isCheckConnectivity())); // VDSM uses the connectivity timeout only if 'connectivityCheck' is set to true if (getParameters().isCheckConnectivity()) { options.add(VdsProperties.connectivityTimeout, getParameters().getConectivityTimeout()); } return options; }
Source:
private void warnIfNotAllDisksPermitSnapshots() { START if (getParameters().getRunAsStateless()) { END for (Disk disk : getVm().getDiskMap().values()) { if (!disk.isAllowSnapshot()) { AuditLogDirector.log(this, AuditLogType.USER_RUN_VM_AS_STATELESS_WITH_DISKS_NOT_ALLOWING_SNAPSHOT); break; } } } } checking runAsStateless is not needed since called from inside statelessTreatment method

Target:
private void warnIfNotAllDisksPermitSnapshots() { for (Disk disk : getVm().getDiskMap().values()) { if (!disk.isAllowSnapshot()) { AuditLogDirector.log(this, AuditLogType.USER_RUN_VM_AS_STATELESS_WITH_DISKS_NOT_ALLOWING_SNAPSHOT); break; } } }
Source:
public Map<String, String> getJobMessageProperties() { if (jobProperties == null) { jobProperties = new HashMap<String, String>(); START jobProperties.put(VdcObjectType.StoragePool.toString().toLowerCase(), getStoragePoolName()); END jobProperties.put(VdcObjectType.VmTemplate.toString().toLowerCase(), getVmTemplateName()); } return jobProperties; } please use VdcObjectType.StoragePool.name() instead of VdcObjectType.StoragePool.toString()

Target:
public Map<String, String> getJobMessageProperties() { if (jobProperties == null) { jobProperties = new HashMap<String, String>(); jobProperties.put(VdcObjectType.StoragePool.name().toLowerCase(), getStoragePoolName()); jobProperties.put(VdcObjectType.VmTemplate.name().toLowerCase(), getVmTemplateName()); } return jobProperties; }
Source:
protected boolean canDoAction() { START if (!super.canDoAction()) { END return false; } if (getGlusterVolume() == null) { addCanDoActionMessage(VdcBllMessages.ACTION_TYPE_FAILED_GLUSTER_VOLUME_INVALID); return false; } setVdsGroupId(getGlusterVolume().getClusterId()); return true; } super.canDoAction() assuming cluster id already set, when checking for up server, so need to overcome this also, please make sure non of the following commands inheriting from this command base doesn't assume the same, specially in getPermissionCheckSubject that is called before canDoAction (this is why usually we initiate params in the ctor)

Target:
protected boolean canDoAction() { if (getGlusterVolume() == null) { addCanDoActionMessage(VdcBllMessages.ACTION_TYPE_FAILED_GLUSTER_VOLUME_INVALID); return false; } setVdsGroupId(getGlusterVolume().getClusterId()); // super class canDoAction expects cluster id (VdsGroupId). if (!super.canDoAction()) { return false; } return true; }
Source:
private boolean hasSnappableDisks() { getDisksBasedOnImage(); START return !disksImages.isEmpty(); END } You flaged "Done on my suggestion from the previous patchset, but I don't see any change. Is this intentional?

Target:
private boolean hasSnappableDisks() { return !getDisksBasedOnImage().isEmpty(); }
Source:
protected void EndSuccessfully() { EndActionOnAllImageGroups(); VM vm = getVm(); START if (vm != null) { END VmHandler.UnLockVm(vm.getId()); endDiskRelatedActions(vm); if (getParameters().getCopyCollapse()) { this.endCopyCollapseOperations(vm); } else { this.endDefaultOps(vm); } } else { setCommandShouldBeLogged(false); log.warn("ExportVmCommand::EndMoveVmCommand: Vm is null - not performing full EndAction"); } setSucceeded(true); } Not sure if vm can be null, it is already locked.

Target:
protected void EndSuccessfully() { EndActionOnAllImageGroups(); VM vm = getVm(); VmHandler.UnLockVm(vm.getId()); endDiskRelatedActions(vm); if (getParameters().getCopyCollapse()) { this.endCopyCollapseOperations(vm); } else { this.endDefaultOps(vm); } setSucceeded(true); }
Source:
private void endDiskRelatedActions(VM vm) { START EndActionOnAllImageGroups(); END VmHandler.updateDisksFromDb(vm); VmDeviceUtils.setVmDevices(vm.getStaticData()); } previously this was run even if vm == null. Is there a situation where we'd have disks to end action on but vm == null? (sounds odd, but need to make sure why code worked as it did).

Target:
private void endDiskRelatedActions(VM vm) { VmHandler.updateDisksFromDb(vm); VmDeviceUtils.setVmDevices(vm.getStaticData()); }
Source:
START protected void RemoveChildren(Guid snapshot) { END List<Guid> children = new ArrayList<Guid>(); GetImageChildren(snapshot, children); Collections.reverse(children); for (Guid child : children) { RemoveSnapshot(getDiskImageDao().getSnapshotById(child)); } } Why protected?

Target:
private void RemoveChildren(Guid snapshot) { List<Guid> children = new ArrayList<Guid>(); GetImageChildren(snapshot, children); Collections.reverse(children); for (Guid child : children) { RemoveSnapshot(getDiskImageDao().getSnapshotById(child)); } }
Source:
public EntitySearchInfo(IAutoCompleter crossRefAutoCompleter, IConditionFieldAutoCompleter conditionFieldAutoCompleter, String relatedTableNameWithOutTags, String relatedTableName, String primeryKeyName, String defaultSort) { START super(); END this.crossRefAutoCompleter = crossRefAutoCompleter; this.conditionFieldAutoCompleter = conditionFieldAutoCompleter; this.relatedTableNameWithOutTags = relatedTableNameWithOutTags; this.relatedTableName = relatedTableName; this.primeryKeyName = primeryKeyName; this.defaultSort = defaultSort; } why call super?

Target:
public EntitySearchInfo(IAutoCompleter crossRefAutoCompleter, IConditionFieldAutoCompleter conditionFieldAutoCompleter, String relatedTableNameWithOutTags, String relatedTableName, String primeryKeyName, String defaultSort) { this.crossRefAutoCompleter = crossRefAutoCompleter; this.conditionFieldAutoCompleter = conditionFieldAutoCompleter; this.relatedTableNameWithOutTags = relatedTableNameWithOutTags; this.relatedTableName = relatedTableName; this.primeryKeyName = primeryKeyName; this.defaultSort = defaultSort; }
Source:
public Map<String, String> getJobMessageProperties() { if (jobProperties == null) { jobProperties = super.getJobMessageProperties(); jobProperties.put(VdcObjectType.StoragePool.name().toLowerCase(), START (getStoragePoolName() == null) ? "" : getStoragePoolName()); END jobProperties.put(VdcObjectType.VDS.name().toLowerCase(), (getVdsName() == null) ? "" : getVdsName()); } return jobProperties; } but without it the message will appear as: "Connecting Host <UNKOWN> to Storage server"

Target:
public Map<String, String> getJobMessageProperties() { if (jobProperties == null) { jobProperties = super.getJobMessageProperties(); jobProperties.put(VdcObjectType.StoragePool.name().toLowerCase(), getStoragePoolName()); jobProperties.put(VdcObjectType.VDS.name().toLowerCase(), getVdsName()); } return jobProperties; }
Source:
protected boolean checkStoragePool() { if (!super.checkStoragePool()) return false; START if (getStoragePool().getstatus() == StoragePoolStatus.Uninitialized) { END return true; } if (getStoragePool().getstatus() != StoragePoolStatus.Up) { addCanDoActionMessage(VdcBllMessages.ACTION_TYPE_FAILED_STORAGE_POOL_NOT_ACTIVE); return false; } return true; } This conflicts with the commit message - either Uninitiazlied is OK, in which case the commit message should reflect it, or it isn't, in which case the check should be removed.

Target:
protected boolean checkStoragePool() { if (!super.checkStoragePool()) return false; StoragePoolStatus status = getStoragePool().getstatus(); if (status == StoragePoolStatus.Uninitialized) { return true; } if (status != StoragePoolStatus.Up) { addCanDoActionMessage(VdcBllMessages.ACTION_TYPE_FAILED_STORAGE_POOL_NOT_ACTIVE); return false; } return true; }
Source:
protected void endActionOnVmConfiguration() { if (getVm() != null) { if (getVm().getstatus() == VMStatus.ImageLocked) { VmHandler.unlockVm(getVm(), getCompensationContext()); } UpdateVmInSpm(getVm().getstorage_pool_id(), Arrays.asList(getVm())); } else { setCommandShouldBeLogged(false); log.warn("VmCommand::EndVmCommand: Vm is null - not performing EndAction on Vm"); } START setSucceeded(true); END } setSucceeded should not have moved out of EndVmAction()

Target:
protected void endActionOnVmConfiguration() { if (getVm() != null) { if (getVm().getstatus() == VMStatus.ImageLocked) { VmHandler.unlockVm(getVm(), getCompensationContext()); } UpdateVmInSpm(getVm().getstorage_pool_id(), Arrays.asList(getVm())); } else { setCommandShouldBeLogged(false); log.warn("VmCommand::EndVmCommand: Vm is null - not performing EndAction on Vm"); } }
Source:
protected void endActionOnVmConfiguration() { START if (getVm() != null) { END if (getVm().getstatus() == VMStatus.ImageLocked) { VmHandler.unlockVm(getVm(), getCompensationContext()); } UpdateVmInSpm(getVm().getstorage_pool_id(), Arrays.asList(getVm())); } else { setCommandShouldBeLogged(false); log.warn("VmCommand::EndVmCommand: Vm is null - not performing EndAction on Vm"); } setSucceeded(true); } Not sure why we check if vm can be null here, it should be verified in the canDoAction when executed, and if the VM has disks then the VM should not be deleted, so I don't think vm can be null

Target:
protected void endActionOnVmConfiguration() { if (getVm().getstatus() == VMStatus.ImageLocked) { VmHandler.unlockVm(getVm(), getCompensationContext()); } UpdateVmInSpm(getVm().getstorage_pool_id(), Arrays.asList(getVm())); setSucceeded(true); }
Source:
START private <T> void validateAndAssertResult(List<VdsNetworkInterface> listOfInterfaces, boolean isValid) { END NoRepetitiveStaticIpInListContainer container = new NoRepetitiveStaticIpInListContainer(listOfInterfaces); Set<ConstraintViolation<NoRepetitiveStaticIpInListContainer>> validate = validator.validate(container); Assert.assertEquals(isValid, validate.isEmpty()); } why <T> is needed ?

Target:
private void validateAndAssertResult(List<VdsNetworkInterface> listOfInterfaces, boolean isValid) { NoRepetitiveStaticIpInListContainer container = new NoRepetitiveStaticIpInListContainer(listOfInterfaces); Set<ConstraintViolation<NoRepetitiveStaticIpInListContainer>> validate = validator.validate(container); Assert.assertEquals(isValid, validate.isEmpty()); }
Source:
private static void addBondDeviceToHost(VDS vds, VdsNetworkInterface iface, Object[] interfaces) { vds.getInterfaces().add(iface); if (interfaces != null) { for (Object name : interfaces) { for (VdsNetworkInterface tempInterface : vds.getInterfaces()) { if (tempInterface.getName().equals(name.toString())) { START tempInterface.setBondName(iface.getName()); END } } } } } Please return the break

Target:
private static void addBondDeviceToHost(VDS vds, VdsNetworkInterface iface, Object[] interfaces) { vds.getInterfaces().add(iface); if (interfaces != null) { for (Object name : interfaces) { for (VdsNetworkInterface tempInterface : vds.getInterfaces()) { if (tempInterface.getName().equals(name.toString())) { tempInterface.setBondName(iface.getName()); break; } } } } }
Source:
void initFrontend() { // Set up Frontend event handlers Frontend.initEventsHandler(frontendEventsHandler); Frontend.getFrontendFailureEvent().addListener(frontendFailureEventListener); Frontend.getFrontendNotLoggedInEvent().addListener(new IEventListener() { @Override public void eventRaised(Event ev, Object sender, EventArgs args) { user.logout(); START frontendFailureEventListener.hide(); END } }); Frontend.setFilterQueries(filterFrontendQueries()); } Maybe we don't need to call 'frontendFailureEventListener.hide()' here, since 'CurrentUser.logout()' will invoke 'BaseApplicationInit.onLogout()' by default.

Target:
void initFrontend() { // Set up Frontend event handlers Frontend.initEventsHandler(frontendEventsHandler); Frontend.getFrontendFailureEvent().addListener(frontendFailureEventListener); Frontend.getFrontendNotLoggedInEvent().addListener(new IEventListener() { @Override public void eventRaised(Event ev, Object sender, EventArgs args) { user.logout(); } }); Frontend.setFilterQueries(filterFrontendQueries()); }
Source:
public Map<String, String> getJobMessageProperties() { START if (jobProperties == null) { END jobProperties.put(VdcObjectType.VmTemplate.name().toLowerCase(), (getVmTemplateName() == null) ? "" : getVmTemplateName()); } return jobProperties; } this will clearly fail - you must to initialize jobProperties first....

Target:
public Map<String, String> getJobMessageProperties() { if (jobProperties == null) { jobProperties = new HashMap<String, String>(); jobProperties.put(VdcObjectType.VmTemplate.name().toLowerCase(), (getVmTemplateName() == null) ? "" : getVmTemplateName()); } return jobProperties; }
Source:
public ManageDomainsResult(ManageDomainsResultEnum enumResult, String... params) { START this("Default error.", enumResult, params); END } Should be blank or null, not "Default error"

Target:
public ManageDomainsResult(ManageDomainsResultEnum enumResult, String... params) { this("", enumResult, params); }
Source:
protected <S extends AbstractBackendResource<?, ?>> S inject(S resource) { resource.setBackend(backend); resource.setMappingLocator(mappingLocator); resource.setValidatorLocator(validatorLocator); resource.setSessionHelper(sessionHelper); resource.setMessageBundle(messageBundle); resource.setUriInfo(uriInfo); resource.setHttpHeaders(httpHeaders); START resource.setValidatorLocator(validatorLocator); END return resource; } why do you set it twice?

Target:
protected <S extends AbstractBackendResource<?, ?>> S inject(S resource) { resource.setBackend(backend); resource.setMappingLocator(mappingLocator); resource.setValidatorLocator(validatorLocator); resource.setSessionHelper(sessionHelper); resource.setMessageBundle(messageBundle); resource.setUriInfo(uriInfo); resource.setHttpHeaders(httpHeaders); return resource; }
Source:
protected ValidatorLocator getValidatorLocator() { if (validatorLocator == null) { validatorLocator = new ValidatorLocator(); START validatorLocator.populate(); END } return validatorLocator; } you do not need creating new instance of validatorLocator for every new sub-resource/subcollection, you can reuse instance defined in BackendApplication by adding [resource.setValidatorLocator(X);] in AbstractBackendResource.inject(). - it used to inject context ('backend', etc.) in to every sub-resource/subcollection,

Target:
protected ValidatorLocator getValidatorLocator() { return validatorLocator; }
Source:
private List<String> getVdsIps(VDS vds) { List<String> vdsIps = new ArrayList<String>(); for (VdsNetworkInterface iface : getInterfaceDao().getAllInterfacesForVds(vds.getId())) { START vdsIps.add(iface.getAddress()); END } return vdsIps; } iface.getAddress() might be null, therefore the list will include null element. It may result within a false positive in the comparison below (in fetchServers) therefore the list should be filtered out null elements.

Target:
private List<String> getVdsIps(VDS vds) { List<String> vdsIps = new ArrayList<String>(); for (VdsNetworkInterface iface : getInterfaceDao().getAllInterfacesForVds(vds.getId())) { if (iface.getAddress() != null) { vdsIps.add(iface.getAddress()); } } return vdsIps; }
Source:
public void refreshLightWeightData() { START log.info("Refreshing Gluster Data [lightweight]"); END List<VDSGroup> clusters = getClusterDao().getAll(); for (VDSGroup cluster : clusters) { if (cluster.supportsGlusterService()) { log.debugFormat("Refreshing Gluter Data for cluster {0}", cluster.getname()); refreshClusterData(cluster); } } } this will be written every 5 sec (by default) i think its better in debug

Target:
public void refreshLightWeightData() { log.debug("Refreshing Gluster Data [lightweight]"); List<VDSGroup> clusters = getClusterDao().getAll(); for (VDSGroup cluster : clusters) { if (cluster.supportsGlusterService()) { log.debugFormat("Refreshing Gluter Data for cluster {0}", cluster.getname()); refreshClusterData(cluster); } } }
Source:
public VolumeType getSelectedVolumeType() { START if (!(Boolean) collapseSnapshots.getEntity() || selectedVolumeType == null) { END return getVolumeType(); } return selectedVolumeType; } I figured out what's bugging me about this line. The logic here is in not semantics. it should be: if ((Boolean) collapseSnapshots.getEntity() && selectedVolumeType != null) { return selectedVolumeType; } return getVolumeType(); This way it is clearer that the only case where user can affect the volume type is if collapse is selected and user changed the value.

Target:
public VolumeType getSelectedVolumeType() { if ((Boolean) collapseSnapshots.getEntity() && selectedVolumeType != null) { return selectedVolumeType; } return getVolumeType(); }
Source:
public Map<String, String> getJobMessageProperties() { if (jobProperties == null) { jobProperties = super.getJobMessageProperties(); jobProperties.put(VdcObjectType.VM.name().toLowerCase(), (getVmName() == null) ? "" : getVmName()); jobProperties.put(VdcObjectType.VdsGroups.name().toLowerCase(), getVdsGroupName()); START jobProperties.put(VdcObjectType.StoragePool.name(), getStoragePoolName()); END } return jobProperties; } StorageHandlingCommandBase has: jobProperties.put(VdcObjectType.StoragePool.name().toLowerCase(), getStoragePoolName()); jobProperties.put(VdcObjectType.Storage.name().toLowerCase(), getStorageDomainName()); jobProperties.put(VdcObjectType.VDS.name().toLowerCase(), getVdsName()); So either rely on it or remove the super.getJobMessageProperties call above, but right now it looks like you're doing something redundant. Personally I prefer the latter (getting rid of super...)

Target:
public Map<String, String> getJobMessageProperties() { if (jobProperties == null) { jobProperties = super.getJobMessageProperties(); jobProperties.put(VdcObjectType.VM.name().toLowerCase(), (getVmName() == null) ? "" : getVmName()); jobProperties.put(VdcObjectType.VdsGroups.name().toLowerCase(), getVdsGroupName()); } return jobProperties; }
Source:
private List<StorageQuotaValidationParameter> getStorageQuotaListParameters() { List<StorageQuotaValidationParameter> list = new ArrayList<StorageQuotaValidationParameter>(); START for (Disk disk : getParameters().getVm().getDiskMap().values()) { END if(disk instanceof DiskImage){ DiskImage diskImage = (DiskImage)disk; list.add(new StorageQuotaValidationParameter(diskImage.getQuotaId(), imageToDestinationDomainMap.get(diskImage.getId()), diskImage.getSizeInGigabytes())); } } return list; } is this fixing anything? the constructor already sets the vm to getParameters().getVm() and getVm either gets the one set in the constructor or goes to the parameters as is done here (which seems redundant, but anyway). So i don't understand why we need to go to the params here.

Target:
private List<StorageQuotaValidationParameter> getStorageQuotaListParameters() { List<StorageQuotaValidationParameter> list = new ArrayList<StorageQuotaValidationParameter>(); for (Disk disk : getVm().getDiskMap().values()) { if(disk instanceof DiskImage){ DiskImage diskImage = (DiskImage)disk; list.add(new StorageQuotaValidationParameter(diskImage.getQuotaId(), //TODO: handle import more than once; imageToDestinationDomainMap.get(diskImage.getId()), diskImage.getSizeInGigabytes())); } } return list; }
Source:
public void setDiskStorageMap(HashMap<Guid, ArrayList<Guid>> value) { diskStorageMap = value; START raiseDiskEvent(); END } raiseDiskEvent sounds like an exception. should be something else (the name)

Target:
public void setDiskStorageMap(HashMap<Guid, ArrayList<Guid>> value) { diskStorageMap = value; }
Source:
START public static boolean isValidVmNetwork(VmNetworkInterface iface, Map<String, Network> networksByName) { END String networkName = iface.getNetworkName(); return (networksByName.containsKey(networkName) && networksByName.get(networkName).isVmNetwork()); } Would you mind adding a few unit tests for this in VmInterfaceManagerTest?

Target:
public boolean isValidVmNetwork(VmNetworkInterface iface, Map<String, Network> networksByName) { String networkName = iface.getNetworkName(); return (networksByName.containsKey(networkName) && networksByName.get(networkName).isVmNetwork()); }
Source:
START public HotPlugUnplgNicVDSParameters(Guid vdsId, VM vm, VmNetworkInterface nic, VmDevice vmDevice) { END super(vdsId); this.vmId = vm.getId(); this.nic = nic; this.vmDevice = vmDevice; this.clusterVersion = vm.getvds_group_compatibility_version(); } Why not add getter for VM and use it, instead of splitting to two fields?

Target:
public HotPlugUnplgNicVDSParameters(Guid vdsId, VM vm, VmNetworkInterface nic, VmDevice vmDevice) { super(vdsId); this.vm = vm; this.nic = nic; this.vmDevice = vmDevice; }
Source:
START DiskImageBase getDisk() { END if (_disk == null) { _disk = (DiskImageBase) getDbFacade().getDiskDao().get(getParameters().getObjectId()); } return _disk; } why isn't this private?

Target:
private DiskImageBase getDisk() { return _disk; }
Source:
protected boolean canDoAction() { // check if SP exist START setStoragePoolId(getParameters().getStoragePoolId()); END if (getStoragePool() == null) { addCanDoActionMessage(VdcBllMessages.ACTION_TYPE_FAILED_STORAGE_POOL_NOT_EXIST); return false; } // Check if quota exist: if (getQuotaId() == null) { addCanDoActionMessage(VdcBllMessages.ACTION_TYPE_FAILED_QUOTA_IS_NOT_VALID); return false; } if (getDbFacade().getQuotaDAO().getById(getQuotaId()) == null) { addCanDoActionMessage(VdcBllMessages.ACTION_TYPE_FAILED_QUOTA_NOT_EXIST); return false; } return true; } well it's not a must but i think the above line better be in the ctor

Target:
protected boolean canDoAction() { // check if SP exist if (getStoragePool() == null) { addCanDoActionMessage(VdcBllMessages.ACTION_TYPE_FAILED_STORAGE_POOL_NOT_EXIST); return false; } // Check if quota exist: if (getQuotaId() == null) { addCanDoActionMessage(VdcBllMessages.ACTION_TYPE_FAILED_QUOTA_IS_NOT_VALID); return false; } if (getDbFacade().getQuotaDAO().getById(getQuotaId()) == null) { addCanDoActionMessage(VdcBllMessages.ACTION_TYPE_FAILED_QUOTA_NOT_EXIST); return false; } return true; }
Source:
protected boolean isAllowClusterWithVirtGluster() { Boolean allowVirGluster = Config.<Boolean> GetValue(ConfigValues.AllowClusterWithVirtGlusterEnabled); START if (allowVirGluster == null) { END allowVirGluster = Boolean.TRUE; } return allowVirGluster; } no need for this check, it shouldn't be null

Target:
protected boolean isAllowClusterWithVirtGluster() { Boolean allowVirGluster = Config.<Boolean> GetValue(ConfigValues.AllowClusterWithVirtGlusterEnabled); return allowVirGluster; }
Source:
private VM getVmForNonShareableDiskImage(DiskImage disk) { if (!disk.isShareable()) { List<VM> vms = getVmDAO().getVmsListForDisk(disk.getId()); START if (vms != null && !vms.isEmpty()) { END return vms.get(0); } } return null; } "vms != null is redundent - the DAO ensures it will return an empty list if no vms are available

Target:
private VM getVmForNonShareableDiskImage(DiskImage disk) { if (!disk.isShareable()) { List<VM> vms = getVmDAO().getVmsListForDisk(disk.getId()); if (!vms.isEmpty()) { return vms.get(0); } } return null; }
Source:
public PermissionSubject(Guid objectId, VdcObjectType objectType, ActionGroup actionGroup, VdcBllMessages message) { START super(); END this.objectId = objectId; this.ObjectType = objectType; this.actionGroup = actionGroup; this.message = message; } super of what?

Target:
public PermissionSubject(Guid objectId, VdcObjectType objectType, ActionGroup actionGroup, VdcBllMessages message) { this.objectId = objectId; this.ObjectType = objectType; this.actionGroup = actionGroup; this.message = message; }
Source:
protected void validateFingerprint(SSHClient client, String fingerprint) { if (!fingerprint.equals(getFingerprint(client))) { START throw new AccessControlException("SSH Fingerprint of server " + getParameters().getServerName() END + " did not match expected fingerprint " + fingerprint); } } Won't String.format will make this nicer?

Target:
protected void validateFingerprint(SSHClient client, String fingerprint) { if (!fingerprint.equals(getFingerprint(client))) { throw new AccessControlException(String.format("SSH Fingerprint of server " + getParameters().getServerName() + " did not match expected fingerprint " + fingerprint)); } }
Source:
private String getTextValue(Element element, String tagName) { NodeList nodes = element.getElementsByTagName(tagName); Element nodeElement = (Element) nodes.item(0); NodeList nodeList = nodeElement.getChildNodes(); START return nodeList.item(0).getNodeValue().trim(); END } return element.getElementByTagName(tagName).item(0).getChildNodes().item(0).getNodeValue.trim(); Looks very long for standard text node extraction...

Target:
private String getTextValue(Element element, String tagName) { return element.getElementsByTagName(tagName).item(0).getChildNodes().item(0).getNodeValue().trim(); }
Source:
protected boolean canDoAction() { if (getVds() == null) { return failCanDoAction(VdcBllMessages.VDS_CANNOT_ACTIVATE_VDS_NOT_EXIST); } START if (true && getVds().getstatus() == VDSStatus.Up) { END return failCanDoAction(VdcBllMessages.VDS_CANNOT_ACTIVATE_VDS_ALREADY_UP); } return true; } why 'true'? Just check for getVds().getstatus()

Target:
protected boolean canDoAction() { if (getVds() == null) { return failCanDoAction(VdcBllMessages.VDS_CANNOT_ACTIVATE_VDS_NOT_EXIST); } if (getVds().getstatus() == VDSStatus.Up) { return failCanDoAction(VdcBllMessages.VDS_CANNOT_ACTIVATE_VDS_ALREADY_UP); } return true; }
Source:
protected void executeQueryCommand() { try { VDSReturnValue returnValue = getBackendResourceManager().RunVdsCommand(VDSCommandType.GetGlusterVolumeAdvancedDetails, new GlusterVolumeAdvancedDetailsVDSParameters(getUpServerId(), getParameters().getClusterId(), getParameters().getVolumeName(), getParameters().getBrickName(), getParameters().detailsRequired())); getQueryReturnValue().setReturnValue(returnValue.getReturnValue()); START } catch (Exception e) { END throw new RuntimeException(e); } } What's the point of catching the exception and then throwing it again, without doing anything in the catch block? There is no need to even wrap it inside a RuntimeException, since what is being thrown inside getUpServerId() is already a RuntimeException.

Target:
protected void executeQueryCommand() { VDSReturnValue returnValue = getBackendResourceManager().RunVdsCommand(VDSCommandType.GetGlusterVolumeAdvancedDetails, new GlusterVolumeAdvancedDetailsVDSParameters(getUpServerId(getParameters().getClusterId()), getParameters().getClusterId(), getParameters().getVolumeName(), getParameters().getBrickName(), getParameters().detailsRequired())); getQueryReturnValue().setReturnValue(returnValue.getReturnValue()); }
Source:
private Guid getBrickId(List<GlusterBrickEntity> bricksList, String qualifiedBrickName) { String[] brickParts = qualifiedBrickName.split(":", -1); START if (brickParts.length != 2) { END throw new RuntimeException("Invalid brick representation [" + qualifiedBrickName + "]"); } for (GlusterBrickEntity brick : bricksList) { // Compare the brickname with the existing volume brick if (brick.getQualifiedName().equals(qualifiedBrickName)) { return brick.getId(); } } return null; } This validation is not required. You can expect the brick name returned by glusterfs (and consequently vdsm) to be of the correct format.

Target:
private Guid getBrickId(List<GlusterBrickEntity> bricksList, String qualifiedBrickName) { for (GlusterBrickEntity brick : bricksList) { // Compare the brickname with the existing volume brick if (brick.getQualifiedName().equals(qualifiedBrickName)) { return brick.getId(); } } // It is possible that the brick is not found, in cases where user has added more bricks to the volume directly // using gluster CLI (and this change has not been synced yet by the GlusterManager). return null; }
Source:
private DiskImage getDiskForVolumeInfo(DiskImage disk) { if (getParameters().getCopyCollapse()) { START DiskImage ancestor = DbFacade.getInstance().getDiskImageDao().getAncestor(disk.getImageId()); END if (ancestor == null) { log.warnFormat("Can't find ancestor of Disk with ID {0}, using original disk for volume info.", disk.getImageId()); ancestor = disk; } return ancestor; } else { return disk; } } Hi Sharad, I saw you already changed the code a bit regarding getDiskImageDao - care to refactor and replace DbFacade.getInstance().getDiskImageDao() with a "getDiskImageDao()" call?

Target:
private DiskImage getDiskForVolumeInfo(DiskImage disk) { if (getParameters().getCopyCollapse()) { DiskImage ancestor = getDiskImageDao().getAncestor(disk.getImageId()); if (ancestor == null) { log.warnFormat("Can't find ancestor of Disk with ID {0}, using original disk for volume info.", disk.getImageId()); ancestor = disk; } return ancestor; } else { return disk; } }
Source:
public String toString() { String AddInfo = getAdditionalInformation(); return String.format("%s(%s %s)", super.toString(), START (!StringUtils.isEmpty(AddInfo) ? AddInfo + "," : ""), END (getParameters() != null ? getParameters().toString() : "null")); } No need for string utils. But if you want to use it, I think they have a isNotEmpty method as well.

Target:
public String toString() { String AddInfo = getAdditionalInformation(); return String.format("%s(%s %s)", super.toString(), (!AddInfo.isEmpty() ? AddInfo + "," : ""), (getParameters() != null ? getParameters().toString() : "null")); }
Source:
public boolean hasSpaceForSnapthosts(VM vm) { Map<storage_domains, Integer> map = mapStorageDomainsToNumOfDisks(vm); Integer minSnapshotSize = Config.<Integer> GetValue(ConfigValues.InitStorageSparseSizeInGB); START for (storage_domains domain : map.keySet()) { END if (!StorageDomainSpaceChecker.hasSpaceForRequest(domain, minSnapshotSize * map.get(domain))) { log.error("not enough space to create snapshot on domain " + domain.getId()); return false; } } return true; } Please iterate using entrySet

Target:
public boolean hasSpaceForSnapthosts(VM vm) { Integer minSnapshotSize = Config.<Integer> GetValue(ConfigValues.InitStorageSparseSizeInGB); for (Entry<storage_domains, Integer> e : mapStorageDomainsToNumOfDisks(vm).entrySet()) { if (!StorageDomainSpaceChecker.hasSpaceForRequest(e.getKey(), minSnapshotSize * e.getValue())) { log.error("not enough space to create snapshot on domain " + e.getKey().getId()); return false; } } return true; }
Source:
private void logException(RuntimeException ex) { log.errorFormat("Command {0} execution failed. Exception: {1}", getCommandName(), ExceptionUtils.getMessage(ex)); START if (!(ex instanceof VDSExceptionBase)) { END log.error(ExceptionUtils.getStackTrace(ex)); } } I really don't like the user of instanceof. Why not overload the method to recive VDSExceptionBase? In both places this function is used, you already have that information.

Target:
private void logException(RuntimeException ex) { log.errorFormat("Command {0} execution failed. Exception: {1}", getCommandName(), ExceptionUtils.getMessage(ex)); }
Source:
public String render(Boolean valueToRender) { if(valueToRender == null) return ""; START END if (trueText == null || falseText == null) { return valueToRender.toString(); } return valueToRender.booleanValue() ? trueText : falseText; } On rebase, please wrap the 'return' statement with curly braces and format the lines (i.e. a white-space is missing after the 'if').

Target:
public String render(Boolean valueToRender) { if (valueToRender == null){ return ""; } if (trueText == null || falseText == null) { return valueToRender.toString(); } return valueToRender.booleanValue() ? trueText : falseText; }
Source:
protected void executeCommand() { VDSReturnValue returnValue = runVdsCommand(VDSCommandType.StopGlusterVolumeProfile, new GlusterVolumeVDSParameters(upServer.getId(), getGlusterVolumeName())); setSucceeded(returnValue.getSucceeded()); if (!getSucceeded()) { handleVdsError(AuditLogType.GLUSTER_VOLUME_PROFILE_STOP_FAILED, returnValue.getVdsError().getMessage()); START return; END } } the return statement is redundant here.

Target:
protected void executeCommand() { VDSReturnValue returnValue = runVdsCommand(VDSCommandType.StopGlusterVolumeProfile, new GlusterVolumeVDSParameters(upServer.getId(), getGlusterVolumeName())); setSucceeded(returnValue.getSucceeded()); if (!getSucceeded()) { handleVdsError(AuditLogType.GLUSTER_VOLUME_PROFILE_STOP_FAILED, returnValue.getVdsError().getMessage()); } }
Source:
START public static QuotaDAO getQuotaDAO() { END return DbFacade.getInstance() .getQuotaDao(); } maybe package protected would work here? It is a commonly accepted practice when writing unit tests.

Target:
public QuotaDAO getQuotaDAO() { return DbFacade.getInstance() .getQuotaDao(); }
Source:
private static void assertNotEmptyCanDoActionMessage() { START assertTrue(EXPECTED_CAN_DO_MESSAGE, canDoActionMessages.size() > 0); END canDoActionMessages.clear(); } optional: consider using assertFalse(EXPECTED_CAN_DO_MESSAGE, canDoActionMessages.isEmpty())

Target:
private void assertNotEmptyCanDoActionMessage() { assertTrue(EXPECTED_CAN_DO_MESSAGE, !canDoActionMessages.isEmpty()); canDoActionMessages.clear(); }
Source:
private static void assertEmptyCanDoActionMessage() { START assertTrue(EXPECTED_EMPTY_CAN_DO_MESSAGE, canDoActionMessages.size() == 0); END } Optional: consider using assertTrue(EXPECTED_EMPTY_CAN_DO_MESSAGE, canDoActionMessages.isEmpty())

Target:
private void assertEmptyCanDoActionMessage() { assertTrue(EXPECTED_EMPTY_CAN_DO_MESSAGE, canDoActionMessages.isEmpty()); }
Source:
private static void assertAuditLogWritten() { START assertTrue(EXPECTED_AUDIT_LOG_MESSAGE, auditLogWritten); END auditLogWritten = false; } This seems like a bit of a workaround - why not use mockito's verify?

Target:
private void assertAuditLogWritten() { assertTrue(EXPECTED_AUDIT_LOG_MESSAGE, auditLogWritten); auditLogWritten = false; }
Source:
protected void ExecuteVdsBrokerCommand() { status = getBroker().glusterValidateSshConnection(getParameters().getRemoteServer(), getParameters().getFingerprint(), getParameters().getUserName()); ProceedProxyReturnValue(); START setReturnValue(getReturnValue()); END } What is the purpose of this statement?

Target:
protected void ExecuteVdsBrokerCommand() { status = getBroker().glusterValidateSshConnection(getParameters().getRemoteServer(), getParameters().getFingerprint(), getParameters().getUserName()); ProceedProxyReturnValue(); setReturnValue(true); }
Source:
public GetConfigurationValuesQuery(P parameters) { super(parameters); START configValuesSet = new HashSet<String>(); END } in addition to moving it, init it in the right size -ConfigValues.values().size()

Target:
public GetConfigurationValuesQuery(P parameters) { super(parameters); }
Source:
public void findMissingEnumNames() { // Find missing ConfigurationValues enum names in ConfigValues enum boolean missingKey = false; for (ConfigurationValues configValue : ConfigurationValues.values()) { if (!configValuesEnumNames.contains(configValue.toString())) { log.error("Found missing key: " + configValue.toString()); missingKey = true; break; } } START assertFalse(missingKey); END } Please add a message here.

Target:
public void findMissingEnumNames() { // Find missing ConfigurationValues enum names in ConfigValues enum boolean missingKey = false; for (ConfigurationValues configValue : ConfigurationValues.values()) { if (!configValuesEnumNames.contains(configValue.toString())) { log.error("Found missing key: " + configValue.toString()); missingKey = true; break; } } assertFalse("Found missing key: ", missingKey); }
Source:
protected VDSExceptionBase createDefaultConcreteException(String errorMessage) { VDSExceptionBase outEx = new IrsOperationFailedNoFailoverException(errorMessage); START return outEx; END } inline the return statement.

Target:
protected VDSExceptionBase createDefaultConcreteException(String errorMessage) { return new IrsOperationFailedNoFailoverException(errorMessage); }
Source:
private VDSExceptionBase createException() { VDSExceptionBase outEx; final String errorMessage = String.format("Failed to %1$s, error = %2$s", getCommandName(), getReturnStatus().mMessage); outEx = createDefaultConcreteException(errorMessage); START return outEx; END } inline the return statement.

Target:
private VDSExceptionBase createException() { final String errorMessage = String.format("Failed to %1$s, error = %2$s", getCommandName(), getReturnStatus().mMessage); return createDefaultConcreteException(errorMessage); }
Source:
public InvalidQuotaParametersException(String errorStr, Throwable cause) { START super("InvalidQuotaParametersException: " + errorStr, cause); END } I'd just call super(message, cause)

Target:
public InvalidQuotaParametersException(String errorStr, Throwable cause) { super(errorStr, cause); }
Source:
public QuotaConsumptionParametersWrapper clone() { QuotaConsumptionParametersWrapper cloneWrapper = new QuotaConsumptionParametersWrapper(getAuditLogable(), canDoActionMessages); cloneWrapper.setParameters(new ArrayList<QuotaConsumptionParameter>()); for (QuotaConsumptionParameter parameter : getParameters()) { QuotaConsumptionParameter clone = parameter instanceof QuotaStorageConsumptionParameter ? ((QuotaStorageConsumptionParameter)parameter).clone(): START ((QuotaVdsGroupConsumptionParameter)parameter).clone(); END cloneWrapper.getParameters().add(clone); } return cloneWrapper; } Do you see a scenario in which a QutoaConsumptionParameter will not have the ability to be cloned?

Target:
public QuotaConsumptionParametersWrapper clone() { QuotaConsumptionParametersWrapper cloneWrapper = new QuotaConsumptionParametersWrapper(getAuditLogable(), canDoActionMessages); cloneWrapper.setParameters(new ArrayList<QuotaConsumptionParameter>()); for (QuotaConsumptionParameter parameter : getParameters()) { cloneWrapper.getParameters().add(parameter.clone()); } return cloneWrapper; }
Source:
START public QuotaDependency getQuotaDependency() { END return this.quotaDependency; } remove this

Target:
public QuotaDependency getQuotaDependency() { return quotaDependency; }
Source:
public static boolean IsVersionMatchStorageType(Version version, StorageType type) { return !((type == StorageType.LOCALFS && version.compareTo(new Version(2, 2)) <= 0) START || (type == StorageType.POSIXFS && version.compareTo(new Version(3, 0)) <= 0) END || (type == StorageType.GLUSTERFS && version.compareTo(new Version(3, 2)) <= 0)); } Config file has GLUSTERFS storage enabled in 3.3, should this be changed here too?

Target:
public static boolean IsVersionMatchStorageType(Version version, StorageType type) { return !((type == StorageType.LOCALFS && version.compareTo(new Version(2, 2)) <= 0) || (type == StorageType.POSIXFS && version.compareTo(new Version(3, 0)) <= 0) || (type == StorageType.GLUSTERFS && version.compareTo(new Version(3, 3)) <= 0)); }
Source:
public List<QuotaStorageConsumptionParameter> getQuotaStorageConsumptionParameters() { List<QuotaStorageConsumptionParameter> list = new ArrayList<QuotaStorageConsumptionParameter>(); START for (DiskImage disk : getDisksList()) { END list.add(new QuotaStorageConsumptionParameter( disk.getQuotaId(), null, QuotaConsumptionParameter.QuotaAction.CONSUME, disk.getstorage_ids().get(0), disk.getActualSize())); } return list; } can you please add a helper method for performing it? this code is repeating itself in all of this patch edited classes.

Target:
public List<QuotaConsumptionParameter> getQuotaStorageConsumptionParameters() { List<QuotaConsumptionParameter> list = new ArrayList<QuotaConsumptionParameter>(); for (DiskImage disk : getDisksList()) { list.add(new QuotaStorageConsumptionParameter( disk.getQuotaId(), null, QuotaConsumptionParameter.QuotaAction.CONSUME, disk.getstorage_ids().get(0), disk.getActualSize())); } return list; }
Source:
protected void endWithFailure() { if (getMoveOrCopyImageOperation() == ImageOperation.Copy) { unLockImage(); if (getParameters().getAddImageDomainMapping()) { // remove image-storage mapping getImageStorageDomainMapDao().remove (new image_storage_domain_map_id(getParameters().getImageId(), getParameters().getStorageDomainId())); } revertTasks(); START } else { END unLockImage(); } setSucceeded(true); } UnlockImage is performed anyway, so it can just be removed out of the if-else.

Target:
protected void endWithFailure() { unLockImage(); if (getMoveOrCopyImageOperation() == ImageOperation.Copy) { if (getParameters().getAddImageDomainMapping()) { // remove image-storage mapping getImageStorageDomainMapDao().remove (new image_storage_domain_map_id(getParameters().getImageId(), getParameters().getStorageDomainId())); } revertTasks(); } setSucceeded(true); }