From 3de607c7914f4cc6e5a1ff6ac4b5d2d1d53086aa Mon Sep 17 00:00:00 2001 From: Benjamin Bentmann Date: Sat, 11 May 2013 18:25:27 +0200 Subject: [PATCH] Simplified code --- .../impl/DefaultUpdateCheckManager.java | 62 +++++++------------ 1 file changed, 23 insertions(+), 39 deletions(-) diff --git a/aether-impl/src/main/java/org/eclipse/aether/internal/impl/DefaultUpdateCheckManager.java b/aether-impl/src/main/java/org/eclipse/aether/internal/impl/DefaultUpdateCheckManager.java index 8b702e64..cbe8d6bb 100644 --- a/aether-impl/src/main/java/org/eclipse/aether/internal/impl/DefaultUpdateCheckManager.java +++ b/aether-impl/src/main/java/org/eclipse/aether/internal/impl/DefaultUpdateCheckManager.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2010, 2012 Sonatype, Inc. + * Copyright (c) 2010, 2013 Sonatype, Inc. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -198,33 +198,31 @@ public class DefaultUpdateCheckManager else { int errorPolicy = Utils.getPolicy( session, artifact, repository ); - if ( error == null || error.length() <= 0 ) + int cacheFlag = getCacheFlag( error ); + if ( ( errorPolicy & cacheFlag ) != 0 ) { - if ( ( errorPolicy & ResolutionErrorPolicy.CACHE_NOT_FOUND ) != 0 ) - { - check.setRequired( false ); - check.setException( newException( error, artifact, repository ) ); - } - else - { - check.setRequired( true ); - } + check.setRequired( false ); + check.setException( newException( error, artifact, repository ) ); } else { - if ( ( errorPolicy & ResolutionErrorPolicy.CACHE_TRANSFER_ERROR ) != 0 ) - { - check.setRequired( false ); - check.setException( newException( error, artifact, repository ) ); - } - else - { - check.setRequired( true ); - } + check.setRequired( true ); } } } + private static int getCacheFlag( String error ) + { + if ( error == null || error.length() <= 0 ) + { + return ResolutionErrorPolicy.CACHE_NOT_FOUND; + } + else + { + return ResolutionErrorPolicy.CACHE_TRANSFER_ERROR; + } + } + private ArtifactTransferException newException( String error, Artifact artifact, RemoteRepository repository ) { if ( error == null || error.length() <= 0 ) @@ -338,29 +336,15 @@ public class DefaultUpdateCheckManager else { int errorPolicy = Utils.getPolicy( session, metadata, repository ); - if ( error == null || error.length() <= 0 ) + int cacheFlag = getCacheFlag( error ); + if ( ( errorPolicy & cacheFlag ) != 0 ) { - if ( ( errorPolicy & ResolutionErrorPolicy.CACHE_NOT_FOUND ) != 0 ) - { - check.setRequired( false ); - check.setException( newException( error, metadata, repository ) ); - } - else - { - check.setRequired( true ); - } + check.setRequired( false ); + check.setException( newException( error, metadata, repository ) ); } else { - if ( ( errorPolicy & ResolutionErrorPolicy.CACHE_TRANSFER_ERROR ) != 0 ) - { - check.setRequired( false ); - check.setException( newException( error, metadata, repository ) ); - } - else - { - check.setRequired( true ); - } + check.setRequired( true ); } } } -- GitLab