Source:
private void optimizeForVirtStore() { UIConstants constants = ConstantsManager.getInstance().getConstants(); if (getSelectedItems() == null || getSelectedItems().size() == 0) { return; } ArrayList<GlusterVolumeEntity> volumesForOptimiseForVirtStore = new ArrayList<GlusterVolumeEntity>(); ArrayList<GlusterVolumeEntity> discouragedConfigVolumes = new ArrayList<GlusterVolumeEntity>(); StringBuilder discouragedConfigVolumeNamesBuilder = new StringBuilder(); discouragedConfigVolumeNamesBuilder.append(constants.optimiseForVirtStoreWarning()); for (Object item : getSelectedItems()) { GlusterVolumeEntity volume = (GlusterVolumeEntity) item; volumesForOptimiseForVirtStore.add(volume); if(volume.getReplicaCount() != 3) { discouragedConfigVolumes.add(volume); discouragedConfigVolumeNamesBuilder.append(volume.getName() + "\n"); } } discouragedConfigVolumeNamesBuilder.append(constants.optimiseForVirtStoreContinueMessage()); if(discouragedConfigVolumes.size() > 0) { ConfirmationModel cModel = new ConfirmationModel(); cModel.setMessage(discouragedConfigVolumeNamesBuilder.toString()); UICommand cancelOptimiseVirtStoreCommand = new UICommand("CancelOptimizeForVirtStore", this); cancelOptimiseVirtStoreCommand.setTitle(constants.doNotOptimiseForVirtStore()); cancelOptimiseVirtStoreCommand.setIsCancel(true); cModel.getCommands().add(cancelOptimiseVirtStoreCommand); UICommand confirmOptimiseForVirtStoreCommand = new UICommand("ConfirmOptimiseForVirtStore", this); confirmOptimiseForVirtStoreCommand.setTitle(constants.continueOptimiseForVirtStore()); confirmOptimiseForVirtStoreCommand.setIsDefault(true); cModel.getCommands().add(confirmOptimiseForVirtStoreCommand); setConfirmWindow(cModel); } else { optimizeVolumesForVirtStore(volumesForOptimiseForVirtStore); } }

Target:
private void optimizeForVirtStore() { UIConstants constants = ConstantsManager.getInstance().getConstants(); if (getSelectedItems() == null || getSelectedItems().size() == 0) { return; } ArrayList<GlusterVolumeEntity> volumesForOptimiseForVirtStore = new ArrayList<GlusterVolumeEntity>(); Boolean isDiscouragedVolumePresent = false; StringBuilder discouragedConfigVolumeNamesBuilder = new StringBuilder(); discouragedConfigVolumeNamesBuilder.append(constants.optimiseForVirtStoreWarning()); for (Object item : getSelectedItems()) { GlusterVolumeEntity volume = (GlusterVolumeEntity) item; volumesForOptimiseForVirtStore.add(volume); if(volume.getReplicaCount() != 3) { discouragedConfigVolumeNamesBuilder.append(volume.getName() + "\n"); isDiscouragedVolumePresent = true; } } discouragedConfigVolumeNamesBuilder.append(constants.optimiseForVirtStoreContinueMessage()); if(isDiscouragedVolumePresent) { ConfirmationModel cModel = new ConfirmationModel(); cModel.setMessage(discouragedConfigVolumeNamesBuilder.toString()); UICommand cancelOptimiseVirtStoreCommand = new UICommand("CancelOptimizeForVirtStore", this); cancelOptimiseVirtStoreCommand.setTitle(constants.doNotOptimiseForVirtStore()); cancelOptimiseVirtStoreCommand.setIsCancel(true); cModel.getCommands().add(cancelOptimiseVirtStoreCommand); UICommand confirmOptimiseForVirtStoreCommand = new UICommand("ConfirmOptimiseForVirtStore", this); confirmOptimiseForVirtStoreCommand.setTitle(constants.continueOptimiseForVirtStore()); confirmOptimiseForVirtStoreCommand.setIsDefault(true); cModel.getCommands().add(confirmOptimiseForVirtStoreCommand); setConfirmWindow(cModel); } else { optimizeVolumesForVirtStore(volumesForOptimiseForVirtStore); } }