use of org.jboss.pnc.facade.providers.api.UserRoles.SYSTEM_USER in project pnc by project-ncl.
the class BuildProviderImpl method setBuiltArtifacts.
@RolesAllowed(SYSTEM_USER)
@Override
public void setBuiltArtifacts(String buildId, List<String> artifactIds) {
Set<Integer> ids = artifactIds.stream().map(Integer::valueOf).collect(Collectors.toSet());
List<Artifact> artifacts = artifactRepository.queryWithPredicates(withIds(ids));
if (ids.size() != artifacts.size()) {
artifacts.stream().map(Artifact::getId).forEach(ids::remove);
throw new InvalidEntityException("Artifacts not found, missing ids: " + ids);
}
final Base32LongID id = parseId(buildId);
BuildRecord buildRecord = repository.queryById(id);
for (Artifact artifact : artifacts) {
if (artifact.getBuildRecord() != null && !id.equals(artifact.getBuildRecord().getId())) {
throw new ConflictedEntryException("Artifact " + artifact.getId() + " is already marked as built by different build.", BuildRecord.class, BuildMapper.idMapper.toDto(artifact.getBuildRecord().getId()));
}
artifact.setBuildRecord(buildRecord);
}
HashSet<Artifact> oldBuiltArtifacts = new HashSet<>(buildRecord.getBuiltArtifacts());
oldBuiltArtifacts.stream().filter(a -> !ids.contains(a.getId())).forEach(a -> a.setBuildRecord(null));
}
use of org.jboss.pnc.facade.providers.api.UserRoles.SYSTEM_USER in project pnc by project-ncl.
the class BuildProviderImpl method setDependentArtifacts.
@RolesAllowed(SYSTEM_USER)
@Override
public void setDependentArtifacts(String buildId, List<String> artifactIds) {
BuildRecord buildRecord = repository.queryById(parseId(buildId));
Set<Artifact> artifacts = artifactIds.stream().map(aId -> Artifact.Builder.newBuilder().id(Integer.valueOf(aId)).build()).collect(Collectors.toSet());
buildRecord.setDependencies(artifacts);
repository.save(buildRecord);
}
Aggregations