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());
}
}
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();
}
Aggregations