use of org.commonjava.indy.model.core.ArtifactStore in project indy by Commonjava.
the class ImpliedRepoMaintainer method initJob.
private boolean initJob(final ImpliedRepoMaintJob job) {
// we might be able to fix the repo-removal problem too.
if (!(job.store instanceof Group)) {
logger.debug("ImpliedRepoMaint: Ignoring non-group: {}", job.store.getKey());
return false;
}
if (!config.isEnabledForGroup(job.store.getName())) {
logger.debug("ImpliedRepoMaint: Implied repositories not enabled for group: {}", job.store.getKey());
return false;
}
logger.debug("Processing group: {} for stores implied by membership which are not yet in the membership", job.store.getName());
job.group = (Group) job.store;
try {
// getOrderedStoresInGroup(), but we can't use persisted info...
job.members = loadMemberStores(job.group, job);
// getOrderedConcreteStores(), but we can't use the persisted info...
final LinkedHashSet<ArtifactStore> reachable = new LinkedHashSet<>(job.members.size());
for (final ArtifactStore member : job.members) {
if (member instanceof Group) {
reachable.addAll(loadMemberStores((Group) member, job));
} else {
reachable.add(member);
}
}
job.reachableMembers = new ArrayList<>(reachable);
logger.debug("For group: {}\n Members: {}\n Reachable Concrete Members: {}", job.group.getKey(), job.members, job.reachableMembers);
} catch (final IndyDataException e) {
logger.error("Failed to retrieve member stores for group: " + job.group.getName(), e);
}
if (job.members == null) {
logger.debug("ImpliedRepoMaint: Group: {} has no membership", job.store.getKey());
return false;
}
return true;
}
use of org.commonjava.indy.model.core.ArtifactStore in project indy by Commonjava.
the class ImpliedReposQueryDelegate method getOrderedConcreteStoresInGroup.
@Override
public List<ArtifactStore> getOrderedConcreteStoresInGroup(String groupName) throws IndyDataException {
Logger logger = LoggerFactory.getLogger(getClass());
logger.trace("Retrieving ordered concrete (recursive) members for group: {}", groupName);
List<ArtifactStore> result = delegate().getOrderedConcreteStoresInGroup(groupName);
if (logger.isTraceEnabled()) {
logger.trace("Raw ordered concrete membership for group: {} is:\n {}", groupName, StringUtils.join(result, "\n "));
}
result = maybeFilter(groupName, result);
if (logger.isTraceEnabled()) {
logger.trace("Filtered for implied-repos: ordered concrete membership for group: {} is now:\n {}", groupName, StringUtils.join(result, "\n "));
}
return result;
}
use of org.commonjava.indy.model.core.ArtifactStore in project indy by Commonjava.
the class SetBackSettingsManager method updateSettingsForGroup.
private DataFile updateSettingsForGroup(final Group group) throws SetBackDataException {
if (!config.isEnabled()) {
throw new SetBackDataException("SetBack is disabled!");
}
logger.info("Updating set-back settings.xml for group: {}", group.getName());
List<ArtifactStore> concreteStores;
try {
concreteStores = storeManager.query().packageType(group.getPackageType()).getOrderedConcreteStoresInGroup(group.getName());
} catch (final IndyDataException e) {
logger.error(String.format("Failed to retrieve concrete membership for group: {}. Reason: {}", group.getName(), e.getMessage()), e);
return null;
}
final List<RemoteRepository> remotes = new ArrayList<RemoteRepository>();
for (final ArtifactStore cs : concreteStores) {
if (StoreType.remote == cs.getKey().getType()) {
remotes.add((RemoteRepository) cs);
}
}
return updateSettings(group, concreteStores, remotes);
}
use of org.commonjava.indy.model.core.ArtifactStore in project indy by Commonjava.
the class SetBackSettingsManagerTest method generateSettings.
private List<String> generateSettings(final StoreKey key) throws Exception {
final ArtifactStore store = storeManager.getArtifactStore(key);
final DataFile settings = manager.generateStoreSettings(store);
assertThat("settings.xml returned from generateStoreSettings(..) for: " + key + " does not exist!", settings.exists(), equalTo(true));
final List<String> lines = readSettings(key, true);
final String localRepoLine = String.format("<localRepository>%s</localRepository>", normalize(USER_HOME, ".m2/repository-" + key.getType().singularEndpointName() + "-" + key.getName()));
assertThat("Local repository for: " + key + " not configured", lines.contains(localRepoLine), equalTo(true));
return lines;
}
use of org.commonjava.indy.model.core.ArtifactStore in project indy by Commonjava.
the class IndyLocationExpander method expand.
/**
* For group references, expand into a list of concrete repository locations (hosted or remote). For remote repository references that are
* specified as cache-only locations (see: {@link CacheOnlyLocation}), lookup the corresponding {@link RemoteRepository} and use it to create a
* {@link RepositoryLocation} that contains any relevant SSL, authentication, proxy, etc. attbributes.
*/
@Override
public <T extends Location> List<Location> expand(final Collection<T> locations) throws TransferException {
final List<Location> result = new ArrayList<Location>();
for (final Location location : locations) {
if (location instanceof GroupLocation) {
final GroupLocation gl = (GroupLocation) location;
try {
logger.debug("Expanding group: {}", gl.getKey());
final List<ArtifactStore> members = data.query().packageType(gl.getKey().getPackageType()).getOrderedConcreteStoresInGroup(gl.getKey().getName());
if (members != null) {
for (final ArtifactStore member : members) {
if (!result.contains(member)) {
logger.debug("expansion += {}", member.getKey());
result.add(LocationUtils.toLocation(member));
}
}
logger.debug("Expanded group: {} to:\n {}", gl.getKey(), new JoinString("\n ", result));
}
} catch (final IndyDataException e) {
throw new TransferException("Failed to lookup ordered concrete artifact stores contained in group: {}. Reason: {}", e, gl, e.getMessage());
}
} else if (location instanceof CacheOnlyLocation && !((CacheOnlyLocation) location).isHostedRepository()) {
final StoreKey key = ((KeyedLocation) location).getKey();
try {
final ArtifactStore store = data.getArtifactStore(key);
if (store == null) {
throw new TransferException("Cannot find ArtifactStore to match key: %s.", key);
}
logger.debug("Adding single store: {} for location: {}", store, location);
result.add(LocationUtils.toLocation(store));
} catch (final IndyDataException e) {
throw new TransferException("Failed to lookup store for key: {}. Reason: {}", e, key, e.getMessage());
}
} else {
logger.debug("No expansion available for location: {}", location);
result.add(location);
}
}
return result;
}
Aggregations