Skip to content

Commit

Permalink
Improved: Rewrite ‘ComponentConfig#getKeystoreInfo’
Browse files Browse the repository at this point in the history
(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 c28820e
Showing 1 changed file with 13 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit c28820e

Please sign in to comment.