use of com.redhat.red.build.koji.model.xmlrpc.KojiBuildInfo in project indy by Commonjava.
the class KojiUtilsTest method formatStorageUrl.
@Test
public void formatStorageUrl() throws Exception {
KojiUtils kojiUtils = new KojiUtils();
String root = "http://my.koji.hub/kojihub";
KojiBuildInfo buildInfo = new KojiBuildInfo();
buildInfo.setName("javax.activation-activation");
buildInfo.setVersion("1.1.1.redhat_5");
buildInfo.setRelease("1");
buildInfo.setVolumeName("DEFAULT");
String url = kojiUtils.formatStorageUrl(root, buildInfo);
assertEquals(defaultUrl, url);
buildInfo.setVolumeName(null);
url = kojiUtils.formatStorageUrl(root, buildInfo);
assertEquals(defaultUrl, url);
buildInfo.setVolumeName("1");
url = kojiUtils.formatStorageUrl(root, buildInfo);
assertEquals(volUrl, url);
}
use of com.redhat.red.build.koji.model.xmlrpc.KojiBuildInfo in project indy by Commonjava.
the class KojiRepairManager method repairGroupVol.
private KojiRepairResult repairGroupVol(KojiRepairRequest request, Group group, String user) throws KojiClientException {
KojiRepairResult ret = new KojiRepairResult(request);
List<StoreKey> stores = group.getConstituents();
if (stores.isEmpty()) {
return ret.withNoChange(group.getKey());
}
KojiSessionInfo session = null;
List<Object> args = new ArrayList<>();
stores.forEach(storeKey -> {
String nvr = kojiUtils.getBuildNvr(storeKey);
if (nvr != null) {
args.add(nvr);
} else {
ret.withIgnore(storeKey);
}
});
List<KojiBuildInfo> buildInfoList = kojiCachedClient.getBuildInfo(args, session);
buildInfoList.forEach(buildInfo -> {
try {
KojiRepairResult.RepairResult repairResult = doRepair(group.getPackageType(), null, buildInfo, user, request.isDryRun());
ret.withResult(repairResult);
} catch (KojiRepairException e) {
// we do not fail the whole attempt if one store failed
logger.debug("Repair failed", e);
ret.withResult(new KojiRepairResult.RepairResult(e.getStoreKey(), e));
}
});
return ret;
}
use of com.redhat.red.build.koji.model.xmlrpc.KojiBuildInfo in project indy by Commonjava.
the class KojiRepairManager method repairPathMask.
public KojiRepairResult repairPathMask(KojiRepairRequest request, String user, boolean skipLock) throws KojiRepairException {
KojiRepairResult ret = new KojiRepairResult(request);
if (skipLock || opLock.tryLock()) {
try {
ArtifactStore store = getRequestedStore(request, ret);
if (store == null) {
return ret;
}
store = store.copyOf();
StoreKey remoteKey = request.getSource();
if (remoteKey.getType() == remote) {
final String nvr = kojiUtils.getBuildNvr(remoteKey);
if (nvr == null) {
String error = String.format("Not a koji store: %s", remoteKey);
return ret.withError(error);
}
try {
KojiSessionInfo session = null;
KojiBuildInfo build = kojiCachedClient.getBuildInfo(nvr, session);
List<KojiArchiveInfo> archives = kojiCachedClient.listArchivesForBuild(build.getId(), session);
ArtifactRef artifactRef = SimpleArtifactRef.parse(store.getMetadata(CREATION_TRIGGER_GAV));
if (artifactRef == null) {
String error = String.format("Koji remote repository: %s does not have %s metadata. Cannot retrieve accurate path masks.", remoteKey, CREATION_TRIGGER_GAV);
return ret.withError(error);
}
// set pathMaskPatterns using build output paths
Set<String> patterns = kojiPathFormatter.getPatterns(store.getKey(), artifactRef, archives, true);
logger.debug("For repo: {}, resetting path_mask_patterns to:\n\n{}\n\n", store.getKey(), patterns);
KojiRepairResult.RepairResult repairResult = new KojiRepairResult.RepairResult(remoteKey);
repairResult.withPropertyChange("path_mask_patterns", store.getPathMaskPatterns(), patterns);
ret.withResult(repairResult);
store.setPathMaskPatterns(patterns);
final ChangeSummary changeSummary = new ChangeSummary(user, "Repairing remote repository path masks to Koji build: " + build.getNvr());
storeManager.storeArtifactStore(store, changeSummary, false, true, new EventMetadata());
} catch (KojiClientException e) {
String error = String.format("Cannot getBuildInfo: %s, error: %s", remoteKey, e);
logger.debug(error, e);
return ret.withError(error, e);
} catch (IndyDataException e) {
String error = String.format("Failed to store changed remote repository: %s, error: %s", remoteKey, e);
logger.debug(error, e);
return ret.withError(error, e);
}
} else {
String error = String.format("Not a remote koji repository: %s", remoteKey);
return ret.withError(error);
}
} finally {
if (!skipLock) {
opLock.unlock();
}
}
} else {
throw new KojiRepairException("Koji repair manager is busy.");
}
return ret;
}
use of com.redhat.red.build.koji.model.xmlrpc.KojiBuildInfo in project indy by Commonjava.
the class KojiRepairManager method repairRemoteRepositoryVol.
private KojiRepairResult repairRemoteRepositoryVol(KojiRepairRequest request, RemoteRepository repository, String user) throws KojiRepairException {
StoreKey storeKey = repository.getKey();
KojiRepairResult ret = new KojiRepairResult(request);
final String nvr = kojiUtils.getBuildNvr(storeKey);
if (nvr == null) {
String error = String.format("Not a koji store: %s", storeKey);
return ret.withError(error);
}
KojiBuildInfo buildInfo;
try {
KojiSessionInfo session = null;
buildInfo = kojiCachedClient.getBuildInfo(nvr, session);
} catch (KojiClientException e) {
String error = String.format("Cannot getBuildInfo: %s, error: %s", storeKey, e);
logger.debug(error, e);
return ret.withError(error, e);
}
KojiRepairResult.RepairResult repairResult = doRepair(repository.getPackageType(), repository, buildInfo, user, request.isDryRun());
return ret.withResult(repairResult);
}
use of com.redhat.red.build.koji.model.xmlrpc.KojiBuildInfo in project indy by Commonjava.
the class KojiMavenMetadataProvider method scanArchive.
private ArchiveScan scanArchive(final KojiArchiveInfo archive, final Set<Integer> seenBuilds) throws KojiClientException {
Logger logger = LoggerFactory.getLogger(getClass());
ArchiveScan scan = new ArchiveScan();
if (!archive.getFilename().endsWith(".pom")) {
logger.debug("Skipping non-POM: {}", archive.getFilename());
scan.setDisqualified(true);
return scan;
}
if (!isVerSignedAllowed(archive.getVersion())) {
logger.debug("version filter pattern not matched: {}", archive.getVersion());
scan.setDisqualified(true);
return scan;
}
SingleVersion singleVersion = null;
try {
singleVersion = VersionUtils.createSingleVersion(archive.getVersion());
scan.setSingleVersion(singleVersion);
} catch (InvalidVersionSpecificationException ivse) {
logger.warn("Skipping mal-formatted version: {}, relPath: {}, buildId: {}", archive.getVersion(), archive.getRelPath(), archive.getBuildId());
scan.setDisqualified(true);
return scan;
}
KojiBuildInfo build = null;
if (seenBuilds.contains(archive.getBuildId())) {
logger.debug("Skipping already seen build: {}", archive.getBuildId());
scan.setDisqualified(true);
return scan;
} else {
build = kojiContentProvider.getBuildInfo(archive.getBuildId(), null);
seenBuilds.add(archive.getBuildId());
scan.setBuild(build);
}
if (build == null) {
logger.debug("Cannot retrieve build info: {}. Skipping: {}", archive.getBuildId(), archive.getFilename());
scan.setDisqualified(true);
return scan;
}
if (build.getBuildState() != KojiBuildState.COMPLETE) {
logger.debug("Build: {} is not completed. The state is {}. Skipping.", build.getNvr(), build.getBuildState());
scan.setDisqualified(true);
return scan;
}
if (build.getTaskId() == null) {
logger.debug("Build: {} is not a real build. It looks like a binary import. Skipping.", build.getNvr());
// This is not a real build, it's a binary import.
scan.setDisqualified(true);
return scan;
}
return scan;
}
Aggregations