diff options
41 files changed, 629 insertions, 315 deletions
diff --git a/sparkybe-onap-application/config/application-personalization.properties b/sparkybe-onap-application/config/application-personalization.properties new file mode 100644 index 0000000..b462aba --- /dev/null +++ b/sparkybe-onap-application/config/application-personalization.properties @@ -0,0 +1,2 @@ +personalization.topLeftHeader=A&AI +personalization.htmlDocumentTitle=A&AI
\ No newline at end of file diff --git a/sparkybe-onap-application/config/application-resources.properties b/sparkybe-onap-application/config/application-resources.properties index 5860c7a..e33cc4f 100644 --- a/sparkybe-onap-application/config/application-resources.properties +++ b/sparkybe-onap-application/config/application-resources.properties @@ -7,3 +7,5 @@ resources.client-cert=client-cert-onap.p12 resources.client-cert-password=1y0q1uvc1uum1uvg1pil1pjl1uuq1uvk1uuu1y10 resources.trust-store=tomcat_keystore resources.maxSelfLinkTraversalDepth=2 +resources.domain=aai +resources.delimitedShallowEntities=cloud-region,complex,vnf-image,image,flavor,availability-zone,tenant,network-profile,l-interface
\ No newline at end of file diff --git a/sparkybe-onap-application/config/spring-beans/sparky-attribute-update-service.xml b/sparkybe-onap-application/config/spring-beans/sparky-attribute-update-service.xml index 6ae1edb..27db51a 100644 --- a/sparkybe-onap-application/config/spring-beans/sparky-attribute-update-service.xml +++ b/sparkybe-onap-application/config/spring-beans/sparky-attribute-update-service.xml @@ -9,6 +9,7 @@ <constructor-arg ref="oxmModelLoader" /> <constructor-arg ref="oxmEntityLookup" /> <constructor-arg ref="activeInventoryAdapter" /> + <constructor-arg name="domain" value="${resources.domain:aai}" /> </bean> <bean id="attributeEditProcessor" diff --git a/sparkybe-onap-application/config/spring-beans/sparky-gizmo.xml b/sparkybe-onap-application/config/spring-beans/sparky-gizmo.xml index adf3507..bb3cfbb 100644 --- a/sparkybe-onap-application/config/spring-beans/sparky-gizmo.xml +++ b/sparkybe-onap-application/config/spring-beans/sparky-gizmo.xml @@ -25,6 +25,7 @@ <property name="relationshipsBasePath" value="/services/inventory/relationships/${gizmo.apiVersion:v12}" /> <property name="inventoryBasePath" value="/services/inventory/${gizmo.apiVersion:v12}" /> + <property name="appPartnerName" value="${gizmo.appPartnerName:AAI-UI}" /> </bean> </beans>
\ No newline at end of file diff --git a/sparkybe-onap-application/config/spring-beans/sparky-global-search.xml b/sparkybe-onap-application/config/spring-beans/sparky-global-search.xml index 4504f65..f572085 100644 --- a/sparkybe-onap-application/config/spring-beans/sparky-global-search.xml +++ b/sparkybe-onap-application/config/spring-beans/sparky-global-search.xml @@ -22,5 +22,6 @@ <bean id="searchServiceAdapter" class="org.onap.aai.sparky.search.SearchServiceAdapter"> <constructor-arg ref="searchServiceRestEndpointConfig" /> <constructor-arg name="serviceApiVersion" value="v1" /> + <property name="appPartnerName" value="${searchservice.appPartnerName:AAI-UI}" /> </bean> </beans>
\ No newline at end of file diff --git a/sparkybe-onap-application/config/spring-beans/sparky-personalization-service.xml b/sparkybe-onap-application/config/spring-beans/sparky-personalization-service.xml new file mode 100644 index 0000000..6ad3f8d --- /dev/null +++ b/sparkybe-onap-application/config/spring-beans/sparky-personalization-service.xml @@ -0,0 +1,19 @@ +<beans xmlns="http://www.springframework.org/schema/beans" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation=" + http://www.springframework.org/schema/beans + http://www.springframework.org/schema/beans/spring-beans.xsd"> + + + <bean id="personalizationConfig" + class="org.onap.aai.sparky.personalization.config.PersonalizationConfig"> + <property name="topLeftHeader" value="${personalization.topLeftHeader:A&AI}" /> + <property name="htmlDocumentTitle" value="${personalization.htmlDocumentTitle:A&AI}" /> + </bean> + + <bean id="personalizationServiceProcessor" + class="org.onap.aai.sparky.personalization.PersonalizationServiceProvider"> + <constructor-arg ref="personalizationConfig" /> + </bean> + +</beans>
\ No newline at end of file diff --git a/sparkybe-onap-application/config/spring-beans/sparky-resources.xml b/sparkybe-onap-application/config/spring-beans/sparky-resources.xml index 6f29868..5788ce4 100644 --- a/sparkybe-onap-application/config/spring-beans/sparky-resources.xml +++ b/sparkybe-onap-application/config/spring-beans/sparky-resources.xml @@ -25,6 +25,9 @@ <constructor-arg ref="oxmModelLoader" /> <constructor-arg ref="oxmEntityLookup" /> <constructor-arg ref="aaiRestEndpointConfig" /> + <constructor-arg name="domain" value="${resources.domain:aai}" /> + <property name="appPartnerName" value="${resources.appPartnerName:AAI-UI}" /> + <property name="syncPartnerName" value="${resources.syncPartnerName:AAI-UI-SYNC}" /> </bean> </beans> diff --git a/sparkybe-onap-application/config/spring-beans/sparky-search-service.xml b/sparkybe-onap-application/config/spring-beans/sparky-search-service.xml index c8d20c6..3a30161 100644 --- a/sparkybe-onap-application/config/spring-beans/sparky-search-service.xml +++ b/sparkybe-onap-application/config/spring-beans/sparky-search-service.xml @@ -22,5 +22,6 @@ <bean id="searchServiceAdapter" class="org.onap.aai.sparky.search.SearchServiceAdapter"> <constructor-arg ref="searchServiceRestEndpointConfig" /> <constructor-arg name="serviceApiVersion" value="v1" /> + <property name="appPartnerName" value="${searchservice.appPartnerName:AAI-UI}" /> </bean> </beans>
\ No newline at end of file diff --git a/sparkybe-onap-application/config/spring-beans/sparky-view-inspect-with-resources.xml b/sparkybe-onap-application/config/spring-beans/sparky-view-inspect-with-resources.xml index 6869b70..7148c56 100644 --- a/sparkybe-onap-application/config/spring-beans/sparky-view-inspect-with-resources.xml +++ b/sparkybe-onap-application/config/spring-beans/sparky-view-inspect-with-resources.xml @@ -15,20 +15,7 @@ <property name="numOfThreadsToFetchNodeIntegrity" value="20" /> <property name="makeAllNeighborsBidirectional" value="false" /> <property name="resourceLoader" ref="sparkyResourceLoader" /> - - <property name="shallowEntities"> - <list value-type="java.lang.String"> - <value>cloud-region</value> - <value>complex</value> - <value>vnf-image</value> - <value>image</value> - <value>flavor</value> - <value>availability-zone</value> - <value>tenant</value> - <value>network-profile</value> - <value>l-interface</value> - </list> - </property> + <property name="delimitedShallowEntities" value="${resources.delimitedShallowEntities:cloud-region,complex,vnf-image,image,flavor,availability-zone,tenant,network-profile,l-interface}" /> </bean> diff --git a/sparkybe-onap-application/src/main/java/org/onap/aai/sparky/camel/PersonalizationRouter.java b/sparkybe-onap-application/src/main/java/org/onap/aai/sparky/camel/PersonalizationRouter.java new file mode 100644 index 0000000..9cd587e --- /dev/null +++ b/sparkybe-onap-application/src/main/java/org/onap/aai/sparky/camel/PersonalizationRouter.java @@ -0,0 +1,37 @@ +/** + * ============LICENSE_START======================================================= + * SPARKY (AAI UI service) + * ================================================================================ + * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved. + * Copyright © 2017-2018 Amdocs + * ================================================================================ + * 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.sparky.camel; + +import org.apache.camel.spring.SpringRouteBuilder; +import org.springframework.stereotype.Component; + +@Component +public class PersonalizationRouter extends SpringRouteBuilder { + + @Override + public void configure() throws Exception { + + rest().get("getPersonalizedValues") + .to("bean:personalizationServiceProcessor?method=getPersonalizedValues"); + + } + +}
\ No newline at end of file diff --git a/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/aggregation/sync/AggregationSynchronizer.java b/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/aggregation/sync/AggregationSynchronizer.java index 0b9733f..dc6bdc0 100644 --- a/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/aggregation/sync/AggregationSynchronizer.java +++ b/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/aggregation/sync/AggregationSynchronizer.java @@ -478,7 +478,7 @@ public class AggregationSynchronizer extends AbstractEntitySynchronizer aaiWorkOnHand.incrementAndGet(); - supplyAsync(new PerformActiveInventoryRetrieval(txn, aaiAdapter), aaiExecutor) + supplyAsync(new PerformActiveInventoryRetrieval(txn, aaiAdapter,"sync"), aaiExecutor) .whenComplete((result, error) -> { aaiWorkOnHand.decrementAndGet(); diff --git a/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/autosuggestion/sync/AutosuggestionSynchronizer.java b/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/autosuggestion/sync/AutosuggestionSynchronizer.java index 583f260..0cb7922 100644 --- a/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/autosuggestion/sync/AutosuggestionSynchronizer.java +++ b/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/autosuggestion/sync/AutosuggestionSynchronizer.java @@ -158,6 +158,7 @@ public class AutosuggestionSynchronizer extends AbstractEntitySynchronizer suggestionEntityLookup.getSuggestionSearchEntityDescriptors(); if (descriptorMap.isEmpty()) { + this.allWorkEnumerated = true; LOG.error(AaiUiMsgs.ERROR_LOADING_OXM_SUGGESTIBLE_ENTITIES); LOG.info(AaiUiMsgs.ERROR_LOADING_OXM_SUGGESTIBLE_ENTITIES); return OperationState.ERROR; @@ -335,7 +336,7 @@ public class AutosuggestionSynchronizer extends AbstractEntitySynchronizer aaiWorkOnHand.incrementAndGet(); - supplyAsync(new PerformActiveInventoryRetrieval(txn, aaiAdapter), aaiExecutor) + supplyAsync(new PerformActiveInventoryRetrieval(txn, aaiAdapter,"sync"), aaiExecutor) .whenComplete((result, error) -> { aaiWorkOnHand.decrementAndGet(); diff --git a/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/crossentityreference/sync/CrossEntityReferenceSynchronizer.java b/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/crossentityreference/sync/CrossEntityReferenceSynchronizer.java index cf7908b..9481173 100644 --- a/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/crossentityreference/sync/CrossEntityReferenceSynchronizer.java +++ b/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/crossentityreference/sync/CrossEntityReferenceSynchronizer.java @@ -320,7 +320,7 @@ public class CrossEntityReferenceSynchronizer extends AbstractEntitySynchronizer aaiWorkOnHand.incrementAndGet(); - supplyAsync(new PerformActiveInventoryRetrieval(txn, aaiAdapter), aaiExecutor) + supplyAsync(new PerformActiveInventoryRetrieval(txn, aaiAdapter,"sync"), aaiExecutor) .whenComplete((result, error) -> { aaiWorkOnHand.decrementAndGet(); @@ -534,7 +534,7 @@ public class CrossEntityReferenceSynchronizer extends AbstractEntitySynchronizer OperationResult aaiQueryResult = aaiAdapter.queryActiveInventoryWithRetries( genericQueryStr, "application/json", - aaiAdapter.getEndpointConfig().getNumRequestRetries()); + aaiAdapter.getEndpointConfig().getNumRequestRetries(),"sync"); aaiWorkOnHand.decrementAndGet(); diff --git a/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/dal/ActiveInventoryAdapter.java b/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/dal/ActiveInventoryAdapter.java index bd00d20..ebcc56a 100644 --- a/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/dal/ActiveInventoryAdapter.java +++ b/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/dal/ActiveInventoryAdapter.java @@ -69,12 +69,19 @@ public class ActiveInventoryAdapter { private static final String TRANSACTION_ID_PREFIX = "txnId-"; private static final String UI_APP_NAME = "AAI-UI"; + private static final String UI_REQUEST_TYPE = "req"; private OxmModelLoader oxmModelLoader; private OxmEntityLookup oxmEntityLookup; private RestEndpointConfig endpointConfig; private RestClient restClient; + private String domain; + + + private String appPartnerName = ""; + private String syncPartnerName = ""; + private Map<String, List<String>> messageHeaders; /** * Instantiates a new active inventory adapter. @@ -83,12 +90,13 @@ public class ActiveInventoryAdapter { */ public ActiveInventoryAdapter(OxmModelLoader oxmModelLoader, OxmEntityLookup oxmEntityLookup, - RestEndpointConfig endpointConfig) + RestEndpointConfig endpointConfig,String domain) throws ElasticSearchOperationException, IOException, RestClientConstructionException { this.oxmModelLoader = oxmModelLoader; this.oxmEntityLookup = oxmEntityLookup; this.endpointConfig = endpointConfig; + this.domain = domain; /* * Add support for de-obfuscating basic auth password (if obfuscated) @@ -107,13 +115,47 @@ public class ActiveInventoryAdapter { this.restClient = RestClientFactory.buildClient(endpointConfig); } + + public String getAppPartnerName() { + return appPartnerName; + } + + public void setAppPartnerName(String appPartnerName) { + this.appPartnerName = appPartnerName; + } + + public String getSyncPartnerName() { + return syncPartnerName; + } + + public void setSyncPartnerName(String syncPartnerName) { + this.syncPartnerName = syncPartnerName; + } protected Map<String, List<String>> getMessageHeaders() { Map<String, List<String>> headers = new HashMap<String, List<String>>(); headers.putIfAbsent(HEADER_FROM_APP_ID, new ArrayList<String>()); - headers.get(HEADER_FROM_APP_ID).add(UI_APP_NAME); + headers.get(HEADER_FROM_APP_ID).add(appPartnerName); + + headers.putIfAbsent(HEADER_TRANS_ID, new ArrayList<String>()); + headers.get(HEADER_TRANS_ID).add(TRANSACTION_ID_PREFIX + NodeUtils.getRandomTxnId()); + + if (endpointConfig.getRestAuthenticationMode() == RestAuthenticationMode.SSL_BASIC) { + headers.putIfAbsent(HEADER_AUTHORIZATION, new ArrayList<String>()); + headers.get(HEADER_AUTHORIZATION).add(getBasicAuthenticationCredentials()); + } + + return headers; + } + + protected Map<String, List<String>> getSyncMessageHeaders() { + + Map<String, List<String>> headers = new HashMap<String, List<String>>(); + + headers.putIfAbsent(HEADER_FROM_APP_ID, new ArrayList<String>()); + headers.get(HEADER_FROM_APP_ID).add(syncPartnerName); headers.putIfAbsent(HEADER_TRANS_ID, new ArrayList<String>()); headers.get(HEADER_TRANS_ID).add(TRANSACTION_ID_PREFIX + NodeUtils.getRandomTxnId()); @@ -150,7 +192,7 @@ public class ActiveInventoryAdapter { throw new RuntimeException("Unable to resolve aai version."); } - return "/aai/" + versionStr.toLowerCase(); + return "/" + domain + "/" + versionStr.toLowerCase(); } @@ -271,7 +313,7 @@ public class ActiveInventoryAdapter { } return queryActiveInventoryWithRetries(link, "application/json", - endpointConfig.getNumRequestRetries()); + endpointConfig.getNumRequestRetries(),"sync"); } @@ -310,9 +352,14 @@ public class ActiveInventoryAdapter { * @return the operation result */ // package protected for test classes instead of private - OperationResult queryActiveInventory(String url, String acceptContentType) { + OperationResult queryActiveInventory(String url, String acceptContentType, String uiRequestType) { - return restClient.get(url, getMessageHeaders(), MediaType.APPLICATION_JSON_TYPE); + if (uiRequestType == UI_REQUEST_TYPE) { + messageHeaders = getMessageHeaders(); + } else { + messageHeaders = getSyncMessageHeaders(); + } + return restClient.get(url, messageHeaders, MediaType.APPLICATION_JSON_TYPE); } @@ -325,7 +372,7 @@ public class ActiveInventoryAdapter { } public OperationResult queryActiveInventoryWithRetries(String url, String responseType, - int numRetries) { + int numRetries,String uiRequestType) { OperationResult result = null; @@ -333,7 +380,7 @@ public class ActiveInventoryAdapter { LOG.debug(AaiUiMsgs.QUERY_AAI_RETRY_SEQ, url, String.valueOf(retryCount + 1)); - result = queryActiveInventory(url, responseType); + result = queryActiveInventory(url, responseType,uiRequestType); /** * Record number of times we have attempted the request to later summarize how many times we @@ -415,5 +462,9 @@ public class ActiveInventoryAdapter { characters such as '?', '&', etc. remain intact as needed by the synchronizer */ return (builder.build().toString() + (includeQueryParams ? queryParams : "")); } + + public String getDomain() { + return domain; + } } diff --git a/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/dal/GizmoAdapter.java b/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/dal/GizmoAdapter.java index a888c8b..c958054 100644 --- a/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/dal/GizmoAdapter.java +++ b/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/dal/GizmoAdapter.java @@ -50,229 +50,231 @@ import org.onap.aai.sparky.util.NodeUtils; public class GizmoAdapter { - private static final Logger LOG = LoggerFactory.getInstance().getLogger(GizmoAdapter.class); + private static final Logger LOG = LoggerFactory.getInstance().getLogger(GizmoAdapter.class); - private static final String HEADER_TRANS_ID = "X-TransactionId"; - private static final String HEADER_FROM_APP_ID = "X-FromAppId"; - private static final String HEADER_AUTHORIZATION = "Authorization"; + private static final String HEADER_TRANS_ID = "X-TransactionId"; + private static final String HEADER_FROM_APP_ID = "X-FromAppId"; + private static final String HEADER_AUTHORIZATION = "Authorization"; - private static final String HTTP_SCHEME = "http"; - private static final String HTTPS_SCHEME = "https"; + private static final String HTTP_SCHEME = "http"; + private static final String HTTPS_SCHEME = "https"; - private static final String TRANSACTION_ID_PREFIX = "txnId-"; - private static final String UI_APP_NAME = "AAI-UI"; + private static final String TRANSACTION_ID_PREFIX = "txnId-"; + private static final String UI_APP_NAME = "AAI-UI"; - private OxmModelLoader oxmModelLoader; + private OxmModelLoader oxmModelLoader; - private RestEndpointConfig endpointConfig; + private RestEndpointConfig endpointConfig; - private RestClient restClient; + private RestClient restClient; - private String inventoryBasePath; - private String relationshipsBasePath; + private String inventoryBasePath; + private String relationshipsBasePath; + private String appPartnerName = ""; - /** - * Instantiates a new active inventory adapter. - * - * @throws RestClientConstructionException - * - */ + /** + * Instantiates a new active inventory adapter. + * + * @throws RestClientConstructionException + * + */ - public GizmoAdapter(OxmModelLoader oxmModelLoader, RestEndpointConfig endpointConfig) - throws ElasticSearchOperationException, IOException, RestClientConstructionException { + public GizmoAdapter(OxmModelLoader oxmModelLoader, RestEndpointConfig endpointConfig) + throws ElasticSearchOperationException, IOException, RestClientConstructionException { - this.oxmModelLoader = oxmModelLoader; - this.endpointConfig = endpointConfig; - this.restClient = RestClientFactory.buildClient(endpointConfig); + this.oxmModelLoader = oxmModelLoader; + this.endpointConfig = endpointConfig; + this.restClient = RestClientFactory.buildClient(endpointConfig); - } + } + + public String getAppPartnerName() { + return appPartnerName; + } + + public void setAppPartnerName(String appPartnerName) { + this.appPartnerName = appPartnerName; + } - public String getRelationshipsBasePath() { - return relationshipsBasePath; - } - public void setRelationshipsBasePath(String relationshipsBasePath) { - this.relationshipsBasePath = relationshipsBasePath; - } + public String getRelationshipsBasePath() { + return relationshipsBasePath; + } - public String getInventoryBasePath() { - return inventoryBasePath; - } + public void setRelationshipsBasePath(String relationshipsBasePath) { + this.relationshipsBasePath = relationshipsBasePath; + } - public void setInventoryBasePath(String inventoryBasePath) { - this.inventoryBasePath = inventoryBasePath; - } + public String getInventoryBasePath() { + return inventoryBasePath; + } + + public void setInventoryBasePath(String inventoryBasePath) { + this.inventoryBasePath = inventoryBasePath; + } - public String getFullInventoryUrl(String resourceUrl) throws Exception { - final String host = endpointConfig.getEndpointIpAddress(); - final String port = endpointConfig.getEndpointServerPort(); - final String basePath = getInventoryBasePath(); - return String.format("https://%s:%s%s%s", host, port, basePath, resourceUrl); - } + public String getFullInventoryUrl(String resourceUrl) throws Exception { + final String host = endpointConfig.getEndpointIpAddress(); + final String port = endpointConfig.getEndpointServerPort(); + final String basePath = getInventoryBasePath(); + return String.format("https://%s:%s%s%s", host, port, basePath, resourceUrl); + } - public String addServerDetailsToUrl(String resourceUrl) throws Exception { - final String host = endpointConfig.getEndpointIpAddress(); - final String port = endpointConfig.getEndpointServerPort(); - return String.format("https://%s:%s/%s", host, port, resourceUrl); - } + public String addServerDetailsToUrl(String resourceUrl) throws Exception { + final String host = endpointConfig.getEndpointIpAddress(); + final String port = endpointConfig.getEndpointServerPort(); + return String.format("https://%s:%s/%s", host, port, resourceUrl); + } - public String getFullRelationshipUrl(String resourceUrl) throws Exception { - final String host = endpointConfig.getEndpointIpAddress(); - final String port = endpointConfig.getEndpointServerPort(); - final String basePath = getRelationshipsBasePath(); - return String.format("https://%s:%s%s%s", host, port, basePath, resourceUrl); - } + public String getFullRelationshipUrl(String resourceUrl) throws Exception { + final String host = endpointConfig.getEndpointIpAddress(); + final String port = endpointConfig.getEndpointServerPort(); + final String basePath = getRelationshipsBasePath(); + return String.format("https://%s:%s%s%s", host, port, basePath, resourceUrl); + } - protected Map<String, List<String>> getMessageHeaders() { + protected Map<String, List<String>> getMessageHeaders() { - Map<String, List<String>> headers = new HashMap<String, List<String>>(); + Map<String, List<String>> headers = new HashMap<String, List<String>>(); - headers.putIfAbsent(HEADER_FROM_APP_ID, new ArrayList<String>()); - headers.get(HEADER_FROM_APP_ID).add(UI_APP_NAME); + headers.putIfAbsent(HEADER_FROM_APP_ID, new ArrayList<String>()); + headers.get(HEADER_FROM_APP_ID).add(appPartnerName); - headers.putIfAbsent(HEADER_TRANS_ID, new ArrayList<String>()); - headers.get(HEADER_TRANS_ID).add(TRANSACTION_ID_PREFIX + NodeUtils.getRandomTxnId()); + headers.putIfAbsent(HEADER_TRANS_ID, new ArrayList<String>()); + headers.get(HEADER_TRANS_ID).add(TRANSACTION_ID_PREFIX + NodeUtils.getRandomTxnId()); - if (endpointConfig.getRestAuthenticationMode() == RestAuthenticationMode.SSL_BASIC) { + if (endpointConfig.getRestAuthenticationMode() == RestAuthenticationMode.SSL_BASIC) { - headers.putIfAbsent(HEADER_AUTHORIZATION, new ArrayList<String>()); - headers.get(HEADER_AUTHORIZATION).add(getBasicAuthenticationCredentials()); + headers.putIfAbsent(HEADER_AUTHORIZATION, new ArrayList<String>()); + headers.get(HEADER_AUTHORIZATION).add(getBasicAuthenticationCredentials()); - } + } - return headers; - } + return headers; + } - protected String getBasicAuthenticationCredentials() { - String usernameAndPassword = String.join(":", endpointConfig.getBasicAuthUserName(), - endpointConfig.getBasicAuthPassword()); - return "Basic " + java.util.Base64.getEncoder().encodeToString(usernameAndPassword.getBytes()); - } + protected String getBasicAuthenticationCredentials() { + String usernameAndPassword = String.join(":", endpointConfig.getBasicAuthUserName(), + endpointConfig.getBasicAuthPassword()); + return "Basic " + java.util.Base64.getEncoder().encodeToString(usernameAndPassword.getBytes()); + } - /** - * Our retry conditions should be very specific. - * - * @param r - * the r - * @return true, if successful - */ - private boolean shouldRetryRequest(OperationResult r) { + /** + * Our retry conditions should be very specific. + * + * @param r the r + * @return true, if successful + */ + private boolean shouldRetryRequest(OperationResult r) { - if (r == null) { - return true; - } + if (r == null) { + return true; + } - int rc = r.getResultCode(); + int rc = r.getResultCode(); - if (rc == 200) { - return false; - } + if (rc == 200) { + return false; + } - if (rc == 404) { - return false; - } + if (rc == 404) { + return false; + } - return true; + return true; - } + } - /** - * Query active inventory. - * - * @param url - * the url - * @param acceptContentType - * the accept content type - * @return the operation result - */ - OperationResult queryGizmo(String url, String acceptContentType) { + /** + * Query active inventory. + * + * @param url the url + * @param acceptContentType the accept content type + * @return the operation result + */ + OperationResult queryGizmo(String url, String acceptContentType) { - return restClient.get(url, getMessageHeaders(), MediaType.APPLICATION_JSON_TYPE); + return restClient.get(url, getMessageHeaders(), MediaType.APPLICATION_JSON_TYPE); - } + } - public RestEndpointConfig getEndpointConfig() { - return endpointConfig; - } + public RestEndpointConfig getEndpointConfig() { + return endpointConfig; + } - public void setEndpointConfig(RestEndpointConfig endpointConfig) { - this.endpointConfig = endpointConfig; - } + public void setEndpointConfig(RestEndpointConfig endpointConfig) { + this.endpointConfig = endpointConfig; + } - public OperationResult queryGizmoWithRetries(String url, String responseType, int numRetries) { + public OperationResult queryGizmoWithRetries(String url, String responseType, int numRetries) { - OperationResult result = null; + OperationResult result = null; - for (int retryCount = 0; retryCount < numRetries; retryCount++) { + for (int retryCount = 0; retryCount < numRetries; retryCount++) { - LOG.debug(AaiUiMsgs.QUERY_AAI_RETRY_SEQ, url, String.valueOf(retryCount + 1)); + LOG.debug(AaiUiMsgs.QUERY_AAI_RETRY_SEQ, url, String.valueOf(retryCount + 1)); - result = queryGizmo(url, responseType); + result = queryGizmo(url, responseType); - /** - * Record number of times we have attempted the request to later - * summarize how many times we are generally retrying over thousands - * of messages in a sync. - * - * If the number of retries is surprisingly high, then we need to - * understand why that is as the number of retries is also causing a - * heavier load on AAI beyond the throttling controls we already - * have in place in term of the transaction rate controller and - * number of parallelized threads per task processor. - */ + /** + * Record number of times we have attempted the request to later summarize how many times we + * are generally retrying over thousands of messages in a sync. + * + * If the number of retries is surprisingly high, then we need to understand why that is as + * the number of retries is also causing a heavier load on AAI beyond the throttling controls + * we already have in place in term of the transaction rate controller and number of + * parallelized threads per task processor. + */ - result.setNumRetries(retryCount); + result.setNumRetries(retryCount); - if (!shouldRetryRequest(result)) { + if (!shouldRetryRequest(result)) { - result.setFromCache(false); - LOG.debug(AaiUiMsgs.QUERY_AAI_RETRY_DONE_SEQ, url, String.valueOf(retryCount + 1)); + result.setFromCache(false); + LOG.debug(AaiUiMsgs.QUERY_AAI_RETRY_DONE_SEQ, url, String.valueOf(retryCount + 1)); - return result; - } + return result; + } - try { - /* - * Sleep between re-tries to be nice to the target system. - */ - Thread.sleep(50); - } catch (InterruptedException exc) { - LOG.error(AaiUiMsgs.QUERY_AAI_WAIT_INTERRUPTION, exc.getLocalizedMessage()); - Thread.currentThread().interrupt(); - break; - } - LOG.error(AaiUiMsgs.QUERY_AAI_RETRY_FAILURE_WITH_SEQ, url, String.valueOf(retryCount + 1)); + try { + /* + * Sleep between re-tries to be nice to the target system. + */ + Thread.sleep(50); + } catch (InterruptedException exc) { + LOG.error(AaiUiMsgs.QUERY_AAI_WAIT_INTERRUPTION, exc.getLocalizedMessage()); + Thread.currentThread().interrupt(); + break; + } + LOG.error(AaiUiMsgs.QUERY_AAI_RETRY_FAILURE_WITH_SEQ, url, String.valueOf(retryCount + 1)); - } + } - LOG.info(AaiUiMsgs.QUERY_AAI_RETRY_MAXED_OUT, url); + LOG.info(AaiUiMsgs.QUERY_AAI_RETRY_MAXED_OUT, url); - return result; + return result; - } + } - /** - * This method adds a scheme, host and port (if missing) to the passed-in - * URI. If these parts of the URI are already present, they will not be - * duplicated. - * - * @param selflink - * The URI to repair - * @param queryParams - * The query parameters as a single string - * @return The corrected URI (i.e. includes a scheme/host/port) - */ + /** + * This method adds a scheme, host and port (if missing) to the passed-in URI. If these parts of + * the URI are already present, they will not be duplicated. + * + * @param selflink The URI to repair + * @param queryParams The query parameters as a single string + * @return The corrected URI (i.e. includes a scheme/host/port) + */ private String repairGizmoSelfLink(String baseUrlPath, String selfLink, String queryParams) { if (selfLink == null) { return selfLink; } - + if (selfLink.startsWith("http") || selfLink.startsWith("https")) { return selfLink; } - + UriBuilder builder = UriBuilder.fromPath(baseUrlPath + "/" + selfLink) .host(endpointConfig.getEndpointIpAddress()) .port(Integer.parseInt(endpointConfig.getEndpointServerPort())); @@ -300,7 +302,7 @@ public class GizmoAdapter { return (builder.build().toString() + (includeQueryParams ? queryParams : "")); } - + public String repairRelationshipSelfLink(String selflink, String queryParams) { return repairGizmoSelfLink(relationshipsBasePath, selflink, queryParams); } @@ -309,25 +311,27 @@ public class GizmoAdapter { return repairGizmoSelfLink(inventoryBasePath, selflink, queryParams); } - public OperationResult getSelfLinksByEntityType(String entityType) throws Exception { - - if (entityType == null) { - throw new NullPointerException("Failed to getSelfLinksByEntityType() because entityType is null"); - } - - String link = getFullInventoryUrl(entityType); - - return queryGizmoWithRetries(link, "application/json", endpointConfig.getNumRequestRetries()); - - } - - public static String extractResourcePath(String selflink) { - try { - return new URI(selflink).getRawPath(); - } catch (URISyntaxException uriSyntaxException) { - LOG.error(AaiUiMsgs.ERROR_EXTRACTING_RESOURCE_PATH_FROM_LINK, uriSyntaxException.getMessage()); - return selflink; - } - } + public OperationResult getSelfLinksByEntityType(String entityType) throws Exception { + + if (entityType == null) { + throw new NullPointerException( + "Failed to getSelfLinksByEntityType() because entityType is null"); + } + + String link = getFullInventoryUrl(entityType); + + return queryGizmoWithRetries(link, "application/json", endpointConfig.getNumRequestRetries()); + + } + + public static String extractResourcePath(String selflink) { + try { + return new URI(selflink).getRawPath(); + } catch (URISyntaxException uriSyntaxException) { + LOG.error(AaiUiMsgs.ERROR_EXTRACTING_RESOURCE_PATH_FROM_LINK, + uriSyntaxException.getMessage()); + return selflink; + } + } } diff --git a/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/editattributes/AttributeUpdater.java b/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/editattributes/AttributeUpdater.java index 9371a4a..23928a5 100644 --- a/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/editattributes/AttributeUpdater.java +++ b/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/editattributes/AttributeUpdater.java @@ -133,16 +133,18 @@ public class AttributeUpdater { private UserValidator validator; private OxmModelLoader oxmModelLoader; private OxmEntityLookup oxmEntityLookup; + private String domain; /** * Instantiates a new attribute updater. * @throws AttributeUpdateException */ - public AttributeUpdater(OxmModelLoader oxmModelLoader, OxmEntityLookup oxmEntityLookup, ActiveInventoryAdapter activeInventoryAdapter) throws AttributeUpdateException { + public AttributeUpdater(OxmModelLoader oxmModelLoader, OxmEntityLookup oxmEntityLookup, ActiveInventoryAdapter activeInventoryAdapter,String domain) throws AttributeUpdateException { super(); this.oxmModelLoader = oxmModelLoader; this.oxmEntityLookup = oxmEntityLookup; this.aaiAdapter = activeInventoryAdapter; + this.domain = domain; try { this.validator = new UserValidator(); @@ -159,7 +161,7 @@ public class AttributeUpdater { versionStr = String.valueOf(oxmModelLoader.getOxmApiVersion()); } - return "/aai/v" + versionStr; + return "/" + domain + "/v" + versionStr; } diff --git a/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/personalization/PersonalizationServiceProvider.java b/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/personalization/PersonalizationServiceProvider.java new file mode 100644 index 0000000..69298a9 --- /dev/null +++ b/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/personalization/PersonalizationServiceProvider.java @@ -0,0 +1,76 @@ +/** + * ============LICENSE_START======================================================= + * org.onap.aai + * ================================================================================ + * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved. + * Copyright © 2017-2018 Amdocs + * ================================================================================ + * 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.sparky.personalization; + +import javax.servlet.http.HttpServletRequest; + +import org.apache.camel.Exchange; +import org.json.JSONObject; +import org.onap.aai.cl.api.Logger; +import org.onap.aai.cl.eelf.LoggerFactory; +import org.onap.aai.restclient.client.OperationResult; +import org.onap.aai.sparky.logging.AaiUiMsgs; +import org.onap.aai.sparky.logging.util.ServletUtils; +import org.onap.aai.sparky.personalization.config.PersonalizationConfig; + +public class PersonalizationServiceProvider { + + private static final String EMPTY_RESPONSE = "{}"; + + private static final Logger LOG = + LoggerFactory.getInstance().getLogger(PersonalizationServiceProvider.class); + + PersonalizationConfig personalizationConfig; + + + public PersonalizationServiceProvider(PersonalizationConfig personalizationConfig) { + this.personalizationConfig = personalizationConfig; + } + + + public void getPersonalizedValues(Exchange exchange) { + + HttpServletRequest request = exchange.getIn().getBody(HttpServletRequest.class); + ServletUtils.setUpMdcContext(exchange, request); + + OperationResult personalizedValuesResult = new OperationResult(); + + try { + personalizedValuesResult.setResultCode(200); + JSONObject personalizedValuesResponse = new JSONObject(); + personalizedValuesResponse.put("topLeftHeader", personalizationConfig.getTopLeftHeader()); + personalizedValuesResponse.put("htmlDocumentTitle", + personalizationConfig.getHtmlDocumentTitle()); + personalizedValuesResult.setResult(personalizedValuesResponse.toString()); + + } catch (Exception exc) { + personalizedValuesResult.setResultCode(500); + personalizedValuesResult.setResult(EMPTY_RESPONSE); + LOG.error(AaiUiMsgs.FAILURE_TO_PROCESS_REQUEST, + "Exception thrown during personalization processing: " + exc.getLocalizedMessage()); + } + + exchange.getOut().setBody(personalizedValuesResult.getResult()); + + + } + +} diff --git a/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/personalization/config/PersonalizationConfig.java b/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/personalization/config/PersonalizationConfig.java new file mode 100644 index 0000000..e92372c --- /dev/null +++ b/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/personalization/config/PersonalizationConfig.java @@ -0,0 +1,42 @@ +/** + * ============LICENSE_START======================================================= + * org.onap.aai + * ================================================================================ + * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved. + * Copyright © 2017-2018 Amdocs + * ================================================================================ + * 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.sparky.personalization.config; + +public class PersonalizationConfig { + private String topLeftHeader = ""; + private String htmlDocumentTitle = ""; + + public String getHtmlDocumentTitle() { + return htmlDocumentTitle; + } + + public void setHtmlDocumentTitle(String htmlDocumentTitle) { + this.htmlDocumentTitle = htmlDocumentTitle; + } + + public String getTopLeftHeader() { + return topLeftHeader; + } + + public void setTopLeftHeader(String topLeftHeader) { + this.topLeftHeader = topLeftHeader; + } +} diff --git a/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/search/SearchServiceAdapter.java b/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/search/SearchServiceAdapter.java index a22170a..a00aa75 100644 --- a/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/search/SearchServiceAdapter.java +++ b/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/search/SearchServiceAdapter.java @@ -54,6 +54,7 @@ public class SearchServiceAdapter { private RestClient client; private RestEndpointConfig endpointConfig; private String serviceApiVersion; + private String appPartnerName = ""; private Map<String, List<String>> commonHeaders; @@ -69,11 +70,19 @@ public class SearchServiceAdapter { commonHeaders = new HashMap<String, List<String>>(); commonHeaders.put("Accept", Arrays.asList("application/json")); - commonHeaders.put(Headers.FROM_APP_ID, Arrays.asList("AAI-UI")); + commonHeaders.put(Headers.FROM_APP_ID, Arrays.asList(appPartnerName)); this.serviceApiVersion = serviceApiVersion; this.endpointConfig = endpointConfig; } + + public String getAppPartnerName() { + return appPartnerName; + } + + public void setAppPartnerName(String appPartnerName) { + this.appPartnerName = appPartnerName; + } public String getServiceApiVersion() { return serviceApiVersion; diff --git a/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/sync/task/PerformActiveInventoryRetrieval.java b/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/sync/task/PerformActiveInventoryRetrieval.java index 3a60cca..4d6041e 100644 --- a/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/sync/task/PerformActiveInventoryRetrieval.java +++ b/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/sync/task/PerformActiveInventoryRetrieval.java @@ -46,6 +46,7 @@ public class PerformActiveInventoryRetrieval implements Supplier<NetworkTransact private NetworkTransaction txn; private ActiveInventoryAdapter aaiAdapter; private Map<String, String> contextMap; + private String uiRequestType; /** * Instantiates a new perform active inventory retrieval. @@ -54,10 +55,11 @@ public class PerformActiveInventoryRetrieval implements Supplier<NetworkTransact * @param aaiProvider the aai provider */ public PerformActiveInventoryRetrieval(NetworkTransaction txn, - ActiveInventoryAdapter aaiAdapter) { + ActiveInventoryAdapter aaiAdapter,String uiRequestType) { this.txn = txn; this.aaiAdapter = aaiAdapter; this.contextMap = MDC.getCopyOfContextMap(); + this.uiRequestType = uiRequestType; } /* (non-Javadoc) @@ -74,7 +76,7 @@ public class PerformActiveInventoryRetrieval implements Supplier<NetworkTransact try { final String absoluteSelfLink = aaiAdapter.repairSelfLink(txn.getLink(), txn.getQueryParameters()); - result = aaiAdapter.queryActiveInventoryWithRetries(absoluteSelfLink, "application/json", 5); + result = aaiAdapter.queryActiveInventoryWithRetries(absoluteSelfLink, "application/json", 5,uiRequestType); } catch (Exception exc) { logger.error(AaiUiMsgs.ERROR_GENERIC,"Failure to resolve self link from AAI. Error = " + exc.getMessage()); result = new OperationResult(500, diff --git a/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/util/NodeUtils.java b/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/util/NodeUtils.java index b75fa91..8772afa 100644 --- a/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/util/NodeUtils.java +++ b/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/util/NodeUtils.java @@ -70,7 +70,7 @@ import com.google.common.util.concurrent.ThreadFactoryBuilder; public class NodeUtils { private static SecureRandom sRandom = new SecureRandom(); - private static final Pattern AAI_VERSION_PREFIX = Pattern.compile("/aai/v[0-9]+/(.*)"); + private static final Pattern URL_VERSION_PREFIX = Pattern.compile("/v[0-9]+/(.*)"); private static final Pattern OXM_VERSION_PREFIX = Pattern.compile(".*_v([0-9]+).*"); private static final Pattern GIZMO_VERSION_PREFIX = Pattern.compile("[/]*services/inventory/v[0-9]+/(.*)"); private static final Pattern GIZMO_RELATIONSHIP_VERSION_PREFIX = Pattern.compile("services/inventory/relationships/v[0-9]+/(.*)"); @@ -125,7 +125,7 @@ public class NodeUtils { String rawPath = new URI(selfLinkUri).getRawPath(); - Matcher m = AAI_VERSION_PREFIX.matcher(rawPath); + Matcher m = URL_VERSION_PREFIX.matcher(rawPath); if (m.matches()) { diff --git a/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/viewandinspect/config/SparkyConstants.java b/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/viewandinspect/config/SparkyConstants.java index 6dc8441..52714ff 100644 --- a/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/viewandinspect/config/SparkyConstants.java +++ b/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/viewandinspect/config/SparkyConstants.java @@ -91,7 +91,7 @@ public class SparkyConstants { // Injected Attributes public static String URI_ATTR_NAME = "uri"; - public static final String URI_VERSION_REGEX_PATTERN = "aai/v[\\d]+/"; + public static final String URI_VERSION_REGEX_PATTERN = "/v[\\d]+/"; public static final String getConfigPath(String configFile){ return CONFIG_HOME + FILESEP + configFile; diff --git a/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/viewandinspect/config/VisualizationConfigs.java b/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/viewandinspect/config/VisualizationConfigs.java index acca775..80328d3 100644 --- a/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/viewandinspect/config/VisualizationConfigs.java +++ b/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/viewandinspect/config/VisualizationConfigs.java @@ -21,6 +21,7 @@ package org.onap.aai.sparky.viewandinspect.config; import java.util.ArrayList; +import java.util.Arrays; import org.onap.aai.sparky.config.SparkyResourceLoader; @@ -61,6 +62,22 @@ public class VisualizationConfigs { public void setShallowEntities(ArrayList<String> shallowEntities) { this.shallowEntities = shallowEntities; } + + public void setDelimitedShallowEntities(String delimitedShallowEntites) { + + if (delimitedShallowEntites == null) { + this.shallowEntities = new ArrayList<>(); + return; + } + + try { + this.shallowEntities = + new ArrayList<String>(Arrays.asList(delimitedShallowEntites.split(","))); + } catch (Exception exc) { + this.shallowEntities = new ArrayList<>(); + } + + } /** * Make all neighbors bidirectional. diff --git a/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/viewandinspect/entity/ActiveInventoryNode.java b/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/viewandinspect/entity/ActiveInventoryNode.java index 4d83509..1a91a1b 100644 --- a/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/viewandinspect/entity/ActiveInventoryNode.java +++ b/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/viewandinspect/entity/ActiveInventoryNode.java @@ -31,8 +31,6 @@ import java.util.Map.Entry; import java.util.Set; import java.util.concurrent.ConcurrentLinkedDeque; import java.util.concurrent.atomic.AtomicBoolean; -import java.util.regex.Matcher; -import java.util.regex.Pattern; import org.onap.aai.cl.api.Logger; import org.onap.aai.cl.eelf.LoggerFactory; @@ -54,7 +52,6 @@ public class ActiveInventoryNode { private static final Logger LOG = LoggerFactory.getInstance().getLogger( ActiveInventoryNode.class); - private static final String URIRegexPattern = "aai/v[\\d]/"; public static final int DEFAULT_INIT_NODE_DEPTH = 1000; @@ -570,22 +567,6 @@ public class ActiveInventoryNode { } /** - * Calculate edit attribute uri. - * - * @param link the link - * @return the string - */ - public String calculateEditAttributeUri(String link) { - String uri = null; - Pattern pattern = Pattern.compile(URIRegexPattern); - Matcher matcher = pattern.matcher(link); - if (matcher.find()) { - uri = link.substring(matcher.end()); - } - return uri; - } - - /** * Analyze self link relationship list. * * @param jsonResult the json result diff --git a/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/viewandinspect/task/PerformNodeSelfLinkProcessingTask.java b/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/viewandinspect/task/PerformNodeSelfLinkProcessingTask.java index 797aa69..783bee4 100644 --- a/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/viewandinspect/task/PerformNodeSelfLinkProcessingTask.java +++ b/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/viewandinspect/task/PerformNodeSelfLinkProcessingTask.java @@ -106,7 +106,7 @@ public class PerformNodeSelfLinkProcessingTask implements Supplier<NodeProcessin try { opResult = aaiAdapter.queryActiveInventoryWithRetries(link, "application/json", - aaiAdapter.getEndpointConfig().getNumRequestRetries()); + aaiAdapter.getEndpointConfig().getNumRequestRetries(),"req"); } catch (Exception exc) { opResult = new OperationResult(); opResult.setResult(500, "Querying AAI with retry failed due to an exception."); diff --git a/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/viewandinspect/task/PerformSelfLinkDeterminationTask.java b/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/viewandinspect/task/PerformSelfLinkDeterminationTask.java index e16be76..75ae87d 100644 --- a/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/viewandinspect/task/PerformSelfLinkDeterminationTask.java +++ b/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/viewandinspect/task/PerformSelfLinkDeterminationTask.java @@ -72,7 +72,7 @@ public class PerformSelfLinkDeterminationTask implements Supplier<SelfLinkDeterm OperationResult opResult = null; try { opResult = aaiAdapter.queryActiveInventoryWithRetries(txn.getQueryString(), "application/json", - aaiAdapter.getEndpointConfig().getNumRequestRetries()); + aaiAdapter.getEndpointConfig().getNumRequestRetries(),"req"); } catch (Exception exc) { opResult = new OperationResult(); opResult.setResult(500, "Querying AAI with retry failed due to an exception."); diff --git a/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/viewinspect/sync/ViewInspectEntitySynchronizer.java b/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/viewinspect/sync/ViewInspectEntitySynchronizer.java index 79eded1..4877ad0 100644 --- a/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/viewinspect/sync/ViewInspectEntitySynchronizer.java +++ b/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/viewinspect/sync/ViewInspectEntitySynchronizer.java @@ -333,7 +333,7 @@ public class ViewInspectEntitySynchronizer extends AbstractEntitySynchronizer aaiWorkOnHand.incrementAndGet(); - supplyAsync(new PerformActiveInventoryRetrieval(txn, aaiAdapter), aaiExecutor) + supplyAsync(new PerformActiveInventoryRetrieval(txn, aaiAdapter,"sync"), aaiExecutor) .whenComplete((result, error) -> { aaiWorkOnHand.decrementAndGet(); diff --git a/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/autosuggestion/sync/AutosuggestionSynchronizerTest.java b/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/autosuggestion/sync/AutosuggestionSynchronizerTest.java index 8eaff79..8a83ca7 100644 --- a/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/autosuggestion/sync/AutosuggestionSynchronizerTest.java +++ b/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/autosuggestion/sync/AutosuggestionSynchronizerTest.java @@ -268,20 +268,20 @@ public class AutosuggestionSynchronizerTest { Mockito .when(aaiAdapter.queryActiveInventoryWithRetries( Matchers.contains("generic-vnf-1"), Mockito.anyString(), - Mockito.anyInt())) + Mockito.anyInt(),Mockito.anyString())) .thenReturn(new OperationResult(200, TestResourceLoader.getTestResourceDataJson( "/sync/aai/generic-vnf-generic-vnf-1_full_depth.json"))); Mockito .when(aaiAdapter.queryActiveInventoryWithRetries( Matchers.contains("generic-vnf-2"), Mockito.anyString(), - Mockito.anyInt())) + Mockito.anyInt(),Mockito.anyString())) .thenReturn(new OperationResult(200, TestResourceLoader.getTestResourceDataJson( "/sync/aai/generic-vnf-generic-vnf-2_full_depth.json"))); Mockito .when(aaiAdapter.queryActiveInventoryWithRetries(Matchers.contains("generic-vnf-3"), - Mockito.anyString(), Mockito.anyInt())) + Mockito.anyString(), Mockito.anyInt(),Mockito.anyString())) .thenReturn(new OperationResult(200, TestResourceLoader .getTestResourceDataJson("/sync/aai/generic-vnf-generic-vnf-3_full_depth.json"))); @@ -358,20 +358,20 @@ public class AutosuggestionSynchronizerTest { Mockito .when(aaiAdapter.queryActiveInventoryWithRetries( Matchers.contains("generic-vnf-1"), Mockito.anyString(), - Mockito.anyInt())) + Mockito.anyInt(),Mockito.anyString())) .thenReturn(new OperationResult(200, TestResourceLoader.getTestResourceDataJson( "/sync/aai/generic-vnf-generic-vnf-1_full_depth.json"))); Mockito .when(aaiAdapter.queryActiveInventoryWithRetries( Matchers.contains("generic-vnf-2"), Mockito.anyString(), - Mockito.anyInt())) + Mockito.anyInt(),Mockito.anyString())) .thenReturn(new OperationResult(200, TestResourceLoader.getTestResourceDataJson( "/sync/aai/generic-vnf-generic-vnf-2_full_depth.json"))); Mockito .when(aaiAdapter.queryActiveInventoryWithRetries(Matchers.contains("generic-vnf-3"), - Mockito.anyString(), Mockito.anyInt())) + Mockito.anyString(), Mockito.anyInt(),Mockito.anyString())) .thenReturn(new OperationResult(200, TestResourceLoader .getTestResourceDataJson("/sync/aai/generic-vnf-generic-vnf-3_full_depth.json"))); diff --git a/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/autosuggestion/sync/VnfAliasSuggestionSynchronizerTest.java b/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/autosuggestion/sync/VnfAliasSuggestionSynchronizerTest.java index e72b0df..3680c6f 100644 --- a/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/autosuggestion/sync/VnfAliasSuggestionSynchronizerTest.java +++ b/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/autosuggestion/sync/VnfAliasSuggestionSynchronizerTest.java @@ -228,19 +228,19 @@ public class VnfAliasSuggestionSynchronizerTest { Mockito .when(aaiAdapter.queryActiveInventoryWithRetries(Matchers.contains("generic-vnf-1"), - Mockito.anyString(), Mockito.anyInt())) + Mockito.anyString(), Mockito.anyInt(),Mockito.anyString())) .thenReturn(new OperationResult(200, TestResourceLoader .getTestResourceDataJson("/sync/aai/generic-vnf-generic-vnf-1_full_depth.json"))); Mockito .when(aaiAdapter.queryActiveInventoryWithRetries(Matchers.contains("generic-vnf-2"), - Mockito.anyString(), Mockito.anyInt())) + Mockito.anyString(), Mockito.anyInt(),Mockito.anyString())) .thenReturn(new OperationResult(200, TestResourceLoader .getTestResourceDataJson("/sync/aai/generic-vnf-generic-vnf-2_full_depth.json"))); Mockito .when(aaiAdapter.queryActiveInventoryWithRetries(Matchers.contains("generic-vnf-3"), - Mockito.anyString(), Mockito.anyInt())) + Mockito.anyString(), Mockito.anyInt(),Mockito.anyString())) .thenReturn(new OperationResult(200, TestResourceLoader .getTestResourceDataJson("/sync/aai/generic-vnf-generic-vnf-3_full_depth.json"))); @@ -310,19 +310,19 @@ public class VnfAliasSuggestionSynchronizerTest { Mockito .when(aaiAdapter.queryActiveInventoryWithRetries(Matchers.contains("generic-vnf-1"), - Mockito.anyString(), Mockito.anyInt())) + Mockito.anyString(), Mockito.anyInt(),Mockito.anyString())) .thenReturn(new OperationResult(200, TestResourceLoader .getTestResourceDataJson("/sync/aai/generic-vnf-generic-vnf-1_full_depth.json"))); Mockito .when(aaiAdapter.queryActiveInventoryWithRetries(Matchers.contains("generic-vnf-2"), - Mockito.anyString(), Mockito.anyInt())) + Mockito.anyString(), Mockito.anyInt(),Mockito.anyString())) .thenReturn(new OperationResult(200, TestResourceLoader .getTestResourceDataJson("/sync/aai/generic-vnf-generic-vnf-2_full_depth.json"))); Mockito .when(aaiAdapter.queryActiveInventoryWithRetries(Matchers.contains("generic-vnf-3"), - Mockito.anyString(), Mockito.anyInt())) + Mockito.anyString(), Mockito.anyInt(),Mockito.anyString())) .thenReturn(new OperationResult(200, TestResourceLoader .getTestResourceDataJson("/sync/aai/generic-vnf-generic-vnf-3_full_depth.json"))); diff --git a/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/crossentityreference/sync/CrossEntityReferenceSynchronizerTest.java b/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/crossentityreference/sync/CrossEntityReferenceSynchronizerTest.java index b275813..2366439 100644 --- a/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/crossentityreference/sync/CrossEntityReferenceSynchronizerTest.java +++ b/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/crossentityreference/sync/CrossEntityReferenceSynchronizerTest.java @@ -216,20 +216,20 @@ public class CrossEntityReferenceSynchronizerTest { Mockito .when(aaiAdapter.queryActiveInventoryWithRetries( Matchers.contains("service-subscription-2"), Mockito.anyString(), - Mockito.anyInt())) + Mockito.anyInt(),Mockito.anyString())) .thenReturn(new OperationResult(200, TestResourceLoader.getTestResourceDataJson( "/sync/aai/service-subscription-service-subscription-2.json"))); Mockito .when(aaiAdapter.queryActiveInventoryWithRetries( Matchers.contains("service-subscription-1"), Mockito.anyString(), - Mockito.anyInt())) + Mockito.anyInt(),Mockito.anyString())) .thenReturn(new OperationResult(200, TestResourceLoader.getTestResourceDataJson( "/sync/aai/service-subscription-service-subscription-1.json"))); Mockito .when(aaiAdapter.queryActiveInventoryWithRetries(Matchers.contains("service-subscription-3"), - Mockito.anyString(), Mockito.anyInt())) + Mockito.anyString(), Mockito.anyInt(),Mockito.anyString())) .thenReturn(new OperationResult(200, TestResourceLoader .getTestResourceDataJson("/sync/aai/service-subscription-service-subscription-3.json"))); @@ -298,70 +298,70 @@ public class CrossEntityReferenceSynchronizerTest { Mockito .when(aaiAdapter.queryActiveInventoryWithRetries( Matchers.contains("generic-query/service-instance-59"), Mockito.anyString(), - Mockito.anyInt())) + Mockito.anyInt(),Mockito.anyString())) .thenReturn(new OperationResult(200, TestResourceLoader.getTestResourceDataJson( "/sync/aai/aai-traversal/generic-query/service-instance-59.json"))); Mockito .when(aaiAdapter.queryActiveInventoryWithRetries( Matchers.contains("generic-query/service-instance-54"), Mockito.anyString(), - Mockito.anyInt())) + Mockito.anyInt(),Mockito.anyString())) .thenReturn(new OperationResult(200, TestResourceLoader.getTestResourceDataJson( "/sync/aai/aai-traversal/generic-query/service-instance-54.json"))); Mockito .when(aaiAdapter.queryActiveInventoryWithRetries( Matchers.contains("generic-query/service-instance-55"), Mockito.anyString(), - Mockito.anyInt())) + Mockito.anyInt(),Mockito.anyString())) .thenReturn(new OperationResult(200, TestResourceLoader.getTestResourceDataJson( "/sync/aai/aai-traversal/generic-query/service-instance-55.json"))); Mockito .when(aaiAdapter.queryActiveInventoryWithRetries( Matchers.contains("generic-query/service-instance-50"), Mockito.anyString(), - Mockito.anyInt())) + Mockito.anyInt(),Mockito.anyString())) .thenReturn(new OperationResult(200, TestResourceLoader.getTestResourceDataJson( "/sync/aai/aai-traversal/generic-query/service-instance-50.json"))); Mockito .when(aaiAdapter.queryActiveInventoryWithRetries( Matchers.contains("generic-query/service-instance-52"), Mockito.anyString(), - Mockito.anyInt())) + Mockito.anyInt(),Mockito.anyString())) .thenReturn(new OperationResult(200, TestResourceLoader.getTestResourceDataJson( "/sync/aai/aai-traversal/generic-query/service-instance-52.json"))); Mockito .when(aaiAdapter.queryActiveInventoryWithRetries( Matchers.contains("generic-query/service-instance-57"), Mockito.anyString(), - Mockito.anyInt())) + Mockito.anyInt(),Mockito.anyString())) .thenReturn(new OperationResult(200, TestResourceLoader.getTestResourceDataJson( "/sync/aai/aai-traversal/generic-query/service-instance-57.json"))); Mockito .when(aaiAdapter.queryActiveInventoryWithRetries( Matchers.contains("generic-query/service-instance-53"), Mockito.anyString(), - Mockito.anyInt())) + Mockito.anyInt(),Mockito.anyString())) .thenReturn(new OperationResult(200, TestResourceLoader.getTestResourceDataJson( "/sync/aai/aai-traversal/generic-query/service-instance-53.json"))); Mockito .when(aaiAdapter.queryActiveInventoryWithRetries( Matchers.contains("generic-query/service-instance-58"), Mockito.anyString(), - Mockito.anyInt())) + Mockito.anyInt(),Mockito.anyString())) .thenReturn(new OperationResult(200, TestResourceLoader.getTestResourceDataJson( "/sync/aai/aai-traversal/generic-query/service-instance-58.json"))); Mockito .when(aaiAdapter.queryActiveInventoryWithRetries( Matchers.contains("generic-query/service-instance-51"), Mockito.anyString(), - Mockito.anyInt())) + Mockito.anyInt(),Mockito.anyString())) .thenReturn(new OperationResult(200, TestResourceLoader.getTestResourceDataJson( "/sync/aai/aai-traversal/generic-query/service-instance-51.json"))); Mockito .when(aaiAdapter.queryActiveInventoryWithRetries( Matchers.contains("generic-query/service-instance-56"), Mockito.anyString(), - Mockito.anyInt())) + Mockito.anyInt(),Mockito.anyString())) .thenReturn(new OperationResult(200, TestResourceLoader.getTestResourceDataJson( "/sync/aai/aai-traversal/generic-query/service-instance-56.json"))); @@ -520,20 +520,20 @@ public class CrossEntityReferenceSynchronizerTest { Mockito .when(aaiAdapter.queryActiveInventoryWithRetries( Matchers.contains("service-subscription-2"), Mockito.anyString(), - Mockito.anyInt())) + Mockito.anyInt(),Mockito.anyString())) .thenReturn(new OperationResult(200, TestResourceLoader.getTestResourceDataJson( "/sync/aai/service-subscription-service-subscription-2.json"))); Mockito .when(aaiAdapter.queryActiveInventoryWithRetries( Matchers.contains("service-subscription-1"), Mockito.anyString(), - Mockito.anyInt())) + Mockito.anyInt(),Mockito.anyString())) .thenReturn(new OperationResult(200, TestResourceLoader.getTestResourceDataJson( "/sync/aai/service-subscription-service-subscription-1.json"))); Mockito .when(aaiAdapter.queryActiveInventoryWithRetries(Matchers.contains("service-subscription-3"), - Mockito.anyString(), Mockito.anyInt())) + Mockito.anyString(), Mockito.anyInt(),Mockito.anyString())) .thenReturn(new OperationResult(200, TestResourceLoader .getTestResourceDataJson("/sync/aai/service-subscription-service-subscription-3.json"))); @@ -602,70 +602,70 @@ public class CrossEntityReferenceSynchronizerTest { Mockito .when(aaiAdapter.queryActiveInventoryWithRetries( Matchers.contains("generic-query/service-instance-59"), Mockito.anyString(), - Mockito.anyInt())) + Mockito.anyInt(),Mockito.anyString())) .thenReturn(new OperationResult(200, TestResourceLoader.getTestResourceDataJson( "/sync/aai/aai-traversal/generic-query/service-instance-59.json"))); Mockito .when(aaiAdapter.queryActiveInventoryWithRetries( Matchers.contains("generic-query/service-instance-54"), Mockito.anyString(), - Mockito.anyInt())) + Mockito.anyInt(),Mockito.anyString())) .thenReturn(new OperationResult(200, TestResourceLoader.getTestResourceDataJson( "/sync/aai/aai-traversal/generic-query/service-instance-54.json"))); Mockito .when(aaiAdapter.queryActiveInventoryWithRetries( Matchers.contains("generic-query/service-instance-55"), Mockito.anyString(), - Mockito.anyInt())) + Mockito.anyInt(),Mockito.anyString())) .thenReturn(new OperationResult(200, TestResourceLoader.getTestResourceDataJson( "/sync/aai/aai-traversal/generic-query/service-instance-55.json"))); Mockito .when(aaiAdapter.queryActiveInventoryWithRetries( Matchers.contains("generic-query/service-instance-50"), Mockito.anyString(), - Mockito.anyInt())) + Mockito.anyInt(),Mockito.anyString())) .thenReturn(new OperationResult(200, TestResourceLoader.getTestResourceDataJson( "/sync/aai/aai-traversal/generic-query/service-instance-50.json"))); Mockito .when(aaiAdapter.queryActiveInventoryWithRetries( Matchers.contains("generic-query/service-instance-52"), Mockito.anyString(), - Mockito.anyInt())) + Mockito.anyInt(),Mockito.anyString())) .thenReturn(new OperationResult(200, TestResourceLoader.getTestResourceDataJson( "/sync/aai/aai-traversal/generic-query/service-instance-52.json"))); Mockito .when(aaiAdapter.queryActiveInventoryWithRetries( Matchers.contains("generic-query/service-instance-57"), Mockito.anyString(), - Mockito.anyInt())) + Mockito.anyInt(),Mockito.anyString())) .thenReturn(new OperationResult(200, TestResourceLoader.getTestResourceDataJson( "/sync/aai/aai-traversal/generic-query/service-instance-57.json"))); Mockito .when(aaiAdapter.queryActiveInventoryWithRetries( Matchers.contains("generic-query/service-instance-53"), Mockito.anyString(), - Mockito.anyInt())) + Mockito.anyInt(),Mockito.anyString())) .thenReturn(new OperationResult(200, TestResourceLoader.getTestResourceDataJson( "/sync/aai/aai-traversal/generic-query/service-instance-53.json"))); Mockito .when(aaiAdapter.queryActiveInventoryWithRetries( Matchers.contains("generic-query/service-instance-58"), Mockito.anyString(), - Mockito.anyInt())) + Mockito.anyInt(),Mockito.anyString())) .thenReturn(new OperationResult(200, TestResourceLoader.getTestResourceDataJson( "/sync/aai/aai-traversal/generic-query/service-instance-58.json"))); Mockito .when(aaiAdapter.queryActiveInventoryWithRetries( Matchers.contains("generic-query/service-instance-51"), Mockito.anyString(), - Mockito.anyInt())) + Mockito.anyInt(),Mockito.anyString())) .thenReturn(new OperationResult(200, TestResourceLoader.getTestResourceDataJson( "/sync/aai/aai-traversal/generic-query/service-instance-51.json"))); Mockito .when(aaiAdapter.queryActiveInventoryWithRetries( Matchers.contains("generic-query/service-instance-56"), Mockito.anyString(), - Mockito.anyInt())) + Mockito.anyInt(),Mockito.anyString())) .thenReturn(new OperationResult(200, TestResourceLoader.getTestResourceDataJson( "/sync/aai/aai-traversal/generic-query/service-instance-56.json"))); @@ -832,20 +832,20 @@ public class CrossEntityReferenceSynchronizerTest { Mockito .when(aaiAdapter.queryActiveInventoryWithRetries( Matchers.contains("service-subscription-2"), Mockito.anyString(), - Mockito.anyInt())) + Mockito.anyInt(),Mockito.anyString())) .thenReturn(new OperationResult(200, TestResourceLoader.getTestResourceDataJson( "/sync/aai/service-subscription-service-subscription-2.json"))); Mockito .when(aaiAdapter.queryActiveInventoryWithRetries( Matchers.contains("service-subscription-1"), Mockito.anyString(), - Mockito.anyInt())) + Mockito.anyInt(),Mockito.anyString())) .thenReturn(new OperationResult(200, TestResourceLoader.getTestResourceDataJson( "/sync/aai/service-subscription-service-subscription-1.json"))); Mockito .when(aaiAdapter.queryActiveInventoryWithRetries(Matchers.contains("service-subscription-3"), - Mockito.anyString(), Mockito.anyInt())) + Mockito.anyString(), Mockito.anyInt(),Mockito.anyString())) .thenReturn(new OperationResult(200, TestResourceLoader .getTestResourceDataJson("/sync/aai/service-subscription-service-subscription-3.json"))); @@ -914,70 +914,70 @@ public class CrossEntityReferenceSynchronizerTest { Mockito .when(aaiAdapter.queryActiveInventoryWithRetries( Matchers.contains("generic-query/service-instance-59"), Mockito.anyString(), - Mockito.anyInt())) + Mockito.anyInt(),Mockito.anyString())) .thenReturn(new OperationResult(200, TestResourceLoader.getTestResourceDataJson( "/sync/aai/aai-traversal/generic-query/service-instance-59.json"))); Mockito .when(aaiAdapter.queryActiveInventoryWithRetries( Matchers.contains("generic-query/service-instance-54"), Mockito.anyString(), - Mockito.anyInt())) + Mockito.anyInt(),Mockito.anyString())) .thenReturn(new OperationResult(200, TestResourceLoader.getTestResourceDataJson( "/sync/aai/aai-traversal/generic-query/service-instance-54.json"))); Mockito .when(aaiAdapter.queryActiveInventoryWithRetries( Matchers.contains("generic-query/service-instance-55"), Mockito.anyString(), - Mockito.anyInt())) + Mockito.anyInt(),Mockito.anyString())) .thenReturn(new OperationResult(200, TestResourceLoader.getTestResourceDataJson( "/sync/aai/aai-traversal/generic-query/service-instance-55.json"))); Mockito .when(aaiAdapter.queryActiveInventoryWithRetries( Matchers.contains("generic-query/service-instance-50"), Mockito.anyString(), - Mockito.anyInt())) + Mockito.anyInt(),Mockito.anyString())) .thenReturn(new OperationResult(200, TestResourceLoader.getTestResourceDataJson( "/sync/aai/aai-traversal/generic-query/service-instance-50.json"))); Mockito .when(aaiAdapter.queryActiveInventoryWithRetries( Matchers.contains("generic-query/service-instance-52"), Mockito.anyString(), - Mockito.anyInt())) + Mockito.anyInt(),Mockito.anyString())) .thenReturn(new OperationResult(200, TestResourceLoader.getTestResourceDataJson( "/sync/aai/aai-traversal/generic-query/service-instance-52.json"))); Mockito .when(aaiAdapter.queryActiveInventoryWithRetries( Matchers.contains("generic-query/service-instance-57"), Mockito.anyString(), - Mockito.anyInt())) + Mockito.anyInt(),Mockito.anyString())) .thenReturn(new OperationResult(200, TestResourceLoader.getTestResourceDataJson( "/sync/aai/aai-traversal/generic-query/service-instance-57.json"))); Mockito .when(aaiAdapter.queryActiveInventoryWithRetries( Matchers.contains("generic-query/service-instance-53"), Mockito.anyString(), - Mockito.anyInt())) + Mockito.anyInt(),Mockito.anyString())) .thenReturn(new OperationResult(200, TestResourceLoader.getTestResourceDataJson( "/sync/aai/aai-traversal/generic-query/service-instance-53.json"))); Mockito .when(aaiAdapter.queryActiveInventoryWithRetries( Matchers.contains("generic-query/service-instance-58"), Mockito.anyString(), - Mockito.anyInt())) + Mockito.anyInt(),Mockito.anyString())) .thenReturn(new OperationResult(200, TestResourceLoader.getTestResourceDataJson( "/sync/aai/aai-traversal/generic-query/service-instance-58.json"))); Mockito .when(aaiAdapter.queryActiveInventoryWithRetries( Matchers.contains("generic-query/service-instance-51"), Mockito.anyString(), - Mockito.anyInt())) + Mockito.anyInt(),Mockito.anyString())) .thenReturn(new OperationResult(200, TestResourceLoader.getTestResourceDataJson( "/sync/aai/aai-traversal/generic-query/service-instance-51.json"))); Mockito .when(aaiAdapter.queryActiveInventoryWithRetries( Matchers.contains("generic-query/service-instance-56"), Mockito.anyString(), - Mockito.anyInt())) + Mockito.anyInt(),Mockito.anyString())) .thenReturn(new OperationResult(200, TestResourceLoader.getTestResourceDataJson( "/sync/aai/aai-traversal/generic-query/service-instance-56.json"))); diff --git a/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/dal/ActiveInventoryAdapterTest.java b/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/dal/ActiveInventoryAdapterTest.java index d60ca02..6ec7513 100644 --- a/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/dal/ActiveInventoryAdapterTest.java +++ b/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/dal/ActiveInventoryAdapterTest.java @@ -27,7 +27,7 @@ public class ActiveInventoryAdapterTest { endpointConfig = new RestEndpointConfig(); queryParams = new ArrayList<String>(); endpointConfig.setRestAuthenticationMode(RestAuthenticationMode.SSL_BASIC); - aaiAdapter = new ActiveInventoryAdapter(oxmModelLoader, oxmEntityLookup, endpointConfig); + aaiAdapter = new ActiveInventoryAdapter(oxmModelLoader, oxmEntityLookup, endpointConfig,"aai"); } @@ -42,9 +42,9 @@ public class ActiveInventoryAdapterTest { assertNotNull(aaiAdapter.getGenericQueryForSelfLink("", queryParams)); assertNull(aaiAdapter.getSelfLinkForEntity("pserver", "PrimaryKeyName", "PrimaryKeyValue")); assertNotNull( - aaiAdapter.queryActiveInventory("https://server.proxy:8443/aai/v11/", "application/json")); + aaiAdapter.queryActiveInventory("https://server.proxy:8443/aai/v11/", "application/json","sync")); assertNotNull(aaiAdapter.queryActiveInventoryWithRetries( - "https://server.proxy:8443/aai/v11/business/customers/", "application/json", 4)); + "https://server.proxy:8443/aai/v11/business/customers/", "application/json", 4,"sync")); aaiAdapter.setOxmEntityLookup(oxmEntityLookup); assertNotNull(aaiAdapter.getOxmEntityLookup()); aaiAdapter.setEndpointConfig(endpointConfig); diff --git a/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/editattributes/AttributeUpdaterTest.java b/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/editattributes/AttributeUpdaterTest.java index b31962b..a5f7049 100644 --- a/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/editattributes/AttributeUpdaterTest.java +++ b/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/editattributes/AttributeUpdaterTest.java @@ -78,7 +78,7 @@ public class AttributeUpdaterTest { entityLookup.addEntityDescriptor("pserver", desc); AttributeUpdater updater = - new AttributeUpdater(new OxmModelLoader("v11", null, null), entityLookup, aaiAdapter); + new AttributeUpdater(new OxmModelLoader("v11", null, null), entityLookup, aaiAdapter,"aai"); Map<String, Object> attributes = new HashMap<>(); attributes.put("prov-status", "PREPROV"); attributes.put("in-maint", "true"); @@ -122,7 +122,7 @@ public class AttributeUpdaterTest { AttributeUpdater updater = - new AttributeUpdater(new OxmModelLoader(version, null, null), entityLookup, aaiAdapter); + new AttributeUpdater(new OxmModelLoader(version, null, null), entityLookup, aaiAdapter,"aai"); AaiEditObject result = updater.getEditObjectFromUri(null); assertEquals("Pserver", result.getObjectType()); assertEquals("pserver", result.getRootElement()); @@ -146,7 +146,7 @@ public class AttributeUpdaterTest { OxmEntityLookup entityLookup = new OxmEntityLookup(); entityLookup.addEntityDescriptor("pserver", desc); - AttributeUpdater updater = new AttributeUpdater(new OxmModelLoader("v11",null,null), entityLookup, aaiAdapter); + AttributeUpdater updater = new AttributeUpdater(new OxmModelLoader("v11",null,null), entityLookup, aaiAdapter,"aai"); // Test entity uri without "/aai/version/" String result = updater.getRelativeUri("cloud-infrastructure/pservers/pserver/mtznjtax101"); assertEquals("/cloud-infrastructure/pservers/pserver/mtznjtax101", result); diff --git a/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/personalization/PersonalizationServiceProviderTest.java b/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/personalization/PersonalizationServiceProviderTest.java new file mode 100644 index 0000000..04f0412 --- /dev/null +++ b/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/personalization/PersonalizationServiceProviderTest.java @@ -0,0 +1,38 @@ +package org.onap.aai.sparky.personalization; + +import org.apache.camel.Exchange; +import org.apache.camel.Message; +import org.junit.Before; +import org.junit.Test; +import org.mockito.Mockito; +import org.onap.aai.sparky.personalization.config.PersonalizationConfig; + + + +public class PersonalizationServiceProviderTest { + + private PersonalizationServiceProvider personalizationServiceProvider; + private Exchange mockExchange; + private Message mockRequestMessage; + private Message mockResponseMessage; + private PersonalizationConfig mockPersonalizationConfig; + + + @Before + public void init() throws Exception { + + mockExchange = Mockito.mock(Exchange.class); + mockRequestMessage = Mockito.mock(Message.class); + mockResponseMessage = Mockito.mock(Message.class); + mockPersonalizationConfig = Mockito.mock(PersonalizationConfig.class); + personalizationServiceProvider = new PersonalizationServiceProvider(mockPersonalizationConfig); + + + Mockito.when(mockExchange.getIn()).thenReturn(mockRequestMessage); + Mockito.when(mockExchange.getOut()).thenReturn(mockResponseMessage); + + + } + + +} diff --git a/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/personalization/config/PersonalizationConfigTest.java b/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/personalization/config/PersonalizationConfigTest.java new file mode 100644 index 0000000..6b06add --- /dev/null +++ b/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/personalization/config/PersonalizationConfigTest.java @@ -0,0 +1,32 @@ +package org.onap.aai.sparky.personalization.config; + + +import static org.junit.Assert.assertNotNull; + +import org.junit.Before; +import org.junit.Test; + +public class PersonalizationConfigTest { + + + private PersonalizationConfig personalizationConfig; + + + @Before + public void init() throws Exception { + personalizationConfig = new PersonalizationConfig(); + + } + + + @Test + public void updateValues() { + + personalizationConfig.setHtmlDocumentTitle("AAI"); + assertNotNull(personalizationConfig.getHtmlDocumentTitle()); + personalizationConfig.setTopLeftHeader("AAI"); + assertNotNull(personalizationConfig.getTopLeftHeader()); + + } + +} diff --git a/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/sync/AggregationSynchronizerTest.java b/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/sync/AggregationSynchronizerTest.java index 8f8beea..da222e4 100644 --- a/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/sync/AggregationSynchronizerTest.java +++ b/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/sync/AggregationSynchronizerTest.java @@ -171,7 +171,7 @@ public class AggregationSynchronizerTest { .thenReturn("https://server.proxy:8443/aai/v11/cloud-infrastructure/complexes/complex" + x); Mockito.when(aaiAdapter.queryActiveInventoryWithRetries(Matchers.contains("complex" + x), - Mockito.anyString(), Mockito.anyInt())) + Mockito.anyString(), Mockito.anyInt(),Mockito.anyString())) .thenReturn(new OperationResult(200, TestResourceLoader .getTestResourceDataJson("/sync/aai/complex" + x + "_fullDepth_aaiEntityRetrieval.json"))); @@ -233,7 +233,7 @@ public class AggregationSynchronizerTest { .thenReturn("https://server.proxy:8443/aai/v11/cloud-infrastructure/complexes/complex" + x); Mockito.when(aaiAdapter.queryActiveInventoryWithRetries(Matchers.contains("complex" + x), - Mockito.anyString(), Mockito.anyInt())) + Mockito.anyString(), Mockito.anyInt(),Mockito.anyString())) .thenReturn(new OperationResult(200, TestResourceLoader .getTestResourceDataJson("/sync/aai/complex" + x + "_fullDepth_aaiEntityRetrieval.json"))); @@ -297,7 +297,7 @@ public class AggregationSynchronizerTest { .thenReturn("https://server.proxy:8443/aai/v11/cloud-infrastructure/complexes/complex" + x); Mockito.when(aaiAdapter.queryActiveInventoryWithRetries(Matchers.contains("complex" + x), - Mockito.anyString(), Mockito.anyInt())) + Mockito.anyString(), Mockito.anyInt(),Mockito.anyString())) .thenReturn(new OperationResult(200, TestResourceLoader .getTestResourceDataJson("/sync/aai/complex" + x + "_fullDepth_aaiEntityRetrieval.json"))); diff --git a/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/viewandinspect/BaseVisualizationContextTest.java b/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/viewandinspect/BaseVisualizationContextTest.java index d58bf42..0a2c75e 100644 --- a/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/viewandinspect/BaseVisualizationContextTest.java +++ b/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/viewandinspect/BaseVisualizationContextTest.java @@ -152,7 +152,7 @@ public class BaseVisualizationContextTest { Mockito .when(aaiAdapter.queryActiveInventoryWithRetries(Matchers.contains("customer-4"), - Mockito.anyString(), Mockito.anyInt())) + Mockito.anyString(), Mockito.anyInt(),Mockito.anyString())) .thenReturn(new OperationResult(200, TestResourceLoader .getTestResourceDataJson("/sync/aai/aai-resources/customer/customer-4.json"))); @@ -160,7 +160,7 @@ public class BaseVisualizationContextTest { Mockito .when(aaiAdapter.queryActiveInventoryWithRetries(Matchers.contains("tenant/tenant-1"), - Mockito.anyString(), Mockito.anyInt())) + Mockito.anyString(), Mockito.anyInt(),Mockito.anyString())) .thenReturn(new OperationResult(200, TestResourceLoader .getTestResourceDataJson("/sync/aai/aai-resources/tenant/tenant-1.json"))); @@ -176,7 +176,7 @@ public class BaseVisualizationContextTest { Mockito .when(aaiAdapter.queryActiveInventoryWithRetries( Matchers.contains("generic-query/service-subscription-2"), Mockito.anyString(), - Mockito.anyInt())) + Mockito.anyInt(),Mockito.anyString())) .thenReturn(new OperationResult(200, TestResourceLoader.getTestResourceDataJson( "/sync/aai/aai-traversal/generic-query/service-subscription/service-subscription-2.json"))); @@ -191,7 +191,7 @@ public class BaseVisualizationContextTest { Mockito .when(aaiAdapter.queryActiveInventoryWithRetries( Matchers.contains("generic-query/service-instance-id/service-instance-54"), - Mockito.anyString(), Mockito.anyInt())) + Mockito.anyString(), Mockito.anyInt(),Mockito.anyString())) .thenReturn(new OperationResult(200, TestResourceLoader.getTestResourceDataJson( "/sync/aai/aai-traversal/generic-query/service-instance/service-instance-54.json"))); @@ -206,7 +206,7 @@ public class BaseVisualizationContextTest { Mockito .when(aaiAdapter.queryActiveInventoryWithRetries( Matchers.contains("generic-query/service-instance-id/service-instance-55"), - Mockito.anyString(), Mockito.anyInt())) + Mockito.anyString(), Mockito.anyInt(),Mockito.anyString())) .thenReturn(new OperationResult(200, TestResourceLoader.getTestResourceDataJson( "/sync/aai/aai-traversal/generic-query/service-instance/service-instance-55.json"))); diff --git a/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/viewandinspect/BaseVisualizationServiceTest.java b/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/viewandinspect/BaseVisualizationServiceTest.java index 9be0fe2..624c239 100644 --- a/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/viewandinspect/BaseVisualizationServiceTest.java +++ b/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/viewandinspect/BaseVisualizationServiceTest.java @@ -64,7 +64,7 @@ public class BaseVisualizationServiceTest { private void initializeMocksForBuildVisualizationUsingGenericQueryTest() { Mockito.when(mockAaiAdapter.queryActiveInventoryWithRetries(Mockito.anyString(), - Mockito.anyString(), Mockito.anyInt())).thenReturn(null); + Mockito.anyString(), Mockito.anyInt(),Mockito.anyString())).thenReturn(null); } } diff --git a/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/viewandinspect/config/VisualizationConfigTest.java b/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/viewandinspect/config/VisualizationConfigTest.java index dbbd38d..3e6cab8 100644 --- a/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/viewandinspect/config/VisualizationConfigTest.java +++ b/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/viewandinspect/config/VisualizationConfigTest.java @@ -57,6 +57,10 @@ public class VisualizationConfigTest { visualConfig.setSelectedSearchedNodeClassName(null); assertNull(visualConfig.getSelectedSearchedNodeClassName()); assertNotNull(visualConfig.toString()); + + visualConfig.setDelimitedShallowEntities("cloud-region,network,pserver"); + assertNotNull(visualConfig.getShallowEntities()); + assertEquals(3, visualConfig.getShallowEntities().size()); } diff --git a/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/viewandinspect/entity/ActiveInventoryNodeTest.java b/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/viewandinspect/entity/ActiveInventoryNodeTest.java index 8469d1a..b44782b 100644 --- a/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/viewandinspect/entity/ActiveInventoryNodeTest.java +++ b/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/viewandinspect/entity/ActiveInventoryNodeTest.java @@ -37,6 +37,7 @@ import org.junit.Before; import org.junit.Test; import org.onap.aai.restclient.client.OperationResult; import org.onap.aai.sparky.config.oxm.OxmEntityLookup; +import org.onap.aai.sparky.util.NodeUtils; import org.onap.aai.sparky.viewandinspect.config.VisualizationConfigs; public class ActiveInventoryNodeTest { @@ -118,8 +119,8 @@ public class ActiveInventoryNodeTest { assertNotNull(activeInventoryNode.getEntityType()); assertNotNull(activeInventoryNode.dumpNodeTree(true)); assertNotNull(activeInventoryNode.getProcessingErrorCauses()); - assertNull(activeInventoryNode.calculateEditAttributeUri("Invalid-link")); - assertNull(activeInventoryNode.calculateEditAttributeUri("aai/v[\\d]/")); + assertNull(NodeUtils.calculateEditAttributeUri("Invalid-link")); + assertNull(NodeUtils.calculateEditAttributeUri("aai/v[\\d]/")); activeInventoryNode.processPathedSelfLinkResponse("jsonResp","startNodeType","startNodeResourceKey"); activeInventoryNode.processPathedSelfLinkResponse(null,"startNodeType","startNodeResourceKey"); activeInventoryNode.processPathedSelfLinkResponse("","startNodeType","startNodeResourceKey"); diff --git a/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/viewandinspect/services/BaseVisualizationContextTest.java b/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/viewandinspect/services/BaseVisualizationContextTest.java index 394bfe4..bfb89ac 100644 --- a/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/viewandinspect/services/BaseVisualizationContextTest.java +++ b/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/viewandinspect/services/BaseVisualizationContextTest.java @@ -152,7 +152,7 @@ public class BaseVisualizationContextTest { Mockito .when(aaiAdapter.queryActiveInventoryWithRetries(Matchers.contains("customer-4"), - Mockito.anyString(), Mockito.anyInt())) + Mockito.anyString(), Mockito.anyInt(),Mockito.anyString())) .thenReturn(new OperationResult(200, TestResourceLoader .getTestResourceDataJson("/sync/aai/aai-resources/customer/customer-4.json"))); @@ -160,7 +160,7 @@ public class BaseVisualizationContextTest { Mockito .when(aaiAdapter.queryActiveInventoryWithRetries(Matchers.contains("tenant/tenant-1"), - Mockito.anyString(), Mockito.anyInt())) + Mockito.anyString(), Mockito.anyInt(),Mockito.anyString())) .thenReturn(new OperationResult(200, TestResourceLoader .getTestResourceDataJson("/sync/aai/aai-resources/tenant/tenant-1.json"))); @@ -176,7 +176,7 @@ public class BaseVisualizationContextTest { Mockito .when(aaiAdapter.queryActiveInventoryWithRetries( Matchers.contains("generic-query/service-subscription-2"), Mockito.anyString(), - Mockito.anyInt())) + Mockito.anyInt(),Mockito.anyString())) .thenReturn(new OperationResult(200, TestResourceLoader.getTestResourceDataJson( "/sync/aai/aai-traversal/generic-query/service-subscription/service-subscription-2.json"))); @@ -191,7 +191,7 @@ public class BaseVisualizationContextTest { Mockito .when(aaiAdapter.queryActiveInventoryWithRetries( Matchers.contains("generic-query/service-instance-id/service-instance-54"), - Mockito.anyString(), Mockito.anyInt())) + Mockito.anyString(), Mockito.anyInt(),Mockito.anyString())) .thenReturn(new OperationResult(200, TestResourceLoader.getTestResourceDataJson( "/sync/aai/aai-traversal/generic-query/service-instance/service-instance-54.json"))); @@ -206,7 +206,7 @@ public class BaseVisualizationContextTest { Mockito .when(aaiAdapter.queryActiveInventoryWithRetries( Matchers.contains("generic-query/service-instance-id/service-instance-55"), - Mockito.anyString(), Mockito.anyInt())) + Mockito.anyString(), Mockito.anyInt(),Mockito.anyString())) .thenReturn(new OperationResult(200, TestResourceLoader.getTestResourceDataJson( "/sync/aai/aai-traversal/generic-query/service-instance/service-instance-55.json"))); diff --git a/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/viewandinspect/sync/ViewInspectEntitySynchronizerTest.java b/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/viewandinspect/sync/ViewInspectEntitySynchronizerTest.java index 0fd3bca..5b2f8d1 100644 --- a/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/viewandinspect/sync/ViewInspectEntitySynchronizerTest.java +++ b/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/viewandinspect/sync/ViewInspectEntitySynchronizerTest.java @@ -211,19 +211,19 @@ public class ViewInspectEntitySynchronizerTest { Mockito .when(aaiAdapter.queryActiveInventoryWithRetries(Matchers.contains("generic-vnf-1"), - Mockito.anyString(), Mockito.anyInt())) + Mockito.anyString(), Mockito.anyInt(),Mockito.anyString())) .thenReturn(new OperationResult(200, TestResourceLoader .getTestResourceDataJson("/sync/aai/generic-vnf-generic-vnf-1_full_depth.json"))); Mockito .when(aaiAdapter.queryActiveInventoryWithRetries(Matchers.contains("generic-vnf-2"), - Mockito.anyString(), Mockito.anyInt())) + Mockito.anyString(), Mockito.anyInt(),Mockito.anyString())) .thenReturn(new OperationResult(200, TestResourceLoader .getTestResourceDataJson("/sync/aai/generic-vnf-generic-vnf-2_full_depth.json"))); Mockito .when(aaiAdapter.queryActiveInventoryWithRetries(Matchers.contains("generic-vnf-3"), - Mockito.anyString(), Mockito.anyInt())) + Mockito.anyString(), Mockito.anyInt(),Mockito.anyString())) .thenReturn(new OperationResult(200, TestResourceLoader .getTestResourceDataJson("/sync/aai/generic-vnf-generic-vnf-3_full_depth.json"))); @@ -293,19 +293,19 @@ public class ViewInspectEntitySynchronizerTest { Mockito .when(aaiAdapter.queryActiveInventoryWithRetries(Matchers.contains("generic-vnf-1"), - Mockito.anyString(), Mockito.anyInt())) + Mockito.anyString(), Mockito.anyInt(),Mockito.anyString())) .thenReturn(new OperationResult(200, TestResourceLoader .getTestResourceDataJson("/sync/aai/generic-vnf-generic-vnf-1_full_depth.json"))); Mockito .when(aaiAdapter.queryActiveInventoryWithRetries(Matchers.contains("generic-vnf-2"), - Mockito.anyString(), Mockito.anyInt())) + Mockito.anyString(), Mockito.anyInt(),Mockito.anyString())) .thenReturn(new OperationResult(200, TestResourceLoader .getTestResourceDataJson("/sync/aai/generic-vnf-generic-vnf-2_full_depth.json"))); Mockito .when(aaiAdapter.queryActiveInventoryWithRetries(Matchers.contains("generic-vnf-3"), - Mockito.anyString(), Mockito.anyInt())) + Mockito.anyString(), Mockito.anyInt(),Mockito.anyString())) .thenReturn(new OperationResult(200, TestResourceLoader .getTestResourceDataJson("/sync/aai/generic-vnf-generic-vnf-3_full_depth.json"))); |