Search in sources :

Example 36 with HostedRepository

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

the class NoPreExistingPaths_GroupWithOneOfTwoHosts_RuleTest method start.

@Override
public void start() throws Throwable {
    super.start();
    hostTarget1 = new HostedRepository("hostTarget1");
    hostTarget1 = client.stores().create(hostTarget1, "Creating first host target", HostedRepository.class);
    hostTarget2 = new HostedRepository("hostTarget2");
    hostTarget2 = client.stores().create(hostTarget2, "Creating secondary host target", HostedRepository.class);
}
Also used : HostedRepository(org.commonjava.indy.model.core.HostedRepository)

Example 37 with HostedRepository

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

the class NoPreExistingPaths_RuleTest method start.

@Override
public void start() throws Throwable {
    super.start();
    otherSource = new HostedRepository("otherSource");
    otherSource = client.stores().create(otherSource, "Creating secondary content source", HostedRepository.class);
    other = new Group("other", otherSource.getKey());
    other = client.stores().create(other, "Creating secondary content group", Group.class);
    Logger logger = LoggerFactory.getLogger(getClass());
    logger.info("{} contains members: {}", other, other.getConstituents());
}
Also used : Group(org.commonjava.indy.model.core.Group) Logger(org.slf4j.Logger) HostedRepository(org.commonjava.indy.model.core.HostedRepository)

Example 38 with HostedRepository

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

the class CassandraStoreDataManager method toExtra.

private Map<String, String> toExtra(ArtifactStore store) {
    Map<String, String> extras = new HashMap<>();
    if (store instanceof AbstractRepository) {
        AbstractRepository repository = (AbstractRepository) store;
        putValueIntoExtra(CassandraStoreUtil.ALLOW_SNAPSHOTS, repository.isAllowSnapshots(), extras);
        putValueIntoExtra(CassandraStoreUtil.ALLOW_RELEASES, repository.isAllowReleases(), extras);
    }
    if (store instanceof HostedRepository) {
        HostedRepository hostedRepository = (HostedRepository) store;
        putValueIntoExtra(CassandraStoreUtil.STORAGE, hostedRepository.getStorage(), extras);
        putValueIntoExtra(CassandraStoreUtil.READONLY, hostedRepository.isReadonly(), extras);
        putValueIntoExtra(CassandraStoreUtil.SNAPSHOT_TIMEOUT_SECONDS, hostedRepository.getSnapshotTimeoutSeconds(), extras);
    }
    if (store instanceof RemoteRepository) {
        RemoteRepository remoteRepository = (RemoteRepository) store;
        putValueIntoExtra(CassandraStoreUtil.URL, remoteRepository.getUrl(), extras);
        putValueIntoExtra(CassandraStoreUtil.HOST, remoteRepository.getHost(), extras);
        putValueIntoExtra(CassandraStoreUtil.PORT, remoteRepository.getPort(), extras);
        putValueIntoExtra(CassandraStoreUtil.USER, remoteRepository.getUser(), extras);
        putValueIntoExtra(CassandraStoreUtil.PASSWORD, remoteRepository.getPassword(), extras);
        putValueIntoExtra(CassandraStoreUtil.PROXY_HOST, remoteRepository.getProxyHost(), extras);
        putValueIntoExtra(CassandraStoreUtil.PROXY_PORT, remoteRepository.getProxyPort(), extras);
        putValueIntoExtra(CassandraStoreUtil.PROXY_USER, remoteRepository.getProxyUser(), extras);
        putValueIntoExtra(CassandraStoreUtil.PROXY_PASSWORD, remoteRepository.getProxyPassword(), extras);
        putValueIntoExtra(CassandraStoreUtil.KEY_CERT_PEM, remoteRepository.getKeyCertPem(), extras);
        putValueIntoExtra(CassandraStoreUtil.KEY_PASSWORD, remoteRepository.getKeyPassword(), extras);
        putValueIntoExtra(CassandraStoreUtil.SERVER_CERT_PEM, remoteRepository.getServerCertPem(), extras);
        putValueIntoExtra(CassandraStoreUtil.PREFETCH_RESCAN_TIMESTAMP, remoteRepository.getPrefetchRescanTimestamp(), extras);
        putValueIntoExtra(CassandraStoreUtil.METADATA_TIMEOUT_SECONDS, remoteRepository.getMetadataTimeoutSeconds(), extras);
        putValueIntoExtra(CassandraStoreUtil.CACHE_TIMEOUT_SECONDS, remoteRepository.getCacheTimeoutSeconds(), extras);
        putValueIntoExtra(CassandraStoreUtil.TIMEOUT_SECONDS, remoteRepository.getTimeoutSeconds(), extras);
        putValueIntoExtra(CassandraStoreUtil.MAX_CONNECTIONS, remoteRepository.getMaxConnections(), extras);
        putValueIntoExtra(CassandraStoreUtil.NFC_TIMEOUT_SECONDS, remoteRepository.getNfcTimeoutSeconds(), extras);
        putValueIntoExtra(CassandraStoreUtil.PASS_THROUGH, remoteRepository.isPassthrough(), extras);
        putValueIntoExtra(CassandraStoreUtil.PREFETCH_RESCAN, remoteRepository.isPrefetchRescan(), extras);
        putValueIntoExtra(CassandraStoreUtil.IGNORE_HOST_NAME_VERIFICATION, remoteRepository.isIgnoreHostnameVerification(), extras);
    }
    if (store instanceof Group) {
        Group group = (Group) store;
        putValueIntoExtra(CassandraStoreUtil.CONSTITUENTS, group.getConstituents(), extras);
        putValueIntoExtra(CassandraStoreUtil.PREPEND_CONSTITUENT, group.isPrependConstituent(), extras);
    }
    return extras;
}
Also used : Group(org.commonjava.indy.model.core.Group) HashMap(java.util.HashMap) AbstractRepository(org.commonjava.indy.model.core.AbstractRepository) RemoteRepository(org.commonjava.indy.model.core.RemoteRepository) HostedRepository(org.commonjava.indy.model.core.HostedRepository)

Example 39 with HostedRepository

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

the class StoreDataSetupAction method start.

@Override
public void start() throws IndyLifecycleException {
    final ChangeSummary summary = new ChangeSummary(ChangeSummary.SYSTEM_USER, "Initializing default data.");
    try {
        logger.info("Verfiying that Indy basic stores are installed...");
        storeManager.install();
        if (storeManager.query().getRemoteRepository(MAVEN_PKG_KEY, "central") == null) {
            final RemoteRepository central = new RemoteRepository(MAVEN_PKG_KEY, "central", "https://repo.maven.apache.org/maven2/");
            central.setCacheTimeoutSeconds(86400);
            storeManager.storeArtifactStore(central, summary, true, true, new EventMetadata().set(StoreDataManager.EVENT_ORIGIN, DEFAULT_SETUP));
        }
        if (storeManager.query().getHostedRepository(MAVEN_PKG_KEY, "local-deployments") == null) {
            final HostedRepository local = new HostedRepository(MAVEN_PKG_KEY, "local-deployments");
            local.setAllowReleases(true);
            local.setAllowSnapshots(true);
            local.setSnapshotTimeoutSeconds(86400);
            storeManager.storeArtifactStore(local, summary, true, true, new EventMetadata().set(StoreDataManager.EVENT_ORIGIN, DEFAULT_SETUP));
        }
        if (storeManager.query().getGroup(MAVEN_PKG_KEY, "public") == null) {
            final Group pub = new Group(MAVEN_PKG_KEY, "public");
            pub.addConstituent(new StoreKey(MAVEN_PKG_KEY, StoreType.remote, "central"));
            pub.addConstituent(new StoreKey(MAVEN_PKG_KEY, StoreType.hosted, "local-deployments"));
            storeManager.storeArtifactStore(pub, summary, true, true, new EventMetadata().set(StoreDataManager.EVENT_ORIGIN, DEFAULT_SETUP));
        }
    } catch (final IndyDataException e) {
        throw new RuntimeException("Failed to boot indy components: " + e.getMessage(), e);
    }
}
Also used : IndyDataException(org.commonjava.indy.data.IndyDataException) Group(org.commonjava.indy.model.core.Group) RemoteRepository(org.commonjava.indy.model.core.RemoteRepository) ChangeSummary(org.commonjava.indy.audit.ChangeSummary) StoreKey(org.commonjava.indy.model.core.StoreKey) EventMetadata(org.commonjava.maven.galley.event.EventMetadata) HostedRepository(org.commonjava.indy.model.core.HostedRepository)

Example 40 with HostedRepository

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

the class DefaultDownloadManagerTest method getTransferFromNotAllowedDeletionStore_DownloadOp_ThrowException.

@Test(expected = IOException.class)
public void getTransferFromNotAllowedDeletionStore_DownloadOp_ThrowException() throws Exception {
    ChangeSummary summary = new ChangeSummary(ChangeSummary.SYSTEM_USER, "Test setup");
    HostedRepository hosted = new HostedRepository(MAVEN_PKG_KEY, "one");
    hosted.setReadonly(true);
    storeManager.storeArtifactStore(hosted, summary, false, true, new EventMetadata());
    String originalString = "This is a test";
    final String path = "/path/path";
    Transfer transfer = downloadManager.getStorageReference(hosted, path, TransferOperation.DOWNLOAD);
    try (OutputStream out = transfer.openOutputStream(TransferOperation.UPLOAD)) {
        out.write(originalString.getBytes());
    }
    assertThat(transfer.exists(), equalTo(true));
    transfer.delete();
}
Also used : OutputStream(java.io.OutputStream) Transfer(org.commonjava.maven.galley.model.Transfer) ChangeSummary(org.commonjava.indy.audit.ChangeSummary) HostedRepository(org.commonjava.indy.model.core.HostedRepository) EventMetadata(org.commonjava.maven.galley.event.EventMetadata) Test(org.junit.Test)

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