use of org.jboss.pnc.facade.validation.EmptyEntityException in project pnc by project-ncl.
the class BuildProviderImpl method getDependencyGraph.
@Override
public Graph<Build> getDependencyGraph(String buildId) {
Build specific = getSpecific(buildId);
if (specific == null) {
throw new EmptyEntityException("there is no record for given buildId.");
}
org.jboss.util.graph.Graph<BuildWithDependencies> buildGraph = createBuildDependencyGraph(buildId);
GraphDtoBuilder<BuildWithDependencies, Build> graphBuilder = new GraphDtoBuilder();
return graphBuilder.from(buildGraph, Build.class, vertex -> vertex.getData().getBuild());
}
use of org.jboss.pnc.facade.validation.EmptyEntityException in project pnc by project-ncl.
the class BuildProviderImpl method getBuildGraphForGroupBuild.
@Override
public Graph<Build> getBuildGraphForGroupBuild(String groupBuildId) {
BuildConfigSetRecord buildConfigSetRecord = buildConfigSetRecordRepository.queryById(Integer.valueOf(groupBuildId));
if (buildConfigSetRecord == null) {
throw new EmptyEntityException("Build group " + groupBuildId + " does not exists.");
}
List<String> runningAndStoredIds = getBuildIdsInTheGroup(buildConfigSetRecord);
org.jboss.util.graph.Graph<BuildWithDependencies> buildGraph = new org.jboss.util.graph.Graph<>();
for (String buildId : runningAndStoredIds) {
org.jboss.util.graph.Graph<BuildWithDependencies> dependencyGraph = createBuildDependencyGraph(buildId);
GraphUtils.merge(buildGraph, dependencyGraph);
logger.trace("Merged graph from buildRecordId {} to BuildConfigSetRecordGraph {}; Edges {},", buildId, buildGraph, buildGraph.getEdges());
}
GraphDtoBuilder<BuildWithDependencies, Build> graphBuilder = new GraphDtoBuilder();
Graph<Build> graphDto = graphBuilder.from(buildGraph, Build.class, vertex -> vertex.getData().getBuild());
return graphDto;
}
use of org.jboss.pnc.facade.validation.EmptyEntityException in project pnc by project-ncl.
the class BuildConfigurationProviderImpl method validateEnvironment.
private void validateEnvironment(BuildConfiguration buildConfigurationRest) {
String envId = buildConfigurationRest.getEnvironment().getId();
BuildEnvironment env = buildEnvironmentRepository.queryById(Integer.valueOf(envId));
if (env == null) {
throw new EmptyEntityException("Build environment " + envId + " does not exist.");
}
}
use of org.jboss.pnc.facade.validation.EmptyEntityException in project pnc by project-ncl.
the class BrewPusherImpl method brewPushCancel.
@Override
public boolean brewPushCancel(String buildId) {
Base32LongID id = BuildMapper.idMapper.toEntity(buildId);
Optional<InProgress.Context> pushContext = buildResultPushManager.getContext(id);
if (pushContext.isPresent()) {
MDCUtils.addProcessContext(pushContext.get().getPushResultId());
MDCUtils.addCustomContext(BUILD_ID_KEY, id.getId());
userLog.info("Build push cancel requested.");
try {
return buildResultPushManager.cancelInProgressPush(id);
} finally {
MDCUtils.removeProcessContext();
MDCUtils.removeCustomContext(BUILD_ID_KEY);
}
} else {
throw new EmptyEntityException("There is no running push operation for build id: " + buildId);
}
}
use of org.jboss.pnc.facade.validation.EmptyEntityException in project pnc by project-ncl.
the class BpmEndpointImpl method notifyTask.
@Override
public void notifyTask(int taskId) {
String content;
JsonNode node;
try {
content = readContent(request.getInputStream());
node = JsonOutputConverterMapper.getMapper().readTree(content);
} catch (IOException e) {
throw new RuntimeException("Could not get JSON from request data. " + "Verify it is not empty and in the correct format.", e);
}
if (!node.has("eventType")) {
throw new RuntimeException("Request JSON does not contain required \"eventType\" field.");
}
String eventTypeName = node.get("eventType").asText();
BpmEventType eventType = nullableValueOf(eventTypeName);
if (eventType != null) {
BpmEvent notification;
try {
notification = JsonOutputConverterMapper.getMapper().readValue(node.traverse(), eventType.getType());
} catch (IOException e) {
throw new RuntimeException("Could not deserialize JSON request for event type '" + eventTypeName + "' " + " into '" + eventType.getType() + "'. JSON value: " + content, e);
}
logger.debug("Received notification {} for BPM task with id {}.", notification, taskId);
try {
bpmManager.notify(taskId, notification);
} catch (NoEntityException e) {
throw new EmptyEntityException(e.getMessage());
}
} else {
logger.info("Received notification with unknown eventType {}, ignoring it.", eventTypeName);
}
}
Aggregations