use of org.commonjava.indy.model.core.HostedRepository in project indy by Commonjava.
the class MeasuringStoreQuery method getAllHostedRepositories.
@Override
public List<HostedRepository> getAllHostedRepositories(String packageType) throws IndyDataException {
AtomicReference<IndyDataException> errorRef = new AtomicReference<>();
List<HostedRepository> result = metricsManager.wrapWithStandardMetrics(() -> {
try {
return query.getAllHostedRepositories(packageType);
} catch (IndyDataException e) {
errorRef.set(e);
}
return null;
}, () -> "getAllHostedRepositories");
IndyDataException error = errorRef.get();
if (error != null) {
throw error;
}
return result;
}
use of org.commonjava.indy.model.core.HostedRepository in project indy by Commonjava.
the class MeasuringStoreQuery method getHostedRepository.
@Override
public HostedRepository getHostedRepository(final String packageType, final String name) throws IndyDataException {
AtomicReference<IndyDataException> errorRef = new AtomicReference<>();
HostedRepository result = metricsManager.wrapWithStandardMetrics(() -> {
try {
return query.getHostedRepository(packageType, name);
} catch (IndyDataException e) {
errorRef.set(e);
}
return null;
}, () -> "getHostedRepository");
IndyDataException error = errorRef.get();
if (error != null) {
throw error;
}
return result;
}
use of org.commonjava.indy.model.core.HostedRepository in project indy by Commonjava.
the class RepoChangelogStoreTest method test.
@Test
public void test() throws Exception {
HostedRepository repo = new HostedRepository(MAVEN_PKG_KEY, newName());
final StoreKey hostedKey = repo.getKey();
repo = client.stores().create(repo, name.getMethodName(), HostedRepository.class);
repo.setAllowReleases(!repo.isAllowReleases());
client.stores().update(repo, name.getMethodName());
repo.setReadonly(true);
client.stores().update(repo, name.getMethodName());
List<ChangeEvent> logs = client.module(IndyRepoChangelogClientModule.class).getByStoreKey(repo.getKey());
final AtomicInteger createCount = new AtomicInteger(0);
final AtomicInteger updateCount = new AtomicInteger(0);
logs.forEach(c -> {
assertThat(c.getStoreKey(), equalTo(hostedKey.toString()));
if (c.getChangeType() == ChangeType.CREATE) {
createCount.getAndIncrement();
}
if (c.getChangeType() == ChangeType.UPDATE) {
updateCount.getAndIncrement();
}
});
assertThat(createCount.get(), equalTo(1));
assertThat(updateCount.get(), equalTo(2));
logs = client.module(IndyRepoChangelogClientModule.class).getAll();
final AtomicInteger updateCount2 = new AtomicInteger(0);
final AtomicInteger testRepoCount = new AtomicInteger(0);
logs.forEach(c -> {
if (c.getChangeType() == ChangeType.UPDATE) {
updateCount2.getAndIncrement();
}
if (c.getStoreKey().equals(hostedKey.toString())) {
testRepoCount.getAndIncrement();
}
});
assertThat(updateCount2.get(), equalTo(2));
assertThat(testRepoCount.get(), equalTo(3));
}
use of org.commonjava.indy.model.core.HostedRepository in project indy by Commonjava.
the class AuthoritativeIndexSettingManager method setAuthoritativeManager.
public void setAuthoritativeManager(@Observes final ArtifactStorePostUpdateEvent event) {
if (indexCfg == null || !indexCfg.isAuthoritativeIndex()) {
return;
}
final Collection<ArtifactStore> stores = event.getChanges();
stores.stream().filter(store -> store.getKey().getType() == StoreType.hosted).forEach(store -> {
final HostedRepository hosted = (HostedRepository) store;
if (hosted.isReadonly()) {
hosted.setAuthoritativeIndex(true);
} else {
hosted.setAuthoritativeIndex(false);
}
});
}
use of org.commonjava.indy.model.core.HostedRepository in project indy by Commonjava.
the class RepoProxyNPMMetaRewriteDisableTest method setupRepos.
@Before
public void setupRepos() throws Exception {
CONTENT_JQUERY = String.format(CONTENT_JQUERY_TEMPLATE, server.formatUrl(REPO_NAME));
server.expect(server.formatUrl(REPO_NAME, PATH_ROOT), 200, new ByteArrayInputStream(CONTENT_JQUERY.getBytes()));
server.expect(server.formatUrl(REPO_NAME, PATH_PACKAGE_JSON), 200, new ByteArrayInputStream(CONTENT_JQUERY.getBytes()));
CONTENT_ANGULAR_CORE = String.format(CONTENT_ANGULAR_CORE_TEMPLATE, server.formatUrl(REPO_NAME));
server.expect(server.formatUrl(REPO_NAME, PATH_SCOPED), 200, new ByteArrayInputStream(CONTENT_ANGULAR_CORE.getBytes()));
remote = client.stores().create(new RemoteRepository(PKG_TYPE_NPM, REPO_NAME, server.formatUrl(REPO_NAME)), "remote npmjs", RemoteRepository.class);
hosted = client.stores().create(new HostedRepository(PKG_TYPE_NPM, REPO_NAME), "hosted npmjs", HostedRepository.class);
REMOTE_REPO_PATH = normalize(fixture.getUrl(), "content/npm/remote", remote.getName());
HOSTED_REPO_PATH = normalize(fixture.getUrl(), "content/npm/hosted", hosted.getName());
}
Aggregations