public static InstallException createFailedToDownload ( RepositoryResource installResource , Exception e , File toDir ) { String target = toDir == null ? System . getProperty ( "java.io.tmpdir" ) : toDir . getAbsolutePath ( ) ; if ( e instanceof IOException ) return ExceptionUtils . createByKey ( InstallException . IO_FAILURE , e , "ERROR_FAILED_DOWNLOAD_ASSETS_TO_TEMP" , InstallUtils . getResourceId ( installResource ) , InstallUtils . getResourceName ( installResource ) , target ) ; if ( e instanceof RepositoryBackendException ) { RepositoryConnection failingConnection = ( ( RepositoryBackendException ) e ) . getFailingConnection ( ) ; String repositoryLocation = failingConnection . getRepositoryLocation ( ) ; boolean isDefaultRepo = repositoryLocation . startsWith ( InstallConstants . REPOSITORY_LIBERTY_URL ) ; if ( ExceptionUtils . isCertPathBuilderException ( e . getCause ( ) ) ) return ExceptionUtils . createByKey ( e , isDefaultRepo ? "ERROR_FAILED_TO_CONNECT_CAUSED_BY_CERT" : "ERROR_FAILED_TO_CONNECT_REPO_CAUSED_BY_CERT" , repositoryLocation ) ; return ExceptionUtils . createByKey ( e , isDefaultRepo ? "ERROR_FAILED_TO_DOWNLOAD_ASSETS_FROM_DEFAULT_REPO" : "ERROR_FAILED_TO_DOWNLOAD_ASSETS_FROM_REPO" , InstallUtils . getResourceId ( installResource ) , InstallUtils . getResourceName ( installResource ) , repositoryLocation ) ; } if ( e instanceof RepositoryResourceException ) return ExceptionUtils . createByKey ( e , "ERROR_FAILED_TO_DOWNLOAD_ASSETS" , InstallUtils . getResourceId ( installResource ) , InstallUtils . getResourceName ( installResource ) ) ; if ( installResource . getType ( ) . equals ( ResourceType . FEATURE ) ) return createByKey ( InstallException . IO_FAILURE , e , "ERROR_FAILED_TO_DOWNLOAD_FEATURE" , installResource . getName ( ) , target ) ; if ( installResource . getType ( ) . equals ( ResourceType . IFIX ) ) return createByKey ( InstallException . IO_FAILURE , e , "ERROR_FAILED_TO_DOWNLOAD_IFIX" , installResource . getName ( ) , target ) ; if ( installResource . getType ( ) . equals ( ResourceType . PRODUCTSAMPLE ) ) return createByKey ( InstallException . IO_FAILURE , e , "ERROR_FAILED_TO_DOWNLOAD_SAMPLE" , installResource . getName ( ) , target ) ; if ( installResource . getType ( ) . equals ( ResourceType . OPENSOURCE ) ) return createByKey ( InstallException . IO_FAILURE , e , "ERROR_FAILED_TO_DOWNLOAD_OPENSOURCE" , installResource . getName ( ) , target ) ; return createByKey ( e , "ERROR_UNSUPPORTED" ) ; }
Create an install exception as a result of a fail to download exception