Search in sources :

Example 1 with ConstraintViolationException

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);
    }
}
Also used : FlowAlreadyExistException(org.openkilda.wfm.error.FlowAlreadyExistException) ConstraintViolationException(org.openkilda.persistence.exceptions.ConstraintViolationException) Flow(org.openkilda.model.Flow) YSubFlow(org.openkilda.model.YSubFlow) RequestedFlow(org.openkilda.wfm.topology.flowhs.model.RequestedFlow) YFlow(org.openkilda.model.YFlow)

Aggregations

Flow (org.openkilda.model.Flow)1 YFlow (org.openkilda.model.YFlow)1 YSubFlow (org.openkilda.model.YSubFlow)1 ConstraintViolationException (org.openkilda.persistence.exceptions.ConstraintViolationException)1 FlowAlreadyExistException (org.openkilda.wfm.error.FlowAlreadyExistException)1 RequestedFlow (org.openkilda.wfm.topology.flowhs.model.RequestedFlow)1