Search in sources :

Example 11 with HostedRepository

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;
}
Also used : IndyDataException(org.commonjava.indy.data.IndyDataException) AtomicReference(java.util.concurrent.atomic.AtomicReference) HostedRepository(org.commonjava.indy.model.core.HostedRepository)

Example 12 with HostedRepository

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;
}
Also used : IndyDataException(org.commonjava.indy.data.IndyDataException) AtomicReference(java.util.concurrent.atomic.AtomicReference) HostedRepository(org.commonjava.indy.model.core.HostedRepository)

Example 13 with HostedRepository

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));
}
Also used : IndyRepoChangelogClientModule(org.commonjava.indy.changelog.client.IndyRepoChangelogClientModule) ChangeEvent(org.commonjava.auditquery.history.ChangeEvent) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) StoreKey(org.commonjava.indy.model.core.StoreKey) HostedRepository(org.commonjava.indy.model.core.HostedRepository) AbstractIndyFunctionalTest(org.commonjava.indy.ftest.core.AbstractIndyFunctionalTest) Test(org.junit.Test)

Example 14 with HostedRepository

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);
        }
    });
}
Also used : Inject(javax.inject.Inject) Logger(org.slf4j.Logger) ArtifactStore(org.commonjava.indy.model.core.ArtifactStore) HostedRepository(org.commonjava.indy.model.core.HostedRepository) Observes(javax.enterprise.event.Observes) Collection(java.util.Collection) LoggerFactory(org.slf4j.LoggerFactory) StoreType(org.commonjava.indy.model.core.StoreType) ApplicationScoped(javax.enterprise.context.ApplicationScoped) ArtifactStorePostUpdateEvent(org.commonjava.indy.change.event.ArtifactStorePostUpdateEvent) ArtifactStore(org.commonjava.indy.model.core.ArtifactStore) HostedRepository(org.commonjava.indy.model.core.HostedRepository)

Example 15 with HostedRepository

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());
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) RemoteRepository(org.commonjava.indy.model.core.RemoteRepository) HostedRepository(org.commonjava.indy.model.core.HostedRepository) Before(org.junit.Before)

Aggregations

HostedRepository (org.commonjava.indy.model.core.HostedRepository)169 Test (org.junit.Test)90 ByteArrayInputStream (java.io.ByteArrayInputStream)83 Group (org.commonjava.indy.model.core.Group)80 InputStream (java.io.InputStream)42 RemoteRepository (org.commonjava.indy.model.core.RemoteRepository)41 AbstractContentManagementTest (org.commonjava.indy.ftest.core.AbstractContentManagementTest)37 Before (org.junit.Before)37 StoreKey (org.commonjava.indy.model.core.StoreKey)32 Transfer (org.commonjava.maven.galley.model.Transfer)23 ConcreteResource (org.commonjava.maven.galley.model.ConcreteResource)19 ChangeSummary (org.commonjava.indy.audit.ChangeSummary)16 IndyDataException (org.commonjava.indy.data.IndyDataException)15 EventMetadata (org.commonjava.maven.galley.event.EventMetadata)15 PackageMetadata (org.commonjava.indy.pkg.npm.model.PackageMetadata)13 ArtifactStore (org.commonjava.indy.model.core.ArtifactStore)12 VersionMetadata (org.commonjava.indy.pkg.npm.model.VersionMetadata)11 IndyClientException (org.commonjava.indy.client.core.IndyClientException)10 IndyObjectMapper (org.commonjava.indy.model.core.io.IndyObjectMapper)10 IndyWorkflowException (org.commonjava.indy.IndyWorkflowException)9