Search in sources :

Example 71 with HostedRepository

use of org.commonjava.indy.model.core.HostedRepository in project indy by Commonjava.

the class AbstractFoloUrlsTest method before.

@Before
public void before() throws Exception {
    content = client.module(IndyFoloContentClientModule.class);
    admin = client.module(IndyFoloAdminClientModule.class);
    if (!createStandardTestStructures()) {
        return;
    }
    final String changelog = "Create test structures";
    final HostedRepository hosted = this.client.stores().create(new HostedRepository(STORE), changelog, HostedRepository.class);
    Group g;
    if (client.stores().exists(group, PUBLIC)) {
        System.out.println("Loading pre-existing public group.");
        g = client.stores().load(group, PUBLIC, Group.class);
    } else {
        System.out.println("Creating new group 'public'");
        g = client.stores().create(new Group(PUBLIC), changelog, Group.class);
    }
    g.setConstituents(Collections.singletonList(hosted.getKey()));
    client.stores().update(g, changelog);
}
Also used : Group(org.commonjava.indy.model.core.Group) IndyFoloAdminClientModule(org.commonjava.indy.folo.client.IndyFoloAdminClientModule) IndyFoloContentClientModule(org.commonjava.indy.folo.client.IndyFoloContentClientModule) HostedRepository(org.commonjava.indy.model.core.HostedRepository) Before(org.junit.Before)

Example 72 with HostedRepository

use of org.commonjava.indy.model.core.HostedRepository in project indy by Commonjava.

the class AbstractFoloContentManagementTest method before.

@Before
public void before() throws Exception {
    final String changelog = "Setup: " + name.getMethodName();
    final HostedRepository hosted = this.client.stores().create(new HostedRepository(STORE), changelog, HostedRepository.class);
    RemoteRepository central = null;
    if (client.stores().exists(remote, CENTRAL)) {
        client.stores().delete(remote, CENTRAL, "removing existing remote:central definition");
    }
    central = client.stores().create(new RemoteRepository(CENTRAL, centralServer.getBaseUri()), changelog, RemoteRepository.class);
    Group g;
    if (client.stores().exists(group, PUBLIC)) {
        g = client.stores().load(group, PUBLIC, Group.class);
    } else {
        g = client.stores().create(new Group(PUBLIC), changelog, Group.class);
    }
    g.setConstituents(Arrays.asList(hosted.getKey(), central.getKey()));
    client.stores().update(g, changelog);
}
Also used : Group(org.commonjava.indy.model.core.Group) RemoteRepository(org.commonjava.indy.model.core.RemoteRepository) HostedRepository(org.commonjava.indy.model.core.HostedRepository) Before(org.junit.Before)

Example 73 with HostedRepository

use of org.commonjava.indy.model.core.HostedRepository in project indy by Commonjava.

the class AbstractTrackingReportTest method before.

@Before
public void before() throws Exception {
    if (!createStandardStores()) {
        return;
    }
    final String changelog = "Setup " + name.getMethodName();
    final HostedRepository hosted = this.client.stores().create(new HostedRepository(STORE), changelog, HostedRepository.class);
    RemoteRepository central = null;
    if (!client.stores().exists(remote, CENTRAL)) {
        central = client.stores().create(new RemoteRepository(CENTRAL, "http://repo.maven.apache.org/maven2/"), changelog, RemoteRepository.class);
    } else {
        central = client.stores().load(remote, CENTRAL, RemoteRepository.class);
    }
    Group g;
    if (client.stores().exists(group, PUBLIC)) {
        g = client.stores().load(group, PUBLIC, Group.class);
    } else {
        g = client.stores().create(new Group(PUBLIC), changelog, Group.class);
    }
    g.setConstituents(Arrays.asList(hosted.getKey(), central.getKey()));
    client.stores().update(g, changelog);
}
Also used : Group(org.commonjava.indy.model.core.Group) RemoteRepository(org.commonjava.indy.model.core.RemoteRepository) HostedRepository(org.commonjava.indy.model.core.HostedRepository) Before(org.junit.Before)

Example 74 with HostedRepository

use of org.commonjava.indy.model.core.HostedRepository in project indy by Commonjava.

the class AutoProxCatalogManager method createHostedRepository.

public HostedRepository createHostedRepository(final StoreKey key) throws AutoProxRuleException {
    if (!checkEnabled()) {
        throw new AutoProxRuleException("AutoProx is disabled");
    }
    final AutoProxRule rule = getRuleMatching(key);
    try {
        if (rule != null) {
            HostedRepository repo = rule.createHostedRepository(key);
            repo.setMetadata(ArtifactStore.METADATA_ORIGIN, AUTOPROX_ORIGIN);
            return repo;
        }
        return null;
    } catch (final Exception e) {
        throw new AutoProxRuleException("Failed to create remote repository for: %s. Reason: %s", e, key, e.getMessage());
    }
}
Also used : MalformedURLException(java.net.MalformedURLException) IOException(java.io.IOException) HostedRepository(org.commonjava.indy.model.core.HostedRepository)

Example 75 with HostedRepository

use of org.commonjava.indy.model.core.HostedRepository in project indy by Commonjava.

the class AutoProxDataManagerDecorator method getHostedRepository.

private HostedRepository getHostedRepository(final StoreKey key, final StoreKey impliedBy) throws IndyDataException {
    HostedRepository repo = (HostedRepository) dataManager.getArtifactStore(key);
    if (!catalog.isEnabled()) {
        logger.debug("AutoProx decorator disabled; returning: {}", repo);
        return repo;
    }
    logger.debug("AutoProx decorator active");
    if (repo == null) {
        logger.info("AutoProx: creating repository for: {}", key);
        try {
            repo = catalog.createHostedRepository(key);
        } catch (final AutoProxRuleException e) {
            throw new IndyDataException("[AUTOPROX] Failed to create new hosted repository from factory matching: '%s'. Reason: %s", e, key, e.getMessage());
        }
        if (repo != null) {
            final ChangeSummary changeSummary = new ChangeSummary(ChangeSummary.SYSTEM_USER, "AUTOPROX: Creating hosted repository for: '" + key + "'");
            final EventMetadata eventMetadata = new EventMetadata().set(StoreDataManager.EVENT_ORIGIN, AutoProxConstants.STORE_ORIGIN).set(AutoProxConstants.ORIGINATING_STORE, impliedBy == null ? repo.getKey() : impliedBy);
            dataManager.storeArtifactStore(repo, changeSummary, false, true, eventMetadata);
        }
    }
    return repo;
}
Also used : IndyDataException(org.commonjava.indy.data.IndyDataException) ChangeSummary(org.commonjava.indy.audit.ChangeSummary) HostedRepository(org.commonjava.indy.model.core.HostedRepository) EventMetadata(org.commonjava.maven.galley.event.EventMetadata)

Aggregations

HostedRepository (org.commonjava.indy.model.core.HostedRepository)77 Test (org.junit.Test)47 Group (org.commonjava.indy.model.core.Group)44 ByteArrayInputStream (java.io.ByteArrayInputStream)37 Transfer (org.commonjava.maven.galley.model.Transfer)21 RemoteRepository (org.commonjava.indy.model.core.RemoteRepository)18 ConcreteResource (org.commonjava.maven.galley.model.ConcreteResource)15 Before (org.junit.Before)15 InputStream (java.io.InputStream)13 ChangeSummary (org.commonjava.indy.audit.ChangeSummary)11 EventMetadata (org.commonjava.maven.galley.event.EventMetadata)11 IndyObjectMapper (org.commonjava.indy.model.core.io.IndyObjectMapper)10 AbstractContentManagementTest (org.commonjava.indy.ftest.core.AbstractContentManagementTest)9 PackageMetadata (org.commonjava.indy.pkg.npm.model.PackageMetadata)7 PathsPromoteRequest (org.commonjava.indy.promote.model.PathsPromoteRequest)7 PathsPromoteResult (org.commonjava.indy.promote.model.PathsPromoteResult)7 Metadata (org.apache.maven.artifact.repository.metadata.Metadata)6 Versioning (org.apache.maven.artifact.repository.metadata.Versioning)6 MetadataXpp3Reader (org.apache.maven.artifact.repository.metadata.io.xpp3.MetadataXpp3Reader)6 IndyDataException (org.commonjava.indy.data.IndyDataException)6