use of org.commonjava.indy.core.inject.AbstractNotFoundCache in project indy by Commonjava.
the class NfcController method getInfo.
public NotFoundCacheInfoDTO getInfo(StoreKey key) throws IndyWorkflowException {
NotFoundCacheInfoDTO dto = new NotFoundCacheInfoDTO();
final AtomicLong size = new AtomicLong(0);
try {
switch(key.getType()) {
case group:
{
// Warn: This is very expensive if group holds thousands of repositories
final List<StoreKey> stores = storeManager.query().getOrderedConcreteStoresInGroup(key.getPackageType(), key.getName()).stream().map(artifactStore -> artifactStore.getKey()).collect(Collectors.toList());
if (stores.size() >= MAX_GROUP_MEMBER_SIZE_FOR_GET_MISSING) {
throw new IndyWorkflowException(SC_UNPROCESSABLE_ENTITY, "Get missing info for group failed (too many members), size: " + stores.size());
}
for (final StoreKey storeKey : stores) {
size.addAndGet(((AbstractNotFoundCache) cache).getSize(storeKey));
}
break;
}
default:
{
size.addAndGet(((AbstractNotFoundCache) cache).getSize(key));
break;
}
}
dto.setSize(size.get());
return dto;
} catch (final IndyDataException e) {
throw new IndyWorkflowException("Failed to get info for ArtifactStore: %s.", e, key);
}
}
use of org.commonjava.indy.core.inject.AbstractNotFoundCache in project indy by Commonjava.
the class NfcController method getAllMissing.
public Pagination<NotFoundCacheDTO> getAllMissing(Page page) {
return new DefaultPagination<>(page, (handler) -> {
Map<Location, Set<String>> allMissing = ((AbstractNotFoundCache) cache).getAllMissing(page.getPageIndex(), page.getPageSize());
NotFoundCacheDTO dto = getNotFoundCacheDTO(allMissing);
return dto;
});
}
Aggregations