diff options
author | Ittay Stern <ittay.stern@att.com> | 2018-12-31 17:21:27 +0200 |
---|---|---|
committer | Ittay Stern <ittay.stern@att.com> | 2019-01-09 20:19:55 +0200 |
commit | 6ad41e3ccd398a2721f41ad61c80b7bb03f7d127 (patch) | |
tree | 3bd672dff83e3218232cd8665680416b7fc26a5d /vid-app-common/src/main/java/org/onap/vid/aai/model/PortDetailsTranslator.java | |
parent | 5ec29ff5e3864f1ba6ecac71f8bffbefa400cf27 (diff) |
Merge from ECOMP's repository
Main Features
--------------
- Async-Instantiation jobs mechanism major update; still WIP (package
`org.onap.vid.job`)
- New features in View/Edit: Activate fabric configuration; show
related networks; soft delete
- Support AAI service-tree traversal (`AAIServiceTree`)
- In-memory cache for SDC models and certain A&AI queries
(`CacheProviderWithLoadingCache`)
- Upgrade TOSCA Parser and add parsing options; fix malformed TOSCA
models
- Resolve Cloud-Owner values for MSO
- Pass X-ONAP headers to MSO
Infrastructure
--------------
- Remove codehaus' jackson mapper; use soley fasterxml 2.9.7
- Surefire invokes both TestNG and JUnit tests
- Support Kotlin source files
- AaiController2 which handles errors in a "Spring manner"
- Inline generated-sources and remove jsonschema2pojo
Quality
--------
- Cumulative bug fixes (A&AI API, UI timeouts, and many more)
- Many Sonar issues cleaned-up
- Some unused classes removed
- Minor changes in vid-automation project, allowing some API
verification to run
Hard Merges
------------
- HTTP Clients (MSO, A&AI, WebConfig, OutgoingRequestHeadersTest)
- Moved `package org.onap.vid.controllers` to `controller`, without
plural -- just to keep semantic sync with ECOMP.
Reference commit in ECOMP: 3d1141625
Issue-ID: VID-378
Change-Id: I9c8d1e74caa41815891d441fc0760bb5f29c5788
Signed-off-by: Ittay Stern <ittay.stern@att.com>
Diffstat (limited to 'vid-app-common/src/main/java/org/onap/vid/aai/model/PortDetailsTranslator.java')
-rw-r--r-- | vid-app-common/src/main/java/org/onap/vid/aai/model/PortDetailsTranslator.java | 42 |
1 files changed, 15 insertions, 27 deletions
diff --git a/vid-app-common/src/main/java/org/onap/vid/aai/model/PortDetailsTranslator.java b/vid-app-common/src/main/java/org/onap/vid/aai/model/PortDetailsTranslator.java index f8980457a..ae74af6fa 100644 --- a/vid-app-common/src/main/java/org/onap/vid/aai/model/PortDetailsTranslator.java +++ b/vid-app-common/src/main/java/org/onap/vid/aai/model/PortDetailsTranslator.java @@ -3,10 +3,7 @@ package org.onap.vid.aai.model; import com.google.common.collect.ImmutableList; import org.onap.vid.aai.AaiResponse; -import org.onap.vid.properties.Features; -import org.togglz.core.manager.FeatureManager; -import javax.inject.Inject; import java.util.LinkedList; import java.util.List; import java.util.Optional; @@ -15,10 +12,7 @@ import java.util.stream.Collectors; public class PortDetailsTranslator { - @Inject - FeatureManager featureManager; - - public static class PortDetailsOk extends PortDetails { + public static class PortDetailsOk implements PortDetails { private final String interfaceId; private final String interfaceName; @@ -43,16 +37,16 @@ public class PortDetailsTranslator { } } - public abstract static class PortDetails { + public interface PortDetails { } - public static class PortDetailsError extends PortDetails { + public static class PortDetailsError implements PortDetails { private final String errorDescription; private final String rawAaiResponse; - public PortDetailsError(String errorDescription, String rawAaiResponse){ - this.errorDescription = errorDescription; - this.rawAaiResponse = rawAaiResponse; + public PortDetailsError(String errorDescription, String rawAaiResponse) { + this.errorDescription = errorDescription; + this.rawAaiResponse = rawAaiResponse; } public String getErrorDescription() { @@ -64,13 +58,13 @@ public class PortDetailsTranslator { } } - public static PortDetails extractPortDetailsFromProperties(Properties properties, String rawPayload){ + public static PortDetails extractPortDetailsFromProperties(Properties properties, String rawPayload) { List<String> errorDescriptions = new LinkedList<>(); describeIfNullOrEmpty("interface-id", properties.getInterfaceId(), errorDescriptions); describeIfNullOrEmpty("interface-name", properties.getInterfaceName(), errorDescriptions); describeIfNullOrEmpty("is-port-mirrored", properties.getIsPortMirrored(), errorDescriptions); - if(errorDescriptions.isEmpty()){ + if (errorDescriptions.isEmpty()) { return new PortDetailsOk(properties.getInterfaceId(), properties.getInterfaceName(), properties.getIsPortMirrored()); } else { return new PortDetailsError(String.join(" ", errorDescriptions), rawPayload); @@ -90,14 +84,14 @@ public class PortDetailsTranslator { final String errorMessage = aaiResponse.getErrorMessage(); return Optional.of(ImmutableList.of(new PortDetailsError( "Got " + aaiResponse.getHttpCode() + " from aai", - errorMessage != null ? errorMessage.toString() : rawPayload) + errorMessage != null ? errorMessage : rawPayload) )); } else { return Optional.empty(); } } - public List<PortDetails> extractPortDetailsInternal(AaiGetPortMirroringSourcePorts aaiGetPortsResponse, String rawPayload){ + public List<PortDetails> extractPortDetailsInternal(CustomQuerySimpleResult aaiGetPortsResponse, String rawPayload) { List<SimpleResult> filteredResult = getFilteredPortList(aaiGetPortsResponse.getResults()); return filteredResult.stream() @@ -107,7 +101,7 @@ public class PortDetailsTranslator { } public List<SimpleResult> getFilteredPortList(List<SimpleResult> results) { - String LINTERFACE = "l-interface"; + final String LINTERFACE = "l-interface"; final Predicate<SimpleResult> ifIsPort = (SimpleResult r) -> LINTERFACE.equals(r.getNodeType()); Predicate<SimpleResult> ifIsSource = getIsSourcePredicate(); @@ -119,18 +113,12 @@ public class PortDetailsTranslator { } private Predicate<SimpleResult> getIsSourcePredicate() { - boolean FLAG_ADVANCED_PORTS_FILTER = featureManager.isActive(Features.FLAG_ADVANCED_PORTS_FILTER); - - if (FLAG_ADVANCED_PORTS_FILTER) { - String PORT_LABEL = "org.onap.relationships.inventory.Source"; - return (SimpleResult r) -> r.getRelatedTo().stream() - .anyMatch(relatedTo -> PORT_LABEL.equalsIgnoreCase(relatedTo.getRelationshipLabel())); - } else { - return (SimpleResult r) -> true; - } + final String PORT_LABEL = "org.onap.relationships.inventory.Source"; + return (SimpleResult r) -> r.getRelatedTo().stream() + .anyMatch(relatedTo -> PORT_LABEL.equalsIgnoreCase(relatedTo.getRelationshipLabel())); } - public List<PortDetails> extractPortDetails(AaiResponse<AaiGetPortMirroringSourcePorts> aaiGetPortsResponse, String rawPayload){ + public List<PortDetails> extractPortDetails(AaiResponse<CustomQuerySimpleResult> aaiGetPortsResponse, String rawPayload) { return extractErrorResponseIfHttpError(aaiGetPortsResponse, rawPayload).orElseGet(() -> extractPortDetailsInternal(aaiGetPortsResponse.getT(), rawPayload)); } |