use of org.openkilda.persistence.exceptions.ConstraintViolationException in project open-kilda by telstra.
the class ResourcesAllocationAction method createFlow.
private void createFlow(RequestedFlow targetFlow) throws FlowNotFoundException, FlowAlreadyExistException {
try {
transactionManager.doInTransaction(() -> {
Flow flow = RequestedFlowMapper.INSTANCE.toFlow(targetFlow);
flow.setStatus(FlowStatus.IN_PROGRESS);
getFlowDiverseGroupFromContext(targetFlow.getDiverseFlowId()).ifPresent(flow::setDiverseGroupId);
getFlowAffinityGroupFromContext(targetFlow.getAffinityFlowId()).ifPresent(flow::setAffinityGroupId);
flowRepository.add(flow);
});
} catch (ConstraintViolationException e) {
throw new FlowAlreadyExistException(format("Failed to save flow with id %s", targetFlow.getFlowId()), e);
}
}
Aggregations