use of org.commonjava.indy.httprox.handler.AbstractProxyRepositoryCreator in project indy by Commonjava.
the class ProxyResponseHelper method getRemoteRepositoryName.
/**
* if repo with this name already exists, we need to use a different name
*/
private String getRemoteRepositoryName(URL url) throws IndyDataException {
final String name = repoCreator.formatId(url.getHost(), getPort(url), 0, null, StoreType.remote);
logger.debug("Looking for remote repo starts with name: {}", name);
AbstractProxyRepositoryCreator abstractProxyRepositoryCreator = null;
if (repoCreator instanceof AbstractProxyRepositoryCreator) {
abstractProxyRepositoryCreator = (AbstractProxyRepositoryCreator) repoCreator;
}
if (abstractProxyRepositoryCreator == null) {
return name;
}
Predicate<ArtifactStore> filter = abstractProxyRepositoryCreator.getNameFilter(name);
List<String> l = storeManager.query().getAllRemoteRepositories(GENERIC_PKG_KEY).stream().filter(filter).map(repository -> repository.getName()).collect(Collectors.toList());
if (l.isEmpty()) {
return name;
}
return abstractProxyRepositoryCreator.getNextName(l);
}
use of org.commonjava.indy.httprox.handler.AbstractProxyRepositoryCreator in project indy by Commonjava.
the class AbstractProxyRepositoryCreatorTest method testGetDistinctName.
@Ignore
@Test
public void testGetDistinctName() {
AbstractProxyRepositoryCreator creator = new AbstractProxyRepositoryCreator() {
@Override
public ProxyCreationResult create(String trackingID, String name, String baseUrl, UrlInfo urlInfo, UserPass userPass, Logger logger) {
return null;
}
};
String host = "127-0-0-1";
String port = "80";
List<String> names = new ArrayList<>();
String name_0 = "httprox_" + host + "_" + port;
String name_1 = name_0 + "_1";
String name_2 = name_0 + "_2";
String name_3 = name_0 + "_3";
String name_4 = name_0 + "_4";
names.add(name_0);
String name = creator.getNextName(names);
assertThat(name, equalTo(name_1));
names.add(name_2);
names.add(name_1);
names.add(name_3);
name = creator.getNextName(names);
assertThat(name, equalTo(name_4));
}
Aggregations