@Test(expected = ResourceNotFoundException.class) public void testRevertFlowWhenFlowDoesNotExist() { flowManager.revertToFlowRevision("DOES-NOT-EXIST", new BigInteger("1")); }
@Override public void revertToFlowRevision(final String flowId, final BigInteger flowRevision) { if (StringUtils.isBlank(flowId)) { throw new IllegalArgumentException("Flow id cannot be null or blank"); } if (flowRevision == null) { throw new IllegalArgumentException("Flow revision cannot be null"); } final Optional<FDFlowEntity> flowEntity = flowRepository.findById(flowId); if (!flowEntity.isPresent()) { throw new ResourceNotFoundException("No flow exists with the provided flow id"); } final Optional<FDFlowEventEntity> flowEventEntity = flowEventRepository.findByFlowAndFlowRevision(flowEntity.get(), flowRevision); if (!flowEventEntity.isPresent()) { throw new ResourceNotFoundException("No flow event exists with given event id for the given flow"); } flowEventRepository.deleteByFlowAndFlowRevisionGreaterThan(flowEntity.get(), flowEventEntity.get().getFlowRevision()); if (flowsById.containsKey(flowEntity.get().getId())) { flowsById.remove(flowEntity.get().getId()); } }
DatabaseFDFlowManager extends BaseService implements FDFlowManager { @Override public void revertToFlowRevision(final String flowId, final BigInteger flowRevision) { if (StringUtils.isBlank(flowId)) { throw new IllegalArgumentException("Flow id cannot be null or blank"); } if (flowRevision == null) { throw new IllegalArgumentException("Flow revision cannot be null"); } final Optional<FDFlowEntity> flowEntity = flowRepository.findById(flowId); if (!flowEntity.isPresent()) { throw new ResourceNotFoundException("No flow exists with the provided flow id"); } final Optional<FDFlowEventEntity> flowEventEntity = flowEventRepository.findByFlowAndFlowRevision(flowEntity.get(), flowRevision); if (!flowEventEntity.isPresent()) { throw new ResourceNotFoundException("No flow event exists with given event id for the given flow"); } flowEventRepository.deleteByFlowAndFlowRevisionGreaterThan(flowEntity.get(), flowEventEntity.get().getFlowRevision()); if (flowsById.containsKey(flowEntity.get().getId())) { flowsById.remove(flowEntity.get().getId()); } } }
DatabaseFDFlowManager extends BaseService implements FDFlowManager { @Override public void revertToFlowRevision(final String flowId, final BigInteger flowRevision) { if (StringUtils.isBlank(flowId)) { throw new IllegalArgumentException("Flow id cannot be null or blank"); } if (flowRevision == null) { throw new IllegalArgumentException("Flow revision cannot be null"); } final Optional<FDFlowEntity> flowEntity = flowRepository.findById(flowId); if (!flowEntity.isPresent()) { throw new ResourceNotFoundException("No flow exists with the provided flow id"); } final Optional<FDFlowEventEntity> flowEventEntity = flowEventRepository.findByFlowAndFlowRevision(flowEntity.get(), flowRevision); if (!flowEventEntity.isPresent()) { throw new ResourceNotFoundException("No flow event exists with given event id for the given flow"); } flowEventRepository.deleteByFlowAndFlowRevisionGreaterThan(flowEntity.get(), flowEventEntity.get().getFlowRevision()); if (flowsById.containsKey(flowEntity.get().getId())) { flowsById.remove(flowEntity.get().getId()); } } @Autowired  DatabaseFDFlowManager(final FDFlowRepository flowRepository,
                                 final FDFlowEventRepository flowEventRepository,
                                 final OptionalModelMapper modelMapper,
                                 final ObjectMapper objectMapper,
                                 final Validator validator); }
DatabaseFDFlowManager extends BaseService implements FDFlowManager { @Override public void revertToFlowRevision(final String flowId, final BigInteger flowRevision) { if (StringUtils.isBlank(flowId)) { throw new IllegalArgumentException("Flow id cannot be null or blank"); } if (flowRevision == null) { throw new IllegalArgumentException("Flow revision cannot be null"); } final Optional<FDFlowEntity> flowEntity = flowRepository.findById(flowId); if (!flowEntity.isPresent()) { throw new ResourceNotFoundException("No flow exists with the provided flow id"); } final Optional<FDFlowEventEntity> flowEventEntity = flowEventRepository.findByFlowAndFlowRevision(flowEntity.get(), flowRevision); if (!flowEventEntity.isPresent()) { throw new ResourceNotFoundException("No flow event exists with given event id for the given flow"); } flowEventRepository.deleteByFlowAndFlowRevisionGreaterThan(flowEntity.get(), flowEventEntity.get().getFlowRevision()); if (flowsById.containsKey(flowEntity.get().getId())) { flowsById.remove(flowEntity.get().getId()); } } @Autowired  DatabaseFDFlowManager(final FDFlowRepository flowRepository,
                                 final FDFlowEventRepository flowEventRepository,
                                 final OptionalModelMapper modelMapper,
                                 final ObjectMapper objectMapper,
                                 final Validator validator); @Override Optional<FDFlowMetadata> getFlowMetadata(final String flowId); @Override Optional<FDFlow> getFlow(final String flowId); @Override FDFlowMetadata createFlow(final String agentClass, final NiFiUser user); @Override List<FDFlowMetadata> getAvailableFlows(); @Override List<FDFlowSummary> getFlowSummaries(); @Override FDFlowMetadata deleteFlow(final String flowId); @Override List<FDFlowEvent> getFlowEvents(final String flowId); @Override Optional<FDFlowEvent> getLatestFlowEvent(final String flowId); @Override Optional<FDFlowEvent> getLatestPublishFlowEvent(final String flowId); @Override Optional<FDFlowEvent> getFlowEvent(final String flowEventId); @Override FDFlowEvent addFlowEvent(final FDFlowEvent flowEvent, final VersionedProcessGroup flowContent, final NiFiUser user); @Override FDFlowEvent deleteFlowEvent(final String flowEventId); @Override void retainPublishEvents(final String flowId); @Override void revertToFlowRevision(final String flowId, final BigInteger flowRevision); }
DatabaseFDFlowManager extends BaseService implements FDFlowManager { @Override public void revertToFlowRevision(final String flowId, final BigInteger flowRevision) { if (StringUtils.isBlank(flowId)) { throw new IllegalArgumentException("Flow id cannot be null or blank"); } if (flowRevision == null) { throw new IllegalArgumentException("Flow revision cannot be null"); } final Optional<FDFlowEntity> flowEntity = flowRepository.findById(flowId); if (!flowEntity.isPresent()) { throw new ResourceNotFoundException("No flow exists with the provided flow id"); } final Optional<FDFlowEventEntity> flowEventEntity = flowEventRepository.findByFlowAndFlowRevision(flowEntity.get(), flowRevision); if (!flowEventEntity.isPresent()) { throw new ResourceNotFoundException("No flow event exists with given event id for the given flow"); } flowEventRepository.deleteByFlowAndFlowRevisionGreaterThan(flowEntity.get(), flowEventEntity.get().getFlowRevision()); if (flowsById.containsKey(flowEntity.get().getId())) { flowsById.remove(flowEntity.get().getId()); } } @Autowired  DatabaseFDFlowManager(final FDFlowRepository flowRepository,
                                 final FDFlowEventRepository flowEventRepository,
                                 final OptionalModelMapper modelMapper,
                                 final ObjectMapper objectMapper,
                                 final Validator validator); @Override Optional<FDFlowMetadata> getFlowMetadata(final String flowId); @Override Optional<FDFlow> getFlow(final String flowId); @Override FDFlowMetadata createFlow(final String agentClass, final NiFiUser user); @Override List<FDFlowMetadata> getAvailableFlows(); @Override List<FDFlowSummary> getFlowSummaries(); @Override FDFlowMetadata deleteFlow(final String flowId); @Override List<FDFlowEvent> getFlowEvents(final String flowId); @Override Optional<FDFlowEvent> getLatestFlowEvent(final String flowId); @Override Optional<FDFlowEvent> getLatestPublishFlowEvent(final String flowId); @Override Optional<FDFlowEvent> getFlowEvent(final String flowEventId); @Override FDFlowEvent addFlowEvent(final FDFlowEvent flowEvent, final VersionedProcessGroup flowContent, final NiFiUser user); @Override FDFlowEvent deleteFlowEvent(final String flowEventId); @Override void retainPublishEvents(final String flowId); @Override void revertToFlowRevision(final String flowId, final BigInteger flowRevision); static final FDFlowFormat CURRENT_FLOW_FORMAT; }