Idan Shaby has uploaded a new change for review. Change subject: core: Replaced returning null to throwing exception ......................................................................
core: Replaced returning null to throwing exception The getUserRequestForStorageDomainRepoFileList method used to return null when the storage domain was not valid. Now it throws a VdcBLLException with GetIsoListError type instead. Change-Id: I3e6dc6fbe03ffba94cff8821b35eacf062e42362 Related-To: https://bugzilla.redhat.com/918949 Signed-off-by: Idan Shaby <[email protected]> --- M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/GetImagesListQueryBase.java M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/IsoDomainListSyncronizer.java 2 files changed, 12 insertions(+), 5 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/33/29033/1 diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/GetImagesListQueryBase.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/GetImagesListQueryBase.java index 6c5daf8..8ab3527 100644 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/GetImagesListQueryBase.java +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/GetImagesListQueryBase.java @@ -3,6 +3,7 @@ import java.util.List; import org.ovirt.engine.core.common.businessentities.RepoImage; +import org.ovirt.engine.core.common.errors.VdcBLLException; import org.ovirt.engine.core.common.errors.VdcBllErrors; import org.ovirt.engine.core.common.queries.GetImagesListParametersBase; import org.ovirt.engine.core.compat.Guid; @@ -17,10 +18,12 @@ @Override protected void executeQueryCommand() { // Fetch all the Iso files of a given type for storage pool with active storage domain of this domain Id. - getQueryReturnValue().setReturnValue(getUserRequestForStorageDomainRepoFileList()); - if (getQueryReturnValue().getReturnValue() == null) { + try { + getQueryReturnValue().setReturnValue(getUserRequestForStorageDomainRepoFileList()); + } + catch (VdcBLLException e) { getQueryReturnValue().setSucceeded(false); - getQueryReturnValue().setExceptionString(VdcBllErrors.GetIsoListError.toString()); + getQueryReturnValue().setExceptionString(e.getErrorCode().toString()); } } diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/IsoDomainListSyncronizer.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/IsoDomainListSyncronizer.java index bbfc42d..5d185af 100644 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/IsoDomainListSyncronizer.java +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/IsoDomainListSyncronizer.java @@ -31,6 +31,8 @@ import org.ovirt.engine.core.common.config.Config; import org.ovirt.engine.core.common.config.ConfigValues; import org.ovirt.engine.core.common.constants.StorageConstants; +import org.ovirt.engine.core.common.errors.VdcBLLException; +import org.ovirt.engine.core.common.errors.VdcBllErrors; import org.ovirt.engine.core.common.utils.Pair; import org.ovirt.engine.core.common.vdscommands.GetFileStatsParameters; import org.ovirt.engine.core.common.vdscommands.IrsBaseVDSCommandParameters; @@ -166,7 +168,7 @@ /** * Returns a RepoFilesMetaData list with Iso file names for storage domain Id and with file type extension.<BR> - * If user choose to refresh the cache, and a problem occurs, then returns null. + * If user choose to refresh the cache, and a problem occurs, then throws VdcBLLException. * * @param storageDomainId * - The storage domain Id, which we fetch the Iso list from. @@ -174,6 +176,8 @@ * - The imageType we want to fetch the files from the cache. * @param forceRefresh * - Indicates if the domain should be refreshed from VDSM. + * @throws VdcBLLException - if a problem occurs when refreshing the image repo cache. + * * @return List of RepoFilesMetaData files or null (If fetch from VDSM failed). */ public List<RepoImage> getUserRequestForStorageDomainRepoFileList(Guid storageDomainId, @@ -182,7 +186,7 @@ // The result list we send back. List<RepoImage> repoList = null; if (!isStorageDomainValid(storageDomainId, imageType, forceRefresh)) { - return null; + throw new VdcBLLException(VdcBllErrors.GetIsoListError); } // At any case, if refreshed or not, get Iso list from the cache. repoList = getCachedIsoListByDomainId(storageDomainId, imageType); -- To view, visit http://gerrit.ovirt.org/29033 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I3e6dc6fbe03ffba94cff8821b35eacf062e42362 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Idan Shaby <[email protected]> _______________________________________________ Engine-patches mailing list [email protected] http://lists.ovirt.org/mailman/listinfo/engine-patches
