Search in sources :

Example 6 with RepositoryType

use of org.jboss.pnc.enums.RepositoryType in project pnc by project-ncl.

the class AbstractArtifactMapper method fillDeployAndPublicUrl.

private void fillDeployAndPublicUrl(org.jboss.pnc.model.Artifact artifactDB, Consumer<String> deployUrlSetter, Consumer<String> publicUrlSetter) {
    GlobalModuleGroup globalConfig = null;
    try {
        globalConfig = config.getGlobalConfig();
    } catch (ConfigurationParseException e) {
        logger.error("Cannot read configuration", e);
    }
    if (globalConfig == null) {
        return;
    }
    TargetRepository targetRepository = artifactDB.getTargetRepository();
    if (targetRepository == null) {
        logger.error("Artifact DB object does not have target repository set: {}", artifactDB);
        return;
    }
    RepositoryType repositoryType = targetRepository.getRepositoryType();
    if (repositoryType.equals(RepositoryType.MAVEN) || repositoryType.equals(RepositoryType.NPM)) {
        if (artifactDB.getDeployPath() == null || artifactDB.getDeployPath().equals("")) {
            deployUrlSetter.accept("");
            publicUrlSetter.accept("");
        } else {
            try {
                deployUrlSetter.accept(UrlUtils.buildUrl(globalConfig.getIndyUrl(), targetRepository.getRepositoryPath(), artifactDB.getDeployPath()));
                publicUrlSetter.accept(UrlUtils.buildUrl(globalConfig.getExternalIndyUrl(), targetRepository.getRepositoryPath(), artifactDB.getDeployPath()));
            } catch (MalformedURLException e) {
                logger.error("Cannot construct internal artifactDB URL.", e);
                deployUrlSetter.accept(null);
                publicUrlSetter.accept(null);
            }
        }
    } else {
        deployUrlSetter.accept(artifactDB.getOriginUrl());
        publicUrlSetter.accept(artifactDB.getOriginUrl());
    }
}
Also used : TargetRepository(org.jboss.pnc.model.TargetRepository) MalformedURLException(java.net.MalformedURLException) ConfigurationParseException(org.jboss.pnc.common.json.ConfigurationParseException) GlobalModuleGroup(org.jboss.pnc.common.json.GlobalModuleGroup) RepositoryType(org.jboss.pnc.enums.RepositoryType)

Example 7 with RepositoryType

use of org.jboss.pnc.enums.RepositoryType in project pnc by project-ncl.

the class IndyRepositorySession method getDownloadsTargetRepository.

private TargetRepository getDownloadsTargetRepository(TrackedContentEntryDTO download, IndyContentClientModule content) throws RepositoryManagerException {
    String identifier;
    String repoPath;
    StoreKey source = download.getStoreKey();
    RepositoryType repoType = toRepoType(source.getPackageType());
    if (repoType == RepositoryType.MAVEN || repoType == RepositoryType.NPM) {
        identifier = "indy-" + repoType.name().toLowerCase();
        repoPath = getTargetRepositoryPath(download, content);
    } else if (repoType == RepositoryType.GENERIC_PROXY) {
        identifier = "indy-http";
        repoPath = getGenericTargetRepositoryPath(source);
    } else {
        throw new RepositoryManagerException("Repository type " + repoType + " is not supported by Indy repo manager driver.");
    }
    if (!repoPath.endsWith("/")) {
        repoPath += '/';
    }
    return TargetRepository.newBuilder().identifier(identifier).repositoryType(repoType).repositoryPath(repoPath).temporaryRepo(false).build();
}
Also used : RepositoryType(org.jboss.pnc.enums.RepositoryType) RepositoryManagerException(org.jboss.pnc.spi.repositorymanager.RepositoryManagerException) StoreKey(org.commonjava.indy.model.core.StoreKey)

Aggregations

RepositoryType (org.jboss.pnc.enums.RepositoryType)7 StoreKey (org.commonjava.indy.model.core.StoreKey)2 ArtifactQuality (org.jboss.pnc.enums.ArtifactQuality)2 Artifact (org.jboss.pnc.model.Artifact)2 TargetRepository (org.jboss.pnc.model.TargetRepository)2 RepositoryManagerException (org.jboss.pnc.spi.repositorymanager.RepositoryManagerException)2 File (java.io.File)1 MalformedURLException (java.net.MalformedURLException)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 Iterator (java.util.Iterator)1 List (java.util.List)1 Map (java.util.Map)1 StopWatch (org.apache.commons.lang3.time.StopWatch)1 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)1 Condition (org.assertj.core.api.Condition)1 IndyClientException (org.commonjava.indy.client.core.IndyClientException)1 IndyContentClientModule (org.commonjava.indy.client.core.module.IndyContentClientModule)1 TrackedContentEntryDTO (org.commonjava.indy.folo.dto.TrackedContentEntryDTO)1