Search in sources :

Example 21 with Group

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);
    }
}
Also used : Group(org.commonjava.indy.model.core.Group) IndyObjectMapper(org.commonjava.indy.model.core.io.IndyObjectMapper) Indy(org.commonjava.indy.client.core.Indy) Before(org.junit.Before)

Example 22 with Group

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;
}
Also used : IndyDataException(org.commonjava.indy.data.IndyDataException) Group(org.commonjava.indy.model.core.Group) AtomicReference(java.util.concurrent.atomic.AtomicReference)

Example 23 with Group

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;
}
Also used : IndyDataException(org.commonjava.indy.data.IndyDataException) Group(org.commonjava.indy.model.core.Group) AtomicReference(java.util.concurrent.atomic.AtomicReference)

Example 24 with Group

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);
}
Also used : Group(org.commonjava.indy.model.core.Group) ArtifactStore(org.commonjava.indy.model.core.ArtifactStore) ArrayList(java.util.ArrayList) Logger(org.slf4j.Logger) StoreKey(org.commonjava.indy.model.core.StoreKey) HashSet(java.util.HashSet)

Example 25 with Group

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);
    }
}
Also used : StoreEventDispatcher(org.commonjava.indy.data.StoreEventDispatcher) Group(org.commonjava.indy.model.core.Group)

Aggregations

Group (org.commonjava.indy.model.core.Group)211 Test (org.junit.Test)111 HostedRepository (org.commonjava.indy.model.core.HostedRepository)89 RemoteRepository (org.commonjava.indy.model.core.RemoteRepository)82 StoreKey (org.commonjava.indy.model.core.StoreKey)76 ByteArrayInputStream (java.io.ByteArrayInputStream)67 InputStream (java.io.InputStream)62 IndyDataException (org.commonjava.indy.data.IndyDataException)44 AbstractContentManagementTest (org.commonjava.indy.ftest.core.AbstractContentManagementTest)42 ArtifactStore (org.commonjava.indy.model.core.ArtifactStore)42 Transfer (org.commonjava.maven.galley.model.Transfer)31 EventMetadata (org.commonjava.maven.galley.event.EventMetadata)30 Logger (org.slf4j.Logger)30 Before (org.junit.Before)29 StoreDataManager (org.commonjava.indy.data.StoreDataManager)27 ConcreteResource (org.commonjava.maven.galley.model.ConcreteResource)27 HashSet (java.util.HashSet)26 ArrayList (java.util.ArrayList)25 List (java.util.List)22 IndyWorkflowException (org.commonjava.indy.IndyWorkflowException)22