Source:
<code>protected void executeVmCommand() { Set<Guid> mImagesToBeRemoved = new HashSet<Guid>(); List<DiskImage> images = getParameters().Images; if (images == null) { images = ImagesHandler.filterImageDisks(DbFacade.getInstance().getDiskDao().getAllForVm(getVmId()), true, false); } for (DiskImage image : images) { if (Boolean.TRUE.equals(image.getActive())) { mImagesToBeRemoved.add(image.getImageId()); } } Collection<DiskImage> failedRemoving = new LinkedList<>(); for (final DiskImage image : images) { if (mImagesToBeRemoved.contains(image.getImageId())) { VdcReturnValueBase vdcReturnValue = Backend.getInstance().runInternalAction(VdcActionType.RemoveImage, buildRemoveImageParameters(image), ExecutionHandler.createDefaultContexForTasks(getExecutionContext())); if (vdcReturnValue.getSucceeded()) { getReturnValue().getInternalVdsmTaskIdList().addAll(vdcReturnValue.getInternalVdsmTaskIdList()); } else { <START> StorageDomain domain = DbFacade.getInstance().getStorageDomainDao().get(image.getStorageIds().get(0)); <END> failedRemoving.add(image); log.errorFormat("Can't remove image id: {0} for VM id: {1} from domain id: {2} due to: {3}.", image.getImageId(), getParameters().getVmId(), image.getStorageIds().get(0), vdcReturnValue.getFault().getMessage()); if (domain.getStorageDomainType() == StorageDomainType.Data) { log.error("Image will be set at illegal state with no snapshot id."); TransactionSupport.executeInScope(TransactionScopeOption.Required, new TransactionMethod<Object>() { @Override public Object runInTransaction() { updateDiskImagesToIllegal(image); return true; } }); } else { log.error("The image is not on a data domain and will not be marked as illegal."); } } } } setActionReturnValue(failedRemoving); setSucceeded(true); }</code><technical_language>please getStorageDomainDao() instead of DbFacade.getInstance().getStorageDomainDao()</technical_language>

Target:
protected void executeVmCommand() { Set<Guid> mImagesToBeRemoved = new HashSet<Guid>(); List<DiskImage> images = getParameters().Images; if (images == null) { images = ImagesHandler.filterImageDisks(DbFacade.getInstance().getDiskDao().getAllForVm(getVmId()), true, false); } for (DiskImage image : images) { if (Boolean.TRUE.equals(image.getActive())) { mImagesToBeRemoved.add(image.getImageId()); } } Collection<DiskImage> failedRemoving = new LinkedList<>(); for (final DiskImage image : images) { if (mImagesToBeRemoved.contains(image.getImageId())) { VdcReturnValueBase vdcReturnValue = Backend.getInstance().runInternalAction(VdcActionType.RemoveImage, buildRemoveImageParameters(image), ExecutionHandler.createDefaultContexForTasks(getExecutionContext())); if (vdcReturnValue.getSucceeded()) { getReturnValue().getInternalVdsmTaskIdList().addAll(vdcReturnValue.getInternalVdsmTaskIdList()); } else { StorageDomain domain = getStorageDomainDao().get(image.getStorageIds().get(0)); failedRemoving.add(image); log.errorFormat("Can't remove image id: {0} for VM id: {1} from domain id: {2} due to: {3}.", image.getImageId(), getParameters().getVmId(), image.getStorageIds().get(0), vdcReturnValue.getFault().getMessage()); if (domain.getStorageDomainType() == StorageDomainType.Data) { log.info("Image will be set at illegal state with no snapshot id."); TransactionSupport.executeInScope(TransactionScopeOption.Required, new TransactionMethod<Object>() { @Override public Object runInTransaction() { updateDiskImagesToIllegal(image); return true; } }); } else { log.info("The image is not on a data domain and will not be marked as illegal."); } } } } setActionReturnValue(failedRemoving); setSucceeded(true); }