summaryrefslogtreecommitdiff
path: root/eaaf_core/src
diff options
context:
space:
mode:
authorThomas <>2021-03-12 15:43:57 +0100
committerThomas <>2021-03-12 15:43:57 +0100
commit7864448fd040b26b5921cfc63afa68ef2cb90c03 (patch)
treec2fdb77b4d3cbf02af1da0892ad1143983f3c3fa /eaaf_core/src
parent391bc8546bf5bc9a6396378ebec50a7e35031adc (diff)
downloadEAAF-Components-7864448fd040b26b5921cfc63afa68ef2cb90c03.tar.gz
EAAF-Components-7864448fd040b26b5921cfc63afa68ef2cb90c03.tar.bz2
EAAF-Components-7864448fd040b26b5921cfc63afa68ef2cb90c03.zip
refactor some code to Java Stream API
Diffstat (limited to 'eaaf_core/src')
-rw-r--r--eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/auth/builder/AbstractAuthenticationDataBuilder.java25
-rw-r--r--eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/auth/data/AuthProcessDataWrapper.java28
-rw-r--r--eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/builder/AttributeBuilderRegistration.java2
-rw-r--r--eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/controller/tasks/RestartAuthProzessManagement.java11
-rw-r--r--eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/process/ProcessEngineImpl.java9
5 files changed, 34 insertions, 41 deletions
diff --git a/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/auth/builder/AbstractAuthenticationDataBuilder.java b/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/auth/builder/AbstractAuthenticationDataBuilder.java
index 1378d49b..f1811022 100644
--- a/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/auth/builder/AbstractAuthenticationDataBuilder.java
+++ b/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/auth/builder/AbstractAuthenticationDataBuilder.java
@@ -24,7 +24,6 @@ import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Collection;
-import java.util.Map.Entry;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
@@ -205,22 +204,18 @@ public abstract class AbstractAuthenticationDataBuilder implements IAuthenticati
setCitizenCountryCode(internalAuthData, authProcessData);
// set generic authProcessData to authdata
- for (final Entry<String, Object> el : authProcessData.getGenericSessionDataStorage()
- .entrySet()) {
- if (el.getKey().startsWith(GENERIC_AUTHDATA_IDENTIFIER)) {
- log.trace("Find generic authProcessData {}. Map it directly to authData", el.getKey());
- try {
- internalAuthData.setGenericData(el.getKey(), el.getValue());
-
- } catch (final EaafStorageException e) {
- log.warn("Can NOT set authData with key: {}", el.getKey(), null, e);
-
- }
-
- }
+ authProcessData.getGenericSessionDataStream()
+ .filter(el -> el.getKey().startsWith(GENERIC_AUTHDATA_IDENTIFIER))
+ .forEach(el -> {
+ log.trace("Find generic authProcessData {}. Map it directly to authData", el.getKey());
+ try {
+ internalAuthData.setGenericData(el.getKey(), el.getValue());
- }
+ } catch (final EaafStorageException e) {
+ log.warn("Can NOT set authData with key: {}", el.getKey(), null, e);
+ }
+ });
}
/**
diff --git a/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/auth/data/AuthProcessDataWrapper.java b/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/auth/data/AuthProcessDataWrapper.java
index 8eef4a8e..368652be 100644
--- a/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/auth/data/AuthProcessDataWrapper.java
+++ b/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/auth/data/AuthProcessDataWrapper.java
@@ -22,9 +22,11 @@ package at.gv.egiz.eaaf.core.impl.idp.auth.data;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
-import java.util.HashMap;
import java.util.Map;
+import java.util.Map.Entry;
import java.util.TimeZone;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
import javax.annotation.Nullable;
@@ -264,16 +266,20 @@ public class AuthProcessDataWrapper
* getGenericSessionDataStorage()
*/
@Override
- public Map<String, Object> getGenericSessionDataStorage() {
- final Map<String, Object> result = new HashMap<>();
- for (final Map.Entry<String, Object> el : authProcessData.entrySet()) {
- if (el.getKey().startsWith(GENERIC_PREFIX)) {
- result.put(el.getKey().substring(GENERIC_PREFIX.length()), el.getValue());
- }
-
- }
-
- return result;
+ public Map<String, Object> getGenericSessionDataStorage() {
+ return authProcessData.entrySet().stream()
+ .filter(el -> el.getKey().startsWith(GENERIC_PREFIX))
+ .collect(
+ Collectors.toMap(
+ el -> el.getKey().substring(GENERIC_PREFIX.length()),
+ value -> value.getValue()));
+
+ }
+
+ @Override
+ public Stream<Entry<String, Object>> getGenericSessionDataStream() {
+ return getGenericSessionDataStorage().entrySet().stream();
+
}
/*
diff --git a/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/builder/AttributeBuilderRegistration.java b/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/builder/AttributeBuilderRegistration.java
index 135bd789..b554ad05 100644
--- a/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/builder/AttributeBuilderRegistration.java
+++ b/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/builder/AttributeBuilderRegistration.java
@@ -24,7 +24,7 @@ public class AttributeBuilderRegistration {
log.info("Loading protocol attribut-builder modules:");
if (attributBuilderLoader != null) {
- final Iterator<IAttributeBuilder> moduleLoaderInterator = attributBuilderLoader.iterator();
+ final Iterator<IAttributeBuilder> moduleLoaderInterator = attributBuilderLoader.iterator();
while (moduleLoaderInterator.hasNext()) {
try {
final IAttributeBuilder modul = moduleLoaderInterator.next();
diff --git a/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/controller/tasks/RestartAuthProzessManagement.java b/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/controller/tasks/RestartAuthProzessManagement.java
index 328a25c5..08bf588f 100644
--- a/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/controller/tasks/RestartAuthProzessManagement.java
+++ b/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/controller/tasks/RestartAuthProzessManagement.java
@@ -19,8 +19,6 @@
package at.gv.egiz.eaaf.core.impl.idp.controller.tasks;
-import java.util.Set;
-
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@@ -73,12 +71,9 @@ public class RestartAuthProzessManagement extends AbstractAuthServletTask {
} else {
// create a new execution context and copy all elements to new context
final ExecutionContext newec = new ExecutionContextImpl();
- final Set<String> entries = executionContext.keySet();
- for (final String key : entries) {
- newec.put(key, executionContext.get(key));
-
- }
-
+ executionContext.keySet().stream().forEach(
+ key -> newec.put(key, executionContext.get(key)));
+
log.debug("Select new auth.-process and restart restart process-engine ... ");
// select and create new process instance
diff --git a/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/process/ProcessEngineImpl.java b/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/process/ProcessEngineImpl.java
index 61d2eb28..6e83a201 100644
--- a/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/process/ProcessEngineImpl.java
+++ b/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/process/ProcessEngineImpl.java
@@ -24,7 +24,6 @@ import java.io.Serializable;
import java.text.MessageFormat;
import java.util.HashMap;
import java.util.Map;
-import java.util.Map.Entry;
import java.util.concurrent.ConcurrentHashMap;
import org.apache.commons.collections4.IterableUtils;
@@ -452,11 +451,9 @@ public class ProcessEngineImpl implements ProcessEngine {
final ExecutionContext executionContext =
new ExecutionContextImpl(piStore.getProcessInstanceId());
-
- final Map<String, Serializable> executionContextData = piStore.getExecutionContextData();
- for (final Entry<String, Serializable> el : executionContextData.entrySet()) {
- executionContext.put(el.getKey(), el.getValue());
- }
+
+ piStore.getExecutionContextData().entrySet().stream().forEach(
+ el -> executionContext.put(el.getKey(), el.getValue()));
final ProcessInstance pi = new ProcessInstance(
processDefinitions.get(piStore.getProcessDefinitionId()), executionContext);