Source:
<code>protected boolean canDoAction() { boolean isInstanceType = getParameters().getTemplateType() == VmEntityType.INSTANCE_TYPE; if (getVdsGroup() == null && !isInstanceType) { return failCanDoAction(VdcBllMessages.VDS_CLUSTER_IS_NOT_VALID); } if (!isVmPriorityValueLegal(getParameters().getMasterVm().getPriority(), getReturnValue() .getCanDoActionMessages())) { return false; } if (isVmInDb && getVm().getStatus() != VMStatus.Down) { return failCanDoAction(VdcBllMessages.VMT_CANNOT_CREATE_TEMPLATE_FROM_DOWN_VM); } if (!isTemplateVersion() && isVmTemlateWithSameNameExist(getVmTemplateName())) { return failCanDoAction(VdcBllMessages.ACTION_TYPE_FAILED_NAME_ALREADY_USED); } if (isTemplateVersion()) { VmTemplate userSelectedBaseTemplate = getBaseTemplate(); if (userSelectedBaseTemplate == null) { return failCanDoAction(VdcBllMessages.ACTION_TYPE_FAILED_TEMPLATE_DOES_NOT_EXIST); } else if (!userSelectedBaseTemplate.isBaseTemplate()) { return failCanDoAction(VdcBllMessages.ACTION_TYPE_FAILED_TEMPLATE_VERSION_CANNOT_BE_BASE_TEMPLATE); } } if (!setAndValidateDiskProfiles()) { return false; } if(!setAndValidateCpuProfile()) { return false; } Iterator<DiskImage> it = diskInfoDestinationMap.values().iterator(); <START> while (it.hasNext()) { <END> if (it.next().getDiskAlias().isEmpty()) { return failCanDoAction(VdcBllMessages.ACTION_TYPE_FAILED_TEMPLATE_CANNOT_BE_CREATED_WITH_EMPTY_DISK_ALIAS); } } if (isInstanceType) { return true; } else { return doClusterRelatedChecks(); } }</code><technical_language>IMHO, more elegant enhanced for loop: for (DiskImage d : diskInfoDestinationMap.values()) { if (d.getDiskAlias().isEmpty()) { return failCanDoAction(VdcBllMessages.ACTION_TYPE_FAILED_TEMPLATE_CANNOT_BE_CREATED_ WITH_EMPTY_DISK_ALIAS); } }</technical_language>

Target:
protected boolean canDoAction() { boolean isInstanceType = getParameters().getTemplateType() == VmEntityType.INSTANCE_TYPE; if (getVdsGroup() == null && !isInstanceType) { return failCanDoAction(VdcBllMessages.VDS_CLUSTER_IS_NOT_VALID); } if (!isVmPriorityValueLegal(getParameters().getMasterVm().getPriority(), getReturnValue() .getCanDoActionMessages())) { return false; } if (isVmInDb && getVm().getStatus() != VMStatus.Down) { return failCanDoAction(VdcBllMessages.VMT_CANNOT_CREATE_TEMPLATE_FROM_DOWN_VM); } if (!isTemplateVersion() && isVmTemlateWithSameNameExist(getVmTemplateName())) { return failCanDoAction(VdcBllMessages.ACTION_TYPE_FAILED_NAME_ALREADY_USED); } if (isTemplateVersion()) { VmTemplate userSelectedBaseTemplate = getBaseTemplate(); if (userSelectedBaseTemplate == null) { return failCanDoAction(VdcBllMessages.ACTION_TYPE_FAILED_TEMPLATE_DOES_NOT_EXIST); } else if (!userSelectedBaseTemplate.isBaseTemplate()) { return failCanDoAction(VdcBllMessages.ACTION_TYPE_FAILED_TEMPLATE_VERSION_CANNOT_BE_BASE_TEMPLATE); } } if (!setAndValidateDiskProfiles()) { return false; } if(!setAndValidateCpuProfile()) { return false; } for (DiskImage diskImage : diskInfoDestinationMap.values()) { if ( StringUtils.isEmpty(diskImage.getDiskAlias()) ) { return failCanDoAction(VdcBllMessages.ACTION_TYPE_FAILED_TEMPLATE_CANNOT_BE_CREATED_WITH_EMPTY_DISK_ALIAS); } } if (isInstanceType) { return true; } else { return doClusterRelatedChecks(); } }