use of org.commonjava.indy.model.core.Group in project indy by Commonjava.
the class ExternalKojiTest method setupExternalKojiBase.
@Before
public void setupExternalKojiBase() throws IndyClientException {
client = new Indy("http://localhost:8080/api", new IndyObjectMapper(Collections.emptySet()), getAdditionalClientModules()).connect();
Group proxyGroup = new Group("maven", kojiProxyGroupName);
boolean exist = client.stores().exists(proxyGroup.getKey());
if (!exist) {
client.stores().create(proxyGroup, "adding brew-proxies", Group.class);
}
Group pseudoGroup = new Group("maven", pseudoGroupName);
exist = client.stores().exists(pseudoGroup.getKey());
if (!exist) {
client.stores().create(pseudoGroup, "adding pseudo group", Group.class);
}
}
use of org.commonjava.indy.model.core.Group in project indy by Commonjava.
the class MeasuringStoreQuery method getGroupsAffectedBy.
@Override
public Set<Group> getGroupsAffectedBy(final StoreKey... keys) throws IndyDataException {
AtomicReference<IndyDataException> errorRef = new AtomicReference<>();
Set<Group> result = metricsManager.wrapWithStandardMetrics(() -> {
try {
return query.getGroupsAffectedBy(keys);
} catch (IndyDataException e) {
errorRef.set(e);
}
return null;
}, () -> "getGroupsAffectedBy-varargs");
IndyDataException error = errorRef.get();
if (error != null) {
throw error;
}
return result;
}
use of org.commonjava.indy.model.core.Group in project indy by Commonjava.
the class MeasuringStoreQuery method getGroup.
@Override
public Group getGroup(final String packageType, final String name) throws IndyDataException {
AtomicReference<IndyDataException> errorRef = new AtomicReference<>();
Group result = metricsManager.wrapWithStandardMetrics(() -> {
try {
return query.getGroup(packageType, name);
} catch (IndyDataException e) {
errorRef.set(e);
}
return null;
}, () -> "getGroup");
IndyDataException error = errorRef.get();
if (error != null) {
throw error;
}
return result;
}
use of org.commonjava.indy.model.core.Group in project indy by Commonjava.
the class AbstractStoreDataManager method affectedByFromStores.
protected Set<Group> affectedByFromStores(final Collection<StoreKey> keys) {
Logger logger = LoggerFactory.getLogger(getClass());
logger.debug("Getting groups affected by: {}", keys);
List<StoreKey> toProcess = new ArrayList<>(new HashSet<>(keys));
Set<Group> groups = new HashSet<>();
if (toProcess.isEmpty()) {
return groups;
}
Set<StoreKey> processed = new HashSet<>();
final String packageType = toProcess.get(0).getPackageType();
Set<ArtifactStore> all = this.getStoreKeysByPkgAndType(packageType, group).stream().map(this::getArtifactStoreInternal).filter(Objects::nonNull).collect(Collectors.toSet());
while (!toProcess.isEmpty()) {
// as long as we have another key to process, pop it off the list (remove it) and process it.
StoreKey next = toProcess.remove(0);
if (processed.contains(next)) {
// if we've already handled this group (via another branch in the group membership tree, etc. then don't bother.
continue;
}
// use this to avoid reprocessing groups we've already encountered.
processed.add(next);
for (ArtifactStore store : all) {
if ((store instanceof Group) && !processed.contains(store.getKey())) {
Group g = (Group) store;
if (g.getConstituents() != null && g.getConstituents().contains(next)) {
groups.add(g);
// add this group as another one to process for groups that contain it...and recurse upwards
toProcess.add(g.getKey());
}
}
}
}
return filterAffectedGroups(groups);
}
use of org.commonjava.indy.model.core.Group in project indy by Commonjava.
the class AbstractStoreDataManager method postStore.
protected void postStore(final ArtifactStore store, final ArtifactStore original, final ChangeSummary summary, final boolean exists, final boolean fireEvents, final EventMetadata eventMetadata) throws IndyDataException {
StoreEventDispatcher dispatcher = getStoreEventDispatcher();
if (dispatcher != null && isStarted() && fireEvents) {
logger.debug("Firing store post-update event for: {} (originally: {})", store, original);
dispatcher.updated(exists ? ArtifactStoreUpdateType.UPDATE : ArtifactStoreUpdateType.ADD, eventMetadata, Collections.singletonMap(store, original));
if (exists) {
if (store.isDisabled() && !original.isDisabled()) {
dispatcher.disabled(eventMetadata, store);
} else if (!store.isDisabled() && original.isDisabled()) {
dispatcher.enabled(eventMetadata, store);
}
}
}
// Hosted or Remote update does not change affectedBy relationships
if (store instanceof Group) {
refreshAffectedBy(store, original, STORE);
}
}
Aggregations