Class AbstractGitFlowRegistryClient

java.lang.Object
org.apache.nifi.components.AbstractConfigurableComponent
org.apache.nifi.registry.flow.AbstractFlowRegistryClient
org.apache.nifi.registry.flow.git.AbstractGitFlowRegistryClient
All Implemented Interfaces:
org.apache.nifi.components.ConfigurableComponent, org.apache.nifi.registry.flow.FlowRegistryClient

public abstract class AbstractGitFlowRegistryClient extends org.apache.nifi.registry.flow.AbstractFlowRegistryClient
Base class for git-based flow registry clients.
  • Field Details

    • REPOSITORY_BRANCH

      public static final org.apache.nifi.components.PropertyDescriptor REPOSITORY_BRANCH
    • REPOSITORY_PATH

      public static final org.apache.nifi.components.PropertyDescriptor REPOSITORY_PATH
    • DIRECTORY_FILTER_EXCLUDE

      public static final org.apache.nifi.components.PropertyDescriptor DIRECTORY_FILTER_EXCLUDE
    • DEFAULT_BUCKET_NAME

      static final String DEFAULT_BUCKET_NAME
      See Also:
    • DEFAULT_BUCKET_KEEP_FILE_PATH

      static final String DEFAULT_BUCKET_KEEP_FILE_PATH
      See Also:
    • DEFAULT_BUCKET_KEEP_FILE_CONTENT

      static final String DEFAULT_BUCKET_KEEP_FILE_CONTENT
      See Also:
    • DEFAULT_BUCKET_KEEP_FILE_MESSAGE

      static final String DEFAULT_BUCKET_KEEP_FILE_MESSAGE
      See Also:
    • REGISTER_FLOW_MESSAGE_PREFIX

      static final String REGISTER_FLOW_MESSAGE_PREFIX
      See Also:
    • REGISTER_FLOW_MESSAGE_FORMAT

      static final String REGISTER_FLOW_MESSAGE_FORMAT
      See Also:
    • DEREGISTER_FLOW_MESSAGE_FORMAT

      static final String DEREGISTER_FLOW_MESSAGE_FORMAT
      See Also:
    • DEFAULT_FLOW_SNAPSHOT_MESSAGE_FORMAT

      static final String DEFAULT_FLOW_SNAPSHOT_MESSAGE_FORMAT
      See Also:
    • SNAPSHOT_FILE_EXTENSION

      static final String SNAPSHOT_FILE_EXTENSION
      See Also:
    • SNAPSHOT_FILE_PATH_FORMAT

      static final String SNAPSHOT_FILE_PATH_FORMAT
      See Also:
    • FLOW_CONTENTS_GROUP_ID

      static final String FLOW_CONTENTS_GROUP_ID
      See Also:
    • flowSnapshotSerializer

      private volatile FlowSnapshotSerializer flowSnapshotSerializer
    • repositoryClient

      private volatile GitRepositoryClient repositoryClient
    • directoryExclusionPattern

      private volatile Pattern directoryExclusionPattern
    • clientInitialized

      private final AtomicBoolean clientInitialized
    • propertyDescriptors

      private volatile List<org.apache.nifi.components.PropertyDescriptor> propertyDescriptors
  • Constructor Details

    • AbstractGitFlowRegistryClient

      public AbstractGitFlowRegistryClient()
  • Method Details

    • initialize

      public void initialize(org.apache.nifi.registry.flow.FlowRegistryClientInitializationContext context)
      Specified by:
      initialize in interface org.apache.nifi.registry.flow.FlowRegistryClient
      Overrides:
      initialize in class org.apache.nifi.registry.flow.AbstractFlowRegistryClient
    • getSupportedPropertyDescriptors

      protected List<org.apache.nifi.components.PropertyDescriptor> getSupportedPropertyDescriptors()
      Overrides:
      getSupportedPropertyDescriptors in class org.apache.nifi.components.AbstractConfigurableComponent
    • customValidate

      protected Collection<org.apache.nifi.components.ValidationResult> customValidate(org.apache.nifi.components.ValidationContext validationContext)
      Overrides:
      customValidate in class org.apache.nifi.components.AbstractConfigurableComponent
    • onPropertyModified

      public void onPropertyModified(org.apache.nifi.components.PropertyDescriptor descriptor, String oldValue, String newValue)
      Specified by:
      onPropertyModified in interface org.apache.nifi.components.ConfigurableComponent
      Overrides:
      onPropertyModified in class org.apache.nifi.components.AbstractConfigurableComponent
    • isBranchingSupported

      public boolean isBranchingSupported(org.apache.nifi.registry.flow.FlowRegistryClientConfigurationContext context)
    • getBranches

      public Set<org.apache.nifi.registry.flow.FlowRegistryBranch> getBranches(org.apache.nifi.registry.flow.FlowRegistryClientConfigurationContext context) throws org.apache.nifi.registry.flow.FlowRegistryException, IOException
      Throws:
      org.apache.nifi.registry.flow.FlowRegistryException
      IOException
    • getDefaultBranch

      public org.apache.nifi.registry.flow.FlowRegistryBranch getDefaultBranch(org.apache.nifi.registry.flow.FlowRegistryClientConfigurationContext context)
    • getBuckets

      public Set<org.apache.nifi.registry.flow.FlowRegistryBucket> getBuckets(org.apache.nifi.registry.flow.FlowRegistryClientConfigurationContext context, String branch) throws IOException, org.apache.nifi.registry.flow.FlowRegistryException
      Throws:
      IOException
      org.apache.nifi.registry.flow.FlowRegistryException
    • getBucket

      public org.apache.nifi.registry.flow.FlowRegistryBucket getBucket(org.apache.nifi.registry.flow.FlowRegistryClientConfigurationContext context, org.apache.nifi.registry.flow.BucketLocation bucketLocation) throws org.apache.nifi.registry.flow.FlowRegistryException, IOException
      Throws:
      org.apache.nifi.registry.flow.FlowRegistryException
      IOException
    • registerFlow

      public org.apache.nifi.registry.flow.RegisteredFlow registerFlow(org.apache.nifi.registry.flow.FlowRegistryClientConfigurationContext context, org.apache.nifi.registry.flow.RegisteredFlow flow) throws org.apache.nifi.registry.flow.FlowRegistryException, IOException
      Throws:
      org.apache.nifi.registry.flow.FlowRegistryException
      IOException
    • deregisterFlow

      public org.apache.nifi.registry.flow.RegisteredFlow deregisterFlow(org.apache.nifi.registry.flow.FlowRegistryClientConfigurationContext context, org.apache.nifi.registry.flow.FlowLocation flowLocation) throws org.apache.nifi.registry.flow.FlowRegistryException, IOException
      Throws:
      org.apache.nifi.registry.flow.FlowRegistryException
      IOException
    • getFlow

      public org.apache.nifi.registry.flow.RegisteredFlow getFlow(org.apache.nifi.registry.flow.FlowRegistryClientConfigurationContext context, org.apache.nifi.registry.flow.FlowLocation flowLocation) throws org.apache.nifi.registry.flow.FlowRegistryException, IOException
      Throws:
      org.apache.nifi.registry.flow.FlowRegistryException
      IOException
    • getFlows

      public Set<org.apache.nifi.registry.flow.RegisteredFlow> getFlows(org.apache.nifi.registry.flow.FlowRegistryClientConfigurationContext context, org.apache.nifi.registry.flow.BucketLocation bucketLocation) throws IOException, org.apache.nifi.registry.flow.FlowRegistryException
      Throws:
      IOException
      org.apache.nifi.registry.flow.FlowRegistryException
    • getFlowContents

      public org.apache.nifi.registry.flow.RegisteredFlowSnapshot getFlowContents(org.apache.nifi.registry.flow.FlowRegistryClientConfigurationContext context, org.apache.nifi.registry.flow.FlowVersionLocation flowVersionLocation) throws org.apache.nifi.registry.flow.FlowRegistryException, IOException
      Throws:
      org.apache.nifi.registry.flow.FlowRegistryException
      IOException
    • registerFlowSnapshot

      public org.apache.nifi.registry.flow.RegisteredFlowSnapshot registerFlowSnapshot(org.apache.nifi.registry.flow.FlowRegistryClientConfigurationContext context, org.apache.nifi.registry.flow.RegisteredFlowSnapshot flowSnapshot, org.apache.nifi.registry.flow.RegisterAction action) throws org.apache.nifi.registry.flow.FlowRegistryException, IOException
      Throws:
      org.apache.nifi.registry.flow.FlowRegistryException
      IOException
    • getFlowVersions

      public Set<org.apache.nifi.registry.flow.RegisteredFlowSnapshotMetadata> getFlowVersions(org.apache.nifi.registry.flow.FlowRegistryClientConfigurationContext context, org.apache.nifi.registry.flow.FlowLocation flowLocation) throws org.apache.nifi.registry.flow.FlowRegistryException, IOException
      Throws:
      org.apache.nifi.registry.flow.FlowRegistryException
      IOException
    • getLatestVersion

      public Optional<String> getLatestVersion(org.apache.nifi.registry.flow.FlowRegistryClientConfigurationContext context, org.apache.nifi.registry.flow.FlowLocation flowLocation) throws org.apache.nifi.registry.flow.FlowRegistryException, IOException
      Throws:
      org.apache.nifi.registry.flow.FlowRegistryException
      IOException
    • generateFlowId

      public String generateFlowId(String flowName)
    • createFlowRegistryBucket

      private org.apache.nifi.registry.flow.FlowRegistryBucket createFlowRegistryBucket(GitRepositoryClient repositoryClient, String name)
    • createSnapshotMetadata

      private org.apache.nifi.registry.flow.RegisteredFlowSnapshotMetadata createSnapshotMetadata(GitCommit commit, org.apache.nifi.registry.flow.FlowLocation flowLocation) throws IOException
      Throws:
      IOException
    • mapToRegisteredFlow

      private org.apache.nifi.registry.flow.RegisteredFlow mapToRegisteredFlow(org.apache.nifi.registry.flow.BucketLocation bucketLocation, String filename)
    • getSnapshotFilePath

      private String getSnapshotFilePath(org.apache.nifi.registry.flow.FlowLocation flowLocation)
    • getSnapshot

      private org.apache.nifi.registry.flow.RegisteredFlowSnapshot getSnapshot(GitRepositoryClient repositoryClient, String filePath, String branch) throws IOException, org.apache.nifi.registry.flow.FlowRegistryException
      Throws:
      IOException
      org.apache.nifi.registry.flow.FlowRegistryException
    • getSnapshot

      private org.apache.nifi.registry.flow.RegisteredFlowSnapshot getSnapshot(InputStream inputStream) throws IOException
      Throws:
      IOException
    • replacePosition

      private org.apache.nifi.flow.Position replacePosition(org.apache.nifi.flow.VersionedProcessGroup group, org.apache.nifi.flow.Position newPosition)
    • replaceGroupId

      private String replaceGroupId(org.apache.nifi.flow.VersionedProcessGroup group, String newGroupId)
    • replaceGroupId

      private <T extends org.apache.nifi.flow.VersionedComponent> void replaceGroupId(Collection<T> components, String newGroupIdentifier)
    • replaceGroupId

      private void replaceGroupId(org.apache.nifi.flow.ConnectableComponent connectableComponent, String originalGroupId, String newGroupId)
    • updateBucketReferences

      private void updateBucketReferences(GitRepositoryClient repositoryClient, org.apache.nifi.registry.flow.RegisteredFlowSnapshot flowSnapshot, String bucketId)
    • populateFlowAndSnapshotMetadata

      private void populateFlowAndSnapshotMetadata(org.apache.nifi.registry.flow.RegisteredFlowSnapshot flowSnapshot, org.apache.nifi.registry.flow.FlowLocation flowLocation)
    • verifyWritePermissions

      private void verifyWritePermissions(GitRepositoryClient repositoryClient) throws org.apache.nifi.registry.flow.AuthorizationException
      Throws:
      org.apache.nifi.registry.flow.AuthorizationException
    • verifyReadPermissions

      private void verifyReadPermissions(GitRepositoryClient repositoryClient) throws org.apache.nifi.registry.flow.AuthorizationException
      Throws:
      org.apache.nifi.registry.flow.AuthorizationException
    • getRepositoryClient

      protected GitRepositoryClient getRepositoryClient(org.apache.nifi.registry.flow.FlowRegistryClientConfigurationContext context) throws IOException, org.apache.nifi.registry.flow.FlowRegistryException
      Throws:
      IOException
      org.apache.nifi.registry.flow.FlowRegistryException
    • invalidateClient

      protected void invalidateClient()
    • initializeDefaultBucket

      private void initializeDefaultBucket(org.apache.nifi.registry.flow.FlowRegistryClientConfigurationContext context) throws IOException, org.apache.nifi.registry.flow.FlowRegistryException
      Throws:
      IOException
      org.apache.nifi.registry.flow.FlowRegistryException
    • createPropertyDescriptors

      protected abstract List<org.apache.nifi.components.PropertyDescriptor> createPropertyDescriptors()
      Create the property descriptors for this client.
      Returns:
      the list of property descriptors
    • getStorageLocation

      protected abstract String getStorageLocation(GitRepositoryClient repositoryClient)
      Provide the storage location for this client.
      Parameters:
      repositoryClient - the repository client
      Returns:
      the storage location value
    • createRepositoryClient

      protected abstract GitRepositoryClient createRepositoryClient(org.apache.nifi.registry.flow.FlowRegistryClientConfigurationContext context) throws IOException, org.apache.nifi.registry.flow.FlowRegistryException
      Creates the repository client based on the current configuration context.
      Parameters:
      context - the configuration context
      Returns:
      the repository client
      Throws:
      IOException - if an I/O error occurs creating the client
      org.apache.nifi.registry.flow.FlowRegistryException - if a non-I/O error occurs creating the client
    • createFlowSnapshotSerializer

      protected FlowSnapshotSerializer createFlowSnapshotSerializer()