use of org.commonjava.atlas.maven.ident.util.JoinString in project indy by Commonjava.
the class GitManager method getStatus.
private Status getStatus() throws GitSubsystemException {
Status status;
try {
status = git.status().call();
} catch (NoWorkTreeException | GitAPIException e) {
throw new GitSubsystemException("Failed to retrieve status of: %s. Reason: %s", e, rootDir, e.getMessage());
}
final Map<String, StageState> css = status.getConflictingStageState();
if (!css.isEmpty()) {
throw new GitSubsystemException("%s contains conflicts. Cannot auto-commit.\n %s", rootDir, new JoinString("\n ", css.entrySet()));
}
return status;
}
use of org.commonjava.atlas.maven.ident.util.JoinString in project indy by Commonjava.
the class DeprecatedStoreAdminHandler method getAll.
@ApiOperation("Retrieve the definitions of all artifact stores of a given type on the system")
@ApiResponses({ @ApiResponse(code = 200, response = StoreListingDTO.class, message = "The store definitions") })
@GET
@Produces(ApplicationContent.application_json)
public Response getAll(@ApiParam(allowableValues = "hosted,group,remote", required = true) @PathParam("type") final String type) {
String altPath = Paths.get(MavenPackageTypeDescriptor.MAVEN_ADMIN_REST_BASE_PATH, type).toString();
Consumer<Response.ResponseBuilder> modifier = (rb) -> responseHelper.markDeprecated(rb, altPath);
final StoreType st = StoreType.get(type);
Response response;
try {
final List<ArtifactStore> stores = adminController.getAllOfType(st);
logger.info("Returning listing containing stores:\n\t{}", new JoinString("\n\t", stores));
final StoreListingDTO<ArtifactStore> dto = new StoreListingDTO<>(stores);
response = responseHelper.formatOkResponseWithJsonEntity(dto, modifier);
} catch (final IndyWorkflowException e) {
logger.error(e.getMessage(), e);
response = responseHelper.formatResponse(e, modifier);
}
return response;
}
use of org.commonjava.atlas.maven.ident.util.JoinString in project indy by Commonjava.
the class ImpliedRepositoryDetector method updateExistingGroups.
private boolean updateExistingGroups(final ImplicationsJob job) {
final StoreKey key = job.store.getKey();
boolean anyChanged = false;
try {
final Set<Group> groups = storeManager.query().getGroupsContaining(key);
if (groups != null) {
logger.debug("{} groups contain: {}\n {}", groups.size(), key, new JoinString("\n ", groups));
final String message = String.format("Adding repositories implied by: %s\n\n %s", key, StringUtils.join(job.implied, "\n "));
final ChangeSummary summary = new ChangeSummary(ChangeSummary.SYSTEM_USER, message);
for (final Group g : groups) {
if (config.isEnabledForGroup(g.getName())) {
Group group = g.copyOf();
boolean changed = false;
for (final ArtifactStore implied : job.implied) {
boolean groupChanged = group.addConstituent(implied);
changed = groupChanged || changed;
logger.debug("After attempting to add: {} to group: {}, changed status is: {}", implied, group, changed);
}
if (changed) {
storeManager.storeArtifactStore(group, summary, false, false, new EventMetadata().set(StoreDataManager.EVENT_ORIGIN, IMPLIED_REPOS_DETECTION).set(IMPLIED_REPOS, job.implied));
}
anyChanged = changed || anyChanged;
}
}
}
} catch (final IndyDataException e) {
logger.error("Failed to lookup groups containing: " + key, e);
}
return anyChanged;
}
use of org.commonjava.atlas.maven.ident.util.JoinString in project indy by Commonjava.
the class ImpliedRepoMaintainer method processImpliedRepos.
private boolean processImpliedRepos(final ImpliedRepoMaintJob job) {
final Set<StoreKey> processed = new HashSet<>();
// implications. Reachable means they could be in nested groups.
for (final ArtifactStore member : job.reachableMembers) {
processed.add(member.getKey());
}
logger.debug("Preset processed-implications to reachable members:\n {}", new JoinString("\n ", processed));
int lastLen = 0;
boolean changed = false;
job.added = new ArrayList<>();
// As soon as we go an iteration without adding a new member, we've captured everything.
do {
lastLen = job.members.size();
for (final ArtifactStore member : new ArrayList<>(job.members)) {
logger.debug("Processing member: {} for implied repos within group: {}", member.getKey(), job.group.getKey());
processed.add(member.getKey());
List<StoreKey> implied;
try {
implied = metadataManager.getStoresImpliedBy(member);
} catch (final ImpliedReposException e) {
logger.error("Failed to retrieve implied-store metadata for: " + member.getKey(), e);
continue;
}
if (implied == null || implied.isEmpty()) {
continue;
}
implied.removeAll(processed);
for (final StoreKey key : implied) {
logger.debug("Found implied store: {} not already in group: {}", key, job.group.getKey());
ArtifactStore impliedStore;
try {
impliedStore = storeManager.getArtifactStore(key);
} catch (final IndyDataException e) {
logger.error("Failed to retrieve store: " + key + " implied by: " + member.getKey(), e);
continue;
}
logger.info("Adding: {} to group: {} (implied by POMs in: {})", key, job.group.getKey(), member.getKey());
processed.add(key);
job.added.add(key);
job.group.addConstituent(key);
job.members.add(impliedStore);
changed = true;
}
}
} while (job.members.size() > lastLen);
return changed;
}
use of org.commonjava.atlas.maven.ident.util.JoinString in project indy by Commonjava.
the class ImpliedRepositoryDetector method addImpliedMetadata.
private boolean addImpliedMetadata(final ImplicationsJob job) {
try {
logger.debug("Adding implied-repo metadata to: {} and {}", job.store, new JoinString(", ", job.implied));
metadataManager.addImpliedMetadata(job.store, job.implied);
ChangeSummary summary = new ChangeSummary(ChangeSummary.SYSTEM_USER, "Update " + IMPLIED_STORES);
storeManager.storeArtifactStore(job.store, summary, false, false, null);
return true;
} catch (final ImpliedReposException e) {
logger.error("Failed to store list of implied stores in: " + job.store.getKey(), e);
} catch (IndyDataException e) {
logger.error("Failed to update ArtifactStore {}", job.store);
}
return false;
}
Aggregations