test_class.declarator: flowManager
test_class.modifier: @Autowired
      private
test_class.original_string: @Autowired
      private FDFlowManager flowManager;
test_class.type: FDFlowManager
test_class.var_name: flowManager
test_class.file: efm/efm-flow-designer/efm-flow-designer-framework/src/test/java/com/cloudera/cem/efm/service/flow/TestDatabaseFDFlowManager.java
test_class.identifier: TestDatabaseFDFlowManager
test_class.superclass: extends DatabaseTest
test_case.body: @Test(expected = IllegalArgumentException.class)
      public void testAddFlowEventAndTryToChangeRootGroupId() {
          final FDFlowEvent flowEvent = new FDFlowEvent();
          flowEvent.setFlowIdentifier("2");
          flowEvent.setComponentId("proc-1");
          flowEvent.setEventType(FDFlowEventType.COMPONENT_ADDED);
          flowEvent.setEventDescription("Added TailFile processor");
          flowEvent.setUserIdentity("test-user");
  
          final VersionedProcessGroup pg = new VersionedProcessGroup();
          pg.setIdentifier(UUID.randomUUID().toString()); // SET A DIFFERENT ID HERE WHICH ISN'T ALLOWED
          pg.setName("root");
  
          final NiFiUser user = new StandardNiFiUser.Builder().identity("system").build();
  
          flowManager.addFlowEvent(flowEvent, pg, user);
      }
test_case.class_method_signature: TestDatabaseFDFlowManager.testAddFlowEventAndTryToChangeRootGroupId()
test_case.full_signature: @Test(expected = IllegalArgumentException.class) public void testAddFlowEventAndTryToChangeRootGroupId()
test_case.identifier: testAddFlowEventAndTryToChangeRootGroupId
test_case.invocations: setFlowIdentifier setComponentId setEventType setEventDescription setUserIdentity setIdentifier toString randomUUID setName build identity addFlowEvent
test_case.modifiers: @Test(expected = IllegalArgumentException.class) public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testAddFlowEventAndTryToChangeRootGroupId()
focal_class.declarator: ROOT_PROCESS_GROUP_NAME = "root"
focal_class.modifier: static final
focal_class.original_string: static final String ROOT_PROCESS_GROUP_NAME = "root";
focal_class.type: String
focal_class.var_name: ROOT_PROCESS_GROUP_NAME
focal_class.declarator: UNPUBLISHED = "UNPUBLISHED"
focal_class.modifier: static final
focal_class.original_string: static final String UNPUBLISHED = "UNPUBLISHED";
focal_class.type: String
focal_class.var_name: UNPUBLISHED
focal_class.declarator: CURRENT_FLOW_FORMAT = FDFlowFormat.JACKSON_JSON_V1
focal_class.modifier: public static final
focal_class.original_string: public static final FDFlowFormat CURRENT_FLOW_FORMAT = FDFlowFormat.JACKSON_JSON_V1;
focal_class.type: FDFlowFormat
focal_class.var_name: CURRENT_FLOW_FORMAT
focal_class.declarator: flowRepository
focal_class.modifier: private final
focal_class.original_string: private final FDFlowRepository flowRepository;
focal_class.type: FDFlowRepository
focal_class.var_name: flowRepository
focal_class.declarator: flowEventRepository
focal_class.modifier: private final
focal_class.original_string: private final FDFlowEventRepository flowEventRepository;
focal_class.type: FDFlowEventRepository
focal_class.var_name: flowEventRepository
focal_class.declarator: objectMapper
focal_class.modifier: private final
focal_class.original_string: private final ObjectMapper objectMapper;
focal_class.type: ObjectMapper
focal_class.var_name: objectMapper
focal_class.declarator: flowsById = new ConcurrentHashMap<>()
focal_class.modifier: private
focal_class.original_string: private Map<String,FDFlow> flowsById = new ConcurrentHashMap<>();
focal_class.type: Map<String,FDFlow>
focal_class.var_name: flowsById
focal_class.file: efm/efm-flow-designer/efm-flow-designer-framework/src/main/java/com/cloudera/cem/efm/service/flow/DatabaseFDFlowManager.java
focal_class.identifier: DatabaseFDFlowManager
focal_class.interfaces: implements FDFlowManager
focal_class.class_method_signature: DatabaseFDFlowManager.DatabaseFDFlowManager(final FDFlowRepository flowRepository,
                                   final FDFlowEventRepository flowEventRepository,
                                   final OptionalModelMapper modelMapper,
                                   final ObjectMapper objectMapper,
                                   final Validator validator)
focal_class.full_signature: @Autowired public  DatabaseFDFlowManager(final FDFlowRepository flowRepository,
                                   final FDFlowEventRepository flowEventRepository,
                                   final OptionalModelMapper modelMapper,
                                   final ObjectMapper objectMapper,
                                   final Validator validator)
focal_class.identifier: DatabaseFDFlowManager
focal_class.modifiers: @Autowired public
focal_class.parameters: (final FDFlowRepository flowRepository,
                                   final FDFlowEventRepository flowEventRepository,
                                   final OptionalModelMapper modelMapper,
                                   final ObjectMapper objectMapper,
                                   final Validator validator)
focal_class.signature:  DatabaseFDFlowManager(final FDFlowRepository flowRepository,
                                   final FDFlowEventRepository flowEventRepository,
                                   final OptionalModelMapper modelMapper,
                                   final ObjectMapper objectMapper,
                                   final Validator validator)
focal_class.class_method_signature: DatabaseFDFlowManager.getFlowMetadata(final String flowId)
focal_class.full_signature: @Override public Optional<FDFlowMetadata> getFlowMetadata(final String flowId)
focal_class.identifier: getFlowMetadata
focal_class.modifiers: @Override public
focal_class.parameters: (final String flowId)
focal_class.return: Optional<FDFlowMetadata>
focal_class.signature: Optional<FDFlowMetadata> getFlowMetadata(final String flowId)
focal_class.class_method_signature: DatabaseFDFlowManager.getFlow(final String flowId)
focal_class.full_signature: @Override public Optional<FDFlow> getFlow(final String flowId)
focal_class.identifier: getFlow
focal_class.modifiers: @Override public
focal_class.parameters: (final String flowId)
focal_class.return: Optional<FDFlow>
focal_class.signature: Optional<FDFlow> getFlow(final String flowId)
focal_class.class_method_signature: DatabaseFDFlowManager.createFlow(final String agentClass, final NiFiUser user)
focal_class.full_signature: @Override public FDFlowMetadata createFlow(final String agentClass, final NiFiUser user)
focal_class.identifier: createFlow
focal_class.modifiers: @Override public
focal_class.parameters: (final String agentClass, final NiFiUser user)
focal_class.return: FDFlowMetadata
focal_class.signature: FDFlowMetadata createFlow(final String agentClass, final NiFiUser user)
focal_class.class_method_signature: DatabaseFDFlowManager.getAvailableFlows()
focal_class.full_signature: @Override public List<FDFlowMetadata> getAvailableFlows()
focal_class.identifier: getAvailableFlows
focal_class.modifiers: @Override public
focal_class.parameters: ()
focal_class.return: List<FDFlowMetadata>
focal_class.signature: List<FDFlowMetadata> getAvailableFlows()
focal_class.class_method_signature: DatabaseFDFlowManager.getFlowSummaries()
focal_class.full_signature: @Override public List<FDFlowSummary> getFlowSummaries()
focal_class.identifier: getFlowSummaries
focal_class.modifiers: @Override public
focal_class.parameters: ()
focal_class.return: List<FDFlowSummary>
focal_class.signature: List<FDFlowSummary> getFlowSummaries()
focal_class.class_method_signature: DatabaseFDFlowManager.deleteFlow(final String flowId)
focal_class.full_signature: @Override public FDFlowMetadata deleteFlow(final String flowId)
focal_class.identifier: deleteFlow
focal_class.modifiers: @Override public
focal_class.parameters: (final String flowId)
focal_class.return: FDFlowMetadata
focal_class.signature: FDFlowMetadata deleteFlow(final String flowId)
focal_class.class_method_signature: DatabaseFDFlowManager.getFlowEvents(final String flowId)
focal_class.full_signature: @Override public List<FDFlowEvent> getFlowEvents(final String flowId)
focal_class.identifier: getFlowEvents
focal_class.modifiers: @Override public
focal_class.parameters: (final String flowId)
focal_class.return: List<FDFlowEvent>
focal_class.signature: List<FDFlowEvent> getFlowEvents(final String flowId)
focal_class.class_method_signature: DatabaseFDFlowManager.getLatestFlowEvent(final String flowId)
focal_class.full_signature: @Override public Optional<FDFlowEvent> getLatestFlowEvent(final String flowId)
focal_class.identifier: getLatestFlowEvent
focal_class.modifiers: @Override public
focal_class.parameters: (final String flowId)
focal_class.return: Optional<FDFlowEvent>
focal_class.signature: Optional<FDFlowEvent> getLatestFlowEvent(final String flowId)
focal_class.class_method_signature: DatabaseFDFlowManager.getLatestFlowEventEntity(final String flowId)
focal_class.full_signature: private Optional<FDFlowEventEntity> getLatestFlowEventEntity(final String flowId)
focal_class.identifier: getLatestFlowEventEntity
focal_class.modifiers: private
focal_class.parameters: (final String flowId)
focal_class.return: Optional<FDFlowEventEntity>
focal_class.signature: Optional<FDFlowEventEntity> getLatestFlowEventEntity(final String flowId)
focal_class.class_method_signature: DatabaseFDFlowManager.getLatestPublishFlowEvent(final String flowId)
focal_class.full_signature: @Override public Optional<FDFlowEvent> getLatestPublishFlowEvent(final String flowId)
focal_class.identifier: getLatestPublishFlowEvent
focal_class.modifiers: @Override public
focal_class.parameters: (final String flowId)
focal_class.return: Optional<FDFlowEvent>
focal_class.signature: Optional<FDFlowEvent> getLatestPublishFlowEvent(final String flowId)
focal_class.class_method_signature: DatabaseFDFlowManager.getFlowEvent(final String flowEventId)
focal_class.full_signature: @Override public Optional<FDFlowEvent> getFlowEvent(final String flowEventId)
focal_class.identifier: getFlowEvent
focal_class.modifiers: @Override public
focal_class.parameters: (final String flowEventId)
focal_class.return: Optional<FDFlowEvent>
focal_class.signature: Optional<FDFlowEvent> getFlowEvent(final String flowEventId)
focal_class.class_method_signature: DatabaseFDFlowManager.addFlowEvent(final FDFlowEvent flowEvent, final VersionedProcessGroup flowContent, final NiFiUser user)
focal_class.full_signature: @Override public FDFlowEvent addFlowEvent(final FDFlowEvent flowEvent, final VersionedProcessGroup flowContent, final NiFiUser user)
focal_class.identifier: addFlowEvent
focal_class.modifiers: @Override public
focal_class.parameters: (final FDFlowEvent flowEvent, final VersionedProcessGroup flowContent, final NiFiUser user)
focal_class.return: FDFlowEvent
focal_class.signature: FDFlowEvent addFlowEvent(final FDFlowEvent flowEvent, final VersionedProcessGroup flowContent, final NiFiUser user)
focal_class.class_method_signature: DatabaseFDFlowManager.deleteFlowEvent(final String flowEventId)
focal_class.full_signature: @Override public FDFlowEvent deleteFlowEvent(final String flowEventId)
focal_class.identifier: deleteFlowEvent
focal_class.modifiers: @Override public
focal_class.parameters: (final String flowEventId)
focal_class.return: FDFlowEvent
focal_class.signature: FDFlowEvent deleteFlowEvent(final String flowEventId)
focal_class.class_method_signature: DatabaseFDFlowManager.retainPublishEvents(final String flowId)
focal_class.full_signature: @Override public void retainPublishEvents(final String flowId)
focal_class.identifier: retainPublishEvents
focal_class.modifiers: @Override public
focal_class.parameters: (final String flowId)
focal_class.return: void
focal_class.signature: void retainPublishEvents(final String flowId)
focal_class.class_method_signature: DatabaseFDFlowManager.revertToFlowRevision(final String flowId, final BigInteger flowRevision)
focal_class.full_signature: @Override public void revertToFlowRevision(final String flowId, final BigInteger flowRevision)
focal_class.identifier: revertToFlowRevision
focal_class.modifiers: @Override public
focal_class.parameters: (final String flowId, final BigInteger flowRevision)
focal_class.return: void
focal_class.signature: void revertToFlowRevision(final String flowId, final BigInteger flowRevision)
focal_class.class_method_signature: DatabaseFDFlowManager.serializeFlowContent(final VersionedProcessGroup flowContent)
focal_class.full_signature: private String serializeFlowContent(final VersionedProcessGroup flowContent)
focal_class.identifier: serializeFlowContent
focal_class.modifiers: private
focal_class.parameters: (final VersionedProcessGroup flowContent)
focal_class.return: String
focal_class.signature: String serializeFlowContent(final VersionedProcessGroup flowContent)
focal_class.class_method_signature: DatabaseFDFlowManager.deserialize(String flowContent)
focal_class.full_signature: private VersionedProcessGroup deserialize(String flowContent)
focal_class.identifier: deserialize
focal_class.modifiers: private
focal_class.parameters: (String flowContent)
focal_class.return: VersionedProcessGroup
focal_class.signature: VersionedProcessGroup deserialize(String flowContent)
focal_class.class_method_signature: DatabaseFDFlowManager.createVersionInfo(final FDFlowEventEntity flowEvent)
focal_class.full_signature: private FDVersionInfo createVersionInfo(final FDFlowEventEntity flowEvent)
focal_class.identifier: createVersionInfo
focal_class.modifiers: private
focal_class.parameters: (final FDFlowEventEntity flowEvent)
focal_class.return: FDVersionInfo
focal_class.signature: FDVersionInfo createVersionInfo(final FDFlowEventEntity flowEvent)
focal_class.superclass: extends BaseService
focal_method.body: @Override
      public FDFlowEvent addFlowEvent(final FDFlowEvent flowEvent, final VersionedProcessGroup flowContent, final NiFiUser user) {
          if (flowEvent == null) {
              throw new IllegalArgumentException("Flow event cannot be null or blank");
          }
  
          if (StringUtils.isBlank(flowEvent.getFlowIdentifier())) {
              throw new IllegalArgumentException("Flow identifier of flow event cannot be null or blank");
          }
  
          if (flowContent == null) {
              throw new IllegalArgumentException("Flow content cannot be null or blank");
          }
  
          if (StringUtils.isBlank(flowContent.getIdentifier()) || StringUtils.isBlank(flowContent.getName())) {
              throw new IllegalArgumentException("Flow content must contain a root process group with an identifier and name");
          }
  
          if (user == null || StringUtils.isBlank(user.getIdentity())) {
              throw new IllegalArgumentException("A user identity must be provided");
          }
  
          final Optional<FDFlowEntity> flowEntity = flowRepository.findById(flowEvent.getFlowIdentifier());
          if (!flowEntity.isPresent()) {
              throw new ResourceNotFoundException("No flow exists with the provided flow id");
          }
  
          final String previousRootGroupId = flowEntity.get().getRootProcessGroupId();
          final String incomingRootGroupId = flowContent.getIdentifier();
          if (!previousRootGroupId.equals(incomingRootGroupId)) {
              throw new IllegalArgumentException("Cannot change the id of the root process group");
          }
  
          final Optional<FDFlowEventEntity> latestFlowEvent = flowEventRepository.findFirstByFlowOrderByFlowRevisionDesc(flowEntity.get());
          if (!latestFlowEvent.isPresent()) {
              throw new IllegalStateException("Could not find any flow content for the given flow");
          }
  
          final BigInteger currRevision = latestFlowEvent.get().getFlowRevision();
          final BigInteger nextRevision = currRevision.add(BigInteger.ONE);
  
          flowEvent.setIdentifier(UUID.randomUUID().toString());
          flowEvent.setCreated(System.currentTimeMillis());
          flowEvent.setUpdated(System.currentTimeMillis());
          flowEvent.setFlowRevision(nextRevision);
          flowEvent.setFlowFormat(CURRENT_FLOW_FORMAT);
          flowEvent.setUserIdentity(user.getIdentity());
  
          // if not a publish event then carry forward the registry info from the previous event, otherwise use whatever was specified
          if (flowEvent.getEventType() != FDFlowEventType.FLOW_PUBLISHED) {
              flowEvent.setRegistryUrl(latestFlowEvent.get().getRegistryUrl());
              flowEvent.setRegistryBucketId(latestFlowEvent.get().getRegistryBucketId());
              flowEvent.setRegistryFlowId(latestFlowEvent.get().getRegistryFlowId());
              flowEvent.setRegistryVersion(latestFlowEvent.get().getRegistryVersion());
  
              final Date lastPublished = latestFlowEvent.get().getLastPublished();
              flowEvent.setLastPublished(lastPublished == null ? null : lastPublished.getTime());
              flowEvent.setLastPublishedUserIdentity(latestFlowEvent.get().getLastPublishedUserIdentity());
          }
  
          if (flowEvent.getEventType() == FDFlowEventType.FLOW_PUBLISHED && flowEvent.getLastPublished() == null) {
              throw new IllegalArgumentException("Publish event must contain a published date");
          }
  
          validate(flowEvent, "Cannot add flow event due to invalid event");
  
          final FDFlowEventEntity flowEventEntity = modelMapper.map(flowEvent, FDFlowEventEntity.class);
          flowEventEntity.setFlowContent(serializeFlowContent(flowContent));
          flowEventEntity.setFlow(flowEntity.get());
  
          final FDFlowEventEntity savedFlowEventEntity = flowEventRepository.save(flowEventEntity);
  
          // Update the cached flow with the latest version info
          final String flowId = flowEntity.get().getId();
          if (flowsById.containsKey(flowId)) {
              final FDVersionInfo versionInfo = createVersionInfo(savedFlowEventEntity);
              final FDFlow cachedFlow = flowsById.get(flowId);
              cachedFlow.setVersionInfo(versionInfo);
              cachedFlow.setLocalFlowRevision(savedFlowEventEntity.getFlowRevision());
          }
  
          return modelMapper.map(savedFlowEventEntity, FDFlowEvent.class);
      }
focal_method.class_method_signature: DatabaseFDFlowManager.addFlowEvent(final FDFlowEvent flowEvent, final VersionedProcessGroup flowContent, final NiFiUser user)
focal_method.full_signature: @Override public FDFlowEvent addFlowEvent(final FDFlowEvent flowEvent, final VersionedProcessGroup flowContent, final NiFiUser user)
focal_method.identifier: addFlowEvent
focal_method.invocations: isBlank getFlowIdentifier isBlank getIdentifier isBlank getName isBlank getIdentity findById getFlowIdentifier isPresent getRootProcessGroupId get getIdentifier equals findFirstByFlowOrderByFlowRevisionDesc get isPresent getFlowRevision get add setIdentifier toString randomUUID setCreated currentTimeMillis setUpdated currentTimeMillis setFlowRevision setFlowFormat setUserIdentity getIdentity getEventType setRegistryUrl getRegistryUrl get setRegistryBucketId getRegistryBucketId get setRegistryFlowId getRegistryFlowId get setRegistryVersion getRegistryVersion get getLastPublished get setLastPublished getTime setLastPublishedUserIdentity getLastPublishedUserIdentity get getEventType getLastPublished validate map setFlowContent serializeFlowContent setFlow get save getId get containsKey createVersionInfo get setVersionInfo setLocalFlowRevision getFlowRevision map
focal_method.modifiers: @Override public
focal_method.parameters: (final FDFlowEvent flowEvent, final VersionedProcessGroup flowContent, final NiFiUser user)
focal_method.return: FDFlowEvent
focal_method.signature: FDFlowEvent addFlowEvent(final FDFlowEvent flowEvent, final VersionedProcessGroup flowContent, final NiFiUser user)