use of org.commonjava.indy.model.core.HostedRepository in project indy by Commonjava.
the class DefaultDownloadManager method store.
/*
* (non-Javadoc)
* @see org.commonjava.indy.core.rest.util.FileManager#upload(java.util.List, java.lang.String,
* java.io.InputStream)
*/
@Override
public Transfer store(final List<? extends ArtifactStore> stores, final String path, final InputStream stream, final TransferOperation op, final EventMetadata eventMetadata) throws IndyWorkflowException {
final ContentQuality quality = getQuality(path);
HostedRepository selected = null;
for (final ArtifactStore store : stores) {
if (!isIgnoreReadonly(eventMetadata) && storeManager.isReadonly(store)) {
logger.debug("The store {} is readonly, store operation not allowed", store.getKey());
continue;
}
if (storeIsSuitableFor(store, quality, op)) {
selected = (HostedRepository) store;
break;
}
}
if (selected == null) {
logger.warn("Cannot deploy. No valid deploy points in group.");
throw new IndyWorkflowException(ApplicationStatus.BAD_REQUEST.code(), "No deployment locations available.");
}
logger.info("Storing: {} in selected: {} with event metadata: {}", path, selected, eventMetadata);
store(selected, path, stream, op, eventMetadata);
return getStorageReference(selected.getKey(), path);
}
use of org.commonjava.indy.model.core.HostedRepository in project indy by Commonjava.
the class ScheduleDBManager method setSnapshotTimeouts.
public 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 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);
}
use of org.commonjava.indy.model.core.HostedRepository in project indy by Commonjava.
the class ArtifactStoreValidatorTest method testRepoValidation.
@Test
public void testRepoValidation() throws Exception {
// RemoteRepository validRepo = new RemoteRepository( "test", "http://www.foo.com" );
// assertTrue( validator.isValid( validRepo ) );
RemoteRepository inValidRepo = new RemoteRepository("test", "this.is.not.valid.repo");
assertFalse(validator.isValid(inValidRepo));
Group group = new Group("group");
assertTrue(validator.isValid(group));
HostedRepository hostedRepository = new HostedRepository("hosted");
assertTrue(validator.isValid(hostedRepository));
}
use of org.commonjava.indy.model.core.HostedRepository in project indy by Commonjava.
the class MeasuringStoreQuery method getAllHostedRepositories.
@Override
public List<HostedRepository> getAllHostedRepositories(String packageType, Boolean enabled) throws IndyDataException {
AtomicReference<IndyDataException> errorRef = new AtomicReference<>();
List<HostedRepository> result = metricsManager.wrapWithStandardMetrics(() -> {
try {
return query.getAllHostedRepositories(packageType, enabled);
} catch (IndyDataException e) {
errorRef.set(e);
}
return null;
}, () -> "getAllHostedRepositories");
IndyDataException error = errorRef.get();
if (error != null) {
throw error;
}
return result;
}
Aggregations