class ArtifactDownloaderHandler {

    public void handle(Options options) {
        if (isOldApiParamSet(options)) {
            log.debug("Latest artifact resolution will be skipped due to configuration settings");
        } else if (isLatestArtifactDownloadEnabled(options)) {
            try {
                log.debug("Latest artifact will be downloaded");
                String groupId = options.getGroupId();
                String artifactId = options.getArtifactId();
                log.info("Downloading latest artifact with groupId '{}' artifactId '{}'", groupId, artifactId);
                DownloadOptions downloadOptions = downloadOptionsFactory.create(options);
                File apiJar = downloaderFactory.create(options).download(downloadOptions);
                ApiFileResolverParameter apiFileResolverParameter = new ApiFileResolverParameter(apiJar, options.getApiFilename());
                File swaggerFile = apiFileResolver.resolve(apiFileResolverParameter);
                options.setOldApiPath(swaggerFile.getAbsolutePath());
            } catch (UnauthorizedException e) {
                throw new LatestArtifactDownloadException("Cannot access Maven repository due to insufficient privileges. Consider providing username and password.", e);
            } catch (Exception e) {
                throw new LatestArtifactDownloadException("Error while downloading the latest version of the artifact", e);
            }
        } else if (isLatestArtifactDownloadWronglyConfigured(options)) {
            log.warn("Seems like latest artifact resolution is intended to be used but missing some of the parameters");
        }
    }

}