use of org.jboss.pnc.model.Artifact in project pnc by project-ncl.
the class DefaultDatastore method saveHttpArtifact.
private Artifact saveHttpArtifact(Artifact artifact) {
logger.trace("Saving http artifact {}.", artifact);
// NONE OF THE ARTIFACTS CAN BE IN THE DB BECAUSE OF PER-BUILD REPOS
logger.trace("Artifact is not in DB. Saving artifact {}.", artifact);
// Relation owner (BuildRecord) must be saved first, the relation is saved when the BR is saved
artifact.setDependantBuildRecords(Collections.emptySet());
Artifact artifactFromDb = artifactRepository.save(artifact);
logger.trace("Saved new artifact {}.", artifactFromDb);
return artifactFromDb;
}
use of org.jboss.pnc.model.Artifact in project pnc by project-ncl.
the class ArtifactAuditedRepositoryImpl method queryById.
@Override
public ArtifactAudited queryById(IdRev idRev) {
logger.trace("Querying for ArtifactAudited.idRev: {}.", idRev);
Artifact artifact = AuditReaderFactory.get(entityManager).find(Artifact.class, idRev.getId(), idRev.getRev());
if (artifact == null) {
return null;
}
return ArtifactAudited.fromArtifact(artifact, idRev.getRev());
}
use of org.jboss.pnc.model.Artifact in project pnc by project-ncl.
the class ArtifactAuditedRepositoryImpl method createAudited.
private ArtifactAudited createAudited(Object entity, Object revision) {
Artifact artifact = (Artifact) entity;
DefaultRevisionEntity revisionEntity = (DefaultRevisionEntity) revision;
return ArtifactAudited.fromArtifact(artifact, revisionEntity.getId());
}
use of org.jboss.pnc.model.Artifact in project pnc by project-ncl.
the class IndyRepositorySession method collectUploads.
/**
* Return list of output artifacts for promotion.
*
* @param report The tracking report that contains info about artifacts uploaded (output) from the build
* @return List of output artifacts meta data
* @throws RepositoryManagerException In case of a client API transport error or an error during promotion of
* artifacts
*/
private Uploads collectUploads(TrackedContentDTO report) throws RepositoryManagerException {
List<Artifact> data;
List<String> promotion;
logger.info("BEGIN: Process artifacts uploaded from build");
userLog.info("Processing built artifacts");
StopWatch stopWatch = StopWatch.createStarted();
Set<TrackedContentEntryDTO> uploads = report.getUploads();
if (CollectionUtils.isEmpty(uploads)) {
data = Collections.emptyList();
promotion = Collections.emptyList();
} else {
data = new ArrayList<>();
Set<String> promotionSet = new HashSet<>();
IndyContentClientModule content;
try {
content = indy.content();
} catch (IndyClientException e) {
throw new RepositoryManagerException("Failed to retrieve Indy content module. Reason: %s", e, e.getMessage());
}
for (TrackedContentEntryDTO upload : uploads) {
String path = upload.getPath();
StoreKey storeKey = upload.getStoreKey();
if (artifactFilter.acceptsForData(upload)) {
String identifier = computeIdentifier(upload);
String purl = computePurl(upload);
logger.info("Recording upload: {}", identifier);
RepositoryType repoType = toRepoType(storeKey.getPackageType());
TargetRepository targetRepository = getUploadsTargetRepository(repoType, content);
ArtifactQuality artifactQuality = getArtifactQuality(isTempBuild);
Artifact.Builder artifactBuilder = Artifact.Builder.newBuilder().md5(upload.getMd5()).sha1(upload.getSha1()).sha256(upload.getSha256()).size(upload.getSize()).deployPath(upload.getPath()).filename(new File(path).getName()).identifier(identifier).purl(purl).targetRepository(targetRepository).artifactQuality(artifactQuality).buildCategory(buildCategory);
Artifact artifact = validateArtifact(artifactBuilder.build());
data.add(artifact);
}
if (artifactFilter.acceptsForPromotion(upload, false)) {
promotionSet.add(path);
if (MAVEN_PKG_KEY.equals(storeKey.getPackageType()) && !isChecksum(path)) {
// add the standard checksums to ensure, they are promoted (Maven usually uses only one, so
// the other would be missing) but avoid adding checksums of checksums.
promotionSet.add(path + ".md5");
promotionSet.add(path + ".sha1");
}
}
}
promotion = new ArrayList<>(promotionSet);
}
logger.info("END: Process artifacts uploaded from build, took {} seconds", stopWatch.getTime(TimeUnit.SECONDS));
return new Uploads(data, promotion);
}
use of org.jboss.pnc.model.Artifact in project pnc by project-ncl.
the class IndyRepositorySession method collectDownloadedArtifacts.
private List<Artifact> collectDownloadedArtifacts(TrackedContentDTO report) throws RepositoryManagerException {
IndyContentClientModule content;
try {
content = indy.content();
} catch (IndyClientException e) {
throw new RepositoryManagerException("Failed to retrieve Indy content module. Reason: %s", e, e.getMessage());
}
Set<TrackedContentEntryDTO> downloads = report.getDownloads();
List<Artifact> deps = new ArrayList<>(downloads.size());
for (TrackedContentEntryDTO download : downloads) {
String path = download.getPath();
if (artifactFilter.acceptsForData(download)) {
String identifier = computeIdentifier(download);
String purl = computePurl(download);
logger.info("Recording download: {}", identifier);
String originUrl = download.getOriginUrl();
if (originUrl == null) {
// this is from a hosted repository, either shared-imports or a build, or something like that.
originUrl = download.getLocalUrl();
}
TargetRepository targetRepository = getDownloadsTargetRepository(download, content);
Artifact.Builder artifactBuilder = Artifact.Builder.newBuilder().md5(download.getMd5()).sha1(download.getSha1()).sha256(download.getSha256()).size(download.getSize()).deployPath(path).originUrl(originUrl).importDate(Date.from(Instant.now())).filename(new File(path).getName()).identifier(identifier).purl(purl).targetRepository(targetRepository);
Artifact artifact = validateArtifact(artifactBuilder.build());
deps.add(artifact);
}
}
return deps;
}
Aggregations