Skip to content

Commit

Permalink
Refactoring to create base class for other git-based flow registry cl…
Browse files Browse the repository at this point in the history
…ients

Working GitLab client
Fix bug where frontend not submitting branch on Change Flow Version dialog
  • Loading branch information
bbende committed Sep 10, 2024
1 parent c4d11fe commit c2dc9f8
Show file tree
Hide file tree
Showing 23 changed files with 1,615 additions and 611 deletions.
6 changes: 6 additions & 0 deletions nifi-assembly/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -856,6 +856,12 @@ language governing permissions and limitations under the License. -->
<version>2.0.0-SNAPSHOT</version>
<type>nar</type>
</dependency>
<dependency>
<groupId>org.apache.nifi</groupId>
<artifactId>nifi-gitlab-nar</artifactId>
<version>2.0.0-SNAPSHOT</version>
<type>nar</type>
</dependency>
<!-- AspectJ library needed by the Java Agent used for native library loading (see bootstrap.conf) -->
<dependency>
<groupId>org.aspectj</groupId>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?xml version="1.0"?>
<!--
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-extension-utils</artifactId>
<version>2.0.0-SNAPSHOT</version>
</parent>
<artifactId>nifi-git-flow-registry</artifactId>
<packaging>jar</packaging>

<dependencies>
<dependency>
<groupId>com.fasterxml.jackson.module</groupId>
<artifactId>jackson-module-jakarta-xmlbind-annotations</artifactId>
</dependency>
</dependencies>

</project>

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
/*
* 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.registry.flow.git.client;

import java.util.Date;
import java.util.Objects;

public class GitCommit {

private final String id;
private final String author;
private final String message;
private final Date commitDate;

private GitCommit(final Builder builder) {
this.id = Objects.requireNonNull(builder.id, "Id is required");
this.author = Objects.requireNonNull(builder.author, "Author is required");
this.commitDate = Objects.requireNonNull(builder.commitDate, "Commit Date is required");
this.message = builder.message;
}

public String getId() {
return id;
}

public String getAuthor() {
return author;
}

public String getMessage() {
return message;
}

public Date getCommitDate() {
return commitDate;
}

public static Builder builder() {
return new Builder();
}

public static final class Builder {
private String id;
private String author;
private String message;
private Date commitDate;

public Builder id(final String id) {
this.id = id;
return this;
}

public Builder author(final String author) {
this.author = author;
return this;
}

public Builder message(final String message) {
this.message = message;
return this;
}

public Builder commitDate(final Date commitDate) {
this.commitDate = commitDate;
return this;
}

public GitCommit build() {
return new GitCommit(this);
}
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/*
*
* 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.
Expand All @@ -14,22 +13,21 @@
* 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.github;
package org.apache.nifi.registry.flow.git.client;

import java.util.Objects;

public class GitHubCreateContentRequest {
public class GitCreateContentRequest {

private final String branch;
private final String path;
private final String content;
private final String message;
private final String existingContentSha;

private GitHubCreateContentRequest(final Builder builder) {
private GitCreateContentRequest(final Builder builder) {
this.branch = Objects.requireNonNull(builder.branch);
this.path = Objects.requireNonNull(builder.path);
this.content = Objects.requireNonNull(builder.content);
Expand Down Expand Up @@ -94,8 +92,8 @@ public Builder existingContentSha(final String existingSha) {
return this;
}

public GitHubCreateContentRequest build() {
return new GitHubCreateContentRequest(this);
public GitCreateContentRequest build() {
return new GitCreateContentRequest(this);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/*
* 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.registry.flow.git.client;

import org.apache.nifi.registry.flow.FlowRegistryException;

import java.io.IOException;
import java.io.InputStream;
import java.util.List;
import java.util.Optional;
import java.util.Set;

/**
* Client for git repository.
*/
public interface GitRepositoryClient {

boolean getCanRead();

boolean getCanWrite();

Set<String> getBranches() throws IOException, FlowRegistryException;

Set<String> getTopLevelDirectoryNames(String branch) throws IOException, FlowRegistryException;

Set<String> getFileNames(String directory, String branch) throws IOException, FlowRegistryException;

List<GitCommit> getCommits(String path, String branch) throws IOException, FlowRegistryException;

InputStream getContentFromBranch(String path, String branch) throws IOException, FlowRegistryException;

InputStream getContentFromCommit(String path, String commitSha) throws IOException, FlowRegistryException;

Optional<String> getContentSha(String path, String branch) throws IOException, FlowRegistryException;

String createContent(GitCreateContentRequest request) throws IOException, FlowRegistryException;

InputStream deleteContent(String filePath, String commitMessage, String branch) throws FlowRegistryException, IOException;

default void close() throws IOException {

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* limitations under the License.
*/

package org.apache.nifi.github;
package org.apache.nifi.registry.flow.git.serialize;

import org.apache.nifi.registry.flow.RegisteredFlowSnapshot;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* limitations under the License.
*/

package org.apache.nifi.github;
package org.apache.nifi.registry.flow.git.serialize;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.databind.DeserializationFeature;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/*
*
* 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.
Expand All @@ -14,10 +13,9 @@
* 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.github;
package org.apache.nifi.registry.flow.git.serialize;

import com.fasterxml.jackson.databind.BeanDescription;
import com.fasterxml.jackson.databind.SerializationConfig;
Expand Down
1 change: 1 addition & 0 deletions nifi-extension-bundles/nifi-extension-utils/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,6 @@
<module>nifi-resource-transfer</module>
<module>nifi-service-utils</module>
<module>nifi-syslog-utils</module>
<module>nifi-git-flow-registry</module>
</modules>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@
<groupId>org.apache.nifi</groupId>
<artifactId>nifi-utils</artifactId>
</dependency>
<dependency>
<groupId>org.apache.nifi</groupId>
<artifactId>nifi-git-flow-registry</artifactId>
<version>2.0.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.module</groupId>
<artifactId>jackson-module-jakarta-xmlbind-annotations</artifactId>
Expand Down
Loading

0 comments on commit c2dc9f8

Please sign in to comment.