use of org.commonjava.indy.model.core.HostedRepository in project indy by Commonjava.
the class AutoProxCalculationTest method jsonRoundTrip_GroupCreation.
@Test
public void jsonRoundTrip_GroupCreation() throws IOException {
HostedRepository first = new HostedRepository("first");
HostedRepository second = new HostedRepository("second");
Group repo = new Group("test", first.getKey(), second.getKey());
AutoProxCalculation in = new AutoProxCalculation(repo, Arrays.asList(first, second), "test-rule.groovy");
IndyObjectMapper mapper = new IndyObjectMapper(true);
String json = mapper.writeValueAsString(in);
AutoProxCalculation out = mapper.readValue(json, AutoProxCalculation.class);
assertThat(out, notNullValue());
assertThat(out.getRuleName(), equalTo(in.getRuleName()));
assertThat(out.getStore(), equalTo(in.getStore()));
assertThat(out, equalTo(in));
List<ArtifactStore> supplementalStores = out.getSupplementalStores();
assertThat(supplementalStores, notNullValue());
assertThat(supplementalStores.size(), equalTo(2));
assertThat(supplementalStores.get(0), equalTo(first));
assertThat(supplementalStores.get(1), equalTo(second));
}
use of org.commonjava.indy.model.core.HostedRepository in project indy by Commonjava.
the class DeleteHostedRepoWithContentTest method deleteHostedRepoWithContent_RepoNotReCreatedWhenContentIsDeleted.
@Test
@Category(EventDependent.class)
public void deleteHostedRepoWithContent_RepoNotReCreatedWhenContentIsDeleted() throws Exception {
final String named = "test";
final String path = "path/to/foo.txt";
final String content = "This is a test";
client.content().store(StoreType.hosted, named, path, new ByteArrayInputStream(content.getBytes()));
final InputStream stream = client.content().get(StoreType.hosted, named, path);
final String retrieved = IOUtils.toString(stream);
stream.close();
assertThat(retrieved, equalTo(content));
System.out.println("Waiting for server events to clear...");
waitForEventPropagation();
client.stores().delete(StoreType.hosted, named, "Removing test repo");
System.out.println("Waiting for server events to clear...");
waitForEventPropagation();
final StoreListingDTO<HostedRepository> repos = client.stores().listHostedRepositories();
boolean found = false;
for (final HostedRepository repo : repos) {
if (repo.getName().equals(named)) {
found = true;
break;
}
}
assertThat(found, equalTo(false));
}
use of org.commonjava.indy.model.core.HostedRepository in project indy by Commonjava.
the class ScheduleManager method setSnapshotTimeouts.
public synchronized void setSnapshotTimeouts(final StoreKey key, final String path) throws IndySchedulerException {
if (!schedulerConfig.isEnabled()) {
logger.debug("Scheduler disabled.");
return;
}
HostedRepository deploy = null;
try {
final ArtifactStore store = dataManager.getArtifactStore(key);
if (store == null) {
return;
}
if (store instanceof HostedRepository) {
deploy = (HostedRepository) store;
} else if (store instanceof Group) {
final Group group = (Group) store;
deploy = findDeployPoint(group);
}
} catch (final IndyDataException e) {
logger.error(String.format("Failed to retrieve deploy point for: %s. Reason: %s", key, e.getMessage()), e);
}
if (deploy == null) {
return;
}
final ContentAdvisor advisor = StreamSupport.stream(Spliterators.spliteratorUnknownSize(contentAdvisor.iterator(), Spliterator.ORDERED), false).filter(Objects::nonNull).findFirst().orElse(null);
final ContentQuality quality = advisor == null ? null : advisor.getContentQuality(path);
if (quality == null) {
return;
}
if (ContentQuality.SNAPSHOT == quality && deploy.getSnapshotTimeoutSeconds() > 0) {
final int timeout = deploy.getSnapshotTimeoutSeconds();
// // logger.info( "[SNAPSHOT TIMEOUT SET] {}/{}; {}", deploy.getKey(), path, new Date( timeout ) );
// cancel( new StoreKeyMatcher( key, CONTENT_JOB_TYPE ), path );
scheduleContentExpiration(key, path, timeout);
}
}
use of org.commonjava.indy.model.core.HostedRepository in project indy by Commonjava.
the class RepoChangelogStoreDisableTest 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());
IndyRepoChangelogClientModule repoChangelogClientModule = client.module(IndyRepoChangelogClientModule.class);
List<ChangeEvent> logs = null;
try {
logs = repoChangelogClientModule.getByStoreKey(repo.getKey());
} catch (IndyClientException e) {
assertThat(e.getStatusCode(), equalTo(404));
}
assertNotNull(logs);
assertTrue(logs.isEmpty());
try {
repoChangelogClientModule.getAll();
} catch (IndyClientException e) {
assertThat(e.getStatusCode(), equalTo(404));
}
assertNotNull(logs);
assertTrue(logs.isEmpty());
}
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);
}
Aggregations