This is an automated email from the ASF dual-hosted git repository.
pvillard31 pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/nifi.git
The following commit(s) were added to refs/heads/main by this push:
new d0792a6d2a7 NIFI-16441 - Added Gitea Flow Registry Client (#11791)
d0792a6d2a7 is described below
commit d0792a6d2a73f8176760e9ee6d55b65cd074919e
Author: Vadim Radu <[email protected]>
AuthorDate: Wed Nov 18 15:45:15 2026 +0200
NIFI-16441 - Added Gitea Flow Registry Client (#11791)
---
nifi-assembly/pom.xml | 6 +
.../nifi-gitea-extensions/pom.xml | 59 ++
.../apache/nifi/gitea/GiteaFlowRegistryClient.java | 166 +++++
.../apache/nifi/gitea/GiteaRepositoryClient.java | 702 +++++++++++++++++++++
...rg.apache.nifi.registry.flow.FlowRegistryClient | 15 +
.../additionalDetails.md | 76 +++
.../nifi/gitea/GiteaFlowRegistryClientTest.java | 90 +++
.../nifi/gitea/GiteaRepositoryClientTest.java | 576 +++++++++++++++++
.../nifi-gitea-bundle/nifi-gitea-nar/pom.xml | 42 ++
.../src/main/resources/META-INF/LICENSE | 222 +++++++
.../src/main/resources/META-INF/NOTICE | 37 ++
nifi-extension-bundles/nifi-gitea-bundle/pom.xml | 32 +
nifi-extension-bundles/pom.xml | 1 +
13 files changed, 2024 insertions(+)
diff --git a/nifi-assembly/pom.xml b/nifi-assembly/pom.xml
index 38dc97336cd..072caac2d93 100644
--- a/nifi-assembly/pom.xml
+++ b/nifi-assembly/pom.xml
@@ -873,6 +873,12 @@ language governing permissions and limitations under the
License. -->
<version>2.13.0-SNAPSHOT</version>
<type>nar</type>
</dependency>
+ <dependency>
+ <groupId>org.apache.nifi</groupId>
+ <artifactId>nifi-gitea-nar</artifactId>
+ <version>2.13.0-SNAPSHOT</version>
+ <type>nar</type>
+ </dependency>
<dependency>
<groupId>org.apache.nifi</groupId>
<artifactId>nifi-iceberg-aws-nar</artifactId>
diff --git
a/nifi-extension-bundles/nifi-gitea-bundle/nifi-gitea-extensions/pom.xml
b/nifi-extension-bundles/nifi-gitea-bundle/nifi-gitea-extensions/pom.xml
new file mode 100644
index 00000000000..db50d41910d
--- /dev/null
+++ b/nifi-extension-bundles/nifi-gitea-bundle/nifi-gitea-extensions/pom.xml
@@ -0,0 +1,59 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
https://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+ http://www.apache.org/licenses/LICENSE-2.0
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ -->
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.nifi</groupId>
+ <artifactId>nifi-gitea-bundle</artifactId>
+ <version>2.13.0-SNAPSHOT</version>
+ </parent>
+ <artifactId>nifi-gitea-extensions</artifactId>
+ <packaging>jar</packaging>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.nifi</groupId>
+ <artifactId>nifi-utils</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.nifi</groupId>
+ <artifactId>nifi-git-flow-registry</artifactId>
+ <version>2.13.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.nifi</groupId>
+ <artifactId>nifi-web-client-provider-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.nifi</groupId>
+ <artifactId>nifi-web-client-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>com.fasterxml.jackson.core</groupId>
+ <artifactId>jackson-databind</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.nifi</groupId>
+ <artifactId>nifi-web-client</artifactId>
+ <version>2.13.0-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>com.squareup.okhttp3</groupId>
+ <artifactId>mockwebserver3</artifactId>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+</project>
diff --git
a/nifi-extension-bundles/nifi-gitea-bundle/nifi-gitea-extensions/src/main/java/org/apache/nifi/gitea/GiteaFlowRegistryClient.java
b/nifi-extension-bundles/nifi-gitea-bundle/nifi-gitea-extensions/src/main/java/org/apache/nifi/gitea/GiteaFlowRegistryClient.java
new file mode 100644
index 00000000000..1e3ac117854
--- /dev/null
+++
b/nifi-extension-bundles/nifi-gitea-bundle/nifi-gitea-extensions/src/main/java/org/apache/nifi/gitea/GiteaFlowRegistryClient.java
@@ -0,0 +1,166 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.nifi.gitea;
+
+import org.apache.nifi.annotation.documentation.CapabilityDescription;
+import org.apache.nifi.annotation.documentation.Tags;
+import org.apache.nifi.components.PropertyDescriptor;
+import org.apache.nifi.components.ValidationContext;
+import org.apache.nifi.components.ValidationResult;
+import org.apache.nifi.processor.util.StandardValidators;
+import org.apache.nifi.registry.flow.FlowRegistryClientConfigurationContext;
+import org.apache.nifi.registry.flow.FlowRegistryException;
+import org.apache.nifi.registry.flow.git.AbstractGitFlowRegistryClient;
+import org.apache.nifi.registry.flow.git.client.GitRepositoryClient;
+import org.apache.nifi.web.client.provider.api.WebClientServiceProvider;
+
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import java.util.Set;
+
+@Tags({ "git", "gitea", "forgejo", "codeberg", "registry", "flow" })
+@CapabilityDescription("Flow Registry Client that uses the Gitea REST API to
version control flows in a Gitea repository. "
+ + "Compatible with Forgejo instances, including Codeberg, which
provide the same REST API. "
+ + "Note that for a given flow, the registry client will retrieve at
most the last 50 commits to limit API calls.")
+public class GiteaFlowRegistryClient extends AbstractGitFlowRegistryClient {
+
+ static final PropertyDescriptor WEBCLIENT_SERVICE = new
PropertyDescriptor.Builder()
+ .name("Web Client Service")
+ .description("The Web Client Service to use for communicating with
Gitea, including TLS and proxy configuration")
+ .required(true)
+ .identifiesControllerService(WebClientServiceProvider.class)
+ .build();
+
+ static final PropertyDescriptor GITEA_API_URL = new
PropertyDescriptor.Builder()
+ .name("Gitea API URL")
+ .description("The base URL of the Gitea or Forgejo instance,
including the context path when applicable "
+ + "(for example, https://gitea.example.com,
https://example.com/gitea or https://codeberg.org)")
+ .addValidator(StandardValidators.URL_VALIDATOR)
+ .required(true)
+ .build();
+
+ static final PropertyDescriptor REPOSITORY_OWNER = new
PropertyDescriptor.Builder()
+ .name("Repository Owner")
+ .description("The user or organization that owns the repository")
+ .addValidator(StandardValidators.NON_BLANK_VALIDATOR)
+ .required(true)
+ .build();
+
+ static final PropertyDescriptor REPOSITORY_NAME = new
PropertyDescriptor.Builder()
+ .name("Repository Name")
+ .description("The name of the repository")
+ .addValidator(StandardValidators.NON_BLANK_VALIDATOR)
+ .required(true)
+ .build();
+
+ static final PropertyDescriptor ACCESS_TOKEN = new
PropertyDescriptor.Builder()
+ .name("Access Token")
+ .description("The Access Token used for authentication. The token
requires the read:repository scope for reading flows "
+ + "and the write:repository scope for committing flows.")
+ .addValidator(StandardValidators.NON_BLANK_VALIDATOR)
+ .required(true)
+ .sensitive(true)
+ .build();
+
+ static final List<PropertyDescriptor> PROPERTY_DESCRIPTORS = List.of(
+ WEBCLIENT_SERVICE,
+ GITEA_API_URL,
+ REPOSITORY_OWNER,
+ REPOSITORY_NAME,
+ ACCESS_TOKEN
+ );
+
+ private static final Set<String> SUPPORTED_SCHEMES = Set.of("http",
"https");
+ private static final String GIT_SUFFIX = ".git";
+ private static final String STORAGE_LOCATION_FORMAT = "%s/%s/%s";
+
+ @Override
+ protected List<PropertyDescriptor> createPropertyDescriptors() {
+ return PROPERTY_DESCRIPTORS;
+ }
+
+ @Override
+ protected Collection<ValidationResult> customValidate(final
ValidationContext validationContext) {
+ final List<ValidationResult> results = new
ArrayList<>(super.customValidate(validationContext));
+
+ final String apiUrl =
validationContext.getProperty(GITEA_API_URL).getValue();
+ if (apiUrl != null && !isSupportedUrl(apiUrl)) {
+ results.add(new ValidationResult.Builder()
+ .subject(GITEA_API_URL.getDisplayName())
+ .input(apiUrl)
+ .valid(false)
+ .explanation("URL must use the http or https scheme and
include a host")
+ .build());
+ }
+
+ return results;
+ }
+
+ @Override
+ protected GitRepositoryClient createRepositoryClient(final
FlowRegistryClientConfigurationContext context) throws FlowRegistryException {
+ return GiteaRepositoryClient.builder()
+ .clientId(getIdentifier())
+ .logger(getLogger())
+ .apiUrl(context.getProperty(GITEA_API_URL).getValue())
+ .repoOwner(context.getProperty(REPOSITORY_OWNER).getValue())
+ .repoName(context.getProperty(REPOSITORY_NAME).getValue())
+ .repoPath(context.getProperty(REPOSITORY_PATH).getValue())
+ .accessToken(context.getProperty(ACCESS_TOKEN).getValue())
+
.webClient(context.getProperty(WEBCLIENT_SERVICE).asControllerService(WebClientServiceProvider.class))
+ .build();
+ }
+
+ @Override
+ public boolean isStorageLocationApplicable(final
FlowRegistryClientConfigurationContext context, final String location) {
+ final String apiUrl = context.getProperty(GITEA_API_URL).getValue();
+ final String repoOwner =
context.getProperty(REPOSITORY_OWNER).getValue();
+ final String repoName =
context.getProperty(REPOSITORY_NAME).getValue();
+ if (location == null || apiUrl == null || repoOwner == null ||
repoName == null) {
+ return false;
+ }
+
+ final String storageLocation = getStorageLocation(apiUrl, repoOwner,
repoName);
+ String normalizedLocation =
GiteaRepositoryClient.normalizeApiUrl(location);
+ if (normalizedLocation.endsWith(GIT_SUFFIX)) {
+ normalizedLocation = normalizedLocation.substring(0,
normalizedLocation.length() - GIT_SUFFIX.length());
+ }
+ // Gitea owner and repository names are case-insensitive
+ return storageLocation.equalsIgnoreCase(normalizedLocation);
+ }
+
+ @Override
+ protected String getStorageLocation(final GitRepositoryClient
repositoryClient) {
+ final GiteaRepositoryClient giteaRepositoryClient =
(GiteaRepositoryClient) repositoryClient;
+ return getStorageLocation(giteaRepositoryClient.getApiUrl(),
giteaRepositoryClient.getRepoOwner(), giteaRepositoryClient.getRepoName());
+ }
+
+ private static String getStorageLocation(final String apiUrl, final String
repoOwner, final String repoName) {
+ return
STORAGE_LOCATION_FORMAT.formatted(GiteaRepositoryClient.normalizeApiUrl(apiUrl),
repoOwner.trim(), repoName.trim());
+ }
+
+ static boolean isSupportedUrl(final String url) {
+ try {
+ final URI uri = URI.create(url.trim());
+ return uri.getScheme() != null &&
SUPPORTED_SCHEMES.contains(uri.getScheme().toLowerCase()) && uri.getHost() !=
null;
+ } catch (final IllegalArgumentException e) {
+ return false;
+ }
+ }
+}
diff --git
a/nifi-extension-bundles/nifi-gitea-bundle/nifi-gitea-extensions/src/main/java/org/apache/nifi/gitea/GiteaRepositoryClient.java
b/nifi-extension-bundles/nifi-gitea-bundle/nifi-gitea-extensions/src/main/java/org/apache/nifi/gitea/GiteaRepositoryClient.java
new file mode 100644
index 00000000000..3e9a85f1b91
--- /dev/null
+++
b/nifi-extension-bundles/nifi-gitea-bundle/nifi-gitea-extensions/src/main/java/org/apache/nifi/gitea/GiteaRepositoryClient.java
@@ -0,0 +1,702 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.nifi.gitea;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.node.ObjectNode;
+import org.apache.nifi.logging.ComponentLog;
+import org.apache.nifi.registry.flow.FlowRegistryException;
+import org.apache.nifi.registry.flow.git.client.GitCommit;
+import org.apache.nifi.registry.flow.git.client.GitCreateContentRequest;
+import org.apache.nifi.registry.flow.git.client.GitRepositoryClient;
+import org.apache.nifi.web.client.api.HttpRequestBodySpec;
+import org.apache.nifi.web.client.api.HttpRequestUriSpec;
+import org.apache.nifi.web.client.api.HttpResponseEntity;
+import org.apache.nifi.web.client.api.HttpUriBuilder;
+import org.apache.nifi.web.client.api.MediaType;
+import org.apache.nifi.web.client.api.WebClientService;
+import org.apache.nifi.web.client.provider.api.WebClientServiceProvider;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.HttpURLConnection;
+import java.net.URI;
+import java.nio.charset.StandardCharsets;
+import java.time.Instant;
+import java.time.OffsetDateTime;
+import java.util.ArrayList;
+import java.util.Base64;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Objects;
+import java.util.Optional;
+import java.util.OptionalLong;
+import java.util.Set;
+
+/**
+ * Git Repository Client implementation for Gitea using the REST API version 1.
+ * The same API is provided by Forgejo, including Codeberg.
+ */
+public class GiteaRepositoryClient implements GitRepositoryClient {
+
+ static final String API_PATH = "/api/v1";
+
+ // Gitea returns the server [git] COMMITS_RANGE_SIZE number of commits
when listing commits for a path, which defaults to 50
+ static final int COMMIT_PAGE_SIZE = 50;
+
+ static final int BRANCH_PAGE_SIZE = 50;
+
+ private static final int MAXIMUM_PAGES = 10_000;
+ private static final int HTTP_UNPROCESSABLE_ENTITY = 422;
+ private static final int HTTP_CONTENT_TOO_LARGE = 413;
+ private static final int MAXIMUM_ERROR_BODY_LENGTH = 1024;
+
+ private static final String AUTHORIZATION_HEADER = "Authorization";
+ private static final String ACCEPT_HEADER = "Accept";
+ private static final String CONTENT_TYPE_HEADER = "Content-Type";
+ private static final String TOKEN_PREFIX = "token ";
+ private static final String TOTAL_COUNT_HEADER = "X-Total-Count";
+
+ private static final String FORWARD_SLASH = "/";
+
+ private static final String SEGMENT_REPOS = "repos";
+ private static final String SEGMENT_BRANCHES = "branches";
+ private static final String SEGMENT_CONTENTS = "contents";
+ private static final String SEGMENT_MEDIA = "media";
+ private static final String SEGMENT_COMMITS = "commits";
+ private static final String SEGMENT_GIT = "git";
+ private static final String SEGMENT_BLOBS = "blobs";
+
+ private static final String PARAM_REF = "ref";
+ private static final String PARAM_SHA = "sha";
+ private static final String PARAM_PATH = "path";
+ private static final String PARAM_PAGE = "page";
+ private static final String PARAM_LIMIT = "limit";
+ private static final String PARAM_STAT = "stat";
+ private static final String PARAM_VERIFICATION = "verification";
+ private static final String PARAM_FILES = "files";
+ private static final String FALSE = "false";
+
+ private static final String FIELD_PERMISSIONS = "permissions";
+ private static final String FIELD_PULL = "pull";
+ private static final String FIELD_PUSH = "push";
+ private static final String FIELD_ARCHIVED = "archived";
+ private static final String FIELD_MIRROR = "mirror";
+ private static final String FIELD_EMPTY = "empty";
+ private static final String FIELD_NAME = "name";
+ private static final String FIELD_TYPE = "type";
+ private static final String FIELD_SHA = "sha";
+ private static final String FIELD_CONTENT = "content";
+ private static final String FIELD_COMMIT = "commit";
+ private static final String FIELD_MESSAGE = "message";
+ private static final String FIELD_AUTHOR = "author";
+ private static final String FIELD_COMMITTER = "committer";
+ private static final String FIELD_EMAIL = "email";
+ private static final String FIELD_DATE = "date";
+ private static final String FIELD_BRANCH = "branch";
+ private static final String FIELD_NEW_BRANCH_NAME = "new_branch_name";
+ private static final String FIELD_OLD_REF_NAME = "old_ref_name";
+
+ private static final String TYPE_FILE = "file";
+ private static final String TYPE_DIR = "dir";
+
+ private static final ObjectMapper MAPPER = new ObjectMapper();
+
+ private final String clientId;
+ private final String apiUrl;
+ private final URI apiUri;
+ private final String repoOwner;
+ private final String repoName;
+ private final String repoPath;
+ private final String accessToken;
+ private final WebClientServiceProvider webClient;
+ private final ComponentLog logger;
+
+ private final boolean canRead;
+ private final boolean canWrite;
+
+ private GiteaRepositoryClient(final Builder builder) throws
FlowRegistryException {
+ clientId = Objects.requireNonNull(builder.clientId, "Client ID
required");
+ apiUrl = normalizeApiUrl(Objects.requireNonNull(builder.apiUrl, "API
URL required"));
+ apiUri = URI.create(apiUrl);
+ repoOwner = Objects.requireNonNull(builder.repoOwner, "Repository
Owner required");
+ repoName = Objects.requireNonNull(builder.repoName, "Repository Name
required");
+ repoPath = trimSlashes(builder.repoPath);
+ accessToken = Objects.requireNonNull(builder.accessToken, "Access
Token required");
+ webClient = Objects.requireNonNull(builder.webClient, "Web Client
Service required");
+ logger = Objects.requireNonNull(builder.logger, "Logger required");
+
+ final URI uri = repositoryUriBuilder().build();
+ try (HttpResponseEntity response = execute(webClientService().get(),
uri, null)) {
+ if (response.statusCode() != HttpURLConnection.HTTP_OK) {
+ throw new FlowRegistryException("Failed to access repository
[%s/%s] - %s".formatted(repoOwner, repoName, getErrorMessage(response)));
+ }
+ final JsonNode repository = readJson(response, uri);
+ final JsonNode permissions = repository.path(FIELD_PERMISSIONS);
+ final boolean archived =
repository.path(FIELD_ARCHIVED).asBoolean(false);
+ final boolean mirror =
repository.path(FIELD_MIRROR).asBoolean(false);
+ canRead = permissions.path(FIELD_PULL).asBoolean(false);
+ canWrite = permissions.path(FIELD_PUSH).asBoolean(false) &&
!archived && !mirror;
+ } catch (final IOException e) {
+ throw new FlowRegistryException("Failed to access repository
[%s/%s]".formatted(repoOwner, repoName), e);
+ }
+
+ logger.info("Created {} for Flow Registry Client ID [{}] repository
[{}/{}] read [{}] write [{}]",
+ getClass().getSimpleName(), clientId, repoOwner, repoName,
canRead, canWrite);
+ }
+
+ public static Builder builder() {
+ return new Builder();
+ }
+
+ /**
+ * Normalize the configured URL of the Gitea instance by removing trailing
separators and the API path when provided.
+ *
+ * @param apiUrl URL of the Gitea instance
+ * @return Normalized URL of the Gitea instance without trailing separator
+ */
+ static String normalizeApiUrl(final String apiUrl) {
+ String normalized = apiUrl.trim();
+ while (normalized.endsWith(FORWARD_SLASH)) {
+ normalized = normalized.substring(0, normalized.length() - 1);
+ }
+ if (normalized.endsWith(API_PATH)) {
+ normalized = normalized.substring(0, normalized.length() -
API_PATH.length());
+ }
+ while (normalized.endsWith(FORWARD_SLASH)) {
+ normalized = normalized.substring(0, normalized.length() - 1);
+ }
+ return normalized;
+ }
+
+ public String getApiUrl() {
+ return apiUrl;
+ }
+
+ public String getRepoOwner() {
+ return repoOwner;
+ }
+
+ public String getRepoName() {
+ return repoName;
+ }
+
+ @Override
+ public boolean hasReadPermission() {
+ return canRead;
+ }
+
+ @Override
+ public boolean hasWritePermission() {
+ return canWrite;
+ }
+
+ @Override
+ public Set<String> getBranches() throws IOException, FlowRegistryException
{
+ logger.debug("Getting branches for repository [{}/{}]", repoOwner,
repoName);
+ final Set<String> branches = new HashSet<>();
+ for (int page = 1; page <= MAXIMUM_PAGES; page++) {
+ final URI uri = repositoryUriBuilder(SEGMENT_BRANCHES)
+ .addQueryParameter(PARAM_PAGE, Integer.toString(page))
+ .addQueryParameter(PARAM_LIMIT,
Integer.toString(BRANCH_PAGE_SIZE))
+ .build();
+
+ final JsonNode response;
+ final Optional<Long> totalCount;
+ try (HttpResponseEntity entity = execute(webClientService().get(),
uri, null)) {
+ if (entity.statusCode() != HttpURLConnection.HTTP_OK) {
+ throw new FlowRegistryException("Request to [%s] failed -
%s".formatted(uri, getErrorMessage(entity)));
+ }
+ totalCount = getHeaderLong(entity, TOTAL_COUNT_HEADER);
+ response = readJson(entity, uri);
+ }
+
+ for (final JsonNode branch : response) {
+ branches.add(branch.path(FIELD_NAME).asText());
+ }
+
+ final boolean allRetrieved = totalCount.map(total ->
branches.size() >= total).orElse(response.size() < BRANCH_PAGE_SIZE);
+ if (response.isEmpty() || allRetrieved) {
+ break;
+ }
+ }
+ return branches;
+ }
+
+ @Override
+ public Set<String> getTopLevelDirectoryNames(final String branch) throws
IOException, FlowRegistryException {
+ logger.debug("Getting top-level directories for repository [{}/{}] on
branch [{}]", repoOwner, repoName, branch);
+ return getDirectoryEntryNames(resolvePath(""), branch, TYPE_DIR);
+ }
+
+ @Override
+ public Set<String> getFileNames(final String directory, final String
branch) throws IOException, FlowRegistryException {
+ logger.debug("Getting file names in directory [{}] for repository
[{}/{}] on branch [{}]", directory, repoOwner, repoName, branch);
+ return getDirectoryEntryNames(resolvePath(directory), branch,
TYPE_FILE);
+ }
+
+ @Override
+ public List<GitCommit> getCommits(final String path, final String branch)
throws IOException, FlowRegistryException {
+ final String resolvedPath = resolvePath(path);
+ logger.debug("Getting commits for [{}] on branch [{}] in repository
[{}/{}]", resolvedPath, branch, repoOwner, repoName);
+
+ final URI uri = repositoryUriBuilder(SEGMENT_COMMITS)
+ .addQueryParameter(PARAM_SHA, branch)
+ .addQueryParameter(PARAM_PATH, resolvedPath)
+ .addQueryParameter(PARAM_STAT, FALSE)
+ .addQueryParameter(PARAM_VERIFICATION, FALSE)
+ .addQueryParameter(PARAM_FILES, FALSE)
+ .addQueryParameter(PARAM_LIMIT,
Integer.toString(COMMIT_PAGE_SIZE))
+ .build();
+
+ try (HttpResponseEntity response = execute(webClientService().get(),
uri, null)) {
+ final int statusCode = response.statusCode();
+ // Not Found indicates that the path does not exist and Conflict
indicates that the repository is empty
+ if (statusCode == HttpURLConnection.HTTP_NOT_FOUND || statusCode
== HttpURLConnection.HTTP_CONFLICT) {
+ logger.debug("No commits found for [{}] on branch [{}]: HTTP
{}", resolvedPath, branch, statusCode);
+ return List.of();
+ } else if (statusCode != HttpURLConnection.HTTP_OK) {
+ throw new FlowRegistryException("Request to [%s] failed -
%s".formatted(uri, getErrorMessage(response)));
+ }
+
+ final List<GitCommit> commits = new ArrayList<>();
+ for (final JsonNode node : readJson(response, uri)) {
+ commits.add(toGitCommit(node));
+ }
+ return commits;
+ }
+ }
+
+ @Override
+ public InputStream getContentFromBranch(final String path, final String
branch) throws IOException, FlowRegistryException {
+ final String resolvedPath = resolvePath(path);
+ logger.debug("Getting content for [{}] from branch [{}] in repository
[{}/{}]", resolvedPath, branch, repoOwner, repoName);
+ return getMedia(resolvedPath, branch);
+ }
+
+ @Override
+ public InputStream getContentFromCommit(final String path, final String
commitSha) throws IOException, FlowRegistryException {
+ final String resolvedPath = resolvePath(path);
+ logger.debug("Getting content for [{}] from commit [{}] in repository
[{}/{}]", resolvedPath, commitSha, repoOwner, repoName);
+ return getMedia(resolvedPath, commitSha);
+ }
+
+ @Override
+ public Optional<String> getContentSha(final String path, final String
branch) throws IOException, FlowRegistryException {
+ final String resolvedPath = resolvePath(path);
+ logger.debug("Getting content SHA for [{}] on branch [{}] in
repository [{}/{}]", resolvedPath, branch, repoOwner, repoName);
+ return getFile(resolvedPath, branch).map(file ->
file.path(FIELD_SHA).asText());
+ }
+
+ @Override
+ public Optional<String> getContentShaAtCommit(final String path, final
String commitSha) throws IOException, FlowRegistryException {
+ final String resolvedPath = resolvePath(path);
+ logger.debug("Getting content SHA for [{}] at commit [{}] in
repository [{}/{}]", resolvedPath, commitSha, repoOwner, repoName);
+ return getFile(resolvedPath, commitSha).map(file ->
file.path(FIELD_SHA).asText());
+ }
+
+ @Override
+ public String createContent(final GitCreateContentRequest request) throws
IOException, FlowRegistryException {
+ final String resolvedPath = resolvePath(request.getPath());
+ final String branch = request.getBranch();
+ final String existingContentSha = request.getExistingContentSha();
+ logger.debug("Creating content at [{}] on branch [{}] in repository
[{}/{}]", resolvedPath, branch, repoOwner, repoName);
+
+ final ObjectNode body = createCommitBody(request.getMessage(), branch,
request.getAuthorName(), request.getAuthorEmail());
+ body.put(FIELD_CONTENT,
Base64.getEncoder().encodeToString(request.getContent().getBytes(StandardCharsets.UTF_8)));
+
+ // Gitea and Forgejo create files with POST and update files with PUT
providing the SHA of the current blob
+ final HttpRequestUriSpec requestSpec;
+ if (existingContentSha == null) {
+ requestSpec = webClientService().post();
+ } else {
+ body.put(FIELD_SHA, existingContentSha);
+ requestSpec = webClientService().put();
+ }
+
+ final URI uri = repositoryUriBuilder(SEGMENT_CONTENTS,
resolvedPath).build();
+ try (HttpResponseEntity response = execute(requestSpec, uri, body)) {
+ final int statusCode = response.statusCode();
+ if (statusCode == HttpURLConnection.HTTP_OK || statusCode ==
HttpURLConnection.HTTP_CREATED) {
+ return readJson(response,
uri).path(FIELD_COMMIT).path(FIELD_SHA).asText(null);
+ }
+ throw createWriteException(response, resolvedPath, branch,
existingContentSha != null);
+ }
+ }
+
+ @Override
+ public InputStream deleteContent(final String filePath, final String
commitMessage, final String branch) throws FlowRegistryException, IOException {
+ return deleteContent(filePath, commitMessage, branch, null, null);
+ }
+
+ @Override
+ public InputStream deleteContent(final String filePath, final String
commitMessage, final String branch,
+ final String authorName, final String
authorEmail) throws FlowRegistryException, IOException {
+ final String resolvedPath = resolvePath(filePath);
+ logger.debug("Deleting [{}] on branch [{}] in repository [{}/{}]",
resolvedPath, branch, repoOwner, repoName);
+
+ final JsonNode file = getFile(resolvedPath, branch)
+ .orElseThrow(() -> new FlowRegistryException("File [%s] not
found on branch [%s]".formatted(resolvedPath, branch)));
+ final String blobSha = file.path(FIELD_SHA).asText();
+ final byte[] content = getFileContent(file);
+
+ final ObjectNode body = createCommitBody(commitMessage, branch,
authorName, authorEmail);
+ body.put(FIELD_SHA, blobSha);
+
+ final URI uri = repositoryUriBuilder(SEGMENT_CONTENTS,
resolvedPath).build();
+ try (HttpResponseEntity response =
execute(webClientService().delete(), uri, body)) {
+ if (response.statusCode() != HttpURLConnection.HTTP_OK) {
+ throw createWriteException(response, resolvedPath, branch,
true);
+ }
+ }
+ return new ByteArrayInputStream(content);
+ }
+
+ @Override
+ public void createBranch(final String newBranchName, final String
sourceBranch, final Optional<String> sourceCommitSha)
+ throws IOException, FlowRegistryException {
+ if (newBranchName == null || newBranchName.isBlank()) {
+ throw new IllegalArgumentException("Branch name must be
specified");
+ }
+ if (sourceBranch == null || sourceBranch.isBlank()) {
+ throw new IllegalArgumentException("Source branch must be
specified");
+ }
+
+ final String trimmedNewBranch = newBranchName.trim();
+ final String sourceRef = sourceCommitSha.filter(sha ->
!sha.isBlank()).orElse(sourceBranch.trim());
+ logger.info("Creating branch [{}] from [{}] in repository [{}/{}]",
trimmedNewBranch, sourceRef, repoOwner, repoName);
+
+ final ObjectNode body = MAPPER.createObjectNode();
+ body.put(FIELD_NEW_BRANCH_NAME, trimmedNewBranch);
+ body.put(FIELD_OLD_REF_NAME, sourceRef);
+
+ final URI uri = repositoryUriBuilder(SEGMENT_BRANCHES).build();
+ try (HttpResponseEntity response = execute(webClientService().post(),
uri, body)) {
+ final int statusCode = response.statusCode();
+ if (statusCode == HttpURLConnection.HTTP_CONFLICT) {
+ throw new FlowRegistryException("Branch [%s] already exists in
repository [%s/%s]".formatted(trimmedNewBranch, repoOwner, repoName));
+ } else if (statusCode != HttpURLConnection.HTTP_CREATED) {
+ throw new FlowRegistryException("Failed to create branch [%s]
from [%s] in repository [%s/%s] - %s"
+ .formatted(trimmedNewBranch, sourceRef, repoOwner,
repoName, getErrorMessage(response)));
+ }
+ }
+ }
+
+ private Set<String> getDirectoryEntryNames(final String directory, final
String ref, final String entryType) throws IOException, FlowRegistryException {
+ final URI uri = repositoryUriBuilder(SEGMENT_CONTENTS,
directory).addQueryParameter(PARAM_REF, ref).build();
+ try (HttpResponseEntity response = execute(webClientService().get(),
uri, null)) {
+ if (response.statusCode() == HttpURLConnection.HTTP_NOT_FOUND) {
+ // Not Found indicates a missing directory, a missing branch
or an empty repository
+ if (isBranchMissing(ref)) {
+ throw new FlowRegistryException("Branch [%s] not found in
repository [%s/%s]".formatted(ref, repoOwner, repoName));
+ }
+ return Set.of();
+ } else if (response.statusCode() != HttpURLConnection.HTTP_OK) {
+ throw new FlowRegistryException("Request to [%s] failed -
%s".formatted(uri, getErrorMessage(response)));
+ }
+
+ final JsonNode entries = readJson(response, uri);
+ final Set<String> names = new HashSet<>();
+ // Directory listings are arrays while file paths return an object
+ if (entries.isArray()) {
+ for (final JsonNode entry : entries) {
+ if (entryType.equals(entry.path(FIELD_TYPE).asText())) {
+ names.add(entry.path(FIELD_NAME).asText());
+ }
+ }
+ }
+ return names;
+ }
+ }
+
+ private boolean isBranchMissing(final String branch) throws IOException,
FlowRegistryException {
+ final URI branchUri = repositoryUriBuilder(SEGMENT_BRANCHES,
branch).build();
+ try (HttpResponseEntity response = execute(webClientService().get(),
branchUri, null)) {
+ if (response.statusCode() == HttpURLConnection.HTTP_OK) {
+ return false;
+ } else if (response.statusCode() !=
HttpURLConnection.HTTP_NOT_FOUND) {
+ throw new FlowRegistryException("Request to [%s] failed -
%s".formatted(branchUri, getErrorMessage(response)));
+ }
+ }
+
+ // Empty repositories have no branches until the first commit creates
the default branch
+ final URI repositoryUri = repositoryUriBuilder().build();
+ try (HttpResponseEntity response = execute(webClientService().get(),
repositoryUri, null)) {
+ if (response.statusCode() != HttpURLConnection.HTTP_OK) {
+ throw new FlowRegistryException("Request to [%s] failed -
%s".formatted(repositoryUri, getErrorMessage(response)));
+ }
+ return !readJson(response,
repositoryUri).path(FIELD_EMPTY).asBoolean(false);
+ }
+ }
+
+ private Optional<JsonNode> getFile(final String resolvedPath, final String
ref) throws IOException, FlowRegistryException {
+ final URI uri = repositoryUriBuilder(SEGMENT_CONTENTS,
resolvedPath).addQueryParameter(PARAM_REF, ref).build();
+ try (HttpResponseEntity response = execute(webClientService().get(),
uri, null)) {
+ if (response.statusCode() == HttpURLConnection.HTTP_NOT_FOUND) {
+ return Optional.empty();
+ } else if (response.statusCode() != HttpURLConnection.HTTP_OK) {
+ throw new FlowRegistryException("Request to [%s] failed -
%s".formatted(uri, getErrorMessage(response)));
+ }
+
+ final JsonNode file = readJson(response, uri);
+ if (file.isObject() &&
TYPE_FILE.equals(file.path(FIELD_TYPE).asText())) {
+ return Optional.of(file);
+ }
+ return Optional.empty();
+ }
+ }
+
+ private byte[] getFileContent(final JsonNode file) throws IOException,
FlowRegistryException {
+ final JsonNode content = file.get(FIELD_CONTENT);
+ if (content != null && content.isTextual()) {
+ return Base64.getMimeDecoder().decode(content.asText());
+ }
+
+ // Content is omitted for files larger than the server [api]
DEFAULT_MAX_BLOB_SIZE setting
+ final String blobSha = file.path(FIELD_SHA).asText();
+ final URI uri = repositoryUriBuilder(SEGMENT_GIT, SEGMENT_BLOBS,
blobSha).build();
+ try (HttpResponseEntity response = execute(webClientService().get(),
uri, null)) {
+ if (response.statusCode() != HttpURLConnection.HTTP_OK) {
+ throw new FlowRegistryException("Request to [%s] failed -
%s".formatted(uri, getErrorMessage(response)));
+ }
+ return Base64.getMimeDecoder().decode(readJson(response,
uri).path(FIELD_CONTENT).asText());
+ }
+ }
+
+ private InputStream getMedia(final String resolvedPath, final String ref)
throws IOException, FlowRegistryException {
+ // The media endpoint returns the raw file and resolves Git LFS
pointers
+ final URI uri = repositoryUriBuilder(SEGMENT_MEDIA,
resolvedPath).addQueryParameter(PARAM_REF, ref).build();
+ final HttpResponseEntity response = execute(webClientService().get(),
uri, null);
+ if (response.statusCode() == HttpURLConnection.HTTP_OK) {
+ return response.body();
+ }
+
+ try (response) {
+ if (response.statusCode() == HttpURLConnection.HTTP_NOT_FOUND) {
+ throw new FlowRegistryException("File [%s] not found at [%s]
in repository [%s/%s]".formatted(resolvedPath, ref, repoOwner, repoName));
+ }
+ throw new FlowRegistryException("Request to [%s] failed -
%s".formatted(uri, getErrorMessage(response)));
+ }
+ }
+
+ private GitCommit toGitCommit(final JsonNode node) {
+ final String sha = node.path(FIELD_SHA).asText();
+ final JsonNode commit = node.path(FIELD_COMMIT);
+ final String message =
commit.path(FIELD_MESSAGE).asText("").stripTrailing();
+ final String author =
commit.path(FIELD_AUTHOR).path(FIELD_NAME).asText("");
+ final String date =
commit.path(FIELD_COMMITTER).path(FIELD_DATE).asText(commit.path(FIELD_AUTHOR).path(FIELD_DATE).asText());
+ final Instant commitDate = OffsetDateTime.parse(date).toInstant();
+ return new GitCommit(sha, author, message, commitDate);
+ }
+
+ private ObjectNode createCommitBody(final String message, final String
branch, final String authorName, final String authorEmail) {
+ final ObjectNode body = MAPPER.createObjectNode();
+ body.put(FIELD_MESSAGE, message);
+ body.put(FIELD_BRANCH, branch);
+ // Committer remains the authenticated user while the author is set
when both name and email are provided
+ if (authorName != null && authorEmail != null) {
+ final ObjectNode author = body.putObject(FIELD_AUTHOR);
+ author.put(FIELD_NAME, authorName);
+ author.put(FIELD_EMAIL, authorEmail);
+ }
+ return body;
+ }
+
+ private FlowRegistryException createWriteException(final
HttpResponseEntity response, final String resolvedPath, final String branch,
+ final boolean
existingContent) {
+ final int statusCode = response.statusCode();
+ final String errorMessage = getErrorMessage(response);
+ // Gitea returns Unprocessable Entity and Forgejo returns Conflict
when the provided blob SHA does not match the current blob
+ if (existingContent && (statusCode == HttpURLConnection.HTTP_CONFLICT
|| statusCode == HTTP_UNPROCESSABLE_ENTITY)) {
+ return new FlowRegistryException("File [%s] on branch [%s] has
been modified by another commit - %s".formatted(resolvedPath, branch,
errorMessage));
+ } else if (statusCode == HttpURLConnection.HTTP_FORBIDDEN) {
+ return new FlowRegistryException("Write access denied for [%s] on
branch [%s]: the Access Token requires the write:repository scope and the
branch must not be protected - %s"
+ .formatted(resolvedPath, branch, errorMessage));
+ } else if (statusCode == HTTP_CONTENT_TOO_LARGE) {
+ return new FlowRegistryException("Repository quota exceeded
writing [%s] on branch [%s] - %s".formatted(resolvedPath, branch,
errorMessage));
+ }
+ return new FlowRegistryException("Failed to write [%s] on branch [%s]
- %s".formatted(resolvedPath, branch, errorMessage));
+ }
+
+ private HttpResponseEntity execute(final HttpRequestUriSpec requestSpec,
final URI uri, final JsonNode body) throws FlowRegistryException {
+ final HttpRequestBodySpec bodySpec = requestSpec.uri(uri)
+ .header(AUTHORIZATION_HEADER, TOKEN_PREFIX + accessToken)
+ .header(ACCEPT_HEADER,
MediaType.APPLICATION_JSON.getMediaType());
+
+ if (body == null) {
+ return bodySpec.retrieve();
+ }
+
+ final byte[] serialized;
+ try {
+ serialized = MAPPER.writeValueAsBytes(body);
+ } catch (final IOException e) {
+ throw new FlowRegistryException("Failed to serialize request for
[%s]".formatted(uri), e);
+ }
+ return bodySpec.header(CONTENT_TYPE_HEADER,
MediaType.APPLICATION_JSON.getMediaType())
+ .body(new ByteArrayInputStream(serialized),
OptionalLong.of(serialized.length))
+ .retrieve();
+ }
+
+ private JsonNode readJson(final HttpResponseEntity response, final URI
uri) throws FlowRegistryException {
+ try (InputStream body = response.body()) {
+ return MAPPER.readTree(body);
+ } catch (final IOException e) {
+ throw new FlowRegistryException("Failed to read response from
[%s]".formatted(uri), e);
+ }
+ }
+
+ private String getErrorMessage(final HttpResponseEntity response) {
+ String responseBody;
+ try (InputStream body = response.body()) {
+ responseBody = body == null ? "" : new
String(body.readNBytes(MAXIMUM_ERROR_BODY_LENGTH), StandardCharsets.UTF_8);
+ } catch (final IOException e) {
+ responseBody = "";
+ }
+
+ String message = responseBody;
+ try {
+ final JsonNode error = MAPPER.readTree(responseBody);
+ if (error != null && error.hasNonNull(FIELD_MESSAGE)) {
+ message = error.get(FIELD_MESSAGE).asText();
+ }
+ } catch (final IOException ignored) {
+ // Use response body when not formatted as JSON
+ }
+ return "HTTP %d: %s".formatted(response.statusCode(), message);
+ }
+
+ private Optional<Long> getHeaderLong(final HttpResponseEntity response,
final String headerName) {
+ return response.headers().getFirstHeader(headerName).flatMap(value -> {
+ try {
+ return Optional.of(Long.parseLong(value.trim()));
+ } catch (final NumberFormatException e) {
+ return Optional.empty();
+ }
+ });
+ }
+
+ private WebClientService webClientService() {
+ return webClient.getWebClientService();
+ }
+
+ /**
+ * Create URI builder for repository resources. Path elements containing
forward slashes are added as multiple path segments.
+ *
+ * @param pathElements Path elements relative to the repository
+ * @return HTTP URI Builder configured for repository resources
+ */
+ private HttpUriBuilder repositoryUriBuilder(final String... pathElements) {
+ final HttpUriBuilder builder = webClient.getHttpUriBuilder()
+ .scheme(apiUri.getScheme())
+ .host(apiUri.getHost())
+ .port(apiUri.getPort())
+ .encodedPath(apiUri.getRawPath() + API_PATH)
+ .addPathSegment(SEGMENT_REPOS)
+ .addPathSegment(repoOwner)
+ .addPathSegment(repoName);
+
+ for (final String pathElement : pathElements) {
+ for (final String segment : pathElement.split(FORWARD_SLASH)) {
+ if (!segment.isEmpty()) {
+ builder.addPathSegment(segment);
+ }
+ }
+ }
+ return builder;
+ }
+
+ private String resolvePath(final String path) {
+ final String trimmedPath = trimSlashes(path);
+ if (repoPath == null) {
+ return trimmedPath == null ? "" : trimmedPath;
+ }
+ return trimmedPath == null ? repoPath : repoPath + FORWARD_SLASH +
trimmedPath;
+ }
+
+ private static String trimSlashes(final String path) {
+ if (path == null) {
+ return null;
+ }
+ String trimmed = path.trim();
+ while (trimmed.startsWith(FORWARD_SLASH)) {
+ trimmed = trimmed.substring(1);
+ }
+ while (trimmed.endsWith(FORWARD_SLASH)) {
+ trimmed = trimmed.substring(0, trimmed.length() - 1);
+ }
+ return trimmed.isEmpty() ? null : trimmed;
+ }
+
+ public static class Builder {
+ private String clientId;
+ private String apiUrl;
+ private String repoOwner;
+ private String repoName;
+ private String repoPath;
+ private String accessToken;
+ private WebClientServiceProvider webClient;
+ private ComponentLog logger;
+
+ public Builder clientId(final String clientId) {
+ this.clientId = clientId;
+ return this;
+ }
+
+ public Builder apiUrl(final String apiUrl) {
+ this.apiUrl = apiUrl;
+ return this;
+ }
+
+ public Builder repoOwner(final String repoOwner) {
+ this.repoOwner = repoOwner;
+ return this;
+ }
+
+ public Builder repoName(final String repoName) {
+ this.repoName = repoName;
+ return this;
+ }
+
+ public Builder repoPath(final String repoPath) {
+ this.repoPath = repoPath;
+ return this;
+ }
+
+ public Builder accessToken(final String accessToken) {
+ this.accessToken = accessToken;
+ return this;
+ }
+
+ public Builder webClient(final WebClientServiceProvider webClient) {
+ this.webClient = webClient;
+ return this;
+ }
+
+ public Builder logger(final ComponentLog logger) {
+ this.logger = logger;
+ return this;
+ }
+
+ public GiteaRepositoryClient build() throws FlowRegistryException {
+ return new GiteaRepositoryClient(this);
+ }
+ }
+}
diff --git
a/nifi-extension-bundles/nifi-gitea-bundle/nifi-gitea-extensions/src/main/resources/META-INF/services/org.apache.nifi.registry.flow.FlowRegistryClient
b/nifi-extension-bundles/nifi-gitea-bundle/nifi-gitea-extensions/src/main/resources/META-INF/services/org.apache.nifi.registry.flow.FlowRegistryClient
new file mode 100644
index 00000000000..5ec9fe94f77
--- /dev/null
+++
b/nifi-extension-bundles/nifi-gitea-bundle/nifi-gitea-extensions/src/main/resources/META-INF/services/org.apache.nifi.registry.flow.FlowRegistryClient
@@ -0,0 +1,15 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+org.apache.nifi.gitea.GiteaFlowRegistryClient
\ No newline at end of file
diff --git
a/nifi-extension-bundles/nifi-gitea-bundle/nifi-gitea-extensions/src/main/resources/docs/org.apache.nifi.gitea.GiteaFlowRegistryClient/additionalDetails.md
b/nifi-extension-bundles/nifi-gitea-bundle/nifi-gitea-extensions/src/main/resources/docs/org.apache.nifi.gitea.GiteaFlowRegistryClient/additionalDetails.md
new file mode 100644
index 00000000000..44a08385f9c
--- /dev/null
+++
b/nifi-extension-bundles/nifi-gitea-bundle/nifi-gitea-extensions/src/main/resources/docs/org.apache.nifi.gitea.GiteaFlowRegistryClient/additionalDetails.md
@@ -0,0 +1,76 @@
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+ http://www.apache.org/licenses/LICENSE-2.0
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+# Gitea Flow Registry Client
+
+This component stores versioned flows in a Gitea repository using the Gitea
REST API. Forgejo provides the same REST API,
+so the component also works with Forgejo instances, including Codeberg.
+
+The component communicates over HTTP or HTTPS with the REST API under
`/api/v1`. It does not use the Git protocol or SSH.
+
+## Repository Layout
+
+Each top-level directory of the repository, or of the configured Repository
Path, is a bucket. Each flow is stored as a
+JSON file named after the flow identifier inside its bucket directory. Flow
versions are the commit SHAs that changed the
+flow file, and branches of the repository are available as registry branches.
+
+When the repository has no top-level directories and the Access Token has
write access, the client creates a `default`
+bucket containing a `.keep` file.
+
+## Access Token
+
+Create an Access Token in the user settings of Gitea or Forgejo under
Applications:
+
+- `read:repository` is required to list buckets and import flows
+- `write:repository` is required to commit, delete and branch flows
+
+The client reports write access based on the repository permissions of the
token owner. Repository permissions do not
+reflect token scopes, so a token limited to `read:repository` passes
verification for write access but commits fail
+with HTTP 403. Archived repositories and pull mirrors are always read-only.
+
+Branch protection rules apply to commits made through the REST API. Commits to
a protected branch fail unless the token
+owner is allowed to push to that branch.
+
+## Web Client Service
+
+Configure a `StandardWebClientServiceProvider` and select it in the Web Client
Service property. Certificates for TLS
+and proxy settings are configured on the Web Client Service. The SSL Context
Service property of this component is not
+used.
+
+## Gitea API URL
+
+Set the Gitea API URL to the base URL of the instance, such as
`https://gitea.example.com` or `https://codeberg.org`.
+When the instance runs under a context path, include the path, such as
`https://example.com/gitea`. A URL ending with
+`/api/v1` is also accepted.
+
+## Commit Authors
+
+When Commit Author Source is set to Application User, the identity of the NiFi
user is sent as both the author name and
+the author email. The owner of the Access Token remains the committer.
+
+## Commit History
+
+For a given flow, the client retrieves at most the last 50 commits to limit
API calls. Older versions are not listed but
+remain available to process groups that reference them.
+
+## Names
+
+Branch names and bucket directory names containing `&` or `+` are not
supported because these characters are not
+encoded in query parameters.
+
+## Compatibility
+
+The client has been tested with Gitea 1.20 to 1.27 and Forgejo 11 to 16. Gitea
1.21 updates branch listings
+asynchronously, so a newly created branch can take a few seconds to appear.
diff --git
a/nifi-extension-bundles/nifi-gitea-bundle/nifi-gitea-extensions/src/test/java/org/apache/nifi/gitea/GiteaFlowRegistryClientTest.java
b/nifi-extension-bundles/nifi-gitea-bundle/nifi-gitea-extensions/src/test/java/org/apache/nifi/gitea/GiteaFlowRegistryClientTest.java
new file mode 100644
index 00000000000..bcb708992f4
--- /dev/null
+++
b/nifi-extension-bundles/nifi-gitea-bundle/nifi-gitea-extensions/src/test/java/org/apache/nifi/gitea/GiteaFlowRegistryClientTest.java
@@ -0,0 +1,90 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.nifi.gitea;
+
+import org.apache.nifi.components.PropertyDescriptor;
+import org.apache.nifi.components.PropertyValue;
+import org.apache.nifi.registry.flow.FlowRegistryClientConfigurationContext;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.Arguments;
+import org.junit.jupiter.params.provider.MethodSource;
+import org.mockito.Mock;
+import org.mockito.junit.jupiter.MockitoExtension;
+
+import java.util.stream.Stream;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.mockito.Mockito.lenient;
+import static org.mockito.Mockito.mock;
+
+@ExtendWith(MockitoExtension.class)
+class GiteaFlowRegistryClientTest {
+
+ @Mock
+ private FlowRegistryClientConfigurationContext context;
+
+ private final GiteaFlowRegistryClient client = new
GiteaFlowRegistryClient();
+
+ @BeforeEach
+ void setContext() {
+ setProperty(GiteaFlowRegistryClient.GITEA_API_URL,
"https://gitea.example.com/");
+ setProperty(GiteaFlowRegistryClient.REPOSITORY_OWNER, "nifi");
+ setProperty(GiteaFlowRegistryClient.REPOSITORY_NAME, "flows");
+ }
+
+ @ParameterizedTest
+ @MethodSource("storageLocationArgs")
+ void testIsStorageLocationApplicable(final String location, final boolean
applicable) {
+ assertEquals(applicable, client.isStorageLocationApplicable(context,
location));
+ }
+
+ @ParameterizedTest
+ @MethodSource("apiUrlArgs")
+ void testIsSupportedUrl(final String url, final boolean supported) {
+ assertEquals(supported, GiteaFlowRegistryClient.isSupportedUrl(url));
+ }
+
+ private static Stream<Arguments> storageLocationArgs() {
+ return Stream.of(
+ Arguments.argumentSet("Same repository",
"https://gitea.example.com/nifi/flows", true),
+ Arguments.argumentSet("Same repository with suffix",
"https://gitea.example.com/nifi/flows.git", true),
+ Arguments.argumentSet("Same repository different case",
"https://Gitea.example.com/NiFi/Flows", true),
+ Arguments.argumentSet("Different repository",
"https://gitea.example.com/nifi/other", false),
+ Arguments.argumentSet("Different host",
"https://codeberg.org/nifi/flows", false),
+ Arguments.argumentSet("GitHub location",
"[email protected]:nifi/flows.git", false),
+ Arguments.argumentSet("Null location", null, false)
+ );
+ }
+
+ private static Stream<Arguments> apiUrlArgs() {
+ return Stream.of(
+ Arguments.argumentSet("HTTPS", "https://gitea.example.com",
true),
+ Arguments.argumentSet("HTTP with port and context path",
"http://10.0.0.1:3000/gitea", true),
+ Arguments.argumentSet("SSH", "ssh://[email protected]",
false),
+ Arguments.argumentSet("Host only", "gitea.example.com", false)
+ );
+ }
+
+ private void setProperty(final PropertyDescriptor descriptor, final String
value) {
+ final PropertyValue propertyValue = mock(PropertyValue.class);
+ lenient().when(propertyValue.getValue()).thenReturn(value);
+
lenient().when(context.getProperty(descriptor)).thenReturn(propertyValue);
+ }
+}
diff --git
a/nifi-extension-bundles/nifi-gitea-bundle/nifi-gitea-extensions/src/test/java/org/apache/nifi/gitea/GiteaRepositoryClientTest.java
b/nifi-extension-bundles/nifi-gitea-bundle/nifi-gitea-extensions/src/test/java/org/apache/nifi/gitea/GiteaRepositoryClientTest.java
new file mode 100644
index 00000000000..aa59902a6d2
--- /dev/null
+++
b/nifi-extension-bundles/nifi-gitea-bundle/nifi-gitea-extensions/src/test/java/org/apache/nifi/gitea/GiteaRepositoryClientTest.java
@@ -0,0 +1,576 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.nifi.gitea;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import mockwebserver3.MockResponse;
+import mockwebserver3.MockWebServer;
+import mockwebserver3.RecordedRequest;
+import org.apache.nifi.logging.ComponentLog;
+import org.apache.nifi.registry.flow.FlowRegistryException;
+import org.apache.nifi.registry.flow.git.client.GitCommit;
+import org.apache.nifi.registry.flow.git.client.GitCreateContentRequest;
+import org.apache.nifi.web.client.StandardHttpUriBuilder;
+import org.apache.nifi.web.client.StandardWebClientService;
+import org.apache.nifi.web.client.provider.api.WebClientServiceProvider;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.ValueSource;
+import org.mockito.Mock;
+import org.mockito.junit.jupiter.MockitoExtension;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.HttpURLConnection;
+import java.nio.charset.StandardCharsets;
+import java.time.Instant;
+import java.util.Base64;
+import java.util.List;
+import java.util.Optional;
+import java.util.Set;
+import java.util.concurrent.TimeUnit;
+import java.util.stream.Collectors;
+import java.util.stream.IntStream;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.mockito.Mockito.lenient;
+
+@ExtendWith(MockitoExtension.class)
+class GiteaRepositoryClientTest {
+
+ private static final String OWNER = "nifi-owner";
+ private static final String REPOSITORY = "nifi-flows";
+ private static final String ACCESS_TOKEN = "access-token";
+ private static final String BRANCH = "main";
+ private static final String REPOSITORY_PATH =
"/api/v1/repos/nifi-owner/nifi-flows";
+ private static final String AUTHORIZATION_HEADER = "Authorization";
+ private static final String TOTAL_COUNT_HEADER = "X-Total-Count";
+ private static final String BLOB_SHA =
"1111111111111111111111111111111111111111";
+ private static final String COMMIT_SHA =
"2222222222222222222222222222222222222222";
+ private static final String FLOW_PATH = "bucket/flow.json";
+ private static final String FLOW_CONTENT = "{\"flow\":\"content\"}";
+
+ private static final String REPOSITORY_WRITABLE = """
+
{"name":"nifi-flows","archived":false,"mirror":false,"permissions":{"admin":false,"push":true,"pull":true}}""";
+
+ private static final ObjectMapper MAPPER = new ObjectMapper();
+
+ @Mock
+ private WebClientServiceProvider webClientServiceProvider;
+
+ @Mock
+ private ComponentLog logger;
+
+ private MockWebServer mockWebServer;
+
+ private StandardWebClientService webClientService;
+
+ @BeforeEach
+ void startServer() throws IOException {
+ mockWebServer = new MockWebServer();
+ mockWebServer.start();
+ webClientService = new StandardWebClientService();
+
lenient().when(webClientServiceProvider.getWebClientService()).thenReturn(webClientService);
+
lenient().when(webClientServiceProvider.getHttpUriBuilder()).thenAnswer(invocation
-> new StandardHttpUriBuilder());
+ }
+
+ @AfterEach
+ void stopServer() {
+ webClientService.close();
+ mockWebServer.close();
+ }
+
+ @Test
+ void testBuildPermissionsAndAuthorization() throws Exception {
+ final GiteaRepositoryClient client = buildClient(null);
+
+ assertTrue(client.hasReadPermission());
+ assertTrue(client.hasWritePermission());
+
+ final RecordedRequest request = takeRequest();
+ assertEquals("GET", request.getMethod());
+ assertEquals(REPOSITORY_PATH, request.getTarget());
+ assertEquals("token " + ACCESS_TOKEN,
request.getHeaders().get(AUTHORIZATION_HEADER));
+ }
+
+ @ParameterizedTest
+ @ValueSource(strings = {
+ """
+
{"archived":true,"mirror":false,"permissions":{"push":true,"pull":true}}""",
+ """
+
{"archived":false,"mirror":true,"permissions":{"push":true,"pull":true}}""",
+ """
+
{"archived":false,"mirror":false,"permissions":{"push":false,"pull":true}}"""
+ })
+ void testBuildReadOnly(final String repository) throws Exception {
+ final GiteaRepositoryClient client = buildClient(null, repository);
+
+ assertTrue(client.hasReadPermission());
+ assertFalse(client.hasWritePermission());
+ }
+
+ @Test
+ void testBuildApiUrlContextPath() throws Exception {
+ enqueue(HttpURLConnection.HTTP_OK, REPOSITORY_WRITABLE);
+ final String apiUrl = mockWebServer.url("/gitea/api/v1/").toString();
+
+ final GiteaRepositoryClient client = GiteaRepositoryClient.builder()
+ .clientId("client")
+ .apiUrl(apiUrl)
+ .repoOwner(OWNER)
+ .repoName(REPOSITORY)
+ .accessToken(ACCESS_TOKEN)
+ .webClient(webClientServiceProvider)
+ .logger(logger)
+ .build();
+
+ assertEquals("/gitea" + REPOSITORY_PATH, takeRequest().getTarget());
+ assertEquals(mockWebServer.url("/gitea").toString(),
client.getApiUrl());
+ }
+
+ @Test
+ void testBuildRepositoryNotFound() {
+ enqueue(HttpURLConnection.HTTP_NOT_FOUND,
"{\"message\":\"GetRepositoryByName\"}");
+
+ final FlowRegistryException exception =
assertThrows(FlowRegistryException.class, this::buildClientRequest);
+ assertTrue(exception.getMessage().contains("HTTP 404:
GetRepositoryByName"), exception.getMessage());
+ }
+
+ @Test
+ void testGetBranchesPaging() throws Exception {
+ final GiteaRepositoryClient client = buildClient(null);
+ final int total = GiteaRepositoryClient.BRANCH_PAGE_SIZE + 2;
+ enqueue(HttpURLConnection.HTTP_OK, branches(0,
GiteaRepositoryClient.BRANCH_PAGE_SIZE), TOTAL_COUNT_HEADER,
Integer.toString(total));
+ enqueue(HttpURLConnection.HTTP_OK,
branches(GiteaRepositoryClient.BRANCH_PAGE_SIZE, total), TOTAL_COUNT_HEADER,
Integer.toString(total));
+
+ final Set<String> branches = client.getBranches();
+
+ assertEquals(total, branches.size());
+ assertTrue(branches.contains("branch-51"));
+ takeRequest();
+ assertEquals(REPOSITORY_PATH + "/branches?page=1&limit=50",
takeRequest().getTarget());
+ assertEquals(REPOSITORY_PATH + "/branches?page=2&limit=50",
takeRequest().getTarget());
+ assertEquals(3, mockWebServer.getRequestCount());
+ }
+
+ @Test
+ void testGetTopLevelDirectoryNamesRepositoryPath() throws Exception {
+ final GiteaRepositoryClient client = buildClient("flows/nifi");
+ enqueue(HttpURLConnection.HTTP_OK, """
+
[{"name":"bucket-a","type":"dir"},{"name":"README.md","type":"file"},{"name":"bucket-b","type":"dir"}]""");
+
+ final Set<String> directories =
client.getTopLevelDirectoryNames(BRANCH);
+
+ assertEquals(Set.of("bucket-a", "bucket-b"), directories);
+ takeRequest();
+ assertEquals(REPOSITORY_PATH + "/contents/flows/nifi?ref=main",
takeRequest().getTarget());
+ }
+
+ @Test
+ void testGetTopLevelDirectoryNamesDirectoryNotFound() throws Exception {
+ final GiteaRepositoryClient client = buildClient("flows");
+ enqueue(HttpURLConnection.HTTP_NOT_FOUND,
"{\"message\":\"GetContentsOrList\"}");
+ enqueue(HttpURLConnection.HTTP_OK, "{\"name\":\"main\"}");
+
+ assertTrue(client.getTopLevelDirectoryNames(BRANCH).isEmpty());
+ takeRequest();
+ assertEquals(REPOSITORY_PATH + "/contents/flows?ref=main",
takeRequest().getTarget());
+ assertEquals(REPOSITORY_PATH + "/branches/main",
takeRequest().getTarget());
+ }
+
+ @Test
+ void testGetTopLevelDirectoryNamesBranchNotFound() throws Exception {
+ final GiteaRepositoryClient client = buildClient(null);
+ enqueue(HttpURLConnection.HTTP_NOT_FOUND, "{\"message\":\"branch does
not exist\"}");
+ enqueue(HttpURLConnection.HTTP_NOT_FOUND, "{\"message\":\"branch does
not exist\"}");
+ enqueue(HttpURLConnection.HTTP_OK, REPOSITORY_WRITABLE);
+
+ final FlowRegistryException exception =
assertThrows(FlowRegistryException.class, () ->
client.getTopLevelDirectoryNames("develop"));
+ assertTrue(exception.getMessage().contains("Branch [develop] not
found"), exception.getMessage());
+ }
+
+ @Test
+ void testGetTopLevelDirectoryNamesEmptyRepository() throws Exception {
+ final GiteaRepositoryClient client = buildClient(null);
+ enqueue(HttpURLConnection.HTTP_NOT_FOUND, "{\"message\":\"not
found\"}");
+ enqueue(HttpURLConnection.HTTP_NOT_FOUND, "{\"message\":\"branch does
not exist\"}");
+ enqueue(HttpURLConnection.HTTP_OK, """
+
{"name":"nifi-flows","empty":true,"permissions":{"push":true,"pull":true}}""");
+
+ assertTrue(client.getTopLevelDirectoryNames(BRANCH).isEmpty());
+ }
+
+ @Test
+ void testGetFileNames() throws Exception {
+ final GiteaRepositoryClient client = buildClient(null);
+ enqueue(HttpURLConnection.HTTP_OK, """
+
[{"name":"flow.json","type":"file"},{"name":"nested","type":"dir"},{"name":".keep","type":"file"}]""");
+
+ assertEquals(Set.of("flow.json", ".keep"),
client.getFileNames("bucket", BRANCH));
+ }
+
+ @Test
+ void testGetCommits() throws Exception {
+ final GiteaRepositoryClient client = buildClient(null);
+ final int retrieved = GiteaRepositoryClient.COMMIT_PAGE_SIZE;
+ enqueue(HttpURLConnection.HTTP_OK, commits(0, retrieved), "X-Total",
"120");
+
+ final List<GitCommit> commits = client.getCommits(FLOW_PATH, BRANCH);
+
+ assertEquals(retrieved, commits.size());
+ final GitCommit first = commits.getFirst();
+ assertEquals(commitSha(0), first.id());
+ assertEquals("Author 0", first.author());
+ assertEquals("Message 0", first.message());
+ assertEquals(Instant.parse("2025-01-01T08:00:00Z"),
first.commitDate());
+ assertEquals(commitSha(retrieved - 1), commits.getLast().id());
+
+ takeRequest();
+ assertEquals(REPOSITORY_PATH +
"/commits?sha=main&path=bucket/flow.json&stat=false&verification=false&files=false&limit=50",
+ takeRequest().getTarget());
+ assertEquals(2, mockWebServer.getRequestCount());
+ }
+
+ @ParameterizedTest
+ @ValueSource(ints = {HttpURLConnection.HTTP_NOT_FOUND,
HttpURLConnection.HTTP_CONFLICT})
+ void testGetCommitsNotFoundOrEmptyRepository(final int statusCode) throws
Exception {
+ final GiteaRepositoryClient client = buildClient(null);
+ enqueue(statusCode, "{\"message\":\"not found\"}");
+
+ assertTrue(client.getCommits(FLOW_PATH, BRANCH).isEmpty());
+ }
+
+ @Test
+ void testGetContentSha() throws Exception {
+ final GiteaRepositoryClient client = buildClient(null);
+ enqueue(HttpURLConnection.HTTP_OK, fileResponse());
+
+ assertEquals(Optional.of(BLOB_SHA), client.getContentSha(FLOW_PATH,
BRANCH));
+ takeRequest();
+ assertEquals(REPOSITORY_PATH + "/contents/bucket/flow.json?ref=main",
takeRequest().getTarget());
+ }
+
+ @Test
+ void testGetContentShaAtCommit() throws Exception {
+ final GiteaRepositoryClient client = buildClient(null);
+ enqueue(HttpURLConnection.HTTP_OK, fileResponse());
+
+ assertEquals(Optional.of(BLOB_SHA),
client.getContentShaAtCommit(FLOW_PATH, COMMIT_SHA));
+ takeRequest();
+ assertEquals(REPOSITORY_PATH + "/contents/bucket/flow.json?ref=" +
COMMIT_SHA, takeRequest().getTarget());
+ }
+
+ @Test
+ void testGetContentShaNotFile() throws Exception {
+ final GiteaRepositoryClient client = buildClient(null);
+ enqueue(HttpURLConnection.HTTP_OK,
"[{\"name\":\"flow.json\",\"type\":\"file\"}]");
+ enqueue(HttpURLConnection.HTTP_NOT_FOUND, "{\"message\":\"not
found\"}");
+
+ assertTrue(client.getContentSha("bucket", BRANCH).isEmpty());
+ assertTrue(client.getContentSha(FLOW_PATH, BRANCH).isEmpty());
+ }
+
+ @Test
+ void testGetContentFromCommit() throws Exception {
+ final GiteaRepositoryClient client = buildClient(null);
+ enqueue(HttpURLConnection.HTTP_OK, FLOW_CONTENT);
+
+ try (InputStream content = client.getContentFromCommit(FLOW_PATH,
COMMIT_SHA)) {
+ assertEquals(FLOW_CONTENT, new String(content.readAllBytes(),
StandardCharsets.UTF_8));
+ }
+ takeRequest();
+ assertEquals(REPOSITORY_PATH + "/media/bucket/flow.json?ref=" +
COMMIT_SHA, takeRequest().getTarget());
+ }
+
+ @Test
+ void testGetContentFromBranchNotFound() throws Exception {
+ final GiteaRepositoryClient client = buildClient(null);
+ enqueue(HttpURLConnection.HTTP_NOT_FOUND, "{\"message\":\"not
found\"}");
+
+ final FlowRegistryException exception =
assertThrows(FlowRegistryException.class, () ->
client.getContentFromBranch(FLOW_PATH, BRANCH));
+ assertTrue(exception.getMessage().contains("not found"),
exception.getMessage());
+ }
+
+ @Test
+ void testCreateContentNewFile() throws Exception {
+ final GiteaRepositoryClient client = buildClient(null);
+ enqueue(HttpURLConnection.HTTP_CREATED, fileCommitResponse());
+
+ final GitCreateContentRequest request =
GitCreateContentRequest.builder()
+ .branch(BRANCH)
+ .path(FLOW_PATH)
+ .content(FLOW_CONTENT)
+ .message("Registering Flow")
+ .build();
+
+ assertEquals(COMMIT_SHA, client.createContent(request));
+
+ takeRequest();
+ final RecordedRequest recordedRequest = takeRequest();
+ assertEquals("POST", recordedRequest.getMethod());
+ assertEquals(REPOSITORY_PATH + "/contents/bucket/flow.json",
recordedRequest.getTarget());
+ final JsonNode body = readBody(recordedRequest);
+ assertEquals(FLOW_CONTENT, new
String(Base64.getDecoder().decode(body.get("content").asText()),
StandardCharsets.UTF_8));
+ assertEquals(BRANCH, body.get("branch").asText());
+ assertEquals("Registering Flow", body.get("message").asText());
+ assertFalse(body.has("sha"));
+ assertFalse(body.has("author"));
+ }
+
+ @Test
+ void testCreateContentUpdateFileWithAuthor() throws Exception {
+ final GiteaRepositoryClient client = buildClient(null);
+ enqueue(HttpURLConnection.HTTP_OK, fileCommitResponse());
+
+ final GitCreateContentRequest request =
GitCreateContentRequest.builder()
+ .branch(BRANCH)
+ .path(FLOW_PATH)
+ .content(FLOW_CONTENT)
+ .message("Updated")
+ .existingContentSha(BLOB_SHA)
+ .expectedCommitSha(COMMIT_SHA)
+ .authorName("CN=admin, OU=NiFi")
+ .authorEmail("CN=admin, OU=NiFi")
+ .build();
+
+ assertEquals(COMMIT_SHA, client.createContent(request));
+
+ takeRequest();
+ final RecordedRequest recordedRequest = takeRequest();
+ assertEquals("PUT", recordedRequest.getMethod());
+ final JsonNode body = readBody(recordedRequest);
+ assertEquals(BLOB_SHA, body.get("sha").asText());
+ assertEquals("CN=admin, OU=NiFi",
body.get("author").get("name").asText());
+ assertEquals("CN=admin, OU=NiFi",
body.get("author").get("email").asText());
+ }
+
+ @ParameterizedTest
+ @ValueSource(ints = {HttpURLConnection.HTTP_CONFLICT, 422})
+ void testCreateContentConflict(final int statusCode) throws Exception {
+ final GiteaRepositoryClient client = buildClient(null);
+ enqueue(statusCode, "{\"message\":\"sha does not match\"}");
+
+ final GitCreateContentRequest request =
GitCreateContentRequest.builder()
+ .branch(BRANCH)
+ .path(FLOW_PATH)
+ .content(FLOW_CONTENT)
+ .message("Updated")
+ .existingContentSha(BLOB_SHA)
+ .build();
+
+ final FlowRegistryException exception =
assertThrows(FlowRegistryException.class, () -> client.createContent(request));
+ assertTrue(exception.getMessage().contains("modified by another
commit"), exception.getMessage());
+ assertTrue(exception.getMessage().contains("sha does not match"),
exception.getMessage());
+ }
+
+ @Test
+ void testCreateContentForbidden() throws Exception {
+ final GiteaRepositoryClient client = buildClient(null);
+ enqueue(HttpURLConnection.HTTP_FORBIDDEN, "{\"message\":\"token does
not have at least one of required scope(s)\"}");
+
+ final GitCreateContentRequest request =
GitCreateContentRequest.builder()
+ .branch(BRANCH)
+ .path(FLOW_PATH)
+ .content(FLOW_CONTENT)
+ .message("Registering Flow")
+ .build();
+
+ final FlowRegistryException exception =
assertThrows(FlowRegistryException.class, () -> client.createContent(request));
+ assertTrue(exception.getMessage().contains("write:repository"),
exception.getMessage());
+ }
+
+ @Test
+ void testCreateContentQuotaExceeded() throws Exception {
+ final GiteaRepositoryClient client = buildClient(null);
+ enqueue(413, "{\"message\":\"quota exceeded\"}");
+
+ final GitCreateContentRequest request =
GitCreateContentRequest.builder()
+ .branch(BRANCH)
+ .path(FLOW_PATH)
+ .content(FLOW_CONTENT)
+ .message("Registering Flow")
+ .build();
+
+ final FlowRegistryException exception =
assertThrows(FlowRegistryException.class, () -> client.createContent(request));
+ assertTrue(exception.getMessage().contains("quota"),
exception.getMessage());
+ }
+
+ @Test
+ void testDeleteContent() throws Exception {
+ final GiteaRepositoryClient client = buildClient(null);
+ enqueue(HttpURLConnection.HTTP_OK, fileResponse());
+ enqueue(HttpURLConnection.HTTP_OK, fileCommitResponse());
+
+ try (InputStream deleted = client.deleteContent(FLOW_PATH,
"Deregistering Flow", BRANCH, "user", "user")) {
+ assertEquals(FLOW_CONTENT, new String(deleted.readAllBytes(),
StandardCharsets.UTF_8));
+ }
+
+ takeRequest();
+ takeRequest();
+ final RecordedRequest recordedRequest = takeRequest();
+ assertEquals("DELETE", recordedRequest.getMethod());
+ assertEquals(REPOSITORY_PATH + "/contents/bucket/flow.json",
recordedRequest.getTarget());
+ final JsonNode body = readBody(recordedRequest);
+ assertEquals(BLOB_SHA, body.get("sha").asText());
+ assertEquals(BRANCH, body.get("branch").asText());
+ assertEquals("user", body.get("author").get("name").asText());
+ }
+
+ @Test
+ void testDeleteContentNotFound() throws Exception {
+ final GiteaRepositoryClient client = buildClient(null);
+ enqueue(HttpURLConnection.HTTP_NOT_FOUND, "{\"message\":\"not
found\"}");
+
+ assertThrows(FlowRegistryException.class, () ->
client.deleteContent(FLOW_PATH, "Deregistering Flow", BRANCH));
+ }
+
+ @Test
+ void testCreateBranchFromCommit() throws Exception {
+ final GiteaRepositoryClient client = buildClient(null);
+ enqueue(HttpURLConnection.HTTP_CREATED, "{\"name\":\"feature\"}");
+
+ client.createBranch(" feature ", BRANCH, Optional.of(COMMIT_SHA));
+
+ takeRequest();
+ final RecordedRequest recordedRequest = takeRequest();
+ assertEquals("POST", recordedRequest.getMethod());
+ assertEquals(REPOSITORY_PATH + "/branches",
recordedRequest.getTarget());
+ final JsonNode body = readBody(recordedRequest);
+ assertEquals("feature", body.get("new_branch_name").asText());
+ assertEquals(COMMIT_SHA, body.get("old_ref_name").asText());
+ }
+
+ @Test
+ void testCreateBranchFromBranchExists() throws Exception {
+ final GiteaRepositoryClient client = buildClient(null);
+ enqueue(HttpURLConnection.HTTP_CONFLICT, "{\"message\":\"The branch
already exists.\"}");
+
+ final FlowRegistryException exception =
assertThrows(FlowRegistryException.class, () -> client.createBranch("feature",
BRANCH, Optional.empty()));
+ assertTrue(exception.getMessage().contains("already exists"),
exception.getMessage());
+
+ takeRequest();
+ assertEquals(BRANCH,
readBody(takeRequest()).get("old_ref_name").asText());
+ }
+
+ @Test
+ void testPathSegmentEncoding() throws Exception {
+ final GiteaRepositoryClient client = buildClient(null);
+ enqueue(HttpURLConnection.HTTP_OK, "[]");
+
+ client.getFileNames("bucket a&b+c%d", BRANCH);
+
+ takeRequest();
+ final RecordedRequest request = takeRequest();
+ assertEquals(REPOSITORY_PATH +
"/contents/bucket%20a&b+c%25d?ref=main", request.getTarget());
+ assertEquals(List.of("api", "v1", "repos", OWNER, REPOSITORY,
"contents", "bucket a&b+c%d"), request.getUrl().pathSegments());
+ }
+
+ @Test
+ void testNormalizeApiUrl() {
+ assertEquals("https://gitea.example.com",
GiteaRepositoryClient.normalizeApiUrl("https://gitea.example.com/"));
+ assertEquals("https://gitea.example.com",
GiteaRepositoryClient.normalizeApiUrl(" https://gitea.example.com/api/v1/ "));
+ assertEquals("https://example.com/gitea",
GiteaRepositoryClient.normalizeApiUrl("https://example.com/gitea/api/v1"));
+ }
+
+ private GiteaRepositoryClient buildClient(final String repositoryPath)
throws FlowRegistryException {
+ return buildClient(repositoryPath, REPOSITORY_WRITABLE);
+ }
+
+ private GiteaRepositoryClient buildClient(final String repositoryPath,
final String repository) throws FlowRegistryException {
+ enqueue(HttpURLConnection.HTTP_OK, repository);
+ return GiteaRepositoryClient.builder()
+ .clientId("client")
+ .apiUrl(mockWebServer.url("/").toString())
+ .repoOwner(OWNER)
+ .repoName(REPOSITORY)
+ .repoPath(repositoryPath)
+ .accessToken(ACCESS_TOKEN)
+ .webClient(webClientServiceProvider)
+ .logger(logger)
+ .build();
+ }
+
+ private void buildClientRequest() throws FlowRegistryException {
+ GiteaRepositoryClient.builder()
+ .clientId("client")
+ .apiUrl(mockWebServer.url("/").toString())
+ .repoOwner(OWNER)
+ .repoName(REPOSITORY)
+ .accessToken(ACCESS_TOKEN)
+ .webClient(webClientServiceProvider)
+ .logger(logger)
+ .build();
+ }
+
+ private void enqueue(final int statusCode, final String body) {
+ mockWebServer.enqueue(new
MockResponse.Builder().code(statusCode).body(body).build());
+ }
+
+ private void enqueue(final int statusCode, final String body, final String
headerName, final String headerValue) {
+ mockWebServer.enqueue(new
MockResponse.Builder().code(statusCode).body(body).addHeader(headerName,
headerValue).build());
+ }
+
+ private RecordedRequest takeRequest() throws InterruptedException {
+ final RecordedRequest request = mockWebServer.takeRequest(1,
TimeUnit.SECONDS);
+ assertNotNull(request);
+ return request;
+ }
+
+ private JsonNode readBody(final RecordedRequest request) throws
IOException {
+ assertNotNull(request.getBody());
+ return MAPPER.readTree(request.getBody().utf8());
+ }
+
+ private static String branches(final int start, final int end) {
+ return IntStream.range(start, end)
+ .mapToObj(index ->
"{\"name\":\"branch-%d\",\"commit\":{\"id\":\"%s\"}}".formatted(index,
commitSha(index)))
+ .collect(Collectors.joining(",", "[", "]"));
+ }
+
+ private static String commits(final int start, final int end) {
+ return IntStream.range(start, end)
+ .mapToObj(index -> """
+ {"sha":"%s","commit":{"message":"Message
%d\\n","author":{"name":"Author
%d","email":"[email protected]","date":"2025-01-01T09:00:00+01:00"},\
+
"committer":{"name":"Committer","email":"[email protected]","date":"2025-01-01T10:00:00+02:00"}}}"""
+ .formatted(commitSha(index), index, index))
+ .collect(Collectors.joining(",", "[", "]"));
+ }
+
+ private static String commitSha(final int index) {
+ return "%040d".formatted(index);
+ }
+
+ private static String fileResponse() {
+ final String content =
Base64.getMimeEncoder().encodeToString(FLOW_CONTENT.getBytes(StandardCharsets.UTF_8));
+ return """
+
{"name":"flow.json","path":"bucket/flow.json","sha":"%s","type":"file","encoding":"base64","content":"%s"}""".formatted(BLOB_SHA,
content);
+ }
+
+ private static String fileCommitResponse() {
+ return """
+
{"content":{"name":"flow.json","sha":"%s"},"commit":{"sha":"%s"}}""".formatted(BLOB_SHA,
COMMIT_SHA);
+ }
+}
diff --git a/nifi-extension-bundles/nifi-gitea-bundle/nifi-gitea-nar/pom.xml
b/nifi-extension-bundles/nifi-gitea-bundle/nifi-gitea-nar/pom.xml
new file mode 100644
index 00000000000..73d189cf042
--- /dev/null
+++ b/nifi-extension-bundles/nifi-gitea-bundle/nifi-gitea-nar/pom.xml
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+ http://www.apache.org/licenses/LICENSE-2.0
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
https://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.apache.nifi</groupId>
+ <artifactId>nifi-gitea-bundle</artifactId>
+ <version>2.13.0-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>nifi-gitea-nar</artifactId>
+ <packaging>nar</packaging>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.nifi</groupId>
+ <artifactId>nifi-gitea-extensions</artifactId>
+ <version>2.13.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.nifi</groupId>
+ <artifactId>nifi-standard-shared-nar</artifactId>
+ <version>2.13.0-SNAPSHOT</version>
+ <type>nar</type>
+ </dependency>
+ </dependencies>
+</project>
+
diff --git
a/nifi-extension-bundles/nifi-gitea-bundle/nifi-gitea-nar/src/main/resources/META-INF/LICENSE
b/nifi-extension-bundles/nifi-gitea-bundle/nifi-gitea-nar/src/main/resources/META-INF/LICENSE
new file mode 100644
index 00000000000..3e05ec8f91e
--- /dev/null
+++
b/nifi-extension-bundles/nifi-gitea-bundle/nifi-gitea-nar/src/main/resources/META-INF/LICENSE
@@ -0,0 +1,222 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ The binary distribution of this product bundles 'Jakarta Activation API
2.1.4' and 'Jakarta XML Binding API 4.0.5' modules under an EDL v1.0 license
+
+ Copyright (c) 2007, Eclipse Foundation, Inc. and its licensors.
+
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
+
+ Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
+ Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
+ Neither the name of the Eclipse Foundation, Inc. nor the names of its
contributors may be used to endorse or promote products derived from this
software without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
IS" AND ANY EXPRESS OR IMPLIED
+ WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
diff --git
a/nifi-extension-bundles/nifi-gitea-bundle/nifi-gitea-nar/src/main/resources/META-INF/NOTICE
b/nifi-extension-bundles/nifi-gitea-bundle/nifi-gitea-nar/src/main/resources/META-INF/NOTICE
new file mode 100644
index 00000000000..e59649b7c79
--- /dev/null
+++
b/nifi-extension-bundles/nifi-gitea-bundle/nifi-gitea-nar/src/main/resources/META-INF/NOTICE
@@ -0,0 +1,37 @@
+nifi-gitea-nar
+Copyright 2026 The Apache Software Foundation
+
+This product includes software developed at
+The Apache Software Foundation (http://www.apache.org/).
+
+******************
+Apache Software License v2
+******************
+
+The following binary components are provided under the Apache Software License
v2
+
+ (ASLv2) Jackson JSON processor
+ The following NOTICE information applies:
+ # Jackson JSON processor
+
+ Jackson is a high-performance, Free/Open Source JSON processing library.
+ It was originally written by Tatu Saloranta ([email protected]), and
has
+ been in development since 2007.
+ It is currently developed by a community of developers, as well as
supported
+ commercially by FasterXML.com.
+
+ ## Licensing
+
+ Jackson core and extension components may licensed under different
licenses.
+ To find the details that apply to this artifact see the accompanying
LICENSE file.
+ For more information, including possible other licensing options, contact
+ FasterXML.com (http://fasterxml.com).
+
+************************
+Eclipse Distribution License 1.0
+************************
+
+The following binary components are provided under the Eclipse Distribution
License 1.0.
+
+ (EDL 1.0) Jakarta Activation API
(jakarta.activation:jakarta.activation-api:jar:2.1.4)
+ (EDL 1.0) Jakarta XML Binding API
(jakarta.xml.bind:jakarta.xml.bind-api:jar:4.0.5)
diff --git a/nifi-extension-bundles/nifi-gitea-bundle/pom.xml
b/nifi-extension-bundles/nifi-gitea-bundle/pom.xml
new file mode 100644
index 00000000000..3556502e6a9
--- /dev/null
+++ b/nifi-extension-bundles/nifi-gitea-bundle/pom.xml
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+ http://www.apache.org/licenses/LICENSE-2.0
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
https://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <artifactId>nifi-standard-shared-bom</artifactId>
+ <groupId>org.apache.nifi</groupId>
+ <version>2.13.0-SNAPSHOT</version>
+
<relativePath>../nifi-standard-shared-bundle/nifi-standard-shared-bom</relativePath>
+ </parent>
+
+ <artifactId>nifi-gitea-bundle</artifactId>
+ <packaging>pom</packaging>
+
+ <modules>
+ <module>nifi-gitea-extensions</module>
+ <module>nifi-gitea-nar</module>
+ </modules>
+</project>
diff --git a/nifi-extension-bundles/pom.xml b/nifi-extension-bundles/pom.xml
index a35b987e52c..437dc48b35e 100755
--- a/nifi-extension-bundles/pom.xml
+++ b/nifi-extension-bundles/pom.xml
@@ -94,6 +94,7 @@
<module>nifi-github-bundle</module>
<module>nifi-gitlab-bundle</module>
<module>nifi-atlassian-bundle</module>
+ <module>nifi-gitea-bundle</module>
<module>nifi-couchbase-bundle</module>
</modules>
</project>