Commit fc57b024 authored by Francesco Chicchiriccò's avatar Francesco Chicchiriccò
Browse files

[CRV-226] Adding ServiceType#GLOBAL_SECURITY_FILTER + utility method

parent 8d37b84b
...@@ -20,12 +20,28 @@ import eu.chorevolution.datamodel.ChoreographyService; ...@@ -20,12 +20,28 @@ import eu.chorevolution.datamodel.ChoreographyService;
import eu.chorevolution.datamodel.DeployedService; import eu.chorevolution.datamodel.DeployedService;
import eu.chorevolution.datamodel.ServiceDependency; import eu.chorevolution.datamodel.ServiceDependency;
import eu.chorevolution.datamodel.ServiceType; import eu.chorevolution.datamodel.ServiceType;
import java.util.ArrayList;
import java.util.HashSet; import java.util.HashSet;
import java.util.List;
import java.util.Set; import java.util.Set;
import java.util.stream.Collectors; import java.util.stream.Collectors;
public final class ChorSpecUtils { public final class ChorSpecUtils {
public static List<String> findGlobalSecurityFilterURLs(final Choreography chorSpec) {
List<String> result = new ArrayList<>();
chorSpec.getServiceGroups().forEach((serviceGroup) -> {
result.addAll(serviceGroup.getServices().stream().
filter((ChoreographyService cs) -> cs instanceof DeployedService).
filter((ChoreographyService dep)
-> ((DeployedService) dep).getServiceType() == ServiceType.GLOBAL_SECURITY_FILTER).
map(dep -> ((DeployedService) dep).getUrl()).
collect(Collectors.toList()));
});
return result;
}
public static String findSecurityFilterURL(final Choreography chorSpec, final ChoreographyService service) { public static String findSecurityFilterURL(final Choreography chorSpec, final ChoreographyService service) {
Set<ChoreographyService> candidates = new HashSet<>(); Set<ChoreographyService> candidates = new HashSet<>();
chorSpec.getServiceGroups().forEach((serviceGroup) -> { chorSpec.getServiceGroups().forEach((serviceGroup) -> {
......
...@@ -26,6 +26,7 @@ public enum ServiceType { ...@@ -26,6 +26,7 @@ public enum ServiceType {
BINDING_COMPONENT, BINDING_COMPONENT,
COORDINATION_DELEGATE, COORDINATION_DELEGATE,
PROTOCOL_ADAPTER, PROTOCOL_ADAPTER,
GLOBAL_SECURITY_FILTER,
SECURITY_FILTER, SECURITY_FILTER,
GENERIC_SERVICE GENERIC_SERVICE
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment