Skip to content
Permalink
Browse files

Improved: Rewrite ‘ComponentConfig#getKeystoreInfo’

(OFBIZ-11101)

It now has a stream based implementation.


git-svn-id: https://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/trunk@1862223 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
mthl committed Jun 27, 2019
1 parent 99a0d56 commit c28820ebb81390e2c7c59878d1ae3ed0e8310357
Showing with 13 additions and 10 deletions.
  1. +13 −10 framework/base/src/main/java/org/apache/ofbiz/base/component/ComponentConfig.java
@@ -195,17 +195,20 @@ public static String getFullLocation(String componentName, String resourceLoader
return cc.getFullLocation(resourceLoaderName, location);
}

/**
* Provides the first key-store matching a name from a specific component.
*
* @param componentName the name of the component to match which can be {@code null}
* @param keystoreName the name of the key-store to match which can be {@code null}
* @return the first key-store matching both {@code componentName} and {@code keystoreName}.
*/
public static KeystoreInfo getKeystoreInfo(String componentName, String keystoreName) {
for (ComponentConfig cc : getAllComponents()) {
if (componentName != null && componentName.equals(cc.getComponentName())) {
for (KeystoreInfo ks : cc.getKeystoreInfos()) {
if (keystoreName != null && keystoreName.equals(ks.getName())) {
return ks;
}
}
}
}
return null;
return getAllComponents().stream()
.filter(cc -> componentName != null && componentName.equals(cc.getComponentName()))
.flatMap(cc -> cc.getKeystoreInfos().stream())
.filter(ks -> keystoreName != null && keystoreName.equals(ks.getName()))
.findFirst()
.orElse(null);
}

public static String getRootLocation(String componentName) throws ComponentException {

0 comments on commit c28820e

Please sign in to comment.
You can’t perform that action at this time.