This is an automated email from the ASF dual-hosted git repository.

pvillard 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 7aabef305c NIFI-13889 Removed Unused Protected Properties abstraction
7aabef305c is described below

commit 7aabef305cf22e67d47f6dcbf9db1ee9766a561e
Author: exceptionfactory <[email protected]>
AuthorDate: Thu Oct 17 10:47:39 2024 -0500

    NIFI-13889 Removed Unused Protected Properties abstraction
    
    - Removed unused methods from nifi-property-utils components
    
    Signed-off-by: Pierre Villard <[email protected]>
    
    This closes #9410.
---
 nifi-commons/nifi-property-utils/pom.xml           |  6 --
 .../AbstractBootstrapPropertiesLoader.java         |  8 ---
 .../nifi/properties/BootstrapProperties.java       | 42 -----------
 .../nifi/properties/ProtectedProperties.java       | 59 ---------------
 .../nifi/properties/ProtectedPropertyContext.java  | 83 ----------------------
 .../properties/StandardReadableProperties.java     | 10 +--
 .../nifi-registry-properties/pom.xml               |  4 ++
 7 files changed, 5 insertions(+), 207 deletions(-)

diff --git a/nifi-commons/nifi-property-utils/pom.xml 
b/nifi-commons/nifi-property-utils/pom.xml
index f4edca1c4e..0bf2a1aa62 100644
--- a/nifi-commons/nifi-property-utils/pom.xml
+++ b/nifi-commons/nifi-property-utils/pom.xml
@@ -21,10 +21,4 @@
         <version>2.0.0-SNAPSHOT</version>
     </parent>
     <artifactId>nifi-property-utils</artifactId>
-    <dependencies>
-        <dependency>
-            <groupId>org.slf4j</groupId>
-            <artifactId>slf4j-api</artifactId>
-        </dependency>
-    </dependencies>
 </project>
diff --git 
a/nifi-commons/nifi-property-utils/src/main/java/org/apache/nifi/properties/AbstractBootstrapPropertiesLoader.java
 
b/nifi-commons/nifi-property-utils/src/main/java/org/apache/nifi/properties/AbstractBootstrapPropertiesLoader.java
index 2684870a86..710cc065d8 100644
--- 
a/nifi-commons/nifi-property-utils/src/main/java/org/apache/nifi/properties/AbstractBootstrapPropertiesLoader.java
+++ 
b/nifi-commons/nifi-property-utils/src/main/java/org/apache/nifi/properties/AbstractBootstrapPropertiesLoader.java
@@ -16,9 +16,6 @@
  */
 package org.apache.nifi.properties;
 
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
 import java.io.File;
 import java.io.IOException;
 import java.io.InputStream;
@@ -31,8 +28,6 @@ import java.util.Properties;
  * An abstract base class for an application-specific BootstrapProperties 
loader.
  */
 public abstract class AbstractBootstrapPropertiesLoader {
-    private static final Logger logger = 
LoggerFactory.getLogger(AbstractBootstrapPropertiesLoader.class);
-
     private static final String RELATIVE_APPLICATION_PROPERTIES_PATTERN = 
"conf/%s";
     private static final String BOOTSTRAP_CONF = "bootstrap.conf";
 
@@ -134,12 +129,9 @@ public abstract class AbstractBootstrapPropertiesLoader {
         String systemPath = System.getProperty(systemPropertyName);
 
         if (systemPath == null || systemPath.trim().isEmpty()) {
-            logger.warn("System Property [{}] not found: Using Relative Path 
[{}]", systemPropertyName, defaultRelativePath);
-            System.setProperty(systemPropertyName, defaultRelativePath);
             systemPath = defaultRelativePath;
         }
 
-        logger.debug("Default Application Properties Path [{}]", systemPath);
         return systemPath;
     }
 }
diff --git 
a/nifi-commons/nifi-property-utils/src/main/java/org/apache/nifi/properties/BootstrapProperties.java
 
b/nifi-commons/nifi-property-utils/src/main/java/org/apache/nifi/properties/BootstrapProperties.java
index 1d97287dbe..ea2f97580d 100644
--- 
a/nifi-commons/nifi-property-utils/src/main/java/org/apache/nifi/properties/BootstrapProperties.java
+++ 
b/nifi-commons/nifi-property-utils/src/main/java/org/apache/nifi/properties/BootstrapProperties.java
@@ -17,19 +17,14 @@
 package org.apache.nifi.properties;
 
 import java.nio.file.Path;
-import java.nio.file.Paths;
-import java.util.Collections;
 import java.util.Enumeration;
 import java.util.Objects;
 import java.util.Properties;
-import java.util.Set;
 
 /**
  * Properties representing bootstrap.conf.
  */
 public class BootstrapProperties extends StandardReadableProperties {
-    private static final String PROPERTY_KEY_FORMAT = "%s.%s";
-
     private final String propertyPrefix;
     private final Path configFilePath;
 
@@ -66,14 +61,6 @@ public class BootstrapProperties extends 
StandardReadableProperties {
         return isBlank(property) ? null : property;
     }
 
-    /**
-     * Returns the path to the bootstrap config file.
-     * @return The path to the file
-     */
-    public Path getConfigFilePath() {
-        return configFilePath;
-    }
-
     /**
      * Includes only the properties starting with the propertyPrefix.
      * @param properties Unfiltered properties
@@ -90,40 +77,11 @@ public class BootstrapProperties extends 
StandardReadableProperties {
         getRawProperties().putAll(filteredProperties);
     }
 
-    private String getPropertyKey(final String subKey) {
-        return String.format(PROPERTY_KEY_FORMAT, propertyPrefix, subKey);
-    }
-
     @Override
     public String toString() {
         return String.format("Bootstrap properties [%s] with prefix [%s]", 
configFilePath, propertyPrefix);
     }
 
-    /**
-     * An empty instance of BootstrapProperties.
-     */
-    public static final BootstrapProperties EMPTY = new 
BootstrapProperties("", new Properties(), Paths.get("conf/bootstrap.conf")) {
-        @Override
-        public Set<String> getPropertyKeys() {
-            return Collections.EMPTY_SET;
-        }
-
-        @Override
-        public String getProperty(String key) {
-            return null;
-        }
-
-        @Override
-        public String getProperty(String key, String defaultValue) {
-            return null;
-        }
-
-        @Override
-        public int size() {
-            return 0;
-        }
-    };
-
     private static boolean isBlank(final String string) {
         return (string == null) || string.isEmpty() || string.trim().isEmpty();
     }
diff --git 
a/nifi-commons/nifi-property-utils/src/main/java/org/apache/nifi/properties/ProtectedProperties.java
 
b/nifi-commons/nifi-property-utils/src/main/java/org/apache/nifi/properties/ProtectedProperties.java
deleted file mode 100644
index f04b1a812f..0000000000
--- 
a/nifi-commons/nifi-property-utils/src/main/java/org/apache/nifi/properties/ProtectedProperties.java
+++ /dev/null
@@ -1,59 +0,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.
- */
-package org.apache.nifi.properties;
-
-import java.util.List;
-import java.util.Properties;
-
-/**
- * Represents a protected set of ApplicationProperties, with methods regarding 
which sensitive properties
- * are protected.
- * @param <T> The ApplicationProperties type
- */
-public interface ProtectedProperties<T extends ApplicationProperties> {
-
-    /**
-     * Additional sensitive properties keys
-     * @return Additional sensitive properties keys
-     */
-    String getAdditionalSensitivePropertiesKeys();
-
-    /**
-     * Returns the name of the property that specifies the additional 
sensitive properties keys
-     * @return Name of additional sensitive properties keys
-     */
-    String getAdditionalSensitivePropertiesKeysName();
-
-    /**
-     * Additional sensitive properties keys
-     * @return Additional sensitive properties keys
-     */
-    List<String> getDefaultSensitiveProperties();
-
-    /**
-     * Returns the application properties.
-     * @return The application properties
-     */
-    T getApplicationProperties();
-
-    /**
-     * Create a new ApplicationProperties object of the generic type.
-     * @param rawProperties Plain old properties
-     * @return The ApplicationProperties
-     */
-    T createApplicationProperties(Properties rawProperties);
-}
diff --git 
a/nifi-commons/nifi-property-utils/src/main/java/org/apache/nifi/properties/ProtectedPropertyContext.java
 
b/nifi-commons/nifi-property-utils/src/main/java/org/apache/nifi/properties/ProtectedPropertyContext.java
deleted file mode 100644
index 0cdf46b1d6..0000000000
--- 
a/nifi-commons/nifi-property-utils/src/main/java/org/apache/nifi/properties/ProtectedPropertyContext.java
+++ /dev/null
@@ -1,83 +0,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.
- */
-package org.apache.nifi.properties;
-
-import java.util.Objects;
-
-/**
- * A context for protected properties, encapsulating the context name and 
property name.
- */
-public class ProtectedPropertyContext {
-    private static final String DEFAULT_CONTEXT = "default";
-
-    private final String propertyName;
-    private final String contextName;
-
-    /**
-     * Creates a ProtectedPropertyContext for the given property name, with a 
specific context name, acting as
-     * a namespace for the property.
-     * @param propertyName The property name in this location
-     * @param contextName A custom context name.  If null, the default context 
will be assigned.
-     * @return A property context representing a property within a specific 
context
-     */
-    public static ProtectedPropertyContext contextFor(final String 
propertyName, final String contextName) {
-        return new ProtectedPropertyContext(propertyName, contextName);
-    }
-
-    /**
-     * Creates a ProtectedPropertyContext for the given property name, using 
the default context.
-     * @param propertyName The property name in this location
-     * @return A property context representing a property with the given name 
in the default context
-     */
-    public static ProtectedPropertyContext defaultContext(final String 
propertyName) {
-        return new ProtectedPropertyContext(propertyName, DEFAULT_CONTEXT);
-    }
-
-    /**
-     * Creates a property context with a property name and custom location.
-     * @param propertyName The property name
-     * @param contextName The context name.  If null, the default context will 
be assigned.
-     */
-    private ProtectedPropertyContext(final String propertyName, final String 
contextName) {
-        this.propertyName = Objects.requireNonNull(propertyName);
-        this.contextName = contextName == null ? DEFAULT_CONTEXT : contextName;
-    }
-
-    /**
-     * Returns the context key, in the format [contextName]/[propertyName]
-     * @return The context key
-     */
-    public String getContextKey() {
-        return String.format("%s/%s", contextName, propertyName);
-    }
-
-    /**
-     * Returns the property name
-     * @return The property name
-     */
-    public String getPropertyName() {
-        return propertyName;
-    }
-
-    /**
-     * Returns the context name
-     * @return The context name
-     */
-    public String getContextName() {
-        return contextName;
-    }
-}
diff --git 
a/nifi-commons/nifi-property-utils/src/main/java/org/apache/nifi/properties/StandardReadableProperties.java
 
b/nifi-commons/nifi-property-utils/src/main/java/org/apache/nifi/properties/StandardReadableProperties.java
index 491a9c7270..2e1a429e39 100644
--- 
a/nifi-commons/nifi-property-utils/src/main/java/org/apache/nifi/properties/StandardReadableProperties.java
+++ 
b/nifi-commons/nifi-property-utils/src/main/java/org/apache/nifi/properties/StandardReadableProperties.java
@@ -16,8 +16,6 @@
  */
 package org.apache.nifi.properties;
 
-import java.util.Enumeration;
-import java.util.HashSet;
 import java.util.Map;
 import java.util.Properties;
 import java.util.Set;
@@ -49,13 +47,7 @@ public class StandardReadableProperties implements 
ReadableProperties {
 
     @Override
     public Set<String> getPropertyKeys() {
-        Set<String> propertyNames = new HashSet<>();
-        Enumeration e = rawProperties.propertyNames();
-        for (; e.hasMoreElements(); ) {
-            propertyNames.add((String) e.nextElement());
-        }
-
-        return propertyNames;
+        return rawProperties.stringPropertyNames();
     }
 
     protected Properties getRawProperties() {
diff --git a/nifi-registry/nifi-registry-core/nifi-registry-properties/pom.xml 
b/nifi-registry/nifi-registry-core/nifi-registry-properties/pom.xml
index 71278c1a61..20cd28456f 100644
--- a/nifi-registry/nifi-registry-core/nifi-registry-properties/pom.xml
+++ b/nifi-registry/nifi-registry-core/nifi-registry-properties/pom.xml
@@ -24,6 +24,10 @@
     <packaging>jar</packaging>
 
     <dependencies>
+        <dependency>
+            <groupId>org.slf4j</groupId>
+            <artifactId>slf4j-api</artifactId>
+        </dependency>
         <dependency>
             <groupId>org.apache.nifi</groupId>
             <artifactId>nifi-property-utils</artifactId>

Reply via email to