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()));
}
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));
}
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()));
}
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);
}
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);
}
Aggregations