diff options
166 files changed, 1789 insertions, 6058 deletions
diff --git a/aai-aaf-auth/pom.xml b/aai-aaf-auth/pom.xml deleted file mode 100644 index 4f50e48a..00000000 --- a/aai-aaf-auth/pom.xml +++ /dev/null @@ -1,77 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<project xmlns="http://maven.apache.org/POM/4.0.0" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> - <modelVersion>4.0.0</modelVersion> - <parent> - <groupId>org.onap.aai.aai-common</groupId> - <artifactId>aai-parent</artifactId> - <version>1.14.6-SNAPSHOT</version> - <relativePath>../aai-parent/pom.xml</relativePath> - </parent> - <artifactId>aai-aaf-auth</artifactId> - <name>aai-aaf-auth</name> - <packaging>jar</packaging> - <dependencies> - <dependency> - <groupId>org.onap.aai.aai-common</groupId> - <artifactId>aai-els-onap-logging</artifactId> - </dependency> - <dependency> - <groupId>org.onap.aaf.authz</groupId> - <artifactId>aaf-cadi-core</artifactId> - </dependency> - <dependency> - <groupId>org.onap.aaf.authz</groupId> - <artifactId>aaf-cadi-aaf</artifactId> - </dependency> - <dependency> - <groupId>org.easymock</groupId> - <artifactId>easymock</artifactId> - <scope>test</scope> - </dependency> - <dependency> - <groupId>org.springframework</groupId> - <artifactId>spring-web</artifactId> - </dependency> - <dependency> - <groupId>org.springframework</groupId> - <artifactId>spring-context</artifactId> - </dependency> - <dependency> - <groupId>org.springframework.boot</groupId> - <artifactId>spring-boot-starter-web</artifactId> - <exclusions> - <exclusion> - <groupId>org.springframework.boot</groupId> - <artifactId>spring-boot-starter-tomcat</artifactId> - </exclusion> - </exclusions> - </dependency> - <dependency> - <groupId>com.google.code.gson</groupId> - <artifactId>gson</artifactId> - </dependency> - <dependency> - <groupId>commons-io</groupId> - <artifactId>commons-io</artifactId> - </dependency> - <dependency> - <groupId>junit</groupId> - <artifactId>junit</artifactId> - <scope>test</scope> - </dependency> - <!-- TODO: Migrate tests to junit 5 and remove this dependency --> - <dependency> - <groupId>org.junit.vintage</groupId> - <artifactId>junit-vintage-engine</artifactId> - <scope>test</scope> - <exclusions> - <exclusion> - <groupId>org.hamcrest</groupId> - <artifactId>hamcrest-core</artifactId> - </exclusion> - </exclusions> - </dependency> - </dependencies> -</project> diff --git a/aai-aaf-auth/src/main/java/org/onap/aai/aaf/auth/AAIAuthCore.java b/aai-aaf-auth/src/main/java/org/onap/aai/aaf/auth/AAIAuthCore.java deleted file mode 100644 index 72e2295e..00000000 --- a/aai-aaf-auth/src/main/java/org/onap/aai/aaf/auth/AAIAuthCore.java +++ /dev/null @@ -1,389 +0,0 @@ -/** - * ============LICENSE_START======================================================= - * org.onap.aai - * ================================================================================ - * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.aai.aaf.auth; - -import com.fasterxml.jackson.core.JsonProcessingException; -import com.google.gson.JsonArray; -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; -import com.google.gson.JsonParser; - -import java.io.File; -import java.io.FileNotFoundException; -import java.io.UnsupportedEncodingException; -import java.nio.file.Files; -import java.nio.file.Paths; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Base64; -import java.util.Date; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Optional; -import java.util.Set; -import java.util.Timer; -import java.util.TimerTask; -import java.util.UUID; -import java.util.regex.Matcher; -import java.util.regex.Pattern; -import java.util.stream.Collectors; - -import org.eclipse.jetty.util.security.Password; -import org.onap.aai.aaf.auth.exceptions.AAIUnrecognizedFunctionException; -import org.onap.aai.logging.ErrorLogHelper; -import org.onap.aai.util.AAIConfig; -import org.onap.aai.util.AAIConstants; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * The Class AAIAuthCore. - */ -public final class AAIAuthCore { - - private static final Logger LOGGER = LoggerFactory.getLogger(AAIAuthCore.class); - - private static final String ERROR_CODE_AAI_4001 = "AAI_4001"; - - private String globalAuthFileName = AAIConstants.AAI_AUTH_CONFIG_FILENAME; - - private final Pattern authPolicyPattern; - private final Set<String> validFunctions = new HashSet<>(); - private Map<String, AAIUser> users; - private boolean timerSet = false; - private Timer timer = null; - - private String basePath; - - /** - * Instantiates a new AAI auth core. - */ - public AAIAuthCore(String basePath) { - this(basePath, AAIConstants.AAI_AUTH_CONFIG_FILENAME); - } - - public AAIAuthCore(String basePath, String filename) { - this.basePath = basePath; - this.globalAuthFileName = filename; - authPolicyPattern = Pattern.compile("^" + this.basePath + "/v\\d+/([\\w\\-]*)"); - init(); - } - - public AAIAuthCore(String basePath, String filename, String pattern) { - this.basePath = basePath; - this.globalAuthFileName = filename; - authPolicyPattern = Pattern.compile(pattern); - init(); - } - - /** - * Inits the. - */ - private synchronized void init() { - - LOGGER.debug("Initializing Auth Policy Config"); - - reloadUsers(); - - /* - * this timer code is setting up a recurring task that checks if the - * auth config file has been updated and reloads the users if so to get - * the most up to date info (that update check logic is within - * FileWatcher) - * - * the timing this method uses is coarser than the frequency of requests - * AI&I gets so we're looking at better ways of doing this (TODO) - */ - TimerTask task = new FileWatcher(new File(globalAuthFileName)) { - @Override - protected void onChange(File file) { - reloadUsers(); - } - }; - - if (!timerSet) { - timerSet = true; - timer = new Timer(); - - // repeat the check every second - timer.schedule(task, new Date(), 10000); - } - LOGGER.debug("Static Initializiation complete"); - } - - /** - * Cleanup. - */ - // just ends the auth config file update checking timer - public void cleanup() { - timer.cancel(); - } - - /** - * Reload users. - */ - /* - * this essentially takes the data file, which is organized role-first with - * users under each role and converts it to data organized user-first with - * each user containing their role with its associated allowed functions - * this data stored in the class field users - */ - private synchronized void reloadUsers() { - - Map<String, AAIUser> tempUsers = new HashMap<>(); - - try { - LOGGER.debug("Reading from " + globalAuthFileName); - String authFile = new String(Files.readAllBytes(Paths.get(globalAuthFileName))); - - JsonObject authObject = JsonParser.parseString(authFile).getAsJsonObject(); - if (authObject.has("roles")) { - JsonArray roles = authObject.getAsJsonArray("roles"); - for (JsonElement role : roles) { - if (role.isJsonObject()) { - JsonObject roleObject = role.getAsJsonObject(); - String roleName = roleObject.get("name").getAsString(); - Map<String, Boolean> usrs = this.getUsernamesFromRole(roleObject); - List<String> aaiFunctions = this.getAAIFunctions(roleObject); - - usrs.forEach((key, value) -> { - final AAIUser au = tempUsers.getOrDefault(key, new AAIUser(key, value)); - au.addRole(roleName); - aaiFunctions.forEach(f -> { - List<String> httpMethods = this.getRoleHttpMethods(f, roleObject); - httpMethods.forEach(hm -> au.setUserAccess(f, hm)); - this.validFunctions.add(f); - }); - - tempUsers.put(key, au); - - }); - } - } - if (!tempUsers.isEmpty()) { - users = tempUsers; - } - } - } catch (FileNotFoundException e) { - ErrorLogHelper.logError(ERROR_CODE_AAI_4001, globalAuthFileName + ". Exception: " + e); - } catch (JsonProcessingException e) { - ErrorLogHelper.logError(ERROR_CODE_AAI_4001, globalAuthFileName + ". Not valid JSON: " + e); - } catch (Exception e) { - ErrorLogHelper.logError(ERROR_CODE_AAI_4001, globalAuthFileName + ". Exception caught: " + e); - } - } - - private List<String> getRoleHttpMethods(String aaiFunctionName, JsonObject roleObject) { - List<String> httpMethods = new ArrayList<>(); - - JsonArray ja = roleObject.getAsJsonArray("functions"); - for (JsonElement je : ja) { - if (je.isJsonObject() && je.getAsJsonObject().has("name") - && je.getAsJsonObject().get("name").getAsString().equals(aaiFunctionName)) { - JsonArray jaMeth = je.getAsJsonObject().getAsJsonArray("methods"); - for (JsonElement jeMeth : jaMeth) { - if (jeMeth.isJsonObject() && jeMeth.getAsJsonObject().has("name")) { - httpMethods.add(jeMeth.getAsJsonObject().get("name").getAsString()); - } - } - } - } - - return httpMethods; - } - - private List<String> getAAIFunctions(JsonObject roleObject) { - List<String> aaiFunctions = new ArrayList<>(); - - JsonArray ja = roleObject.getAsJsonArray("functions"); - for (JsonElement je : ja) { - if (je.isJsonObject() && je.getAsJsonObject().has("name")) { - aaiFunctions.add(je.getAsJsonObject().get("name").getAsString()); - } - } - - return aaiFunctions; - } - - private Map<String, Boolean> getUsernamesFromRole(JsonObject roleObject) throws UnsupportedEncodingException { - Map<String, Boolean> usernames = new HashMap<>(); - - JsonArray uja = roleObject.getAsJsonArray("users"); - for (JsonElement je : uja) { - if (je.isJsonObject()) { - if (je.getAsJsonObject().has("username")) { - if (je.getAsJsonObject().has("is-wildcard-id")) { - usernames.put(je.getAsJsonObject().get("username").getAsString().toLowerCase(), - je.getAsJsonObject().get("is-wildcard-id").getAsBoolean()); - } else { - usernames.put(je.getAsJsonObject().get("username").getAsString().toLowerCase(), false); - } - } else if (je.getAsJsonObject().has("user")) { - String auth = je.getAsJsonObject().get("user").getAsString() + ":" - + Password.deobfuscate(je.getAsJsonObject().get("pass").getAsString()); - String authorizationCode = new String(Base64.getEncoder().encode(auth.getBytes("utf-8"))); - usernames.put(authorizationCode, false); - } - } - } - - return usernames; - } - - public String getAuthPolicyFunctName(String uri) { - String authPolicyFunctionName = ""; - if (uri.startsWith(basePath + "/search")) { - authPolicyFunctionName = "search"; - } else if (uri.startsWith(basePath + "/recents")) { - authPolicyFunctionName = "recents"; - } else if (uri.startsWith(basePath + "/cq2gremlin")) { - authPolicyFunctionName = "cq2gremlin"; - } else if (uri.startsWith(basePath + "/cq2gremlintest")) { - authPolicyFunctionName = "cq2gremlintest"; - } else if (uri.startsWith(basePath + "/util/echo")) { - authPolicyFunctionName = "util"; - } else if (uri.startsWith(basePath + "/tools")) { - authPolicyFunctionName = "tools"; - } else { - Matcher match = authPolicyPattern.matcher(uri); - if (match.find()) { - authPolicyFunctionName = match.group(1); - } - } - return authPolicyFunctionName; - } - - /** - * for backwards compatibility - * - * @param username - * @param uri - * @param httpMethod - * @param haProxyUser - * @return - * @throws AAIUnrecognizedFunctionException - */ - public boolean authorize(String username, String uri, String httpMethod, String haProxyUser) - throws AAIUnrecognizedFunctionException { - return authorize(username, uri, httpMethod, haProxyUser, null); - } - - /** - * - * @param username - * @param uri - * @param httpMethod - * @param haProxyUser - * @param issuer issuer of the cert - * @return - * @throws AAIUnrecognizedFunctionException - */ - public boolean authorize(String username, String uri, String httpMethod, String haProxyUser, String issuer) - throws AAIUnrecognizedFunctionException { - String aaiMethod = this.getAuthPolicyFunctName(uri); - if (!this.validFunctions.contains(aaiMethod) && !("info".equalsIgnoreCase(aaiMethod))) { - throw new AAIUnrecognizedFunctionException(aaiMethod); - } - boolean wildcardCheck = isWildcardIssuer(issuer); - boolean authorized; - LOGGER.debug( - "Authorizing the user for the request cert {}, haproxy header {}, aai method {}, httpMethod {}, cert issuer {}", - username, haProxyUser, aaiMethod, httpMethod, issuer); - Optional<AAIUser> oau = this.getUser(username, wildcardCheck); - if (oau.isPresent()) { - AAIUser au = oau.get(); - if (au.hasRole("HAProxy")) { - LOGGER.debug("User has HAProxy role"); - if ("GET".equalsIgnoreCase(httpMethod) && "util".equalsIgnoreCase(aaiMethod) && haProxyUser.isEmpty()) { - LOGGER.debug("Authorized user has HAProxy role with echo request"); - authorized = this.authorize(au, aaiMethod, httpMethod); - } else { - authorized = this.authorize(haProxyUser, uri, httpMethod, "", issuer); - } - } else { - LOGGER.debug("User doesn't have HAProxy role so assuming its a regular client"); - authorized = this.authorize(au, aaiMethod, httpMethod); - } - } else { - LOGGER.debug("User not found: " + username + " on function " + aaiMethod + " request type " + httpMethod); - authorized = false; - } - - return authorized; - } - - private boolean isWildcardIssuer(String issuer) { - if (issuer != null && !issuer.isEmpty()) { - List<String> validIssuers = Arrays - .asList(AAIConfig.get("aaf.valid.issuer.wildcard", UUID.randomUUID().toString()).split("\\|")); - for (String validIssuer : validIssuers) { - if (issuer.contains(validIssuer)) { - return true; - } - } - } - return false; - } - - /** - * returns aai user either matching the username or containing the wildcard. - * - * @param username - * @return - */ - public Optional<AAIUser> getUser(String username, boolean wildcardCheck) { - if (users.containsKey(username)) { - return Optional.of(users.get(username)); - } else if (wildcardCheck) { - List<AAIUser> laus = - users.entrySet().stream().filter(e -> e.getValue().isWildcard() && username.contains(e.getKey())) - .map(Map.Entry::getValue).collect(Collectors.toList()); - if (!laus.isEmpty()) { - return Optional.of(laus.get(0)); - } - } - return Optional.empty(); - } - - /** - * - * @param aaiUser - * aai user with the username - * @param aaiMethod - * aai function the authorization is required on - * @param httpMethod - * http action user is attempting - * @return true, if successful - */ - private boolean authorize(AAIUser aaiUser, String aaiMethod, String httpMethod) { - if ("info".equalsIgnoreCase(aaiMethod) || aaiUser.hasAccess(aaiMethod, httpMethod)) { - LOGGER.debug("AUTH ACCEPTED: " + aaiUser.getUsername() + " on function " + aaiMethod + " request type " - + httpMethod); - return true; - } else { - LOGGER.debug("AUTH FAILED: " + aaiUser.getUsername() + " on function " + aaiMethod + " request type " - + httpMethod); - return false; - } - } -} diff --git a/aai-aaf-auth/src/main/java/org/onap/aai/aaf/auth/AAIUser.java b/aai-aaf-auth/src/main/java/org/onap/aai/aaf/auth/AAIUser.java deleted file mode 100644 index 4512adb0..00000000 --- a/aai-aaf-auth/src/main/java/org/onap/aai/aaf/auth/AAIUser.java +++ /dev/null @@ -1,81 +0,0 @@ -/** - * ============LICENSE_START======================================================= - * org.onap.aai - * ================================================================================ - * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Modifications Copyright © 2018 IBM. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.aai.aaf.auth; - -import java.util.*; - -public class AAIUser { - - private String username; - - private boolean isWildcard = false; - private Set<String> roles; - private Map<String, Set<String>> aaiFunctionToHttpMethod; - - public AAIUser(String username) { - this(username, false); - } - - public AAIUser(String username, boolean isWildcard) { - this.username = username; - this.roles = new HashSet<>(); - this.aaiFunctionToHttpMethod = new HashMap<>(); - this.isWildcard = isWildcard; - } - - public boolean isWildcard() { - return isWildcard; - } - - public String getUsername() { - return username; - } - - public void addRole(String role) { - this.roles.add(role); - } - - public boolean hasRole(String role) { - return this.roles.contains(role); - } - - public void setUserAccess(String aaiMethod, String... httpMethods) { - for (String httpMethod : httpMethods) { - this.addUserAccess(aaiMethod, httpMethod); - } - } - - private void addUserAccess(String aaiMethod, String httpMethod) { - Set<String> httpMethods = new HashSet<>(); - if (this.aaiFunctionToHttpMethod.containsKey(aaiMethod)) { - httpMethods = this.aaiFunctionToHttpMethod.get(aaiMethod); - } - httpMethods.add(httpMethod); - this.aaiFunctionToHttpMethod.put(aaiMethod, httpMethods); - } - - public boolean hasAccess(String aaiMethod, String httpMethod) { - return this.aaiFunctionToHttpMethod.getOrDefault(aaiMethod, Collections.emptySet()).contains(httpMethod); - } - -} diff --git a/aai-aaf-auth/src/main/java/org/onap/aai/aaf/auth/AafRequestFilter.java b/aai-aaf-auth/src/main/java/org/onap/aai/aaf/auth/AafRequestFilter.java deleted file mode 100644 index 2c8aaf28..00000000 --- a/aai-aaf-auth/src/main/java/org/onap/aai/aaf/auth/AafRequestFilter.java +++ /dev/null @@ -1,115 +0,0 @@ -/** - * ============LICENSE_START======================================================= - * org.onap.aai - * ================================================================================ - * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.aai.aaf.auth; - -import static org.onap.aai.aaf.auth.ResponseFormatter.errorResponse; - -import java.io.IOException; -import java.util.Enumeration; -import java.util.List; -import java.util.Properties; - -import javax.servlet.FilterChain; -import javax.servlet.ServletException; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -import org.onap.aaf.cadi.filter.CadiFilter; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * The Class AafRequestFilter provides common auth filter methods - */ -public class AafRequestFilter { - - private static final Logger LOGGER = LoggerFactory.getLogger(AafRequestFilter.class); - - public static void authenticationFilter(HttpServletRequest request, HttpServletResponse response, - FilterChain filterChain, CadiFilter cadiFilter, Properties props, String userChainPattern) - throws IOException, ServletException { - if (!request.getRequestURI().matches("^.*/util/echo$")) { - - List<String> cadiConfiguredIssuers = CertUtil.getCadiCertIssuers(props); - String issuer = CertUtil.getCertIssuer(request); - if (issuer == null || issuer.isEmpty()) { - errorResponse(request, response); - return; - } - issuer = issuer.replaceAll("\\s+", "").toUpperCase(); - - if (cadiConfiguredIssuers.contains(issuer)) { - LOGGER.debug("authenticationFilter CADI issuer " + issuer); - if (CertUtil.isHaProxy(request)) { - // get the end user/client mechid and use it in the user chain header value - String user = CertUtil.getMechId(request); - LOGGER.debug("authenticationFilter haProxy sent end user/mechid " + user); - if (user == null || user.isEmpty()) { - errorResponse(request, response); - return; - } - AafRequestWrapper reqWrapper = new AafRequestWrapper(request); - String userChainHdr = CertUtil.buildUserChainHeader(user, userChainPattern); - LOGGER.debug("User chain header value: " + userChainHdr); - reqWrapper.putHeader(CertUtil.AAF_USER_CHAIN_HDR, userChainHdr); - cadiFilter.doFilter(reqWrapper, response, filterChain); - } else { - cadiFilter.doFilter(request, response, filterChain); - } - if (response.getStatus() == 401 || response.getStatus() == 403) { - LOGGER.debug("authenticationFilter failed CADI authentication"); - errorResponse(request, response); - return; - } - } else { - filterChain.doFilter(request, response); - } - } else { - filterChain.doFilter(request, response); - } - } - - public static void authorizationFilter(HttpServletRequest request, HttpServletResponse response, - FilterChain filterChain, String permission, Properties props) throws IOException, ServletException { - if (request.getRequestURI().matches("^.*/util/echo$")) { - filterChain.doFilter(request, response); - } - List<String> cadiConfiguredIssuers = CertUtil.getCadiCertIssuers(props); - String issuer = CertUtil.getCertIssuer(request); - if (issuer == null || issuer.isEmpty()) { - errorResponse(request, response); - return; - } - issuer = issuer.replaceAll("\\s+", "").toUpperCase(); - Enumeration<String> hdrs = request.getHeaders(CertUtil.AAF_USER_CHAIN_HDR); - while (hdrs.hasMoreElements()) { - String headerValue = (String) hdrs.nextElement(); - LOGGER.debug("authorizationFilter user chain headerValue=" + headerValue); - } - if ((cadiConfiguredIssuers.contains(issuer)) && (!request.isUserInRole(permission))) { - LOGGER.debug( - "authorizationFilter failed CADI authorization issuer=" + issuer + " permission=" + permission); - errorResponse(request, response); - } else { - filterChain.doFilter(request, response); - } - } -} diff --git a/aai-aaf-auth/src/main/java/org/onap/aai/aaf/auth/AafRequestWrapper.java b/aai-aaf-auth/src/main/java/org/onap/aai/aaf/auth/AafRequestWrapper.java deleted file mode 100644 index f74ed3e4..00000000 --- a/aai-aaf-auth/src/main/java/org/onap/aai/aaf/auth/AafRequestWrapper.java +++ /dev/null @@ -1,79 +0,0 @@ -/** - * ============LICENSE_START======================================================= - * org.onap.aai - * ================================================================================ - * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.aai.aaf.auth; - -import java.util.*; - -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletRequestWrapper; - -/** - * The AafRequestWrapper sets the user in the principal name - */ -public class AafRequestWrapper extends HttpServletRequestWrapper { - - private final Map<String, String> customHeaders; - - public AafRequestWrapper(HttpServletRequest request) { - super(request); - this.customHeaders = new HashMap<String, String>(); - } - - public void putHeader(String name, String value) { - this.customHeaders.put(name, value); - } - - @Override - public String getHeader(String name) { - String headerValue = customHeaders.get(name); - if (headerValue != null) { - return headerValue; - } - return (((HttpServletRequest) getRequest()).getHeader(name)); - } - - @Override - public Enumeration<String> getHeaderNames() { - Set<String> nameSet = new HashSet<String>(customHeaders.keySet()); - - Enumeration<String> e = ((HttpServletRequest) getRequest()).getHeaderNames(); - while (e.hasMoreElements()) { - String headerName = e.nextElement(); - nameSet.add(headerName); - } - return Collections.enumeration(nameSet); - } - - @Override - public Enumeration<String> getHeaders(String name) { - String myHeaderValue = customHeaders.get(name); - Set<String> headerValueSet = new HashSet<String>(); - if (myHeaderValue != null) { - headerValueSet.add(myHeaderValue); - } - Enumeration<String> e = ((HttpServletRequest) getRequest()).getHeaders(name); - while (e.hasMoreElements()) { - String headerValue = e.nextElement(); - headerValueSet.add(headerValue); - } - return Collections.enumeration(headerValueSet); - } -} diff --git a/aai-aaf-auth/src/main/java/org/onap/aai/aaf/auth/CertUtil.java b/aai-aaf-auth/src/main/java/org/onap/aai/aaf/auth/CertUtil.java deleted file mode 100644 index 139e46c8..00000000 --- a/aai-aaf-auth/src/main/java/org/onap/aai/aaf/auth/CertUtil.java +++ /dev/null @@ -1,164 +0,0 @@ -/** - * ============LICENSE_START======================================================= - * org.onap.aai - * ================================================================================ - * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.aai.aaf.auth; - -import java.io.FileInputStream; -import java.io.IOException; -import java.security.cert.X509Certificate; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.List; -import java.util.Objects; -import java.util.Properties; -import java.util.stream.Collectors; - -import javax.servlet.http.HttpServletRequest; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * The Class CertUtil provides cert related utility methods. - */ -public class CertUtil { - public static final String DEFAULT_CADI_ISSUERS = "CN=ATT AAF CADI Test Issuing " - + "CA 01, OU=CSO, O=ATT, C=US:CN=ATT AAF CADI Test Issuing CA 02, OU=CSO, O=ATT, C=US"; - public static final String CADI_PROP_FILES = "cadi_prop_files"; - public static final String CADI_ISSUERS_PROP_NAME = "cadi_x509_issuers"; - public static final String CADI_ISSUERS_SEPARATOR = ":"; - public static final String AAI_SSL_CLIENT_OU_HDR = "X-AAI-SSL-Client-OU"; - public static final String AAI_SSL_ISSUER_HDR = "X-AAI-SSL-Issuer"; - public static final String AAI_SSL_CLIENT_CN_HDR = "X-AAI-SSL-Client-CN"; - public static final String AAI_SSL_CLIENT_O_HDR = "X-AAI-SSL-Client-O"; - public static final String AAI_SSL_CLIENT_L_HDR = "X-AAI-SSL-Client-L"; - public static final String AAI_SSL_CLIENT_ST_HDR = "X-AAI-SSL-Client-ST"; - public static final String AAI_SSL_CLIENT_C_HDR = "X-AAI-SSL-Client-C"; - public static final String AAF_USER_CHAIN_HDR = "USER_CHAIN"; - public static final String AAF_ID = "<AAF-ID>"; - private static final Logger LOGGER = LoggerFactory.getLogger(CertUtil.class); - - public static String getAaiSslClientOuHeader(HttpServletRequest hsr) { - return (hsr.getHeader(AAI_SSL_CLIENT_OU_HDR)); - } - - public static boolean isHaProxy(HttpServletRequest hsr) { - - String haProxyUser = ""; - if (Objects.isNull(hsr.getHeader(AAI_SSL_CLIENT_CN_HDR)) || Objects.isNull(hsr.getHeader(AAI_SSL_CLIENT_OU_HDR)) - || Objects.isNull(hsr.getHeader(AAI_SSL_CLIENT_O_HDR)) - || Objects.isNull(hsr.getHeader(AAI_SSL_CLIENT_L_HDR)) - || Objects.isNull(hsr.getHeader(AAI_SSL_CLIENT_ST_HDR)) - || Objects.isNull(hsr.getHeader(AAI_SSL_CLIENT_C_HDR))) { - haProxyUser = ""; - } else { - haProxyUser = String.format("CN=%s, OU=%s, O=\"%s\", L=%s, ST=%s, C=%s", - Objects.toString(hsr.getHeader(AAI_SSL_CLIENT_CN_HDR), ""), - Objects.toString(hsr.getHeader(AAI_SSL_CLIENT_OU_HDR), ""), - Objects.toString(hsr.getHeader(AAI_SSL_CLIENT_O_HDR), ""), - Objects.toString(hsr.getHeader(AAI_SSL_CLIENT_L_HDR), ""), - Objects.toString(hsr.getHeader(AAI_SSL_CLIENT_ST_HDR), ""), - Objects.toString(hsr.getHeader(AAI_SSL_CLIENT_C_HDR), "")).toLowerCase(); - } - if (!haProxyUser.isEmpty()) { - LOGGER.debug("isHaProxy haProxyUser=" + haProxyUser); - return true; - } - LOGGER.debug("isHaProxy haProxyUser not found"); - return false; - } - - public static String getMechId(HttpServletRequest hsr) { - String mechId = null; - String ou = getAaiSslClientOuHeader(hsr); - if ((ou != null) && (!ou.isEmpty())) { - String[] parts = ou.split(CADI_ISSUERS_SEPARATOR); - if (parts != null && parts.length >= 1) { - mechId = parts[0]; - } - } - LOGGER.debug("getMechId mechId=" + mechId); - return (mechId); - } - - public static String getCertIssuer(HttpServletRequest hsr) { - String issuer = hsr.getHeader(AAI_SSL_ISSUER_HDR); - if (issuer != null && !issuer.isEmpty()) { - LOGGER.debug("getCertIssuer issuer from header " + AAI_SSL_ISSUER_HDR + " " + issuer); - // the haproxy header replaces the ', ' with '/' and reverses on the '/' need to undo that. - List<String> broken = Arrays.asList(issuer.split("/")); - broken = broken.stream().filter(s -> !s.isEmpty()).collect(Collectors.toList()); - Collections.reverse(broken); - issuer = String.join(", ", broken); - } else { - if (hsr.getAttribute("javax.servlet.request.cipher_suite") != null) { - X509Certificate[] certChain = - (X509Certificate[]) hsr.getAttribute("javax.servlet.request.X509Certificate"); - if (certChain != null && certChain.length > 0) { - X509Certificate clientCert = certChain[0]; - issuer = clientCert.getIssuerX500Principal().getName(); - LOGGER.debug("getCertIssuer issuer from client cert " + issuer); - } - } - } - return issuer; - } - - public static List<String> getCadiCertIssuers(Properties cadiProperties) { - - List<String> defaultList = new ArrayList<>(); - List<String> resultList = new ArrayList<String>(); - - String[] cadiIssuers = DEFAULT_CADI_ISSUERS.split(CADI_ISSUERS_SEPARATOR); - for (String issuer : cadiIssuers) { - defaultList.add(issuer.replaceAll("\\s+", "").toUpperCase()); - } - try { - String certPropFileName = cadiProperties.getProperty(CADI_PROP_FILES); - String configuredIssuers = DEFAULT_CADI_ISSUERS; - Properties certProperties = new Properties(); - if (certPropFileName != null) { - try (FileInputStream fis = new FileInputStream(certPropFileName)) { - certProperties.load(fis); - } - configuredIssuers = certProperties.getProperty(CADI_ISSUERS_PROP_NAME); - } - if ((configuredIssuers != null) && (!configuredIssuers.isEmpty())) { - cadiIssuers = configuredIssuers.split(CADI_ISSUERS_SEPARATOR); - for (String issuer : cadiIssuers) { - resultList.add(issuer.replaceAll("\\s+", "").toUpperCase()); - } - } - } catch (IOException ioe) { - return (defaultList); - } - if (resultList.isEmpty()) { - return defaultList; - } - LOGGER.debug("getCadiCertIssuers " + resultList.toString()); - return resultList; - } - - public static String buildUserChainHeader(String user, String userChainPattern) { - // aaf.userchain.pattern=<AAF-ID>:${aaf.userchain.service.reference}:${aaf.userchain.auth.type}:AS - return (userChainPattern.replaceAll(AAF_ID, user)); - } -} diff --git a/aai-aaf-auth/src/main/java/org/onap/aai/aaf/auth/FileWatcher.java b/aai-aaf-auth/src/main/java/org/onap/aai/aaf/auth/FileWatcher.java deleted file mode 100644 index 45331ed9..00000000 --- a/aai-aaf-auth/src/main/java/org/onap/aai/aaf/auth/FileWatcher.java +++ /dev/null @@ -1,60 +0,0 @@ -/** - * ============LICENSE_START======================================================= - * org.onap.aai - * ================================================================================ - * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.aai.aaf.auth; - -import java.io.File; -import java.util.TimerTask; - -public abstract class FileWatcher extends TimerTask { - private long timeStamp; - private File file; - - /** - * Instantiates a new file watcher. - * - * @param file the file - */ - public FileWatcher(File file) { - this.file = file; - this.timeStamp = file.lastModified(); - } - - /** - * runs a timer task - * - * @see TimerTask#run - */ - public final void run() { - long timeStamp = file.lastModified(); - - if ((timeStamp - this.timeStamp) > 500) { - this.timeStamp = timeStamp; - onChange(file); - } - } - - /** - * On change. - * - * @param file the file - */ - protected abstract void onChange(File file); -} diff --git a/aai-aaf-auth/src/main/java/org/onap/aai/aaf/auth/ResponseFormatter.java b/aai-aaf-auth/src/main/java/org/onap/aai/aaf/auth/ResponseFormatter.java deleted file mode 100644 index 1748ed15..00000000 --- a/aai-aaf-auth/src/main/java/org/onap/aai/aaf/auth/ResponseFormatter.java +++ /dev/null @@ -1,72 +0,0 @@ -/** - * ============LICENSE_START======================================================= - * org.onap.aai - * ================================================================================ - * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.aai.aaf.auth; - -import java.io.IOException; -import java.util.ArrayList; -import java.util.Collections; - -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import javax.ws.rs.core.MediaType; - -import org.onap.aai.exceptions.AAIException; -import org.onap.aai.logging.ErrorLogHelper; - -public class ResponseFormatter { - - private static final String ACCEPT_HEADER = "accept"; - private static final String CONTENT_TYPE_HEADER = "Content-Type"; - - private ResponseFormatter() { - throw new IllegalStateException("Utility class"); - } - - public static void errorResponse(HttpServletRequest request, HttpServletResponse response) throws IOException { - errorResponse(new AAIException("AAI_3300"), request, response); - } - - public static void errorResponse(AAIException exception, HttpServletRequest request, HttpServletResponse response) - throws IOException { - - if (response.isCommitted()) { - return; - } - - String accept = request.getHeader(ACCEPT_HEADER); - switch (accept != null ? accept : MediaType.APPLICATION_XML) { - case MediaType.APPLICATION_JSON: - response.setHeader(CONTENT_TYPE_HEADER, MediaType.APPLICATION_JSON); - break; - case MediaType.APPLICATION_XML: - default: - response.setHeader(CONTENT_TYPE_HEADER, MediaType.APPLICATION_XML); - } - - response.setStatus(exception.getErrorObject().getHTTPResponseCode().getStatusCode()); - response.resetBuffer(); - - String resp = ErrorLogHelper.getRESTAPIErrorResponse(Collections.singletonList(MediaType.valueOf(accept)), - exception, new ArrayList<>()); - response.getOutputStream().print(resp); - response.flushBuffer(); - } -} diff --git a/aai-aaf-auth/src/main/java/org/onap/aai/aaf/auth/exceptions/AAIUnrecognizedFunctionException.java b/aai-aaf-auth/src/main/java/org/onap/aai/aaf/auth/exceptions/AAIUnrecognizedFunctionException.java deleted file mode 100644 index c6a97ac5..00000000 --- a/aai-aaf-auth/src/main/java/org/onap/aai/aaf/auth/exceptions/AAIUnrecognizedFunctionException.java +++ /dev/null @@ -1,46 +0,0 @@ -/** - * ============LICENSE_START======================================================= - * org.onap.aai - * ================================================================================ - * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Modifications Copyright © 2018 IBM. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.aai.aaf.auth.exceptions; - -import org.onap.aai.exceptions.AAIException; - -public class AAIUnrecognizedFunctionException extends AAIException { - - private static final String AAI_3012 = "AAI_3012"; - private static final long serialVersionUID = 3297064867724071290L; - - public AAIUnrecognizedFunctionException() { - } - - public AAIUnrecognizedFunctionException(String message) { - super(AAI_3012, message); - } - - public AAIUnrecognizedFunctionException(Throwable cause) { - super(AAI_3012, cause); - } - - public AAIUnrecognizedFunctionException(String message, Throwable cause) { - super(AAI_3012, cause, message); - } -} diff --git a/aai-aaf-auth/src/main/java/org/onap/aai/aaf/filters/AafAuthorizationFilter.java b/aai-aaf-auth/src/main/java/org/onap/aai/aaf/filters/AafAuthorizationFilter.java deleted file mode 100644 index fb7a58e6..00000000 --- a/aai-aaf-auth/src/main/java/org/onap/aai/aaf/filters/AafAuthorizationFilter.java +++ /dev/null @@ -1,118 +0,0 @@ -/** - * ============LICENSE_START======================================================= - * org.onap.aai - * ================================================================================ - * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * <p> - * http://www.apache.org/licenses/LICENSE-2.0 - * <p> - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.aai.aaf.filters; - -import java.io.IOException; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.stream.Collectors; - -import javax.servlet.FilterChain; -import javax.servlet.ServletException; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -import org.onap.aai.aaf.auth.ResponseFormatter; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.boot.web.servlet.filter.OrderedRequestContextFilter; -import org.springframework.context.annotation.Profile; -import org.springframework.context.annotation.PropertySource; -import org.springframework.stereotype.Component; - -/** - * AAF authorization filter - */ - -@Component -@Profile(AafProfiles.AAF_AUTHENTICATION) -@PropertySource(value = "file:${CONFIG_HOME}/aaf/permissions.properties", ignoreResourceNotFound = true) -@PropertySource(value = "file:${server.local.startpath}/aaf/permissions.properties", ignoreResourceNotFound = true) -public class AafAuthorizationFilter extends OrderedRequestContextFilter { - - private static final String ADVANCED = "advanced"; - private static final String BASIC = "basic"; - - private final String type; - private final String instance; - - private GremlinFilter gremlinFilter; - - private List<String> advancedKeywordsList; - - public AafAuthorizationFilter(GremlinFilter gremlinFilter, @Value("${permission.type}") String type, - @Value("${permission.instance}") String instance, - @Value("${advanced.keywords.list:}") String advancedKeys) { - this.gremlinFilter = gremlinFilter; - this.type = type; - this.instance = instance; - if (advancedKeys == null || advancedKeys.isEmpty()) { - this.advancedKeywordsList = new ArrayList<>(); - } else { - this.advancedKeywordsList = Arrays.stream(advancedKeys.split(",")).collect(Collectors.toList()); - } - this.setOrder(FilterPriority.AAF_AUTHORIZATION.getPriority()); - } - - @Override - protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) - throws IOException, ServletException { - if (request.getRequestURI().matches("^.*/util/echo$")) { - filterChain.doFilter(request, response); - } - if (request.getRequestURI().endsWith("/query")) { - gremlinFilter.doBasicAuthFilter(request, response, filterChain); - } else { - - String permission = null; - - if (advancedKeywordsList == null || advancedKeywordsList.size() == 0) { - permission = String.format("%s|%s|%s", type, instance, request.getMethod().toLowerCase()); - } else { - - boolean isAdvanced = this.containsAdvancedKeywords(request); - - // if the URI contains advanced.keywords it's an advanced query - String queryType = isAdvanced ? ADVANCED : BASIC; - permission = String.format("%s|%s|%s", type, instance, queryType); - } - - boolean isAuthorized = request.isUserInRole(permission); - - if (!isAuthorized) { - ResponseFormatter.errorResponse(request, response); - } else { - filterChain.doFilter(request, response); - } - - } - } - - private boolean containsAdvancedKeywords(HttpServletRequest request) { - String uri = request.getRequestURI(); - for (String keyword : advancedKeywordsList) { - if (uri.contains(keyword)) { - return true; - } - } - return false; - } -} diff --git a/aai-aaf-auth/src/main/java/org/onap/aai/aaf/filters/AafCertAuthorizationFilter.java b/aai-aaf-auth/src/main/java/org/onap/aai/aaf/filters/AafCertAuthorizationFilter.java deleted file mode 100644 index f19f4b8e..00000000 --- a/aai-aaf-auth/src/main/java/org/onap/aai/aaf/filters/AafCertAuthorizationFilter.java +++ /dev/null @@ -1,103 +0,0 @@ -/** - * ============LICENSE_START======================================================= - * org.onap.aai - * ================================================================================ - * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * <p> - * http://www.apache.org/licenses/LICENSE-2.0 - * <p> - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.aai.aaf.filters; - -import java.io.IOException; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.stream.Collectors; - -import javax.servlet.FilterChain; -import javax.servlet.ServletException; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -import org.onap.aai.aaf.auth.AafRequestFilter; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.boot.web.servlet.filter.OrderedRequestContextFilter; -import org.springframework.context.annotation.Profile; -import org.springframework.context.annotation.PropertySource; -import org.springframework.stereotype.Component; - -/** - * AAF with client cert authorization filter - */ - -@Component -@Profile(AafProfiles.AAF_CERT_AUTHENTICATION) -@PropertySource(value = "file:${CONFIG_HOME}/aaf/permissions.properties", ignoreResourceNotFound = true) -@PropertySource(value = "file:${server.local.startpath}/aaf/permissions.properties", ignoreResourceNotFound = true) -public class AafCertAuthorizationFilter extends OrderedRequestContextFilter { - - private static final String ADVANCED = "advanced"; - private static final String BASIC = "basic"; - - String type; - - String instance; - - private CadiProps cadiProps; - - private List<String> advancedKeywordsList; - - public AafCertAuthorizationFilter(@Value("${permission.type}") String type, - @Value("${permission.instance}") String instance, @Value("${advanced.keywords.list:}") String advancedKeys, - CadiProps cadiProps) { - this.type = type; - this.instance = instance; - this.cadiProps = cadiProps; - if (advancedKeys == null || advancedKeys.isEmpty()) { - this.advancedKeywordsList = new ArrayList<>(); - } else { - this.advancedKeywordsList = Arrays.stream(advancedKeys.split(",")).collect(Collectors.toList()); - } - this.setOrder(FilterPriority.AAF_CERT_AUTHORIZATION.getPriority()); - } - - @Override - protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) - throws IOException, ServletException { - if (advancedKeywordsList == null || advancedKeywordsList.size() == 0) { - String permission = String.format("%s|%s|%s", type, instance, request.getMethod().toLowerCase()); - AafRequestFilter.authorizationFilter(request, response, filterChain, permission, - cadiProps.getCadiProperties()); - } else { - boolean isAdvanced = this.containsAdvancedKeywords(request); - - // if the URI contains advanced.keywords it's an advanced query - String queryType = isAdvanced ? ADVANCED : BASIC; - String permission = String.format("%s|%s|%s", type, instance, queryType); - AafRequestFilter.authorizationFilter(request, response, filterChain, permission, - cadiProps.getCadiProperties()); - } - } - - private boolean containsAdvancedKeywords(HttpServletRequest request) { - String uri = request.getRequestURI(); - for (String keyword : advancedKeywordsList) { - if (uri.contains(keyword)) { - return true; - } - } - return false; - } -} diff --git a/aai-aaf-auth/src/main/java/org/onap/aai/aaf/filters/AafCertFilter.java b/aai-aaf-auth/src/main/java/org/onap/aai/aaf/filters/AafCertFilter.java deleted file mode 100644 index a3ce12b0..00000000 --- a/aai-aaf-auth/src/main/java/org/onap/aai/aaf/filters/AafCertFilter.java +++ /dev/null @@ -1,112 +0,0 @@ -/** - * ============LICENSE_START======================================================= - * org.onap.aai - * ================================================================================ - * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * <p> - * http://www.apache.org/licenses/LICENSE-2.0 - * <p> - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.aai.aaf.filters; - -import java.io.IOException; - -import javax.servlet.FilterChain; -import javax.servlet.ServletException; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -import org.onap.aaf.cadi.PropAccess; -import org.onap.aaf.cadi.filter.CadiFilter; -import org.onap.aai.aaf.auth.AafRequestFilter; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.boot.web.servlet.filter.OrderedRequestContextFilter; -import org.springframework.context.annotation.Profile; -import org.springframework.context.annotation.PropertySource; -import org.springframework.stereotype.Component; - -/** - * AAF with client cert authentication filter - */ - -@Component -@Profile(AafProfiles.AAF_CERT_AUTHENTICATION) -@PropertySource(value = "file:${CONFIG_HOME}/aaf/permissions.properties", ignoreResourceNotFound = true) -@PropertySource(value = "file:${server.local.startpath}/aaf/permissions.properties", ignoreResourceNotFound = true) -public class AafCertFilter extends OrderedRequestContextFilter { - - private static final Logger LOGGER = LoggerFactory.getLogger(AafCertFilter.class); - - String aafUserChainPattern; - - private final CadiFilter cadiFilter; - - private final CadiProps cadiProps; - - public AafCertFilter(@Value("${aaf.userchain.pattern}") String aafUserChainPattern, CadiProps cadiProps) - throws IOException, ServletException { - - this.aafUserChainPattern = aafUserChainPattern; - this.cadiProps = cadiProps; - cadiFilter = new CadiFilter(new PropAccess((level, element) -> { - switch (level) { - case DEBUG: - LOGGER.debug(buildMsg(element)); - break; - case INFO: - case AUDIT: - LOGGER.info(buildMsg(element)); - break; - case WARN: - LOGGER.warn(buildMsg(element)); - break; - case ERROR: - LOGGER.error(buildMsg(element)); - break; - case INIT: - LOGGER.info(buildMsg(element)); - break; - case TRACE: - LOGGER.trace(buildMsg(element)); - break; - case NONE: - break; - } - }, new String[] {"cadi_prop_files=" + cadiProps.getCadiFileName()})); - this.setOrder(FilterPriority.AAF_CERT_AUTHENTICATION.getPriority()); - } - - @Override - protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) - throws IOException, ServletException { - AafRequestFilter.authenticationFilter(request, response, filterChain, cadiFilter, cadiProps.getCadiProperties(), - aafUserChainPattern); - } - - private String buildMsg(Object[] objects) { - StringBuilder sb = new StringBuilder(); - boolean first = true; - for (Object o : objects) { - if (first) { - first = false; - } else { - sb.append(' '); - } - sb.append(o.toString()); - } - return (sb.toString()); - } -} diff --git a/aai-aaf-auth/src/main/java/org/onap/aai/aaf/filters/AafFilter.java b/aai-aaf-auth/src/main/java/org/onap/aai/aaf/filters/AafFilter.java deleted file mode 100644 index ae3a6ca6..00000000 --- a/aai-aaf-auth/src/main/java/org/onap/aai/aaf/filters/AafFilter.java +++ /dev/null @@ -1,106 +0,0 @@ -/** - * ============LICENSE_START======================================================= - * org.onap.aai - * ================================================================================ - * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * <p> - * http://www.apache.org/licenses/LICENSE-2.0 - * <p> - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.aai.aaf.filters; - -import java.io.IOException; - -import javax.servlet.FilterChain; -import javax.servlet.ServletException; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -import org.onap.aaf.cadi.PropAccess; -import org.onap.aaf.cadi.filter.CadiFilter; -import org.onap.aai.aaf.auth.ResponseFormatter; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.boot.web.servlet.filter.OrderedRequestContextFilter; -import org.springframework.context.annotation.Profile; -import org.springframework.stereotype.Component; - -/** - * AAF authentication filter - */ - -@Component -@Profile(AafProfiles.AAF_AUTHENTICATION) -public class AafFilter extends OrderedRequestContextFilter { - - private static final Logger LOGGER = LoggerFactory.getLogger(AafCertFilter.class); - - private final CadiFilter cadiFilter; - - public AafFilter(CadiProps cadiProps) throws IOException, ServletException { - cadiFilter = new CadiFilter(new PropAccess((level, element) -> { - switch (level) { - case DEBUG: - LOGGER.debug(buildMsg(element)); - break; - case INFO: - case AUDIT: - LOGGER.info(buildMsg(element)); - break; - case WARN: - LOGGER.warn(buildMsg(element)); - break; - case ERROR: - LOGGER.error(buildMsg(element)); - break; - case INIT: - LOGGER.info(buildMsg(element)); - break; - case TRACE: - LOGGER.trace(buildMsg(element)); - break; - case NONE: - break; - } - }, new String[] {"cadi_prop_files=" + cadiProps.getCadiFileName()})); - this.setOrder(FilterPriority.AAF_AUTHENTICATION.getPriority()); - } - - @Override - protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) - throws IOException, ServletException { - if (!request.getRequestURI().matches("^.*/util/echo$")) { - cadiFilter.doFilter(request, response, filterChain); - if (response.getStatus() == 401 || response.getStatus() == 403) { - ResponseFormatter.errorResponse(request, response); - } - } else { - filterChain.doFilter(request, response); - } - } - - private String buildMsg(Object[] objects) { - StringBuilder sb = new StringBuilder(); - boolean first = true; - for (Object o : objects) { - if (first) { - first = false; - } else { - sb.append(' '); - } - sb.append(o.toString()); - } - return (sb.toString()); - } -} diff --git a/aai-aaf-auth/src/main/java/org/onap/aai/aaf/filters/CadiProps.java b/aai-aaf-auth/src/main/java/org/onap/aai/aaf/filters/CadiProps.java deleted file mode 100644 index 01b89148..00000000 --- a/aai-aaf-auth/src/main/java/org/onap/aai/aaf/filters/CadiProps.java +++ /dev/null @@ -1,80 +0,0 @@ -/** - * ============LICENSE_START======================================================= - * org.onap.aai - * ================================================================================ - * Copyright © 2017-2019 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.aai.aaf.filters; - -import java.io.File; -import java.io.FileInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.util.Properties; - -import javax.annotation.PostConstruct; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.context.annotation.Profile; -import org.springframework.stereotype.Component; - -// This component will be created if and only if any of the following profiles are active -@Component -@Profile({AafProfiles.AAF_CERT_AUTHENTICATION, AafProfiles.AAF_AUTHENTICATION, AafProfiles.TWO_WAY_SSL}) -public class CadiProps { - - private static final Logger LOGGER = LoggerFactory.getLogger(CadiProps.class); - - private String cadiFileName; - - private Properties cadiProperties; - - public CadiProps(@Value("${aaf.cadi.file:./resources/cadi.properties}") String filename) { - cadiFileName = filename; - cadiProperties = new Properties(); - } - - @PostConstruct - public void init() throws IOException { - - File cadiFile = new File(cadiFileName); - - if (!cadiFile.exists()) { - LOGGER.warn("Unable to find the cadi file in the given path {} so loading cadi.properties from classloader", - cadiFileName); - InputStream is = this.getClass().getClassLoader().getResourceAsStream("cadi.properties"); - cadiProperties.load(is); - } else { - LOGGER.info("Successfully found the file {} and started loading the properties from it", cadiFileName); - cadiFileName = cadiFile.getAbsolutePath(); - try (InputStream inputStream = new FileInputStream(cadiFile)) { - cadiProperties.load(inputStream); - } - - } - } - - public String getCadiFileName() { - return cadiFileName; - } - - public Properties getCadiProperties() { - return cadiProperties; - } -} diff --git a/aai-aaf-auth/src/main/java/org/onap/aai/aaf/filters/FilterPriority.java b/aai-aaf-auth/src/main/java/org/onap/aai/aaf/filters/FilterPriority.java deleted file mode 100644 index e2423425..00000000 --- a/aai-aaf-auth/src/main/java/org/onap/aai/aaf/filters/FilterPriority.java +++ /dev/null @@ -1,42 +0,0 @@ -/** - * ============LICENSE_START======================================================= - * org.onap.aai - * ================================================================================ - * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.aai.aaf.filters; - -import org.springframework.core.Ordered; - -public enum FilterPriority { - - AAF_AUTHENTICATION(Ordered.HIGHEST_PRECEDENCE), AAF_AUTHORIZATION(Ordered.HIGHEST_PRECEDENCE + 1), // higher number - // = lower - // priority - AAF_CERT_AUTHENTICATION(Ordered.HIGHEST_PRECEDENCE + 2), AAF_CERT_AUTHORIZATION( - Ordered.HIGHEST_PRECEDENCE + 3), TWO_WAY_SSL_AUTH(Ordered.HIGHEST_PRECEDENCE + 4); - - private final int priority; - - FilterPriority(final int p) { - priority = p; - } - - public int getPriority() { - return priority; - } -} diff --git a/aai-aaf-auth/src/main/java/org/onap/aai/aaf/filters/GremlinFilter.java b/aai-aaf-auth/src/main/java/org/onap/aai/aaf/filters/GremlinFilter.java deleted file mode 100644 index f800097f..00000000 --- a/aai-aaf-auth/src/main/java/org/onap/aai/aaf/filters/GremlinFilter.java +++ /dev/null @@ -1,98 +0,0 @@ -/** - * ============LICENSE_START======================================================= - * org.onap.aai - * ================================================================================ - * Copyright © 2017-2019 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.aai.aaf.filters; - -import java.io.IOException; -import java.nio.charset.StandardCharsets; -import java.util.regex.Pattern; - -import javax.servlet.FilterChain; -import javax.servlet.ServletException; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -import org.apache.commons.io.IOUtils; -import org.onap.aai.aaf.auth.ResponseFormatter; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.context.annotation.Profile; -import org.springframework.stereotype.Component; - -@Component -@Profile({AafProfiles.AAF_CERT_AUTHENTICATION, AafProfiles.AAF_AUTHENTICATION}) -public class GremlinFilter { - - private static final Logger LOGGER = LoggerFactory.getLogger(GremlinFilter.class); - - private static final String ADVANCED = "advanced"; - private static final String BASIC = "basic"; - private static final Pattern ECHO_ENDPOINT = Pattern.compile("^.*/util/echo$"); - - String type; - - String instance; - - private CadiProps cadiProps; - - public GremlinFilter(@Value("${permission.type}") String type, @Value("${permission.instance}") String instance, - CadiProps cadiProps) { - this.type = type; - this.instance = instance; - this.cadiProps = cadiProps; - } - - public void doBasicAuthFilter(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) - throws IOException, ServletException { - PayloadBufferingRequestWrapper requestBufferWrapper = new PayloadBufferingRequestWrapper(request); - - if (ECHO_ENDPOINT.matcher(request.getRequestURI()).matches()) { - filterChain.doFilter(requestBufferWrapper, response); - } - - String payload = IOUtils.toString(requestBufferWrapper.getInputStream(), StandardCharsets.UTF_8.name()); - boolean containsWordGremlin = payload.contains("\"gremlin\""); - - // if the requestBufferWrapper contains the word "gremlin" it's an "advanced" query needing an "advanced" role - String permissionBasic = String.format("%s|%s|%s", type, instance, BASIC); - String permissionAdvanced = String.format("%s|%s|%s", type, instance, ADVANCED); - - boolean isAuthorized; - - if (containsWordGremlin) { - isAuthorized = requestBufferWrapper.isUserInRole(permissionAdvanced); - } else { - isAuthorized = requestBufferWrapper.isUserInRole(permissionAdvanced) - || requestBufferWrapper.isUserInRole(permissionBasic); - } - - if (!isAuthorized) { - String name = - requestBufferWrapper.getUserPrincipal() != null ? requestBufferWrapper.getUserPrincipal().getName() - : "unknown"; - LOGGER.info("User " + name + " does not have a role for " - + (containsWordGremlin ? "gremlin" : "non-gremlin") + " query"); - ResponseFormatter.errorResponse(request, response); - } else { - filterChain.doFilter(requestBufferWrapper, response); - } - } -} diff --git a/aai-aaf-auth/src/main/java/org/onap/aai/aaf/filters/PayloadBufferingRequestWrapper.java b/aai-aaf-auth/src/main/java/org/onap/aai/aaf/filters/PayloadBufferingRequestWrapper.java deleted file mode 100644 index e8c72dc3..00000000 --- a/aai-aaf-auth/src/main/java/org/onap/aai/aaf/filters/PayloadBufferingRequestWrapper.java +++ /dev/null @@ -1,52 +0,0 @@ -/** - * ============LICENSE_START======================================================= - * org.onap.aai - * ================================================================================ - * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.aai.aaf.filters; - -import java.io.ByteArrayInputStream; -import java.io.IOException; - -import javax.servlet.ServletInputStream; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletRequestWrapper; - -import org.apache.commons.io.IOUtils; -import org.onap.aaf.cadi.BufferedServletInputStream; - -/** - * This class buffers the payload of the servlet request. The reason is that we access the payload multiple times, - * which is not supported by the request per se. - */ - -class PayloadBufferingRequestWrapper extends HttpServletRequestWrapper { - - private byte[] buffer; - - PayloadBufferingRequestWrapper(HttpServletRequest req) throws IOException { - super(req); - this.buffer = IOUtils.toByteArray(req.getInputStream()); - } - - @Override - public ServletInputStream getInputStream() { - ByteArrayInputStream bais = new ByteArrayInputStream(this.buffer); - return new BufferedServletInputStream(bais); - } -} diff --git a/aai-aaf-auth/src/main/java/org/onap/aai/aaf/filters/TwoWaySslAuthorization.java b/aai-aaf-auth/src/main/java/org/onap/aai/aaf/filters/TwoWaySslAuthorization.java deleted file mode 100644 index 3dad92df..00000000 --- a/aai-aaf-auth/src/main/java/org/onap/aai/aaf/filters/TwoWaySslAuthorization.java +++ /dev/null @@ -1,186 +0,0 @@ -/** - * ============LICENSE_START======================================================= - * org.onap.aai - * ================================================================================ - * Copyright © 2017-2019 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.aai.aaf.filters; - -import java.io.IOException; -import java.security.cert.X509Certificate; -import java.util.*; - -import javax.security.auth.x500.X500Principal; -import javax.servlet.FilterChain; -import javax.servlet.ServletException; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -import org.onap.aai.aaf.auth.AAIAuthCore; -import org.onap.aai.aaf.auth.CertUtil; -import org.onap.aai.aaf.auth.ResponseFormatter; -import org.onap.aai.exceptions.AAIException; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.web.servlet.filter.OrderedRequestContextFilter; -import org.springframework.context.annotation.Profile; -import org.springframework.core.env.Environment; -import org.springframework.stereotype.Component; - -@Component -@Profile("two-way-ssl") -public class TwoWaySslAuthorization extends OrderedRequestContextFilter { - - private static final Logger LOGGER = LoggerFactory.getLogger(TwoWaySslAuthorization.class); - - public static final String HTTP_METHOD_OVERRIDE = "X-HTTP-Method-Override"; - - public static final String MERGE_PATCH = "MERGE_PATCH"; - - @Autowired - private Environment environment; - - @Autowired - private AAIAuthCore aaiAuthCore; - - @Autowired - private CadiProps cadiProps; - - public TwoWaySslAuthorization() { - this.setOrder(FilterPriority.TWO_WAY_SSL_AUTH.getPriority()); - } - - @Override - protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) - throws IOException, ServletException { - - String uri = request.getRequestURI(); - String httpMethod = getHttpMethod(request); - - Optional<String> authUser = getUser(request); - - if (authUser.isPresent()) { - Properties cadiProperties = cadiProps.getCadiProperties(); - - String issuer = CertUtil.getCertIssuer(request); - if (issuer == null || issuer.isEmpty()) { - AAIException aaie = new AAIException("AAI_9107"); - ResponseFormatter.errorResponse(aaie, request, response); - return; - } - issuer = issuer.replaceAll("\\s+", "").toUpperCase(); - - List<String> cadiConfiguredIssuers = CertUtil.getCadiCertIssuers(cadiProperties); - boolean isAafAuthProfileActive = this.isAafAuthProfileActive(); - if ((!isAafAuthProfileActive) || (!cadiConfiguredIssuers.contains(issuer))) { - try { - this.authorize(uri, httpMethod, authUser.get(), this.getHaProxyUser(request), issuer); - } catch (AAIException e) { - ResponseFormatter.errorResponse(e, request, response); - return; - } - } - } else { - AAIException aaie = new AAIException("AAI_9107"); - ResponseFormatter.errorResponse(aaie, request, response); - return; - } - filterChain.doFilter(request, response); - } - - private String getHttpMethod(HttpServletRequest request) { - String httpMethod = request.getMethod(); - if ("POST".equalsIgnoreCase(httpMethod) && "PATCH".equals(request.getHeader(HTTP_METHOD_OVERRIDE))) { - httpMethod = MERGE_PATCH; - } - if (httpMethod.equalsIgnoreCase(MERGE_PATCH) || "patch".equalsIgnoreCase(httpMethod)) { - httpMethod = "PUT"; - } - return httpMethod; - } - - private Optional<String> getUser(HttpServletRequest hsr) { - String authUser = null; - if (hsr.getAttribute("javax.servlet.request.cipher_suite") != null) { - X509Certificate[] certChain = (X509Certificate[]) hsr.getAttribute("javax.servlet.request.X509Certificate"); - - /* - * If the certificate is null or the certificate chain length is zero Then - * retrieve the authorization in the request header Authorization Check that it - * is not null and that it starts with Basic and then strip the basic portion to - * get the base64 credentials Check if this is contained in the AAIBasicAuth - * Singleton class If it is, retrieve the username associated with that - * credentials and set to authUser Otherwise, get the principal from certificate - * and use that authUser - */ - - if (certChain == null || certChain.length == 0) { - - String authorization = hsr.getHeader("Authorization"); - - if (authorization != null && authorization.startsWith("Basic ")) { - authUser = authorization.replace("Basic ", ""); - } - - } else { - X509Certificate clientCert = certChain[0]; - X500Principal subjectDN = clientCert.getSubjectX500Principal(); - authUser = subjectDN.toString().toLowerCase(); - } - } - - return Optional.ofNullable(authUser); - } - - private String getHaProxyUser(HttpServletRequest hsr) { - String haProxyUser; - if (Objects.isNull(hsr.getHeader("X-AAI-SSL-Client-CN")) || Objects.isNull(hsr.getHeader("X-AAI-SSL-Client-OU")) - || Objects.isNull(hsr.getHeader("X-AAI-SSL-Client-O")) - || Objects.isNull(hsr.getHeader("X-AAI-SSL-Client-L")) - || Objects.isNull(hsr.getHeader("X-AAI-SSL-Client-ST")) - || Objects.isNull(hsr.getHeader("X-AAI-SSL-Client-C"))) { - haProxyUser = ""; - } else { - haProxyUser = String.format("CN=%s, OU=%s, O=\"%s\", L=%s, ST=%s, C=%s", - Objects.toString(hsr.getHeader("X-AAI-SSL-Client-CN"), ""), - Objects.toString(hsr.getHeader("X-AAI-SSL-Client-OU"), ""), - Objects.toString(hsr.getHeader("X-AAI-SSL-Client-O"), ""), - Objects.toString(hsr.getHeader("X-AAI-SSL-Client-L"), ""), - Objects.toString(hsr.getHeader("X-AAI-SSL-Client-ST"), ""), - Objects.toString(hsr.getHeader("X-AAI-SSL-Client-C"), "")).toLowerCase(); - } - return haProxyUser; - } - - private void authorize(String uri, String httpMethod, String authUser, String haProxyUser, String issuer) - throws AAIException { - if (!aaiAuthCore.authorize(authUser, uri, httpMethod, haProxyUser, issuer)) { - throw new AAIException("AAI_9101", "Request on " + httpMethod + " " + uri + " status is not OK"); - } - } - - private boolean isAafAuthProfileActive() { - String[] profiles = environment.getActiveProfiles(); - if (profiles != null) { - if (Arrays.stream(profiles).anyMatch(env -> (env.equalsIgnoreCase(AafProfiles.AAF_CERT_AUTHENTICATION)))) { - return true; - } - } - return false; - } -} diff --git a/aai-aaf-auth/src/test/java/org/onap/aai/aaf/auth/AAIAuthCoreTest.java b/aai-aaf-auth/src/test/java/org/onap/aai/aaf/auth/AAIAuthCoreTest.java deleted file mode 100644 index 813e8fa1..00000000 --- a/aai-aaf-auth/src/test/java/org/onap/aai/aaf/auth/AAIAuthCoreTest.java +++ /dev/null @@ -1,235 +0,0 @@ -/** - * ============LICENSE_START======================================================= - * org.onap.aai - * ================================================================================ - * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.aai.aaf.auth; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; - -import org.junit.Before; -import org.junit.Test; -import org.onap.aai.aaf.auth.exceptions.AAIUnrecognizedFunctionException; - -public class AAIAuthCoreTest extends AAISetup { - - private AAIAuthCore authCore; - - @Before - public void setup() { - authCore = new AAIAuthCore("/aai"); - } - - @Test - public void getAuthPolicyFunctionNameTest() { - - String uri = "/aai/v3/search/edge-tag-query"; - assertEquals("Get aai function name from " + uri, "search", authCore.getAuthPolicyFunctName(uri)); - - uri = "/aai/v10/search/edge-tag-query"; - assertEquals("Get aai function name from " + uri, "search", authCore.getAuthPolicyFunctName(uri)); - - uri = "/aai/search/model"; - assertEquals("Get aai function name from " + uri, "search", authCore.getAuthPolicyFunctName(uri)); - - uri = "/aai/v9/cloud-infrastructure/cloud-regions/cloud-region/somecloudregion/some-cloud-owner"; - assertEquals("Get aai function name from " + uri, "cloud-infrastructure", authCore.getAuthPolicyFunctName(uri)); - - uri = "/aai/v8/network/pnfs/pnf/ff4ca01orc/p-interfaces"; - assertEquals("Get aai function name from " + uri, "network", authCore.getAuthPolicyFunctName(uri)); - - uri = "/aai/util/echo"; - assertEquals("Get aai function name from " + uri, "util", authCore.getAuthPolicyFunctName(uri)); - - uri = "/aai/tools"; - assertEquals("Get aai function name from " + uri, "tools", authCore.getAuthPolicyFunctName(uri)); - - uri = "/aai/v12/bulk/single-transaction"; - assertEquals("Get aai function name from " + uri, "bulk", authCore.getAuthPolicyFunctName(uri)); - - } - - @Test - public void validUsernameAuthTest() throws AAIUnrecognizedFunctionException { - assertTrue(authCore.authorize("testUser".toLowerCase(), "/aai/v0/testFunction/someUri", "PUT", "")); - } - - @Test - public void validUsernameInvalidHttpMethodAuthTest() throws AAIUnrecognizedFunctionException { - assertFalse(authCore.authorize("testUser".toLowerCase(), "/aai/v0/testFunction/someUri", "POST", "")); - } - - @Test(expected = AAIUnrecognizedFunctionException.class) - public void validUsernameInvalidFunctionInURIAuthTest() throws AAIUnrecognizedFunctionException { - authCore.authorize("testUser".toLowerCase(), "/aai/v0/badFunction/someUri", "PUT", ""); - } - - @Test - public void invalidUsernameAuthTest() throws AAIUnrecognizedFunctionException { - assertFalse(authCore.authorize("invlaidTestUser".toLowerCase(), "/aai/v0/testFunction/someUri", "PUT", "")); - } - - @Test - public void validUsernameIsTheExactWildcardIdAuthTest() throws AAIUnrecognizedFunctionException { - assertTrue(authCore.authorize("testWildcardId".toLowerCase(), "/aai/v0/testFunction/someUri", "PUT", "")); - } - - @Test - public void validUsernameContainsTheWildcardIdAuthTest() throws AAIUnrecognizedFunctionException { - assertTrue(authCore.authorize("cn=blah, testWildcardId, O=".toLowerCase(), "/aai/v0/testFunction/someUri", - "PUT", "", "aafWildCardIssuer")); - } - - @Test - public void validUsernameContainsTheWildcardIdInvalidIssuerAuthTest() throws AAIUnrecognizedFunctionException { - assertFalse(authCore.authorize("cn=blah, testWildcardId, O=".toLowerCase(), "/aai/v0/testFunction/someUri", - "PUT", "", "invalidIssuer")); - } - - @Test - public void invalidUsernameContainsRegularUsernameAuthTest() throws AAIUnrecognizedFunctionException { - assertFalse( - authCore.authorize("cn=blah, testUser, O=".toLowerCase(), "/aai/v0/testFunction/someUri", "PUT", "")); - } - - @Test - public void haProxyUsernameAuthTest() throws AAIUnrecognizedFunctionException { - assertTrue(authCore.authorize("ha-proxy-user".toLowerCase(), "/aai/util/echo", "GET", "")); - } - - @Test - public void haProxyUsernameInvalidFunctionAuthTest() throws AAIUnrecognizedFunctionException { - assertFalse(authCore.authorize("ha-proxy-user".toLowerCase(), "/aai/v0/testFunction/someUri", "PUT", "")); - } - - @Test - public void validUsernameViaHaProxyAuthTest() throws AAIUnrecognizedFunctionException { - assertTrue(authCore.authorize("ha-proxy-user".toLowerCase(), "/aai/v0/testFunction/someUri", "PUT", - "testUser".toLowerCase())); - } - - @Test - public void validUsernameInvalidHttpMethodViaHaProxyAuthTest() throws AAIUnrecognizedFunctionException { - assertFalse(authCore.authorize("ha-proxy-user".toLowerCase(), "/aai/v0/testFunction/someUri", "POST", - "testUser".toLowerCase())); - } - - @Test(expected = AAIUnrecognizedFunctionException.class) - public void validUsernameInvalidFunctionInURIViaHaProxyAuthTest() throws AAIUnrecognizedFunctionException { - authCore.authorize("ha-proxy-user".toLowerCase(), "/aai/v0/badFunction/someUri", "PUT", - "testUser".toLowerCase()); - } - - @Test - public void invalidUsernameViaHaProxyAuthTest() throws AAIUnrecognizedFunctionException { - assertFalse(authCore.authorize("ha-proxy-user".toLowerCase(), "/aai/v0/testFunction/someUri", "PUT", - "invlaidTestUser".toLowerCase())); - } - - @Test - public void validUsernameIsTheExactWildcardIdViaHaProxyAuthTest() throws AAIUnrecognizedFunctionException { - assertTrue(authCore.authorize("ha-proxy-user".toLowerCase(), "/aai/v0/testFunction/someUri", "PUT", - "testWildcardId".toLowerCase())); - } - - @Test - public void validUsernameContainsTheWildcardIdViaHaProxyAuthTest() throws AAIUnrecognizedFunctionException { - assertTrue(authCore.authorize("ha-proxy-user".toLowerCase(), "/aai/v0/testFunction/someUri", "PUT", - "cn=blah, testWildcardId, O=".toLowerCase(), "aafWildCardIssuer")); - } - - @Test - public void invalidUsernameContainsRegularUsernameViaHaProxyAuthTest() throws AAIUnrecognizedFunctionException { - assertFalse(authCore.authorize("ha-proxy-user".toLowerCase(), "/aai/v0/testFunction/someUri", "PUT", - "cn=blah, testUser, O=".toLowerCase())); - } - - @Test - public void haProxyUsernameTwiceAuthTest() throws AAIUnrecognizedFunctionException { - assertFalse(authCore.authorize("ha-proxy-user".toLowerCase(), "/aai/v0/testFunction/someUri", "PUT", - "ha-proxy-user".toLowerCase())); - } - - @Test - public void haProxyWildcardIdAuthTest() throws AAIUnrecognizedFunctionException { - assertTrue(authCore.authorize("cn=blah, ha-proxy-wildcard-id, O=".toLowerCase(), "/aai/util/echo", "GET", "", - "aafWildCardIssuer")); - } - - @Test - public void haProxyWildcardIdInvalidFunctionAuthTest() throws AAIUnrecognizedFunctionException { - assertFalse(authCore.authorize("cn=blah, ha-proxy-wildcard-id, O=".toLowerCase(), - "/aai/v0/testFunction/someUri", "PUT", "")); - } - - @Test - public void validUsernameViaHaProxyWildcardIdAuthTest() throws AAIUnrecognizedFunctionException { - assertTrue(authCore.authorize("cn=blah, ha-proxy-wildcard-id, O=".toLowerCase(), "/aai/v0/testFunction/someUri", - "PUT", "testUser".toLowerCase(), "aafWildCardIssuer")); - } - - @Test - public void validUsernameInvalidHttpMethodViaHaProxyWildcardIdAuthTest() throws AAIUnrecognizedFunctionException { - assertFalse(authCore.authorize("cn=blah, ha-proxy-wildcard-id, O=".toLowerCase(), - "/aai/v0/testFunction/someUri", "POST", "testUser".toLowerCase())); - } - - @Test(expected = AAIUnrecognizedFunctionException.class) - public void validUsernameInvalidFunctionInURIViaHaProxyWildcardIdAuthTest() - throws AAIUnrecognizedFunctionException { - authCore.authorize("cn=blah, ha-proxy-wildcard-id, O=".toLowerCase(), "/aai/v0/badFunction/someUri", "PUT", - "testUser".toLowerCase()); - } - - @Test - public void invalidUsernameViaHaProxyWildcardIdAuthTest() throws AAIUnrecognizedFunctionException { - assertFalse(authCore.authorize("cn=blah, ha-proxy-wildcard-id, O=".toLowerCase(), - "/aai/v0/testFunction/someUri", "PUT", "invlaidTestUser".toLowerCase())); - } - - @Test - public void validUsernameIsTheExactWildcardIdViaHaProxyWildcardIdAuthTest() - throws AAIUnrecognizedFunctionException { - assertTrue(authCore.authorize("cn=blah, ha-proxy-wildcard-id, O=".toLowerCase(), "/aai/v0/testFunction/someUri", - "PUT", "testWildcardId".toLowerCase(), "aafWildCardIssuer")); - } - - @Test - public void validUsernameContainsTheWildcardIdViaHaProxyWildcardIdAuthTest() - throws AAIUnrecognizedFunctionException { - assertTrue(authCore.authorize("cn=blah, ha-proxy-wildcard-id, O=".toLowerCase(), "/aai/v0/testFunction/someUri", - "PUT", "cn=blah, testWildcardId, O=".toLowerCase(), "aafWildCardIssuer")); - } - - @Test - public void validUsernameContainsTheWildcardIdViaHaProxyWildcardIdInvalidIssuerAuthTest() - throws AAIUnrecognizedFunctionException { - assertFalse(authCore.authorize("cn=blah, ha-proxy-wildcard-id, O=".toLowerCase(), - "/aai/v0/testFunction/someUri", "PUT", "cn=blah, testWildcardId, O=".toLowerCase(), "invalidIssuer")); - } - - @Test - public void invalidUsernameContainsRegularUsernameViaHaProxyWildcardIdAuthTest() - throws AAIUnrecognizedFunctionException { - assertFalse(authCore.authorize("cn=blah, ha-proxy-wildcard-id, O=".toLowerCase(), - "/aai/v0/testFunction/someUri", "PUT", "cn=blah, testUser, O=".toLowerCase())); - } - -} diff --git a/aai-aaf-auth/src/test/java/org/onap/aai/aaf/auth/AAIUserTest.java b/aai-aaf-auth/src/test/java/org/onap/aai/aaf/auth/AAIUserTest.java deleted file mode 100644 index 5f02f1aa..00000000 --- a/aai-aaf-auth/src/test/java/org/onap/aai/aaf/auth/AAIUserTest.java +++ /dev/null @@ -1,53 +0,0 @@ -/** - * ============LICENSE_START======================================================= - * org.onap.aai - * ================================================================================ - * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.aai.aaf.auth; - -import static org.junit.Assert.assertEquals; - -import org.junit.Test; - -public class AAIUserTest extends AAISetup { - - @Test - public void testIsAuth() { - AAIUser usr = new AAIUser("testUser"); - usr.addRole("testRole"); - usr.setUserAccess("auth", "GET"); - usr.setUserAccess("auth", "PUT"); - usr.setUserAccess("authentication", "PUT", "GET", "POST"); - - assertEquals(true, usr.hasAccess("auth", "GET")); - assertEquals(true, usr.hasAccess("auth", "PUT")); - assertEquals(true, usr.hasAccess("authentication", "POST")); - } - - @Test - public void testIsNotAuth() { - AAIUser usr = new AAIUser("testUser"); - usr.addRole("testRole"); - - assertEquals(false, usr.hasAccess("auth", "GET")); - - usr.setUserAccess("auth", "GET"); - assertEquals(false, usr.hasAccess("auth", "PUT")); - } - -} diff --git a/aai-aaf-auth/src/test/java/org/onap/aai/aaf/auth/AafRequestWrapperTest.java b/aai-aaf-auth/src/test/java/org/onap/aai/aaf/auth/AafRequestWrapperTest.java deleted file mode 100644 index 46389d02..00000000 --- a/aai-aaf-auth/src/test/java/org/onap/aai/aaf/auth/AafRequestWrapperTest.java +++ /dev/null @@ -1,60 +0,0 @@ -/*- - * ============LICENSE_START============================================ - * ONAP Portal - * ===================================================================== - * Copyright (C) 2020 IBM Intellectual Property. All rights reserved. - * ===================================================================== - * - * Unless otherwise specified, all software contained herein is licensed - * under the Apache License, Version 2.0 (the "License"); - * you may not use this software except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * Unless otherwise specified, all documentation contained herein is licensed - * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); - * you may not use this documentation except in compliance with the License. - * You may obtain a copy of the License at - * - * https://creativecommons.org/licenses/by/4.0/ - * - * Unless required by applicable law or agreed to in writing, documentation - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * ============LICENSE_END================================================ - * - * - */ - -package org.onap.aai.aaf.auth; - -import static org.easymock.EasyMock.*; -import static org.junit.Assert.assertEquals; - -import javax.servlet.http.HttpServletRequest; - -import org.junit.Test; - -public class AafRequestWrapperTest { - - @Test - public void testGetHeader() { - HttpServletRequest mockRequest = createMock(HttpServletRequest.class); - expect(mockRequest.getHeader(CertUtil.AAI_SSL_CLIENT_OU_HDR)).andReturn("m55555@org.onap.com:TEST").times(1, 4); - replay(mockRequest); - AafRequestWrapper af = new AafRequestWrapper(mockRequest); - assertEquals(af.getHeader("X-AAI-SSL-Client-OU"), "m55555@org.onap.com:TEST"); - af.putHeader("X-AAI-SSL-Client-C", "test@org.onap.com:test"); - assertEquals(af.getHeader("X-AAI-SSL-Client-C"), "test@org.onap.com:test"); - } -} diff --git a/aai-aaf-auth/src/test/java/org/onap/aai/aaf/auth/CertUtilTest.java b/aai-aaf-auth/src/test/java/org/onap/aai/aaf/auth/CertUtilTest.java deleted file mode 100644 index 81a9c1b6..00000000 --- a/aai-aaf-auth/src/test/java/org/onap/aai/aaf/auth/CertUtilTest.java +++ /dev/null @@ -1,87 +0,0 @@ -/** - * ============LICENSE_START======================================================= - * org.onap.aai - * ================================================================================ - * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.aai.aaf.auth; - -import static org.easymock.EasyMock.*; -import static org.junit.Assert.assertTrue; - -import java.io.File; -import java.io.FileInputStream; -import java.io.IOException; -import java.util.List; -import java.util.Properties; - -import javax.servlet.http.HttpServletRequest; - -import org.junit.Test; - -/** - * The Class CertUtilTest - */ -public class CertUtilTest extends AAISetup { - - @Test - public void testCadiCertIssuers() throws IOException { - String propFile = System.getProperty("BUNDLECONFIG_DIR") + "/aaf/cadi.properties"; - Properties cadiProperties = new Properties(); - cadiProperties.load(new FileInputStream(new File(propFile))); - - List<String> issuersList = CertUtil.getCadiCertIssuers(cadiProperties); - assertTrue("issuersList isn't populated", !issuersList.isEmpty()); - - int x = issuersList.get(0).indexOf(" "); - assertTrue("issuer contains spaces", x < 0); - } - - @Test - public void testAaiSslClientOuHeader() { - - HttpServletRequest mockRequest = createMock(HttpServletRequest.class); - expect(mockRequest.getHeader(CertUtil.AAI_SSL_CLIENT_OU_HDR)).andReturn("m55555@org.onap.com:TEST").times(1, 4); - expect(mockRequest.getHeader(CertUtil.AAI_SSL_CLIENT_CN_HDR)).andReturn("CN").times(1, 2); - expect(mockRequest.getHeader(CertUtil.AAI_SSL_CLIENT_O_HDR)).andReturn("O").times(1, 2); - expect(mockRequest.getHeader(CertUtil.AAI_SSL_CLIENT_L_HDR)).andReturn("L").times(1, 2); - expect(mockRequest.getHeader(CertUtil.AAI_SSL_CLIENT_ST_HDR)).andReturn("ST").times(1, 2); - expect(mockRequest.getHeader(CertUtil.AAI_SSL_CLIENT_C_HDR)).andReturn("C").times(1, 2); - - replay(mockRequest); - String ou = CertUtil.getAaiSslClientOuHeader(mockRequest); - assertTrue("OU Header value is not as expected", ou.equals("m55555@org.onap.com:TEST")); - - assertTrue("Unexpected isHaProxy() return value", CertUtil.isHaProxy(mockRequest)); - - String mechId = CertUtil.getMechId(mockRequest); - assertTrue("mechid value is not as expected", mechId.equals("m55555@org.onap.com")); - - } - - @Test - public void testBuildUserChain() { - - // aaf.userchain.pattern=<AAF-ID>:${aaf.userchain.service.reference}:${aaf.userchain.auth.type}:AS - String aafUserChainPattern = "<AAF-ID>:org.onap.haproxy:X509:AS"; - String mechid = "m11111@onap.org"; - String result = CertUtil.buildUserChainHeader(mechid, aafUserChainPattern); - - assertTrue("user chain value is not as expected", "m11111@onap.org:org.onap.haproxy:X509:AS".equals(result)); - - } -} diff --git a/aai-aaf-auth/src/test/java/org/onap/aai/aaf/filters/CadiPropsTest.java b/aai-aaf-auth/src/test/java/org/onap/aai/aaf/filters/CadiPropsTest.java deleted file mode 100644 index 601b8292..00000000 --- a/aai-aaf-auth/src/test/java/org/onap/aai/aaf/filters/CadiPropsTest.java +++ /dev/null @@ -1,56 +0,0 @@ -/*- - * ============LICENSE_START========================================== - * ONAP Portal - * =================================================================== - * Copyright (C) 2020 IBM Intellectual Property. All rights reserved. - * =================================================================== - * - * Unless otherwise specified, all software contained herein is licensed - * under the Apache License, Version 2.0 (the "License"); - * you may not use this software except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * Unless otherwise specified, all documentation contained herein is licensed - * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); - * you may not use this documentation except in compliance with the License. - * You may obtain a copy of the License at - * - * https://creativecommons.org/licenses/by/4.0/ - * - * Unless required by applicable law or agreed to in writing, documentation - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * ============LICENSE_END============================================ - * - * - */ - -package org.onap.aai.aaf.filters; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; - -import org.junit.Test; -import org.springframework.beans.factory.annotation.Autowired; - -public class CadiPropsTest { - @Autowired - CadiProps ca = new CadiProps("src/test/resources/bundleconfig-local/aaf/org.onap.aai.props"); - - @Test - public void testGetCadiFileName() { - assertEquals(ca.getCadiFileName(), "src/test/resources/bundleconfig-local/aaf/org.onap.aai.props"); - assertNotNull(ca.getCadiProperties()); - } -} diff --git a/aai-aaf-auth/src/test/resources/bundleconfig-local/aaf/cadi.properties b/aai-aaf-auth/src/test/resources/bundleconfig-local/aaf/cadi.properties deleted file mode 100644 index 8f7004ff..00000000 --- a/aai-aaf-auth/src/test/resources/bundleconfig-local/aaf/cadi.properties +++ /dev/null @@ -1,14 +0,0 @@ -## Location properties -## -## Localized Machine Information -## -cadi_loglevel=DEBUG -cadi_latitude=38.0 -cadi_longitude=-72.0 - -# Locate URL (which AAF Env) - Use lower case -aaf_locate_url=https://aafist.test.org:8095 -# AAF URL - Use upper case -aaf_url=https://AAF_LOCATE_URL/service:2.0 -# -cadi_prop_files=src/test/resources/bundleconfig-local/aaf/org.onap.aai.props diff --git a/aai-aaf-auth/src/test/resources/bundleconfig-local/aaf/org.onap.aai.props b/aai-aaf-auth/src/test/resources/bundleconfig-local/aaf/org.onap.aai.props deleted file mode 100644 index 3056e5f9..00000000 --- a/aai-aaf-auth/src/test/resources/bundleconfig-local/aaf/org.onap.aai.props +++ /dev/null @@ -1,4 +0,0 @@ -cm_url=cm_url -hostname=hostname -aaf_env=IST -cadi_x509_issuers=CN=AAF CADI Test Issuing CA 01, OU=CSO, O=CO, C=US:CN=AAF CADI Test Issuing CA 02, OU=CSO, O=CO, C=US
\ No newline at end of file diff --git a/aai-aaf-auth/src/test/resources/bundleconfig-local/etc/appprops/aaiconfig.properties b/aai-aaf-auth/src/test/resources/bundleconfig-local/etc/appprops/aaiconfig.properties deleted file mode 100644 index 0239e2ef..00000000 --- a/aai-aaf-auth/src/test/resources/bundleconfig-local/etc/appprops/aaiconfig.properties +++ /dev/null @@ -1,58 +0,0 @@ -# -# ============LICENSE_START======================================================= -# org.onap.aai -# ================================================================================ -# Copyright © 2017 AT&T Intellectual Property. All rights reserved. -# ================================================================================ -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# ============LICENSE_END========================================================= - -aai.config.checktime=1000 - -# this could come from siteconfig.pl? -aai.config.nodename=AutomaticallyOverwritten - -aai.transaction.logging=true -aai.transaction.logging.get=true -aai.transaction.logging.post=true - -aai.server.url.base=https://localhost:8443/aai/ -aai.server.url=https://localhost:8443/aai/v10/ -aai.oldserver.url.base=https://localhost:8443/aai/servers/ -aai.oldserver.url=https://localhost:8443/aai/servers/v2/ -aai.global.callback.url=https://localhost:8443/aai/ - -aai.notification.current.version=v10 -aai.notificationEvent.default.status=UNPROCESSED -aai.notificationEvent.default.eventType=AAI-EVENT -aai.notificationEvent.default.domain=devINT1 -aai.notificationEvent.default.sourceName=aai -aai.notificationEvent.default.sequenceNumber=0 -aai.notificationEvent.default.severity=NORMAL -aai.notificationEvent.default.version=v10 -# This one lets us enable/disable resource-version checking on updates/deletes -aai.resourceversion.enableflag=true -aai.default.api.version=v10 - -aai.example.passwd.x=OBF:1vn21ugu1saj1v9i1v941sar1ugw1vo0 -aai.example.string=hello -aai.example.int=7748 - -aai.realtime.clients=RO,SDNC,SO - -aai.jms.enable=false - -aai.rest.getall.depthparam=someuuid - -aaf.valid.issuer.wildcard=aaf wild card issuer|aafWildCardIssuer|OU=another - diff --git a/aai-aaf-auth/src/test/resources/bundleconfig-local/etc/appprops/error.properties b/aai-aaf-auth/src/test/resources/bundleconfig-local/etc/appprops/error.properties deleted file mode 100644 index 3a5671c2..00000000 --- a/aai-aaf-auth/src/test/resources/bundleconfig-local/etc/appprops/error.properties +++ /dev/null @@ -1,160 +0,0 @@ -# Adding comment trying to trigger a build -#------------------------------------------------------------------------------- ---------- -#Key=Disposition:Category:Severity:Error Code:HTTP ResponseCode:RESTError Code:Error Message -#------------------------------------------------------------------------------- ---------- -# testing code, please don't change unless error utility source code changes -AAI_TESTING=5:2:WARN:0000:400:0001:Error code for testing - -# General success -AAI_0000=0:0:INFO:0000:200:0000:Success - -# health check success -AAI_0001=0:0:INFO:0001:200:0001:Success X-FromAppId=%1 X-TransactionId=%2 -AAI_0002=0:0:INFO:0002:200:0001:Successful health check - -# Success with additional info -AAI_0003=0:3:INFO:0003:202:0003:Success with additional info performing %1 on %2. Added %3 with key %4 -AAI_0004=0:3:INFO:0004:202:0003:Added prerequisite object to db - -#--- aairest: 3000-3299 -# svc errors -AAI_3000=5:2:INFO:3000:400:3000:Invalid input performing %1 on %2 -AAI_3001=5:6:INFO:3001:404:3001:Resource not found for %1 using id %2 -AAI_3002=5:1:WARN:3002:400:3002:Error writing output performing %1 on %2 -AAI_3003=5:1:WARN:3003:400:3003:Failed to make edge to missing target node of type %3 with keys %4 performing %1 on %2 -AAI_3005=5:6:WARN:3005:404:3001:Node cannot be directly accessed for read, must be accessed via ancestor(s) -AAI_3006=5:6:WARN:3006:404:3001:Node cannot be directly accessed for write, must be accessed via ancestor(s) -AAI_3007=5:6:INFO:3007:410:3007:This version (%1) of the API is retired, please migrate to %2 -AAI_3008=5:6:ERROR:3008:400:3008:URI is not encoded in UTF-8 -AAI_3009=5:6:ERROR:3009:400:3002:Malformed URL -# pol errors -AAI_3100=5:1:WARN:3100:400:3100:Unsupported operation %1 -AAI_3101=5:1:WARN:3101:403:3101:Attempt by client %1 to execute API %2 -AAI_3102=5:1:WARN:3102:400:3102:Error parsing input performing %1 on %2 -AAI_3300=5:1:WARN:3300:403:3300:Unauthorized -AAI_3301=5:1:WARN:3301:401:3301:Stale credentials -AAI_3302=5:1:WARN:3302:401:3301:Not authenticated -AAI_3303=5:1:ERROR:3303:403:3300:Too many objects would be returned by this request, please refine your request and retry - -#--- aaigen: 4000-4099 -AAI_4000=5:4:ERROR:4000:500:3002:Internal Error -AAI_4001=5:4:FATAL:4001:500:3002:Configuration file not found -AAI_4002=5:4:FATAL:4002:500:3002:Error reading Configuration file -AAI_4003=5:4:ERROR:4003:500:3002:Error writing to log file -AAI_4004=5:4:FATAL:4004:500:3002:Error reading/parsing the error properties file -AAI_4005=5:4:FATAL:4005:500:3002:Missing or invalid configuration parameter -AAI_4006=5:4:FATAL:4006:500:3002:Unexpected error in service -AAI_4007=5:4:ERROR:4007:500:3102:Input parsing error -AAI_4008=5:4:ERROR:4008:500:3002:Output parsing error -AAI_4009=4:0:ERROR:4009:400:3000:Invalid X-FromAppId in header -AAI_4010=4:0:ERROR:4010:400:3000:Invalid X-TransactionId in header -AAI_4011=5:4:ERROR:4011:500:3002:Missing data for REST error response -AAI_4014=4:0:ERROR:4014:400:3000:Invalid Accept header -AAI_4015=4:0:ERROR:4015:400:3000:You must provide at least one indexed property -AAI_4016=4:0:ERROR:4016:400:3000:The depth parameter must be a number or the string "all" -AAI_4017=5:2:INFO:4017:400:3000:Could not set property -AAI_4018=5:2:ERROR:4018:400:3000:Unable to convert the string to integer -#--- aaidbmap: 5102-5199 -AAI_5102=5:4:FATAL:5102:500:3002:Graph database is null after open -AAI_5105=5:4:ERROR:5105:500:3002:Unexpected error reading/updating database -AAI_5106=5:4:WARN:5106:404:3001:Node not found -AAI_5107=5:2:WARN:5107:400:3000:Required information missing -AAI_5108=5:2:WARN:5108:200:0:Unexpected information in request being ignored - -#--- aaidbgen: 6101-6199 -AAI_6101=5:4:ERROR:6101:500:3002:null JanusGraph object passed -AAI_6102=5:4:WARN:6102:400:3000:Passed-in property is not valid for this nodeType -AAI_6103=5:4:WARN:6103:400:3000:Required Node-property not found in input data -AAI_6104=5:4:WARN:6104:400:3000:Required Node-property was passed with no data -AAI_6105=5:4:WARN:6105:400:3000:Node-Key-Property not defined in DbMaps -AAI_6106=5:4:WARN:6106:400:3000:Passed-in property is not valid for this edgeType -AAI_6107=5:4:WARN:6107:400:3000:Required Edge-property not found in input data -AAI_6108=5:4:WARN:6108:400:3000:Required Edge-property was passed with no data -AAI_6109=5:4:WARN:6109:400:3000:Bad dependent Node value -AAI_6110=5:4:ERROR:6110:400:3100:Node cannot be deleted -AAI_6111=5:4:ERROR:6111:400:3000:JSON processing error -AAI_6112=5:4:ERROR:6112:400:3000:More than one node found by getUniqueNode() -AAI_6114=5:4:INFO:6114:404:3001:Node Not Found -AAI_6115=5:4:ERROR:6115:400:3000:Unrecognized NodeType -AAI_6116=5:4:ERROR:6116:400:3000:Unrecognized Property -AAI_6117=5:4:ERROR:6117:400:3000:Uniqueness constraint violated -AAI_6118=5:4:ERROR:6118:400:3000:Required Field not passed. -AAI_6120=5:4:ERROR:6120:400:3000:Bad Parameter Passed -AAI_6121=5:4:ERROR:6121:400:3000:Problem with internal AAI reference data -AAI_6122=5:4:ERROR:6122:400:3000:Data Set not complete in DB for this request -AAI_6123=5:4:ERROR:6123:500:3000:Bad Data found by DataGrooming Tool - Investigate -AAI_6124=5:4:ERROR:6124:500:3000:File read/write error -AAI_6125=5:4:WARN:6125:500:3000:Problem Pulling Data Set -AAI_6126=5:4:ERROR:6126:400:3000:Edge cannot be deleted -AAI_6127=5:4:INFO:6127:404:3001:Edge Not Found -AAI_6128=5:4:INFO:6128:500:3000:Unexpected error -AAI_6129=5:4:INFO:6129:404:3003:Error making edge to target node -AAI_6130=5:4:WARN:6130:412:3000:Precondition Required -AAI_6131=5:4:WARN:6131:412:3000:Precondition Failed -AAI_6132=5:4:WARN:6132:400:3000:Bad Model Definition -AAI_6133=5:4:WARN:6133:400:3000:Bad Named Query Definition -AAI_6134=5:4:ERROR:6134:500:6134:Could not persist transaction to storage back end. Exhausted retry amount -AAI_6135=5:4:WARN:6135:412:3000:Resource version specified on create -AAI_6136=5:4:ERROR:6136:400:3000:Object cannot hold multiple items -AAI_6137=5:4:ERROR:6137:400:3000:Cannot perform writes on multiple vertices -AAI_6138=5:4:ERROR:6138:400:3000:Cannot delete multiple vertices -AAI_6139=5:4:ERROR:6139:404:3000:Attempted to add edge to vertex that does not exist -AAI_6140=5:4:ERROR:6140:400:3000:Edge multiplicity violated -AAI_6141=5:4:WARN:6141:400:3000:Please Refine Query -AAI_6142=5:4:INFO:6142:400:3000:Retrying transaction -AAI_6143=5:4:INFO:6143:400:3000:Ghost vertex found -AAI_6144=5:4:WARN:6144:400:3000:Cycle found in graph -AAI_6145=5:4:ERROR:6145:400:3000:Cannot create a nested/containment edge via relationship -AAI_6146=5:4:ERROR:6146:400:3000:Ambiguous identity map found, use a URI instead - -#--- aaicsvp: 7101-7199 -AAI_7101=5:4:ERROR:7101:500:3002:Unexpected error in CSV file processing -AAI_7102=5:4:ERROR:7102:500:3002:Error in cleanup temporary directory -#AAI_7103=4:2:ERROR:7103:500:3002:Unsupported user -AAI_7104=5:4:ERROR:7104:500:3002:Failed to create directory -AAI_7105=5:4:ERROR:7105:500:3002:Temporary directory exists -AAI_7106=5:4:ERROR:7106:500:3002:Cannot delete -AAI_7107=5:4:ERROR:7107:500:3002:Input file does not exist -AAI_7108=5:4:ERROR:7108:500:3002:Output file does not exist -AAI_7109=5:4:ERROR:7109:500:3002:Error closing file -AAI_7110=5:4:ERROR:7110:500:3002:Error loading/reading properties file -AAI_7111=5:4:ERROR:7111:500:3002:Error executing shell script -AAI_7112=5:4:ERROR:7112:500:3002:Error creating output file -AAI_7113=5:4:ERROR:7113:500:3002:Trailer record error -AAI_7114=5:4:ERROR:7114:500:3002:Input file error -AAI_7115=5:4:ERROR:7115:500:3002:Unexpected error -AAI_7116=5:4:ERROR:7116:500:3002:Request error -AAI_7117=5:4:ERROR:7117:500:3002:Error in get http client object -AAI_7118=5:4:ERROR:7118:500:3002:Script Error -AAI_7119=5:4:ERROR:7119:500:3002:Unknown host - -#--- aaisdnc: 7201-7299 -AAI_7202=5:4:ERROR:7202:500:3002:Error getting connection to odl -AAI_7203=5:4:ERROR:7203:500:3002:Unexpected error calling DataChangeNotification API -AAI_7204=5:4:ERROR:7204:500:3002:Error returned by DataChangeNotification API -AAI_7205=5:4:ERROR:7205:500:3002:Unexpected error running notifySDNCOnUpdate -AAI_7206=5:4:ERROR:7206:500:3002:Invalid data returned from ODL - -#--- NotificationEvent, using UEB space -AAI_7350=5:4:ERROR:7305:500:3002:Notification event creation failed - -#--- aairestctlr: 7401-7499 -AAI_7401=5:4:ERROR:7401:500:3002:Error connecting to AAI REST API -AAI_7402=5:4:ERROR:7402:500:3002:Unexpected error -AAI_7403=5:4:WARN:7403:400:3001:Request error -AAI_7404=5:4:INFO:7404:404:3001:Node not found -AAI_7405=5:4:WARN:7405:200:0:UUID not formatted correctly, generating UUID - -#--- aaiauth: 9101-9199 -AAI_9101=5:0:WARN:9101:403:3300:User is not authorized to perform function -AAI_9102=5:0:WARN:9102:401:3301:Refresh credentials from source -AAI_9103=5:0:WARN:9103:403:3300:User not found -AAI_9104=5:0:WARN:9104:401:3302:Authentication error -AAI_9105=5:0:WARN:9105:403:3300:Authorization error -AAI_9106=5:0:WARN:9106:403:3300:Invalid AppId -#AAI_9107=5:0:WARN:9107:403:3300:No Username in Request -AAI_9107=5:0:WARN:9107:403:3300:SSL is not provided in request, please contact admin - -#--- aaiinstar: 9201-9299 -AAI_9201=5:4:ERROR:9201:500:3002:Unable to send notification -AAI_9202=5:4:ERROR:9202:500:3002:Unable to start a thread diff --git a/aai-aaf-auth/src/test/resources/bundleconfig-local/etc/appprops/janusgraph-cached.properties b/aai-aaf-auth/src/test/resources/bundleconfig-local/etc/appprops/janusgraph-cached.properties deleted file mode 100644 index aa3c0631..00000000 --- a/aai-aaf-auth/src/test/resources/bundleconfig-local/etc/appprops/janusgraph-cached.properties +++ /dev/null @@ -1,36 +0,0 @@ -# -# ============LICENSE_START======================================================= -# org.onap.aai -# ================================================================================ -# Copyright © 2017-18 AT&T Intellectual Property. All rights reserved. -# ================================================================================ -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# ============LICENSE_END========================================================= - -query.fast-property=true -# the following parameters are not reloaded automatically and require a manual bounce -storage.backend=inmemory -storage.hostname=localhost - -#schema.default=none -storage.lock.wait-time=300 -storage.hbase.table=aaigraph-dev1.dev -storage.hbase.ext.zookeeper.znode.parent=/hbase-unsecure -#caching on -cache.db-cache = true -cache.db-cache-clean-wait = 20 -cache.db-cache-time = 180000 -cache.db-cache-size = 0.3 - -#load graphson file on startup -load.snapshot.file=false diff --git a/aai-aaf-auth/src/test/resources/bundleconfig-local/etc/appprops/janusgraph-realtime.properties b/aai-aaf-auth/src/test/resources/bundleconfig-local/etc/appprops/janusgraph-realtime.properties deleted file mode 100644 index 05394334..00000000 --- a/aai-aaf-auth/src/test/resources/bundleconfig-local/etc/appprops/janusgraph-realtime.properties +++ /dev/null @@ -1,33 +0,0 @@ -# -# ============LICENSE_START======================================================= -# org.onap.aai -# ================================================================================ -# Copyright © 2017-18 AT&T Intellectual Property. All rights reserved. -# ================================================================================ -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# ============LICENSE_END========================================================= - -query.fast-property=true -# the following parameters are not reloaded automatically and require a manual bounce -storage.backend=inmemory -storage.hostname=localhost - -#schema.default=none -storage.lock.wait-time=300 -storage.hbase.table=aaigraph-dev1.dev -storage.hbase.ext.zookeeper.znode.parent=/hbase-unsecure -# Setting db-cache to false ensure the fastest propagation of changes across servers -cache.db-cache = false - -#load graphson file on startup -load.snapshot.file=false diff --git a/aai-aaf-auth/src/test/resources/bundleconfig-local/etc/auth/aai_policy.json b/aai-aaf-auth/src/test/resources/bundleconfig-local/etc/auth/aai_policy.json deleted file mode 100644 index 9335a7bb..00000000 --- a/aai-aaf-auth/src/test/resources/bundleconfig-local/etc/auth/aai_policy.json +++ /dev/null @@ -1,73 +0,0 @@ -{ - "roles": [ - { - "name": "testRole", - "functions": [ - { - "name": "testFunction", - "methods": [ - { - "name": "GET" - }, - { - "name": "DELETE" - }, - { - "name": "PUT" - } - ] - } - ], - "users": [ - { - "username": "testUser" - }, - { - "username": "testWildcardId", - "is-wildcard-id": true - } - ] - }, - { - "name": "HAProxy", - "functions": [ - { - "name": "util", - "methods": [ - { - "name": "GET" - } - ] - } - ], - "users": [ - { - "username": "ha-proxy-user" - }, - { - "username": "ha-proxy-wildcard-id", - "is-wildcard-id": true - } - ] - }, - { - "name": "testBasicAuth", - "functions": [ - { - "name": "testBasicAuthFunction", - "methods": [ - { - "name": "GET" - } - ] - } - ], - "users": [ - { - "user": "testBasicAuthUser", - "pass": "OBF:1ytc1vu91v2p1rxf1mqh1v8s1z0d1msn1san1mqf1z0h1v9u1msl1rvf1v1p1vv11yta" - } - ] - } - ] -}
\ No newline at end of file diff --git a/aai-aaf-auth/src/test/resources/bundleconfig-local/etc/queryformarts/graphson/resource.graphson b/aai-aaf-auth/src/test/resources/bundleconfig-local/etc/queryformarts/graphson/resource.graphson deleted file mode 100644 index 04f48174..00000000 --- a/aai-aaf-auth/src/test/resources/bundleconfig-local/etc/queryformarts/graphson/resource.graphson +++ /dev/null @@ -1,2 +0,0 @@ -{"id": 386506928,"label": "vertex","properties": {"aai-last-mod-ts": [{"id": "ob632u-6e46nk-5j45","value": 1488308500413}],"aai-uri": [{"id": "ob6712-6e46nk-5lhh","value": "/cloud-infrastructure/cloud-regions/cloud-region/cloud-owner-987654321-9922-as988q/cloud-region-id-987654321-9922-as988q/tenants/tenant/tenant-987654321-9999-as988q/vservers/vserver/vserver-987654321-9999-as988q"}],"prov-status": [{"id": "ob651y-6e46nk-1kw5","value": "example-prov-status-val-7367"}],"aai-created-ts": [{"id": "ob62ae-6e46nk-5gqt","value": 1488308500413}],"source-of-truth": [{"id": "ob61w6-6e46nk-5jwl","value": "FitNesse-Test-as988q"}],"vserver-selflink": [{"id": "ob65g6-6e46nk-3xfp","value": "example-vserver-selflink-val-7367"}],"aai-node-type": [{"id": "ob61hy-6e46nk-5f5x","value": "vserver"}],"in-maint": [{"id": "ob65ue-6e46nk-20p1","value": false}],"resource-version": [{"id": "ob62om-6e46nk-23ut","value": "1488308500413"}],"vserver-name": [{"id": "ob649i-6e46nk-3u9x","value": "example-vserver-name-val-7367vserver-987654321-9999-as988q"}],"vserver-id": [{"id": "ob63va-6e46nk-3sp1","value": "vserver-987654321-9999-as988q"}],"last-mod-source-of-truth": [{"id": "ob63h2-6e46nk-5edh","value": "FitNesse-Test-as988q"}],"vserver-name2": [{"id": "ob64nq-6e46nk-3vut","value": "example-vserver-name2-val-7367"}],"is-closed-loop-disabled": [{"id": "ob668m-6e46nk-229x","value": false}]}} -{"id": 2461872,"label": "vertex","properties": {"aai-last-mod-ts": [{"id": "21hqu-1grlc-5j45","value": 1467901600}],"in-maint": [{"id": "21i52-1grlc-20p1","value": false}],"resource-version": [{"id": "21ija-1grlc-23ut","value": "1467901600"}],"vserver-name": [{"id": "21ixi-1grlc-3u9x","value": "PerfTest_VServerFix0027TenantPez002701611467901587187Name"}],"aai-created-ts": [{"id": "21jbq-1grlc-5gqt","value": 1467901600}],"vserver-id": [{"id": "21jpy-1grlc-3sp1","value": "PerfTest_VServerFix0027TenantPez002701611467901587187"}],"last-mod-source-of-truth": [{"id": "21k46-1grlc-5edh","value": "MSO"}],"vserver-name2": [{"id": "21kie-1grlc-3vut","value": "PerfTest_VServerFix0027TenantPez002701611467901587187-VM Name2 optional"}],"source-of-truth": [{"id": "21kwm-1grlc-5jwl","value": "MSO"}],"vserver-selflink": [{"id": "21lau-1grlc-3xfp","value": "http://testvserverLink.com/.html?vserv=VserverLink"}],"is-closed-loop-disabled": [{"id": "21lp2-1grlc-229x","value": false}],"aai-node-type": [{"id": "21m3a-1grlc-5f5x","value": "vserver"}],"aai-uri": [{"id": "21m3a-1grlc-5a5x","value": "/vservers/vserver/test1"}]}}
\ No newline at end of file diff --git a/aai-aaf-auth/src/test/resources/bundleconfig-local/etc/queryformarts/resource-format.json b/aai-aaf-auth/src/test/resources/bundleconfig-local/etc/queryformarts/resource-format.json deleted file mode 100644 index c7e42556..00000000 --- a/aai-aaf-auth/src/test/resources/bundleconfig-local/etc/queryformarts/resource-format.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "results": [ - { - "vserver": { - - } - }, - { - "vserver": { - } - } - ] -}
\ No newline at end of file diff --git a/aai-aaf-auth/src/test/resources/bundleconfig-local/etc/queryformarts/resource_and_url-format.json b/aai-aaf-auth/src/test/resources/bundleconfig-local/etc/queryformarts/resource_and_url-format.json deleted file mode 100644 index d90a71bc..00000000 --- a/aai-aaf-auth/src/test/resources/bundleconfig-local/etc/queryformarts/resource_and_url-format.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "results": [ - { - "url" : "/cloud-infrastructure/cloud-regions/cloud-region/cloud-owner-987654321-9922-as988q/cloud-region-id-987654321-9922-as988q/tenants/tenant/tenant-987654321-9999-as988q/vservers/vserver/vserver-987654321-9999-as988q", - "vserver": { - - } - }, - { - "url" : "/vservers/vserver/test1", - "vserver": { - - } - } - ] -}
\ No newline at end of file diff --git a/aai-aaf-auth/src/test/resources/bundleconfig-local/etc/queryformarts/simple-format.json b/aai-aaf-auth/src/test/resources/bundleconfig-local/etc/queryformarts/simple-format.json deleted file mode 100644 index dd342615..00000000 --- a/aai-aaf-auth/src/test/resources/bundleconfig-local/etc/queryformarts/simple-format.json +++ /dev/null @@ -1,43 +0,0 @@ -{ - "results" : [{ - "id" : "0", - "node-type" : "generic-vnf", - "url" : "urimissing", - "properties" : { - "vnf-name" : "myVnf" - }, - "related-to" : [{ - "node-type" : "vserver", - "id" : "1", - "url" : "urimissing" - }] - } , { - "id" : "1", - "node-type" : "vserver", - "url" : "urimissing", - "properties" : { - "vserver-name" : "myVserver" - }, - "related-to" : [{ - "node-type" : "generic-vnf", - "id" : "0", - "url" : "urimissing" - },{ - "node-type" : "pserver", - "id" : "2", - "url" : "/pservers/pserver/key1" - }] - },{ - "id" : "2", - "node-type" : "pserver", - "url" : "/pservers/pserver/key1", - "properties" : { - "hostname" : "myPserver" - }, - "related-to" : [{ - "node-type" : "vserver", - "id" : "1", - "url" : "urimissing" - }] - }] -}
\ No newline at end of file diff --git a/aai-aaf-auth/src/test/resources/bundleconfig-local/etc/relationship/ambiguous-relationship.json b/aai-aaf-auth/src/test/resources/bundleconfig-local/etc/relationship/ambiguous-relationship.json deleted file mode 100644 index c6407e2c..00000000 --- a/aai-aaf-auth/src/test/resources/bundleconfig-local/etc/relationship/ambiguous-relationship.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "related-to": "generic-vnf", - "relationship-data" : [{ - "relationship-key" : "generic-vnf.vnf-id", - "relationship-value":"key1" - },{ - "relationship-key" : "generic-vnf.vnf-id", - "relationship-value":"key2" - }] -}
\ No newline at end of file diff --git a/aai-aaf-auth/src/test/resources/bundleconfig-local/etc/relationship/both-failv10-successv9.json b/aai-aaf-auth/src/test/resources/bundleconfig-local/etc/relationship/both-failv10-successv9.json deleted file mode 100644 index 5bafc9ff..00000000 --- a/aai-aaf-auth/src/test/resources/bundleconfig-local/etc/relationship/both-failv10-successv9.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "related-to": "generic-vnf", - "related-link": "/aai/v10/network/generic-vnfs/test-objet/key1", - "relationship-data" : [{ - "relationship-key" : "generic-vnf.vnf-id", - "relationship-value":"key2" - }] -}
\ No newline at end of file diff --git a/aai-aaf-auth/src/test/resources/bundleconfig-local/etc/relationship/both-successv10-failv9.json b/aai-aaf-auth/src/test/resources/bundleconfig-local/etc/relationship/both-successv10-failv9.json deleted file mode 100644 index 3afe6bb7..00000000 --- a/aai-aaf-auth/src/test/resources/bundleconfig-local/etc/relationship/both-successv10-failv9.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "related-to": "generic-vnf", - "related-link": "http://localhost/aai/v10/network/generic-vnfs/generic-vnf/key1", - "relationship-data" : [{ - "relationship-key" : "test-obect.vnf-id", - "relationship-value":"key2" - }] -}
\ No newline at end of file diff --git a/aai-aaf-auth/src/test/resources/bundleconfig-local/etc/relationship/nothing-to-parse.json b/aai-aaf-auth/src/test/resources/bundleconfig-local/etc/relationship/nothing-to-parse.json deleted file mode 100644 index b24834af..00000000 --- a/aai-aaf-auth/src/test/resources/bundleconfig-local/etc/relationship/nothing-to-parse.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "related-to": "generic-vnf", - "relationship-data" : [] -}
\ No newline at end of file diff --git a/aai-aaf-auth/src/test/resources/bundleconfig-local/etc/relationship/only-related-link.json b/aai-aaf-auth/src/test/resources/bundleconfig-local/etc/relationship/only-related-link.json deleted file mode 100644 index 4cc103e8..00000000 --- a/aai-aaf-auth/src/test/resources/bundleconfig-local/etc/relationship/only-related-link.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "related-to": "generic-vnf", - "related-link": "http://localhost/aai/v10/network/generic-vnfs/generic-vnf/key1" -}
\ No newline at end of file diff --git a/aai-aaf-auth/src/test/resources/bundleconfig-local/etc/relationship/only-relationship-data.json b/aai-aaf-auth/src/test/resources/bundleconfig-local/etc/relationship/only-relationship-data.json deleted file mode 100644 index b9fccc9c..00000000 --- a/aai-aaf-auth/src/test/resources/bundleconfig-local/etc/relationship/only-relationship-data.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "related-to": "generic-vnf", - "relationship-data" : [{ - "relationship-key" : "generic-vnf.vnf-id", - "relationship-value":"key1" - }] -}
\ No newline at end of file diff --git a/aai-aaf-auth/src/test/resources/bundleconfig-local/etc/relationship/too-many-items-relationship.json b/aai-aaf-auth/src/test/resources/bundleconfig-local/etc/relationship/too-many-items-relationship.json deleted file mode 100644 index 97765cfb..00000000 --- a/aai-aaf-auth/src/test/resources/bundleconfig-local/etc/relationship/too-many-items-relationship.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "related-to": "l-interface", - "relationship-data" : [{ - "relationship-key" : "generic-vnf.vnf-id", - "relationship-value":"key1" - },{ - "relationship-key" : "subnet.subnet-id", - "relationship-value":"key5" - },{ - "relationship-key" : "vlan.vlan-interface", - "relationship-value":"key3" - },{ - "relationship-key" : "l-interface.interface-name", - "relationship-value":"key2" - },{ - "relationship-key" : "l3-interface-ipv4-address-list.l3-interface-ipv4-address", - "relationship-value":"key4" - }] -} diff --git a/aai-aaf-auth/src/test/resources/bundleconfig-local/etc/relationship/top-level-two-keys-relationship.json b/aai-aaf-auth/src/test/resources/bundleconfig-local/etc/relationship/top-level-two-keys-relationship.json deleted file mode 100644 index c6dbf557..00000000 --- a/aai-aaf-auth/src/test/resources/bundleconfig-local/etc/relationship/top-level-two-keys-relationship.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "related-to" : "availability-zone", - "relationship-data" : [ { - "relationship-key" : "cloud-region.cloud-owner", - "relationship-value" : "key1" - }, { - "relationship-key" : "cloud-region.cloud-region-id", - "relationship-value" : "key2" - }, { - "relationship-key" : "availability-zone.availability-zone-name", - "relationship-value" : "key3" - } ] -}
\ No newline at end of file diff --git a/aai-aaf-auth/src/test/resources/bundleconfig-local/etc/relationship/two-top-level-relationship.json b/aai-aaf-auth/src/test/resources/bundleconfig-local/etc/relationship/two-top-level-relationship.json deleted file mode 100644 index 54cac2c8..00000000 --- a/aai-aaf-auth/src/test/resources/bundleconfig-local/etc/relationship/two-top-level-relationship.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "related-to": "l-interface", - "relationship-data" : [{ - "relationship-key" : "generic-vnf.vnf-id", - "relationship-value":"key1" - },{ - "relationship-key" : "vlan.vlan-interface", - "relationship-value":"key3" - },{ - "relationship-key" : "l-interface.interface-name", - "relationship-value":"key2" - },{ - "relationship-key" : "zone.zone-id", - "relationship-value":"key5" - },{ - "relationship-key" : "l3-interface-ipv4-address-list.l3-interface-ipv4-address", - "relationship-value":"key4" - }] -} diff --git a/aai-annotations/.classpath b/aai-annotations/.classpath deleted file mode 100644 index 123ad540..00000000 --- a/aai-annotations/.classpath +++ /dev/null @@ -1,57 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<classpath> - <classpathentry kind="src" output="target/classes" path="src/main/java"> - <attributes> - <attribute name="optional" value="true"/> - <attribute name="maven.pomderived" value="true"/> - </attributes> - </classpathentry> - <classpathentry kind="src" output="target/test-classes" path="src/test/java"> - <attributes> - <attribute name="optional" value="true"/> - <attribute name="maven.pomderived" value="true"/> - <attribute name="test" value="true"/> - </attributes> - </classpathentry> - <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"> - <attributes> - <attribute name="maven.pomderived" value="true"/> - </attributes> - </classpathentry> - <classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER"> - <attributes> - <attribute name="maven.pomderived" value="true"/> - </attributes> - </classpathentry> - <classpathentry kind="src" path="target/generated-sources/annotations"> - <attributes> - <attribute name="optional" value="true"/> - <attribute name="maven.pomderived" value="true"/> - <attribute name="ignore_optional_problems" value="true"/> - <attribute name="m2e-apt" value="true"/> - </attributes> - </classpathentry> - <classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources"> - <attributes> - <attribute name="maven.pomderived" value="true"/> - <attribute name="optional" value="true"/> - </attributes> - </classpathentry> - <classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources"> - <attributes> - <attribute name="maven.pomderived" value="true"/> - <attribute name="test" value="true"/> - <attribute name="optional" value="true"/> - </attributes> - </classpathentry> - <classpathentry kind="src" output="target/test-classes" path="target/generated-test-sources/test-annotations"> - <attributes> - <attribute name="optional" value="true"/> - <attribute name="maven.pomderived" value="true"/> - <attribute name="ignore_optional_problems" value="true"/> - <attribute name="m2e-apt" value="true"/> - <attribute name="test" value="true"/> - </attributes> - </classpathentry> - <classpathentry kind="output" path="target/classes"/> -</classpath> diff --git a/aai-annotations/pom.xml b/aai-annotations/pom.xml index 9718c8cf..19567ef4 100644 --- a/aai-annotations/pom.xml +++ b/aai-annotations/pom.xml @@ -27,7 +27,7 @@ <parent> <groupId>org.onap.aai.aai-common</groupId> <artifactId>aai-parent</artifactId> - <version>1.14.6-SNAPSHOT</version> + <version>1.15.2-SNAPSHOT</version> <relativePath>../aai-parent/pom.xml</relativePath> </parent> <artifactId>aai-annotations</artifactId> diff --git a/aai-auth/pom.xml b/aai-auth/pom.xml index b766ffe7..13eaeeae 100644 --- a/aai-auth/pom.xml +++ b/aai-auth/pom.xml @@ -27,7 +27,7 @@ <parent> <groupId>org.onap.aai.aai-common</groupId> <artifactId>aai-parent</artifactId> - <version>1.14.6-SNAPSHOT</version> + <version>1.15.2-SNAPSHOT</version> <relativePath>../aai-parent/pom.xml</relativePath> </parent> <artifactId>aai-auth</artifactId> diff --git a/aai-common-docker/aai-common-images/pom.xml b/aai-common-docker/aai-common-images/pom.xml index a10bb127..c1beb781 100644 --- a/aai-common-docker/aai-common-images/pom.xml +++ b/aai-common-docker/aai-common-images/pom.xml @@ -25,11 +25,11 @@ <parent> <groupId>org.onap.aai.aai-common</groupId> <artifactId>aai-common-docker</artifactId> - <version>1.14.6-SNAPSHOT</version> + <version>1.15.2-SNAPSHOT</version> </parent> <artifactId>aai-common-images</artifactId> - <version>1.14.6-SNAPSHOT</version> + <version>1.15.2-SNAPSHOT</version> <packaging>pom</packaging> <name>aai-aai-common-images</name> <description>Contains dockerfiles for aai-common images (alpine and ubuntu based).</description> diff --git a/aai-common-docker/aai-haproxy-image/pom.xml b/aai-common-docker/aai-haproxy-image/pom.xml index bd2b3a45..e8048ba2 100644 --- a/aai-common-docker/aai-haproxy-image/pom.xml +++ b/aai-common-docker/aai-haproxy-image/pom.xml @@ -25,11 +25,11 @@ <parent> <groupId>org.onap.aai.aai-common</groupId> <artifactId>aai-common-docker</artifactId> - <version>1.14.6-SNAPSHOT</version> + <version>1.15.2-SNAPSHOT</version> </parent> <artifactId>aai-haproxy-image</artifactId> - <version>1.14.6-SNAPSHOT</version> + <version>1.15.2-SNAPSHOT</version> <packaging>pom</packaging> <name>aai-aai-haproxy-image</name> <description>Contains dockerfiles for aai-haproxy image.</description> diff --git a/aai-common-docker/pom.xml b/aai-common-docker/pom.xml index 8aaa8c57..b7cf7fbd 100644 --- a/aai-common-docker/pom.xml +++ b/aai-common-docker/pom.xml @@ -26,7 +26,7 @@ <parent> <groupId>org.onap.aai.aai-common</groupId> <artifactId>aai-parent</artifactId> - <version>1.14.6-SNAPSHOT</version> + <version>1.15.2-SNAPSHOT</version> <relativePath>../aai-parent/pom.xml</relativePath> </parent> diff --git a/aai-core/pom.xml b/aai-core/pom.xml index d2aed3a0..4ce7f76d 100644 --- a/aai-core/pom.xml +++ b/aai-core/pom.xml @@ -26,7 +26,7 @@ limitations under the License. <parent> <groupId>org.onap.aai.aai-common</groupId> <artifactId>aai-parent</artifactId> - <version>1.14.6-SNAPSHOT</version> + <version>1.15.2-SNAPSHOT</version> <relativePath>../aai-parent/pom.xml</relativePath> </parent> <artifactId>aai-core</artifactId> @@ -36,7 +36,6 @@ limitations under the License. <springframework.version>4.3.24.RELEASE</springframework.version> <jacoco.line.coverage.limit>0.50</jacoco.line.coverage.limit> - <groovy.version>2.5.15</groovy.version> <mockito.core.version>3.4.0</mockito.core.version> <!-- Start of Default ONAP Schema Properties --> <aai.wiki.link>https://wiki.onap.org/</aai.wiki.link> @@ -115,10 +114,6 @@ limitations under the License. </dependency> <dependency> <groupId>org.onap.aai.aai-common</groupId> - <artifactId>aai-aaf-auth</artifactId> - </dependency> - <dependency> - <groupId>org.onap.aai.aai-common</groupId> <artifactId>aai-annotations</artifactId> </dependency> <dependency> @@ -176,6 +171,11 @@ limitations under the License. <artifactId>guava</artifactId> </dependency> <dependency> + <groupId>org.glassfish</groupId> + <artifactId>javax.json</artifactId> + <version>1.1.4</version> + </dependency> + <dependency> <groupId>org.janusgraph</groupId> <artifactId>janusgraph-core</artifactId> <exclusions> @@ -213,16 +213,12 @@ limitations under the License. <artifactId>json-simple</artifactId> </dependency> <dependency> - <groupId>javax.xml.bind</groupId> - <artifactId>jaxb-api</artifactId> - </dependency> - <dependency> - <groupId>com.sun.xml.bind</groupId> - <artifactId>jaxb-impl</artifactId> + <groupId>jakarta.xml.bind</groupId> + <artifactId>jakarta.xml.bind-api</artifactId> </dependency> <dependency> - <groupId>com.sun.xml.bind</groupId> - <artifactId>jaxb-core</artifactId> + <groupId>org.glassfish.jaxb</groupId> + <artifactId>jaxb-runtime</artifactId> </dependency> <dependency> <groupId>org.eclipse.persistence</groupId> @@ -250,16 +246,12 @@ limitations under the License. <artifactId>jackson-module-jaxb-annotations</artifactId> </dependency> <dependency> - <groupId>com.sun.jersey</groupId> - <artifactId>jersey-core</artifactId> - </dependency> - <dependency> - <groupId>com.sun.jersey</groupId> + <groupId>org.glassfish.jersey.core</groupId> <artifactId>jersey-client</artifactId> </dependency> <dependency> - <groupId>com.sun.jersey</groupId> - <artifactId>jersey-json</artifactId> + <groupId>org.glassfish.jersey.media</groupId> + <artifactId>jersey-media-json-jackson</artifactId> </dependency> <dependency> <groupId>org.apache.tinkerpop</groupId> @@ -300,14 +292,6 @@ limitations under the License. <artifactId>logback-access</artifactId> </dependency> <dependency> - <groupId>org.apache.activemq</groupId> - <artifactId>activemq-broker</artifactId> - </dependency> - <dependency> - <groupId>org.apache.activemq</groupId> - <artifactId>activemq-openwire-legacy</artifactId> - </dependency> - <dependency> <groupId>org.freemarker</groupId> <artifactId>freemarker</artifactId> </dependency> @@ -316,12 +300,6 @@ limitations under the License. <artifactId>json-patch</artifactId> </dependency> <dependency> - <groupId>org.codehaus.groovy</groupId> - <artifactId>groovy</artifactId> - <version>${groovy.version}</version> - <classifier>indy</classifier> - </dependency> - <dependency> <groupId>org.springframework</groupId> <artifactId>spring-context</artifactId> </dependency> @@ -369,21 +347,6 @@ limitations under the License. <dependency> <groupId>org.apache.tinkerpop</groupId> <artifactId>gremlin-groovy</artifactId> - <exclusions> - <exclusion> - <groupId>org.codehaus.groovy</groupId> - <artifactId>groovy</artifactId> - </exclusion> - </exclusions> - </dependency> - <dependency> - <groupId>org.springframework</groupId> - <artifactId>spring-jms</artifactId> - </dependency> - <dependency> - <groupId>javax.jms</groupId> - <artifactId>javax.jms-api</artifactId> - <version>2.0.1</version> </dependency> <dependency> <groupId>com.fasterxml.jackson.core</groupId> @@ -414,14 +377,9 @@ limitations under the License. <dependency> <groupId>org.projectlombok</groupId> <artifactId>lombok</artifactId> - <version>1.18.30</version> + <version>1.18.34</version> <scope>provided</scope> </dependency> - <dependency> - <groupId>org.apache.commons</groupId> - <artifactId>commons-configuration2</artifactId> - <version>2.7</version> - </dependency> </dependencies> <!-- Plugins and repositories --> diff --git a/aai-core/src/main/java/org/onap/aai/concurrent/AaiCallable.java b/aai-core/src/main/java/org/onap/aai/concurrent/AaiCallable.java index 2703bdc4..9451e32e 100644 --- a/aai-core/src/main/java/org/onap/aai/concurrent/AaiCallable.java +++ b/aai-core/src/main/java/org/onap/aai/concurrent/AaiCallable.java @@ -35,7 +35,6 @@ public abstract class AaiCallable<T> implements Callable<T> { /** * The constructor. */ - @SuppressWarnings("unchecked") public AaiCallable() { mdcCopy = MDC.getCopyOfContextMap(); } diff --git a/aai-core/src/main/java/org/onap/aai/config/KafkaConfig.java b/aai-core/src/main/java/org/onap/aai/config/KafkaConfig.java new file mode 100644 index 00000000..7a81d9d2 --- /dev/null +++ b/aai-core/src/main/java/org/onap/aai/config/KafkaConfig.java @@ -0,0 +1,120 @@ +/** + * ============LICENSE_START======================================================= + * org.onap.aai + * ================================================================================ + * Copyright © 2024 Deutsche Telekom. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.aai.config; + +import java.util.Map; +import java.util.HashMap; + +import org.apache.kafka.clients.producer.ProducerConfig; +import org.apache.kafka.common.serialization.StringSerializer; +import org.onap.aai.domain.deltaEvent.DeltaEvent; +import org.onap.aai.domain.notificationEvent.NotificationEvent; +import org.onap.aai.kafka.DeltaProducer; +import org.onap.aai.kafka.DeltaProducerService; +import org.onap.aai.kafka.NotificationProducer; +import org.onap.aai.kafka.NotificationProducerService; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.kafka.core.DefaultKafkaProducerFactory; +import org.springframework.kafka.core.KafkaTemplate; +import org.springframework.kafka.core.ProducerFactory; +import org.springframework.kafka.support.serializer.JsonSerializer; + +@Configuration +public class KafkaConfig { + + private static final Logger logger = LoggerFactory.getLogger(KafkaConfig.class); + + @Value("${spring.kafka.producer.bootstrap-servers}") + private String bootstrapServers; + + @Value("${spring.kafka.producer.properties.security.protocol}") + private String securityProtocol; + + @Value("${spring.kafka.producer.properties.sasl.mechanism}") + private String saslMechanism; + + @Value("${spring.kafka.producer.properties.sasl.jaas.config:#{null}}") + private String saslJaasConfig; + + @Value("${spring.kafka.producer.retries:3}") + private String retries; + + private Map<String, Object> buildKafkaProperties() throws Exception { + Map<String, Object> props = new HashMap<>(); + if (bootstrapServers == null) { + logger.error("Environment Variable " + bootstrapServers + " is missing"); + throw new Exception("Environment Variable " + bootstrapServers + " is missing"); + } else { + props.put(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, bootstrapServers); + } + props.put(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG, JsonSerializer.class); + props.put(ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG, StringSerializer.class); + props.put(ProducerConfig.RETRIES_CONFIG, retries); + props.put(ProducerConfig.MAX_IN_FLIGHT_REQUESTS_PER_CONNECTION, "5"); + + if (saslJaasConfig == null) { + logger.info("Not using any authentication for kafka interaction"); + } else { + logger.info("Using authentication provided by kafka interaction"); + // Strimzi Kafka security properties + props.put("security.protocol", securityProtocol); + props.put("sasl.mechanism", saslMechanism); + props.put("sasl.jaas.config", saslJaasConfig); + } + return props; + } + + @Bean + public KafkaTemplate<String, NotificationEvent> kafkaNotificationEventTemplate(ProducerFactory<String, NotificationEvent> producerFactory) throws Exception { + return new KafkaTemplate<>(producerFactory); + } + + @Bean + public NotificationProducer notificationProducer(KafkaTemplate<String,NotificationEvent> kafkaTemplate) { + return new NotificationProducerService(kafkaTemplate); + } + + @Bean + public ProducerFactory<String, NotificationEvent> notificationEventProducerFactory() throws Exception { + Map<String, Object> props = buildKafkaProperties(); + return new DefaultKafkaProducerFactory<>(props); + } + + @Bean + public ProducerFactory<String, DeltaEvent> deltaEventProducerFactory() throws Exception { + Map<String, Object> props = buildKafkaProperties(); + return new DefaultKafkaProducerFactory<>(props); + } + + @Bean + public KafkaTemplate<String, DeltaEvent> kafkaDeltaEventTemplate(ProducerFactory<String, DeltaEvent> producerFactory) throws Exception { + return new KafkaTemplate<>(producerFactory); + } + + @Bean + public DeltaProducer deltaProducer(KafkaTemplate<String,DeltaEvent> kafkaTemplate) { + return new DeltaProducerService(kafkaTemplate); + } +} diff --git a/aai-core/src/main/java/org/onap/aai/config/RestBeanConfig.java b/aai-core/src/main/java/org/onap/aai/config/RestBeanConfig.java index c04e4e3c..3cc1719c 100644 --- a/aai-core/src/main/java/org/onap/aai/config/RestBeanConfig.java +++ b/aai-core/src/main/java/org/onap/aai/config/RestBeanConfig.java @@ -32,8 +32,19 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Scope; import org.springframework.web.context.annotation.RequestScope; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.module.jaxb.JaxbAnnotationModule; + @Configuration public class RestBeanConfig { + + @Bean + public ObjectMapper objectMapper() { + ObjectMapper objectMapper = new ObjectMapper(); + objectMapper.registerModule(new JaxbAnnotationModule()); + return objectMapper; + } + @Bean(name = "traversalUriHttpEntry") @Scope(scopeName = ConfigurableBeanFactory.SCOPE_PROTOTYPE) public HttpEntry traversalUriHttpEntry() { diff --git a/aai-core/src/main/java/org/onap/aai/dbgen/SchemaGenerator.java b/aai-core/src/main/java/org/onap/aai/dbgen/SchemaGenerator.java index 6430df50..055a70e3 100644 --- a/aai-core/src/main/java/org/onap/aai/dbgen/SchemaGenerator.java +++ b/aai-core/src/main/java/org/onap/aai/dbgen/SchemaGenerator.java @@ -26,12 +26,10 @@ import com.google.common.collect.Multimap; import java.util.ArrayList; import java.util.Collection; -import java.util.Collections; import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Map; -import java.util.Objects; import java.util.Optional; import java.util.Set; import java.util.concurrent.CompletableFuture; @@ -49,10 +47,10 @@ import org.janusgraph.core.PropertyKey; import org.janusgraph.core.schema.ConsistencyModifier; import org.janusgraph.core.schema.JanusGraphIndex; import org.janusgraph.core.schema.JanusGraphManagement; -import org.janusgraph.core.schema.JanusGraphManagement.IndexJobFuture; import org.janusgraph.core.schema.RelationTypeIndex; import org.janusgraph.core.schema.SchemaAction; import org.janusgraph.core.schema.SchemaStatus; +import org.janusgraph.diskstorage.keycolumnvalue.scan.ScanJobFuture; import org.janusgraph.graphdb.database.StandardJanusGraph; import org.janusgraph.graphdb.database.management.ManagementSystem; import org.janusgraph.graphdb.database.management.RelationIndexStatusReport; @@ -109,7 +107,7 @@ public class SchemaGenerator { final Map<String, Introspector> objs = LoaderUtil.getLatestVersion().getAllObjects(); final Map<String, PropertyKey> seenProps = new HashMap<>(); - + for (Introspector obj : objs.values()) { createSchemaForObject(graphMgmt, seenProps, obj); } @@ -340,7 +338,7 @@ public class SchemaGenerator { private static void awaitRelationIndexStatus(JanusGraph graph, Collection<String> labels, SchemaStatus newStatus) { LOGGER.info("Awaiting index status [{}]", newStatus);; CompletableFuture<RelationIndexStatusReport>[] awaits = labels.stream() - .map(label -> + .map(label -> CompletableFuture.supplyAsync(() -> { try { return ManagementSystem @@ -365,8 +363,8 @@ public class SchemaGenerator { private static void updateRelationIndexes(JanusGraph graph, Collection<String> labels, SchemaAction updateAction) { JanusGraphManagement graphMgmt = graph.openManagement(); - CompletableFuture<IndexJobFuture>[] awaits = labels.stream() - .map(label -> + CompletableFuture<ScanJobFuture>[] awaits = labels.stream() + .map(label -> CompletableFuture.supplyAsync(() -> { EdgeLabel relation = graphMgmt.getEdgeLabel(label); RelationTypeIndex index = graphMgmt.getRelationIndex(relation, label); @@ -398,7 +396,7 @@ public class SchemaGenerator { LOGGER.debug("Closing open transaction [{}] before schema generation", transaction.toString()); transaction.rollback(); }); - + final JanusGraphManagement graphMgtForClosing = graph.openManagement(); Set<String> instances = graphMgtForClosing.getOpenInstances(); diff --git a/aai-core/src/main/java/org/onap/aai/config/AuthorizationConfiguration.java b/aai-core/src/main/java/org/onap/aai/domain/deltaEvent/DeltaEvent.java index 24e7ec5a..b8c37744 100644 --- a/aai-core/src/main/java/org/onap/aai/config/AuthorizationConfiguration.java +++ b/aai-core/src/main/java/org/onap/aai/domain/deltaEvent/DeltaEvent.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * org.onap.aai * ================================================================================ - * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved. + * Copyright © 2024 Deutsche Telekom. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,23 +18,22 @@ * ============LICENSE_END========================================================= */ -package org.onap.aai.config; +package org.onap.aai.domain.deltaEvent; -import org.onap.aai.aaf.auth.AAIAuthCore; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.Profile; +import java.util.Collection; -@Profile("two-way-ssl") -@Configuration -public class AuthorizationConfiguration { +import org.onap.aai.domain.notificationEvent.NotificationEvent.EventHeader; +import org.onap.aai.util.delta.ObjectDelta; - @Value("${schema.uri.base.path}") - private String basePath; +import com.fasterxml.jackson.annotation.JsonProperty; - @Bean - public AAIAuthCore aaiAuthCore() { - return new AAIAuthCore(basePath); - } +import lombok.Data; + +@Data +public class DeltaEvent { + @JsonProperty("cambria.partition") + protected String cambriaPartition; + @JsonProperty("event-header") + protected EventHeader eventHeader; + Collection<ObjectDelta> entities; } diff --git a/aai-core/src/main/java/org/onap/aai/domain/notificationEvent/NotificationEvent.java b/aai-core/src/main/java/org/onap/aai/domain/notificationEvent/NotificationEvent.java index dad35669..e349009e 100644 --- a/aai-core/src/main/java/org/onap/aai/domain/notificationEvent/NotificationEvent.java +++ b/aai-core/src/main/java/org/onap/aai/domain/notificationEvent/NotificationEvent.java @@ -17,188 +17,35 @@ * limitations under the License. * ============LICENSE_END========================================================= */ -// -// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4-2 -// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> -// Any modifications to this file will be lost upon recompilation of the source schema. -// Generated on: 2016.01.06 at 05:38:00 PM EST -// - package org.onap.aai.domain.notificationEvent; import javax.xml.bind.annotation.*; -import org.w3c.dom.Element; +import com.fasterxml.jackson.annotation.JsonProperty; -/** - * <p> - * Java class for anonymous complex type. - * - * <p> - * The following schema fragment specifies the expected content contained within this class. - * - * <pre> - * <complexType> - * <complexContent> - * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType"> - * <sequence> - * <element name="cambria.partition" type="{http://www.w3.org/2001/XMLSchema}string"/> - * <element name="event-header" minOccurs="0"> - * <complexType> - * <complexContent> - * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType"> - * <sequence> - * <element name="id" type="{http://www.w3.org/2001/XMLSchema}string"/> - * <element name="timestamp" type="{http://www.w3.org/2001/XMLSchema}string"/> - * <element name="source-name" type="{http://www.w3.org/2001/XMLSchema}string"/> - * <element name="domain" type="{http://www.w3.org/2001/XMLSchema}string"/> - * <element name="sequence-number" type="{http://www.w3.org/2001/XMLSchema}string"/> - * <element name="severity" type="{http://www.w3.org/2001/XMLSchema}string"/> - * <element name="event-type" type="{http://www.w3.org/2001/XMLSchema}string"/> - * <element name="version" type="{http://www.w3.org/2001/XMLSchema}string"/> - * <element name="action" type="{http://www.w3.org/2001/XMLSchema}string"/> - * <element name="entity-type" type="{http://www.w3.org/2001/XMLSchema}string"/> - * <element name="top-entity-type" type="{http://www.w3.org/2001/XMLSchema}string"/> - * <element name="entity-link" type="{http://www.w3.org/2001/XMLSchema}string"/> - * <element name="status" type="{http://www.w3.org/2001/XMLSchema}string"/> - * </sequence> - * </restriction> - * </complexContent> - * </complexType> - * </element> - * <any processContents='lax' namespace='##other' minOccurs="0"/> - * </sequence> - * </restriction> - * </complexContent> - * </complexType> - * </pre> - * - * - */ +import lombok.Data; + +@Data @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "", propOrder = {"cambriaPartition", "eventHeader", "entity"}) @XmlRootElement(name = "NotificationEvent") public class NotificationEvent { @XmlElement(name = "cambria.partition") + @JsonProperty("cambria.partition") protected String cambriaPartition; @XmlElement(name = "event-header") + @JsonProperty("event-header") protected EventHeader eventHeader; @XmlAnyElement(lax = true) protected Object entity; - /** - * Gets the value of the eventHeader property. - * - * @return - * possible object is - * {@link EventHeader } - * - */ - public EventHeader getEventHeader() { - return eventHeader; - } - - /** - * Sets the value of the eventHeader property. - * - * @param value - * allowed object is - * {@link EventHeader } - * - */ - public void setEventHeader(EventHeader value) { - this.eventHeader = value; - } - - /** - * Gets the value of the any property. - * - * @return - * possible object is - * {@link Object } - * {@link Element } - * - */ - public Object getEntity() { - return entity; - } - - /** - * Sets the value of the any property. - * - * @param value - * allowed object is - * {@link Object } - * {@link Element } - * - */ - public void setEntity(Object value) { - this.entity = value; - } - - /** - * Gets the value of the cambriaPartition property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getCambriaPartition() { - return cambriaPartition; - } - - /** - * Sets the value of the cambriaPartition property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setCambriaPartition(String value) { - this.cambriaPartition = value; - } - - /** - * <p> - * Java class for anonymous complex type. - * - * <p> - * The following schema fragment specifies the expected content contained within this class. - * - * <pre> - * <complexType> - * <complexContent> - * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType"> - * <sequence> - * <element name="id" type="{http://www.w3.org/2001/XMLSchema}string"/> - * <element name="timestamp" type="{http://www.w3.org/2001/XMLSchema}string"/> - * <element name="source-name" type="{http://www.w3.org/2001/XMLSchema}string"/> - * <element name="domain" type="{http://www.w3.org/2001/XMLSchema}string"/> - * <element name="sequence-number" type="{http://www.w3.org/2001/XMLSchema}string"/> - * <element name="severity" type="{http://www.w3.org/2001/XMLSchema}string"/> - * <element name="event-type" type="{http://www.w3.org/2001/XMLSchema}string"/> - * <element name="version" type="{http://www.w3.org/2001/XMLSchema}string"/> - * <element name="action" type="{http://www.w3.org/2001/XMLSchema}string"/> - * <element name="entity-type" type="{http://www.w3.org/2001/XMLSchema}string"/> - * <element name="top-entity-type" type="{http://www.w3.org/2001/XMLSchema}string"/> - * <element name="entity-link" type="{http://www.w3.org/2001/XMLSchema}string"/> - * <element name="status" type="{http://www.w3.org/2001/XMLSchema}string"/> - * </sequence> - * </restriction> - * </complexContent> - * </complexType> - * </pre> - * - * - */ + @Data @XmlAccessorType(XmlAccessType.FIELD) @XmlType( name = "", propOrder = {"id", "timestamp", "sourceName", "domain", "sequenceNumber", "severity", "eventType", - "version", "action", "entityType", "topEntityType", "entityLink", "status"}) + "version", "action", "entityType", "topEntityType", "entityLink","entityUuid"}) public static class EventHeader { @XmlElement(required = true) @@ -206,340 +53,33 @@ public class NotificationEvent { @XmlElement(required = true) protected String timestamp; @XmlElement(name = "source-name", required = true) + @JsonProperty("source-name") protected String sourceName; @XmlElement(required = true) protected String domain; @XmlElement(name = "sequence-number", required = true) + @JsonProperty("sequence-number") protected String sequenceNumber; @XmlElement(required = true) protected String severity; @XmlElement(name = "event-type", required = true) + @JsonProperty("event-type") protected String eventType; @XmlElement(required = true) protected String version; @XmlElement(required = true) protected String action; @XmlElement(name = "entity-type", required = true) + @JsonProperty("entity-type") protected String entityType; @XmlElement(name = "top-entity-type", required = true) + @JsonProperty("top-entity-type") protected String topEntityType; @XmlElement(name = "entity-link", required = true) + @JsonProperty("entity-link") protected String entityLink; - @XmlElement(required = true) - protected String status; - - /** - * Gets the value of the id property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getId() { - return id; - } - - /** - * Sets the value of the id property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setId(String value) { - this.id = value; - } - - /** - * Gets the value of the timestamp property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getTimestamp() { - return timestamp; - } - - /** - * Sets the value of the timestamp property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setTimestamp(String value) { - this.timestamp = value; - } - - /** - * Gets the value of the sourceName property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getSourceName() { - return sourceName; - } - - /** - * Sets the value of the sourceName property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setSourceName(String value) { - this.sourceName = value; - } - - /** - * Gets the value of the domain property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getDomain() { - return domain; - } - - /** - * Sets the value of the domain property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setDomain(String value) { - this.domain = value; - } - - /** - * Gets the value of the sequenceNumber property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getSequenceNumber() { - return sequenceNumber; - } - - /** - * Sets the value of the sequenceNumber property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setSequenceNumber(String value) { - this.sequenceNumber = value; - } - - /** - * Gets the value of the severity property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getSeverity() { - return severity; - } - - /** - * Sets the value of the severity property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setSeverity(String value) { - this.severity = value; - } - - /** - * Gets the value of the eventType property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getEventType() { - return eventType; - } - - /** - * Sets the value of the eventType property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setEventType(String value) { - this.eventType = value; - } - - /** - * Gets the value of the version property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getVersion() { - return version; - } - - /** - * Sets the value of the version property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setVersion(String value) { - this.version = value; - } - - /** - * Gets the value of the action property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getAction() { - return action; - } - - /** - * Sets the value of the action property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setAction(String value) { - this.action = value; - } - - /** - * Gets the value of the entityType property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getEntityType() { - return entityType; - } - - /** - * Sets the value of the entityType property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setEntityType(String value) { - this.entityType = value; - } - - /** - * Gets the value of the topEntityType property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getTopEntityType() { - return topEntityType; - } - - /** - * Sets the value of the topEntityType property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setTopEntityType(String value) { - this.topEntityType = value; - } - - /** - * Gets the value of the entityLink property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getEntityLink() { - return entityLink; - } - - /** - * Sets the value of the entityLink property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setEntityLink(String value) { - this.entityLink = value; - } - - /** - * Gets the value of the status property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getStatus() { - return status; - } - - /** - * Sets the value of the status property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setStatus(String value) { - this.status = value; - } - + @JsonProperty("entity-uuid") + protected String entityUuid; } } diff --git a/aai-core/src/main/java/org/onap/aai/introspection/Introspector.java b/aai-core/src/main/java/org/onap/aai/introspection/Introspector.java index 87983d8d..cde99db4 100644 --- a/aai-core/src/main/java/org/onap/aai/introspection/Introspector.java +++ b/aai-core/src/main/java/org/onap/aai/introspection/Introspector.java @@ -20,6 +20,8 @@ package org.onap.aai.introspection; +import com.fasterxml.jackson.annotation.JsonRawValue; +import com.fasterxml.jackson.annotation.JsonValue; import com.google.common.base.CaseFormat; import java.io.UnsupportedEncodingException; @@ -620,6 +622,12 @@ public abstract class Introspector implements Cloneable { return marshal(properties); } + @JsonValue + @JsonRawValue + public String toString() { + return marshal(false); + } + public String makeSingular(String word) { String result = word; diff --git a/aai-core/src/main/java/org/onap/aai/introspection/sideeffect/SideEffect.java b/aai-core/src/main/java/org/onap/aai/introspection/sideeffect/SideEffect.java index bec46520..ce802c7a 100644 --- a/aai-core/src/main/java/org/onap/aai/introspection/sideeffect/SideEffect.java +++ b/aai-core/src/main/java/org/onap/aai/introspection/sideeffect/SideEffect.java @@ -136,7 +136,7 @@ public abstract class SideEffect { } private Optional<String> resolveRelativePath(Optional<String> populatedUri) throws UnsupportedEncodingException { - if (!populatedUri.isPresent()) { + if (populatedUri.isEmpty()) { return Optional.empty(); } else { return Optional.of(populatedUri.get().replaceFirst("\\./", this.serializer.getURIForVertex(self) + "/")); diff --git a/aai-core/src/main/java/org/onap/aai/kafka/AAIKafkaEventJMSConsumer.java b/aai-core/src/main/java/org/onap/aai/kafka/AAIKafkaEventJMSConsumer.java deleted file mode 100644 index 67f6842e..00000000 --- a/aai-core/src/main/java/org/onap/aai/kafka/AAIKafkaEventJMSConsumer.java +++ /dev/null @@ -1,133 +0,0 @@ -/** - * ============LICENSE_START======================================================= - * org.onap.aai - * ================================================================================ - * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Modifications Copyright © 2018 IBM. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.aai.kafka; - -import java.util.Map; - -import javax.jms.JMSException; -import javax.jms.Message; -import javax.jms.MessageListener; -import javax.jms.TextMessage; - -import org.json.JSONException; -import org.json.JSONObject; -import org.onap.aai.aailog.logs.AaiDmaapMetricLog; -import org.onap.aai.exceptions.AAIException; -import org.onap.aai.logging.AaiElsErrorCode; -import org.onap.aai.logging.ErrorLogHelper; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.slf4j.MDC; -import org.springframework.kafka.core.KafkaTemplate; - - -public class AAIKafkaEventJMSConsumer implements MessageListener { - - private static final String EVENT_TOPIC = "event-topic"; - - private static final Logger LOGGER = LoggerFactory.getLogger(AAIKafkaEventJMSConsumer.class); - - private Map<String, String> mdcCopy; - private final KafkaTemplate<String, String> kafkaTemplate; - - public AAIKafkaEventJMSConsumer(KafkaTemplate<String, String> kafkaTemplate) { - super(); - mdcCopy = MDC.getCopyOfContextMap(); - this.kafkaTemplate = kafkaTemplate; - } - - @Override - public void onMessage(Message message) { - - if (kafkaTemplate == null) { - return; - } - - String jmsMessageText = ""; - String aaiEvent = ""; - JSONObject aaiEventHeader; - JSONObject aaiEventPayload; - String transactionId = ""; - String serviceName = ""; - String topicName = ""; - String aaiElsErrorCode = AaiElsErrorCode.SUCCESS; - String errorDescription = ""; - - if (mdcCopy != null) { - MDC.setContextMap(mdcCopy); - } - - if (message instanceof TextMessage) { - AaiDmaapMetricLog metricLog = new AaiDmaapMetricLog(); - try { - jmsMessageText = ((TextMessage) message).getText(); - JSONObject jsonObject = new JSONObject(jmsMessageText); - if (jsonObject.has("aaiEventPayload")) { - aaiEventPayload = jsonObject.getJSONObject("aaiEventPayload"); - aaiEvent = aaiEventPayload.toString(); - } else { - return; - } - if (jsonObject.getString(EVENT_TOPIC) != null) { - topicName = jsonObject.getString(EVENT_TOPIC); - } - if (aaiEventPayload.has("event-header")) { - try { - aaiEventHeader = aaiEventPayload.getJSONObject("event-header"); - if (aaiEventHeader.has("id")) { - transactionId = aaiEventHeader.get("id").toString(); - } - if (aaiEventHeader.has("entity-link")) { - serviceName = aaiEventHeader.get("entity-link").toString(); - } - } catch (JSONException jexc) { - // ignore, this is just used for logging - } - } - metricLog.pre(topicName, aaiEvent, transactionId, serviceName); - - if ("AAI-EVENT".equals(topicName)) { - - kafkaTemplate.send(topicName, aaiEvent); - - } else { - LOGGER.error(String.format("%s|Event Topic invalid.", topicName)); - } - } catch (JMSException | JSONException e) { - aaiElsErrorCode = AaiElsErrorCode.DATA_ERROR; - errorDescription = e.getMessage(); - ErrorLogHelper.logException(new AAIException("AAI_7350")); - } catch (Exception e) { - e.printStackTrace(); - // LOGGER.error(); - LOGGER.error(e.getMessage()); - aaiElsErrorCode = AaiElsErrorCode.AVAILABILITY_TIMEOUT_ERROR; - errorDescription = e.getMessage(); - String errorMessage = String.format("Error processing message: %s, message payload: %s", e.getMessage(), jmsMessageText); - ErrorLogHelper.logException(new AAIException("AAI_7304", errorMessage)); - } finally { - metricLog.post(aaiElsErrorCode, errorDescription); - } - } - } -} diff --git a/aai-aaf-auth/src/test/java/org/onap/aai/aaf/auth/AAISetup.java b/aai-core/src/main/java/org/onap/aai/kafka/DeltaProducer.java index 3284d7a1..d1b74fd2 100644 --- a/aai-aaf-auth/src/test/java/org/onap/aai/aaf/auth/AAISetup.java +++ b/aai-core/src/main/java/org/onap/aai/kafka/DeltaProducer.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * org.onap.aai * ================================================================================ - * Copyright © 2017-2019 AT&T Intellectual Property. All rights reserved. + * Copyright © 2024 Deutsche Telekom. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,15 +18,12 @@ * ============LICENSE_END========================================================= */ -package org.onap.aai.aaf.auth; +package org.onap.aai.kafka; -import org.junit.BeforeClass; +import org.onap.aai.domain.deltaEvent.DeltaEvent; +import org.springframework.stereotype.Service; -public class AAISetup { - - @BeforeClass - public static void preSetup() { - System.setProperty("AJSC_HOME", "."); - System.setProperty("BUNDLECONFIG_DIR", "src/test/resources/bundleconfig-local"); - } +@Service +public interface DeltaProducer { + public void sendNotification(DeltaEvent notificationEvent); } diff --git a/aai-core/src/main/java/org/onap/aai/kafka/AAIKafkaEventJMSProducer.java b/aai-core/src/main/java/org/onap/aai/kafka/DeltaProducerService.java index 4e948772..bdf02316 100644 --- a/aai-core/src/main/java/org/onap/aai/kafka/AAIKafkaEventJMSProducer.java +++ b/aai-core/src/main/java/org/onap/aai/kafka/DeltaProducerService.java @@ -2,15 +2,13 @@ * ============LICENSE_START======================================================= * org.onap.aai * ================================================================================ - * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Modifications Copyright © 2018 IBM. + * Copyright © 2024 Deutsche Telekom. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, @@ -22,27 +20,25 @@ package org.onap.aai.kafka; -import org.json.JSONObject; +import org.onap.aai.domain.deltaEvent.DeltaEvent; import org.springframework.beans.factory.annotation.Value; -import org.springframework.jms.core.JmsTemplate; +import org.springframework.kafka.core.KafkaTemplate; import org.springframework.stereotype.Service; import lombok.RequiredArgsConstructor; @Service @RequiredArgsConstructor -public class AAIKafkaEventJMSProducer implements MessageProducer { - - @Value("${aai.events.enabled:true}") private boolean eventsEnabled; - private final JmsTemplate jmsTemplate; +public class DeltaProducerService implements DeltaProducer { - public void sendMessageToDefaultDestination(String msg) { - if (eventsEnabled) { - jmsTemplate.convertAndSend(msg); - } - } + private final KafkaTemplate<String,DeltaEvent> kafkaTemplate; + @Value("${aai.notifications.enabled:true}") + boolean notificationsEnabled; - public void sendMessageToDefaultDestination(JSONObject finalJson) { - sendMessageToDefaultDestination(finalJson.toString()); + @Override + public void sendNotification(DeltaEvent deltaEvent) { + if(notificationsEnabled) { + kafkaTemplate.send("DELTA", deltaEvent); } + } } diff --git a/aai-core/src/main/java/org/onap/aai/kafka/MessageProducer.java b/aai-core/src/main/java/org/onap/aai/kafka/MessageProducer.java index d6a491ef..09fc68a2 100644 --- a/aai-core/src/main/java/org/onap/aai/kafka/MessageProducer.java +++ b/aai-core/src/main/java/org/onap/aai/kafka/MessageProducer.java @@ -22,6 +22,12 @@ package org.onap.aai.kafka; import org.json.JSONObject; +/** + * MessageProducer interface based on untyped messages + * + * @deprecated use {@link org.onap.aai.kafka.NotificationProducer} instead + */ +@Deprecated public interface MessageProducer { void sendMessageToDefaultDestination(JSONObject finalJson); diff --git a/aai-aaf-auth/src/main/java/org/onap/aai/aaf/filters/AafProfiles.java b/aai-core/src/main/java/org/onap/aai/kafka/NotificationProducer.java index e87dc4a5..3c739174 100644 --- a/aai-aaf-auth/src/main/java/org/onap/aai/aaf/filters/AafProfiles.java +++ b/aai-core/src/main/java/org/onap/aai/kafka/NotificationProducer.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * org.onap.aai * ================================================================================ - * Copyright © 2017-2019 AT&T Intellectual Property. All rights reserved. + * Copyright © 2024 Deutsche Telekom. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,18 +18,14 @@ * ============LICENSE_END========================================================= */ -package org.onap.aai.aaf.filters; +package org.onap.aai.kafka; -public class AafProfiles { +import org.onap.aai.domain.notificationEvent.NotificationEvent; +import org.onap.aai.rest.notification.UEBNotification; +import org.springframework.stereotype.Service; - // AAF Basic Auth - public static final String AAF_AUTHENTICATION = "aaf-auth"; - - // AAF Auth with Client Certs - public static final String AAF_CERT_AUTHENTICATION = "aaf-cert-auth"; - - public static final String TWO_WAY_SSL = "two-way-ssl"; - - private AafProfiles() { - } +@Service +public interface NotificationProducer { + public void sendNotification(NotificationEvent notificationEvent); + public void sendUEBNotification(UEBNotification uebNotification); } diff --git a/aai-core/src/main/java/org/onap/aai/kafka/NotificationProducerService.java b/aai-core/src/main/java/org/onap/aai/kafka/NotificationProducerService.java new file mode 100644 index 00000000..44a03ba1 --- /dev/null +++ b/aai-core/src/main/java/org/onap/aai/kafka/NotificationProducerService.java @@ -0,0 +1,48 @@ +/** + * ============LICENSE_START======================================================= + * org.onap.aai + * ================================================================================ + * Copyright © 2024 Deutsche Telekom. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.aai.kafka; + +import org.onap.aai.domain.notificationEvent.NotificationEvent; +import org.onap.aai.rest.notification.UEBNotification; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.kafka.core.KafkaTemplate; +import org.springframework.stereotype.Service; + +import lombok.RequiredArgsConstructor; + +@Service +@RequiredArgsConstructor +public class NotificationProducerService implements NotificationProducer { + + private final KafkaTemplate<String,NotificationEvent> kafkaTemplate; + @Value("${aai.notifications.enabled:true}") boolean notificationsEnabled; + + public void sendNotification(NotificationEvent notificationEvent) { + if(notificationsEnabled) { + kafkaTemplate.send("AAI-EVENT", notificationEvent); + } + } + + public void sendUEBNotification(UEBNotification uebNotification) { + uebNotification.getEvents().stream() + .forEach(this::sendNotification); + } +} diff --git a/aai-core/src/main/java/org/onap/aai/parsers/relationship/RelationshipToURI.java b/aai-core/src/main/java/org/onap/aai/parsers/relationship/RelationshipToURI.java index 95b1517d..af9d8aa1 100644 --- a/aai-core/src/main/java/org/onap/aai/parsers/relationship/RelationshipToURI.java +++ b/aai-core/src/main/java/org/onap/aai/parsers/relationship/RelationshipToURI.java @@ -112,12 +112,12 @@ public class RelationshipToURI { try { if (loader.getVersion().compareTo(schemaVersions.getRelatedLinkVersion()) >= 0) { result = processRelatedLink(relatedLink); - if (!result.isPresent()) { + if (result.isEmpty()) { result = processRelationshipData(); } } else { result = processRelationshipData(); - if (!result.isPresent()) { + if (result.isEmpty()) { result = processRelatedLink(relatedLink); } } diff --git a/aai-core/src/main/java/org/onap/aai/parsers/uri/URIToObject.java b/aai-core/src/main/java/org/onap/aai/parsers/uri/URIToObject.java index 186f2ee9..11a028bf 100644 --- a/aai-core/src/main/java/org/onap/aai/parsers/uri/URIToObject.java +++ b/aai-core/src/main/java/org/onap/aai/parsers/uri/URIToObject.java @@ -24,6 +24,7 @@ import java.io.UnsupportedEncodingException; import java.net.URI; import java.util.HashMap; import java.util.List; +import java.util.Map; import javax.ws.rs.core.MultivaluedMap; @@ -37,27 +38,21 @@ import org.onap.aai.setup.SchemaVersion; /** * Given a URI this class returns an object, or series of nested objects * with their keys populated based off the values in the URI. - * + * * It populates the keys in the order they are listed in the model. */ public class URIToObject implements Parsable { + private final SchemaVersion version; + private final Loader loader; + private final Map<String, Introspector> relatedObjects; private Introspector topEntity = null; - private String topEntityName = null; - private String entityName = null; - private Introspector entity = null; - private Introspector previous = null; - private List<Object> parentList = null; - private SchemaVersion version = null; - private Loader loader = null; - private final HashMap<String, Introspector> relatedObjects; - /** * Instantiates a new URI to object. * @@ -77,7 +72,7 @@ public class URIToObject implements Parsable { this.version = loader.getVersion(); } - public URIToObject(Loader loader, URI uri, HashMap<String, Introspector> relatedObjects) + public URIToObject(Loader loader, URI uri, Map<String, Introspector> relatedObjects) throws AAIException, UnsupportedEncodingException { URIParser parser = new URIParser(loader, uri); diff --git a/aai-core/src/main/java/org/onap/aai/prevalidation/ValidationService.java b/aai-core/src/main/java/org/onap/aai/prevalidation/ValidationService.java index 093062a9..9d8f5fdb 100644 --- a/aai-core/src/main/java/org/onap/aai/prevalidation/ValidationService.java +++ b/aai-core/src/main/java/org/onap/aai/prevalidation/ValidationService.java @@ -22,8 +22,8 @@ package org.onap.aai.prevalidation; -import com.google.gson.Gson; -import com.google.gson.JsonSyntaxException; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; import java.net.ConnectException; import java.net.SocketTimeoutException; @@ -41,9 +41,10 @@ import java.util.stream.Collectors; import javax.annotation.PostConstruct; import org.apache.http.conn.ConnectTimeoutException; +import org.onap.aai.domain.notificationEvent.NotificationEvent; +import org.onap.aai.domain.notificationEvent.NotificationEvent.EventHeader; import org.onap.aai.exceptions.AAIException; -import org.onap.aai.introspection.Introspector; -import org.onap.aai.rest.notification.NotificationEvent; + import org.onap.aai.restclient.RestClient; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -74,22 +75,19 @@ public class ValidationService { static final String VALIDATION_HEALTH_ENDPOINT = "/v1/info"; private static final Logger LOGGER = LoggerFactory.getLogger(ValidationService.class); - private static final String ENTITY_TYPE = "entity-type"; - private static final String ACTION = "action"; - private static final String SOURCE_NAME = "source-name"; private static final String DELETE = "DELETE"; private final RestClient validationRestClient; private final String appName; private final Set<String> validationNodeTypes; - private final Gson gson; - - private List<Pattern> exclusionList; + private final ObjectMapper mapper; + private final List<Pattern> exclusionList; public ValidationService(@Qualifier("validationRestClient") RestClient validationRestClient, @Value("${spring.application.name}") String appName, @Value("${validation.service.node-types}") String validationNodes, - @Value("${validation.service.exclusion-regexes:#{null}}") String exclusionRegexes) { + @Value("${validation.service.exclusion-regexes:#{null}}") String exclusionRegexes, + ObjectMapper mapper) { this.validationRestClient = validationRestClient; this.appName = appName; @@ -101,7 +99,7 @@ public class ValidationService { this.exclusionList = Arrays.stream(exclusionRegexes.split(",")).map(Pattern::compile).collect(Collectors.toList()); } - this.gson = new Gson(); + this.mapper = mapper; LOGGER.info("Successfully initialized the pre validation service"); } @@ -119,7 +117,7 @@ public class ValidationService { ResponseEntity<String> healthCheckResponse = null; try { healthCheckResponse = - validationRestClient.execute(VALIDATION_HEALTH_ENDPOINT, HttpMethod.GET, httpHeaders, null); + validationRestClient.execute(VALIDATION_HEALTH_ENDPOINT, HttpMethod.GET, httpHeaders); } catch (Exception ex) { AAIException validationException = new AAIException("AAI_4021", ex); throw validationException; @@ -142,7 +140,7 @@ public class ValidationService { } for (NotificationEvent event : notificationEvents) { - Introspector eventHeader = event.getEventHeader(); + EventHeader eventHeader = event.getEventHeader(); if (eventHeader == null) { // Should I skip processing the request and let it continue // or fail the request and cause client impact @@ -156,10 +154,10 @@ public class ValidationService { if (isDelete(eventHeader)) { continue; } - String entityType = eventHeader.getValue(ENTITY_TYPE); + String entityType = eventHeader.getEntityType(); if (this.shouldValidate(entityType)) { - List<String> violations = preValidate(event.getNotificationEvent()); + List<String> violations = preValidate(event); if (!violations.isEmpty()) { AAIException aaiException = new AAIException("AAI_4019"); aaiException.getTemplateVars().addAll(violations); @@ -172,8 +170,8 @@ public class ValidationService { /** * Determine if event is of type delete */ - private boolean isDelete(Introspector eventHeader) { - String action = eventHeader.getValue(ACTION); + private boolean isDelete(EventHeader eventHeader) { + String action = eventHeader.getAction(); return DELETE.equalsIgnoreCase(action); } @@ -186,15 +184,15 @@ public class ValidationService { // Get the first notification and if the source of that notification // is in one of the regexes then we skip sending it to validation NotificationEvent notification = notificationEvents.get(0); - Introspector eventHeader = notification.getEventHeader(); + EventHeader eventHeader = notification.getEventHeader(); if (eventHeader != null) { - String source = eventHeader.getValue(SOURCE_NAME); + String source = eventHeader.getSourceName(); return exclusionList.stream().anyMatch(pattern -> pattern.matcher(source).matches()); } return false; } - public List<String> preValidate(String body) throws AAIException { + public List<String> preValidate(NotificationEvent notificationEvent) throws AAIException { Map<String, String> httpHeaders = new HashMap<>(); httpHeaders.put("X-FromAppId", appName); httpHeaders.put("X-TransactionID", UUID.randomUUID().toString()); @@ -203,7 +201,8 @@ public class ValidationService { List<String> violations = new ArrayList<>(); ResponseEntity<String> responseEntity; try { - responseEntity = validationRestClient.execute(VALIDATION_ENDPOINT, HttpMethod.POST, httpHeaders, body); + String requestBody = mapper.writeValueAsString(notificationEvent); + responseEntity = validationRestClient.execute(VALIDATION_ENDPOINT, HttpMethod.POST, httpHeaders, requestBody); Object responseBody = responseEntity.getBody(); if (isSuccess(responseEntity)) { LOGGER.debug("Validation Service returned following response status code {} and body {}", @@ -242,8 +241,8 @@ public class ValidationService { private Validation getValidation(Object responseBody) { Validation validation = null; try { - validation = gson.fromJson(responseBody.toString(), Validation.class); - } catch (JsonSyntaxException jsonException) { + validation = mapper.readValue(responseBody.toString(), Validation.class); + } catch (JsonProcessingException jsonException) { LOGGER.warn("Unable to convert the response body {}", jsonException.getMessage()); } return validation; diff --git a/aai-core/src/main/java/org/onap/aai/query/builder/GraphTraversalBuilder.java b/aai-core/src/main/java/org/onap/aai/query/builder/GraphTraversalBuilder.java index 10f5cbaf..4ea0c074 100644 --- a/aai-core/src/main/java/org/onap/aai/query/builder/GraphTraversalBuilder.java +++ b/aai-core/src/main/java/org/onap/aai/query/builder/GraphTraversalBuilder.java @@ -30,10 +30,11 @@ import java.util.Arrays; import java.util.Collections; import java.util.List; import java.util.Map; +import java.util.NoSuchElementException; import java.util.Optional; import java.util.Set; -import org.apache.tinkerpop.gremlin.groovy.jsr223.GroovyTranslator; +import org.apache.tinkerpop.gremlin.process.traversal.translator.GroovyTranslator; import org.apache.tinkerpop.gremlin.process.traversal.Order; import org.apache.tinkerpop.gremlin.process.traversal.P; import org.apache.tinkerpop.gremlin.process.traversal.Path; @@ -519,7 +520,7 @@ public abstract class GraphTraversalBuilder<E> extends QueryBuilder<E> { @Override public QueryBuilder<E> store(String name) { - this.traversal.store(name); + this.traversal.aggregate(Scope.local , name); stepIndex++; return this; @@ -1028,7 +1029,7 @@ public abstract class GraphTraversalBuilder<E> extends QueryBuilder<E> { try { return mapPaginationResult((Map<String,Object>) completeTraversal.next()); // .next() will throw an IllegalArguementException if there are no vertices of the given type - } catch (IllegalArgumentException e) { + } catch (NoSuchElementException | IllegalArgumentException e) { return new PaginationResult<>(Collections.emptyList(), 0L); } } diff --git a/aai-core/src/main/java/org/onap/aai/rest/db/HttpEntry.java b/aai-core/src/main/java/org/onap/aai/rest/db/HttpEntry.java index 94dc63aa..c481e2cd 100644 --- a/aai-core/src/main/java/org/onap/aai/rest/db/HttpEntry.java +++ b/aai-core/src/main/java/org/onap/aai/rest/db/HttpEntry.java @@ -130,7 +130,7 @@ public class HttpEntry { this.dbEngine = new JanusGraphDBEngine(queryStyle, loader); getDbEngine().startTransaction(); - this.notification = new UEBNotification(loader, loaderFactory, schemaVersions); + this.notification = new UEBNotification(loaderFactory, schemaVersions); if ("true".equals(AAIConfig.get("aai.notification.depth.all.enabled", "true"))) { this.notificationDepth = AAIProperties.MAXIMUM_DEPTH; } else { @@ -196,7 +196,6 @@ public class HttpEntry { Set<String> groups, boolean enableResourceVersion, QueryOptions queryOptions) throws AAIException { DBSerializer serializer = null; - if (serverBase != null) { serializer = new DBSerializer(version, dbEngine, introspectorFactoryType, sourceOfTruth, groups, notificationDepth, serverBase); @@ -205,45 +204,29 @@ public class HttpEntry { notificationDepth); } - Response response; - Introspector obj; - QueryParser query; - URI uri; - String transactionId = null; - int depth; - Format format = null; - List<Pair<URI, Response>> responses = new ArrayList<>(); - MultivaluedMap<String, String> params; - HttpMethod method; - String uriTemp; - boolean success = true; - QueryEngine queryEngine = dbEngine.getQueryEngine(); Set<Vertex> mainVertexesToNotifyOn = new LinkedHashSet<>(); - AaiDBMetricLog metricLog = new AaiDBMetricLog(AAIConstants.AAI_RESOURCES_MS); String outputMediaType = null; - if (requests != null && !requests.isEmpty()) { HttpHeaders headers = requests.get(0).getHeaders(); outputMediaType = getMediaType(headers.getAcceptableMediaTypes()); } + String transactionId = requests.get(0).getTransactionId(); + boolean success = true; + QueryEngine queryEngine = dbEngine.getQueryEngine(); + List<Pair<URI, Response>> responses = new ArrayList<>(); for (DBRequest request : requests) { - response = null; + Response response = null; Status status = Status.NOT_FOUND; - method = request.getMethod(); + HttpMethod method = request.getMethod(); metricLog.pre(request); try { try { + String uriTemp = request.getUri().getRawPath().replaceFirst("^v\\d+/", ""); - obj = request.getIntrospector(); - query = request.getParser(); - transactionId = request.getTransactionId(); - uriTemp = request.getUri().getRawPath().replaceFirst("^v\\d+/", ""); - uri = UriBuilder.fromPath(uriTemp).build(); - - boolean groupsAvailable = serializer.getGroups() != null && !serializer.getGroups().isEmpty(); + QueryParser query = request.getParser(); List<Vertex> queryResult; PaginationResult<Vertex> paginationResult = null; if(queryOptions != null && queryOptions.getPageable() != null) { @@ -253,28 +236,22 @@ public class HttpEntry { queryResult = executeQuery(query, queryOptions); } + boolean groupsAvailable = serializer.getGroups() != null && !serializer.getGroups().isEmpty(); List<Vertex> vertices = groupsAvailable ? queryResult.stream() .filter(vertex -> OwnerCheck.isAuthorized(groups, vertex)) .collect(Collectors.toList()) : queryResult; - boolean isNewVertex; - HttpHeaders headers = request.getHeaders(); - outputMediaType = getMediaType(headers.getAcceptableMediaTypes()); - String result = null; - params = request.getInfo().getQueryParameters(false); - depth = setDepth(obj, params.getFirst("depth")); + MultivaluedMap<String, String> params = request.getInfo().getQueryParameters(false); + Introspector obj = request.getIntrospector(); + int depth = setDepth(obj, params.getFirst("depth")); + Format format = null; if (params.containsKey("format")) { format = Format.getFormat(params.getFirst("format")); } - String cleanUp = params.getFirst("cleanup"); - String requestContext = ""; - List<String> requestContextList = request.getHeaders().getRequestHeader("aai-request-context"); - if (requestContextList != null) { - requestContext = requestContextList.get(0); - } + String cleanUp = params.getFirst("cleanup"); if (cleanUp == null) { cleanUp = "false"; } @@ -287,6 +264,7 @@ public class HttpEntry { throw new AAIException("AAI_6137"); } } + boolean isNewVertex; if (method.equals(HttpMethod.PUT)) { String resourceVersion = obj.getValue(AAIProperties.RESOURCE_VERSION); if (vertices.isEmpty()) { @@ -337,6 +315,16 @@ public class HttpEntry { HashMap<String, Introspector> relatedObjects = new HashMap<>(); String nodeOnly = params.getFirst("nodes-only"); boolean isNodeOnly = nodeOnly != null; + + String requestContext = ""; + List<String> requestContextList = request.getHeaders().getRequestHeader("aai-request-context"); + if (requestContextList != null) { + requestContext = requestContextList.get(0); + } + URI uri = UriBuilder.fromPath(uriTemp).build(); + HttpHeaders headers = request.getHeaders(); + outputMediaType = getMediaType(headers.getAcceptableMediaTypes()); + String result = null; switch (method) { case GET: @@ -384,7 +372,7 @@ public class HttpEntry { if (obj != null) { status = Status.OK; MarshallerProperties properties; - if (!request.getMarshallerProperties().isPresent()) { + if (request.getMarshallerProperties().isEmpty()) { properties = new MarshallerProperties.Builder( org.onap.aai.restcore.MediaType.getEnum(outputMediaType)).build(); } else { diff --git a/aai-core/src/main/java/org/onap/aai/rest/notification/EntityConverter.java b/aai-core/src/main/java/org/onap/aai/rest/notification/EntityConverter.java new file mode 100644 index 00000000..e939f323 --- /dev/null +++ b/aai-core/src/main/java/org/onap/aai/rest/notification/EntityConverter.java @@ -0,0 +1,66 @@ +/** + * ============LICENSE_START======================================================= + * org.onap.aai + * ================================================================================ + * Copyright © 2024 Deutsche Telekom. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.aai.rest.notification; + +import java.util.List; + +import org.onap.aai.introspection.Introspector; +import org.onap.aai.introspection.exceptions.AAIUnmarshallingException; +import org.onap.aai.parsers.uri.URIToObject; + +import lombok.Value; + +@Value +public class EntityConverter { + + final URIToObject parser; + + public Introspector convert(Introspector obj) throws AAIUnmarshallingException { + List<Object> parentList = parser.getParentList(); + parentList.clear(); + + if (!parser.getTopEntity().equals(parser.getEntity())) { + Introspector child = obj; + if (!parser.getLoader().getVersion().equals(obj.getVersion())) { + String json = obj.marshal(false); + child = parser.getLoader().unmarshal(parser.getEntity().getName(), json); + } + + // wrap the child object in its parents + parentList.add(child.getUnderlyingObject()); + } + + final Introspector eventObject; + if (parser.getTopEntity().equals(parser.getEntity())) { + // take the top level parent object passed in + eventObject = obj; + } else { + // take the wrapped child objects (ogres are like onions) + eventObject = parser.getTopEntity(); + } + + return eventObject; + } + + public String getTopEntityName() { + return parser.getTopEntityName(); + } +} diff --git a/aai-core/src/main/java/org/onap/aai/rest/notification/NotificationEvent.java b/aai-core/src/main/java/org/onap/aai/rest/notification/NotificationEvent.java deleted file mode 100644 index 17f09b19..00000000 --- a/aai-core/src/main/java/org/onap/aai/rest/notification/NotificationEvent.java +++ /dev/null @@ -1,101 +0,0 @@ -/** - * ============LICENSE_START======================================================= - * org.onap.aai - * ================================================================================ - * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.aai.rest.notification; - -import org.onap.aai.exceptions.AAIException; -import org.onap.aai.introspection.Introspector; -import org.onap.aai.introspection.Loader; -import org.onap.aai.setup.SchemaVersion; -import org.onap.aai.util.StoreNotificationEvent; - -/** - * The Class NotificationEvent. - */ -public class NotificationEvent { - - private final Loader loader; - - private final Introspector eventHeader; - - private final Introspector obj; - private final String transactionId; - private final String sourceOfTruth; - - /** - * Instantiates a new notification event. - * - * @param eventHeader the event header - * @param obj the obj - */ - public NotificationEvent(Loader loader, Introspector eventHeader, Introspector obj, String transactionId, - String sourceOfTruth) { - this.loader = loader; - this.eventHeader = eventHeader; - this.obj = obj; - this.transactionId = transactionId; - this.sourceOfTruth = sourceOfTruth; - } - - /** - * Trigger. - * - * @throws AAIException the AAI exception - */ - public void trigger() throws AAIException { - - StoreNotificationEvent sne = new StoreNotificationEvent(transactionId, sourceOfTruth); - - sne.storeEventAndSendToJms(loader, eventHeader, obj); - - } - - public String getNotificationEvent() throws AAIException { - return new StoreNotificationEvent(transactionId, sourceOfTruth).storeEventOnly(loader, eventHeader, obj); - } - - /** - * Gets the notification version. - * - * @return the notification version - */ - public SchemaVersion getNotificationVersion() { - return loader.getVersion(); - } - - /** - * Gets the event header. - * - * @return the event header - */ - public Introspector getEventHeader() { - return eventHeader; - } - - /** - * Gets the obj. - * - * @return the obj - */ - public Introspector getObj() { - return obj; - } - -} diff --git a/aai-core/src/main/java/org/onap/aai/rest/notification/NotificationService.java b/aai-core/src/main/java/org/onap/aai/rest/notification/NotificationService.java index 9c3dde15..c2770692 100644 --- a/aai-core/src/main/java/org/onap/aai/rest/notification/NotificationService.java +++ b/aai-core/src/main/java/org/onap/aai/rest/notification/NotificationService.java @@ -34,6 +34,7 @@ import org.onap.aai.db.props.AAIProperties; import org.onap.aai.exceptions.AAIException; import org.onap.aai.introspection.Introspector; import org.onap.aai.introspection.LoaderFactory; +import org.onap.aai.kafka.NotificationProducer; import org.onap.aai.prevalidation.ValidationService; import org.onap.aai.serialization.db.DBSerializer; import org.onap.aai.serialization.engines.query.QueryEngine; @@ -52,6 +53,7 @@ public class NotificationService { public static final Logger LOGGER = LoggerFactory.getLogger(NotificationService.class); private final ValidationService validationService; + private final NotificationProducer notificationProducer; private final LoaderFactory loaderFactory; private final boolean isDeltaEventsEnabled; private final String basePath; @@ -60,11 +62,13 @@ public class NotificationService { @Nullable ValidationService validationService, LoaderFactory loaderFactory, @Value("${schema.uri.base.path}") String basePath, - @Value("${delta.events.enabled:false}") boolean isDeltaEventsEnabled) { + @Value("${delta.events.enabled:false}") boolean isDeltaEventsEnabled, + NotificationProducer notificationProducer) { this.validationService = validationService; this.loaderFactory = loaderFactory; this.basePath = basePath; this.isDeltaEventsEnabled = isDeltaEventsEnabled; + this.notificationProducer = notificationProducer; } /** @@ -99,7 +103,7 @@ public class NotificationService { validationService.validate(notification.getEvents()); } - notification.triggerEvents(); + notificationProducer.sendUEBNotification(notification); if (isDeltaEventsEnabled) { try { DeltaEvents deltaEvents = new DeltaEvents(transactionId, sourceOfTruth, schemaVersion.toString(), diff --git a/aai-core/src/main/java/org/onap/aai/rest/notification/UEBNotification.java b/aai-core/src/main/java/org/onap/aai/rest/notification/UEBNotification.java index 83a446b2..61be76c8 100644 --- a/aai-core/src/main/java/org/onap/aai/rest/notification/UEBNotification.java +++ b/aai-core/src/main/java/org/onap/aai/rest/notification/UEBNotification.java @@ -4,6 +4,8 @@ * ================================================================================ * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved. * ================================================================================ + * Modifications Copyright © 2024 Deutsche Telekom. + * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -30,6 +32,8 @@ import java.util.Map; import javax.ws.rs.core.Response.Status; +import org.onap.aai.domain.notificationEvent.NotificationEvent; +import org.onap.aai.domain.notificationEvent.NotificationEvent.EventHeader; import org.onap.aai.exceptions.AAIException; import org.onap.aai.introspection.Introspector; import org.onap.aai.introspection.Loader; @@ -41,59 +45,31 @@ import org.onap.aai.logging.LogFormatTools; import org.onap.aai.parsers.uri.URIToObject; import org.onap.aai.setup.SchemaVersion; import org.onap.aai.setup.SchemaVersions; +import org.onap.aai.util.AAIConfig; +import org.onap.aai.util.AAIConstants; +import org.onap.aai.util.FormatDate; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -/** - * The Class UEBNotification. - */ public class UEBNotification { private static final Logger LOGGER = LoggerFactory.getLogger(UEBNotification.class); + private static final FormatDate FORMAT_DATE = new FormatDate("YYYYMMdd-HH:mm:ss:SSS"); + private static final String EVENT_TYPE = "AAI-EVENT"; - private Loader currentVersionLoader = null; - protected Map<String, NotificationEvent> events = null; - private SchemaVersion notificationVersion = null; - - /** - * Instantiates a new UEB notification. - * - * @param loader the loader - */ - public UEBNotification(Loader loader, LoaderFactory loaderFactory, SchemaVersions schemaVersions) { - events = new LinkedHashMap<>(); - SchemaVersion defaultVersion = schemaVersions.getDefaultVersion(); - currentVersionLoader = loaderFactory.createLoaderForVersion(loader.getModelType(), defaultVersion); - notificationVersion = defaultVersion; - } + private final String domain = AAIConfig.get("aai.notificationEvent.default.domain", "UNK"); + private final String sequenceNumber = AAIConfig.get("aai.notificationEvent.default.sequenceNumber", "UNK"); + private final String severity = AAIConfig.get("aai.notificationEvent.default.severity", "UNK"); + private final Map<String, NotificationEvent> events; + private final Loader currentVersionLoader; + private final SchemaVersion notificationVersion; - /** - * Instantiates a new UEB notification. - * - * @param modelType - Model type - * @param loaderFactory - the loader factory - * @param schemaVersions the schema versions bean - */ - public UEBNotification(ModelType modelType, LoaderFactory loaderFactory, SchemaVersions schemaVersions) { + public UEBNotification(LoaderFactory loaderFactory, SchemaVersions schemaVersions) { events = new LinkedHashMap<>(); - SchemaVersion defaultVersion = schemaVersions.getDefaultVersion(); - currentVersionLoader = loaderFactory.createLoaderForVersion(modelType, defaultVersion); - notificationVersion = defaultVersion; + notificationVersion = schemaVersions.getDefaultVersion(); + currentVersionLoader = loaderFactory.createLoaderForVersion(ModelType.MOXY, notificationVersion); } - /** - * Creates the notification event. - * - * @param transactionId the X-TransactionId - * @param sourceOfTruth - * @param status the status - * @param uri the uri - * @param obj the obj - * @param basePath base URI path - * @throws AAIException the AAI exception - * @throws IllegalArgumentException the illegal argument exception - * @throws UnsupportedEncodingException the unsupported encoding exception - */ public void createNotificationEvent(String transactionId, String sourceOfTruth, Status status, URI uri, Introspector obj, HashMap<String, Introspector> relatedObjects, String basePath) throws AAIException, UnsupportedEncodingException { @@ -101,60 +77,32 @@ public class UEBNotification { String action = getAction(status); try { - Introspector eventHeader = currentVersionLoader.introspectorFromName("notification-event-header"); - URIToObject parser = new URIToObject(currentVersionLoader, uri, relatedObjects); + EntityConverter entityConverter = new EntityConverter(new URIToObject(currentVersionLoader, uri, relatedObjects)); + EventHeader eventHeader = new EventHeader(); basePath = formatBasePath(basePath); - String entityLink = formatEntityLink(uri, basePath); - - eventHeader.setValue("entity-link", entityLink); - eventHeader.setValue("action", action); - eventHeader.setValue("entity-type", obj.getDbName()); - eventHeader.setValue("top-entity-type", parser.getTopEntityName()); - eventHeader.setValue("source-name", sourceOfTruth); - eventHeader.setValue("version", notificationVersion.toString()); - eventHeader.setValue("id", transactionId); - - List<Object> parentList = parser.getParentList(); - parentList.clear(); - - if (!parser.getTopEntity().equals(parser.getEntity())) { - Introspector child = obj; - if (!parser.getLoader().getVersion().equals(obj.getVersion())) { - String json = obj.marshal(false); - child = parser.getLoader().unmarshal(parser.getEntity().getName(), json); - } - - // wrap the child object in its parents - parentList.add(child.getUnderlyingObject()); - } - - final Introspector eventObject; - - // convert to most resent version - if (!parser.getLoader().getVersion().equals(currentVersionLoader.getVersion())) { - String json = ""; - if (parser.getTopEntity().equals(parser.getEntity())) { - // convert the parent object passed in - json = obj.marshal(false); - eventObject = currentVersionLoader.unmarshal(obj.getName(), json); - } else { - // convert the object created in the parser - json = parser.getTopEntity().marshal(false); - eventObject = currentVersionLoader.unmarshal(parser.getTopEntity().getName(), json); - } - } else { - if (parser.getTopEntity().equals(parser.getEntity())) { - // take the top level parent object passed in - eventObject = obj; - } else { - // take the wrapped child objects (ogres are like onions) - eventObject = parser.getTopEntity(); - } - } - final NotificationEvent event = - new NotificationEvent(currentVersionLoader, eventHeader, eventObject, transactionId, sourceOfTruth); + eventHeader.setEntityLink(entityLink); + eventHeader.setAction(action); + eventHeader.setEntityType(obj.getDbName()); + eventHeader.setTopEntityType(entityConverter.getTopEntityName()); + eventHeader.setSourceName(sourceOfTruth); + eventHeader.setVersion(notificationVersion.toString()); + eventHeader.setId(transactionId); + + // default values + eventHeader.setTimestamp(FORMAT_DATE.getDateTime()); + eventHeader.setEventType(EVENT_TYPE); + eventHeader.setDomain(domain); + eventHeader.setSequenceNumber(sequenceNumber); + eventHeader.setSeverity(severity); + + Introspector entity = entityConverter.convert(obj); + + final NotificationEvent event = new NotificationEvent(); + event.setEventHeader(eventHeader); + event.setCambriaPartition(AAIConstants.UEB_PUB_PARTITION_AAI); + event.setEntity(entity); events.put(uri.toString(), event); } catch (AAIUnknownObjectException e) { throw new RuntimeException("Fatal error - notification-event-header object not found!"); @@ -206,26 +154,10 @@ public class UEBNotification { return action; } - /** - * Trigger events. - * - * @throws AAIException the AAI exception - */ - public void triggerEvents() throws AAIException { - for (NotificationEvent event : events.values()) { - event.trigger(); - } - clearEvents(); - } - public List<NotificationEvent> getEvents() { return new ArrayList<>(this.events.values()); } - public Map<String, NotificationEvent> getEventsMap() { - return this.events; - } - private String getUri(String uri, String basePath) { if (uri == null || uri.isEmpty()) { return ""; diff --git a/aai-core/src/main/java/org/onap/aai/serialization/db/EdgeSerializer.java b/aai-core/src/main/java/org/onap/aai/serialization/db/EdgeSerializer.java index 0d491c9d..ce3891ee 100644 --- a/aai-core/src/main/java/org/onap/aai/serialization/db/EdgeSerializer.java +++ b/aai-core/src/main/java/org/onap/aai/serialization/db/EdgeSerializer.java @@ -112,7 +112,7 @@ public class EdgeSerializer { if (message.isPresent() && !isBestEffort) { throw new EdgeMultiplicityException(message.get()); } - if (!message.isPresent()) { + if (message.isEmpty()) { if (rule.getDirection().equals(Direction.OUT)) { e = aVertex.addEdge(rule.getLabel(), bVertex); } else if (rule.getDirection().equals(Direction.IN)) { @@ -185,7 +185,7 @@ public class EdgeSerializer { if (message.isPresent() && !isBestEffort) { throw new EdgeMultiplicityException(message.get()); } - if (!message.isPresent()) { + if (message.isEmpty()) { if (rule.getDirection().equals(Direction.OUT)) { e = aVertex.addEdge(rule.getLabel(), bVertex); } else if (rule.getDirection().equals(Direction.IN)) { diff --git a/aai-core/src/main/java/org/onap/aai/serialization/queryformats/Aggregate.java b/aai-core/src/main/java/org/onap/aai/serialization/queryformats/Aggregate.java index 71f7bc78..54fc4eb0 100644 --- a/aai-core/src/main/java/org/onap/aai/serialization/queryformats/Aggregate.java +++ b/aai-core/src/main/java/org/onap/aai/serialization/queryformats/Aggregate.java @@ -177,7 +177,7 @@ public class Aggregate extends MultiFormatMapper { } return Optional.<JsonObject>empty(); - }).filter(Optional::isPresent).map(Optional::get).forEach(json -> { + }).flatMap(Optional::stream).forEach(json -> { if (isParallel) { synchronized (body) { body.add(json); diff --git a/aai-core/src/main/java/org/onap/aai/serialization/queryformats/Count.java b/aai-core/src/main/java/org/onap/aai/serialization/queryformats/Count.java index 216d021d..c736eab8 100644 --- a/aai-core/src/main/java/org/onap/aai/serialization/queryformats/Count.java +++ b/aai-core/src/main/java/org/onap/aai/serialization/queryformats/Count.java @@ -44,7 +44,7 @@ public class Count implements FormatMapper { final JsonObject countResult = new JsonObject(); - list.stream().map(this::getCount).filter(Optional::isPresent).map(Optional::get) + list.stream().map(this::getCount).flatMap(Optional::stream) .collect(Collectors.toConcurrentMap(Pair::getValue0, Pair::getValue1, Long::sum)) .forEach(countResult::addProperty); diff --git a/aai-core/src/main/java/org/onap/aai/serialization/queryformats/Formatter.java b/aai-core/src/main/java/org/onap/aai/serialization/queryformats/Formatter.java index da5d5425..10f1edc4 100644 --- a/aai-core/src/main/java/org/onap/aai/serialization/queryformats/Formatter.java +++ b/aai-core/src/main/java/org/onap/aai/serialization/queryformats/Formatter.java @@ -102,7 +102,7 @@ public class Formatter { } return Optional.<JsonObject>empty(); - }).filter(Optional::isPresent).map(Optional::get).forEach(json -> { + }).flatMap(Optional::stream).forEach(json -> { if (isParallel) { synchronized (body) { body.add(json); diff --git a/aai-core/src/main/java/org/onap/aai/serialization/queryformats/GraphSON.java b/aai-core/src/main/java/org/onap/aai/serialization/queryformats/GraphSON.java index 89970e24..9c7c4a44 100644 --- a/aai-core/src/main/java/org/onap/aai/serialization/queryformats/GraphSON.java +++ b/aai-core/src/main/java/org/onap/aai/serialization/queryformats/GraphSON.java @@ -54,7 +54,7 @@ public class GraphSON implements FormatMapper { private static final GraphSONVersion version = GraphSONVersion.V1_0; private final GraphSONMapper mapper = - GraphSONMapper.build().version(version).addRegistry(JanusGraphIoRegistry.getInstance()).create(); + GraphSONMapper.build().version(version).addRegistry(JanusGraphIoRegistry.instance()).create(); private final GraphSONWriter writer = GraphSONWriter.build().mapper(mapper).create(); @Override diff --git a/aai-core/src/main/java/org/onap/aai/serialization/queryformats/LifecycleFormat.java b/aai-core/src/main/java/org/onap/aai/serialization/queryformats/LifecycleFormat.java index 74742c98..fbe74e28 100644 --- a/aai-core/src/main/java/org/onap/aai/serialization/queryformats/LifecycleFormat.java +++ b/aai-core/src/main/java/org/onap/aai/serialization/queryformats/LifecycleFormat.java @@ -267,7 +267,7 @@ public class LifecycleFormat extends HistoryFormat { } return Optional.<JsonObject>empty(); - }).filter(Optional::isPresent).map(Optional::get).forEach(json -> { + }).flatMap(Optional::stream).forEach(json -> { if (isParallel) { synchronized (body) { body.add(json); diff --git a/aai-core/src/main/java/org/onap/aai/util/HttpsAuthClient.java b/aai-core/src/main/java/org/onap/aai/util/HttpsAuthClient.java index f8f0b65e..b31bfcb8 100644 --- a/aai-core/src/main/java/org/onap/aai/util/HttpsAuthClient.java +++ b/aai-core/src/main/java/org/onap/aai/util/HttpsAuthClient.java @@ -20,13 +20,6 @@ package org.onap.aai.util; -import com.sun.jersey.api.client.Client; -import com.sun.jersey.api.client.ClientResponse; -import com.sun.jersey.api.client.config.ClientConfig; -import com.sun.jersey.api.client.config.DefaultClientConfig; -import com.sun.jersey.api.json.JSONConfiguration; -import com.sun.jersey.client.urlconnection.HTTPSProperties; - import java.io.FileInputStream; import java.io.IOException; import java.security.KeyManagementException; @@ -41,8 +34,16 @@ import javax.net.ssl.HttpsURLConnection; import javax.net.ssl.KeyManagerFactory; import javax.net.ssl.SSLContext; import javax.net.ssl.SSLSession; - -import org.onap.aai.aailog.filter.RestControllerClientLoggingInterceptor; +import javax.ws.rs.client.Client; +import javax.ws.rs.client.ClientBuilder; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; + +import org.apache.commons.configuration2.JSONConfiguration; +import org.glassfish.jersey.client.ClientConfig; +import org.glassfish.jersey.client.ClientProperties; +import org.onap.aai.aailog.filter.RestControllerClientRequestLoggingInterceptor; +import org.onap.aai.aailog.filter.RestControllerClientResponseLoggingInterceptor; import org.onap.aai.exceptions.AAIException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -62,12 +63,10 @@ public class HttpsAuthClient { System.out.println("Making Jersey https call..."); Client client = HttpsAuthClient.getClient(); - ClientResponse res = client.resource(url).accept("application/json").header("X-TransactionId", "PROV001") - .header("X-FromAppId", "AAI").type("application/json").get(ClientResponse.class); - - // System.out.println("Jersey result: "); - // System.out.println(res.getEntity(String.class).toString()); - + Response res = client.target(url) + .request(MediaType.APPLICATION_JSON) + .header("X-TransactionId", "PROV001") + .header("X-FromAppId", "AAI").get(); } catch (KeyManagementException e) { logger.debug("HttpsAuthClient KeyManagement error : {}", e.getMessage()); } catch (Exception e) { @@ -89,9 +88,9 @@ public class HttpsAuthClient { String keystorePassword) throws KeyManagementException, UnrecoverableKeyException, CertificateException, NoSuchAlgorithmException, KeyStoreException, IOException { - ClientConfig config = new DefaultClientConfig(); - config.getFeatures().put(JSONConfiguration.FEATURE_POJO_MAPPING, Boolean.TRUE); - config.getClasses().add(org.onap.aai.restcore.CustomJacksonJaxBJsonProvider.class); + ClientConfig config = new ClientConfig(); + config.register(org.onap.aai.restcore.CustomJacksonJaxBJsonProvider.class); + SSLContext ctx = null; try { System.setProperty("javax.net.ssl.trustStore", truststorePath); @@ -117,20 +116,16 @@ public class HttpsAuthClient { } ctx.init(kmf.getKeyManagers(), null, null); - config.getProperties().put(HTTPSProperties.PROPERTY_HTTPS_PROPERTIES, - new HTTPSProperties(new HostnameVerifier() { - @Override - public boolean verify(String s, SSLSession sslSession) { - return true; - } - }, ctx)); + config.property("jersey.config.client.ssl.context", ctx); + config.property("jersey.config.client.hostname.verifier", (HostnameVerifier) (s, sslSession) -> true); } catch (Exception e) { System.out.println("Error setting up config: exiting " + e.getMessage()); throw e; } - Client client = Client.create(config); - client.addFilter(new RestControllerClientLoggingInterceptor()); + Client client = ClientBuilder.newClient(config); + client.register(new RestControllerClientRequestLoggingInterceptor()); + client.register(new RestControllerClientResponseLoggingInterceptor()); // uncomment this line to get more logging for the request/response // client.addFilter(new LoggingFilter(System.out)); diff --git a/aai-core/src/main/java/org/onap/aai/util/HttpsAuthExternalClient.java b/aai-core/src/main/java/org/onap/aai/util/HttpsAuthExternalClient.java index 53e2d958..1ace66c7 100644 --- a/aai-core/src/main/java/org/onap/aai/util/HttpsAuthExternalClient.java +++ b/aai-core/src/main/java/org/onap/aai/util/HttpsAuthExternalClient.java @@ -20,21 +20,16 @@ package org.onap.aai.util; -import com.sun.jersey.api.client.Client; -import com.sun.jersey.api.client.config.ClientConfig; -import com.sun.jersey.api.client.config.DefaultClientConfig; -import com.sun.jersey.api.json.JSONConfiguration; -import com.sun.jersey.client.urlconnection.HTTPSProperties; - import java.io.FileInputStream; -import java.security.KeyStore; + +import org.glassfish.jersey.client.ClientConfig; +import org.glassfish.jersey.SslConfigurator; import javax.net.ssl.HostnameVerifier; -import javax.net.ssl.HttpsURLConnection; -import javax.net.ssl.KeyManagerFactory; import javax.net.ssl.SSLContext; import javax.net.ssl.SSLSession; -import javax.net.ssl.TrustManagerFactory; +import javax.ws.rs.client.Client; +import javax.ws.rs.client.ClientBuilder; public class HttpsAuthExternalClient { @@ -48,63 +43,45 @@ public class HttpsAuthExternalClient { */ public static Client getClient(String keystoreFileName, String keystorePassword) throws Exception { - ClientConfig config = new DefaultClientConfig(); - config.getFeatures().put(JSONConfiguration.FEATURE_POJO_MAPPING, Boolean.TRUE); - config.getClasses().add(org.onap.aai.restcore.CustomJacksonJaxBJsonProvider.class); - Client client = null; - SSLContext ctx = null; - String truststore_path = AAIConstants.AAI_HOME_ETC_AUTH + AAIConfig.get(AAIConstants.AAI_TRUSTSTORE_FILENAME); - try (FileInputStream tin = new FileInputStream(truststore_path)) { - String truststore_password = AAIConfig.get(AAIConstants.AAI_TRUSTSTORE_PASSWD); - String keystore_path = AAIConstants.AAI_HOME_ETC_AUTH + keystoreFileName; - String keystore_password = keystorePassword; - // System.setProperty("javax.net.ssl.trustStore", truststore_path); - // System.setProperty("javax.net.ssl.trustStorePassword", truststore_password); - HttpsURLConnection.setDefaultHostnameVerifier(new HostnameVerifier() { - public boolean verify(String string, SSLSession ssls) { - return true; - } - }); + ClientConfig config = new ClientConfig(); + config.register(org.onap.aai.restcore.CustomJacksonJaxBJsonProvider.class); - ctx = SSLContext.getInstance("TLS"); - KeyManagerFactory kmf = null; + SSLContext sslContext = null; + String truststorePath = AAIConstants.AAI_HOME_ETC_AUTH + AAIConfig.get(AAIConstants.AAI_TRUSTSTORE_FILENAME); + try (FileInputStream tin = new FileInputStream(truststorePath)) { + String truststorePassword = AAIConfig.get(AAIConstants.AAI_TRUSTSTORE_PASSWD); + String keystorePath = AAIConstants.AAI_HOME_ETC_AUTH + keystoreFileName; - /**** - * kmf = KeyManagerFactory.getInstance("SunX509"); - * FileInputStream fin = new FileInputStream(keystore_path); - * KeyStore ks = KeyStore.getInstance("PKCS12"); - * char[] pwd = keystore_password.toCharArray(); - * ks.load(fin, pwd); - * kmf.init(ks, pwd); - ***/ + SslConfigurator sslConfig = SslConfigurator.newInstance() + .trustStoreFile(truststorePath) + .trustStorePassword(truststorePassword) + .keyStoreFile(keystorePath) + .keyStorePassword(keystorePassword); - String alg = TrustManagerFactory.getDefaultAlgorithm(); - TrustManagerFactory tmf = TrustManagerFactory.getInstance(alg); + sslContext = sslConfig.createSSLContext(); - KeyStore ts = KeyStore.getInstance("PKCS12"); - char[] tpwd = truststore_password.toCharArray(); - ts.load(tin, tpwd); - tmf.init(ts); + HostnameVerifier hostnameVerifier = new HostnameVerifier() { + @Override + public boolean verify(String s, SSLSession sslSession) { + return true; + } + }; - // ctx.init(kmf.getKeyManagers(), tmf.getTrustManagers(), null); - // Updating key manager to null, to disable two way SSL - ctx.init(null, tmf.getTrustManagers(), null); + Client client = ClientBuilder.newBuilder() + .withConfig(config) + .sslContext(sslContext) + .hostnameVerifier(hostnameVerifier) + .build(); - config.getProperties().put(HTTPSProperties.PROPERTY_HTTPS_PROPERTIES, - new HTTPSProperties(new HostnameVerifier() { - @Override - public boolean verify(String s, SSLSession sslSession) { - return true; - } - }, ctx)); + // Uncomment this line to get more logging for the request/response + // client.register(new + // LoggingFeature(Logger.getLogger(LoggingFeature.DEFAULT_LOGGER_NAME), + // Level.INFO, LoggingFeature.Verbosity.PAYLOAD_ANY, 8192)); - client = Client.create(config); - // uncomment this line to get more logging for the request/response - // client.addFilter(new LoggingFilter(System.out)); + return client; } catch (Exception e) { throw e; } - return client; } } diff --git a/aai-core/src/main/java/org/onap/aai/util/RestController.java b/aai-core/src/main/java/org/onap/aai/util/RestController.java index 1b050829..b72b5af5 100644 --- a/aai-core/src/main/java/org/onap/aai/util/RestController.java +++ b/aai-core/src/main/java/org/onap/aai/util/RestController.java @@ -22,9 +22,8 @@ package org.onap.aai.util; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.type.TypeFactory; -import com.sun.jersey.api.client.Client; -import com.sun.jersey.api.client.ClientHandlerException; -import com.sun.jersey.api.client.ClientResponse; + +import javax.ws.rs.client.Entity; import java.io.IOException; import java.lang.reflect.InvocationTargetException; @@ -37,6 +36,11 @@ import java.util.ArrayList; import java.util.List; import java.util.UUID; +import javax.ws.rs.ClientErrorException; +import javax.ws.rs.client.Client; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; + import org.onap.aai.exceptions.AAIException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -69,8 +73,7 @@ public class RestController implements RestControllerInterface { public static final String REST_APIPATH_CLOUDREGION = "cloud-infrastructure/cloud-regions/cloud-region/"; public static final String REST_APIPATH_TENANT = "cloud-infrastructure/tenants/tenant/"; - public static final String REST_APIPATH_VIRTUAL_DATA_CENTER = - "cloud-infrastructure/virtual-data-centers/virtual-data-center/"; + public static final String REST_APIPATH_VIRTUAL_DATA_CENTER = "cloud-infrastructure/virtual-data-centers/virtual-data-center/"; public static final String REST_APIPATH_VIRTUAL_DATA_CENTERS = "cloud-infrastructure/virtual-data-centers/"; public static final String REST_APIPATH_GENERIC_VNF = "network/generic-vnfs/generic-vnf/"; public static final String REST_APIPATH_GENERIC_VNFS = "network/generic-vnfs"; @@ -173,8 +176,8 @@ public class RestController implements RestControllerInterface { url = AAIConfig.get(AAIConstants.AAI_OLDSERVER_URL) + path; } else { if (overrideLocalHost == null) { - overrideLocalHost = - AAIConfig.get(AAIConstants.AAI_LOCAL_OVERRIDE, AAIConstants.AAI_LOCAL_OVERRIDE_DEFAULT); + overrideLocalHost = AAIConfig.get(AAIConstants.AAI_LOCAL_OVERRIDE, + AAIConstants.AAI_LOCAL_OVERRIDE_DEFAULT); } if (AAIConstants.AAI_LOCAL_OVERRIDE_DEFAULT.equals(overrideLocalHost)) { url = String.format(AAIConstants.AAI_LOCAL_REST, port, @@ -185,21 +188,26 @@ public class RestController implements RestControllerInterface { } } LOGGER.debug(url + " for the get REST API"); - ClientResponse cres = client.resource(url).accept("application/json").header("X-TransactionId", transId) - .header("X-FromAppId", sourceID).header("Real-Time", "true").type("application/json") - .get(ClientResponse.class); + Response response = client.target(url) + .request(MediaType.APPLICATION_JSON) + .header("X-TransactionId", transId) + .header("X-FromAppId", sourceID) + .header("Real-Time", "true") + .get(); - // System.out.println("cres.EntityInputSream()="+cres.getEntityInputStream().toString()); - // System.out.println("cres.tostring()="+cres.toString()); + // System.out.println("response.EntityInputSream()="+response.getEntityInputStream().toString()); + // System.out.println("response.tostring()="+response.toString()); - if (cres.getStatus() == 200) { + if (response.getStatus() == 200) { // System.out.println(methodName + ": url=" + url); - t = (T) cres.getEntity(t.getClass()); + T entity = response.readEntity((Class<T>) t.getClass()); + restObject.set(entity); restObject.set(t); LOGGER.debug(methodName + "REST api GET was successfull!"); } else { - // System.out.println(methodName + ": url=" + url + " failed with status=" + cres.getStatus()); - throw new AAIException("AAI_7116", methodName + " with status=" + cres.getStatus() + ", url=" + url); + // System.out.println(methodName + ": url=" + url + " failed with status=" + + // response.getStatus()); + throw new AAIException("AAI_7116", methodName + " with status=" + response.getStatus() + ", url=" + url); } } @@ -229,21 +237,25 @@ public class RestController implements RestControllerInterface { url = AAIConfig.get(AAIConstants.AAI_SERVER_URL_BASE) + apiVersion + "/" + path; LOGGER.debug(url + " for the get REST API"); - ClientResponse cres = client.resource(url).accept("application/json").header("X-TransactionId", transId) - .header("X-FromAppId", sourceID).header("Real-Time", "true").type("application/json") - .get(ClientResponse.class); + Response response = client.target(url) + .request(MediaType.APPLICATION_JSON) + .header("X-TransactionId", transId) + .header("X-FromAppId", sourceID) + .header("Real-Time", "true") + .get(); - // System.out.println("cres.EntityInputSream()="+cres.getEntityInputStream().toString()); - // System.out.println("cres.tostring()="+cres.toString()); + // System.out.println("response.EntityInputSream()="+response.getEntityInputStream().toString()); + // System.out.println("response.tostring()="+response.toString()); - if (cres.getStatus() == 200) { + if (response.getStatus() == 200) { // System.out.println(methodName + ": url=" + url); - t = (T) cres.getEntity(t.getClass()); - restObject.set(t); + T entity = response.readEntity((Class<T>) t.getClass()); + restObject.set(entity); LOGGER.debug(methodName + "REST api GET was successfull!"); } else { - // System.out.println(methodName + ": url=" + url + " failed with status=" + cres.getStatus()); - throw new AAIException("AAI_7116", methodName + " with status=" + cres.getStatus() + ", url=" + url); + // System.out.println(methodName + ": url=" + url + " failed with status=" + + // response.getStatus()); + throw new AAIException("AAI_7116", methodName + " with status=" + response.getStatus() + ", url=" + url); } } @@ -318,8 +330,8 @@ public class RestController implements RestControllerInterface { url = AAIConfig.get(AAIConstants.AAI_OLDSERVER_URL) + path; } else { if (overrideLocalHost == null) { - overrideLocalHost = - AAIConfig.get(AAIConstants.AAI_LOCAL_OVERRIDE, AAIConstants.AAI_LOCAL_OVERRIDE_DEFAULT); + overrideLocalHost = AAIConfig.get(AAIConstants.AAI_LOCAL_OVERRIDE, + AAIConstants.AAI_LOCAL_OVERRIDE_DEFAULT); } if (AAIConstants.AAI_LOCAL_OVERRIDE_DEFAULT.equals(overrideLocalHost)) { url = String.format(AAIConstants.AAI_LOCAL_REST, port, @@ -330,18 +342,21 @@ public class RestController implements RestControllerInterface { } } - ClientResponse cres = client.resource(url).accept("application/json").header("X-TransactionId", transId) - .header("X-FromAppId", sourceID).header("Real-Time", "true").type("application/json").entity(t) - .put(ClientResponse.class); + Response response = client.target(url) + .request(MediaType.APPLICATION_JSON) + .header("X-TransactionId", transId) + .header("X-FromAppId", sourceID) + .header("Real-Time", "true") + .put(Entity.entity(t, MediaType.APPLICATION_JSON)); - // System.out.println("cres.tostring()="+cres.toString()); + // System.out.println("response.tostring()="+response.toString()); - int statuscode = cres.getStatus(); + int statuscode = response.getStatus(); if (statuscode >= 200 && statuscode <= 299) { LOGGER.debug(methodName + ": url=" + url + ", request=" + path); } else { throw new AAIException("AAI_7116", methodName + " with status=" + statuscode + ", url=" + url + ", msg=" - + cres.getEntity(String.class)); + + response.readEntity(String.class)); } } @@ -365,18 +380,21 @@ public class RestController implements RestControllerInterface { url = AAIConfig.get(AAIConstants.AAI_SERVER_URL_BASE) + apiVersion + "/" + path; - ClientResponse cres = client.resource(url).accept("application/json").header("X-TransactionId", transId) - .header("X-FromAppId", sourceID).header("Real-Time", "true").type("application/json").entity(t) - .put(ClientResponse.class); + Response response = client.target(url) + .request(MediaType.APPLICATION_JSON) + .header("X-TransactionId", transId) + .header("X-FromAppId", sourceID) + .header("Real-Time", "true") + .put(Entity.entity(t, MediaType.APPLICATION_JSON)); - // System.out.println("cres.tostring()="+cres.toString()); + // System.out.println("response.tostring()="+response.toString()); - int statuscode = cres.getStatus(); + int statuscode = response.getStatus(); if (statuscode >= 200 && statuscode <= 299) { LOGGER.debug(methodName + ": url=" + url + ", request=" + path); } else { throw new AAIException("AAI_7116", methodName + " with status=" + statuscode + ", url=" + url + ", msg=" - + cres.getEntity(String.class)); + + response.getEntity()); } } @@ -410,16 +428,20 @@ public class RestController implements RestControllerInterface { url = String.format(AAIConstants.AAI_LOCAL_REST_OVERRIDE, overrideLocalHost, AAIConfig.get(AAIConstants.AAI_DEFAULT_API_VERSION_PROP)) + path; } - ClientResponse cres = client.resource(url).accept("application/json").header("X-TransactionId", transId) - .header("X-FromAppId", sourceID).header("Real-Time", "true").type("application/json").entity(request) - .delete(ClientResponse.class); - - if (cres.getStatus() == 404) { // resource not found - LOGGER.info("Resource does not exist...: " + cres.getStatus() + ":" + cres.getEntity(String.class)); - } else if (cres.getStatus() == 200 || cres.getStatus() == 204) { + Response response = client.target(url) + .request(MediaType.APPLICATION_JSON) + .header("X-TransactionId", transId) + .header("X-FromAppId", sourceID) + .header("Real-Time", "true") + .delete(); + + if (response.getStatus() == 404) { // resource not found + LOGGER.info( + "Resource does not exist...: " + response.getStatus() + ":" + response.readEntity(String.class)); + } else if (response.getStatus() == 200 || response.getStatus() == 204) { LOGGER.info("Resource " + url + " deleted"); } else { - LOGGER.error("Deleting Resource failed: " + cres.getStatus() + ":" + cres.getEntity(String.class)); + LOGGER.error("Deleting Resource failed: " + response.getStatus() + ":" + response.readEntity(String.class)); throw new AAIException("AAI_7116", "Error during DELETE"); } } @@ -451,17 +473,20 @@ public class RestController implements RestControllerInterface { url = AAIConfig.get(AAIConstants.AAI_SERVER_URL_BASE) + apiVersion + "/" + path; - ClientResponse cres = client.resource(url).accept("application/json").header("X-TransactionId", transId) - .header("X-FromAppId", sourceID).header("Real-Time", "true").type("application/json").entity(t) - .post(ClientResponse.class); + Response response = client.target(url) + .request(MediaType.APPLICATION_JSON) + .header("X-TransactionId", transId) + .header("X-FromAppId", sourceID) + .header("Real-Time", "true") + .post(Entity.entity(t, MediaType.APPLICATION_JSON)); - int statuscode = cres.getStatus(); + int statuscode = response.getStatus(); if (statuscode >= 200 && statuscode <= 299) { LOGGER.debug(methodName + "REST api POST was successful!"); - return cres.getEntity(String.class); + return response.readEntity(String.class); } else { throw new AAIException("AAI_7116", methodName + " with status=" + statuscode + ", url=" + url + ", msg=" - + cres.getEntity(String.class)); + + response.readEntity(String.class)); } } catch (AAIException e) { @@ -503,17 +528,17 @@ public class RestController implements RestControllerInterface { */ /* * DoesResourceExist - * + * * To check whether a resource exist or get a copy of the existing version of the resource - * + * * Resourcepath: should contain the qualified resource path (including encoded unique key identifier value), * resourceClassName: is the canonical name of the resource class name, * fromAppId: * transId: - * + * * Will return null (if the resource doesn’t exist) (or) * Will return the specified resource from the Graph. - * + * * Example: * LogicalLink llink = new LogicalLink(); * String resourceClassName = llink.getClass().getCanonicalName(); @@ -536,7 +561,7 @@ public class RestController implements RestControllerInterface { } catch (AAIException e) { - } catch (ClientHandlerException che) { + } catch (ClientErrorException che) { } catch (Exception e) { @@ -560,13 +585,13 @@ public class RestController implements RestControllerInterface { transId += ":" + UUID.randomUUID().toString(); int numRetries = 5; - ClientResponse cres = null; + Response response = null; int statusCode = -1; try { if (overrideLocalHost == null) { - overrideLocalHost = - AAIConfig.get(AAIConstants.AAI_LOCAL_OVERRIDE, AAIConstants.AAI_LOCAL_OVERRIDE_DEFAULT); + overrideLocalHost = AAIConfig.get(AAIConstants.AAI_LOCAL_OVERRIDE, + AAIConstants.AAI_LOCAL_OVERRIDE_DEFAULT); } if (AAIConstants.AAI_LOCAL_OVERRIDE_DEFAULT.equals(overrideLocalHost)) { url = String.format(AAIConstants.AAI_LOCAL_REST, AAIConstants.AAI_RESOURCES_PORT, @@ -578,11 +603,14 @@ public class RestController implements RestControllerInterface { do { - cres = client.resource(url).accept("application/json").header("X-TransactionId", transId) - .header("X-FromAppId", sourceID).header("X-HTTP-Method-Override", "PATCH") - .type("application/merge-patch+json").entity(t).post(ClientResponse.class); + response = client.target(url) + .request(MediaType.APPLICATION_JSON) + .header("X-TransactionId", transId) + .header("X-FromAppId", sourceID) + .header("X-HTTP-Method-Override", "PATCH") + .post(Entity.entity(t, "application/merge-patch+json")); - statusCode = cres.getStatus(); + statusCode = response.getStatus(); if (statusCode >= 200 && statusCode <= 299) { LOGGER.debug(methodName + "REST api PATCH was successful!"); @@ -598,7 +626,7 @@ public class RestController implements RestControllerInterface { LOGGER.debug(methodName + "Unable to make the patch request to url " + url + " even after trying = " + numRetries + " times."); throw new AAIException("AAI_7116", methodName + " with status=" + statusCode + ", url=" + url + ", msg=" - + cres.getEntity(String.class)); + + response.readEntity(String.class)); } catch (AAIException e) { throw new AAIException("AAI_7116", methodName + " with url=" + url + ", Exception: " + e.toString()); diff --git a/aai-core/src/main/java/org/onap/aai/util/StoreNotificationEvent.java b/aai-core/src/main/java/org/onap/aai/util/StoreNotificationEvent.java deleted file mode 100644 index 127cf538..00000000 --- a/aai-core/src/main/java/org/onap/aai/util/StoreNotificationEvent.java +++ /dev/null @@ -1,452 +0,0 @@ -/** - * ============LICENSE_START======================================================= - * org.onap.aai - * ================================================================================ - * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.aai.util; - -import java.io.StringWriter; -import java.util.Iterator; -import java.util.UUID; - -import javax.xml.bind.Marshaller; - -import org.eclipse.persistence.dynamic.DynamicEntity; -import org.eclipse.persistence.jaxb.dynamic.DynamicJAXBContext; -import org.json.JSONException; -import org.json.JSONObject; -import org.onap.aai.domain.notificationEvent.NotificationEvent; -import org.onap.aai.exceptions.AAIException; -import org.onap.aai.introspection.Introspector; -import org.onap.aai.introspection.Loader; -import org.onap.aai.introspection.exceptions.AAIUnknownObjectException; -import org.onap.aai.kafka.AAIKafkaEventJMSProducer; -import org.onap.aai.kafka.MessageProducer; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.ApplicationContext; -import org.springframework.core.env.Environment; -import org.springframework.jms.core.JmsTemplate; - -public class StoreNotificationEvent { - - private static final Logger LOGGER = LoggerFactory.getLogger(StoreNotificationEvent.class); - - @Autowired JmsTemplate jmsTemplate; - - private final MessageProducer messageProducer; - private String fromAppId = ""; - private String transId = ""; - private final String transactionId; - private final String sourceOfTruth; - - private ApplicationContext context; - private Environment env; - - /** - * Instantiates a new store notification event. - */ - public StoreNotificationEvent(String transactionId, String sourceOfTruth) { - this.messageProducer = new AAIKafkaEventJMSProducer(jmsTemplate); - this.transactionId = transactionId; - this.sourceOfTruth = sourceOfTruth; - } - - public StoreNotificationEvent(MessageProducer producer, String transactionId, String sourceOfTruth) { - this.messageProducer = producer; - this.transactionId = transactionId; - this.sourceOfTruth = sourceOfTruth; - } - - /** - * Store event. - * - * @param eh - * the eh - * @param obj - * the obj - * @throws AAIException - * the AAI exception - */ - public String storeEventAndSendToJms(NotificationEvent.EventHeader eh, Object obj) throws AAIException { - - if (obj == null) { - throw new AAIException("AAI_7350"); - } - - org.onap.aai.domain.notificationEvent.ObjectFactory factory = - new org.onap.aai.domain.notificationEvent.ObjectFactory(); - - org.onap.aai.domain.notificationEvent.NotificationEvent ne = factory.createNotificationEvent(); - - if (eh.getId() == null) { - eh.setId(genDate2() + "-" + UUID.randomUUID().toString()); - } - if (eh.getTimestamp() == null) { - eh.setTimestamp(genDate()); - } - - // there's no default, but i think we want to put this in hbase? - - if (eh.getEntityLink() == null) { - eh.setEntityLink("UNK"); - } - - if (eh.getAction() == null) { - eh.setAction("UNK"); - } - - if (eh.getEventType() == null) { - eh.setEventType(AAIConfig.get("aai.notificationEvent.default.eventType", "UNK")); - } - - if (eh.getDomain() == null) { - eh.setDomain(AAIConfig.get("aai.notificationEvent.default.domain", "UNK")); - } - - if (eh.getSourceName() == null) { - eh.setSourceName(AAIConfig.get("aai.notificationEvent.default.sourceName", "UNK")); - } - - if (eh.getSequenceNumber() == null) { - eh.setSequenceNumber(AAIConfig.get("aai.notificationEvent.default.sequenceNumber", "UNK")); - } - - if (eh.getSeverity() == null) { - eh.setSeverity(AAIConfig.get("aai.notificationEvent.default.severity", "UNK")); - } - - if (eh.getVersion() == null) { - eh.setVersion(AAIConfig.get("aai.notificationEvent.default.version", "UNK")); - } - - ne.setCambriaPartition(AAIConstants.UEB_PUB_PARTITION_AAI); - ne.setEventHeader(eh); - ne.setEntity(obj); - - try { - PojoUtils pu = new PojoUtils(); - String entityJson = pu.getJsonFromObject(ne); - sendToKafkaJmsQueue(entityJson); - return entityJson; - } catch (Exception e) { - throw new AAIException("AAI_7350", e); - } - } - - /** - * Store dynamic event. - * - * @param notificationJaxbContext - * the notification jaxb context - * @param notificationVersion - * the notification version - * @param eventHeader - * the event header - * @param obj - * the obj - * @throws AAIException - * the AAI exception - */ - public void storeDynamicEvent(DynamicJAXBContext notificationJaxbContext, String notificationVersion, - DynamicEntity eventHeader, DynamicEntity obj) throws AAIException { - - if (obj == null) { - throw new AAIException("AAI_7350"); - } - - DynamicEntity notificationEvent = notificationJaxbContext - .getDynamicType("inventory.aai.onap.org." + notificationVersion + ".NotificationEvent") - .newDynamicEntity(); - - if (eventHeader.get("id") == null) { - eventHeader.set("id", genDate2() + "-" + UUID.randomUUID().toString()); - } - - if (eventHeader.get("timestamp") == null) { - eventHeader.set("timestamp", genDate()); - } - - if (eventHeader.get("entityLink") == null) { - eventHeader.set("entityLink", "UNK"); - } - - if (eventHeader.get("action") == null) { - eventHeader.set("action", "UNK"); - } - - if (eventHeader.get("eventType") == null) { - eventHeader.set("eventType", AAIConfig.get("aai.notificationEvent.default.eventType", "UNK")); - } - - if (eventHeader.get("domain") == null) { - eventHeader.set("domain", AAIConfig.get("aai.notificationEvent.default.domain", "UNK")); - } - - if (eventHeader.get("sourceName") == null) { - eventHeader.set("sourceName", AAIConfig.get("aai.notificationEvent.default.sourceName", "UNK")); - } - - if (eventHeader.get("sequenceNumber") == null) { - eventHeader.set("sequenceNumber", AAIConfig.get("aai.notificationEvent.default.sequenceNumber", "UNK")); - } - - if (eventHeader.get("severity") == null) { - eventHeader.set("severity", AAIConfig.get("aai.notificationEvent.default.severity", "UNK")); - } - - if (eventHeader.get("version") == null) { - eventHeader.set("version", AAIConfig.get("aai.notificationEvent.default.version", "UNK")); - } - - if (notificationEvent.get("cambriaPartition") == null) { - notificationEvent.set("cambriaPartition", AAIConstants.UEB_PUB_PARTITION_AAI); - } - - notificationEvent.set("eventHeader", eventHeader); - notificationEvent.set("entity", obj); - - try { - StringWriter result = new StringWriter(); - - Marshaller marshaller = notificationJaxbContext.createMarshaller(); - marshaller.setProperty(org.eclipse.persistence.jaxb.MarshallerProperties.MEDIA_TYPE, "application/json"); - marshaller.setProperty(org.eclipse.persistence.jaxb.MarshallerProperties.JSON_INCLUDE_ROOT, false); - marshaller.setProperty(org.eclipse.persistence.jaxb.MarshallerProperties.JSON_WRAPPER_AS_ARRAY_NAME, false); - marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, false); - marshaller.marshal(notificationEvent, result); - this.sendToKafkaJmsQueue(result.toString()); - - } catch (Exception e) { - throw new AAIException("AAI_7350", e); - } - } - - public String storeEventOnly(Loader loader, Introspector eventHeader, Introspector obj) throws AAIException { - if (obj == null) { - throw new AAIException("AAI_7350"); - } - - try { - final Introspector notificationEvent = loader.introspectorFromName("notification-event"); - - if (eventHeader.getValue("id") == null) { - eventHeader.setValue("id", genDate2() + "-" + UUID.randomUUID().toString()); - } - - if (eventHeader.getValue("timestamp") == null) { - eventHeader.setValue("timestamp", genDate()); - } - - if (eventHeader.getValue("entity-link") == null) { - eventHeader.setValue("entity-link", "UNK"); - } - - if (eventHeader.getValue("action") == null) { - eventHeader.setValue("action", "UNK"); - } - - if (eventHeader.getValue("event-type") == null) { - eventHeader.setValue("event-type", AAIConfig.get("aai.notificationEvent.default.eventType", "UNK")); - } - - if (eventHeader.getValue("domain") == null) { - eventHeader.setValue("domain", AAIConfig.get("aai.notificationEvent.default.domain", "UNK")); - } - - if (eventHeader.getValue("source-name") == null) { - eventHeader.setValue("source-name", AAIConfig.get("aai.notificationEvent.default.sourceName", "UNK")); - } - - if (eventHeader.getValue("sequence-number") == null) { - eventHeader.setValue("sequence-number", - AAIConfig.get("aai.notificationEvent.default.sequenceNumber", "UNK")); - } - - if (eventHeader.getValue("severity") == null) { - eventHeader.setValue("severity", AAIConfig.get("aai.notificationEvent.default.severity", "UNK")); - } - - if (eventHeader.getValue("version") == null) { - eventHeader.setValue("version", AAIConfig.get("aai.notificationEvent.default.version", "UNK")); - } - - if (notificationEvent.getValue("cambria-partition") == null) { - notificationEvent.setValue("cambria-partition", - AAIConfig.get("aai.notificationEvent.default.partition", AAIConstants.UEB_PUB_PARTITION_AAI)); - } - - notificationEvent.setValue("event-header", eventHeader.getUnderlyingObject()); - notificationEvent.setValue("entity", obj.getUnderlyingObject()); - - String entityJson = notificationEvent.marshal(false); - JSONObject entityJsonObject = new JSONObject(entityJson); - - JSONObject entityJsonObjectUpdated = new JSONObject(); - - JSONObject entityHeader = entityJsonObject.getJSONObject("event-header"); - String cambriaPartition = entityJsonObject.getString("cambria.partition"); - - entityJsonObject.remove("event-header"); - entityJsonObject.remove("cambria.partition"); - - entityJsonObjectUpdated.put("event-header", entityHeader); - entityJsonObjectUpdated.put("cambria.partition", cambriaPartition); - - Iterator<String> iter = entityJsonObject.keys(); - JSONObject entity = new JSONObject(); - if (iter.hasNext()) { - entity = entityJsonObject.getJSONObject(iter.next()); - } - - entityJsonObjectUpdated.put("entity", entity); - - return entityJsonObjectUpdated.toString(); - } catch (JSONException e) { - throw new AAIException("AAI_7350", e); - } catch (AAIUnknownObjectException e) { - throw new AAIException("AAI_7350", e); - } - } - - public String storeEventAndSendToJms(Loader loader, Introspector eventHeader, Introspector obj) - throws AAIException { - if (obj == null) { - throw new AAIException("AAI_7350"); - } - - try { - final Introspector notificationEvent = loader.introspectorFromName("notification-event"); - - if (eventHeader.getValue("id") == null) { - eventHeader.setValue("id", genDate2() + "-" + UUID.randomUUID().toString()); - } - - if (eventHeader.getValue("timestamp") == null) { - eventHeader.setValue("timestamp", genDate()); - } - - if (eventHeader.getValue("entity-link") == null) { - eventHeader.setValue("entity-link", "UNK"); - } - - if (eventHeader.getValue("action") == null) { - eventHeader.setValue("action", "UNK"); - } - - if (eventHeader.getValue("event-type") == null) { - eventHeader.setValue("event-type", AAIConfig.get("aai.notificationEvent.default.eventType", "UNK")); - } - - if (eventHeader.getValue("domain") == null) { - eventHeader.setValue("domain", AAIConfig.get("aai.notificationEvent.default.domain", "UNK")); - } - - if (eventHeader.getValue("source-name") == null) { - eventHeader.setValue("source-name", AAIConfig.get("aai.notificationEvent.default.sourceName", "UNK")); - } - - if (eventHeader.getValue("sequence-number") == null) { - eventHeader.setValue("sequence-number", - AAIConfig.get("aai.notificationEvent.default.sequenceNumber", "UNK")); - } - - if (eventHeader.getValue("severity") == null) { - eventHeader.setValue("severity", AAIConfig.get("aai.notificationEvent.default.severity", "UNK")); - } - - if (eventHeader.getValue("version") == null) { - eventHeader.setValue("version", AAIConfig.get("aai.notificationEvent.default.version", "UNK")); - } - - if (notificationEvent.getValue("cambria-partition") == null) { - notificationEvent.setValue("cambria-partition", - AAIConfig.get("aai.notificationEvent.default.partition", AAIConstants.UEB_PUB_PARTITION_AAI)); - } - - notificationEvent.setValue("event-header", eventHeader.getUnderlyingObject()); - notificationEvent.setValue("entity", obj.getUnderlyingObject()); - - String entityJson = notificationEvent.marshal(false); - sendToKafkaJmsQueue(entityJson); - return entityJson; - } catch (JSONException e) { - throw new AAIException("AAI_7350", e); - } catch (AAIUnknownObjectException e) { - throw new AAIException("AAI_7350", e); - } - } - - private void sendToKafkaJmsQueue(String entityString) throws JSONException { - - JSONObject entityJsonObject = new JSONObject(entityString); - - JSONObject entityJsonObjectUpdated = new JSONObject(); - JSONObject finalJson = new JSONObject(); - - JSONObject entityHeader = entityJsonObject.getJSONObject("event-header"); - String cambriaPartition = entityJsonObject.getString("cambria.partition"); - - entityJsonObject.remove("event-header"); - entityJsonObject.remove("cambria.partition"); - - entityJsonObjectUpdated.put("event-header", entityHeader); - entityJsonObjectUpdated.put("cambria.partition", cambriaPartition); - - String transId = entityHeader.getString("id"); - String fromAppId = entityHeader.getString("source-name"); - - Iterator<String> iter = entityJsonObject.keys(); - JSONObject entity = new JSONObject(); - if (iter.hasNext()) { - entity = entityJsonObject.getJSONObject(iter.next()); - } - - entityJsonObjectUpdated.put("entity", entity); - - finalJson.put("event-topic", "AAI-EVENT"); - finalJson.put("transId", transId); - finalJson.put("fromAppId", fromAppId); - finalJson.put("fullId", ""); - finalJson.put("aaiEventPayload", entityJsonObjectUpdated); - - messageProducer.sendMessageToDefaultDestination(finalJson); - } - - /** - * Gen date. - * - * @return the string - */ - public static String genDate() { - FormatDate fd = new FormatDate("YYYYMMdd-HH:mm:ss:SSS"); - return fd.getDateTime(); - } - - /** - * Gen date 2. - * - * @return the string - */ - public static String genDate2() { - FormatDate fd = new FormatDate("YYYYMMddHHmmss"); - return fd.getDateTime(); - } - -} diff --git a/aai-core/src/main/java/org/onap/aai/util/delta/DeltaEvents.java b/aai-core/src/main/java/org/onap/aai/util/delta/DeltaEvents.java index 39a03777..b255687d 100644 --- a/aai-core/src/main/java/org/onap/aai/util/delta/DeltaEvents.java +++ b/aai-core/src/main/java/org/onap/aai/util/delta/DeltaEvents.java @@ -27,33 +27,25 @@ import java.util.Date; import java.util.Map; import org.onap.aai.db.props.AAIProperties; -import org.onap.aai.kafka.MessageProducer; +import org.onap.aai.domain.deltaEvent.DeltaEvent; +import org.onap.aai.domain.notificationEvent.NotificationEvent.EventHeader; +import org.onap.aai.kafka.DeltaProducer; import org.onap.aai.util.AAIConfig; import org.springframework.beans.factory.annotation.Autowired; -import com.google.gson.FieldNamingPolicy; -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; -import com.google.gson.JsonObject; - public class DeltaEvents { - - private static final Gson gson = - new GsonBuilder().setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_DASHES).create(); - private static final String eventVersion = "v1"; - private final String transId; private final String sourceName; private final String schemaVersion; private final Map<String, ObjectDelta> objectDeltas; - @Autowired private MessageProducer messageProducer; + @Autowired private DeltaProducer deltaProducer; public DeltaEvents(String transId, String sourceName, String schemaVersion, Map<String, ObjectDelta> objectDeltas) { - this.transId = transId; - this.sourceName = sourceName; - this.schemaVersion = schemaVersion; - this.objectDeltas = objectDeltas; + this.transId = transId; + this.sourceName = sourceName; + this.schemaVersion = schemaVersion; + this.objectDeltas = objectDeltas; } public boolean triggerEvents() { @@ -61,44 +53,35 @@ public class DeltaEvents { return false; } - JsonObject finalJson = new JsonObject(); - finalJson.addProperty("event-topic", "DELTA"); - finalJson.addProperty("transId", transId); - finalJson.addProperty("fromAppId", sourceName); - finalJson.addProperty("fullId", ""); - finalJson.add("aaiEventPayload", buildEvent()); - - this.messageProducer.sendMessageToDefaultDestination(finalJson.toString()); + deltaProducer.sendNotification(buildEvent()); return true; } - private JsonObject buildEvent() { - JsonObject event = new JsonObject(); - event.addProperty("cambria.partition", this.getPartition()); - event.add("event-header", getHeader()); - event.add("entities", gson.toJsonTree(objectDeltas.values())); - return event; + private DeltaEvent buildEvent() { + DeltaEvent deltaEvent = new DeltaEvent(); + deltaEvent.setCambriaPartition(getPartition()); + deltaEvent.setEventHeader(getHeader()); + deltaEvent.setEntities(objectDeltas.values()); + return deltaEvent; } private String getPartition() { return "DELTA"; } - private JsonObject getHeader() { + private EventHeader getHeader() { ObjectDelta first = objectDeltas.values().iterator().next(); - JsonObject header = new JsonObject(); - header.addProperty("id", this.transId); - header.addProperty("timestamp", this.getTimeStamp(first.getTimestamp())); - header.addProperty("source-name", this.sourceName); - header.addProperty("domain", this.getDomain()); - header.addProperty("event-type", this.getEventType()); - header.addProperty("event-version", eventVersion); - header.addProperty("schema-version", this.schemaVersion); - header.addProperty("action", first.getAction().toString()); - header.addProperty("entity-type", this.getEntityType(first)); - header.addProperty("entity-link", first.getUri()); - header.addProperty("entity-uuid", this.getUUID(first)); - + EventHeader header = new EventHeader(); + header.setId(this.transId); + header.setTimestamp(this.getTimeStamp(first.getTimestamp())); + header.setSourceName(this.sourceName); + header.setDomain(this.getDomain()); + header.setEventType(this.getEventType()); + header.setVersion(this.schemaVersion); + header.setAction(first.getAction().toString()); + header.setEntityType(this.getEntityType(first)); + header.setEntityLink(first.getUri()); + header.setEntityUuid(this.getUUID(first)); return header; } diff --git a/aai-core/src/main/java/org/onap/aai/util/delta/ObjectDelta.java b/aai-core/src/main/java/org/onap/aai/util/delta/ObjectDelta.java index 23476675..7af30db9 100644 --- a/aai-core/src/main/java/org/onap/aai/util/delta/ObjectDelta.java +++ b/aai-core/src/main/java/org/onap/aai/util/delta/ObjectDelta.java @@ -20,7 +20,9 @@ package org.onap.aai.util.delta; -import com.google.gson.annotations.SerializedName; +import com.fasterxml.jackson.annotation.JsonProperty; + +import lombok.Data; import java.util.ArrayList; import java.util.HashMap; @@ -29,24 +31,17 @@ import java.util.Map; import org.apache.commons.lang3.builder.ToStringBuilder; +@Data public class ObjectDelta { - @SerializedName("uri") private String uri; - - @SerializedName("action") private DeltaAction action; - - @SerializedName("source-of-truth") + @JsonProperty("source-of-truth") private String sourceOfTruth; - - @SerializedName("timestamp") private long timestamp; - - @SerializedName("property-deltas") + @JsonProperty("property-deltas") private Map<String, PropertyDelta> propertyDeltas = new HashMap<>(); - - @SerializedName("relationship-deltas") + @JsonProperty("relationship-deltas") private List<RelationshipDelta> relationshipDeltas = new ArrayList<>(); public ObjectDelta(String uri, DeltaAction action, String sourceOfTruth, long timestamp) { @@ -64,54 +59,6 @@ public class ObjectDelta { relationshipDeltas.add(relationshipDelta); } - public String getUri() { - return uri; - } - - public void setUri(String uri) { - this.uri = uri; - } - - public DeltaAction getAction() { - return action; - } - - public void setAction(DeltaAction action) { - this.action = action; - } - - public String getSourceOfTruth() { - return sourceOfTruth; - } - - public void setSourceOfTruth(String sourceOfTruth) { - this.sourceOfTruth = sourceOfTruth; - } - - public long getTimestamp() { - return timestamp; - } - - public void setTimestamp(long timestamp) { - this.timestamp = timestamp; - } - - public void setPropertyDeltas(Map<String, PropertyDelta> propertyDeltas) { - this.propertyDeltas = propertyDeltas; - } - - public void setRelationshipDeltas(List<RelationshipDelta> relationshipDeltas) { - this.relationshipDeltas = relationshipDeltas; - } - - public Map<String, PropertyDelta> getPropertyDeltas() { - return propertyDeltas; - } - - public List<RelationshipDelta> getRelationshipDeltas() { - return relationshipDeltas; - } - @Override public String toString() { return new ToStringBuilder(this).append("uri", uri).append("action", action) diff --git a/aai-core/src/main/java/org/onap/aai/util/delta/PropertyDelta.java b/aai-core/src/main/java/org/onap/aai/util/delta/PropertyDelta.java index 98296d35..62890ffc 100644 --- a/aai-core/src/main/java/org/onap/aai/util/delta/PropertyDelta.java +++ b/aai-core/src/main/java/org/onap/aai/util/delta/PropertyDelta.java @@ -20,19 +20,18 @@ package org.onap.aai.util.delta; -import com.google.gson.annotations.SerializedName; +import com.fasterxml.jackson.annotation.JsonProperty; + +import lombok.Data; import org.apache.commons.lang3.builder.ToStringBuilder; +@Data public class PropertyDelta { - @SerializedName("action") protected DeltaAction action; - - @SerializedName("value") protected Object value; - - @SerializedName("old-value") + @JsonProperty("old-value") private Object oldValue; public PropertyDelta(DeltaAction action, Object value) { @@ -45,30 +44,6 @@ public class PropertyDelta { this.oldValue = oldValue; } - public DeltaAction getAction() { - return action; - } - - public void setAction(DeltaAction action) { - this.action = action; - } - - public Object getValue() { - return value; - } - - public void setValue(Object value) { - this.value = value; - } - - public Object getOldValue() { - return oldValue; - } - - public void setOldValue(Object oldValue) { - this.oldValue = oldValue; - } - @Override public String toString() { return new ToStringBuilder(this).append("action", action).append("value", value).append("oldValue", oldValue) diff --git a/aai-core/src/main/java/org/onap/aai/web/KafkaConfig.java b/aai-core/src/main/java/org/onap/aai/web/KafkaConfig.java deleted file mode 100644 index c1e8357d..00000000 --- a/aai-core/src/main/java/org/onap/aai/web/KafkaConfig.java +++ /dev/null @@ -1,185 +0,0 @@ -/** - * ============LICENSE_START======================================================= - * org.onap.aai - * ================================================================================ - * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.aai.web; - -import java.util.HashMap; -import java.util.Map; - -import javax.annotation.PostConstruct; -import javax.jms.ConnectionFactory; -import javax.jms.MessageListener; -import javax.jms.Queue; - -import org.apache.activemq.ActiveMQConnectionFactory; -import org.apache.activemq.broker.BrokerService; -import org.apache.activemq.command.ActiveMQQueue; -import org.apache.kafka.clients.producer.ProducerConfig; -import org.onap.aai.introspection.LoaderFactory; -import org.onap.aai.kafka.AAIKafkaEventJMSConsumer; -import org.onap.aai.kafka.AAIKafkaEventJMSProducer; -import org.onap.aai.kafka.MessageProducer; -import org.onap.aai.rest.notification.NotificationService; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.Profile; -import org.springframework.jms.connection.CachingConnectionFactory; -import org.springframework.jms.core.JmsTemplate; -import org.springframework.jms.listener.DefaultMessageListenerContainer; -import org.springframework.kafka.core.DefaultKafkaProducerFactory; -import org.springframework.kafka.core.KafkaTemplate; -import org.springframework.kafka.core.ProducerFactory; - -@Profile("kafka") -@Configuration -public class KafkaConfig { - - @Value("${jms.bind.address}") - private String bindAddress; - - @Value("${spring.kafka.producer.bootstrap-servers}") - private String bootstrapServers; - - @Value("${spring.kafka.producer.properties.security.protocol}") - private String securityProtocol; - - @Value("${spring.kafka.producer.properties.sasl.mechanism}") - private String saslMechanism; - - @Value("${spring.kafka.producer.properties.sasl.jaas.config}") - private String saslJaasConfig; - - @Value("${spring.kafka.producer.retries}") - private String retries; - - private static final Logger logger = LoggerFactory.getLogger(KafkaConfig.class); - - @PostConstruct - public void init() { - System.setProperty("activemq.tcp.url", bindAddress); - } - - @Bean(destroyMethod = "stop") - public BrokerService brokerService() throws Exception { - - BrokerService broker = new BrokerService(); - broker.addConnector(bindAddress); - broker.setPersistent(false); - broker.setUseJmx(false); - broker.setSchedulerSupport(false); - broker.start(); - - return broker; - } - - @ConditionalOnMissingBean - @Bean(name = "connectionFactory") - public ConnectionFactory activeMQConnectionFactory() { - return new ActiveMQConnectionFactory(bindAddress); - } - - @Bean - @ConditionalOnMissingBean - public CachingConnectionFactory cachingConnectionFactory(ConnectionFactory targetConnectionFactory) { - return new CachingConnectionFactory(targetConnectionFactory); - } - - @Bean(name = "destinationQueue") - public Queue activeMQQueue() { - return new ActiveMQQueue("IN_QUEUE"); - } - - @Bean - public JmsTemplate jmsTemplate(ConnectionFactory connectionFactory, Queue queue) { - JmsTemplate jmsTemplate = new JmsTemplate(); - - jmsTemplate.setConnectionFactory(connectionFactory); - jmsTemplate.setDefaultDestination(queue); - - return jmsTemplate; - } - - @Bean(name = "jmsConsumer") - public MessageListener jmsConsumer(KafkaTemplate<String, String> kafkaTemplate) throws Exception { - return new AAIKafkaEventJMSConsumer(kafkaTemplate); - } - - @Bean - public DefaultMessageListenerContainer defaultMessageListenerContainer(ConnectionFactory connectionFactory, MessageListener messageListener) - throws Exception { - - DefaultMessageListenerContainer messageListenerContainer = new DefaultMessageListenerContainer(); - - messageListenerContainer.setConnectionFactory(connectionFactory); - messageListenerContainer.setDestinationName("IN_QUEUE"); - messageListenerContainer.setMessageListener(messageListener); - - return messageListenerContainer; - } - - @Bean - public ProducerFactory<String, String> producerFactory() throws Exception { - Map<String, Object> props = new HashMap<>(); - if (bootstrapServers == null) { - logger.error("Environment Variable " + bootstrapServers + " is missing"); - throw new Exception("Environment Variable " + bootstrapServers + " is missing"); - } else { - props.put(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, bootstrapServers); - } - props.put("key.serializer", "org.apache.kafka.common.serialization.StringSerializer"); - props.put("value.serializer", "org.apache.kafka.common.serialization.StringSerializer"); - props.put(ProducerConfig.RETRIES_CONFIG, retries); - props.put(ProducerConfig.MAX_IN_FLIGHT_REQUESTS_PER_CONNECTION, "5"); - - if (saslJaasConfig == null) { - logger.info("Not using any authentication for kafka interaction"); - } else { - logger.info("Using authentication provided by kafka interaction"); - // Strimzi Kafka security properties - props.put("security.protocol", securityProtocol); - props.put("sasl.mechanism", saslMechanism); - props.put("sasl.jaas.config", saslJaasConfig); - } - - return new DefaultKafkaProducerFactory<>(props); - } - - @Bean - public KafkaTemplate<String, String> kafkaTemplate(ProducerFactory<String, String> producerFactory) throws Exception { - return new KafkaTemplate<>(producerFactory); - } - - @Bean - public MessageProducer messageProducer(JmsTemplate jmsTemplate) { - return new AAIKafkaEventJMSProducer(jmsTemplate); - } - - @Bean - @ConditionalOnMissingBean - public NotificationService notificationService(LoaderFactory loaderFactory, - @Value("${schema.uri.base.path}") String basePath, - @Value("${delta.events.enabled:false}") boolean isDeltaEventsEnabled) { - return new NotificationService(null, loaderFactory, basePath, isDeltaEventsEnabled); - } -} diff --git a/aai-core/src/main/resources/logback.xml b/aai-core/src/main/resources/logback.xml index ba5b3de8..6eb8ea47 100644 --- a/aai-core/src/main/resources/logback.xml +++ b/aai-core/src/main/resources/logback.xml @@ -245,7 +245,6 @@ <logger name="org.springframework" level="WARN" /> <logger name="org.springframework.beans" level="WARN" /> <logger name="org.springframework.web" level="WARN" /> - <logger name="com.blog.spring.jms" level="WARN" /> <logger name="com.jayway.jsonpath" level="WARN" /> <!-- AJSC Services (bootstrap services) --> diff --git a/aai-core/src/test/java/org/onap/aai/AAISetup.java b/aai-core/src/test/java/org/onap/aai/AAISetup.java index 08a0e91b..5273c6e7 100644 --- a/aai-core/src/test/java/org/onap/aai/AAISetup.java +++ b/aai-core/src/test/java/org/onap/aai/AAISetup.java @@ -40,7 +40,6 @@ import org.onap.aai.setup.AAIConfigTranslator; import org.onap.aai.setup.SchemaVersion; import org.onap.aai.setup.SchemaVersions; import org.onap.aai.util.AAIConstants; -import org.onap.aai.web.KafkaConfig; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.test.context.ContextConfiguration; @@ -54,11 +53,12 @@ import org.springframework.test.context.web.WebAppConfiguration; classes = {ConfigConfiguration.class, AAIConfigTranslator.class, EdgeIngestor.class, EdgeSerializer.class, NodeIngestor.class, SpringContextAware.class, IntrospectionConfig.class, RestBeanConfig.class, XmlFormatTransformerConfiguration.class, ValidationService.class, ValidationConfiguration.class, - KafkaConfig.class, LoaderFactory.class, NotificationService.class}) + KafkaConfig.class, LoaderFactory.class, NotificationService.class, KafkaConfig.class}) @TestPropertySource( properties = {"schema.uri.base.path = /aai", "schema.xsd.maxoccurs = 5000", "schema.translator.list=config", "schema.nodes.location=src/test/resources/onap/oxm", - "schema.edges.location=src/test/resources/onap/dbedgerules"}) + "schema.edges.location=src/test/resources/onap/dbedgerules", + "aai.notifications.enabled=false"}) public abstract class AAISetup { @ClassRule diff --git a/aai-core/src/test/java/org/onap/aai/DataLinkSetup.java b/aai-core/src/test/java/org/onap/aai/DataLinkSetup.java index b38a5c69..5ede5c22 100644 --- a/aai-core/src/test/java/org/onap/aai/DataLinkSetup.java +++ b/aai-core/src/test/java/org/onap/aai/DataLinkSetup.java @@ -49,13 +49,13 @@ import org.springframework.test.context.junit4.rules.SpringMethodRule; @ContextConfiguration( classes = {ConfigConfiguration.class, TestUtilConfigTranslatorforDataLink.class, EdgeIngestor.class, EdgeSerializer.class, NodeIngestor.class, SpringContextAware.class, IntrospectionConfig.class, - RestBeanConfig.class, XmlFormatTransformerConfiguration.class, LoaderFactory.class, NotificationService.class}) + RestBeanConfig.class, XmlFormatTransformerConfiguration.class, LoaderFactory.class, NotificationService.class, KafkaConfig.class}) @TestPropertySource( properties = {"schema.uri.base.path = /aai", "schema.xsd.maxoccurs = 5000", "schema.version.api.default = v4", "schema.version.edge.label.start = v4", "schema.version.depth.start = v3", "schema.version.app.root.start = v4", "schema.version.related.link.start = v4", "schema.version.namespace.change.start = v4", "schema.version.list = v1,v2,v3,v4", - "schema.translator.list = config"}) + "schema.translator.list = config","aai.notifications.enabled = false"}) @DirtiesContext(classMode = DirtiesContext.ClassMode.BEFORE_CLASS) public abstract class DataLinkSetup { diff --git a/aai-core/src/test/java/org/onap/aai/HttpTestUtil.java b/aai-core/src/test/java/org/onap/aai/HttpTestUtil.java index 49524c4e..62f63ea3 100644 --- a/aai-core/src/test/java/org/onap/aai/HttpTestUtil.java +++ b/aai-core/src/test/java/org/onap/aai/HttpTestUtil.java @@ -153,14 +153,6 @@ public class HttpTestUtil extends RESTAPI { doReturn(null).when(queryParameters).remove(any()); when(httpHeaders.getMediaType()).thenReturn(APPLICATION_JSON); - - try { - if (notification != null) { - doNothing().when(notification).triggerEvents(); - } - } catch (AAIException e) { - e.printStackTrace(); - } } public Response doPut(String uri, String payload) throws UnsupportedEncodingException, AAIException { diff --git a/aai-core/src/test/java/org/onap/aai/introspection/IntrospectorSerializationTest.java b/aai-core/src/test/java/org/onap/aai/introspection/IntrospectorSerializationTest.java new file mode 100644 index 00000000..60749ddd --- /dev/null +++ b/aai-core/src/test/java/org/onap/aai/introspection/IntrospectorSerializationTest.java @@ -0,0 +1,87 @@ +/** + * ============LICENSE_START======================================================= + * org.onap.aai + * ================================================================================ + * Copyright © 2024 Deutsche Telekom. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.aai.introspection; + +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; + +import org.junit.Before; +import org.junit.Test; +import org.onap.aai.AAISetup; +import org.onap.aai.domain.notificationEvent.NotificationEvent; +import org.onap.aai.domain.notificationEvent.NotificationEvent.EventHeader; +import org.onap.aai.introspection.exceptions.AAIUnmarshallingException; +import org.onap.aai.setup.SchemaVersion; +import org.skyscreamer.jsonassert.JSONAssert; + +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.module.jaxb.JaxbAnnotationModule; + +public class IntrospectorSerializationTest extends AAISetup { + + ObjectMapper mapper; + Loader loader; + + @Before + public void setup() { + loader = loaderFactory.getMoxyLoaderInstance().get(new SchemaVersion("v14")); + } + + @Test + public void serializePlain() throws IOException, AAIUnmarshallingException { + mapper = new ObjectMapper(); + + String pserver = new String(Files.readAllBytes(Path.of("src/test/resources/payloads/templates/pserver.json"))); + Introspector introspector = loader.unmarshal("pserver", pserver); + String result = mapper.writeValueAsString(introspector); + JSONAssert.assertEquals(pserver, result, false); + } + + @Test + public void serializeNotificationEvent() throws IOException, AAIUnmarshallingException { + mapper = new ObjectMapper(); + mapper.registerModule(new JaxbAnnotationModule()); + + String pserver = new String(Files.readAllBytes(Path.of("src/test/resources/payloads/templates/pserver.json"))).replace("${hostname}", "pserver1"); + Introspector introspector = loader.unmarshal("pserver", pserver); + + NotificationEvent notificationEvent = new NotificationEvent(); + notificationEvent.setCambriaPartition("AAI"); + notificationEvent.setEntity(introspector); + EventHeader eventHeader = new EventHeader(); + eventHeader.setSeverity("NORMAL"); + eventHeader.setEntityType("pserver"); + eventHeader.setTopEntityType("pserver"); + eventHeader.setEntityLink("/aai/v14/cloud-infrastructure/pservers/pserver/pserver1"); + eventHeader.setEventType("AAI-EVENT"); + eventHeader.setDomain("devINT1"); + eventHeader.setAction("CREATE"); + eventHeader.setSequenceNumber("0"); + eventHeader.setId("someTransaction"); + eventHeader.setSourceName("test"); + eventHeader.setVersion("v14"); + notificationEvent.setEventHeader(eventHeader); + String result = mapper.writeValueAsString(notificationEvent); + String expectedEvent = new String(Files.readAllBytes(Path.of("src/test/resources/payloads/expected/pserver-event.json"))); + JSONAssert.assertEquals(expectedEvent, result, false); + } +} diff --git a/aai-core/src/test/java/org/onap/aai/kafka/AAIKafkaEventIntegrationTest.java b/aai-core/src/test/java/org/onap/aai/kafka/AAIKafkaEventIntegrationTest.java index 0f5f47ad..d00fa818 100644 --- a/aai-core/src/test/java/org/onap/aai/kafka/AAIKafkaEventIntegrationTest.java +++ b/aai-core/src/test/java/org/onap/aai/kafka/AAIKafkaEventIntegrationTest.java @@ -20,16 +20,39 @@ package org.onap.aai.kafka; import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.mockito.ArgumentMatchers.anyBoolean; +import static org.mockito.Mockito.when; +import java.io.IOException; +import java.net.URI; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.ArrayList; import java.util.Collections; +import java.util.List; + +import javax.ws.rs.core.HttpHeaders; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.MultivaluedMap; +import javax.ws.rs.core.UriInfo; import org.apache.kafka.clients.consumer.Consumer; -import org.apache.kafka.clients.consumer.ConsumerRecord; import org.apache.kafka.clients.consumer.ConsumerRecords; +import org.junit.Before; +import org.junit.Ignore; import org.junit.Test; import org.mockito.Mock; import org.onap.aai.AAISetup; import org.onap.aai.PayloadUtil; +import org.onap.aai.domain.notificationEvent.NotificationEvent; +import org.onap.aai.exceptions.AAIException; +import org.onap.aai.introspection.Introspector; +import org.onap.aai.introspection.Loader; +import org.onap.aai.parsers.query.QueryParser; +import org.onap.aai.rest.db.DBRequest; +import org.onap.aai.restcore.HttpMethod; +import org.onap.aai.serialization.engines.TransactionalGraphEngine; +import org.onap.aai.setup.SchemaVersion; import org.skyscreamer.jsonassert.JSONAssert; import org.skyscreamer.jsonassert.JSONCompareMode; import org.springframework.beans.factory.annotation.Autowired; @@ -41,6 +64,9 @@ import org.springframework.kafka.test.utils.KafkaTestUtils; import org.springframework.test.context.ActiveProfiles; import org.springframework.test.context.TestPropertySource; +import com.fasterxml.jackson.databind.ObjectMapper; + +import lombok.SneakyThrows; import lombok.extern.slf4j.Slf4j; @Slf4j @@ -49,11 +75,11 @@ import lombok.extern.slf4j.Slf4j; @EmbeddedKafka(partitions = 1, topics = { "AAI-EVENT" }) @TestPropertySource( properties = { - "jms.bind.address=tcp://localhost:61647", "aai.events.enabled=true", "spring.kafka.producer.retries=0", "spring.kafka.producer.properties.sasl.jaas.config=#{null}", - "spring.kafka.producer.bootstrap-servers=${spring.embedded.kafka.brokers}" + "spring.kafka.producer.bootstrap-servers=${spring.embedded.kafka.brokers}", + "aai.notifications.enabled=true" }) public class AAIKafkaEventIntegrationTest extends AAISetup { @@ -61,12 +87,28 @@ public class AAIKafkaEventIntegrationTest extends AAISetup { private KafkaTemplate<String, String> kafkaTemplate; @Autowired - MessageProducer messageProducer; + ObjectMapper mapper; + + @Autowired + NotificationProducer messageProducer; @Autowired private ConsumerFactory<String, String> consumerFactory; + @Mock UriInfo uriInfoMock; + @Mock MultivaluedMap<String, String> queryParamsMock; + @Mock HttpHeaders headersMock; + + @Before + public void setup() { + when(headersMock.getAcceptableMediaTypes()).thenReturn(Collections.singletonList(MediaType.APPLICATION_JSON_TYPE)); + when(uriInfoMock.getQueryParameters(anyBoolean())).thenReturn(queryParamsMock); + when(queryParamsMock.getFirst("depth")).thenReturn("0"); + when(headersMock.getRequestHeader("aai-request-context")).thenReturn(null); + } + @Test + @Ignore public void onMessage_shouldSendMessageToKafkaTopic_whenAAIEventReceived() throws Exception { Consumer<String, String> consumer = consumerFactory.createConsumer(); @@ -74,8 +116,9 @@ public class AAIKafkaEventIntegrationTest extends AAISetup { consumer.subscribe(Collections.singletonList("AAI-EVENT")); String payload = PayloadUtil.getResourcePayload("aai-event.json"); + NotificationEvent event = mapper.readValue(payload, NotificationEvent.class); String expectedResponse = PayloadUtil.getExpectedPayload("aai-event.json"); - messageProducer.sendMessageToDefaultDestination(payload); + messageProducer.sendNotification(event); ConsumerRecords<String, String> consumerRecords = KafkaTestUtils.getRecords(consumer, 10000); assertFalse(consumerRecords.isEmpty()); @@ -84,4 +127,41 @@ public class AAIKafkaEventIntegrationTest extends AAISetup { }); } + @Test + public void thatEventsAreBeingCreated() throws AAIException, IOException { + Consumer<String, String> consumer = consumerFactory.createConsumer(); + consumer.subscribe(Collections.singletonList("AAI-EVENT")); + + traversalUriHttpEntry.setHttpEntryProperties(new SchemaVersion("v14")); + String pserverUri = "/aai/v14/cloud-infrastructure/pservers/pserver/pserver1"; + String entity = new String(Files.readAllBytes(Path.of("src/test/resources/payloads/templates/pserver.json"))).replace("${hostname}", "pserver1"); + DBRequest dbRequest = createDBRequest(pserverUri, entity); + List<DBRequest> dbRequests = new ArrayList<>(); + dbRequests.add(dbRequest); + + traversalUriHttpEntry.process(dbRequests, "test"); + + ConsumerRecords<String, String> consumerRecords = KafkaTestUtils.getRecords(consumer, 100000); + assertFalse(consumerRecords.isEmpty()); + String expectedResponse = PayloadUtil.getExpectedPayload("pserver-event.json"); + + consumerRecords.forEach(consumerRecord -> { + JSONAssert.assertEquals(expectedResponse, consumerRecord.value(), JSONCompareMode.LENIENT); + }); + } + + @SneakyThrows + private DBRequest createDBRequest(String uri, String entity) { + TransactionalGraphEngine dbEngine = traversalUriHttpEntry.getDbEngine(); + Loader loader = traversalUriHttpEntry.getLoader(); + URI uriObject = new URI(uri); + QueryParser uriQuery = dbEngine.getQueryBuilder().createQueryFromURI(uriObject); + String objName = uriQuery.getResultType(); + Introspector obj = loader.unmarshal(objName, entity, + org.onap.aai.restcore.MediaType.getEnum("application/json")); + return new DBRequest.Builder(HttpMethod.PUT, uriObject, uriQuery, obj, headersMock, uriInfoMock, "someTransaction") + .rawRequestContent(entity) + .build(); + } + } diff --git a/aai-core/src/test/java/org/onap/aai/prevalidation/ValidationServiceTest.java b/aai-core/src/test/java/org/onap/aai/prevalidation/ValidationServiceTest.java index 8ef1d706..db9ee961 100644 --- a/aai-core/src/test/java/org/onap/aai/prevalidation/ValidationServiceTest.java +++ b/aai-core/src/test/java/org/onap/aai/prevalidation/ValidationServiceTest.java @@ -24,9 +24,14 @@ import static org.hamcrest.CoreMatchers.containsString; import static org.hamcrest.CoreMatchers.is; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertThat; +import static org.mockito.ArgumentCaptor.forClass; import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.Mockito.verify; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.module.jaxb.JaxbAnnotationModule; import com.google.gson.Gson; import java.io.IOException; @@ -38,10 +43,13 @@ import org.apache.http.conn.ConnectTimeoutException; import org.junit.Before; import org.junit.Rule; import org.junit.Test; +import org.mockito.ArgumentCaptor; import org.mockito.Mockito; import org.onap.aai.PayloadUtil; +import org.onap.aai.domain.notificationEvent.NotificationEvent; import org.onap.aai.exceptions.AAIException; import org.onap.aai.restclient.RestClient; +import org.skyscreamer.jsonassert.JSONAssert; import org.springframework.boot.test.system.OutputCaptureRule; import org.springframework.http.HttpMethod; import org.springframework.http.ResponseEntity; @@ -56,12 +64,15 @@ public class ValidationServiceTest { public OutputCaptureRule capture = new OutputCaptureRule(); private Gson gson; + private ObjectMapper mapper; @Before public void setUp() throws Exception { + mapper = new ObjectMapper(); + mapper.registerModule(new JaxbAnnotationModule()); gson = new Gson(); restClient = Mockito.mock(RestClient.class); - validationService = Mockito.spy(new ValidationService(restClient, "JUNIT", "generic-vnf", null)); + validationService = Mockito.spy(new ValidationService(restClient, "JUNIT", "generic-vnf", null, mapper)); } @Test @@ -81,14 +92,19 @@ public class ValidationServiceTest { throws IOException, AAIException { String pserverRequest = PayloadUtil.getResourcePayload("prevalidation/success-request-with-no-violations.json"); + NotificationEvent notificationEvent = mapper.readValue(pserverRequest, NotificationEvent.class); Mockito.when(restClient.execute(eq(ValidationService.VALIDATION_ENDPOINT), eq(HttpMethod.POST), any(), - eq(pserverRequest))).thenThrow(new RuntimeException(new ConnectException("Connection refused"))); + anyString())).thenThrow(new RuntimeException(new ConnectException("Connection refused"))); - validationService.preValidate(pserverRequest); + validationService.preValidate(notificationEvent); assertThat(capture.toString(), containsString("Connection refused to the validation microservice due to service unreachable")); + ArgumentCaptor<String> bodyCaptor = forClass(String.class); + verify(restClient).execute(eq(ValidationService.VALIDATION_ENDPOINT), eq(HttpMethod.POST), any(), bodyCaptor.capture()); + + JSONAssert.assertEquals(pserverRequest, bodyCaptor.getValue(), false); } @Test @@ -96,15 +112,20 @@ public class ValidationServiceTest { throws IOException, AAIException { String pserverRequest = PayloadUtil.getResourcePayload("prevalidation/success-request-with-no-violations.json"); + NotificationEvent notificationEvent = mapper.readValue(pserverRequest, NotificationEvent.class); Mockito.when(restClient.execute(eq(ValidationService.VALIDATION_ENDPOINT), eq(HttpMethod.POST), any(), - eq(pserverRequest))) + anyString())) .thenThrow(new RuntimeException(new ConnectTimeoutException("Connection timed out"))); - validationService.preValidate(pserverRequest); + validationService.preValidate(notificationEvent); assertThat(capture.toString(), containsString( "Connection timeout to the validation microservice as this could indicate the server is unable to reach port")); + ArgumentCaptor<String> bodyCaptor = forClass(String.class); + verify(restClient).execute(eq(ValidationService.VALIDATION_ENDPOINT), eq(HttpMethod.POST), any(), bodyCaptor.capture()); + + JSONAssert.assertEquals(pserverRequest, bodyCaptor.getValue(), false); } @Test @@ -112,22 +133,28 @@ public class ValidationServiceTest { throws IOException, AAIException { String pserverRequest = PayloadUtil.getResourcePayload("prevalidation/success-request-with-no-violations.json"); + NotificationEvent notificationEvent = mapper.readValue(pserverRequest, NotificationEvent.class); String validationResponse = PayloadUtil.getResourcePayload("prevalidation/success-response-with-empty-violations.json"); ResponseEntity responseEntity = Mockito.mock(ResponseEntity.class, Mockito.RETURNS_DEEP_STUBS); Mockito.when(restClient.execute(eq(ValidationService.VALIDATION_ENDPOINT), eq(HttpMethod.POST), any(), - eq(pserverRequest))).thenReturn(responseEntity); + anyString())).thenReturn(responseEntity); Mockito.when(responseEntity.getStatusCodeValue()).thenReturn(200); Mockito.when(responseEntity.getBody()).thenReturn(validationResponse); Mockito.doReturn(true).when(validationService).isSuccess(responseEntity); - List<String> errorMessages = validationService.preValidate(pserverRequest); + List<String> errorMessages = validationService.preValidate(notificationEvent); assertNotNull("Expected the error messages to be not null", errorMessages); assertThat(errorMessages.size(), is(0)); + + ArgumentCaptor<String> bodyCaptor = forClass(String.class); + verify(restClient).execute(eq(ValidationService.VALIDATION_ENDPOINT), eq(HttpMethod.POST), any(), bodyCaptor.capture()); + + JSONAssert.assertEquals(pserverRequest, bodyCaptor.getValue(), false); } @Test @@ -135,16 +162,21 @@ public class ValidationServiceTest { throws IOException, AAIException { String pserverRequest = PayloadUtil.getResourcePayload("prevalidation/success-request-with-no-violations.json"); + NotificationEvent notificationEvent = mapper.readValue(pserverRequest, NotificationEvent.class); Mockito.when(restClient.execute(eq(ValidationService.VALIDATION_ENDPOINT), eq(HttpMethod.POST), any(), - eq(pserverRequest))) + anyString())) .thenThrow(new RuntimeException( new SocketTimeoutException("Request timed out due to taking longer than client expected"))); - validationService.preValidate(pserverRequest); + validationService.preValidate(notificationEvent); assertThat(capture.toString(), containsString("Request to validation service took longer than the currently set timeout")); + ArgumentCaptor<String> bodyCaptor = forClass(String.class); + verify(restClient).execute(eq(ValidationService.VALIDATION_ENDPOINT), eq(HttpMethod.POST), any(), bodyCaptor.capture()); + + JSONAssert.assertEquals(pserverRequest, bodyCaptor.getValue(), false); } @Test diff --git a/aai-core/src/test/java/org/onap/aai/query/builder/QueryBuilderTestAbstraction.java b/aai-core/src/test/java/org/onap/aai/query/builder/QueryBuilderTestAbstraction.java index 8f4a209b..7685360b 100644 --- a/aai-core/src/test/java/org/onap/aai/query/builder/QueryBuilderTestAbstraction.java +++ b/aai-core/src/test/java/org/onap/aai/query/builder/QueryBuilderTestAbstraction.java @@ -42,6 +42,7 @@ import org.junit.*; import org.junit.runner.RunWith; import org.onap.aai.config.ConfigConfiguration; import org.onap.aai.config.IntrospectionConfig; +import org.onap.aai.config.KafkaConfig; import org.onap.aai.config.SpringContextAware; import org.onap.aai.config.XmlFormatTransformerConfiguration; import org.onap.aai.db.props.AAIProperties; @@ -68,11 +69,12 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; @ContextConfiguration( classes = {ConfigConfiguration.class, QueryTestsConfigTranslator.class, NodeIngestor.class, EdgeIngestor.class, EdgeSerializer.class, SpringContextAware.class, IntrospectionConfig.class, - XmlFormatTransformerConfiguration.class, LoaderFactory.class, NotificationService.class}) + XmlFormatTransformerConfiguration.class, LoaderFactory.class, NotificationService.class, KafkaConfig.class}) @DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_CLASS) @TestPropertySource( properties = {"schema.translator.list = config", "schema.nodes.location=src/test/resources/onap/oxm", - "schema.edges.location=src/test/resources/onap/dbedgerules"}) + "schema.edges.location=src/test/resources/onap/dbedgerules", + "aai.notifications.enabled=false"}) public abstract class QueryBuilderTestAbstraction { protected Loader loader; diff --git a/aai-core/src/test/java/org/onap/aai/rest/ImpliedDeleteIntegrationTest.java b/aai-core/src/test/java/org/onap/aai/rest/ImpliedDeleteIntegrationTest.java index 218c3a24..38731288 100644 --- a/aai-core/src/test/java/org/onap/aai/rest/ImpliedDeleteIntegrationTest.java +++ b/aai-core/src/test/java/org/onap/aai/rest/ImpliedDeleteIntegrationTest.java @@ -45,8 +45,9 @@ import org.onap.aai.HttpTestUtil; import org.onap.aai.PayloadUtil; import org.onap.aai.db.props.AAIProperties; import org.onap.aai.dbmap.AAIGraph; +import org.onap.aai.domain.notificationEvent.NotificationEvent; +import org.onap.aai.domain.notificationEvent.NotificationEvent.EventHeader; import org.onap.aai.introspection.ModelType; -import org.onap.aai.rest.notification.NotificationEvent; import org.onap.aai.rest.notification.UEBNotification; import org.onap.aai.serialization.engines.QueryStyle; import org.skyscreamer.jsonassert.JSONAssert; @@ -73,7 +74,7 @@ public class ImpliedDeleteIntegrationTest extends AAISetup { String uri = "/aai/v12/cloud-infrastructure/pservers/pserver/test-pserver-implied-delete"; - UEBNotification notification = Mockito.spy(new UEBNotification(ModelType.MOXY, loaderFactory, schemaVersions)); + UEBNotification notification = Mockito.spy(new UEBNotification(loaderFactory, schemaVersions)); HttpTestUtil httpTestUtil = new HttpTestUtil(queryStyle, notification, AAIProperties.MINIMUM_DEPTH); String resource = PayloadUtil.getResourcePayload("pserver-implied-delete.json"); @@ -91,7 +92,7 @@ public class ImpliedDeleteIntegrationTest extends AAISetup { JSONAssert.assertEquals(resource, response.getEntity().toString(), false); jsonObject.getJSONObject("p-interfaces").remove("p-interface"); - notification = Mockito.spy(new UEBNotification(ModelType.MOXY, loaderFactory, schemaVersions)); + notification = Mockito.spy(new UEBNotification(loaderFactory, schemaVersions)); httpTestUtil = new HttpTestUtil(queryStyle, notification, AAIProperties.MINIMUM_DEPTH); response = httpTestUtil.doPut(uri, jsonObject.toString()); @@ -100,10 +101,11 @@ public class ImpliedDeleteIntegrationTest extends AAISetup { List<NotificationEvent> notificationEvents = notification.getEvents(); assertThat(notificationEvents.size(), is(5)); - List<String> notificationEventHeaders = notification.getEvents().stream() - .map(event -> event.getEventHeader().marshal(false)).collect(Collectors.toList()); + List<EventHeader> notificationEventHeaders = notification.getEvents().stream() + .map(NotificationEvent::getEventHeader) + .collect(Collectors.toList()); - Long deletedEventsCount = notificationEventHeaders.stream().filter(e -> e.contains("\"DELETE\"")).count(); + Long deletedEventsCount = notificationEventHeaders.stream().filter(e -> "DELETE".equals(e.getAction())).count(); assertThat(deletedEventsCount, is(4L)); diff --git a/aai-core/src/test/java/org/onap/aai/rest/NotificationDmaapEventTest.java b/aai-core/src/test/java/org/onap/aai/rest/NotificationDmaapEventTest.java index 4b52462e..0eafdf1c 100644 --- a/aai-core/src/test/java/org/onap/aai/rest/NotificationDmaapEventTest.java +++ b/aai-core/src/test/java/org/onap/aai/rest/NotificationDmaapEventTest.java @@ -26,6 +26,7 @@ import static org.hamcrest.CoreMatchers.not; import static org.hamcrest.junit.MatcherAssert.assertThat; import static org.junit.Assert.assertEquals; +import com.fasterxml.jackson.databind.ObjectMapper; import com.google.gson.JsonObject; import com.google.gson.JsonParser; @@ -55,24 +56,29 @@ import org.onap.aai.HttpTestUtil; import org.onap.aai.PayloadUtil; import org.onap.aai.db.props.AAIProperties; import org.onap.aai.dbmap.AAIGraph; +import org.onap.aai.domain.notificationEvent.NotificationEvent; +import org.onap.aai.domain.notificationEvent.NotificationEvent.EventHeader; import org.onap.aai.exceptions.AAIException; import org.onap.aai.introspection.ModelType; -import org.onap.aai.rest.notification.NotificationEvent; import org.onap.aai.rest.notification.UEBNotification; import org.onap.aai.serialization.engines.QueryStyle; import org.skyscreamer.jsonassert.JSONAssert; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.annotation.DirtiesContext; @RunWith(value = Parameterized.class) @DirtiesContext(classMode = DirtiesContext.ClassMode.BEFORE_CLASS) public class NotificationDmaapEventTest extends AAISetup { +// ObjectMapper mapper = new ObjectMapper(); + @Autowired private ObjectMapper mapper; + @Parameterized.Parameter public QueryStyle queryStyle; @Parameterized.Parameters(name = "QueryStyle.{0}") public static Collection<Object[]> data() { - return Arrays.asList(new Object[][] {{QueryStyle.TRAVERSAL}, {QueryStyle.TRAVERSAL_URI}}); + return Arrays.asList(new Object[][] {{QueryStyle.TRAVERSAL}}); } @Test @@ -80,7 +86,7 @@ public class NotificationDmaapEventTest extends AAISetup { throws IOException, AAIException { String uri = "/aai/v14/cloud-infrastructure/pservers/pserver/example-hostname-val-85598"; - UEBNotification notification = Mockito.spy(new UEBNotification(ModelType.MOXY, loaderFactory, schemaVersions)); + UEBNotification notification = Mockito.spy(new UEBNotification(loaderFactory, schemaVersions)); HttpTestUtil httpTestUtil = new HttpTestUtil(queryStyle, notification, AAIProperties.MINIMUM_DEPTH); String resource = PayloadUtil.getResourcePayload("pserver-with-children-for-notification.json"); @@ -97,13 +103,8 @@ public class NotificationDmaapEventTest extends AAISetup { // Verify all the events are create since its a new PUT notification.getEvents().forEach((event) -> { - - String header = event.getEventHeader().marshal(false); - - assertThat(event.getEventHeader().marshal(false), containsString("\"CREATE\"")); - - assertThat(header, containsString("\"top-entity-type\":\"pserver\"")); - + assertEquals("CREATE", event.getEventHeader().getAction()); + assertEquals("pserver", event.getEventHeader().getTopEntityType()); }); response = httpTestUtil.doGet(uri); @@ -116,7 +117,7 @@ public class NotificationDmaapEventTest extends AAISetup { throws IOException, AAIException { String uri = "/aai/v14/cloud-infrastructure/pservers/pserver/example-hostname-val-85598"; - UEBNotification notification = Mockito.spy(new UEBNotification(ModelType.MOXY, loaderFactory, schemaVersions)); + UEBNotification notification = Mockito.spy(new UEBNotification(loaderFactory, schemaVersions)); HttpTestUtil httpTestUtil = new HttpTestUtil(queryStyle); String pserverResource = PayloadUtil.getResourcePayload("pserver-with-children-for-notification.json"); @@ -147,19 +148,20 @@ public class NotificationDmaapEventTest extends AAISetup { List<NotificationEvent> events = notification.getEvents(); assertThat(events.size(), is(2)); - String notificationEventHeader = events.get(1).getEventHeader().marshal(false); - String notificationEventBody = events.get(1).getObj().marshal(false); + EventHeader notificationEventHeader = events.get(1).getEventHeader(); + String notificationEventBody = events.get(1).getEntity().toString(); - assertThat(notificationEventHeader, containsString("\"action\":\"CREATE\"")); - assertThat(notificationEventHeader, containsString("\"entity-type\":\"p-interface\"")); - assertThat(notificationEventHeader, containsString("\"top-entity-type\":\"pserver\"")); + assertEquals("CREATE", notificationEventHeader.getAction()); + assertEquals("p-interface", notificationEventHeader.getEntityType()); + assertEquals("pserver", notificationEventHeader.getTopEntityType()); String expectedNotificationHeader = PayloadUtil.getResourcePayload( "notification-dmaap-events/depth-zero/expected-notification-header-create-child-on-existing-obj.json"); String expectedNotificationBody = PayloadUtil.getResourcePayload( "notification-dmaap-events/depth-zero/expected-notification-body-create-child-on-existing-obj.json"); - JSONAssert.assertEquals(expectedNotificationHeader, notificationEventHeader, false); + String eventHeaderJson = mapper.writeValueAsString(events.get(1).getEventHeader()); + JSONAssert.assertEquals(expectedNotificationHeader, eventHeaderJson, false); JSONAssert.assertEquals(expectedNotificationBody, notificationEventBody, false); } @@ -168,7 +170,7 @@ public class NotificationDmaapEventTest extends AAISetup { throws IOException, AAIException { String uri = "/aai/v14/cloud-infrastructure/pservers/pserver/example-hostname-val-85598"; - UEBNotification notification = Mockito.spy(new UEBNotification(ModelType.MOXY, loaderFactory, schemaVersions)); + UEBNotification notification = Mockito.spy(new UEBNotification(loaderFactory, schemaVersions)); HttpTestUtil httpTestUtil = new HttpTestUtil(queryStyle); String pserverResource = PayloadUtil.getResourcePayload("pserver-with-children-for-notification.json"); @@ -200,19 +202,19 @@ public class NotificationDmaapEventTest extends AAISetup { List<NotificationEvent> events = notification.getEvents(); assertThat(events.size(), is(1)); - String notificationEventHeader = events.get(0).getEventHeader().marshal(false); - String notificationEventBody = events.get(0).getObj().marshal(false); - - assertThat(notificationEventHeader, containsString("\"action\":\"UPDATE\"")); - assertThat(notificationEventHeader, containsString("\"entity-type\":\"pserver\"")); - assertThat(notificationEventHeader, containsString("\"top-entity-type\":\"pserver\"")); + EventHeader notificationEventHeader = events.get(0).getEventHeader(); + String notificationEventBody = events.get(0).getEntity().toString(); + assertEquals("UPDATE", notificationEventHeader.getAction()); + assertEquals("pserver", notificationEventHeader.getEntityType()); + assertEquals("pserver", notificationEventHeader.getTopEntityType()); String expectedNotificationHeader = PayloadUtil.getResourcePayload( "notification-dmaap-events/depth-all/expected-notification-header-create-child-on-existing-obj.json"); String expectedNotificationBody = PayloadUtil.getResourcePayload( "notification-dmaap-events/depth-all/expected-notification-body-create-child-on-existing-obj.json"); - JSONAssert.assertEquals(expectedNotificationHeader, notificationEventHeader, false); + String eventHeaderJson = mapper.writeValueAsString(events.get(0).getEventHeader()); + JSONAssert.assertEquals(expectedNotificationHeader, eventHeaderJson, false); JSONAssert.assertEquals(expectedNotificationBody, notificationEventBody, false); response = httpTestUtil.doGet(uri, "0"); @@ -235,7 +237,7 @@ public class NotificationDmaapEventTest extends AAISetup { String cloudRegionUri = "/aai/v14/cloud-infrastructure/cloud-regions/cloud-region/random-cloud-region-owner/random-cloud-region-id"; - UEBNotification notification = Mockito.spy(new UEBNotification(ModelType.MOXY, loaderFactory, schemaVersions)); + UEBNotification notification = Mockito.spy(new UEBNotification(loaderFactory, schemaVersions)); HttpTestUtil httpTestUtil = new HttpTestUtil(queryStyle, notification, AAIProperties.MINIMUM_DEPTH); Map<String, String> uriPayload = new LinkedHashMap<>(); @@ -252,8 +254,7 @@ public class NotificationDmaapEventTest extends AAISetup { assertThat("Expecting the number of dmaap events to be 2", numberOfEventsActual, is(expectedEvents)); notification.getEvents().forEach((event) -> { - String notificationEventHeader = event.getEventHeader().marshal(false); - assertThat(notificationEventHeader, containsString("\"CREATE\"")); + assertEquals("CREATE", event.getEventHeader().getAction()); }); } @@ -265,7 +266,7 @@ public class NotificationDmaapEventTest extends AAISetup { String cloudRegionUri = "/aai/v14/cloud-infrastructure/cloud-regions/cloud-region/random-cloud-region-owner/random-cloud-region-id"; - UEBNotification notification = Mockito.spy(new UEBNotification(ModelType.MOXY, loaderFactory, schemaVersions)); + UEBNotification notification = Mockito.spy(new UEBNotification(loaderFactory, schemaVersions)); HttpTestUtil httpTestUtil = new HttpTestUtil(queryStyle, notification, AAIProperties.MAXIMUM_DEPTH); Map<String, String> uriPayload = new LinkedHashMap<>(); @@ -282,8 +283,7 @@ public class NotificationDmaapEventTest extends AAISetup { assertThat("Expecting the number of dmaap events to be 2", numberOfEventsActual, is(expectedEvents)); notification.getEvents().forEach((event) -> { - String notificationEventHeader = event.getEventHeader().marshal(false); - assertThat(notificationEventHeader, containsString("\"CREATE\"")); + assertEquals("CREATE", event.getEventHeader().getAction()); }); } @@ -291,7 +291,7 @@ public class NotificationDmaapEventTest extends AAISetup { public void testDeleteOnExistingPserverAndCheckIfNotificationDepthIsZeroThatAllEventsHaveDeleteAndThatDepthIsZeroOnEachNotificationEvent() throws IOException, AAIException { String uri = "/aai/v14/cloud-infrastructure/pservers/pserver/example-hostname-val-85598"; - UEBNotification notification = Mockito.spy(new UEBNotification(ModelType.MOXY, loaderFactory, schemaVersions)); + UEBNotification notification = Mockito.spy(new UEBNotification(loaderFactory, schemaVersions)); HttpTestUtil httpTestUtil = new HttpTestUtil(queryStyle); String pserverResource = PayloadUtil.getResourcePayload("pserver-with-children-for-notification.json"); @@ -316,19 +316,16 @@ public class NotificationDmaapEventTest extends AAISetup { assertThat(notificationEvents.size(), is(17)); notificationEvents.forEach((event) -> { - - String header = event.getEventHeader().marshal(false); - - assertThat(event.getEventHeader().marshal(false), containsString("\"DELETE\"")); - - assertThat(header, containsString("\"top-entity-type\":\"pserver\"")); + EventHeader header = event.getEventHeader(); + assertEquals("DELETE", header.getAction()); + assertEquals("pserver", header.getTopEntityType()); }); } @Test public void testDeleteOnExistingResourceVersionMismatchNoEventGenerated() throws IOException, AAIException { String uri = "/aai/v14/cloud-infrastructure/pservers/pserver/example-hostname-val-85598"; - UEBNotification notification = Mockito.spy(new UEBNotification(ModelType.MOXY, loaderFactory, schemaVersions)); + UEBNotification notification = Mockito.spy(new UEBNotification(loaderFactory, schemaVersions)); HttpTestUtil httpTestUtil = new HttpTestUtil(queryStyle); String pserverResource = PayloadUtil.getResourcePayload("pserver-with-children-for-notification.json"); @@ -362,7 +359,7 @@ public class NotificationDmaapEventTest extends AAISetup { throws IOException, AAIException { String uri = "/aai/v14/cloud-infrastructure/pservers/pserver/example-hostname-val-85598"; - UEBNotification notification = Mockito.spy(new UEBNotification(ModelType.MOXY, loaderFactory, schemaVersions)); + UEBNotification notification = Mockito.spy(new UEBNotification(loaderFactory, schemaVersions)); HttpTestUtil httpTestUtil = new HttpTestUtil(queryStyle, notification, AAIProperties.MAXIMUM_DEPTH); String resource = PayloadUtil.getResourcePayload("pserver-with-children-for-notification.json"); @@ -378,20 +375,16 @@ public class NotificationDmaapEventTest extends AAISetup { NotificationEvent notificationEvent = notification.getEvents().get(0); // Verify all the events are create since its a new PUT - String header = notificationEvent.getEventHeader().marshal(false); - - assertThat(header, containsString("\"CREATE\"")); - - assertThat(header, containsString("\"entity-type\":\"pserver\"")); - - assertThat(header, containsString("\"top-entity-type\":\"pserver\"")); - - assertThat(header, containsString("\"entity-link\":\"" + uri + "\"")); + EventHeader eventHeader = notificationEvent.getEventHeader(); + assertEquals("CREATE", eventHeader.getAction()); + assertEquals("pserver", eventHeader.getEntityType()); + assertEquals("pserver", eventHeader.getTopEntityType()); + assertEquals(uri, eventHeader.getEntityLink()); response = httpTestUtil.doGet(uri); assertEquals("Expecting the pserver to be found", 200, response.getStatus()); - JSONAssert.assertEquals(response.getEntity().toString(), notificationEvent.getObj().marshal(false), false); + JSONAssert.assertEquals(response.getEntity().toString(), notificationEvent.getEntity().toString(), false); } @Test @@ -399,7 +392,7 @@ public class NotificationDmaapEventTest extends AAISetup { throws IOException, AAIException { String uri = "/aai/v14/cloud-infrastructure/pservers/pserver/example-hostname-val-85598"; - UEBNotification notification = Mockito.spy(new UEBNotification(ModelType.MOXY, loaderFactory, schemaVersions)); + UEBNotification notification = Mockito.spy(new UEBNotification(loaderFactory, schemaVersions)); HttpTestUtil httpTestUtil = new HttpTestUtil(queryStyle); String resource = PayloadUtil.getResourcePayload("pserver-with-children-for-notification.json"); @@ -424,7 +417,7 @@ public class NotificationDmaapEventTest extends AAISetup { assertThat(response.getEntity().toString(), containsString("new-equip-patch-type")); assertThat(notification.getEvents().size(), is(1)); - String updateNotificationEvent = notification.getEvents().get(0).getObj().marshal(true); + String updateNotificationEvent = notification.getEvents().get(0).getEntity().toString(); // Check that everything in notification event is also response body // Not comparing the other way as notification only includes parents main properties @@ -436,7 +429,7 @@ public class NotificationDmaapEventTest extends AAISetup { throws IOException, AAIException { String uri = "/aai/v14/cloud-infrastructure/pservers/pserver/example-hostname-val-85598"; - UEBNotification notification = Mockito.spy(new UEBNotification(ModelType.MOXY, loaderFactory, schemaVersions)); + UEBNotification notification = Mockito.spy(new UEBNotification(loaderFactory, schemaVersions)); HttpTestUtil httpTestUtil = new HttpTestUtil(queryStyle); String resource = PayloadUtil.getResourcePayload("pserver-with-children-for-notification.json"); @@ -461,7 +454,7 @@ public class NotificationDmaapEventTest extends AAISetup { assertThat(response.getEntity().toString(), containsString("new-equip-patch-type")); assertThat(notification.getEvents().size(), is(1)); - String updateNotificationEvent = notification.getEvents().get(0).getObj().marshal(true); + String updateNotificationEvent = notification.getEvents().get(0).getEntity().toString(); // Check that everything in notification event is also response body // Not comparing the other way as notification only includes parents main properties @@ -476,7 +469,7 @@ public class NotificationDmaapEventTest extends AAISetup { throws IOException, AAIException { String uri = "/aai/v14/cloud-infrastructure/pservers/pserver/example-hostname-val-85598"; - UEBNotification notification = Mockito.spy(new UEBNotification(ModelType.MOXY, loaderFactory, schemaVersions)); + UEBNotification notification = Mockito.spy(new UEBNotification(loaderFactory, schemaVersions)); HttpTestUtil httpTestUtil = new HttpTestUtil(queryStyle); String resource = PayloadUtil.getResourcePayload("pserver-with-children-for-notification.json"); @@ -506,7 +499,7 @@ public class NotificationDmaapEventTest extends AAISetup { assertThat(response.getEntity().toString(), containsString("new-equipment-identifier")); assertThat(notification.getEvents().size(), is(1)); - String updateNotificationEvent = notification.getEvents().get(0).getObj().marshal(true); + String updateNotificationEvent = notification.getEvents().get(0).getEntity().toString(); // Check that everything in notification event is also response body // Not comparing the other way as notification only includes parents main properties @@ -520,7 +513,7 @@ public class NotificationDmaapEventTest extends AAISetup { throws IOException, AAIException { String uri = "/aai/v14/cloud-infrastructure/pservers/pserver/example-hostname-val-85598"; - UEBNotification notification = Mockito.spy(new UEBNotification(ModelType.MOXY, loaderFactory, schemaVersions)); + UEBNotification notification = Mockito.spy(new UEBNotification(loaderFactory, schemaVersions)); HttpTestUtil httpTestUtil = new HttpTestUtil(queryStyle); String resource = PayloadUtil.getResourcePayload("pserver-with-children-for-notification.json"); @@ -547,7 +540,7 @@ public class NotificationDmaapEventTest extends AAISetup { response = httpTestUtil.doGet(uri); assertThat(notification.getEvents().size(), is(1)); - String updateNotificationEvent = notification.getEvents().get(0).getObj().marshal(true); + String updateNotificationEvent = notification.getEvents().get(0).getEntity().toString(); System.out.println("Update notification " + updateNotificationEvent); // Check that everything in notification event is also response body @@ -564,7 +557,7 @@ public class NotificationDmaapEventTest extends AAISetup { String pserverUri = "/aai/v14/cloud-infrastructure/pservers/pserver/" + hostname; String genericVnfUri = "/aai/v14/network/generic-vnfs/generic-vnf/generic-vnf-notification"; - UEBNotification notification = Mockito.spy(new UEBNotification(ModelType.MOXY, loaderFactory, schemaVersions)); + UEBNotification notification = Mockito.spy(new UEBNotification(loaderFactory, schemaVersions)); HttpTestUtil httpTestUtil = new HttpTestUtil(queryStyle); String resource = PayloadUtil.getResourcePayload("pserver-with-children-for-notification.json"); @@ -604,9 +597,9 @@ public class NotificationDmaapEventTest extends AAISetup { String expectedNotificationBody = PayloadUtil.getResourcePayload( "notification-dmaap-events/depth-zero/expected-notification-body-create-edge-between-pserver-and-generic-vnf.json"); - JSONAssert.assertEquals(expectedNotificationHeader, notificationEvents.get(0).getEventHeader().marshal(false), + JSONAssert.assertEquals(expectedNotificationHeader, mapper.writeValueAsString(notificationEvents.get(0).getEventHeader()), false); - JSONAssert.assertEquals(expectedNotificationBody, notificationEvents.get(0).getObj().marshal(false), false); + JSONAssert.assertEquals(expectedNotificationBody, notificationEvents.get(0).getEntity().toString(), false); response = httpTestUtil.doGet(genericVnfUri); @@ -623,7 +616,7 @@ public class NotificationDmaapEventTest extends AAISetup { String pserverUri = "/aai/v14/cloud-infrastructure/pservers/pserver/" + hostname; String genericVnfUri = "/aai/v14/network/generic-vnfs/generic-vnf/generic-vnf-notification"; - UEBNotification notification = Mockito.spy(new UEBNotification(ModelType.MOXY, loaderFactory, schemaVersions)); + UEBNotification notification = Mockito.spy(new UEBNotification(loaderFactory, schemaVersions)); HttpTestUtil httpTestUtil = new HttpTestUtil(queryStyle); String resource = PayloadUtil.getResourcePayload("pserver-with-children-for-notification.json"); @@ -663,10 +656,10 @@ public class NotificationDmaapEventTest extends AAISetup { String expectedNotificationBody = PayloadUtil.getResourcePayload( "notification-dmaap-events/depth-all/expected-notification-body-create-edge-between-pserver-and-generic-vnf.json"); - System.out.println("Notification Body: " + notificationEvents.get(0).getObj().marshal(false)); - JSONAssert.assertEquals(expectedNotificationHeader, notificationEvents.get(0).getEventHeader().marshal(false), + System.out.println("Notification Body: " + notificationEvents.get(0).getEntity().toString()); + JSONAssert.assertEquals(expectedNotificationHeader, mapper.writeValueAsString(notificationEvents.get(0).getEventHeader()), false); - JSONAssert.assertEquals(expectedNotificationBody, notificationEvents.get(0).getObj().marshal(false), false); + JSONAssert.assertEquals(expectedNotificationBody, notificationEvents.get(0).getEntity().toString(), false); response = httpTestUtil.doGet(genericVnfUri); @@ -685,7 +678,7 @@ public class NotificationDmaapEventTest extends AAISetup { String relationship = PayloadUtil.getResourcePayload("pserver-to-gvnf-relationship-notification.json"); - UEBNotification notification = Mockito.spy(new UEBNotification(ModelType.MOXY, loaderFactory, schemaVersions)); + UEBNotification notification = Mockito.spy(new UEBNotification(loaderFactory, schemaVersions)); HttpTestUtil httpTestUtil = new HttpTestUtil(queryStyle); String resource = PayloadUtil.getResourcePayload("pserver-with-children-for-notification.json"); @@ -741,9 +734,9 @@ public class NotificationDmaapEventTest extends AAISetup { String expectedNotificationBody = PayloadUtil.getResourcePayload( "notification-dmaap-events/depth-zero/expected-notification-body-delete-edge-between-pserver-and-generic-vnf.json"); - JSONAssert.assertEquals(expectedNotificationHeader, notificationEvents.get(0).getEventHeader().marshal(false), + JSONAssert.assertEquals(expectedNotificationHeader, mapper.writeValueAsString(notificationEvents.get(0).getEventHeader()), false); - JSONAssert.assertEquals(expectedNotificationBody, notificationEvents.get(0).getObj().marshal(false), false); + JSONAssert.assertEquals(expectedNotificationBody, notificationEvents.get(0).getEntity().toString(), false); } @@ -758,7 +751,7 @@ public class NotificationDmaapEventTest extends AAISetup { String relationship = PayloadUtil.getResourcePayload("pserver-to-gvnf-relationship-notification.json"); - UEBNotification notification = Mockito.spy(new UEBNotification(ModelType.MOXY, loaderFactory, schemaVersions)); + UEBNotification notification = Mockito.spy(new UEBNotification(loaderFactory, schemaVersions)); HttpTestUtil httpTestUtil = new HttpTestUtil(queryStyle); String resource = PayloadUtil.getResourcePayload("pserver-with-children-for-notification.json"); @@ -813,9 +806,9 @@ public class NotificationDmaapEventTest extends AAISetup { String expectedNotificationBody = PayloadUtil.getResourcePayload( "notification-dmaap-events/depth-all/expected-notification-body-delete-edge-between-pserver-and-generic-vnf.json"); - JSONAssert.assertEquals(expectedNotificationHeader, notificationEvents.get(0).getEventHeader().marshal(false), + JSONAssert.assertEquals(expectedNotificationHeader, mapper.writeValueAsString(notificationEvents.get(0).getEventHeader()), false); - JSONAssert.assertEquals(expectedNotificationBody, notificationEvents.get(0).getObj().marshal(false), false); + JSONAssert.assertEquals(expectedNotificationBody, notificationEvents.get(0).getEntity().toString(), false); } @@ -823,7 +816,7 @@ public class NotificationDmaapEventTest extends AAISetup { public void testDeleteOnExistingResourceVersionMismatchNoEventGeneratedFullDepth() throws IOException, AAIException { String uri = "/aai/v14/cloud-infrastructure/pservers/pserver/example-hostname-val-85598"; - UEBNotification notification = Mockito.spy(new UEBNotification(ModelType.MOXY, loaderFactory, schemaVersions)); + UEBNotification notification = Mockito.spy(new UEBNotification(loaderFactory, schemaVersions)); HttpTestUtil httpTestUtil = new HttpTestUtil(queryStyle); String pserverResource = PayloadUtil.getResourcePayload("pserver-with-children-for-notification.json"); @@ -851,7 +844,7 @@ public class NotificationDmaapEventTest extends AAISetup { @Test public void testCreateVnfWithChildrenCreateCustomerWithChildrenAndCousinBetweenVlanAndServiceInstanceThenDeleteCustomerVerifyingVlanRV() throws IOException, AAIException { - UEBNotification notification = Mockito.spy(new UEBNotification(ModelType.MOXY, loaderFactory, schemaVersions)); + UEBNotification notification = Mockito.spy(new UEBNotification(loaderFactory, schemaVersions)); HttpTestUtil httpTestUtil = new HttpTestUtil(queryStyle); String json = PayloadUtil.getResourcePayload( @@ -912,7 +905,7 @@ public class NotificationDmaapEventTest extends AAISetup { @Test public void testBulkCreateOfComplexAndPserverWithRelationshipThenBulkDeleteBoth() throws IOException, AAIException { - UEBNotification notification = Mockito.spy(new UEBNotification(ModelType.MOXY, loaderFactory, schemaVersions)); + UEBNotification notification = Mockito.spy(new UEBNotification(loaderFactory, schemaVersions)); HttpTestUtil httpTestUtil = new HttpTestUtil(queryStyle, notification, AAIProperties.MAXIMUM_DEPTH); JsonObject payloads = JsonParser @@ -945,7 +938,7 @@ public class NotificationDmaapEventTest extends AAISetup { Map<String, Pair<String, String>> deletes = new LinkedHashMap<>(); deletes.put(pserverUri, new Pair<>(pserverRv, null)); deletes.put(complexUri, new Pair<>(complexRV, null)); - notification = Mockito.spy(new UEBNotification(ModelType.MOXY, loaderFactory, schemaVersions)); + notification = Mockito.spy(new UEBNotification(loaderFactory, schemaVersions)); httpTestUtil = new HttpTestUtil(queryStyle, notification, AAIProperties.MAXIMUM_DEPTH); httpTestUtil.doDelete(deletes); @@ -958,7 +951,7 @@ public class NotificationDmaapEventTest extends AAISetup { @Test public void testCreateVnfWithChildrenCreateCustomerWithChildrenAndCousinBetweenVlanAndServiceInstanceThenImplicitDeleteVlanVerifyingServiceInstanceRV() throws IOException, AAIException { - UEBNotification notification = Mockito.spy(new UEBNotification(ModelType.MOXY, loaderFactory, schemaVersions)); + UEBNotification notification = Mockito.spy(new UEBNotification(loaderFactory, schemaVersions)); HttpTestUtil httpTestUtil = new HttpTestUtil(queryStyle); String json = PayloadUtil.getResourcePayload( diff --git a/aai-core/src/test/java/org/onap/aai/rest/db/HttpEntryNotificationIntegrationTest.java b/aai-core/src/test/java/org/onap/aai/rest/db/HttpEntryNotificationIntegrationTest.java index e8e3d691..6b90782c 100644 --- a/aai-core/src/test/java/org/onap/aai/rest/db/HttpEntryNotificationIntegrationTest.java +++ b/aai-core/src/test/java/org/onap/aai/rest/db/HttpEntryNotificationIntegrationTest.java @@ -61,8 +61,6 @@ import org.onap.aai.restcore.HttpMethod; import org.onap.aai.serialization.engines.TransactionalGraphEngine; import org.springframework.test.annotation.DirtiesContext; -import com.fasterxml.jackson.databind.ObjectMapper; - @DirtiesContext(classMode = DirtiesContext.ClassMode.BEFORE_CLASS) public class HttpEntryNotificationIntegrationTest extends AAISetup { @@ -77,8 +75,6 @@ public class HttpEntryNotificationIntegrationTest extends AAISetup { private List<String> aaiRequestContextList; private List<MediaType> outputMediaTypes; - ObjectMapper mapper = new ObjectMapper(); - @Before public void setup() { @@ -129,7 +125,7 @@ public class HttpEntryNotificationIntegrationTest extends AAISetup { public void notificationOnRelatedToTest() throws UnsupportedEncodingException, AAIException { Loader ld = loaderFactory.createLoaderForVersion(ModelType.MOXY, schemaVersions.getDefaultVersion()); - UEBNotification uebNotification = Mockito.spy(new UEBNotification(ld, loaderFactory, schemaVersions)); + UEBNotification uebNotification = Mockito.spy(new UEBNotification(loaderFactory, schemaVersions)); traversalHttpEntry.setHttpEntryProperties(schemaVersions.getDefaultVersion(), uebNotification); Loader loader = traversalHttpEntry.getLoader(); @@ -148,25 +144,24 @@ public class HttpEntryNotificationIntegrationTest extends AAISetup { content = "{\"related-to\":\"pserver\",\"related-link\":\"/aai/" + schemaVersions.getDefaultVersion().toString() + "/cloud-infrastructure/pservers/pserver/junit-edge-test-pserver\",\"relationship-label\":\"org.onap.relationships.inventory.LocatedIn\"}"; - doNothing().when(uebNotification).triggerEvents(); Response response = doRequest(traversalHttpEntry, loader, dbEngine, HttpMethod.PUT_EDGE, uri, content); assertEquals("Expected the pserver relationship to be deleted", 200, response.getStatus()); assertEquals("Two notifications", 2, uebNotification.getEvents().size()); assertEquals("Notification generated for PUT edge", "UPDATE", - uebNotification.getEvents().get(0).getEventHeader().getValue("action").toString()); + uebNotification.getEvents().get(1).getEventHeader().getAction()); assertThat("Event body for the edge create has the related to", - uebNotification.getEvents().get(0).getObj().marshal(false), + uebNotification.getEvents().get(1).getEntity().toString(), containsString("cloud-infrastructure/pservers/pserver/junit-edge-test-pserver")); response = doRequest(traversalHttpEntry, loader, dbEngine, HttpMethod.DELETE_EDGE, uri, content); assertEquals("Expected the pserver relationship to be deleted", 204, response.getStatus()); assertEquals("Two notifications", 2, uebNotification.getEvents().size()); assertEquals("Notification generated for DELETE edge", "UPDATE", - uebNotification.getEvents().get(0).getEventHeader().getValue("action").toString()); + uebNotification.getEvents().get(0).getEventHeader().getAction()); assertThat("Event body for the edge delete does not have the related to", - uebNotification.getEvents().get(0).getObj().marshal(false), + uebNotification.getEvents().get(0).getEntity().toString(), not(containsString("cloud-infrastructure/pservers/pserver/junit-edge-test-pserver"))); dbEngine.rollback(); diff --git a/aai-core/src/test/java/org/onap/aai/rest/notification/EntityConverterTest.java b/aai-core/src/test/java/org/onap/aai/rest/notification/EntityConverterTest.java new file mode 100644 index 00000000..cbfedef7 --- /dev/null +++ b/aai-core/src/test/java/org/onap/aai/rest/notification/EntityConverterTest.java @@ -0,0 +1,119 @@ +/** + * ============LICENSE_START======================================================= + * org.onap.aai + * ================================================================================ + * Copyright © 2024 Deutsche Telekom. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.aai.rest.notification; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.anyString; +import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; + +import java.util.List; + + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.mockito.Mock; +import org.mockito.MockitoAnnotations; +import org.onap.aai.introspection.Introspector; +import org.onap.aai.introspection.Loader; +import org.onap.aai.introspection.exceptions.AAIUnmarshallingException; +import org.onap.aai.parsers.uri.URIToObject; +import org.onap.aai.setup.SchemaVersion; + +public class EntityConverterTest { + + @Mock URIToObject parser; + @Mock Introspector introspector; + @Mock Loader loader; + @Mock List<Object> parentList; + + EntityConverter entityConverter; + + @BeforeEach + public void setUp() { + MockitoAnnotations.openMocks(this); + entityConverter = new EntityConverter(parser); + } + + @Test + public void testConvert_topEntitySameAsEntity() throws AAIUnmarshallingException { + when(parser.getParentList()).thenReturn(parentList); + when(parser.getTopEntity()).thenReturn(introspector); + when(parser.getEntity()).thenReturn(introspector); + + Introspector result = entityConverter.convert(introspector); + + assertEquals(introspector, result); + verify(parser.getParentList()).clear(); + } + + @Test + public void testConvert_topEntityDifferentFromEntity_withVersionMismatch() throws AAIUnmarshallingException { + Introspector topEntity = mock(Introspector.class); + Introspector childEntity = mock(Introspector.class); + String json = "{}"; + + when(parser.getParentList()).thenReturn(parentList); + when(parser.getTopEntity()).thenReturn(topEntity); + when(parser.getEntity()).thenReturn(childEntity); + when(childEntity.getName()).thenReturn("smth"); + when(parser.getLoader()).thenReturn(loader); + when(introspector.getVersion()).thenReturn(new SchemaVersion("v1")); + when(loader.getVersion()).thenReturn(new SchemaVersion("v2")); + when(introspector.marshal(false)).thenReturn(json); + when(loader.unmarshal(anyString(), eq(json))).thenReturn(childEntity); + + Introspector result = entityConverter.convert(introspector); + + assertEquals(topEntity, result); + } + + @Test + public void testConvert_topEntityDifferentFromEntity_withoutVersionMismatch() throws AAIUnmarshallingException { + Introspector topEntity = mock(Introspector.class); + Introspector childEntity = mock(Introspector.class); + + when(parser.getParentList()).thenReturn(parentList); + when(parser.getTopEntity()).thenReturn(topEntity); + when(parser.getEntity()).thenReturn(childEntity); + when(parser.getLoader()).thenReturn(loader); + when(introspector.getVersion()).thenReturn(new SchemaVersion("v1")); + when(loader.getVersion()).thenReturn(new SchemaVersion("v1")); + + Introspector result = entityConverter.convert(introspector); + + assertEquals(topEntity, result); + verify(parentList).add(any()); + } + + @Test + public void testGetTopEntityName() { + String topEntityName = "TopEntity"; + when(parser.getTopEntityName()).thenReturn(topEntityName); + + String result = entityConverter.getTopEntityName(); + + assertEquals(topEntityName, result); + } +} diff --git a/aai-core/src/test/java/org/onap/aai/rest/notification/NotificationServiceTest.java b/aai-core/src/test/java/org/onap/aai/rest/notification/NotificationServiceTest.java index 95301c6f..4fd21497 100644 --- a/aai-core/src/test/java/org/onap/aai/rest/notification/NotificationServiceTest.java +++ b/aai-core/src/test/java/org/onap/aai/rest/notification/NotificationServiceTest.java @@ -24,6 +24,7 @@ import static org.mockito.ArgumentMatchers.anyInt; import static org.mockito.ArgumentMatchers.anyList; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.doNothing; +import static org.mockito.Mockito.mock; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; @@ -50,6 +51,7 @@ import org.onap.aai.db.props.AAIProperties; import org.onap.aai.exceptions.AAIException; import org.onap.aai.introspection.Introspector; import org.onap.aai.introspection.LoaderFactory; +import org.onap.aai.kafka.NotificationProducerService; import org.onap.aai.prevalidation.ValidationService; import org.onap.aai.serialization.db.DBSerializer; import org.onap.aai.serialization.engines.query.QueryEngine; @@ -62,6 +64,7 @@ public class NotificationServiceTest extends AAISetup { @Mock SchemaVersions schemaVersions; @Mock UEBNotification uebNotification; @Mock ValidationService validationService; + @Mock NotificationProducerService notificationProducerService; @Mock DBSerializer dbSerializer; @Mock QueryEngine queryEngine; @Mock Introspector introspector; @@ -77,9 +80,10 @@ public class NotificationServiceTest extends AAISetup { when(dbSerializer.touchStandardVertexPropertiesForEdges()).thenReturn(Collections.emptySet()); when(dbSerializer.getLatestVersionView(any(),anyInt())).thenReturn(introspector); - notificationService = new NotificationService(validationService, loaderFactory, basePath, isDeltaEventsEnabled); + notificationService = new NotificationService(validationService, loaderFactory, basePath, isDeltaEventsEnabled, notificationProducerService); when(schemaVersions.getDefaultVersion()).thenReturn(new SchemaVersion("v29")); doNothing().when(uebNotification).createNotificationEvent(any(),any(),any(),any(),any(),any(),any()); + doNothing().when(notificationProducerService).sendUEBNotification(any()); } @Test @@ -101,7 +105,7 @@ public class NotificationServiceTest extends AAISetup { verify(uebNotification, times(1)).createNotificationEvent(eq("transactionId"), eq("sourceOfTruth"), eq(Status.OK), eq(URI.create("/aai/v29/pservers/pserver/hostname")), eq(introspector), any(), eq("/aai")); verify(validationService, times(1)).validate(anyList()); - verify(uebNotification, times(1)).triggerEvents(); + verify(notificationProducerService, times(1)).sendUEBNotification(uebNotification); } @Test @@ -119,9 +123,9 @@ public class NotificationServiceTest extends AAISetup { SchemaVersion schemaVersion = new SchemaVersion("v29"); when(dbSerializer.getUpdatedVertexes()).thenReturn(Collections.emptyMap()); - notificationService = new NotificationService(null, loaderFactory, basePath, isDeltaEventsEnabled); + notificationService = new NotificationService(null, loaderFactory, basePath, isDeltaEventsEnabled, notificationProducerService); notificationService.generateEvents(uebNotification, AAIProperties.MINIMUM_DEPTH, "sourceOfTruth", dbSerializer, "transactionId", queryEngine, mainVertexesToNotifyOn, schemaVersion); - verify(uebNotification, times(1)).triggerEvents(); + verify(notificationProducerService, times(1)).sendUEBNotification(uebNotification); } } diff --git a/aai-core/src/test/java/org/onap/aai/rest/notification/UEBNotificationTest.java b/aai-core/src/test/java/org/onap/aai/rest/notification/UEBNotificationTest.java index 229abae4..e176f1cb 100644 --- a/aai-core/src/test/java/org/onap/aai/rest/notification/UEBNotificationTest.java +++ b/aai-core/src/test/java/org/onap/aai/rest/notification/UEBNotificationTest.java @@ -71,14 +71,14 @@ public class UEBNotificationTest extends AAISetup { Introspector pserver = loader.introspectorFromName("pserver"); pserver.setValue("hostname", "hn"); URI uri = new URI("/cloud-infrastructure/pservers/pserver/hn"); - UEBNotification uebNotification = new UEBNotification(loader, loaderFactory, schemaVersions); + UEBNotification uebNotification = new UEBNotification(loaderFactory, schemaVersions); uebNotification.createNotificationEvent(UUID.randomUUID().toString(), "JUNIT-SOT", Response.Status.CREATED, uri, pserver, new HashMap<>(), BASE_PATH); assertEquals("One event created", 1, uebNotification.getEvents().size()); assertEquals("Uri is correct", BASE_PATH + "/" + schemaVersions.getDefaultVersion() + "/cloud-infrastructure/pservers/pserver/hn", - uebNotification.getEvents().get(0).getEventHeader().getValue("entity-link").toString()); + uebNotification.getEvents().get(0).getEventHeader().getEntityLink()); } @Test @@ -87,13 +87,13 @@ public class UEBNotificationTest extends AAISetup { Introspector pserver = loader.introspectorFromName("pserver"); pserver.setValue("hostname", "hn"); URI uri = new URI(BASE_PATH + "/v12/cloud-infrastructure/pservers/pserver/hn"); - UEBNotification uebNotification = new UEBNotification(loader, loaderFactory, schemaVersions); + UEBNotification uebNotification = new UEBNotification(loaderFactory, schemaVersions); uebNotification.createNotificationEvent(UUID.randomUUID().toString(), "JUNIT-SOT", Response.Status.CREATED, uri, pserver, new HashMap<>(), BASE_PATH); assertEquals("One event created", 1, uebNotification.getEvents().size()); assertEquals("Uri is correct", BASE_PATH + "/" + schemaVersions.getDefaultVersion() + "/cloud-infrastructure/pservers/pserver/hn", - uebNotification.getEvents().get(0).getEventHeader().getValue("entity-link").toString()); + uebNotification.getEvents().get(0).getEventHeader().getEntityLink()); } } diff --git a/aai-core/src/test/java/org/onap/aai/serialization/db/DbSerializer_needsFakeRulesTest.java b/aai-core/src/test/java/org/onap/aai/serialization/db/DbSerializer_needsFakeRulesTest.java index 7dca441e..6db9e4fa 100644 --- a/aai-core/src/test/java/org/onap/aai/serialization/db/DbSerializer_needsFakeRulesTest.java +++ b/aai-core/src/test/java/org/onap/aai/serialization/db/DbSerializer_needsFakeRulesTest.java @@ -42,6 +42,7 @@ import org.junit.rules.ExpectedException; import org.junit.runner.RunWith; import org.onap.aai.config.ConfigConfiguration; import org.onap.aai.config.IntrospectionConfig; +import org.onap.aai.config.KafkaConfig; import org.onap.aai.config.SpringContextAware; import org.onap.aai.config.XmlFormatTransformerConfiguration; import org.onap.aai.db.props.AAIProperties; @@ -71,10 +72,11 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; @ContextConfiguration( classes = {ConfigConfiguration.class, AAICoreFakeEdgesConfigTranslator.class, NodeIngestor.class, EdgeIngestor.class, EdgeSerializer.class, SpringContextAware.class, IntrospectionConfig.class, - XmlFormatTransformerConfiguration.class, LoaderFactory.class, NotificationService.class}) + XmlFormatTransformerConfiguration.class, LoaderFactory.class, NotificationService.class, + KafkaConfig.class}) @TestPropertySource( properties = {"schema.translator.list = config", "schema.nodes.location=src/test/resources/onap/oxm", - "schema.edges.location=src/test/resources/onap/dbedgerules"}) + "schema.edges.location=src/test/resources/onap/dbedgerules","aai.notifications.enabled=false"}) public class DbSerializer_needsFakeRulesTest { // to use, set thrown.expect to whatever your test needs diff --git a/aai-core/src/test/java/org/onap/aai/serialization/queryformats/PathedURLTest.java b/aai-core/src/test/java/org/onap/aai/serialization/queryformats/PathedURLTest.java index 6ed42539..cd2c3af3 100644 --- a/aai-core/src/test/java/org/onap/aai/serialization/queryformats/PathedURLTest.java +++ b/aai-core/src/test/java/org/onap/aai/serialization/queryformats/PathedURLTest.java @@ -127,7 +127,7 @@ public class PathedURLTest extends AAISetup { when(urlBuilder.pathed(pserver)).thenReturn("/aai/v14/cloud-infrastructure/pservers/pserver/hostname-1"); Optional<JsonObject> jsonObjectOptional = pathedURL.getJsonFromVertex(pserver); - if (!jsonObjectOptional.isPresent()) { + if (jsonObjectOptional.isEmpty()) { fail("Expecting an json object returned from pathed url but returned none"); } @@ -150,7 +150,7 @@ public class PathedURLTest extends AAISetup { when(urlBuilder.pathed(pserver)).thenReturn("/aai/v14/cloud-infrastructure/pservers/pserver/hostname-1"); Optional<JsonObject> jsonObjectOptional = pathedURL.getJsonFromVertex(pserver); - if (!jsonObjectOptional.isPresent()) { + if (jsonObjectOptional.isEmpty()) { fail("Expecting an json object returned from pathed url but returned none"); } diff --git a/aai-core/src/test/java/org/onap/aai/util/StoreNotificationEventTest.java b/aai-core/src/test/java/org/onap/aai/util/StoreNotificationEventTest.java deleted file mode 100644 index a0c3f639..00000000 --- a/aai-core/src/test/java/org/onap/aai/util/StoreNotificationEventTest.java +++ /dev/null @@ -1,227 +0,0 @@ -/** - * ============LICENSE_START======================================================= - * org.onap.aai - * ================================================================================ - * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.aai.util; - -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; - -import com.fasterxml.jackson.core.JsonGenerationException; -import com.fasterxml.jackson.databind.JsonMappingException; - -import java.io.IOException; - -import javax.json.Json; -import javax.json.JsonObject; - -import org.eclipse.persistence.dynamic.DynamicEntity; -import org.eclipse.persistence.jaxb.dynamic.DynamicJAXBContext; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Ignore; -import org.junit.Test; -import org.mockito.Mockito; -import org.onap.aai.AAISetup; -import org.onap.aai.domain.notificationEvent.NotificationEvent.EventHeader; -import org.onap.aai.exceptions.AAIException; -import org.onap.aai.introspection.Introspector; -import org.onap.aai.introspection.Loader; -import org.onap.aai.introspection.ModelType; -import org.onap.aai.kafka.AAIKafkaEventJMSProducer; - -public class StoreNotificationEventTest extends AAISetup { - - private static AAIKafkaEventJMSProducer producer; - private static StoreNotificationEvent sne; - - @BeforeClass - public static void setUp() { - producer = Mockito.mock(AAIKafkaEventJMSProducer.class); - // sne = new StoreNotificationEvent(producer, "transiationId", "sourceOfTruth"); - } - - @Before - public void setUpBefore() { - producer = Mockito.mock(AAIKafkaEventJMSProducer.class); - sne = new StoreNotificationEvent(producer, "transiationId", "sourceOfTruth"); - - } - - @Test(expected = AAIException.class) - public void testStoreEventNullObj() throws AAIException { - sne.storeEventAndSendToJms(new EventHeader(), null); - } - - @Test(expected = AAIException.class) - public void testStoreEventInvalidObjForPojoUtils() throws AAIException { - sne.storeEventAndSendToJms(new EventHeader(), new Object()); - } - - @Test - public void testStoreEventEmptyEventHeader() - throws AAIException, JsonGenerationException, JsonMappingException, IOException { - JsonObject object = Json.createObjectBuilder().add("hello", "world").build(); - String res = sne.storeEventAndSendToJms(new EventHeader(), object); - - assertNotNull(res); - assertTrue(res.contains("\"cambria.partition\" : \"" + AAIConstants.UEB_PUB_PARTITION_AAI + "\"")); - assertTrue(res.contains("\"event-header\"")); - assertTrue(res.contains("\"id\"")); - assertTrue(res.contains("\"timestamp\"")); - assertTrue(res - .contains("\"source-name\" : \"" + AAIConfig.get("aai.notificationEvent.default.sourceName") + "\"")); - assertTrue(res.contains("\"domain\" : \"" + AAIConfig.get("aai.notificationEvent.default.domain") + "\"")); - assertTrue(res.contains( - "\"sequence-number\" : \"" + AAIConfig.get("aai.notificationEvent.default.sequenceNumber") + "\"")); - assertTrue(res.contains("\"severity\" : \"" + AAIConfig.get("aai.notificationEvent.default.severity") + "\"")); - assertTrue( - res.contains("\"event-type\" : \"" + AAIConfig.get("aai.notificationEvent.default.eventType") + "\"")); - assertTrue(res.contains("\"version\" : \"" + AAIConfig.get("aai.notificationEvent.default.version") + "\"")); - assertTrue(res.contains("\"action\" : \"UNK\"")); - assertTrue(res.contains("\"entity-link\" : \"UNK\"")); - assertTrue(res.contains("\"entity\"")); - assertTrue(res.contains("\"hello\"")); - assertTrue(res.contains("\"chars\" : \"world\"")); - assertTrue(res.contains("\"string\" : \"world\"")); - assertTrue(res.contains("\"valueType\" : \"STRING\"")); - } - - @Test - public void testStoreEvent() throws AAIException, JsonGenerationException, JsonMappingException, IOException { - JsonObject object = Json.createObjectBuilder().add("hello", "world").build(); - EventHeader eh = new EventHeader(); - eh.setId("123"); - eh.setTimestamp("current-time"); - eh.setEntityLink("entity-link"); - eh.setAction("action!"); - eh.setEventType("surprise"); - eh.setDomain("PROD"); - eh.setSourceName("source"); - eh.setSequenceNumber("23"); - eh.setSeverity("ALERT"); - eh.setVersion("v12"); - - String res = sne.storeEventAndSendToJms(eh, object); - - assertNotNull(res); - assertTrue(res.contains("\"cambria.partition\" : \"" + AAIConstants.UEB_PUB_PARTITION_AAI + "\"")); - assertTrue(res.contains("\"event-header\"")); - assertTrue(res.contains("\"id\" : \"123\"")); - assertTrue(res.contains("\"timestamp\" : \"current-time\"")); - assertTrue(res.contains("\"source-name\" : \"source\"")); - assertTrue(res.contains("\"domain\" : \"PROD\"")); - assertTrue(res.contains("\"sequence-number\" : \"23\"")); - assertTrue(res.contains("\"severity\" : \"ALERT\"")); - assertTrue(res.contains("\"event-type\" : \"surprise\"")); - assertTrue(res.contains("\"version\" : \"v12\"")); - assertTrue(res.contains("\"action\" : \"action!\"")); - assertTrue(res.contains("\"entity-link\" : \"entity-link\"")); - assertTrue(res.contains("\"entity\"")); - assertTrue(res.contains("\"hello\"")); - assertTrue(res.contains("\"chars\" : \"world\"")); - assertTrue(res.contains("\"string\" : \"world\"")); - assertTrue(res.contains("\"valueType\" : \"STRING\"")); - } - - @Test(expected = AAIException.class) - public void testStoreDynamicEventNullObj() throws AAIException { - DynamicEntity eventHeader = Mockito.mock(DynamicEntity.class); - DynamicJAXBContext notificationJaxbContext = - nodeIngestor.getContextForVersion(schemaVersions.getEdgeLabelVersion()); - sne.storeDynamicEvent(notificationJaxbContext, "v12", eventHeader, null); - } - - @Test(expected = Exception.class) - public void testStoreDynamicEventAAIException() throws Exception { - - DynamicJAXBContext notificationJaxbContext = - nodeIngestor.getContextForVersion(schemaVersions.getEdgeLabelVersion()); - DynamicEntity obj = Mockito.mock(DynamicEntity.class); - DynamicEntity eventHeader = Mockito.mock(DynamicEntity.class); - sne.storeDynamicEvent(notificationJaxbContext, "v12", eventHeader, obj); - } - - @Test(expected = AAIException.class) - public void testStoreEventIntrospectorNullObj() throws Exception { - Loader loader = Mockito.mock(Loader.class); - sne.storeEventAndSendToJms(loader, null, null); - } - - @Ignore("Stopped working since the model driven story") - @Test - public void testStoreEvent1Introspector() throws Exception { - Loader loader = loaderFactory.createLoaderForVersion(ModelType.MOXY, schemaVersions.getEdgeLabelVersion()); - Introspector eventHeader = loader.introspectorFromName("notification-event-header"); - eventHeader.setValue("id", "123"); - eventHeader.setValue("timestamp", "current-time"); - eventHeader.setValue("entity-link", "entity-link"); - eventHeader.setValue("action", "action!"); - eventHeader.setValue("event-type", "surprise"); - eventHeader.setValue("domain", "PROD"); - eventHeader.setValue("source-name", "source"); - eventHeader.setValue("sequence-number", "23"); - eventHeader.setValue("severity", "ALERT"); - eventHeader.setValue("version", "v12"); - Introspector obj = loader.introspectorFromName("notification-event"); - String res = sne.storeEventAndSendToJms(loader, eventHeader, obj); - - assertNotNull(res); - assertTrue(res.contains("\"cambria.partition\":\"" + AAIConstants.UEB_PUB_PARTITION_AAI + "\"")); - assertTrue(res.contains("\"event-header\"")); - assertTrue(res.contains("\"id\":\"123\"")); - assertTrue(res.contains("\"timestamp\":\"current-time\"")); - assertTrue(res.contains("\"source-name\":\"source\"")); - assertTrue(res.contains("\"domain\":\"PROD\"")); - assertTrue(res.contains("\"sequence-number\":\"23\"")); - assertTrue(res.contains("\"severity\":\"ALERT\"")); - assertTrue(res.contains("\"event-type\":\"surprise\"")); - assertTrue(res.contains("\"version\":\"v12\"")); - assertTrue(res.contains("\"action\":\"action!\"")); - assertTrue(res.contains("\"entity-link\":\"entity-link\"")); - assertTrue(res.contains("\"notification-event\"")); - } - - @Ignore("Stopped working since the model driven story") - @Test - public void testStoreEventIntrospectorEmptyEventHeader() throws Exception { - Loader loader = loaderFactory.createLoaderForVersion(ModelType.MOXY, schemaVersions.getEdgeLabelVersion()); - Introspector eventHeader = loader.introspectorFromName("notification-event-header"); - Introspector obj = loader.introspectorFromName("notification-event"); - - String res = sne.storeEventAndSendToJms(loader, eventHeader, obj); - - assertNotNull(res); - assertTrue(res.contains("\"cambria.partition\":\"" + AAIConstants.UEB_PUB_PARTITION_AAI + "\"")); - assertTrue(res.contains("\"event-header\"")); - assertTrue(res.contains("\"id\"")); - assertTrue(res.contains("\"timestamp\"")); - assertTrue( - res.contains("\"source-name\":\"" + AAIConfig.get("aai.notificationEvent.default.sourceName") + "\"")); - assertTrue(res.contains("\"domain\":\"" + AAIConfig.get("aai.notificationEvent.default.domain") + "\"")); - assertTrue(res.contains( - "\"sequence-number\":\"" + AAIConfig.get("aai.notificationEvent.default.sequenceNumber") + "\"")); - assertTrue(res.contains("\"severity\":\"" + AAIConfig.get("aai.notificationEvent.default.severity") + "\"")); - assertTrue(res.contains("\"event-type\":\"" + AAIConfig.get("aai.notificationEvent.default.eventType") + "\"")); - assertTrue(res.contains("\"version\":\"" + AAIConfig.get("aai.notificationEvent.default.version") + "\"")); - assertTrue(res.contains("\"action\":\"UNK\"")); - assertTrue(res.contains("\"entity-link\":\"UNK\"")); - assertTrue(res.contains("\"notification-event\"")); - } -} diff --git a/aai-core/src/test/resources/bundleconfig-local/etc/appprops/aaiconfig.properties b/aai-core/src/test/resources/bundleconfig-local/etc/appprops/aaiconfig.properties index c7eaad36..40554216 100644 --- a/aai-core/src/test/resources/bundleconfig-local/etc/appprops/aaiconfig.properties +++ b/aai-core/src/test/resources/bundleconfig-local/etc/appprops/aaiconfig.properties @@ -50,8 +50,6 @@ aai.example.int=7748 aai.realtime.clients=RO,SDNC,SO -aai.jms.enable=false - aai.rest.getall.depthparam=someuuid aaf.valid.issuer.wildcard=aaf wild card issuer|aafWildCardIssuer|OU=another diff --git a/aai-core/src/test/resources/payloads/expected/pserver-event.json b/aai-core/src/test/resources/payloads/expected/pserver-event.json new file mode 100644 index 00000000..11c1a100 --- /dev/null +++ b/aai-core/src/test/resources/payloads/expected/pserver-event.json @@ -0,0 +1,44 @@ +{ + "cambria.partition": "AAI", + "event-header": { + "severity": "NORMAL", + "entity-type": "pserver", + "top-entity-type": "pserver", + "entity-link": "/aai/v14/cloud-infrastructure/pservers/pserver/pserver1", + "event-type": "AAI-EVENT", + "domain": "devINT1", + "action": "CREATE", + "sequence-number": "0", + "id": "someTransaction", + "source-name": "test", + "version": "v14", + }, + "entity": { + "ptnii-equip-name": "example-ptnii-equip-name-val-36969", + "ipaddress-v6-loopback-0": "example-ipaddress-v6-loopback0-val-17856", + "equip-vendor": "example-equip-vendor-val-37452", + "purpose": "example-purpose-val-90218", + "pserver-selflink": "example-pserver-selflink-val-10125", + "number-of-cpus": 62220, + "ipaddress-v6-aim": "example-ipaddress-v6-aim-val-6210", + "pserver-name2": "example-pserver-name2-val-53802", + "hostname": "pserver1", + "inv-status": "example-inv-status-val-3682", + "disk-in-gigabytes": 872, + "equip-type": "example-equip-type-val-22986", + "fqdn": "example-fqdn-val-33429", + "serial-number": "example-serial-number-val-12010", + "ipaddress-v6-oam": "example-ipaddress-v6-oam-val-40977", + "pserver-id": "example-pserver-id-val-82142", + "prov-status": "example-prov-status-val-11642", + "ipv4-oam-address": "example-ipv4-oam-address-val-3155", + "ipaddress-v4-loopback-0": "example-ipaddress-v4-loopback0-val-77686", + "equip-model": "example-equip-model-val-14665", + "in-maint": true, + "ram-in-megabytes": 35331, + "ipaddress-v4-aim": "example-ipaddress-v4-aim-val-33665", + "management-option": "example-management-option-val-91111", + "internet-topology": "example-internet-topology-val-56425", + "host-profile": "example-host-profile-val-36247" + } +} diff --git a/aai-core/src/test/resources/payloads/resource/aai-event.json b/aai-core/src/test/resources/payloads/resource/aai-event.json index 0fab96da..86c67992 100644 --- a/aai-core/src/test/resources/payloads/resource/aai-event.json +++ b/aai-core/src/test/resources/payloads/resource/aai-event.json @@ -1,64 +1,61 @@ { - "event-topic": "AAI-EVENT", - "aaiEventPayload": { - "cambria.partition": "AAI", - "event-header": { - "severity": "NORMAL", - "entity-type": "object-group", - "top-entity-type": "object-group", - "entity-link": "/aai/v28/common/object-groups/object-group/ric_cluster", - "event-type": "AAI-EVENT", - "domain": "dev", - "action": "UPDATE", - "sequence-number": "0", - "id": "23f12123-c326-48a7-b57e-e48746c295ea", - "source-name": "postman-api", - "version": "v28", - "timestamp": "20231207-12:14:44:757" + "cambria.partition": "AAI", + "event-header": { + "severity": "NORMAL", + "entity-type": "object-group", + "top-entity-type": "object-group", + "entity-link": "/aai/v28/common/object-groups/object-group/ric_cluster", + "event-type": "AAI-EVENT", + "domain": "dev", + "action": "UPDATE", + "sequence-number": "0", + "id": "23f12123-c326-48a7-b57e-e48746c295ea", + "source-name": "postman-api", + "version": "v28", + "timestamp": "20231207-12:14:44:757" + }, + "entity": { + "relationship-list": { + "relationship": [ + { + "related-to": "cell", + "relationship-data": [ + { + "relationship-value": "445611193273958916", + "relationship-key": "cell.cell-id" + } + ], + "related-link": "/aai/v28/network/cells/cell/445611193273958916", + "relationship-label": "org.onap.relationships.inventory.MemberOf", + "related-to-property": [ + { + "property-key": "cell.cell-name", + "property-value": "MY6885_M-Schwere-Reiter-Str-440460_GU2_84079913" + } + ] + }, + { + "related-to": "cell", + "relationship-data": [ + { + "relationship-value": "445611193272330241", + "relationship-key": "cell.cell-id" + } + ], + "related-link": "/aai/v28/network/cells/cell/445611193272330241", + "relationship-label": "org.onap.relationships.inventory.MemberOf", + "related-to-property": [ + { + "property-key": "cell.cell-name", + "property-value": "MY6885_M-Schwere-Reiter-Str-440460_GTC2_84003803" + } + ] + } + ] }, - "entity": { - "relationship-list": { - "relationship": [ - { - "related-to": "cell", - "relationship-data": [ - { - "relationship-value": "445611193273958916", - "relationship-key": "cell.cell-id" - } - ], - "related-link": "/aai/v28/network/cells/cell/445611193273958916", - "relationship-label": "org.onap.relationships.inventory.MemberOf", - "related-to-property": [ - { - "property-key": "cell.cell-name", - "property-value": "MY6885_M-Schwere-Reiter-Str-440460_GU2_84079913" - } - ] - }, - { - "related-to": "cell", - "relationship-data": [ - { - "relationship-value": "445611193272330241", - "relationship-key": "cell.cell-id" - } - ], - "related-link": "/aai/v28/network/cells/cell/445611193272330241", - "relationship-label": "org.onap.relationships.inventory.MemberOf", - "related-to-property": [ - { - "property-key": "cell.cell-name", - "property-value": "MY6885_M-Schwere-Reiter-Str-440460_GTC2_84003803" - } - ] - } - ] - }, - "group-name": "Urban", - "resource-version": "1701951284582", - "group-type": "cell", - "object-group-id": "ric_cluster" - } + "group-name": "Urban", + "resource-version": "1701951284582", + "group-type": "cell", + "object-group-id": "ric_cluster" } -}
\ No newline at end of file +} diff --git a/aai-els-onap-logging/pom.xml b/aai-els-onap-logging/pom.xml index 6b24e1f4..65e340cf 100644 --- a/aai-els-onap-logging/pom.xml +++ b/aai-els-onap-logging/pom.xml @@ -4,7 +4,7 @@ <parent> <groupId>org.onap.aai.aai-common</groupId> <artifactId>aai-parent</artifactId> - <version>1.14.6-SNAPSHOT</version> + <version>1.15.2-SNAPSHOT</version> <relativePath>../aai-parent/pom.xml</relativePath> </parent> <artifactId>aai-els-onap-logging</artifactId> @@ -65,8 +65,8 @@ <scope>compile</scope> </dependency> <dependency> - <groupId>javax.annotation</groupId> - <artifactId>javax.annotation-api</artifactId> + <groupId>jakarta.annotation</groupId> + <artifactId>jakarta.annotation-api</artifactId> <scope>provided</scope> </dependency> <dependency> @@ -123,13 +123,13 @@ <artifactId>commons-io</artifactId> </dependency> <dependency> - <groupId>com.sun.jersey</groupId> + <groupId>org.glassfish.jersey.core</groupId> <artifactId>jersey-client</artifactId> </dependency> <dependency> <groupId>org.projectlombok</groupId> <artifactId>lombok</artifactId> - <version>1.18.30</version> + <version>1.18.34</version> <scope>provided</scope> </dependency> <dependency> @@ -165,17 +165,4 @@ </exclusions> </dependency> </dependencies> - - <!-- <build> - <plugins> - <plugin> - <groupId>org.springframework.boot</groupId> - <artifactId>spring-boot-maven-plugin</artifactId> - </plugin> - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-surefire-plugin</artifactId> - </plugin> - </plugins> - </build> --> </project> diff --git a/aai-els-onap-logging/src/main/java/org/onap/aai/aailog/filter/RestControllerClientLoggingInterceptor.java b/aai-els-onap-logging/src/main/java/org/onap/aai/aailog/filter/RestControllerClientRequestLoggingInterceptor.java index c09023d1..7a90aff0 100644 --- a/aai-els-onap-logging/src/main/java/org/onap/aai/aailog/filter/RestControllerClientLoggingInterceptor.java +++ b/aai-els-onap-logging/src/main/java/org/onap/aai/aailog/filter/RestControllerClientRequestLoggingInterceptor.java @@ -20,57 +20,39 @@ package org.onap.aai.aailog.filter; -import com.sun.jersey.api.client.ClientHandler; -import com.sun.jersey.api.client.ClientHandlerException; -import com.sun.jersey.api.client.ClientRequest; -import com.sun.jersey.api.client.ClientResponse; -import com.sun.jersey.api.client.filter.ClientFilter; - +import java.io.IOException; import java.time.ZoneOffset; import java.time.ZonedDateTime; import java.time.format.DateTimeFormatter; import java.util.UUID; import javax.ws.rs.core.MultivaluedMap; - +import javax.ws.rs.client.ClientRequestContext; +import javax.ws.rs.client.ClientRequestFilter; +import org.glassfish.jersey.client.ClientResponse; import org.onap.aai.aailog.logs.ServiceName; import org.onap.logging.filter.base.Constants; import org.onap.logging.filter.base.MDCSetup; import org.onap.logging.ref.slf4j.ONAPLogConstants; import org.slf4j.*; -public class RestControllerClientLoggingInterceptor extends ClientFilter { - private static final Logger logger = LoggerFactory.getLogger(RestControllerClientLoggingInterceptor.class); +public class RestControllerClientRequestLoggingInterceptor implements ClientRequestFilter { + private static final Logger logger = LoggerFactory.getLogger(RestControllerClientRequestLoggingInterceptor.class); private static final Marker INVOKE_RETURN = MarkerFactory.getMarker("INVOKE-RETURN"); private final MDCSetup mdcSetup; private final String partnerName; - public RestControllerClientLoggingInterceptor() { + public RestControllerClientRequestLoggingInterceptor() { mdcSetup = new MDCSetup(); partnerName = getPartnerName(); } - @Override - public ClientResponse handle(ClientRequest clientRequest) throws ClientHandlerException { - ClientResponse clientResponse = null; - pre(clientRequest); - // Call the next client handler in the filter chain - ClientHandler nextHandler = getNext(); - if (nextHandler != null) { - clientResponse = nextHandler.handle(clientRequest); - } - if (clientResponse != null) { - post(clientResponse); - } - return clientResponse; - } - - protected String getTargetServiceName(ClientRequest clientRequest) { - return getServiceName(clientRequest); + protected String getTargetServiceName(ClientRequestContext requestContext) { + return getServiceName(requestContext); } - protected String getServiceName(ClientRequest clientRequest) { - String path = clientRequest.getURI().getRawPath(); + protected String getServiceName(ClientRequestContext requestContext) { + String path = requestContext.getUri().getRawPath(); return ServiceName.extractServiceName(path); } @@ -82,24 +64,29 @@ public class RestControllerClientLoggingInterceptor extends ClientFilter { return String.valueOf(clientResponse.getStatus()); } - protected String getTargetEntity(ClientRequest ClientRequest) { + protected String getTargetEntity(ClientRequestContext requestContext) { return Constants.DefaultValues.UNKNOWN_TARGET_ENTITY; }; - protected void pre(ClientRequest clientRequest) { + @Override + public void filter(ClientRequestContext requestContext) throws IOException { + pre(requestContext); + } + + protected void pre(ClientRequestContext requestContext) { try { - setInvocationId(clientRequest); - setupMDC(clientRequest); - setupHeaders(clientRequest); + setInvocationId(requestContext); + setupMDC(requestContext); + setupHeaders(requestContext); logger.info(ONAPLogConstants.Markers.INVOKE, "Invoke"); } catch (Exception e) { logger.warn("Error in RestControllerClientLoggingInterceptor pre", e.getMessage()); } } - public void setInvocationId(ClientRequest clientRequest) { + public void setInvocationId(ClientRequestContext requestContext) { String invocationId = null; - MultivaluedMap<String, Object> requestHeaders = clientRequest.getHeaders(); + MultivaluedMap<String, Object> requestHeaders = requestContext.getHeaders(); Object id = requestHeaders.get(ONAPLogConstants.Headers.INVOCATION_ID); if (id != null) { invocationId = (String) id; @@ -111,9 +98,9 @@ public class RestControllerClientLoggingInterceptor extends ClientFilter { MDC.put(ONAPLogConstants.MDCs.INVOCATION_ID, invocationId); } - protected void setupHeaders(ClientRequest clientRequest) { - String requestId = extractRequestID(clientRequest); - MultivaluedMap<String, Object> requestHeaders = clientRequest.getHeaders(); + protected void setupHeaders(ClientRequestContext requestContext) { + String requestId = extractRequestID(requestContext); + MultivaluedMap<String, Object> requestHeaders = requestContext.getHeaders(); addHeader(requestHeaders, ONAPLogConstants.Headers.REQUEST_ID, requestId); addHeader(requestHeaders, Constants.HttpHeaders.HEADER_REQUEST_ID, requestId); Object requestIdObj = requestHeaders.getFirst(Constants.HttpHeaders.TRANSACTION_ID); @@ -127,15 +114,15 @@ public class RestControllerClientLoggingInterceptor extends ClientFilter { } } - protected void setupMDC(ClientRequest clientRequest) { + protected void setupMDC(ClientRequestContext requestContext) { MDC.put(ONAPLogConstants.MDCs.INVOKE_TIMESTAMP, ZonedDateTime.now(ZoneOffset.UTC).format(DateTimeFormatter.ISO_INSTANT)); - MDC.put(ONAPLogConstants.MDCs.TARGET_SERVICE_NAME, getTargetServiceName(clientRequest)); + MDC.put(ONAPLogConstants.MDCs.TARGET_SERVICE_NAME, getTargetServiceName(requestContext)); MDC.put(ONAPLogConstants.MDCs.RESPONSE_STATUS_CODE, ONAPLogConstants.ResponseStatus.INPROGRESS.toString()); mdcSetup.setInvocationIdFromMDC(); if (MDC.get(ONAPLogConstants.MDCs.TARGET_ENTITY) == null) { - String targetEntity = getTargetEntity(clientRequest); + String targetEntity = getTargetEntity(requestContext); if (targetEntity != null) { MDC.put(ONAPLogConstants.MDCs.TARGET_ENTITY, targetEntity); } else { @@ -144,15 +131,15 @@ public class RestControllerClientLoggingInterceptor extends ClientFilter { } if (MDC.get(ONAPLogConstants.MDCs.SERVICE_NAME) == null) { - MDC.put(ONAPLogConstants.MDCs.SERVICE_NAME, getServiceName(clientRequest)); + MDC.put(ONAPLogConstants.MDCs.SERVICE_NAME, getServiceName(requestContext)); } mdcSetup.setServerFQDN(); } - protected String extractRequestID(ClientRequest clientRequest) { + protected String extractRequestID(ClientRequestContext requestContext) { String requestId = MDC.get(ONAPLogConstants.MDCs.REQUEST_ID); if (requestId == null || requestId.isEmpty()) { - MultivaluedMap<String, Object> requestHeaders = clientRequest.getHeaders(); + MultivaluedMap<String, Object> requestHeaders = requestContext.getHeaders(); Object requestIdObj = requestHeaders.getFirst(Constants.HttpHeaders.TRANSACTION_ID); if (requestIdObj != null) { requestId = (String) requestIdObj; diff --git a/aai-els-onap-logging/src/main/java/org/onap/aai/aailog/filter/RestControllerClientResponseLoggingInterceptor.java b/aai-els-onap-logging/src/main/java/org/onap/aai/aailog/filter/RestControllerClientResponseLoggingInterceptor.java new file mode 100644 index 00000000..f35e9490 --- /dev/null +++ b/aai-els-onap-logging/src/main/java/org/onap/aai/aailog/filter/RestControllerClientResponseLoggingInterceptor.java @@ -0,0 +1,91 @@ +/** + * ============LICENSE_START======================================================= + * org.onap.aai + * ================================================================================ + * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.aai.aailog.filter; + +import java.io.IOException; +import java.util.UUID; + +import javax.ws.rs.client.ClientRequestContext; +import javax.ws.rs.client.ClientResponseContext; +import javax.ws.rs.client.ClientResponseFilter; +import javax.ws.rs.core.MultivaluedMap; + +import org.onap.logging.filter.base.Constants; +import org.onap.logging.filter.base.MDCSetup; +import org.onap.logging.ref.slf4j.ONAPLogConstants; +import org.slf4j.*; + +public class RestControllerClientResponseLoggingInterceptor implements ClientResponseFilter { + private static final Logger logger = LoggerFactory.getLogger(RestControllerClientRequestLoggingInterceptor.class); + private static final Marker INVOKE_RETURN = MarkerFactory.getMarker("INVOKE-RETURN"); + private final MDCSetup mdcSetup; + private final String partnerName; + + public RestControllerClientResponseLoggingInterceptor() { + mdcSetup = new MDCSetup(); + partnerName = getPartnerName(); + } + + @Override + public void filter(ClientRequestContext requestContext, ClientResponseContext responseContext) throws IOException { + post(responseContext); + } + + protected void post(ClientResponseContext responseContext) { + try { + mdcSetup.setLogTimestamp(); + mdcSetup.setElapsedTimeInvokeTimestamp(); + mdcSetup.setResponseStatusCode(getHttpStatusCode(responseContext)); + mdcSetup.setResponseDescription(getHttpStatusCode(responseContext)); + MDC.put(ONAPLogConstants.MDCs.RESPONSE_CODE, getResponseCode(responseContext)); + logger.info(INVOKE_RETURN, "InvokeReturn"); + mdcSetup.clearClientMDCs(); + } catch (Exception e) { + logger.warn("Error in RestControllerClientLoggingInterceptor post", e.getMessage()); + } + } + + protected int getHttpStatusCode(ClientResponseContext responseContext) { + return responseContext.getStatus(); + } + + protected String getResponseCode(ClientResponseContext responseContext) { + return String.valueOf(responseContext.getStatus()); + } + + public void setInvocationId(ClientRequestContext requestContext) { + String invocationId = null; + MultivaluedMap<String, Object> requestHeaders = requestContext.getHeaders(); + Object id = requestHeaders.get(ONAPLogConstants.Headers.INVOCATION_ID); + if (id != null) { + invocationId = (String) id; + } + requestHeaders.remove(ONAPLogConstants.Headers.INVOCATION_ID); + if (invocationId == null) { + invocationId = UUID.randomUUID().toString(); + } + MDC.put(ONAPLogConstants.MDCs.INVOCATION_ID, invocationId); + } + + protected String getPartnerName() { + return mdcSetup.getProperty(Constants.Property.PARTNER_NAME); + } +} diff --git a/aai-els-onap-logging/src/main/java/org/onap/aai/domain/errorResponse/RequestError.java b/aai-els-onap-logging/src/main/java/org/onap/aai/domain/errorResponse/RequestError.java index 96602906..6d3a6501 100644 --- a/aai-els-onap-logging/src/main/java/org/onap/aai/domain/errorResponse/RequestError.java +++ b/aai-els-onap-logging/src/main/java/org/onap/aai/domain/errorResponse/RequestError.java @@ -21,7 +21,6 @@ package org.onap.aai.domain.errorResponse; import lombok.AllArgsConstructor; import lombok.NoArgsConstructor; -import lombok.Value; import java.util.Map; @NoArgsConstructor diff --git a/aai-els-onap-logging/src/main/java/org/onap/aai/exceptions/AAIException.java b/aai-els-onap-logging/src/main/java/org/onap/aai/exceptions/AAIException.java index e302cd5a..6c30dd07 100644 --- a/aai-els-onap-logging/src/main/java/org/onap/aai/exceptions/AAIException.java +++ b/aai-els-onap-logging/src/main/java/org/onap/aai/exceptions/AAIException.java @@ -28,7 +28,6 @@ import java.util.LinkedList; import org.onap.aai.logging.ErrorLogHelper; import org.onap.aai.logging.ErrorObject; -import org.onap.aai.logging.ErrorObjectNotFoundException; public class AAIException extends Exception { diff --git a/aai-els-onap-logging/src/main/java/org/onap/aai/util/FormatDate.java b/aai-els-onap-logging/src/main/java/org/onap/aai/util/FormatDate.java index 9ee2b71d..4243c539 100644 --- a/aai-els-onap-logging/src/main/java/org/onap/aai/util/FormatDate.java +++ b/aai-els-onap-logging/src/main/java/org/onap/aai/util/FormatDate.java @@ -27,21 +27,18 @@ import java.time.format.DateTimeFormatter; public class FormatDate { private final String timeZone; - private final String pattern; + private final DateTimeFormatter formatter ; public FormatDate(String pattern) { - this.pattern = pattern; - this.timeZone = "GMT"; + this(pattern, "GMT"); } public FormatDate(String pattern, String timeZone) { - this.pattern = pattern; this.timeZone = timeZone; + this.formatter = DateTimeFormatter.ofPattern(pattern); } public String getDateTime() { - - final DateTimeFormatter formatter = DateTimeFormatter.ofPattern(pattern); return formatter.format(ZonedDateTime.now(ZoneId.of(timeZone))); } } diff --git a/aai-els-onap-logging/src/main/java/org/onap/logging/filter/base/AuditLogContainerFilter.java b/aai-els-onap-logging/src/main/java/org/onap/logging/filter/base/AuditLogContainerFilter.java index 530d53b3..270f786e 100644 --- a/aai-els-onap-logging/src/main/java/org/onap/logging/filter/base/AuditLogContainerFilter.java +++ b/aai-els-onap-logging/src/main/java/org/onap/logging/filter/base/AuditLogContainerFilter.java @@ -24,7 +24,10 @@ import java.io.IOException; import javax.annotation.Priority; import javax.servlet.http.HttpServletRequest; -import javax.ws.rs.container.*; +import javax.ws.rs.container.ContainerRequestContext; +import javax.ws.rs.container.ContainerRequestFilter; +import javax.ws.rs.container.ContainerResponseContext; +import javax.ws.rs.container.ContainerResponseFilter; import javax.ws.rs.core.Context; import javax.ws.rs.ext.Providers; diff --git a/aai-els-onap-logging/src/test/java/org/onap/aai/aailog/filter/AaiAuditLogContainerFilterTest.java b/aai-els-onap-logging/src/test/java/org/onap/aai/aailog/filter/AaiAuditLogContainerFilterTest.java index 246586d0..fd770347 100644 --- a/aai-els-onap-logging/src/test/java/org/onap/aai/aailog/filter/AaiAuditLogContainerFilterTest.java +++ b/aai-els-onap-logging/src/test/java/org/onap/aai/aailog/filter/AaiAuditLogContainerFilterTest.java @@ -20,7 +20,7 @@ package org.onap.aai.aailog.filter; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import static org.mockito.Mockito.when; import java.net.URI; @@ -31,18 +31,18 @@ import javax.ws.rs.core.MultivaluedHashMap; import javax.ws.rs.core.MultivaluedMap; import javax.ws.rs.core.UriInfo; -import org.junit.After; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.InjectMocks; import org.mockito.Mock; import org.mockito.Spy; -import org.mockito.junit.MockitoJUnitRunner; +import org.mockito.junit.jupiter.MockitoExtension; import org.onap.logging.filter.base.Constants; import org.onap.logging.ref.slf4j.ONAPLogConstants; import org.slf4j.MDC; -@RunWith(MockitoJUnitRunner.class) +@ExtendWith(MockitoExtension.class) public class AaiAuditLogContainerFilterTest { @Mock private ContainerRequestContext containerRequest; @@ -57,7 +57,7 @@ public class AaiAuditLogContainerFilterTest { @InjectMocks private AaiAuditLogContainerFilter aaiAuditFilter; - @After + @AfterEach public void tearDown() { MDC.clear(); } diff --git a/aai-els-onap-logging/src/test/java/org/onap/aai/aailog/filter/RestClientLoggingInterceptorTest.java b/aai-els-onap-logging/src/test/java/org/onap/aai/aailog/filter/RestClientLoggingInterceptorTest.java index f8d23f39..53e87509 100644 --- a/aai-els-onap-logging/src/test/java/org/onap/aai/aailog/filter/RestClientLoggingInterceptorTest.java +++ b/aai-els-onap-logging/src/test/java/org/onap/aai/aailog/filter/RestClientLoggingInterceptorTest.java @@ -20,8 +20,8 @@ package org.onap.aai.aailog.filter; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.mockito.Mockito.doReturn; import java.net.InetAddress; @@ -29,20 +29,20 @@ import java.net.URI; import java.net.URISyntaxException; import java.net.UnknownHostException; -import org.junit.After; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.InjectMocks; import org.mockito.Mock; import org.mockito.Spy; -import org.mockito.junit.MockitoJUnitRunner; +import org.mockito.junit.jupiter.MockitoExtension; import org.onap.logging.filter.base.Constants; import org.onap.logging.ref.slf4j.ONAPLogConstants; import org.slf4j.MDC; import org.springframework.http.HttpHeaders; import org.springframework.http.HttpRequest; -@RunWith(MockitoJUnitRunner.class) +@ExtendWith(MockitoExtension.class) public class RestClientLoggingInterceptorTest { @Mock @@ -52,7 +52,7 @@ public class RestClientLoggingInterceptorTest { @InjectMocks private RestClientLoggingInterceptor restClientLoggingInterceptor; - @After + @AfterEach public void tearDown() { MDC.clear(); } diff --git a/aai-els-onap-logging/src/test/java/org/onap/aai/aailog/filter/RestControllerClientLoggingInterceptorTest.java b/aai-els-onap-logging/src/test/java/org/onap/aai/aailog/filter/RestControllerClientLoggingInterceptorTest.java index 9c4b2655..006b3c4a 100644 --- a/aai-els-onap-logging/src/test/java/org/onap/aai/aailog/filter/RestControllerClientLoggingInterceptorTest.java +++ b/aai-els-onap-logging/src/test/java/org/onap/aai/aailog/filter/RestControllerClientLoggingInterceptorTest.java @@ -22,14 +22,14 @@ package org.onap.aai.aailog.filter; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; - -import com.sun.jersey.api.client.ClientRequest; +import static org.mockito.Mockito.when; import java.net.InetAddress; import java.net.URI; import java.net.URISyntaxException; import java.net.UnknownHostException; +import javax.ws.rs.client.ClientRequestContext; import javax.ws.rs.core.MultivaluedHashMap; import javax.ws.rs.core.MultivaluedMap; @@ -47,17 +47,24 @@ import org.slf4j.MDC; @RunWith(MockitoJUnitRunner.class) public class RestControllerClientLoggingInterceptorTest { - private ClientRequest clientRequest; + @Spy + private ClientRequestContext clientRequest; @Spy @InjectMocks - private RestControllerClientLoggingInterceptor restControllerClientLoggingInterceptor; + private RestControllerClientRequestLoggingInterceptor restControllerClientLoggingInterceptor; @Before public void init() throws URISyntaxException { System.setProperty("javax.ws.rs.ext.RuntimeDelegate", "com.sun.ws.rs.ext.RuntimeDelegateImpl"); - clientRequest = ClientRequest.create().build( - new URI("https://localhost:9999/aai/v1/cloud-infrastructure/complexes/complex/complex-1"), "GET"); + when(clientRequest.getHeaders()).thenReturn(new MultivaluedHashMap<String, Object>()); + when(clientRequest.getUri()) + .thenReturn(new URI("https://localhost:9999/aai/v1/cloud-infrastructure/complexes/complex/complex-1")); + + // clientRequest = ClientRequest.create().build( + // new + // URI("https://localhost:9999/aai/v1/cloud-infrastructure/complexes/complex/complex-1"), + // "GET"); } @After @@ -71,6 +78,10 @@ public class RestControllerClientLoggingInterceptorTest { String transId = "37b3ab2a-e57e-4fe8-8d8f-eee3019efce6"; MultivaluedMap<String, Object> requestHeaders = new MultivaluedHashMap<String, Object>(); requestHeaders.add(Constants.HttpHeaders.TRANSACTION_ID, transId); + when(clientRequest.getHeaders()).thenReturn(requestHeaders); + when(clientRequest.getUri()) + .thenReturn(new URI("https://localhost:9999/aai/v1/cloud-infrastructure/complexes/complex/complex-1")); + clientRequest.getHeaders().putAll(requestHeaders); restControllerClientLoggingInterceptor.pre(clientRequest); MultivaluedMap<String, Object> headers = clientRequest.getHeaders(); diff --git a/aai-els-onap-logging/src/test/java/org/onap/aai/exceptions/AAIExceptionTest.java b/aai-els-onap-logging/src/test/java/org/onap/aai/exceptions/AAIExceptionTest.java index b489a0ab..5d7b989d 100644 --- a/aai-els-onap-logging/src/test/java/org/onap/aai/exceptions/AAIExceptionTest.java +++ b/aai-els-onap-logging/src/test/java/org/onap/aai/exceptions/AAIExceptionTest.java @@ -20,14 +20,14 @@ package org.onap.aai.exceptions; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; import java.io.IOException; import javax.ws.rs.core.Response; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.onap.aai.logging.AaiElsErrorCode; import org.onap.aai.logging.ErrorObject; diff --git a/aai-els-onap-logging/src/test/java/org/onap/aai/exceptions/AAIExceptionWithInfoTest.java b/aai-els-onap-logging/src/test/java/org/onap/aai/exceptions/AAIExceptionWithInfoTest.java index 84284ec5..282dcfa3 100644 --- a/aai-els-onap-logging/src/test/java/org/onap/aai/exceptions/AAIExceptionWithInfoTest.java +++ b/aai-els-onap-logging/src/test/java/org/onap/aai/exceptions/AAIExceptionWithInfoTest.java @@ -20,13 +20,13 @@ package org.onap.aai.exceptions; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; import java.io.IOException; import java.util.HashMap; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class AAIExceptionWithInfoTest { diff --git a/aai-els-onap-logging/src/test/java/org/onap/aai/logging/CNNameTest.java b/aai-els-onap-logging/src/test/java/org/onap/aai/logging/CNNameTest.java index d95aefa0..906bd5db 100644 --- a/aai-els-onap-logging/src/test/java/org/onap/aai/logging/CNNameTest.java +++ b/aai-els-onap-logging/src/test/java/org/onap/aai/logging/CNNameTest.java @@ -20,7 +20,7 @@ package org.onap.aai.logging; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import static org.mockito.Mockito.when; import ch.qos.logback.access.spi.IAccessEvent; @@ -29,16 +29,16 @@ import java.security.cert.X509Certificate; import javax.security.auth.x500.X500Principal; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.InjectMocks; import org.mockito.Mock; import org.mockito.Spy; -import org.mockito.junit.MockitoJUnitRunner; +import org.mockito.junit.jupiter.MockitoExtension; import org.springframework.mock.web.MockHttpServletRequest; -@RunWith(MockitoJUnitRunner.class) +@ExtendWith(MockitoExtension.class) public class CNNameTest { @Mock X509Certificate cert; @@ -50,7 +50,7 @@ public class CNNameTest { @InjectMocks private CNName cnName; - @Before + @BeforeEach public void setup() { when(cnName.isStarted()).thenReturn(true); } diff --git a/aai-els-onap-logging/src/test/java/org/onap/aai/logging/CustomLogPatternLayoutTest.java b/aai-els-onap-logging/src/test/java/org/onap/aai/logging/CustomLogPatternLayoutTest.java index 28be0bf0..6a39a4b7 100644 --- a/aai-els-onap-logging/src/test/java/org/onap/aai/logging/CustomLogPatternLayoutTest.java +++ b/aai-els-onap-logging/src/test/java/org/onap/aai/logging/CustomLogPatternLayoutTest.java @@ -20,9 +20,9 @@ package org.onap.aai.logging; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class CustomLogPatternLayoutTest { diff --git a/aai-els-onap-logging/src/test/java/org/onap/aai/logging/DME2RestFlagTest.java b/aai-els-onap-logging/src/test/java/org/onap/aai/logging/DME2RestFlagTest.java index c29e29d6..ddd0c6db 100644 --- a/aai-els-onap-logging/src/test/java/org/onap/aai/logging/DME2RestFlagTest.java +++ b/aai-els-onap-logging/src/test/java/org/onap/aai/logging/DME2RestFlagTest.java @@ -20,20 +20,20 @@ package org.onap.aai.logging; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import static org.mockito.Mockito.when; import ch.qos.logback.access.spi.IAccessEvent; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.InjectMocks; import org.mockito.Mock; import org.mockito.Spy; -import org.mockito.junit.MockitoJUnitRunner; +import org.mockito.junit.jupiter.MockitoExtension; -@RunWith(MockitoJUnitRunner.class) +@ExtendWith(MockitoExtension.class) public class DME2RestFlagTest { @Mock @@ -43,7 +43,7 @@ public class DME2RestFlagTest { @InjectMocks private DME2RestFlag dme2RestFlag; - @Before + @BeforeEach public void setup() { when(dme2RestFlag.isStarted()).thenReturn(true); } diff --git a/aai-els-onap-logging/src/test/java/org/onap/aai/logging/ErrorLogHelperTest.java b/aai-els-onap-logging/src/test/java/org/onap/aai/logging/ErrorLogHelperTest.java index 73890a0a..226e4b22 100644 --- a/aai-els-onap-logging/src/test/java/org/onap/aai/logging/ErrorLogHelperTest.java +++ b/aai-els-onap-logging/src/test/java/org/onap/aai/logging/ErrorLogHelperTest.java @@ -22,7 +22,7 @@ package org.onap.aai.logging; import static java.lang.Thread.sleep; -import static org.junit.Assert.*; +import static org.junit.jupiter.api.Assertions.*; import java.io.IOException; import java.util.ArrayList; @@ -34,10 +34,9 @@ import java.util.Map; import javax.ws.rs.core.MediaType; -import org.junit.After; -import org.junit.Before; -import org.junit.Ignore; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.onap.aai.domain.errorResponse.ErrorMessage; import org.onap.aai.domain.errorResponse.ExceptionType; import org.onap.aai.domain.errorResponse.Fault; @@ -59,12 +58,12 @@ public class ErrorLogHelperTest { private static final ObjectMapper objectMapper = new ObjectMapper(); private static final XmlMapper xmlMapper = new XmlMapper(); - @Before + @BeforeEach public void init() { System.setProperty("AJSC_HOME", "."); } - @After + @AfterEach public void cleanup() throws IOException { MDC.clear(); LogFile.deleteContents(errorLogFileName); diff --git a/aai-els-onap-logging/src/test/java/org/onap/aai/logging/ErrorObjectFormatExceptionTest.java b/aai-els-onap-logging/src/test/java/org/onap/aai/logging/ErrorObjectFormatExceptionTest.java index 97934723..bcf35885 100644 --- a/aai-els-onap-logging/src/test/java/org/onap/aai/logging/ErrorObjectFormatExceptionTest.java +++ b/aai-els-onap-logging/src/test/java/org/onap/aai/logging/ErrorObjectFormatExceptionTest.java @@ -20,9 +20,9 @@ package org.onap.aai.logging; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertTrue; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class ErrorObjectFormatExceptionTest { diff --git a/aai-els-onap-logging/src/test/java/org/onap/aai/logging/ErrorObjectNotFoundExceptionTest.java b/aai-els-onap-logging/src/test/java/org/onap/aai/logging/ErrorObjectNotFoundExceptionTest.java index 6be89425..6b832c2f 100644 --- a/aai-els-onap-logging/src/test/java/org/onap/aai/logging/ErrorObjectNotFoundExceptionTest.java +++ b/aai-els-onap-logging/src/test/java/org/onap/aai/logging/ErrorObjectNotFoundExceptionTest.java @@ -20,11 +20,11 @@ package org.onap.aai.logging; -import static org.junit.Assert.*; +import static org.junit.jupiter.api.Assertions.*; import java.io.IOException; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class ErrorObjectNotFoundExceptionTest { diff --git a/aai-els-onap-logging/src/test/java/org/onap/aai/logging/ErrorObjectTest.java b/aai-els-onap-logging/src/test/java/org/onap/aai/logging/ErrorObjectTest.java index a281ba56..6c2b12e0 100644 --- a/aai-els-onap-logging/src/test/java/org/onap/aai/logging/ErrorObjectTest.java +++ b/aai-els-onap-logging/src/test/java/org/onap/aai/logging/ErrorObjectTest.java @@ -20,11 +20,11 @@ package org.onap.aai.logging; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import javax.ws.rs.core.Response; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class ErrorObjectTest { private ErrorObject errorObject; diff --git a/aai-els-onap-logging/src/test/java/org/onap/aai/logging/LogFormatToolsTest.java b/aai-els-onap-logging/src/test/java/org/onap/aai/logging/LogFormatToolsTest.java index b352cb14..d580efa1 100644 --- a/aai-els-onap-logging/src/test/java/org/onap/aai/logging/LogFormatToolsTest.java +++ b/aai-els-onap-logging/src/test/java/org/onap/aai/logging/LogFormatToolsTest.java @@ -20,10 +20,10 @@ package org.onap.aai.logging; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.onap.aai.exceptions.AAIException; public class LogFormatToolsTest { diff --git a/aai-els-onap-logging/src/test/java/org/onap/aai/logging/LoggingContextTest.java b/aai-els-onap-logging/src/test/java/org/onap/aai/logging/LoggingContextTest.java index d793eb77..650f94b7 100644 --- a/aai-els-onap-logging/src/test/java/org/onap/aai/logging/LoggingContextTest.java +++ b/aai-els-onap-logging/src/test/java/org/onap/aai/logging/LoggingContextTest.java @@ -20,17 +20,17 @@ package org.onap.aai.logging; -import static org.junit.Assert.*; +import static org.junit.jupiter.api.Assertions.*; import java.util.concurrent.TimeUnit; -import org.junit.After; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Test; import org.slf4j.MDC; public class LoggingContextTest { - @After + @AfterEach public void cleanup() { MDC.clear(); } diff --git a/aai-els-onap-logging/src/test/java/org/onap/aai/logging/StopWatchNotStartedExceptionTest.java b/aai-els-onap-logging/src/test/java/org/onap/aai/logging/StopWatchNotStartedExceptionTest.java index 2c9c52c5..6833942a 100644 --- a/aai-els-onap-logging/src/test/java/org/onap/aai/logging/StopWatchNotStartedExceptionTest.java +++ b/aai-els-onap-logging/src/test/java/org/onap/aai/logging/StopWatchNotStartedExceptionTest.java @@ -20,10 +20,10 @@ package org.onap.aai.logging; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class StopWatchNotStartedExceptionTest { diff --git a/aai-els-onap-logging/src/test/java/org/onap/aai/logging/StopWatchTest.java b/aai-els-onap-logging/src/test/java/org/onap/aai/logging/StopWatchTest.java index 34aecd56..9893bb2b 100644 --- a/aai-els-onap-logging/src/test/java/org/onap/aai/logging/StopWatchTest.java +++ b/aai-els-onap-logging/src/test/java/org/onap/aai/logging/StopWatchTest.java @@ -21,15 +21,15 @@ package org.onap.aai.logging; import static java.lang.Thread.sleep; -import static org.junit.Assert.*; +import static org.junit.jupiter.api.Assertions.*; -import org.junit.After; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Test; import org.slf4j.MDC; public class StopWatchTest { - @After + @AfterEach public void cleanup() { MDC.clear(); } diff --git a/aai-els-onap-logging/src/test/java/org/onap/aai/util/AAIApplicationConfigTest.java b/aai-els-onap-logging/src/test/java/org/onap/aai/util/AAIApplicationConfigTest.java index 7d51ccc2..242e3441 100644 --- a/aai-els-onap-logging/src/test/java/org/onap/aai/util/AAIApplicationConfigTest.java +++ b/aai-els-onap-logging/src/test/java/org/onap/aai/util/AAIApplicationConfigTest.java @@ -22,16 +22,16 @@ package org.onap.aai.util; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.onap.aai.exceptions.AAIException; public class AAIApplicationConfigTest { - @Before + @BeforeEach public void setup() { AAIApplicationConfig.init(); } diff --git a/aai-els-onap-logging/src/test/java/org/onap/aai/util/AAIConfigTest.java b/aai-els-onap-logging/src/test/java/org/onap/aai/util/AAIConfigTest.java index dad8c351..7073c841 100644 --- a/aai-els-onap-logging/src/test/java/org/onap/aai/util/AAIConfigTest.java +++ b/aai-els-onap-logging/src/test/java/org/onap/aai/util/AAIConfigTest.java @@ -22,15 +22,15 @@ package org.onap.aai.util; -import static org.junit.Assert.*; +import static org.junit.jupiter.api.Assertions.*; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.onap.aai.exceptions.AAIException; public class AAIConfigTest { - @Before + @BeforeEach public void setup() throws AAIException { AAIConfig.init(); } diff --git a/aai-els-onap-logging/src/test/java/org/onap/aai/util/FormatDateTest.java b/aai-els-onap-logging/src/test/java/org/onap/aai/util/FormatDateTest.java index b1be62a1..4041f00d 100644 --- a/aai-els-onap-logging/src/test/java/org/onap/aai/util/FormatDateTest.java +++ b/aai-els-onap-logging/src/test/java/org/onap/aai/util/FormatDateTest.java @@ -22,9 +22,9 @@ package org.onap.aai.util; -import static org.junit.Assert.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNotNull; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.onap.aai.exceptions.AAIException; public class FormatDateTest { diff --git a/aai-els-onap-logging/src/test/java/org/onap/aai/util/MapperUtilTest.java b/aai-els-onap-logging/src/test/java/org/onap/aai/util/MapperUtilTest.java index 14d80020..309e4a49 100644 --- a/aai-els-onap-logging/src/test/java/org/onap/aai/util/MapperUtilTest.java +++ b/aai-els-onap-logging/src/test/java/org/onap/aai/util/MapperUtilTest.java @@ -22,19 +22,19 @@ package org.onap.aai.util; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import org.json.JSONObject; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; public class MapperUtilTest { private JSONObject expectedJson; private JSONObject sampleJson; - @Before + @BeforeEach public void setup() { expectedJson = new JSONObject(); sampleJson = new JSONObject(); @@ -45,7 +45,7 @@ public class MapperUtilTest { expectedJson.put("color", "black"); expectedJson.put("shape", "box"); SampleClass sample = new SampleClass("black", "box"); - Assert.assertEquals(expectedJson.toString(), MapperUtil.writeAsJSONString(sample)); + Assertions.assertEquals(expectedJson.toString(), MapperUtil.writeAsJSONString(sample)); } @Test diff --git a/aai-els-onap-logging/src/test/java/org/onap/logging/filter/base/AuditLogContainerFilterTest.java b/aai-els-onap-logging/src/test/java/org/onap/logging/filter/base/AuditLogContainerFilterTest.java index 8ac9f12d..a8903c41 100644 --- a/aai-els-onap-logging/src/test/java/org/onap/logging/filter/base/AuditLogContainerFilterTest.java +++ b/aai-els-onap-logging/src/test/java/org/onap/logging/filter/base/AuditLogContainerFilterTest.java @@ -20,7 +20,7 @@ package org.onap.logging.filter.base; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import static org.mockito.Mockito.when; import javax.ws.rs.container.ContainerRequestContext; @@ -29,19 +29,19 @@ import javax.ws.rs.core.MultivaluedHashMap; import javax.ws.rs.core.MultivaluedMap; import javax.ws.rs.core.UriInfo; -import org.junit.After; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.InjectMocks; import org.mockito.Mock; import org.mockito.Spy; -import org.mockito.junit.MockitoJUnitRunner; +import org.mockito.junit.jupiter.MockitoExtension; import org.onap.logging.ref.slf4j.ONAPLogConstants; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.slf4j.MDC; -@RunWith(MockitoJUnitRunner.class) +@ExtendWith(MockitoExtension.class) public class AuditLogContainerFilterTest { protected static final Logger logger = LoggerFactory.getLogger(AbstractMetricLogFilter.class); @@ -58,7 +58,7 @@ public class AuditLogContainerFilterTest { @InjectMocks private AuditLogContainerFilter auditLogContainerFilter; - @After + @AfterEach public void tearDown() { MDC.clear(); } diff --git a/aai-els-onap-logging/src/test/java/org/onap/logging/filter/base/AuditLogServletFilterTest.java b/aai-els-onap-logging/src/test/java/org/onap/logging/filter/base/AuditLogServletFilterTest.java index afdfe059..6f724a09 100644 --- a/aai-els-onap-logging/src/test/java/org/onap/logging/filter/base/AuditLogServletFilterTest.java +++ b/aai-els-onap-logging/src/test/java/org/onap/logging/filter/base/AuditLogServletFilterTest.java @@ -20,7 +20,7 @@ package org.onap.logging.filter.base; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import static org.mockito.Mockito.when; import javax.servlet.ServletRequest; @@ -28,17 +28,17 @@ import javax.servlet.ServletResponse; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; -import org.junit.After; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.InjectMocks; import org.mockito.Mock; import org.mockito.Spy; -import org.mockito.junit.MockitoJUnitRunner; +import org.mockito.junit.jupiter.MockitoExtension; import org.onap.logging.ref.slf4j.ONAPLogConstants; import org.slf4j.MDC; -@RunWith(MockitoJUnitRunner.class) +@ExtendWith(MockitoExtension.class) public class AuditLogServletFilterTest { @Mock @@ -57,7 +57,7 @@ public class AuditLogServletFilterTest { @InjectMocks private AuditLogServletFilter auditLogServletFilter; - @After + @AfterEach public void tearDown() { MDC.clear(); } diff --git a/aai-els-onap-logging/src/test/java/org/onap/logging/filter/base/LoggingContainerFilterTest.java b/aai-els-onap-logging/src/test/java/org/onap/logging/filter/base/LoggingContainerFilterTest.java index 6390c8ea..defc7855 100644 --- a/aai-els-onap-logging/src/test/java/org/onap/logging/filter/base/LoggingContainerFilterTest.java +++ b/aai-els-onap-logging/src/test/java/org/onap/logging/filter/base/LoggingContainerFilterTest.java @@ -20,12 +20,12 @@ package org.onap.logging.filter.base; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import javax.ws.rs.core.MultivaluedHashMap; import javax.ws.rs.core.MultivaluedMap; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.onap.logging.ref.slf4j.ONAPLogConstants; public class LoggingContainerFilterTest { diff --git a/aai-els-onap-logging/src/test/java/org/onap/logging/filter/base/MDCSetupTest.java b/aai-els-onap-logging/src/test/java/org/onap/logging/filter/base/MDCSetupTest.java index e47db8ce..e3245fa9 100644 --- a/aai-els-onap-logging/src/test/java/org/onap/logging/filter/base/MDCSetupTest.java +++ b/aai-els-onap-logging/src/test/java/org/onap/logging/filter/base/MDCSetupTest.java @@ -20,9 +20,7 @@ package org.onap.logging.filter.base; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; +import static org.junit.jupiter.api.Assertions.*; import static org.mockito.Mockito.when; import java.util.HashMap; @@ -32,15 +30,15 @@ import javax.ws.rs.core.HttpHeaders; import javax.ws.rs.core.MultivaluedHashMap; import javax.ws.rs.core.MultivaluedMap; -import org.junit.After; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.Mock; -import org.mockito.junit.MockitoJUnitRunner; +import org.mockito.junit.jupiter.MockitoExtension; import org.onap.logging.ref.slf4j.ONAPLogConstants; import org.slf4j.MDC; -@RunWith(MockitoJUnitRunner.class) +@ExtendWith(MockitoExtension.class) public class MDCSetupTest extends MDCSetup { @Mock @@ -49,7 +47,7 @@ public class MDCSetupTest extends MDCSetup { private String requestId = "4d31fe02-4918-4975-942f-fe51a44e6a9b"; private String invocationId = "4d31fe02-4918-4975-942f-fe51a44e6a9a"; - @After + @AfterEach public void tearDown() { MDC.clear(); System.clearProperty("partnerName"); diff --git a/aai-els-onap-logging/src/test/java/org/onap/logging/filter/base/MetricLogClientFilterTest.java b/aai-els-onap-logging/src/test/java/org/onap/logging/filter/base/MetricLogClientFilterTest.java index daa57625..6f23d9b5 100644 --- a/aai-els-onap-logging/src/test/java/org/onap/logging/filter/base/MetricLogClientFilterTest.java +++ b/aai-els-onap-logging/src/test/java/org/onap/logging/filter/base/MetricLogClientFilterTest.java @@ -20,8 +20,8 @@ package org.onap.logging.filter.base; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.mockito.Mockito.doReturn; import java.net.URI; @@ -34,17 +34,17 @@ import javax.ws.rs.client.ClientRequestContext; import javax.ws.rs.core.MultivaluedHashMap; import javax.ws.rs.core.MultivaluedMap; -import org.junit.After; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.InjectMocks; import org.mockito.Mock; import org.mockito.Spy; -import org.mockito.junit.MockitoJUnitRunner; +import org.mockito.junit.jupiter.MockitoExtension; import org.onap.logging.ref.slf4j.ONAPLogConstants; import org.slf4j.MDC; -@RunWith(MockitoJUnitRunner.class) +@ExtendWith(MockitoExtension.class) public class MetricLogClientFilterTest { @Mock private ClientRequestContext clientRequest; @@ -53,7 +53,7 @@ public class MetricLogClientFilterTest { @InjectMocks private MetricLogClientFilter metricLogClientFilter; - @After + @AfterEach public void tearDown() { MDC.clear(); } diff --git a/aai-els-onap-logging/src/test/java/org/onap/logging/filter/base/PayloadLoggingClientFilterTest.java b/aai-els-onap-logging/src/test/java/org/onap/logging/filter/base/PayloadLoggingClientFilterTest.java index 61e7014b..74463a7b 100644 --- a/aai-els-onap-logging/src/test/java/org/onap/logging/filter/base/PayloadLoggingClientFilterTest.java +++ b/aai-els-onap-logging/src/test/java/org/onap/logging/filter/base/PayloadLoggingClientFilterTest.java @@ -20,7 +20,7 @@ package org.onap.logging.filter.base; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import static org.mockito.Mockito.when; import java.io.IOException; @@ -30,14 +30,14 @@ import javax.ws.rs.client.ClientRequestContext; import javax.ws.rs.core.MultivaluedHashMap; import javax.ws.rs.core.MultivaluedMap; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.InjectMocks; import org.mockito.Mock; import org.mockito.Spy; -import org.mockito.junit.MockitoJUnitRunner; +import org.mockito.junit.jupiter.MockitoExtension; -@RunWith(MockitoJUnitRunner.class) +@ExtendWith(MockitoExtension.class) public class PayloadLoggingClientFilterTest { @Mock diff --git a/aai-els-onap-logging/src/test/java/org/onap/logging/filter/base/SimpleJaxrsHeadersMapTest.java b/aai-els-onap-logging/src/test/java/org/onap/logging/filter/base/SimpleJaxrsHeadersMapTest.java index 0ae919fc..660bd3ce 100644 --- a/aai-els-onap-logging/src/test/java/org/onap/logging/filter/base/SimpleJaxrsHeadersMapTest.java +++ b/aai-els-onap-logging/src/test/java/org/onap/logging/filter/base/SimpleJaxrsHeadersMapTest.java @@ -20,12 +20,12 @@ package org.onap.logging.filter.base; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import javax.ws.rs.core.MultivaluedHashMap; import javax.ws.rs.core.MultivaluedMap; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.onap.logging.ref.slf4j.ONAPLogConstants; public class SimpleJaxrsHeadersMapTest { diff --git a/aai-els-onap-logging/src/test/java/org/onap/logging/filter/base/SimpleServletHeadersMapTest.java b/aai-els-onap-logging/src/test/java/org/onap/logging/filter/base/SimpleServletHeadersMapTest.java index ccde0000..c2a271a7 100644 --- a/aai-els-onap-logging/src/test/java/org/onap/logging/filter/base/SimpleServletHeadersMapTest.java +++ b/aai-els-onap-logging/src/test/java/org/onap/logging/filter/base/SimpleServletHeadersMapTest.java @@ -20,19 +20,19 @@ package org.onap.logging.filter.base; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import static org.mockito.Mockito.when; import javax.servlet.http.HttpServletRequest; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.InjectMocks; import org.mockito.Mock; import org.mockito.Spy; -import org.mockito.junit.MockitoJUnitRunner; +import org.mockito.junit.jupiter.MockitoExtension; -@RunWith(MockitoJUnitRunner.class) +@ExtendWith(MockitoExtension.class) public class SimpleServletHeadersMapTest { @Mock diff --git a/aai-els-onap-logging/src/test/java/org/onap/logging/ref/slf4j/ONAPLogAdapterTest.java b/aai-els-onap-logging/src/test/java/org/onap/logging/ref/slf4j/ONAPLogAdapterTest.java index f0553603..f3d0ed95 100644 --- a/aai-els-onap-logging/src/test/java/org/onap/logging/ref/slf4j/ONAPLogAdapterTest.java +++ b/aai-els-onap-logging/src/test/java/org/onap/logging/ref/slf4j/ONAPLogAdapterTest.java @@ -29,6 +29,7 @@ import static org.hamcrest.core.IsNull.nullValue; import static org.hamcrest.core.IsSame.sameInstance; import static org.hamcrest.core.StringEndsWith.endsWith; import static org.hamcrest.number.OrderingComparison.lessThan; +import static org.junit.jupiter.api.Assertions.assertThrows; import java.util.HashMap; import java.util.Map; @@ -36,8 +37,8 @@ import java.util.UUID; import javax.xml.bind.DatatypeConverter; -import org.junit.After; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.slf4j.MDC; @@ -52,7 +53,7 @@ public class ONAPLogAdapterTest { /** * Ensure that MDCs are cleared after each testcase. */ - @After + @AfterEach public void resetMDCs() { MDC.clear(); } @@ -60,10 +61,11 @@ public class ONAPLogAdapterTest { /** * Test nullcheck. */ - @Test(expected = NullPointerException.class) + @Test public void testCheckNotNull() { + assertThrows(NullPointerException.class, () -> - ONAPLogAdapter.checkNotNull(null); + ONAPLogAdapter.checkNotNull(null)); } /** diff --git a/aai-els-onap-logging/src/test/resources/logback.xml b/aai-els-onap-logging/src/test/resources/logback.xml index 7bf5d98f..2925be00 100644 --- a/aai-els-onap-logging/src/test/resources/logback.xml +++ b/aai-els-onap-logging/src/test/resources/logback.xml @@ -27,7 +27,7 @@ <property name="AJSC_HOME" value="${AJSC_HOME:-.}" /> <jmxConfigurator /> <property name="logDirectory" value="${AJSC_HOME}/logs" /> - + <property name="p_tim" value="%d{"yyyy-MM-dd'T'HH:mm:ss.SSSXXX", UTC}"/> <property name="p_lvl" value="%level"/> <property name="p_log" value="%logger"/> @@ -53,7 +53,7 @@ </pattern> </encoder> </appender> - + <appender name="asyncMETRIC" class="ch.qos.logback.classic.AsyncAppender"> <queueSize>1000</queueSize> @@ -123,7 +123,7 @@ <includeCallerData>true</includeCallerData> <appender-ref ref="AUDIT" /> </appender> - + <appender name="auth" class="ch.qos.logback.core.rolling.RollingFileAppender"> <filter class="ch.qos.logback.classic.filter.ThresholdFilter"> @@ -147,17 +147,14 @@ <logger name="ch.qos.logback.classic" level="WARN" /> <logger name="ch.qos.logback.core" level="WARN" /> - + <logger name="com.jayway.jsonpath" level="WARN" /> <logger name="org.apache" level="OFF" /> - + <logger name="org.onap.aai" level="DEBUG" additivity="false"> <appender-ref ref="STDOUT" /> </logger> - <logger name="org.onap.aai.aaf.auth" level="DEBUG" additivity="false"> - <appender-ref ref="asyncAUTH" /> - </logger> <logger name="org.onap.aai.logging.ErrorLogHelper" level="WARN"> <appender-ref ref="asyncERROR"/> </logger> diff --git a/aai-failover/pom.xml b/aai-failover/pom.xml index 240fd071..4b5f1d76 100644 --- a/aai-failover/pom.xml +++ b/aai-failover/pom.xml @@ -5,7 +5,7 @@ <parent> <groupId>org.onap.aai.aai-common</groupId> <artifactId>aai-parent</artifactId> - <version>1.14.6-SNAPSHOT</version> + <version>1.15.2-SNAPSHOT</version> <relativePath>../aai-parent/pom.xml</relativePath> </parent> <modelVersion>4.0.0</modelVersion> diff --git a/aai-failover/src/main/java/org/onap/aai/failover/FailoverMonitor.java b/aai-failover/src/main/java/org/onap/aai/failover/FailoverMonitor.java index 731abe7c..111ac6b2 100644 --- a/aai-failover/src/main/java/org/onap/aai/failover/FailoverMonitor.java +++ b/aai-failover/src/main/java/org/onap/aai/failover/FailoverMonitor.java @@ -24,7 +24,6 @@ import java.io.IOException; import java.io.InputStream; import java.nio.file.Files; import java.nio.file.Path; -import java.nio.file.Paths; import java.util.Properties; import org.springframework.beans.factory.annotation.Value; @@ -42,7 +41,7 @@ public class FailoverMonitor { public boolean shouldRun() throws IOException { - Path failoverPath = Paths.get(failoverPropertiesPath); + Path failoverPath = Path.of(failoverPropertiesPath); if (Files.exists(failoverPath)) { Properties properties = new Properties(); diff --git a/aai-parent/pom.xml b/aai-parent/pom.xml index 717049eb..add636e1 100644 --- a/aai-parent/pom.xml +++ b/aai-parent/pom.xml @@ -27,7 +27,7 @@ limitations under the License. <parent> <groupId>org.onap.aai.aai-common</groupId> <artifactId>aai-common</artifactId> - <version>1.14.6-SNAPSHOT</version> + <version>1.15.2-SNAPSHOT</version> </parent> <artifactId>aai-parent</artifactId> <name>aai-parent</name> @@ -38,41 +38,38 @@ limitations under the License. </modules> <properties> + <maven.compiler.release>11</maven.compiler.release> <!-- update this just prior to release or figure out something with version.properties --> <aai.release.version>${aai.common.version}</aai.release.version> <aai.common.logging.version>1.8.0</aai.common.logging.version> <aai.rest.client.version>1.6.4</aai.rest.client.version> <aai.schema.service.version>1.9.6</aai.schema.service.version> - <aaf.version>2.1.15</aaf.version> <antlr.version>4.11.1</antlr.version> <activemq.version>5.16.1</activemq.version> <commons.beanutils.version>1.9.4</commons.beanutils.version> <commons.cli.version>1.5.0</commons.cli.version> - <commons.compress.version>1.21</commons.compress.version> + <commons.compress.version>1.27.0</commons.compress.version> <commons.configuration.version>1.10</commons.configuration.version> - <commons.io.version>2.11.0</commons.io.version> - <commons.lang3.version>3.9</commons.lang3.version> + <commons.io.version>2.16.1</commons.io.version> + <commons.lang3.version>3.15.0</commons.lang3.version> <commons.net.version>3.8.0</commons.net.version> <commons.text.version>1.10.0</commons.text.version> <docker.fabric.version>0.40.2</docker.fabric.version> <easy.mock.version>5.0.0</easy.mock.version> - <eclipse.persistence.version>2.7.11</eclipse.persistence.version> + <eclipse.persistence.version>2.7.15</eclipse.persistence.version> <eelf.core.version>2.0.0-oss</eelf.core.version> <freemarker.version>2.3.31</freemarker.version> - <google.guava.version>31.1-jre</google.guava.version> - <gremlin.version>3.5.8</gremlin.version> - <janusgraph.version>0.6.4</janusgraph.version> - <groovy.version>2.5.15</groovy.version> + <google.guava.version>33.3.1-jre</google.guava.version> + <gremlin.version>3.7.1</gremlin.version> + <janusgraph.version>1.0.0</janusgraph.version> <gson.version>2.9.1</gson.version> <hamcrest.junit.version>2.0.0.0</hamcrest.junit.version> <hamcrest.core.version>2.2</hamcrest.core.version> <javatuples.version>1.2</javatuples.version> <jaxb.version>2.3.1</jaxb.version> - <old.jaxb.version>2.3.0.1</old.jaxb.version> <jaxrs.version>2.1.1</jaxrs.version> <jcommander.version>1.78</jcommander.version> - <jersey.version>1.19.4</jersey.version> <jnr.ffi.version>2.2.12</jnr.ffi.version> <jolt.version>0.1.7</jolt.version> <jopt.simple.version>5.0.4</jopt.simple.version> @@ -91,14 +88,13 @@ limitations under the License. --> <spring.boot.version>2.5.15</spring.boot.version> <spring.version>5.3.39</spring.version> - <spring.jms.version>5.2.25.RELEASE</spring.jms.version> <spring.test.version>${spring.version}</spring.test.version> <json.path.version>2.2.0</json.path.version> <json.version>20190722</json.version> <junit.version>4.12</junit.version> <httpclient.version>4.5.13</httpclient.version> <io.swagger.version>1.5.24</io.swagger.version> - <logback.version>1.2.7</logback.version> + <logback.version>1.2.13</logback.version> <slf4j.version>1.7.25</slf4j.version> <log4j.version>2.17.1</log4j.version> <mockito.all.version>3.4.0</mockito.all.version> @@ -120,7 +116,7 @@ limitations under the License. <!-- we let things pass by default, set custom level for each child project --> <jacoco.line.coverage.limit>0.00</jacoco.line.coverage.limit> - <jacoco.version>0.8.5</jacoco.version> + <jacoco.version>0.8.12</jacoco.version> <sonar-jacoco-listeners.version>3.2</sonar-jacoco-listeners.version> <sonar.core.codeCoveragePlugin>jacoco</sonar.core.codeCoveragePlugin> <sonar.coverage.jacoco.xmlReportPaths>${project.reporting.outputDirectory}/jacoco-ut/jacoco.xml</sonar.coverage.jacoco.xmlReportPaths> @@ -163,13 +159,6 @@ limitations under the License. <artifactId>spring-security-rsa</artifactId> <version>${spring.security.rsa.version}</version> </dependency> - <dependency> - <groupId>org.springframework</groupId> - <artifactId>spring-jms</artifactId> - <version>5.3.39</version> - </dependency> - - <dependency> <groupId>com.googlecode.json-simple</groupId> @@ -191,12 +180,6 @@ limitations under the License. <dependency> <groupId>org.onap.aai.aai-common</groupId> - <artifactId>aai-aaf-auth</artifactId> - <version>${aai.release.version}</version> - </dependency> - - <dependency> - <groupId>org.onap.aai.aai-common</groupId> <artifactId>aai-els-onap-logging</artifactId> <version>${aai.release.version}</version> </dependency> @@ -274,9 +257,9 @@ limitations under the License. <scope>provided</scope> </dependency> <dependency> - <groupId>javax.annotation</groupId> - <artifactId>javax.annotation-api</artifactId> - <version>${javax.annotation.version}</version> + <groupId>jakarta.annotation</groupId> + <artifactId>jakarta.annotation-api</artifactId> + <version>1.3.5</version> </dependency> <dependency> @@ -296,6 +279,13 @@ limitations under the License. <groupId>org.janusgraph</groupId> <artifactId>janusgraph-core</artifactId> <version>${janusgraph.version}</version> + <exclusions> + <exclusion> + <!-- vulnerable dependency --> + <groupId>com.rabbitmq</groupId> + <artifactId>amqp-client</artifactId> + </exclusion> + </exclusions> </dependency> <dependency> @@ -339,13 +329,6 @@ limitations under the License. </dependency> <dependency> - <groupId>org.codehaus.groovy</groupId> - <artifactId>groovy</artifactId> - <version>${groovy.version}</version> - <classifier>indy</classifier> - </dependency> - - <dependency> <groupId>org.mockito</groupId> <artifactId>mockito-all</artifactId> <version>${mockito.all.version}</version> @@ -387,65 +370,14 @@ limitations under the License. </dependency> <dependency> - <groupId>javax.xml.bind</groupId> - <artifactId>jaxb-api</artifactId> - <version>${jaxb.version}</version> - </dependency> - - <dependency> - <groupId>org.apache.activemq</groupId> - <artifactId>activemq-broker</artifactId> - <version>${activemq.version}</version> - </dependency> - - <dependency> - <groupId>org.apache.activemq</groupId> - <artifactId>activemq-client</artifactId> - <version>${activemq.version}</version> + <groupId>jakarta.xml.bind</groupId> + <artifactId>jakarta.xml.bind-api</artifactId> + <version>2.3.3</version> </dependency> - <dependency> - <groupId>org.apache.activemq</groupId> - <artifactId>activemq-openwire-legacy</artifactId> - <version>${activemq.version}</version> - </dependency> - - <dependency> - <groupId>org.onap.aaf.authz</groupId> - <artifactId>aaf-cadi-core</artifactId> - <version>${aaf.version}</version> - <scope>compile</scope> - </dependency> - <dependency> - <groupId>org.onap.aaf.authz</groupId> - <artifactId>aaf-cadi-aaf</artifactId> - <version>${aaf.version}</version> - <scope>compile</scope> - </dependency> - - <dependency> - <groupId>org.easymock</groupId> - <artifactId>easymock</artifactId> - <version>${easy.mock.version}</version> - <scope>test</scope> - </dependency> - - <dependency> - <groupId>com.sun.xml.bind</groupId> - <artifactId>jaxb-xjc</artifactId> - <version>${old.jaxb.version}</version> - </dependency> - - <dependency> - <groupId>com.sun.xml.bind</groupId> - <artifactId>jaxb-impl</artifactId> - <version>${old.jaxb.version}</version> - </dependency> - - <dependency> - <groupId>com.sun.xml.bind</groupId> - <artifactId>jaxb-core</artifactId> - <version>${old.jaxb.version}</version> + <groupId>org.glassfish.jaxb</groupId> + <artifactId>jaxb-runtime</artifactId> + <version>2.3.9</version> </dependency> <dependency> @@ -496,24 +428,6 @@ limitations under the License. </dependency> <dependency> - <groupId>com.sun.jersey</groupId> - <artifactId>jersey-core</artifactId> - <version>${jersey.version}</version> - </dependency> - - <dependency> - <groupId>com.sun.jersey</groupId> - <artifactId>jersey-client</artifactId> - <version>${jersey.version}</version> - </dependency> - - <dependency> - <groupId>com.sun.jersey</groupId> - <artifactId>jersey-json</artifactId> - <version>${jersey.version}</version> - </dependency> - - <dependency> <groupId>javax.ws.rs</groupId> <artifactId>javax.ws.rs-api</artifactId> <version>${jaxrs.version}</version> diff --git a/aai-rest/pom.xml b/aai-rest/pom.xml index 9af589ff..0c981a50 100644 --- a/aai-rest/pom.xml +++ b/aai-rest/pom.xml @@ -29,7 +29,7 @@ <parent> <groupId>org.onap.aai.aai-common</groupId> <artifactId>aai-parent</artifactId> - <version>1.14.6-SNAPSHOT</version> + <version>1.15.2-SNAPSHOT</version> <relativePath>../aai-parent/pom.xml</relativePath> </parent> <artifactId>aai-rest</artifactId> diff --git a/aai-schema-abstraction/pom.xml b/aai-schema-abstraction/pom.xml index c89cf6eb..140db51c 100644 --- a/aai-schema-abstraction/pom.xml +++ b/aai-schema-abstraction/pom.xml @@ -28,7 +28,7 @@ <parent> <groupId>org.onap.aai.aai-common</groupId> <artifactId>aai-parent</artifactId> - <version>1.14.6-SNAPSHOT</version> + <version>1.15.2-SNAPSHOT</version> <relativePath>../aai-parent/pom.xml</relativePath> </parent> diff --git a/aai-schema-abstraction/src/test/java/org/onap/aai/schemaif/json/JsonSchemaProviderTest.java b/aai-schema-abstraction/src/test/java/org/onap/aai/schemaif/json/JsonSchemaProviderTest.java index 9011dfa2..a4c7546d 100644 --- a/aai-schema-abstraction/src/test/java/org/onap/aai/schemaif/json/JsonSchemaProviderTest.java +++ b/aai-schema-abstraction/src/test/java/org/onap/aai/schemaif/json/JsonSchemaProviderTest.java @@ -33,7 +33,7 @@ import java.io.IOException; import java.io.PrintWriter; import java.io.StringWriter; import java.nio.file.Files; -import java.nio.file.Paths; +import java.nio.file.Path; import java.util.List; import java.util.Set; import java.util.zip.ZipEntry; @@ -74,7 +74,7 @@ public class JsonSchemaProviderTest { ByteArrayOutputStream fos = new ByteArrayOutputStream(); ZipOutputStream zos = new ZipOutputStream(fos); zos.putNextEntry(new ZipEntry("schemaServiceResponse.json")); - byte[] fileData = Files.readAllBytes(Paths.get("src/test/resources/json/schemaServiceResponse.json")); + byte[] fileData = Files.readAllBytes(Path.of("src/test/resources/json/schemaServiceResponse.json")); zos.write(fileData, 0, fileData.length); zos.closeEntry(); zos.close(); @@ -591,7 +591,7 @@ public class JsonSchemaProviderTest { } static String readFile(String path) throws IOException { - byte[] encoded = Files.readAllBytes(Paths.get(path)); + byte[] encoded = Files.readAllBytes(Path.of(path)); return new String(encoded); } } diff --git a/aai-schema-abstraction/src/test/java/org/onap/aai/schemaif/oxm/OxmSchemaServiceSetup.java b/aai-schema-abstraction/src/test/java/org/onap/aai/schemaif/oxm/OxmSchemaServiceSetup.java index e7055a3f..08cf880e 100644 --- a/aai-schema-abstraction/src/test/java/org/onap/aai/schemaif/oxm/OxmSchemaServiceSetup.java +++ b/aai-schema-abstraction/src/test/java/org/onap/aai/schemaif/oxm/OxmSchemaServiceSetup.java @@ -31,7 +31,7 @@ import org.junit.Before; import org.junit.runner.RunWith; import org.mockito.Mock; import org.mockito.Mockito; -import org.mockito.runners.MockitoJUnitRunner; +import org.mockito.junit.MockitoJUnitRunner; import org.onap.aai.edges.EdgeIngestor; import org.onap.aai.nodes.NodeIngestor; import org.onap.aai.setup.AAIConfigTranslator; diff --git a/aai-schema-ingest/pom.xml b/aai-schema-ingest/pom.xml index 56305a9a..cf908b19 100644 --- a/aai-schema-ingest/pom.xml +++ b/aai-schema-ingest/pom.xml @@ -26,7 +26,7 @@ limitations under the License. <parent> <groupId>org.onap.aai.aai-common</groupId> <artifactId>aai-parent</artifactId> - <version>1.14.6-SNAPSHOT</version> + <version>1.15.2-SNAPSHOT</version> <relativePath>../aai-parent/pom.xml</relativePath> </parent> <artifactId>aai-schema-ingest</artifactId> @@ -35,7 +35,6 @@ limitations under the License. <properties> <httpclient.version>4.5.13</httpclient.version> - <groovy.version>2.5.15</groovy.version> <springframework.version>4.3.24.RELEASE</springframework.version> </properties> <build> @@ -67,12 +66,6 @@ limitations under the License. <artifactId>guava</artifactId> </dependency> <dependency> - <groupId>org.codehaus.groovy</groupId> - <artifactId>groovy</artifactId> - <version>${groovy.version}</version> - <classifier>indy</classifier> - </dependency> - <dependency> <groupId>commons-io</groupId> <artifactId>commons-io</artifactId> </dependency> diff --git a/aai-schema-ingest/src/main/java/org/onap/aai/setup/AAIConfigTranslator.java b/aai-schema-ingest/src/main/java/org/onap/aai/setup/AAIConfigTranslator.java index 66ffcf88..ca5eed39 100644 --- a/aai-schema-ingest/src/main/java/org/onap/aai/setup/AAIConfigTranslator.java +++ b/aai-schema-ingest/src/main/java/org/onap/aai/setup/AAIConfigTranslator.java @@ -48,7 +48,7 @@ public class AAIConfigTranslator extends ConfigTranslator { /* * (non-Javadoc) - * + * * @see org.onap.aai.setup.ConfigTranslator#getNodeFiles() */ @Override @@ -70,7 +70,7 @@ public class AAIConfigTranslator extends ConfigTranslator { /* * (non-Javadoc) - * + * * @see org.onap.aai.setup.ConfigTranslator#getEdgeFiles() */ @Override @@ -94,9 +94,13 @@ public class AAIConfigTranslator extends ConfigTranslator { private List<String> getVersionFiles(String startDirectory, SchemaVersion schemaVersion, Supplier<Stream<String>> inclusionPattern, Supplier<Stream<String>> exclusionPattern) { - final File versionDirectory = new File(startDirectory + "/" + schemaVersion.toString()); - final List<String> container = Arrays.stream(versionDirectory.listFiles()) - .filter(Objects::nonNull) + final File versionDirectory = new File(startDirectory + "/" + schemaVersion.toString()); + File[] versionFiles = versionDirectory.listFiles(); + if(versionFiles == null) { + throw new RuntimeException("No files found in directory: " + versionDirectory.getAbsolutePath()); + } + final List<String> container = Arrays.stream(versionFiles) + .filter(Objects::nonNull) .map(File::getName) .filter(versionFileName -> inclusionPattern .get() diff --git a/aai-schema-ingest/src/test/java/org/onap/aai/nodes/NodeIngestorLocalTest.java b/aai-schema-ingest/src/test/java/org/onap/aai/nodes/NodeIngestorLocalTest.java index 6e00eb73..f26e603a 100644 --- a/aai-schema-ingest/src/test/java/org/onap/aai/nodes/NodeIngestorLocalTest.java +++ b/aai-schema-ingest/src/test/java/org/onap/aai/nodes/NodeIngestorLocalTest.java @@ -30,7 +30,7 @@ import java.io.IOException; import java.io.OutputStream; import java.io.OutputStreamWriter; import java.nio.file.Files; -import java.nio.file.Paths; +import java.nio.file.Path; import javax.xml.bind.SchemaOutputResolver; import javax.xml.transform.OutputKeys; @@ -152,7 +152,7 @@ public class NodeIngestorLocalTest { ctx13.generateSchema(outputResolver13); ByteArrayOutputStream buffer = new ByteArrayOutputStream(); printDocument(nodeIngestor.getSchema(new SchemaVersion("v13")), buffer); - String content = new String(Files.readAllBytes(Paths.get("src/test/resources/forWiringTests/aai_oxm_v13.xml"))); + String content = new String(Files.readAllBytes(Path.of("src/test/resources/forWiringTests/aai_oxm_v13.xml"))); content = content.replaceAll("\\s+", ""); String expected = buffer.toString().replaceAll("\\s+", ""); diff --git a/aai-schema-ingest/src/test/java/org/onap/aai/nodes/NodeIngestorTest.java b/aai-schema-ingest/src/test/java/org/onap/aai/nodes/NodeIngestorTest.java index fff22116..053004bd 100644 --- a/aai-schema-ingest/src/test/java/org/onap/aai/nodes/NodeIngestorTest.java +++ b/aai-schema-ingest/src/test/java/org/onap/aai/nodes/NodeIngestorTest.java @@ -30,7 +30,7 @@ import java.io.IOException; import java.io.OutputStream; import java.io.OutputStreamWriter; import java.nio.file.Files; -import java.nio.file.Paths; +import java.nio.file.Path; import javax.xml.bind.SchemaOutputResolver; import javax.xml.transform.OutputKeys; @@ -145,7 +145,7 @@ public class NodeIngestorTest { ctx13.generateSchema(outputResolver13); ByteArrayOutputStream buffer = new ByteArrayOutputStream(); printDocument(nodeIngestor.getSchema(new SchemaVersion("v13")), buffer); - String content = new String(Files.readAllBytes(Paths.get("src/test/resources/forWiringTests/aai_oxm_v13.xml"))); + String content = new String(Files.readAllBytes(Path.of("src/test/resources/forWiringTests/aai_oxm_v13.xml"))); content = content.replaceAll("\\s+", ""); String expected = buffer.toString().replaceAll("\\s+", ""); diff --git a/aai-utils/pom.xml b/aai-utils/pom.xml index af541a21..f5bc33f6 100644 --- a/aai-utils/pom.xml +++ b/aai-utils/pom.xml @@ -27,7 +27,7 @@ <parent> <groupId>org.onap.aai.aai-common</groupId> <artifactId>aai-parent</artifactId> - <version>1.14.6-SNAPSHOT</version> + <version>1.15.2-SNAPSHOT</version> <relativePath>../aai-parent/pom.xml</relativePath> </parent> <artifactId>aai-utils</artifactId> @@ -35,7 +35,6 @@ <properties> <onap.nexus.url>https://nexus.onap.org</onap.nexus.url> - <logback.version>1.2.3</logback.version> </properties> <dependencies> @@ -63,8 +62,8 @@ <artifactId>eclipselink</artifactId> </dependency> <dependency> - <groupId>javax.xml.bind</groupId> - <artifactId>jaxb-api</artifactId> + <groupId>jakarta.xml.bind</groupId> + <artifactId>jakarta.xml.bind-api</artifactId> </dependency> <!-- Common logging framework --> <dependency> @@ -77,6 +76,11 @@ <artifactId>spring-core</artifactId> </dependency> <dependency> + <groupId>org.glassfish.jaxb</groupId> + <artifactId>jaxb-runtime</artifactId> + <scope>runtime</scope> + </dependency> + <dependency> <groupId>com.fasterxml.jackson.core</groupId> <artifactId>jackson-core</artifactId> </dependency> diff --git a/docs/platform/offerapis.html b/docs/platform/offerapis.html index 77f5ab2b..bc6c1fba 100644 --- a/docs/platform/offerapis.html +++ b/docs/platform/offerapis.html @@ -380,12 +380,12 @@ ul.auto-toc { <tr><td>html doc</td> <td>yaml doc</td> </tr> -<tr><td><p class="first"><a href="#id1"><span class="problematic" id="id2">:download:`link <https://wiki.onap.org/download/attachments/41421924/aai_swagger_v14.html?api=v2>`</span></a></p> +<tr><td><p class="first"><a href="#id1"><span class="problematic" id="id2">:download:`link <https://lf-onap.atlassian.net/wiki/download/attachments/16506145/aai_swagger_v29.html?api=v2>`</span></a></p> <div class="last system-message" id="id1"> <p class="system-message-title">System Message: ERROR/3 (<tt class="docutils">offeredapis.rst</tt>, line 20); <em><a href="#id2">backlink</a></em></p> Unknown interpreted text role "download".</div> </td> -<td><p class="first"><a href="#id3"><span class="problematic" id="id4">:download:`link <https://wiki.onap.org/download/attachments/41421924/aai_swagger_v14.yaml?api=v2>`</span></a></p> +<td><p class="first"><a href="#id3"><span class="problematic" id="id4">:download:`link <https://lf-onap.atlassian.net/wiki/download/attachments/16506145/aai_swagger_v29.yaml?api=v2>`</span></a></p> <div class="last system-message" id="id3"> <p class="system-message-title">System Message: ERROR/3 (<tt class="docutils">offeredapis.rst</tt>, line 20); <em><a href="#id4">backlink</a></em></p> Unknown interpreted text role "download".</div> diff --git a/docs/platform/offeredapis.rst b/docs/platform/offeredapis.rst index 649abac0..e6dbfd54 100644 --- a/docs/platform/offeredapis.rst +++ b/docs/platform/offeredapis.rst @@ -19,6 +19,4 @@ The list of APIs that AAI offers could be found in the following table: :widths: 60,60 "html doc", "yaml doc" - ":download:`link <https://wiki.onap.org/download/attachments/103422039/aai_swagger_v24.html?api=v2>`", ":download:`link <https://wiki.onap.org/download/attachments/103422039/aai_swagger_v24.yaml?api=v2>`" - - + ":download:`link <https://lf-onap.atlassian.net/wiki/download/attachments/16506145/aai_swagger_v29.html?api=v2>`", ":download:`link <https://lf-onap.atlassian.net/wiki/download/attachments/16506145/aai_swagger_v29.yaml?api=v2>`" diff --git a/docs/release-notes.rst b/docs/release-notes.rst index 980b7316..dc7bf740 100644 --- a/docs/release-notes.rst +++ b/docs/release-notes.rst @@ -182,7 +182,7 @@ References Quick links: -- `AAI project page <https://wiki.onap.org/display/DW/Active+and+Available+Inventory+Project>`_ +- `AAI project page <https://lf-onap.atlassian.net/wiki/spaces/DW/pages/16230663/Active+and+Available+Inventory+Project>`_ - `Passing Badge information for AAI <https://bestpractices.coreinfrastructure.org/en/projects/1591>`_ For more information on the ONAP Honolulu release, please see: @@ -193,7 +193,7 @@ For more information on the ONAP Honolulu release, please see: #. `ONAP Wiki Page`_ .. _`ONAP Home Page`: https://www.onap.org -.. _`ONAP Wiki Page`: https://wiki.onap.org +.. _`ONAP Wiki Page`: https://lf-onap.atlassian.net .. _`ONAP Documentation`: https://docs.onap.org .. _`ONAP Release Downloads`: https://git.onap.org @@ -266,7 +266,7 @@ Honolulu References Quick links: -- `AAI project page <https://wiki.onap.org/display/DW/Active+and+Available+Inventory+Project>`_ +- `AAI project page <https://lf-onap.atlassian.net/wiki/spaces/DW/pages/16230663/Active+and+Available+Inventory+Project>`_ - `Passing Badge information for AAI <https://bestpractices.coreinfrastructure.org/en/projects/1591>`_ For more information on the ONAP Honolulu release, please see: @@ -277,7 +277,7 @@ For more information on the ONAP Honolulu release, please see: #. `ONAP Wiki Page`_ .. _`ONAP Home Page`: https://www.onap.org -.. _`ONAP Wiki Page`: https://wiki.onap.org +.. _`ONAP Wiki Page`: https://lf-onap.atlassian.net .. _`ONAP Documentation`: https://docs.onap.org .. _`ONAP Release Downloads`: https://git.onap.org @@ -321,7 +321,7 @@ Istanbul References Quick links: -- `AAI project page <https://wiki.onap.org/display/DW/Active+and+Available+Inventory+Project>`_ +- `AAI project page <https://lf-onap.atlassian.net/wiki/spaces/DW/pages/16230663/Active+and+Available+Inventory+Project>`_ - `Passing Badge information for AAI <https://bestpractices.coreinfrastructure.org/en/projects/1591>`_ For more information on the ONAP Honolulu release, please see: @@ -332,7 +332,7 @@ For more information on the ONAP Honolulu release, please see: #. `ONAP Wiki Page`_ .. _`ONAP Home Page`: https://www.onap.org -.. _`ONAP Wiki Page`: https://wiki.onap.org +.. _`ONAP Wiki Page`: https://lf-onap.atlassian.net .. _`ONAP Documentation`: https://docs.onap.org .. _`ONAP Release Downloads`: https://git.onap.org @@ -383,7 +383,7 @@ Guilin Known Limitations, Issues, and Workarounds Known Issues ------------ -* `AAI-3219 <https://jira.onap.org/browse/AAI-3219>`_ - AAI-EVENT notifications failed to be published to DMaap +* `AAI-3219 <https://lf-onap.atlassian.net/browse/AAI-3219>`_ - AAI-EVENT notifications failed to be published to DMaap Workarounds ----------- @@ -409,7 +409,7 @@ Guilin References Quick links: -- `AAI project page <https://wiki.onap.org/display/DW/Active+and+Available+Inventory+Project>`_ +- `AAI project page <https://lf-onap.atlassian.net/wiki/spaces/DW/pages/16230663/Active+and+Available+Inventory+Project>`_ - `Passing Badge information for AAI <https://bestpractices.coreinfrastructure.org/en/projects/1591>`_ For more information on the ONAP Guilin release, please see: @@ -420,7 +420,7 @@ For more information on the ONAP Guilin release, please see: #. `ONAP Wiki Page`_ .. _`ONAP Home Page`: https://www.onap.org -.. _`ONAP Wiki Page`: https://wiki.onap.org +.. _`ONAP Wiki Page`: https://lf-onap.atlassian.net .. _`ONAP Documentation`: https://docs.onap.org .. _`ONAP Release Downloads`: https://git.onap.org @@ -453,8 +453,8 @@ Frankfurt Known Limitations, Issues, and Workarounds Known Issues ------------ -* `AAI-2766 <https://jira.onap.org/browse/AAI-2766>`_ - AAI data-router cannot communicate with DMaaP message router service -* `AAI-2905 <https://jira.onap.org/browse/AAI-2905>`_ - AAI sparky cannot communicate with portal due to certificate issue, might be related to https://jira.onap.org/browse/PORTAL-875 +* `AAI-2766 <https://lf-onap.atlassian.net/browse/AAI-2766>`_ - AAI data-router cannot communicate with DMaaP message router service +* `AAI-2905 <https://lf-onap.atlassian.net/browse/AAI-2905>`_ - AAI sparky cannot communicate with portal due to certificate issue, might be related to https://lf-onap.atlassian.net/browse/PORTAL-875 The AAI sub-project External System Registry (ESR) is re-using elalto containers. The integration team has helped ESR to meet security requirements for Frankfurt, and the AAI is grateful for the contribution. @@ -470,7 +470,7 @@ Frankfurt References Quick links: -- `AAI project page <https://wiki.onap.org/display/DW/Active+and+Available+Inventory+Project>`_ +- `AAI project page <https://lf-onap.atlassian.net/wiki/spaces/DW/pages/16230663/Active+and+Available+Inventory+Project>`_ - `Passing Badge information for AAI <https://bestpractices.coreinfrastructure.org/en/projects/1591>`_ For more information on the ONAP Frankfurt release, please see: @@ -481,7 +481,7 @@ For more information on the ONAP Frankfurt release, please see: #. `ONAP Wiki Page`_ .. _`ONAP Home Page`: https://www.onap.org -.. _`ONAP Wiki Page`: https://wiki.onap.org +.. _`ONAP Wiki Page`: https://lf-onap.atlassian.net .. _`ONAP Documentation`: https://docs.onap.org .. _`ONAP Release Downloads`: https://git.onap.org @@ -561,24 +561,22 @@ inside the AAI resources pod. curl -v -k -u "$CRED" -H "Content-Type: application/UserRoleRequest+json" $URL/authz/userRole -d '{ "user":"demo@people.osaaf.org", "role":"org.onap.aai.aaiui" }' Frankfurt will include the role and role assignment in the -default bootstrap data (being tracked under `AAI-2475 <https://jira.onap.org/browse/AAI-2475>`__) +default bootstrap data (being tracked under `AAI-2475 <https://lf-onap.atlassian.net/browse/AAI-2475>`__) -- `AAI-2606 <https://jira.onap.org/browse/AAI-2606>`_ Schema-service entity description is not available +- `AAI-2606 <https://lf-onap.atlassian.net/browse/AAI-2606>`_ Schema-service entity description is not available -- `AAI-2457 <https://jira.onap.org/browse/AAI-2457>`_ Inconsistent error messages when getting AAI resources +- `AAI-2457 <https://lf-onap.atlassian.net/browse/AAI-2457>`_ Inconsistent error messages when getting AAI resources -- `AAI-2457 <https://jira.onap.org/browse/AAI-2457>`_ Inconsistent error messages when getting AAI resources +- `AAI-2457 <https://lf-onap.atlassian.net/browse/AAI-2457>`_ Inconsistent error messages when getting AAI resources -- `AAI-2092 <https://jira.onap.org/browse/AAI-2092>`_ aai-resources does excessive amounts of logging +- `AAI-2092 <https://lf-onap.atlassian.net/browse/AAI-2092>`_ aai-resources does excessive amounts of logging -- `AAI-2082 <https://jira.onap.org/browse/AAI-2082>`_ aai-resources gives incorrect output when aai-cassandra has shutdown with failure +- `AAI-2082 <https://lf-onap.atlassian.net/browse/AAI-2082>`_ aai-resources gives incorrect output when aai-cassandra has shutdown with failure Quick Links: -- `Active and Available Inventory project page <https://wiki.onap.org/display/DW/Active+and+Available+Inventory+Project>`_ +- `Active and Available Inventory project page <https://lf-onap.atlassian.net/wiki/spaces/DW/pages/16230663/Active+and+Available+Inventory+Project>`_ - `R5 Passing Badge information for AAI <https://bestpractices.coreinfrastructure.org/en/projects/1591>`_ -- `R5 Project Vulnerability Review Table for AAI <https://wiki.onap.org/pages/viewpage.action?pageId=64003431>`_ - Version: 1.4.0 -------------- @@ -605,7 +603,7 @@ re-building key microservices. AAI delivered 55%+ test coverage on all Java-based repos. -See `AAI-1779 <https://jira.onap.org/browse/AAI-1779>`__ for details +See `AAI-1779 <https://lf-onap.atlassian.net/browse/AAI-1779>`__ for details on the schema updates in R4. Some AAI services can be configured to leverage the ONAP Pluggable @@ -635,26 +633,26 @@ inside the AAI resources pod. curl -v -k -u "$CRED" -H "Content-Type: application/UserRoleRequest+json" $URL/authz/userRole -d '{ "user":"demo@people.osaaf.org", "role":"org.onap.aai.aaiui" }' Future releases will include the role and role assignment in the -default bootstrap data (being tracked under `AAI-2475 <https://jira.onap.org/browse/AAI-2475>`__) +default bootstrap data (being tracked under `AAI-2475 <https://lf-onap.atlassian.net/browse/AAI-2475>`__) **Security Notes** *Fixed Security Issues* -- `OJSI-114 <https://jira.onap.org/browse/OJSI-114>`_ In default deployment AAI (aai) exposes HTTP port 30232 outside of cluster. +- `OJSI-114 <https://lf-onap.atlassian.net/browse/OJSI-114>`_ In default deployment AAI (aai) exposes HTTP port 30232 outside of cluster. *Known Security Issues* *Known Vulnerabilities in Used Modules* -AAI code has been formally scanned during build time using NexusIQ and all Critical vulnerabilities have been addressed, items that remain open have been assessed for risk and determined to be false positive. The AAI open Critical security vulnerabilities and their risk assessment have been documented as part of the `R4 project wiki <https://wiki.onap.org/pages/viewpage.action?pageId=64003431>`_. +AAI code has been formally scanned during build time using NexusIQ and all Critical vulnerabilities have been addressed, items that remain open have been assessed for risk and determined to be false positive. The AAI open Critical security vulnerabilities and their risk assessment have been documented as part of the `R4 project wiki <https://lf-onap.atlassian.net/wiki/spaces/DW/pages/16335975/AAI+R4+Release+Planning>`_. Quick Links: -- `AAI project page <https://wiki.onap.org/display/DW/Active+and+Available+Inventory+Project>`_ +- `AAI project page <https://lf-onap.atlassian.net/wiki/spaces/DW/pages/16230663/Active+and+Available+Inventory+Project>`_ - `Passing Badge information for AAI <https://bestpractices.coreinfrastructure.org/en/projects/1591>`_ -- `R4 Project Vulnerability Review Table for AAI <https://wiki.onap.org/pages/viewpage.action?pageId=64003431>`_ +- `R4 Project Vulnerability Review Table for AAI <https://lf-onap.atlassian.net/wiki/spaces/DW/pages/16335975/AAI+R4+Release+Planning>`_ @@ -668,7 +666,7 @@ Version: 1.3.2 AAI demo certificates were going to expire before Dublin release, so they've been refreshed to last until 2020. -- `AAI-2282 <https://jira.onap.org/browse/AAI-2282>`_ Update certifcate for Casablanca 3.0.2 +- `AAI-2282 <https://lf-onap.atlassian.net/browse/AAI-2282>`_ Update certifcate for Casablanca 3.0.2 Version: 1.3.1 -------------- @@ -681,28 +679,28 @@ The Casablanca Maintenance Release provides a number of security and bug fixes. Highlights of the issues corrected in the Casablanca Maintenance Release: -- `AAI-2047 <https://jira.onap.org/browse/AAI-2047>`_ Make success of createDbSchema job required to proceed in AAI startup +- `AAI-2047 <https://lf-onap.atlassian.net/browse/AAI-2047>`_ Make success of createDbSchema job required to proceed in AAI startup -- `AAI-1923 <https://jira.onap.org/browse/AAI-1923>`_ Problem deleting due to EdgeRules in CCVPN usecase Casablanca +- `AAI-1923 <https://lf-onap.atlassian.net/browse/AAI-1923>`_ Problem deleting due to EdgeRules in CCVPN usecase Casablanca -- `AAI-1776 <https://jira.onap.org/browse/AAI-1776>`_ Champ fails to start +- `AAI-1776 <https://lf-onap.atlassian.net/browse/AAI-1776>`_ Champ fails to start -- `AAI-1958 <https://jira.onap.org/browse/AAI-1958>`_ [graphadmin] createDbSchema.sh job loses detailed logfile +- `AAI-1958 <https://lf-onap.atlassian.net/browse/AAI-1958>`_ [graphadmin] createDbSchema.sh job loses detailed logfile -- `AAI-1973 <https://jira.onap.org/browse/AAI-1973>`_ Schema update wiki is out of data of Casablanca +- `AAI-1973 <https://lf-onap.atlassian.net/browse/AAI-1973>`_ Schema update wiki is out of data of Casablanca -- `AAI-2058 <https://jira.onap.org/browse/AAI-2058>`_ Upgrade to latest jetty-security +- `AAI-2058 <https://lf-onap.atlassian.net/browse/AAI-2058>`_ Upgrade to latest jetty-security -- `AAI-2076 <https://jira.onap.org/browse/AAI-2076>`_ A&AI healthcheck timeout +- `AAI-2076 <https://lf-onap.atlassian.net/browse/AAI-2076>`_ A&AI healthcheck timeout -- `AAI-2079 <https://jira.onap.org/browse/AAI-2079>`_ aai-traversal and aai container failure to deploy issues in casablanca 3.0.0-ONAP +- `AAI-2079 <https://lf-onap.atlassian.net/browse/AAI-2079>`_ aai-traversal and aai container failure to deploy issues in casablanca 3.0.0-ONAP Dependencies were updated in multiple repos to patch security vulnerabilities. **Known Issues** -- `AAI-2090 <https://jira.onap.org/browse/AAI-2090>`_ aai-data-router pod enters CrashLoopBackOff state +- `AAI-2090 <https://lf-onap.atlassian.net/browse/AAI-2090>`_ aai-data-router pod enters CrashLoopBackOff state This issue can still present itself if you use the OOM chart which references version 1.3.2 (which is the version specified in the @@ -711,7 +709,7 @@ is to set 1.3.3 in the values.yaml file for data-router, or use the docker-manifest to override. File is oom/kubernetes/aai/charts/aai-data-router/values.yaml Users should pay special attention to `AAI-2064 -<https://jira.onap.org/browse/AAI-2064>`_ and should consult `this +<https://lf-onap.atlassian.net/browse/AAI-2064>`_ and should consult `this page <https://www.rabbitmq.com/ssl.html>`_ for instructions on how to properly secure it if they are concerned about the issue. @@ -722,12 +720,12 @@ all Critical vulnerabilities have been addressed, items that remain open have been assessed for risk and determined to be false positive. The AAI open Critical security vulnerabilities and their risk assessment have been documented as part of the `R3 project wiki -<https://wiki.onap.org/pages/viewpage.action?pageId=45307817>`_. +<https://lf-onap.atlassian.net/wiki/spaces/DW/pages/16296535/AAI+R3+Release+Planning>`_. Quick Links: -- `AAI main project page <https://wiki.onap.org/display/DW/Active+and+Available+Inventory+Project>`_ -- `CMR Vulnerability Review Table for AAI <https://wiki.onap.org/pages/viewpage.action?pageId=45307817>`_ +- `AAI main project page <https://lf-onap.atlassian.net/wiki/spaces/DW/pages/16230663/Active+and+Available+Inventory+Project>`_ +- `CMR Vulnerability Review Table for AAI <https://lf-onap.atlassian.net/wiki/spaces/DW/pages/16309541/AAI+R3+Security+Vulnerability+Threat+Analysis>`_ Version: 1.3.0 @@ -780,17 +778,17 @@ Added support for VLAN tagging. **Known Issues** -Please find at this link the list of issues that will be fixed in the `Casablanca Maintenance Release <https://jira.onap.org/issues/?jql=fixVersion%20%3D%20%22Casablanca%20Maintenance%20Release%22%20and%20type%20%3D%20Bug%20and%20project%20%3D%20%22Active%20and%20Available%20Inventory%22>`_ +Please find at this link the list of issues that will be fixed in the `Casablanca Maintenance Release <https://lf-onap.atlassian.net/issues/?jql=fixVersion%20%3D%20%22Casablanca%20Maintenance%20Release%22%20and%20type%20%3D%20Bug%20and%20project%20%3D%20%22Active%20and%20Available%20Inventory%22>`_ **Security Notes** -AAI code has been formally scanned during build time using NexusIQ and all Critical vulnerabilities have been addressed, items that remain open have been assessed for risk and determined to be false positive. The AAI open Critical security vulnerabilities and their risk assessment have been documented as part of the `R2 project wiki <https://wiki.onap.org/pages/viewpage.action?pageId=45307817>`_. +AAI code has been formally scanned during build time using NexusIQ and all Critical vulnerabilities have been addressed, items that remain open have been assessed for risk and determined to be false positive. The AAI open Critical security vulnerabilities and their risk assessment have been documented as part of the `R2 project wiki <https://lf-onap.atlassian.net/wiki/spaces/DW/pages/16258007/AAI+R2+Release+Planning>`_. Quick Links: -- `AAI project page <https://wiki.onap.org/display/DW/Active+and+Available+Inventory+Project>`_ +- `AAI project page <https://lf-onap.atlassian.net/wiki/spaces/DW/pages/16230663/Active+and+Available+Inventory+Project>`_ - `Passing Badge information for AAI <https://bestpractices.coreinfrastructure.org/en/projects/1591>`_ -- `R3 Project Vulnerability Review Table for AAI <https://wiki.onap.org/pages/viewpage.action?pageId=45307817>`_ +- `R3 Project Vulnerability Review Table for AAI <https://lf-onap.atlassian.net/wiki/spaces/DW/pages/16309541/AAI+R3+Security+Vulnerability+Threat+Analysis>`_ Version: 1.2.0 @@ -852,221 +850,221 @@ Source code of AAI is released under the following repositories at https://gerri **Epic** -- `AAI-16 <https://jira.onap.org/browse/AAI-16>`_ A&AI Platform Deployment +- `AAI-16 <https://lf-onap.atlassian.net/browse/AAI-16>`_ A&AI Platform Deployment -- `AAI-17 <https://jira.onap.org/browse/AAI-17>`_ Seed code stabilization +- `AAI-17 <https://lf-onap.atlassian.net/browse/AAI-17>`_ Seed code stabilization -- `AAI-21 <https://jira.onap.org/browse/AAI-21>`_ Gizmo +- `AAI-21 <https://lf-onap.atlassian.net/browse/AAI-21>`_ Gizmo -- `AAI-24 <https://jira.onap.org/browse/AAI-24>`_ Move to Active Open Source Graph Database +- `AAI-24 <https://lf-onap.atlassian.net/browse/AAI-24>`_ Move to Active Open Source Graph Database -- `AAI-38 <https://jira.onap.org/browse/AAI-38>`_ AAI Microservice to generate AAI model XML +- `AAI-38 <https://lf-onap.atlassian.net/browse/AAI-38>`_ AAI Microservice to generate AAI model XML -- `AAI-280 <https://jira.onap.org/browse/AAI-280>`_ This epic groups together the various requests for making AAI more configurable +- `AAI-280 <https://lf-onap.atlassian.net/browse/AAI-280>`_ This epic groups together the various requests for making AAI more configurable -- `AAI-466 <https://jira.onap.org/browse/AAI-466>`_ Beijing R2 AAI Schema Updates +- `AAI-466 <https://lf-onap.atlassian.net/browse/AAI-466>`_ Beijing R2 AAI Schema Updates -- `AAI-680 <https://jira.onap.org/browse/AAI-680>`_ HPA Use Case Support in AAI +- `AAI-680 <https://lf-onap.atlassian.net/browse/AAI-680>`_ HPA Use Case Support in AAI -- `AAI-681 <https://jira.onap.org/browse/AAI-681>`_ Change Management Use Case Support in AAI +- `AAI-681 <https://lf-onap.atlassian.net/browse/AAI-681>`_ Change Management Use Case Support in AAI -- `AAI-682 <https://jira.onap.org/browse/AAI-682>`_ Scale Out Use Case Support in AAI +- `AAI-682 <https://lf-onap.atlassian.net/browse/AAI-682>`_ Scale Out Use Case Support in AAI -- `AAI-769 <https://jira.onap.org/browse/AAI-769>`_ Required updates to the v13 REST API +- `AAI-769 <https://lf-onap.atlassian.net/browse/AAI-769>`_ Required updates to the v13 REST API **Bug Fixes** -- `AAI-129 <https://jira.onap.org/browse/AAI-129>`_ RestClientBuilder SSL protocol should be configurable +- `AAI-129 <https://lf-onap.atlassian.net/browse/AAI-129>`_ RestClientBuilder SSL protocol should be configurable -- `AAI-131 <https://jira.onap.org/browse/AAI-131>`_ Model-Loader service of A&AI has it's Log Provider Configuration File sealed inside the WAR +- `AAI-131 <https://lf-onap.atlassian.net/browse/AAI-131>`_ Model-Loader service of A&AI has it's Log Provider Configuration File sealed inside the WAR -- `AAI-175 <https://jira.onap.org/browse/AAI-175>`_ aai core service of A&AI has it's Log Provider Configuration File configurable from startup.sh +- `AAI-175 <https://lf-onap.atlassian.net/browse/AAI-175>`_ aai core service of A&AI has it's Log Provider Configuration File configurable from startup.sh -- `AAI-295 <https://jira.onap.org/browse/AAI-295>`_ ChampDAO tests failing in gizmo +- `AAI-295 <https://lf-onap.atlassian.net/browse/AAI-295>`_ ChampDAO tests failing in gizmo -- `AAI-460 <https://jira.onap.org/browse/AAI-460>`_ vm1-aai-inst1 aai-resources fails to start +- `AAI-460 <https://lf-onap.atlassian.net/browse/AAI-460>`_ vm1-aai-inst1 aai-resources fails to start -- `AAI-463 <https://jira.onap.org/browse/AAI-463>`_ Wrong Error message when we use PUT instead of POST to create the relationship +- `AAI-463 <https://lf-onap.atlassian.net/browse/AAI-463>`_ Wrong Error message when we use PUT instead of POST to create the relationship -- `AAI-521 <https://jira.onap.org/browse/AAI-521>`_ A&AI resources container sporadically hangs on startup +- `AAI-521 <https://lf-onap.atlassian.net/browse/AAI-521>`_ A&AI resources container sporadically hangs on startup -- `AAI-523 <https://jira.onap.org/browse/AAI-523>`_ Sparky UI does not display RelationshipList nodes +- `AAI-523 <https://lf-onap.atlassian.net/browse/AAI-523>`_ Sparky UI does not display RelationshipList nodes -- `AAI-558 <https://jira.onap.org/browse/AAI-558>`_ aai-resources java daily jenkins job is failing +- `AAI-558 <https://lf-onap.atlassian.net/browse/AAI-558>`_ aai-resources java daily jenkins job is failing -- `AAI-559 <https://jira.onap.org/browse/AAI-559>`_ CSIT jobs should use a set of streams, not a list of branches +- `AAI-559 <https://lf-onap.atlassian.net/browse/AAI-559>`_ CSIT jobs should use a set of streams, not a list of branches -- `AAI-561 <https://jira.onap.org/browse/AAI-561>`_ aai-traversal java daily jenkins job is failing +- `AAI-561 <https://lf-onap.atlassian.net/browse/AAI-561>`_ aai-traversal java daily jenkins job is failing -- `AAI-568 <https://jira.onap.org/browse/AAI-568>`_ aai/logging-api build fails on license.txt not found when run outside of aai/logging-service dir - for root CI builds +- `AAI-568 <https://lf-onap.atlassian.net/browse/AAI-568>`_ aai/logging-api build fails on license.txt not found when run outside of aai/logging-service dir - for root CI builds -- `AAI-601 <https://jira.onap.org/browse/AAI-601>`_ AAI search-data-service build failing on 1.1 JAX-RS instead of required 2.0 library only on clean Ubuntu 16.04/JDK1.8.0_151 +- `AAI-601 <https://lf-onap.atlassian.net/browse/AAI-601>`_ AAI search-data-service build failing on 1.1 JAX-RS instead of required 2.0 library only on clean Ubuntu 16.04/JDK1.8.0_151 -- `AAI-603 <https://jira.onap.org/browse/AAI-603>`_ Sonar only push to master +- `AAI-603 <https://lf-onap.atlassian.net/browse/AAI-603>`_ Sonar only push to master -- `AAI-666 <https://jira.onap.org/browse/AAI-666>`_ aai/datarouter startup fails to find logback.xml +- `AAI-666 <https://lf-onap.atlassian.net/browse/AAI-666>`_ aai/datarouter startup fails to find logback.xml -- `AAI-679 <https://jira.onap.org/browse/AAI-679>`_ A&AI UI failed to search service-instance based on service-instance-id +- `AAI-679 <https://lf-onap.atlassian.net/browse/AAI-679>`_ A&AI UI failed to search service-instance based on service-instance-id -- `AAI-699 <https://jira.onap.org/browse/AAI-699>`_ SDC Tosca does not generate Groups from resource yaml +- `AAI-699 <https://lf-onap.atlassian.net/browse/AAI-699>`_ SDC Tosca does not generate Groups from resource yaml -- `AAI-738 <https://jira.onap.org/browse/AAI-738>`_ When register service to MSB, esr-server still will register to MSB automaticly +- `AAI-738 <https://lf-onap.atlassian.net/browse/AAI-738>`_ When register service to MSB, esr-server still will register to MSB automaticly -- `AAI-788 <https://jira.onap.org/browse/AAI-788>`_ fix the cookie decryption algorithm +- `AAI-788 <https://lf-onap.atlassian.net/browse/AAI-788>`_ fix the cookie decryption algorithm -- `AAI-796 <https://jira.onap.org/browse/AAI-796>`_ AAI is logging %PARSER_ERROR instead of REMOTE_USER +- `AAI-796 <https://lf-onap.atlassian.net/browse/AAI-796>`_ AAI is logging %PARSER_ERROR instead of REMOTE_USER -- `AAI-833 <https://jira.onap.org/browse/AAI-833>`_ The url of query vim type from multiCloud is incorrect +- `AAI-833 <https://lf-onap.atlassian.net/browse/AAI-833>`_ The url of query vim type from multiCloud is incorrect -- `AAI-838 <https://jira.onap.org/browse/AAI-838>`_ Add back the properties that got removed +- `AAI-838 <https://lf-onap.atlassian.net/browse/AAI-838>`_ Add back the properties that got removed -- `AAI-874 <https://jira.onap.org/browse/AAI-874>`_ Fix the test-config traversal aaiconfig to use proper timeout keys +- `AAI-874 <https://lf-onap.atlassian.net/browse/AAI-874>`_ Fix the test-config traversal aaiconfig to use proper timeout keys -- `AAI-948 <https://jira.onap.org/browse/AAI-948>`_ aai-rest-client build fails with non-resolvable parent POM +- `AAI-948 <https://lf-onap.atlassian.net/browse/AAI-948>`_ aai-rest-client build fails with non-resolvable parent POM -- `AAI-961 <https://jira.onap.org/browse/AAI-961>`_ Fix aai-sparky-be-master-aai-docker-java-daily +- `AAI-961 <https://lf-onap.atlassian.net/browse/AAI-961>`_ Fix aai-sparky-be-master-aai-docker-java-daily -- `AAI-985 <https://jira.onap.org/browse/AAI-985>`_ Sparky-be: Change dependency to make use of sparky-fe war file from Beijing version +- `AAI-985 <https://lf-onap.atlassian.net/browse/AAI-985>`_ Sparky-be: Change dependency to make use of sparky-fe war file from Beijing version -- `AAI-987 <https://jira.onap.org/browse/AAI-987>`_ Update ML with the latest changes +- `AAI-987 <https://lf-onap.atlassian.net/browse/AAI-987>`_ Update ML with the latest changes -- `AAI-993 <https://jira.onap.org/browse/AAI-993>`_ Champ docker image name incorrect +- `AAI-993 <https://lf-onap.atlassian.net/browse/AAI-993>`_ Champ docker image name incorrect -- `AAI-994 <https://jira.onap.org/browse/AAI-994>`_ Crud-service (Gizmo) docker tag version is incorrect +- `AAI-994 <https://lf-onap.atlassian.net/browse/AAI-994>`_ Crud-service (Gizmo) docker tag version is incorrect -- `AAI-995 <https://jira.onap.org/browse/AAI-995>`_ Gizmo docker image name incorrect +- `AAI-995 <https://lf-onap.atlassian.net/browse/AAI-995>`_ Gizmo docker image name incorrect -- `AAI-996 <https://jira.onap.org/browse/AAI-996>`_ Change ML pom file to address build failure problems +- `AAI-996 <https://lf-onap.atlassian.net/browse/AAI-996>`_ Change ML pom file to address build failure problems -- `AAI-1005 <https://jira.onap.org/browse/AAI-1005>`_ Fix docker-compose-db.yml in test-config +- `AAI-1005 <https://lf-onap.atlassian.net/browse/AAI-1005>`_ Fix docker-compose-db.yml in test-config -- `AAI-1006 <https://jira.onap.org/browse/AAI-1006>`_ Babel start script does not set all required properties +- `AAI-1006 <https://lf-onap.atlassian.net/browse/AAI-1006>`_ Babel start script does not set all required properties -- `AAI-1007 <https://jira.onap.org/browse/AAI-1007>`_ Babel: java.lang.NoClassDefFoundError: com/att/aft/dme2/internal/gson/JsonSyntaxException +- `AAI-1007 <https://lf-onap.atlassian.net/browse/AAI-1007>`_ Babel: java.lang.NoClassDefFoundError: com/att/aft/dme2/internal/gson/JsonSyntaxException -- `AAI-1016 <https://jira.onap.org/browse/AAI-1016>`_ Model-loader: properties files are incorrectly named and have errors +- `AAI-1016 <https://lf-onap.atlassian.net/browse/AAI-1016>`_ Model-loader: properties files are incorrectly named and have errors -- `AAI-1017 <https://jira.onap.org/browse/AAI-1017>`_ Fix Champ build - incorrect definition of Java system path +- `AAI-1017 <https://lf-onap.atlassian.net/browse/AAI-1017>`_ Fix Champ build - incorrect definition of Java system path -- `AAI-1018 <https://jira.onap.org/browse/AAI-1018>`_ Model-loader: CONF_INVALID_MSG_BUS_ADDRESS +- `AAI-1018 <https://lf-onap.atlassian.net/browse/AAI-1018>`_ Model-loader: CONF_INVALID_MSG_BUS_ADDRESS -- `AAI-1019 <https://jira.onap.org/browse/AAI-1019>`_ aai-resources: does not require username/password after springboot upgrade +- `AAI-1019 <https://lf-onap.atlassian.net/browse/AAI-1019>`_ aai-resources: does not require username/password after springboot upgrade -- `AAI-1020 <https://jira.onap.org/browse/AAI-1020>`_ aai-traversal: does not require username/password after springboot upgrade +- `AAI-1020 <https://lf-onap.atlassian.net/browse/AAI-1020>`_ aai-traversal: does not require username/password after springboot upgrade -- `AAI-1024 <https://jira.onap.org/browse/AAI-1024>`_ Test-config: model-loader MSG_BUS_ADDRESSES not set +- `AAI-1024 <https://lf-onap.atlassian.net/browse/AAI-1024>`_ Test-config: model-loader MSG_BUS_ADDRESSES not set -- `AAI-1025 <https://jira.onap.org/browse/AAI-1025>`_ Test-config: traversal updateQueryData.sh fails to update models and queries +- `AAI-1025 <https://lf-onap.atlassian.net/browse/AAI-1025>`_ Test-config: traversal updateQueryData.sh fails to update models and queries -- `AAI-1026 <https://jira.onap.org/browse/AAI-1026>`_ test-config: model-loader is attempting 2-way TLS with AAI +- `AAI-1026 <https://lf-onap.atlassian.net/browse/AAI-1026>`_ test-config: model-loader is attempting 2-way TLS with AAI -- `AAI-1027 <https://jira.onap.org/browse/AAI-1027>`_ ModelLoader basic auth failure with aai-resources +- `AAI-1027 <https://lf-onap.atlassian.net/browse/AAI-1027>`_ ModelLoader basic auth failure with aai-resources -- `AAI-1029 <https://jira.onap.org/browse/AAI-1029>`_ The DOC about ESR installation should be update +- `AAI-1029 <https://lf-onap.atlassian.net/browse/AAI-1029>`_ The DOC about ESR installation should be update -- `AAI-1034 <https://jira.onap.org/browse/AAI-1034>`_ [sparky-be] Portal API Proxy missing from Spring Boot Sparky +- `AAI-1034 <https://lf-onap.atlassian.net/browse/AAI-1034>`_ [sparky-be] Portal API Proxy missing from Spring Boot Sparky -- `AAI-1035 <https://jira.onap.org/browse/AAI-1035>`_ Security: Springboot 1.5.10 has new nexusIQ critical exceptions +- `AAI-1035 <https://lf-onap.atlassian.net/browse/AAI-1035>`_ Security: Springboot 1.5.10 has new nexusIQ critical exceptions -- `AAI-1038 <https://jira.onap.org/browse/AAI-1038>`_ Babel missing .gitreview file +- `AAI-1038 <https://lf-onap.atlassian.net/browse/AAI-1038>`_ Babel missing .gitreview file -- `AAI-1049 <https://jira.onap.org/browse/AAI-1049>`_ [Model Loader] - Remove dependency on PowerMockito +- `AAI-1049 <https://lf-onap.atlassian.net/browse/AAI-1049>`_ [Model Loader] - Remove dependency on PowerMockito -- `AAI-1051 <https://jira.onap.org/browse/AAI-1051>`_ API Spec is specifying v12 in v13 file +- `AAI-1051 <https://lf-onap.atlassian.net/browse/AAI-1051>`_ API Spec is specifying v12 in v13 file -- `AAI-1052 <https://jira.onap.org/browse/AAI-1052>`_ AAI is using -SNAPSHOT artifacts; remove -SNAPSHOT dependencies +- `AAI-1052 <https://lf-onap.atlassian.net/browse/AAI-1052>`_ AAI is using -SNAPSHOT artifacts; remove -SNAPSHOT dependencies -- `AAI-1077 <https://jira.onap.org/browse/AAI-1077>`_ [Babel] master daily build job is not creating an autorelease staging repo +- `AAI-1077 <https://lf-onap.atlassian.net/browse/AAI-1077>`_ [Babel] master daily build job is not creating an autorelease staging repo -- `AAI-1082 <https://jira.onap.org/browse/AAI-1082>`_ Champ janus version incompatible with Resources janus version +- `AAI-1082 <https://lf-onap.atlassian.net/browse/AAI-1082>`_ Champ janus version incompatible with Resources janus version -- `AAI-1084 <https://jira.onap.org/browse/AAI-1084>`_ POST with PATCH override call is returning 405 +- `AAI-1084 <https://lf-onap.atlassian.net/browse/AAI-1084>`_ POST with PATCH override call is returning 405 -- `AAI-1086 <https://jira.onap.org/browse/AAI-1086>`_ Babel: Compressed files contain proprietary markings +- `AAI-1086 <https://lf-onap.atlassian.net/browse/AAI-1086>`_ Babel: Compressed files contain proprietary markings -- `AAI-1088 <https://jira.onap.org/browse/AAI-1088>`_ aai-common: version.properties refers to previous patch release +- `AAI-1088 <https://lf-onap.atlassian.net/browse/AAI-1088>`_ aai-common: version.properties refers to previous patch release -- `AAI-1089 <https://jira.onap.org/browse/AAI-1089>`_ haproxy, aai-resources, and aai-traversal using outdated certificate in HEAT config +- `AAI-1089 <https://lf-onap.atlassian.net/browse/AAI-1089>`_ haproxy, aai-resources, and aai-traversal using outdated certificate in HEAT config -- `AAI-1090 <https://jira.onap.org/browse/AAI-1090>`_ v13 does not support External System under cloud region +- `AAI-1090 <https://lf-onap.atlassian.net/browse/AAI-1090>`_ v13 does not support External System under cloud region -- `AAI-1091 <https://jira.onap.org/browse/AAI-1091>`_ ESR fails to register EMS +- `AAI-1091 <https://lf-onap.atlassian.net/browse/AAI-1091>`_ ESR fails to register EMS -- `AAI-1094 <https://jira.onap.org/browse/AAI-1094>`_ Model-loader: failure to negotiate with message router in OOM +- `AAI-1094 <https://lf-onap.atlassian.net/browse/AAI-1094>`_ Model-loader: failure to negotiate with message router in OOM -- `AAI-1096 <https://jira.onap.org/browse/AAI-1096>`_ Increase length for field:password in ESR-GUI VIM registration page +- `AAI-1096 <https://lf-onap.atlassian.net/browse/AAI-1096>`_ Increase length for field:password in ESR-GUI VIM registration page -- `AAI-1100 <https://jira.onap.org/browse/AAI-1100>`_ OOM Resources and Traversal Config map missing release +- `AAI-1100 <https://lf-onap.atlassian.net/browse/AAI-1100>`_ OOM Resources and Traversal Config map missing release -- `AAI-1101 <https://jira.onap.org/browse/AAI-1101>`_ haproxy, aai-resources, and aai-traversal using outdated certificate in OOM config +- `AAI-1101 <https://lf-onap.atlassian.net/browse/AAI-1101>`_ haproxy, aai-resources, and aai-traversal using outdated certificate in OOM config -- `AAI-1105 <https://jira.onap.org/browse/AAI-1105>`_ aai-traversal job is failing when trying to start OOM +- `AAI-1105 <https://lf-onap.atlassian.net/browse/AAI-1105>`_ aai-traversal job is failing when trying to start OOM -- `AAI-1106 <https://jira.onap.org/browse/AAI-1106>`_ aai-resources: scripts do not work properly with spring-boot +- `AAI-1106 <https://lf-onap.atlassian.net/browse/AAI-1106>`_ aai-resources: scripts do not work properly with spring-boot -- `AAI-1107 <https://jira.onap.org/browse/AAI-1107>`_ Security: babel and m-l brings in springboot jersey starter, which includes logback 1.1.11 +- `AAI-1107 <https://lf-onap.atlassian.net/browse/AAI-1107>`_ Security: babel and m-l brings in springboot jersey starter, which includes logback 1.1.11 -- `AAI-1108 <https://jira.onap.org/browse/AAI-1108>`_ [Babel] Remove license violations in latest commit. +- `AAI-1108 <https://lf-onap.atlassian.net/browse/AAI-1108>`_ [Babel] Remove license violations in latest commit. -- `AAI-1110 <https://jira.onap.org/browse/AAI-1110>`_ Model Loader logback.xml errors +- `AAI-1110 <https://lf-onap.atlassian.net/browse/AAI-1110>`_ Model Loader logback.xml errors -- `AAI-1111 <https://jira.onap.org/browse/AAI-1111>`_ Update test-config project for Babel +- `AAI-1111 <https://lf-onap.atlassian.net/browse/AAI-1111>`_ Update test-config project for Babel -- `AAI-1113 <https://jira.onap.org/browse/AAI-1113>`_ ESR VIM registration portal: Physical Location Id does not populate any data +- `AAI-1113 <https://lf-onap.atlassian.net/browse/AAI-1113>`_ ESR VIM registration portal: Physical Location Id does not populate any data -- `AAI-1114 <https://jira.onap.org/browse/AAI-1114>`_ Security: [Champ] add Dockerfile and remove additional AJSC files +- `AAI-1114 <https://lf-onap.atlassian.net/browse/AAI-1114>`_ Security: [Champ] add Dockerfile and remove additional AJSC files -- `AAI-1116 <https://jira.onap.org/browse/AAI-1116>`_ [Gizmo] addressing Security vulnerabilities (Nexus IQ) +- `AAI-1116 <https://lf-onap.atlassian.net/browse/AAI-1116>`_ [Gizmo] addressing Security vulnerabilities (Nexus IQ) -- `AAI-1117 <https://jira.onap.org/browse/AAI-1117>`_ [Champ] addressing Security vulnerabilities (Nexus IQ) +- `AAI-1117 <https://lf-onap.atlassian.net/browse/AAI-1117>`_ [Champ] addressing Security vulnerabilities (Nexus IQ) -- `AAI-1118 <https://jira.onap.org/browse/AAI-1118>`_ [Gizmo] upgrade artefacts from aai-common to 1.2.4 +- `AAI-1118 <https://lf-onap.atlassian.net/browse/AAI-1118>`_ [Gizmo] upgrade artefacts from aai-common to 1.2.4 -- `AAI-1119 <https://jira.onap.org/browse/AAI-1119>`_ [Champ] Prevent deployment of Champ service jar +- `AAI-1119 <https://lf-onap.atlassian.net/browse/AAI-1119>`_ [Champ] Prevent deployment of Champ service jar -- `AAI-1120 <https://jira.onap.org/browse/AAI-1120>`_ [Gizmo] Fix Jacoco configuration +- `AAI-1120 <https://lf-onap.atlassian.net/browse/AAI-1120>`_ [Gizmo] Fix Jacoco configuration -- `AAI-1121 <https://jira.onap.org/browse/AAI-1121>`_ Add the default realtime clients +- `AAI-1121 <https://lf-onap.atlassian.net/browse/AAI-1121>`_ Add the default realtime clients -- `AAI-1123 <https://jira.onap.org/browse/AAI-1123>`_ Babel logback.xml errors +- `AAI-1123 <https://lf-onap.atlassian.net/browse/AAI-1123>`_ Babel logback.xml errors -- `AAI-1124 <https://jira.onap.org/browse/AAI-1124>`_ [router-core] NexusIQ reporting httpclient 4.5 vulnerability +- `AAI-1124 <https://lf-onap.atlassian.net/browse/AAI-1124>`_ [router-core] NexusIQ reporting httpclient 4.5 vulnerability -- `AAI-1125 <https://jira.onap.org/browse/AAI-1125>`_ [data-router] NexusIQ reporting httpclient 4.5 vulnerability +- `AAI-1125 <https://lf-onap.atlassian.net/browse/AAI-1125>`_ [data-router] NexusIQ reporting httpclient 4.5 vulnerability -- `AAI-1126 <https://jira.onap.org/browse/AAI-1126>`_ [Babel] Authorisation mechanism is not functioning +- `AAI-1126 <https://lf-onap.atlassian.net/browse/AAI-1126>`_ [Babel] Authorisation mechanism is not functioning -- `AAI-1127 <https://jira.onap.org/browse/AAI-1127>`_ [sparky-be] doesn't release artifacts because it is missing the staging plugin +- `AAI-1127 <https://lf-onap.atlassian.net/browse/AAI-1127>`_ [sparky-be] doesn't release artifacts because it is missing the staging plugin -- `AAI-1132 <https://jira.onap.org/browse/AAI-1132>`_ AAI's OOM server certificate doesn't include all k8 names +- `AAI-1132 <https://lf-onap.atlassian.net/browse/AAI-1132>`_ AAI's OOM server certificate doesn't include all k8 names -- `AAI-1133 <https://jira.onap.org/browse/AAI-1133>`_ AAI's haproxy server config doesn't include all k8 names +- `AAI-1133 <https://lf-onap.atlassian.net/browse/AAI-1133>`_ AAI's haproxy server config doesn't include all k8 names -- `AAI-1134 <https://jira.onap.org/browse/AAI-1134>`_ OOF not defined in AAI realm properties files +- `AAI-1134 <https://lf-onap.atlassian.net/browse/AAI-1134>`_ OOF not defined in AAI realm properties files -- `AAI-1135 <https://jira.onap.org/browse/AAI-1135>`_ [traversal] closed loop named-query is missing property-collect-list +- `AAI-1135 <https://lf-onap.atlassian.net/browse/AAI-1135>`_ [traversal] closed loop named-query is missing property-collect-list -- `AAI-1136 <https://jira.onap.org/browse/AAI-1136>`_ Babel doesnt start in HEAT due to log directory permissions +- `AAI-1136 <https://lf-onap.atlassian.net/browse/AAI-1136>`_ Babel doesnt start in HEAT due to log directory permissions -- `AAI-1138 <https://jira.onap.org/browse/AAI-1138>`_ [Champ] Bump to 1.2.1-SNAPSHOT and 1.2.1 in version.properties +- `AAI-1138 <https://lf-onap.atlassian.net/browse/AAI-1138>`_ [Champ] Bump to 1.2.1-SNAPSHOT and 1.2.1 in version.properties -- `AAI-1139 <https://jira.onap.org/browse/AAI-1139>`_ [resources and traversal] do not release artifacts properly +- `AAI-1139 <https://lf-onap.atlassian.net/browse/AAI-1139>`_ [resources and traversal] do not release artifacts properly -- `AAI-1141 <https://jira.onap.org/browse/AAI-1141>`_ [champ] duplicate dependency in pom.xml +- `AAI-1141 <https://lf-onap.atlassian.net/browse/AAI-1141>`_ [champ] duplicate dependency in pom.xml -- `AAI-1142 <https://jira.onap.org/browse/AAI-1142>`_ [champ] doesn't create release artifacts +- `AAI-1142 <https://lf-onap.atlassian.net/browse/AAI-1142>`_ [champ] doesn't create release artifacts -- `AAI-1143 <https://jira.onap.org/browse/AAI-1143>`_ [resources] createDbSchema.sh tries to add -SNAPSHOT version to classpath +- `AAI-1143 <https://lf-onap.atlassian.net/browse/AAI-1143>`_ [resources] createDbSchema.sh tries to add -SNAPSHOT version to classpath -- `AAI-1144 <https://jira.onap.org/browse/AAI-1144>`_ [oom and test-config] robot-ete is missing from realtime clients list +- `AAI-1144 <https://lf-onap.atlassian.net/browse/AAI-1144>`_ [oom and test-config] robot-ete is missing from realtime clients list -- `AAI-1146 <https://jira.onap.org/browse/AAI-1146>`_ [champ] daily build job is failing +- `AAI-1146 <https://lf-onap.atlassian.net/browse/AAI-1146>`_ [champ] daily build job is failing -- `AAI-1148 <https://jira.onap.org/browse/AAI-1148>`_ [Model-Loader] Rollback of VNF Images fails +- `AAI-1148 <https://lf-onap.atlassian.net/browse/AAI-1148>`_ [Model-Loader] Rollback of VNF Images fails -- `AAI-1151 <https://jira.onap.org/browse/AAI-1151>`_ [Champ & Gizmo] Fix JJB jenkins jobs +- `AAI-1151 <https://lf-onap.atlassian.net/browse/AAI-1151>`_ [Champ & Gizmo] Fix JJB jenkins jobs -- `AAI-1153 <https://jira.onap.org/browse/AAI-1153>`_ [Champ] Bump to 1.2.2-SNAPSHOT and 1.2.2 in version.properties +- `AAI-1153 <https://lf-onap.atlassian.net/browse/AAI-1153>`_ [Champ] Bump to 1.2.2-SNAPSHOT and 1.2.2 in version.properties **Known Issues** @@ -1074,13 +1072,13 @@ If the either the aai-resources or aai-traversal pod is deleted, haproxy will no **Security Notes** -AAI code has been formally scanned during build time using NexusIQ and all Critical vulnerabilities have been addressed, items that remain open have been assessed for risk and determined to be false positive. The AAI open Critical security vulnerabilities and their risk assessment have been documented as part of the `project <https://wiki.onap.org/pages/viewpage.action?pageId=25441383>`_. +AAI code has been formally scanned during build time using NexusIQ and all Critical vulnerabilities have been addressed, items that remain open have been assessed for risk and determined to be false positive. The AAI open Critical security vulnerabilities and their risk assessment have been documented as part of the `project <https://lf-onap.atlassian.net/wiki/spaces/DW/pages/16258007/AAI+R2+Release+Planning>`_. Quick Links: -- `AAI project page <https://wiki.onap.org/display/DW/Active+and+Available+Inventory+Project>`_ +- `AAI project page <https://lf-onap.atlassian.net/wiki/spaces/DW/pages/16230663/Active+and+Available+Inventory+Project>`_ - `Passing Badge information for AAI <https://bestpractices.coreinfrastructure.org/en/projects/1591>`_ -- `R2 Project Vulnerability Review Table for AAI <https://wiki.onap.org/pages/viewpage.action?pageId=25441383>`_ +- `R2 Project Vulnerability Review Table for AAI <https://lf-onap.atlassian.net/wiki/spaces/DW/pages/16276191/AAI+R2+Security+Vulnerability+Threat+Analysis>`_ Version: 1.1.1 -------------- @@ -1089,23 +1087,23 @@ Version: 1.1.1 **Bug Fixes** -- `AAI-456 <https://jira.onap.org/browse/AAI-456>`_ AAI named-query for policy not returning extra-properties +- `AAI-456 <https://lf-onap.atlassian.net/browse/AAI-456>`_ AAI named-query for policy not returning extra-properties -- `AAI-458 <https://jira.onap.org/browse/AAI-458>`_ [aai] ML, Search, DR, and Sparky Jenkins jobs not creating autorelease repo +- `AAI-458 <https://lf-onap.atlassian.net/browse/AAI-458>`_ [aai] ML, Search, DR, and Sparky Jenkins jobs not creating autorelease repo -- `AAI-459 <https://jira.onap.org/browse/AAI-459>`_ aai-common child pom still depends on openecomp artifacts +- `AAI-459 <https://lf-onap.atlassian.net/browse/AAI-459>`_ aai-common child pom still depends on openecomp artifacts -- `AAI-461 <https://jira.onap.org/browse/AAI-461>`_ AAI mS configuration files are using old openecomp params in test-config +- `AAI-461 <https://lf-onap.atlassian.net/browse/AAI-461>`_ AAI mS configuration files are using old openecomp params in test-config -- `AAI-462 <https://jira.onap.org/browse/AAI-462>`_ Fix the resources junit tests broken in windows environment +- `AAI-462 <https://lf-onap.atlassian.net/browse/AAI-462>`_ Fix the resources junit tests broken in windows environment -- `AAI-558 <https://jira.onap.org/browse/AAI-558>`_ aai-resources java daily jenkins job is failing +- `AAI-558 <https://lf-onap.atlassian.net/browse/AAI-558>`_ aai-resources java daily jenkins job is failing -- `AAI-561 <https://jira.onap.org/browse/AAI-561>`_ aai-traversal java daily jenkins job is failing +- `AAI-561 <https://lf-onap.atlassian.net/browse/AAI-561>`_ aai-traversal java daily jenkins job is failing -- `AAI-566 <https://jira.onap.org/browse/AAI-566>`_ AAI Eclipse build failure - aai-traversal pom as hardcoded 1.8.0_101 jdk.tools version +- `AAI-566 <https://lf-onap.atlassian.net/browse/AAI-566>`_ AAI Eclipse build failure - aai-traversal pom as hardcoded 1.8.0_101 jdk.tools version -- `AAI-621 <https://jira.onap.org/browse/AAI-621>`_ Update the snapshot in test-config for v1.1.1-SNAPSHOT +- `AAI-621 <https://lf-onap.atlassian.net/browse/AAI-621>`_ Update the snapshot in test-config for v1.1.1-SNAPSHOT Version: 1.1.0 -------------- @@ -1152,120 +1150,120 @@ Source code of AAI is released under the following repositories at https://gerri **Epic** -- `AAI-17 <https://jira.onap.org/browse/AAI-17>`_ Seed code stabilization -- `AAI-20 <https://jira.onap.org/browse/AAI-20>`_ Champ Library -- `AAI-22 <https://jira.onap.org/browse/AAI-22>`_ Amsterdam User Case Schema Updates -- `AAI-23 <https://jira.onap.org/browse/AAI-23>`_ Model Loader Support for R1 -- `AAI-58 <https://jira.onap.org/browse/AAI-58>`_ Define and build functional test cases for CSIT -- `AAI-72 <https://jira.onap.org/browse/AAI-72>`_ External System Register -- `AAI-254 <https://jira.onap.org/browse/AAI-254>`_ Documentation of REST APIs, dev guides, onboarding, etc. -- `AAI-280 <https://jira.onap.org/browse/AAI-280>`_ Confguration enhancements +- `AAI-17 <https://lf-onap.atlassian.net/browse/AAI-17>`_ Seed code stabilization +- `AAI-20 <https://lf-onap.atlassian.net/browse/AAI-20>`_ Champ Library +- `AAI-22 <https://lf-onap.atlassian.net/browse/AAI-22>`_ Amsterdam User Case Schema Updates +- `AAI-23 <https://lf-onap.atlassian.net/browse/AAI-23>`_ Model Loader Support for R1 +- `AAI-58 <https://lf-onap.atlassian.net/browse/AAI-58>`_ Define and build functional test cases for CSIT +- `AAI-72 <https://lf-onap.atlassian.net/browse/AAI-72>`_ External System Register +- `AAI-254 <https://lf-onap.atlassian.net/browse/AAI-254>`_ Documentation of REST APIs, dev guides, onboarding, etc. +- `AAI-280 <https://lf-onap.atlassian.net/browse/AAI-280>`_ Confguration enhancements **Bug Fixes** -- `AAI-11 <https://jira.onap.org/browse/AAI-11>`_ robot_vm: demo.sh failing - '200' does not match '^(201|412)$' on vanilla openstack +- `AAI-11 <https://lf-onap.atlassian.net/browse/AAI-11>`_ robot_vm: demo.sh failing - '200' does not match '^(201|412)$' on vanilla openstack -- `AAI-13 <https://jira.onap.org/browse/AAI-13>`_ VM_init is failing to get sparky +- `AAI-13 <https://lf-onap.atlassian.net/browse/AAI-13>`_ VM_init is failing to get sparky -- `AAI-31 <https://jira.onap.org/browse/AAI-31>`_ Compilation failure in aai-traversal +- `AAI-31 <https://lf-onap.atlassian.net/browse/AAI-31>`_ Compilation failure in aai-traversal -- `AAI-48 <https://jira.onap.org/browse/AAI-48>`_ AAI Common REST Client returns an error on a 204 (No Content) server response +- `AAI-48 <https://lf-onap.atlassian.net/browse/AAI-48>`_ AAI Common REST Client returns an error on a 204 (No Content) server response -- `AAI-49 <https://jira.onap.org/browse/AAI-49>`_ Health check is failing in DFW 1.1 RS. Connection refused +- `AAI-49 <https://lf-onap.atlassian.net/browse/AAI-49>`_ Health check is failing in DFW 1.1 RS. Connection refused -- `AAI-62 <https://jira.onap.org/browse/AAI-62>`_ Search Data Service should not implicitly create indexes on document write +- `AAI-62 <https://lf-onap.atlassian.net/browse/AAI-62>`_ Search Data Service should not implicitly create indexes on document write -- `AAI-63 <https://jira.onap.org/browse/AAI-63>`_ Data Router must handle Search Service document create failures if index does not exit +- `AAI-63 <https://lf-onap.atlassian.net/browse/AAI-63>`_ Data Router must handle Search Service document create failures if index does not exit -- `AAI-73 <https://jira.onap.org/browse/AAI-73>`_ Sparky sync issues +- `AAI-73 <https://lf-onap.atlassian.net/browse/AAI-73>`_ Sparky sync issues -- `AAI-76 <https://jira.onap.org/browse/AAI-76>`_ Jenkins stage-site builds failing on resources and traversal +- `AAI-76 <https://lf-onap.atlassian.net/browse/AAI-76>`_ Jenkins stage-site builds failing on resources and traversal -- `AAI-94 <https://jira.onap.org/browse/AAI-94>`_ AAI Certificate will expire 30 Nov 2017 - fyi +- `AAI-94 <https://lf-onap.atlassian.net/browse/AAI-94>`_ AAI Certificate will expire 30 Nov 2017 - fyi -- `AAI-146 <https://jira.onap.org/browse/AAI-146>`_ Both esr-server and esr-gui Jenkins failed +- `AAI-146 <https://lf-onap.atlassian.net/browse/AAI-146>`_ Both esr-server and esr-gui Jenkins failed -- `AAI-192 <https://jira.onap.org/browse/AAI-192>`_ Model Loader depends on httpclient version 4.4.1 +- `AAI-192 <https://lf-onap.atlassian.net/browse/AAI-192>`_ Model Loader depends on httpclient version 4.4.1 -- `AAI-205 <https://jira.onap.org/browse/AAI-205>`_ Having an invalid xml namespace for v11, named-query api returns 500 error, model query return incorrect error message +- `AAI-205 <https://lf-onap.atlassian.net/browse/AAI-205>`_ Having an invalid xml namespace for v11, named-query api returns 500 error, model query return incorrect error message -- `AAI-206 <https://jira.onap.org/browse/AAI-206>`_ Model based delete is failing +- `AAI-206 <https://lf-onap.atlassian.net/browse/AAI-206>`_ Model based delete is failing -- `AAI-217 <https://jira.onap.org/browse/AAI-217>`_ Remove internal references from A&AI seed code +- `AAI-217 <https://lf-onap.atlassian.net/browse/AAI-217>`_ Remove internal references from A&AI seed code -- `AAI-222 <https://jira.onap.org/browse/AAI-222>`_ the version property of esr-server is incorrect +- `AAI-222 <https://lf-onap.atlassian.net/browse/AAI-222>`_ the version property of esr-server is incorrect -- `AAI-224 <https://jira.onap.org/browse/AAI-224>`_ aai/esr-gui daily build failed +- `AAI-224 <https://lf-onap.atlassian.net/browse/AAI-224>`_ aai/esr-gui daily build failed -- `AAI-225 <https://jira.onap.org/browse/AAI-225>`_ aai/esr-server daily build failed +- `AAI-225 <https://lf-onap.atlassian.net/browse/AAI-225>`_ aai/esr-server daily build failed -- `AAI-265 <https://jira.onap.org/browse/AAI-265>`_ EdgePropertyMap throws NullPointer if edge rule does not include property +- `AAI-265 <https://lf-onap.atlassian.net/browse/AAI-265>`_ EdgePropertyMap throws NullPointer if edge rule does not include property -- `AAI-266 <https://jira.onap.org/browse/AAI-266>`_ auth-info edge rule does not include contains-other-v +- `AAI-266 <https://lf-onap.atlassian.net/browse/AAI-266>`_ auth-info edge rule does not include contains-other-v -- `AAI-273 <https://jira.onap.org/browse/AAI-273>`_ Fix the esr-server setup error issue +- `AAI-273 <https://lf-onap.atlassian.net/browse/AAI-273>`_ Fix the esr-server setup error issue -- `AAI-278 <https://jira.onap.org/browse/AAI-278>`_ AAI throws exception about mismatch keys adding esr-system-info to cloud-region +- `AAI-278 <https://lf-onap.atlassian.net/browse/AAI-278>`_ AAI throws exception about mismatch keys adding esr-system-info to cloud-region -- `AAI-293 <https://jira.onap.org/browse/AAI-293>`_ Jenkins job failing for aai-sparky-fe-master-release-version-java-daily +- `AAI-293 <https://lf-onap.atlassian.net/browse/AAI-293>`_ Jenkins job failing for aai-sparky-fe-master-release-version-java-daily -- `AAI-377 <https://jira.onap.org/browse/AAI-377>`_ esr-gui docker build failed +- `AAI-377 <https://lf-onap.atlassian.net/browse/AAI-377>`_ esr-gui docker build failed -- `AAI-393 <https://jira.onap.org/browse/AAI-393>`_ The jjb defiend in a error way that cause CSIT build failed. +- `AAI-393 <https://lf-onap.atlassian.net/browse/AAI-393>`_ The jjb defiend in a error way that cause CSIT build failed. -- `AAI-398 <https://jira.onap.org/browse/AAI-398>`_ If a cloud-region didn't contain a external system info, there will be an null pointer error +- `AAI-398 <https://lf-onap.atlassian.net/browse/AAI-398>`_ If a cloud-region didn't contain a external system info, there will be an null pointer error -- `AAI-400 <https://jira.onap.org/browse/AAI-400>`_ Register ServiceTest to microservice +- `AAI-400 <https://lf-onap.atlassian.net/browse/AAI-400>`_ Register ServiceTest to microservice -- `AAI-401 <https://jira.onap.org/browse/AAI-401>`_ Remove DMaaP router duplication +- `AAI-401 <https://lf-onap.atlassian.net/browse/AAI-401>`_ Remove DMaaP router duplication -- `AAI-407 <https://jira.onap.org/browse/AAI-407>`_ There is an error to startup esr-gui docker +- `AAI-407 <https://lf-onap.atlassian.net/browse/AAI-407>`_ There is an error to startup esr-gui docker -- `AAI-412 <https://jira.onap.org/browse/AAI-412>`_ Replace the type specification in this constructor call with the diamond operator ("<>") +- `AAI-412 <https://lf-onap.atlassian.net/browse/AAI-412>`_ Replace the type specification in this constructor call with the diamond operator ("<>") -- `AAI-417 <https://jira.onap.org/browse/AAI-417>`_ Rackspace 20170928 fails to authenticate nexus3 on 10003 during *_init.sh* (sdnc for example) +- `AAI-417 <https://lf-onap.atlassian.net/browse/AAI-417>`_ Rackspace 20170928 fails to authenticate nexus3 on 10003 during *_init.sh* (sdnc for example) -- `AAI-420 <https://jira.onap.org/browse/AAI-420>`_ Can not get the MSB address in esr-server +- `AAI-420 <https://lf-onap.atlassian.net/browse/AAI-420>`_ Can not get the MSB address in esr-server -- `AAI-422 <https://jira.onap.org/browse/AAI-422>`_ The esr-server csit failed +- `AAI-422 <https://lf-onap.atlassian.net/browse/AAI-422>`_ The esr-server csit failed -- `AAI-424 <https://jira.onap.org/browse/AAI-424>`_ The integration catalog is not in use, should be removed +- `AAI-424 <https://lf-onap.atlassian.net/browse/AAI-424>`_ The integration catalog is not in use, should be removed -- `AAI-425 <https://jira.onap.org/browse/AAI-425>`_ Fix the artifact of esr-gui +- `AAI-425 <https://lf-onap.atlassian.net/browse/AAI-425>`_ Fix the artifact of esr-gui -- `AAI-426 <https://jira.onap.org/browse/AAI-426>`_ Fix the artifact of esr-server +- `AAI-426 <https://lf-onap.atlassian.net/browse/AAI-426>`_ Fix the artifact of esr-server -- `AAI-431 <https://jira.onap.org/browse/AAI-431>`_ esr-gui files did not contained in webapp of tomcat +- `AAI-431 <https://lf-onap.atlassian.net/browse/AAI-431>`_ esr-gui files did not contained in webapp of tomcat -- `AAI-433 <https://jira.onap.org/browse/AAI-433>`_ Failed to pre-load vCPE data to AAI. No response from AAI +- `AAI-433 <https://lf-onap.atlassian.net/browse/AAI-433>`_ Failed to pre-load vCPE data to AAI. No response from AAI -- `AAI-434 <https://jira.onap.org/browse/AAI-434>`_ Can not visit ESR portal with demo deployment +- `AAI-434 <https://lf-onap.atlassian.net/browse/AAI-434>`_ Can not visit ESR portal with demo deployment -- `AAI-435 <https://jira.onap.org/browse/AAI-435>`_ default tenant need be input to A&AI while register VIM +- `AAI-435 <https://lf-onap.atlassian.net/browse/AAI-435>`_ default tenant need be input to A&AI while register VIM -- `AAI-436 <https://jira.onap.org/browse/AAI-436>`_ Call the API from MultiCloud failed +- `AAI-436 <https://lf-onap.atlassian.net/browse/AAI-436>`_ Call the API from MultiCloud failed -- `AAI-440 <https://jira.onap.org/browse/AAI-440>`_ The version input box should be changed in a more easy to use when register a VIM +- `AAI-440 <https://lf-onap.atlassian.net/browse/AAI-440>`_ The version input box should be changed in a more easy to use when register a VIM -- `AAI-441 <https://jira.onap.org/browse/AAI-441>`_ Can not input the vendor and version information to EMS, but there is a default data for the two parameter +- `AAI-441 <https://lf-onap.atlassian.net/browse/AAI-441>`_ Can not input the vendor and version information to EMS, but there is a default data for the two parameter -- `AAI-442 <https://jira.onap.org/browse/AAI-442>`_ Can't instantiate a service +- `AAI-442 <https://lf-onap.atlassian.net/browse/AAI-442>`_ Can't instantiate a service -- `AAI-444 <https://jira.onap.org/browse/AAI-444>`_ Cannot associate multiple service-instances to PNFs +- `AAI-444 <https://lf-onap.atlassian.net/browse/AAI-444>`_ Cannot associate multiple service-instances to PNFs -- `AAI-446 <https://jira.onap.org/browse/AAI-446>`_ vnf to esr-system-info named-query is missing vnfc +- `AAI-446 <https://lf-onap.atlassian.net/browse/AAI-446>`_ vnf to esr-system-info named-query is missing vnfc -- `AAI-448 <https://jira.onap.org/browse/AAI-448>`_ Remove snapshot dependencies from aai-common, data-router, and rest-client +- `AAI-448 <https://lf-onap.atlassian.net/browse/AAI-448>`_ Remove snapshot dependencies from aai-common, data-router, and rest-client -- `AAI-450 <https://jira.onap.org/browse/AAI-450>`_ Named Query needs to be updated to return VNFC Info +- `AAI-450 <https://lf-onap.atlassian.net/browse/AAI-450>`_ Named Query needs to be updated to return VNFC Info -- `AAI-453 <https://jira.onap.org/browse/AAI-453>`_ Fix stage-site jenkins job for aai-common +- `AAI-453 <https://lf-onap.atlassian.net/browse/AAI-453>`_ Fix stage-site jenkins job for aai-common -- `AAI-454 <https://jira.onap.org/browse/AAI-454>`_ LoggingContext.requestId required NULL handling in aai/aai-common (20170607) - during demo.sh init_customer +- `AAI-454 <https://lf-onap.atlassian.net/browse/AAI-454>`_ LoggingContext.requestId required NULL handling in aai/aai-common (20170607) - during demo.sh init_customer **Known Issues** -- `AAI-61 <https://jira.onap.org/browse/AAI-61>`_ AAI cleaned up references to OpenECOMP but in order to keep the release stable for R1, the XML namespace still contains openecomp. +- `AAI-61 <https://lf-onap.atlassian.net/browse/AAI-61>`_ AAI cleaned up references to OpenECOMP but in order to keep the release stable for R1, the XML namespace still contains openecomp. **Security Issues** diff --git a/onap-java-formatter.xml b/onap-java-formatter.xml index 1dd9de63..afd15d67 100644 --- a/onap-java-formatter.xml +++ b/onap-java-formatter.xml @@ -2,11 +2,11 @@ <profiles version="12"> <profile kind="CodeFormatterProfile" name="onap-java-formatter" version="12"> <setting id="org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode" value="enabled"/> -<setting id="org.eclipse.jdt.core.compiler.codegen.targetPlatform" value="1.8"/> -<setting id="org.eclipse.jdt.core.compiler.compliance" value="1.8"/> +<setting id="org.eclipse.jdt.core.compiler.codegen.targetPlatform" value="11"/> +<setting id="org.eclipse.jdt.core.compiler.compliance" value="11"/> <setting id="org.eclipse.jdt.core.compiler.problem.assertIdentifier" value="error"/> <setting id="org.eclipse.jdt.core.compiler.problem.enumIdentifier" value="error"/> -<setting id="org.eclipse.jdt.core.compiler.source" value="1.8"/> +<setting id="org.eclipse.jdt.core.compiler.source" value="11"/> <setting id="org.eclipse.jdt.core.formatter.align_type_members_on_columns" value="false"/> <setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression" value="16"/> <setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation" value="48"/> @@ -25,12 +25,12 @@ <parent> <groupId>org.onap.oparent</groupId> <artifactId>oparent</artifactId> - <version>2.1.0</version> + <version>3.0.2</version> </parent> <groupId>org.onap.aai.aai-common</groupId> <artifactId>aai-common</artifactId> - <version>1.14.6-SNAPSHOT</version> + <version>1.15.2-SNAPSHOT</version> <packaging>pom</packaging> <name>aai-aai-common</name> <description>Contains all of the common code for resources and traversal repos</description> @@ -40,7 +40,6 @@ <module>aai-rest</module> <module>aai-schema-ingest</module> <module>aai-annotations</module> - <module>aai-aaf-auth</module> <module>aai-core</module> <module>aai-auth</module> <module>aai-els-onap-logging</module> @@ -110,8 +109,7 @@ <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <configuration> - <source>1.8</source> - <target>1.8</target> + <release>11</release> </configuration> </plugin> <plugin> @@ -238,11 +236,6 @@ <url>https://mvnrepository.com/artifact/com.att.ajsc</url> </repository> <repository> - <id>restlet</id> - <name>maven reslet</name> - <url>https://maven.restlet.com/</url> - </repository> - <repository> <id>ecomp-releases</id> <name>ECOMP Release Repository</name> <url>${onap.nexus.url}/content/repositories/releases/</url> diff --git a/releases/1.14.6-maven-release.yaml b/releases/1.14.6-maven-release.yaml new file mode 100644 index 00000000..d6503ca1 --- /dev/null +++ b/releases/1.14.6-maven-release.yaml @@ -0,0 +1,4 @@ +distribution_type: maven +log_dir: aai-aai-common-maven-stage-master/1462/ +project: aai-common +version: 1.14.6 diff --git a/releases/1.14.7-maven-release.yaml b/releases/1.14.7-maven-release.yaml new file mode 100644 index 00000000..73fc9d8d --- /dev/null +++ b/releases/1.14.7-maven-release.yaml @@ -0,0 +1,4 @@ +distribution_type: maven +log_dir: aai-aai-common-maven-stage-master/1464/ +project: aai-common +version: 1.14.7 diff --git a/releases/1.15.0-maven-release.yaml b/releases/1.15.0-maven-release.yaml new file mode 100644 index 00000000..56edfb73 --- /dev/null +++ b/releases/1.15.0-maven-release.yaml @@ -0,0 +1,4 @@ +distribution_type: maven +log_dir: aai-aai-common-maven-stage-master/1465/ +project: aai-common +version: 1.15.0 diff --git a/releases/1.15.1-maven-release.yaml b/releases/1.15.1-maven-release.yaml new file mode 100644 index 00000000..94a995f1 --- /dev/null +++ b/releases/1.15.1-maven-release.yaml @@ -0,0 +1,4 @@ +distribution_type: maven +log_dir: aai-aai-common-maven-stage-master/1466/ +project: aai-common +version: 1.15.1 diff --git a/version.properties b/version.properties index cae43c29..df314753 100644 --- a/version.properties +++ b/version.properties @@ -4,8 +4,8 @@ # because they are used in Jenkins, whose plug-in doesn't support major_version=1 -minor_version=14 -patch_version=6 +minor_version=15 +patch_version=2 base_version=${major_version}.${minor_version}.${patch_version} |