use of org.commonjava.indy.audit.ChangeSummary in project indy by Commonjava.
the class AutoProxDataManagerDecorator method getHostedRepository.
private HostedRepository getHostedRepository(final StoreKey key, final StoreKey impliedBy) throws IndyDataException {
HostedRepository repo = (HostedRepository) dataManager.getArtifactStore(key);
if (!catalog.isEnabled()) {
logger.debug("AutoProx decorator disabled; returning: {}", repo);
return repo;
}
logger.debug("AutoProx decorator active");
if (repo == null) {
logger.info("AutoProx: creating repository for: {}", key);
try {
repo = catalog.createHostedRepository(key);
} catch (final AutoProxRuleException e) {
throw new IndyDataException("[AUTOPROX] Failed to create new hosted repository from factory matching: '%s'. Reason: %s", e, key, e.getMessage());
}
if (repo != null) {
final ChangeSummary changeSummary = new ChangeSummary(ChangeSummary.SYSTEM_USER, "AUTOPROX: Creating hosted repository for: '" + key + "'");
final EventMetadata eventMetadata = new EventMetadata().set(StoreDataManager.EVENT_ORIGIN, AutoProxConstants.STORE_ORIGIN).set(AutoProxConstants.ORIGINATING_STORE, impliedBy == null ? repo.getKey() : impliedBy);
dataManager.storeArtifactStore(repo, changeSummary, false, true, eventMetadata);
}
}
return repo;
}
use of org.commonjava.indy.audit.ChangeSummary in project indy by Commonjava.
the class LegacyDataMigrationActionTest method dataFileMigrationForExistingHostedRepoJSON.
@Test
public void dataFileMigrationForExistingHostedRepoJSON() throws Exception {
final DataFile dir = dfm.getDataFile(INDY_STORE, hosted.singularEndpointName());
dir.mkdirs();
final DataFile old = dfm.getDataFile(INDY_STORE, hosted.singularEndpointName(), "test.json");
final DataFile migrated = dfm.getDataFile(INDY_STORE, MAVEN_PKG_KEY, hosted.singularEndpointName(), "test.json");
String srcJson = "{\"name\": \"test\", \"type\" : \"hosted\", \"packageType\": \"maven\", \"key\": \"maven:hosted:test\"}";
old.writeString(srcJson, new ChangeSummary(ChangeSummary.SYSTEM_USER, "test repo creation"));
migrated.writeString(srcJson, new ChangeSummary(ChangeSummary.SYSTEM_USER, "test repo creation"));
final boolean result = action.migrate();
assertThat(result, equalTo(false));
}
use of org.commonjava.indy.audit.ChangeSummary in project indy by Commonjava.
the class ConcurrencyTest method deadlockOnListAllDuringDelete.
@BMRules(rules = { @BMRule(name = "init rendezvous", targetClass = "MemoryStoreDataManager", targetMethod = "<init>", targetLocation = "ENTRY", action = "createRendezvous($0, 2)"), @BMRule(name = "delete call", targetClass = "MemoryStoreDataManager", targetMethod = "deleteArtifactStore", targetLocation = "EXIT", action = "rendezvous($0); debug(Thread.currentThread().getName() + \": deletion thread proceeding.\")"), @BMRule(name = "streamArtifactStores call", targetClass = "MemoryStoreDataManager", targetMethod = "streamArtifactStores", targetLocation = "ENTRY", action = "rendezvous($0); debug(Thread.currentThread().getName() + \": streamArtifactStores() thread proceeding.\")") })
@Test
public void deadlockOnListAllDuringDelete() throws IndyDataException, InterruptedException, ExecutionException {
ExecutorService executor = Executors.newFixedThreadPool(2);
ExecutorCompletionService<String> completionService = new ExecutorCompletionService<>(executor);
RemoteRepository repo = new RemoteRepository(MAVEN_PKG_KEY, "central", "http://repo.maven.apache.org/maven2");
TestDeletingEventDispatcher dispatcher = new TestDeletingEventDispatcher(completionService);
MemoryStoreDataManager dataManager = new MemoryStoreDataManager(dispatcher, new DefaultIndyConfiguration());
dispatcher.setDataManager(dataManager);
ChangeSummary summary = new ChangeSummary(ChangeSummary.SYSTEM_USER, "Test init");
dataManager.storeArtifactStore(repo, summary, false, false, new EventMetadata());
dataManager.deleteArtifactStore(repo.getKey(), new ChangeSummary(ChangeSummary.SYSTEM_USER, "Test deletion"), new EventMetadata());
Future<String> future = completionService.take();
assertThat(future.get(), nullValue());
}
Aggregations