indy-repository-manager/src/main/java/org/jboss/pnc/indyrepositorymanager/IndyRepositorySession.java
private List<Artifact> processDownloads(TrackedContentDTO report) throws RepositoryManagerException {
        Logger logger = LoggerFactory.getLogger(getClass());

        IndyContentClientModule content;
        try {
            content = indy.content();
        } catch (IndyClientException e) {
            throw new RepositoryManagerException("Failed to retrieve Indy content module. Reason: %s", e, e.getMessage());
        }

        List<Artifact> deps = new ArrayList<>();

        Set<TrackedContentEntryDTO> downloads = report.getDownloads();
        if (downloads != null) {
            Map<StoreKey, Map<StoreKey, Set<String>>> toPromote = new HashMap<>();

            Map<String, StoreKey> promotionTargets = new HashMap<>();
            for (TrackedContentEntryDTO download : downloads) {
                String path = download.getPath();
                StoreKey source = download.getStoreKey();
                String packageType = source.getPackageType();
                if (ignoreContent(packageType, path)) {
                    logger.debug("Ignoring download (matched in ignored-suffixes): {} (From: {})", download.getPath(), source);
                    continue;
                }


                // If the entry is from a hosted repository (also shared-imports), it shouldn't be auto-promoted.
                // New binary imports will be coming from a remote repository...
                if (isExternalOrigin(source)) {
                    StoreKey target = null;
                    Map<StoreKey, Set<String>> sources = null;
                    Set<String> paths = null;

                    // this has not been captured, so promote it.
                    switch (packageType) {
                        case MAVEN_PKG_KEY:
                        case NPM_PKG_KEY:
                            target = getPromotionTarget(packageType, promotionTargets);
                            sources = toPromote.computeIfAbsent(target, t -> new HashMap<>());
                            paths = sources.computeIfAbsent(source, s -> new HashSet<>());

                            paths.add(download.getPath());
                            if (MAVEN_PKG_KEY.equals(packageType)) {
                                paths.add(download.getPath() + ".md5");
                                paths.add(download.getPath() + ".sha1");
                            }
                            break;

                        case GENERIC_PKG_KEY:
                            String remoteName = source.getName();
                            String hostedName;
                            if (remoteName.startsWith("r-")) {
                                hostedName = "h-" + remoteName.substring(2);
                            } else {
                                logger.warn("Unexpected generic http remote repo name {}. Using it for hosted repo "
                                        + "without change, but it probably doesn't exist.", remoteName);
                                hostedName = remoteName;
                            }
                            target = new StoreKey(source.getPackageType(), StoreType.hosted, hostedName);
                            sources = toPromote.computeIfAbsent(target, t -> new HashMap<>());
                            paths = sources.computeIfAbsent(source, s -> new HashSet<>());

                            paths.add(download.getPath());
                            break;

                        default:
                            // do not promote anything else anywhere
                            break;
                    }
                }

                String identifier = computeIdentifier(download);

                logger.info("Recording download: {}", identifier);

                String originUrl = download.getOriginUrl();
                if (originUrl == null) {
                    // this is from a hosted repository, either shared-imports or a build, or something like that.
                    originUrl = download.getLocalUrl();
                }

                TargetRepository targetRepository = getDownloadsTargetRepository(download, content);

                Artifact.Builder artifactBuilder = Artifact.Builder.newBuilder()
                        .md5(download.getMd5())
                        .sha1(download.getSha1())
                        .sha256(download.getSha256())
                        .size(download.getSize())
                        .deployPath(download.getPath())
                        .originUrl(originUrl)
                        .importDate(Date.from(Instant.now()))
                        .filename(new File(path).getName())
                        .identifier(identifier)
                        .targetRepository(targetRepository);

                Artifact artifact = validateArtifact(artifactBuilder.build());
                deps.add(artifact);
            }

            for (Map.Entry<StoreKey, Map<StoreKey, Set<String>>> targetToSources : toPromote.entrySet()) {
                StoreKey target = targetToSources.getKey();
                for (Map.Entry<StoreKey, Set<String>> sourceToPaths : targetToSources.getValue().entrySet()) {
                    StoreKey source = sourceToPaths.getKey();
                    PathsPromoteRequest req = new PathsPromoteRequest(source, target, sourceToPaths.getValue()).setPurgeSource(false);
                    // set read-only only the generic http proxy hosted repos, not shared-imports
                    doPromoteByPath(req, GENERIC_PKG_KEY.equals(target.getPackageType()));
                }
            }
        }

        return deps;
    }
private List<Artifact> processDownloads(TrackedContentDTO report) throws RepositoryManagerException {
        Logger logger = LoggerFactory.getLogger(getClass());

        IndyContentClientModule content;
        try {
            content = indy.content();
        } catch (IndyClientException e) {
            throw new RepositoryManagerException("Failed to retrieve Indy content module. Reason: %s", e, e.getMessage());
        }

        List<Artifact> deps = new ArrayList<>();

        Set<TrackedContentEntryDTO> downloads = report.getDownloads();
        if (downloads != null) {
            Map<StoreKey, Map<StoreKey, Set<String>>> toPromote = new HashMap<>();

            Map<String, StoreKey> promotionTargets = new HashMap<>();
            for (TrackedContentEntryDTO download : downloads) {
                String path = download.getPath();
                StoreKey source = download.getStoreKey();
                String packageType = source.getPackageType();
                if (ignoreContent(packageType, path)) {
                    logger.debug("Ignoring download (matched in ignored-suffixes): {} (From: {})", download.getPath(), source);
                    continue;
                }


                // If the entry is from a hosted repository (also shared-imports), it shouldn't be auto-promoted.
                // New binary imports will be coming from a remote repository...
                if (isExternalOrigin(source)) {
                    StoreKey target = null;
                    Map<StoreKey, Set<String>> sources = null;
                    Set<String> paths = null;

                    // this has not been captured, so promote it.
                    switch (packageType) {
                        case MAVEN_PKG_KEY:
                        case NPM_PKG_KEY:
                            target = getPromotionTarget(packageType, promotionTargets);
                            sources = toPromote.computeIfAbsent(target, t -> new HashMap<>());
                            paths = sources.computeIfAbsent(source, s -> new HashSet<>());

                            paths.add(download.getPath());
                            if (MAVEN_PKG_KEY.equals(packageType)) {
                                paths.add(download.getPath() + ".md5");
                                paths.add(download.getPath() + ".sha1");
                            }
                            break;

                        case GENERIC_PKG_KEY:
                            String remoteName = source.getName();
                            String hostedName;
                            if (remoteName.startsWith("r-")) {
                                hostedName = "h-" + remoteName.substring(2);
                            } else {
                                logger.warn("Unexpected generic http remote repo name {}. Using it for hosted repo "
                                        + "without change, but it probably doesn't exist.", remoteName);
                                hostedName = remoteName;
                            }
                            target = new StoreKey(source.getPackageType(), StoreType.hosted, hostedName);
                            sources = toPromote.computeIfAbsent(target, t -> new HashMap<>());
                            paths = sources.computeIfAbsent(source, s -> new HashSet<>());

                            paths.add(download.getPath());
                            break;

                        default:
                            // do not promote anything else anywhere
                            break;
                    }
                }

                String identifier = computeIdentifier(download);

                logger.info("Recording download: {}", identifier);

                String originUrl = download.getOriginUrl();
                if (originUrl == null) {
                    // this is from a hosted repository, either shared-imports or a build, or something like that.
                    originUrl = download.getLocalUrl();
                }

                TargetRepository targetRepository = getDownloadsTargetRepository(download, content);

                Artifact.Builder artifactBuilder = Artifact.Builder.newBuilder()
                        .md5(download.getMd5())
                        .sha1(download.getSha1())
                        .sha256(download.getSha256())
                        .size(download.getSize())
                        .deployPath(download.getPath())
                        .originUrl(originUrl)
                        .importDate(Date.from(Instant.now()))
                        .filename(new File(path).getName())
                        .identifier(identifier)
                        .targetRepository(targetRepository);

                Artifact artifact = validateArtifact(artifactBuilder.build());
                deps.add(artifact);
            }

            for (Map.Entry<StoreKey, Map<StoreKey, Set<String>>> targetToSources : toPromote.entrySet()) {
                StoreKey target = targetToSources.getKey();
                for (Map.Entry<StoreKey, Set<String>> sourceToPaths : targetToSources.getValue().entrySet()) {
                    StoreKey source = sourceToPaths.getKey();
                    PathsPromoteRequest req = new PathsPromoteRequest(source, target, sourceToPaths.getValue()).setPurgeSource(false);
                    // set read-only only the generic http proxy hosted repos, not shared-imports
                    doPromoteByPath(req, GENERIC_PKG_KEY.equals(target.getPackageType()));
                }
            }
        }

        return deps;
    }
private List < Artifact > processDownloads ( TrackedContentDTO report ) throws RepositoryManagerException { Logger logger = LoggerFactory . getLogger ( getClass ( ) ) ; IndyContentClientModule content ; try { content = indy . content ( ) ; } catch ( IndyClientException e ) { throw new RepositoryManagerException ( "Failed to retrieve Indy content module. Reason: %s" , e , e . getMessage ( ) ) ; } List < Artifact > deps = new ArrayList <> ( ) ; Set < TrackedContentEntryDTO > downloads = report . getDownloads ( ) ; if ( downloads != null ) { Map < StoreKey , Map < StoreKey , Set < String > > > toPromote = new HashMap <> ( ) ; Map < String , StoreKey > promotionTargets = new HashMap <> ( ) ; for ( TrackedContentEntryDTO download : downloads ) { String path = download . getPath ( ) ; StoreKey source = download . getStoreKey ( ) ; String packageType = source . getPackageType ( ) ; if ( ignoreContent ( packageType , path ) ) { logger . debug ( "Ignoring download (matched in ignored-suffixes): {} (From: {})" , download . getPath ( ) , source ) ; continue ; } // If the entry is from a hosted repository (also shared-imports), it shouldn't be auto-promoted. // New binary imports will be coming from a remote repository... if ( isExternalOrigin ( source ) ) { StoreKey target = null ; Map < StoreKey , Set < String > > sources = null ; Set < String > paths = null ; // this has not been captured, so promote it. switch ( packageType ) { case MAVEN_PKG_KEY : case NPM_PKG_KEY : target = getPromotionTarget ( packageType , promotionTargets ) ; sources = toPromote . computeIfAbsent ( target , t -> new HashMap <> ( ) ) ; paths = sources . computeIfAbsent ( source , s -> new HashSet <> ( ) ) ; paths . add ( download . getPath ( ) ) ; if ( MAVEN_PKG_KEY . equals ( packageType ) ) { paths . add ( download . getPath ( ) + ".md5" ) ; paths . add ( download . getPath ( ) + ".sha1" ) ; } break ; case GENERIC_PKG_KEY : String remoteName = source . getName ( ) ; String hostedName ; if ( remoteName . startsWith ( "r-" ) ) { hostedName = "h-" + remoteName . substring ( 2 ) ; } else { logger . warn ( "Unexpected generic http remote repo name {}. Using it for hosted repo " + "without change, but it probably doesn't exist." , remoteName ) ; hostedName = remoteName ; } target = new StoreKey ( source . getPackageType ( ) , StoreType . hosted , hostedName ) ; sources = toPromote . computeIfAbsent ( target , t -> new HashMap <> ( ) ) ; paths = sources . computeIfAbsent ( source , s -> new HashSet <> ( ) ) ; paths . add ( download . getPath ( ) ) ; break ; default : // do not promote anything else anywhere break ; } } String identifier = computeIdentifier ( download ) ; logger . info ( "Recording download: {}" , identifier ) ; String originUrl = download . getOriginUrl ( ) ; if ( originUrl == null ) { // this is from a hosted repository, either shared-imports or a build, or something like that. originUrl = download . getLocalUrl ( ) ; } TargetRepository targetRepository = getDownloadsTargetRepository ( download , content ) ; Artifact . Builder artifactBuilder = Artifact . Builder . newBuilder ( ) . md5 ( download . getMd5 ( ) ) . sha1 ( download . getSha1 ( ) ) . sha256 ( download . getSha256 ( ) ) . size ( download . getSize ( ) ) . deployPath ( download . getPath ( ) ) . originUrl ( originUrl ) . importDate ( Date . from ( Instant . now ( ) ) ) . filename ( new File ( path ) . getName ( ) ) . identifier ( identifier ) . targetRepository ( targetRepository ) ; Artifact artifact = validateArtifact ( artifactBuilder . build ( ) ) ; deps . add ( artifact ) ; } for ( Map . Entry < StoreKey , Map < StoreKey , Set < String > > > targetToSources : toPromote . entrySet ( ) ) { StoreKey target = targetToSources . getKey ( ) ; for ( Map . Entry < StoreKey , Set < String > > sourceToPaths : targetToSources . getValue ( ) . entrySet ( ) ) { StoreKey source = sourceToPaths . getKey ( ) ; PathsPromoteRequest req = new PathsPromoteRequest ( source , target , sourceToPaths . getValue ( ) ) . setPurgeSource ( false ) ; // set read-only only the generic http proxy hosted repos, not shared-imports doPromoteByPath ( req , GENERIC_PKG_KEY . equals ( target . getPackageType ( ) ) ) ; } } } return deps ; }
Promote all build dependencies NOT ALREADY CAPTURED to the hosted repository holding store for the shared imports and
return dependency artifacts meta data.

@param report The tracking report that contains info about artifacts downloaded by the build
@return List of dependency artifacts meta data
@throws RepositoryManagerException In case of a client API transport error or an error during promotion of artifacts
Promote all build dependencies NOT ALREADY CAPTURED to the hosted repository holding store for the shared imports and return dependency artifacts meta data .