Search in sources :

Example 26 with HostedRepository

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

the class HostedGenerateMissingChecksumTest method setupTest.

@Before
public void setupTest() throws Exception {
    String change = "setup";
    hosted = client.stores().create(new HostedRepository("maven", HOSTED), change, HostedRepository.class);
    client.content().store(hosted.getKey(), POM_PATH, new ByteArrayInputStream(POM_CONTENT.getBytes()));
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) HostedRepository(org.commonjava.indy.model.core.HostedRepository) Before(org.junit.Before)

Example 27 with HostedRepository

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

the class ReaonlyHostedStoreFileTest method storeFileNotAllowed.

@Test
public void storeFileNotAllowed() throws Exception {
    final String content = "This is a test: " + System.nanoTime();
    InputStream stream = new ByteArrayInputStream(content.getBytes());
    final String path = "/path/to/foo.class";
    final String repoName = "test-hosted";
    HostedRepository repo = new HostedRepository(repoName);
    repo.setReadonly(true);
    repo = client.stores().create(repo, name.getMethodName(), HostedRepository.class);
    assertThat(client.content().exists(hosted, repoName, path), equalTo(false));
    try {
        client.content().store(hosted, repoName, path, stream);
    } catch (IndyClientException e) {
        assertThat(e.getStatusCode(), equalTo(ApplicationStatus.METHOD_NOT_ALLOWED.code()));
    }
    assertThat(client.content().exists(hosted, repoName, path), equalTo(false));
    repo.setReadonly(false);
    client.stores().update(repo, name.getMethodName());
    stream = new ByteArrayInputStream(content.getBytes());
    client.content().store(hosted, repoName, path, stream);
    assertThat(client.content().exists(hosted, repoName, path), equalTo(true));
    final InputStream is = client.content().get(hosted, repoName, path);
    final String result = IOUtils.toString(is);
    is.close();
    assertThat(result, equalTo(content));
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) IndyClientException(org.commonjava.indy.client.core.IndyClientException) HostedRepository(org.commonjava.indy.model.core.HostedRepository) Test(org.junit.Test) AbstractContentManagementTest(org.commonjava.indy.ftest.core.AbstractContentManagementTest)

Example 28 with HostedRepository

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

the class HostedMetadataMergeSnapshotTest method setupRepos.

@Before
public void setupRepos() throws IndyClientException {
    String message = "test setup";
    hosted = new HostedRepository(PKG_TYPE_MAVEN, HOSTED_A_NAME);
    hosted.setAllowSnapshots(true);
    hosted = client.stores().create(hosted, message, HostedRepository.class);
    aPomPath = POM_PATH_TEMPLATE.replaceAll("%version%", A_VERSION);
    aPomContent = POM_CONTENT_TEMPLATE.replaceAll("%version%", A_VERSION);
    client.content().store(hosted.getKey(), aPomPath, new ByteArrayInputStream(aPomContent.getBytes()));
    bPomPath = POM_PATH_TEMPLATE.replaceAll("%version%", B_VERSION);
    bPomContent = POM_CONTENT_TEMPLATE.replaceAll("%version%", B_VERSION);
    client.content().store(hosted.getKey(), bPomPath, new ByteArrayInputStream(bPomContent.getBytes()));
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) HostedRepository(org.commonjava.indy.model.core.HostedRepository) Before(org.junit.Before)

Example 29 with HostedRepository

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

the class HostedRepositoryDeleteNotAllowedWhenReadonly 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 = client.stores().create(hosted, "Test setup", HostedRepository.class);
    String originalString = "This is a test";
    final String path = "/path/path";
    client.content().store(hosted.getKey(), path, new ByteArrayInputStream(originalString.getBytes()));
    hosted.setReadonly(true);
    client.stores().update(hosted, "make readonly");
    client.content().delete(hosted.getKey(), path);
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) ChangeSummary(org.commonjava.indy.audit.ChangeSummary) HostedRepository(org.commonjava.indy.model.core.HostedRepository) Test(org.junit.Test) AbstractContentManagementTest(org.commonjava.indy.ftest.core.AbstractContentManagementTest)

Example 30 with HostedRepository

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

the class StorageAdvisor method getStorageAdvice.

public StorageAdvice getStorageAdvice(final ArtifactStore store) throws DotMavenException {
    boolean deployable = false;
    boolean releases = true;
    boolean snapshots = false;
    HostedRepository hostedStore = null;
    final StoreType type = store.getKey().getType();
    all: switch(type) {
        case group:
            {
                List<ArtifactStore> constituents;
                try {
                    constituents = dataManager.query().enabledState(true).getOrderedConcreteStoresInGroup(MAVEN_PKG_KEY, store.getName());
                } catch (final IndyDataException e) {
                    throw new DotMavenException("Failed to retrieve constituent ArtifactStores for group: %s. Reason: %s", e, store.getName(), e.getMessage());
                }
                for (final ArtifactStore as : constituents) {
                    if (as.getKey().getType() == hosted) {
                        deployable = true;
                        hostedStore = (HostedRepository) as;
                        snapshots = hostedStore.isAllowSnapshots();
                        releases = hostedStore.isAllowReleases();
                        break all;
                    }
                }
                break;
            }
        case hosted:
            {
                deployable = true;
                hostedStore = (HostedRepository) store;
                snapshots = hostedStore.isAllowSnapshots();
                releases = hostedStore.isAllowReleases();
                break;
            }
        default:
    }
    return new StorageAdvice(store, hostedStore, deployable, releases, snapshots);
}
Also used : StoreType(org.commonjava.indy.model.core.StoreType) IndyDataException(org.commonjava.indy.data.IndyDataException) ArtifactStore(org.commonjava.indy.model.core.ArtifactStore) HostedRepository(org.commonjava.indy.model.core.HostedRepository) DotMavenException(org.commonjava.indy.dotmaven.DotMavenException)

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