summaryrefslogtreecommitdiffstats
path: root/sparkybe-onap-service/src/main/java
diff options
context:
space:
mode:
authorSteven Blimkie <Steven.Blimkie@amdocs.com>2018-12-14 16:41:20 +0000
committerGerrit Code Review <gerrit@onap.org>2018-12-14 16:41:20 +0000
commitb83325323617b24b4316f6cf2532236e603167a5 (patch)
treec87f11cc3e78c55791341fc0bd61d8250a98e94a /sparkybe-onap-service/src/main/java
parent885545697c79b299a372956b1b368e13bab3426c (diff)
parentd89597a79b75aa6624fe4ff939e13a21d8b99a03 (diff)
Merge "Fix sync update flow"
Diffstat (limited to 'sparkybe-onap-service/src/main/java')
-rw-r--r--sparkybe-onap-service/src/main/java/org/onap/aai/sparky/aggregation/sync/AggregationSynchronizer.java6
-rw-r--r--sparkybe-onap-service/src/main/java/org/onap/aai/sparky/crossentityreference/sync/CrossEntityReferenceSynchronizer.java25
-rw-r--r--sparkybe-onap-service/src/main/java/org/onap/aai/sparky/search/SearchServiceAdapter.java17
-rw-r--r--sparkybe-onap-service/src/main/java/org/onap/aai/sparky/sync/entity/IndexableCrossEntityReference.java8
-rw-r--r--sparkybe-onap-service/src/main/java/org/onap/aai/sparky/viewandinspect/search/ViewInspectSearchProvider.java2
-rw-r--r--sparkybe-onap-service/src/main/java/org/onap/aai/sparky/viewinspect/sync/ViewInspectEntitySynchronizer.java6
6 files changed, 28 insertions, 36 deletions
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 dc6bdc0..70aaa93 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
@@ -278,7 +278,7 @@ public class AggregationSynchronizer extends AbstractEntitySynchronizer
try {
versionNumber = NodeUtils.extractFieldValueFromObject(
NodeUtils.convertJsonStrToJsonNode(esGetTxn.getOperationResult().getResult()),
- "_version");
+ "etag");
} catch (IOException exc) {
String message =
"Error extracting version number from response, aborting aggregation entity sync of "
@@ -303,7 +303,7 @@ public class AggregationSynchronizer extends AbstractEntitySynchronizer
ArrayList<JsonNode> sourceObject = new ArrayList<JsonNode>();
NodeUtils.extractObjectsByKey(
NodeUtils.convertJsonStrToJsonNode(esGetTxn.getOperationResult().getResult()),
- "_source", sourceObject);
+ "content", sourceObject);
if (!sourceObject.isEmpty()) {
String responseSource = NodeUtils.convertObjectToJson(sourceObject.get(0), false);
@@ -328,7 +328,7 @@ public class AggregationSynchronizer extends AbstractEntitySynchronizer
String requestPayload =
searchServiceAdapter.buildBulkImportOperationRequest(schemaConfig.getIndexName(),
- ae.getId(),jsonPayload);
+ versionNumber, ae.getId(),jsonPayload);
NetworkTransaction transactionTracker = new NetworkTransaction();
transactionTracker.setEntityType(esGetTxn.getEntityType());
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 9481173..4b6b7a5 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
@@ -684,7 +684,7 @@ public class CrossEntityReferenceSynchronizer extends AbstractEntitySynchronizer
try {
versionNumber = NodeUtils.extractFieldValueFromObject(
NodeUtils.convertJsonStrToJsonNode(esGetResult.getOperationResult().getResult()),
- "_version");
+ "etag");
} catch (IOException exc) {
LOG.error(AaiUiMsgs.ES_ABORT_CROSS_ENTITY_REF_SYNC, "version Number",
icer.getEntityPrimaryKeyValue(), exc.getLocalizedMessage());
@@ -707,7 +707,7 @@ public class CrossEntityReferenceSynchronizer extends AbstractEntitySynchronizer
ArrayList<JsonNode> sourceObject = new ArrayList<JsonNode>();
NodeUtils.extractObjectsByKey(
NodeUtils.convertJsonStrToJsonNode(esGetResult.getOperationResult().getResult()),
- "_source", sourceObject);
+ "content", sourceObject);
if (!sourceObject.isEmpty()) {
String responseSource = NodeUtils.convertObjectToJson(sourceObject.get(0), false);
@@ -729,7 +729,7 @@ public class CrossEntityReferenceSynchronizer extends AbstractEntitySynchronizer
if (versionNumber != null && jsonPayload != null) {
String requestPayload = searchServiceAdapter.buildBulkImportOperationRequest(getIndexName(),
- icer.getId(), jsonPayload);
+ icer.getId(), versionNumber, jsonPayload);
NetworkTransaction transactionTracker = new NetworkTransaction();
transactionTracker.setEntityType(esGetResult.getEntityType());
@@ -744,7 +744,7 @@ public class CrossEntityReferenceSynchronizer extends AbstractEntitySynchronizer
esWorkOnHand.decrementAndGet();
if (error != null) {
- LOG.error(AaiUiMsgs.ES_CROSS_ENTITY_REF_PUT, error.getLocalizedMessage());
+ LOG.error(AaiUiMsgs.ES_CROSS_ENTITY_REF_PUT, error.getLocalizedMessage());
} else {
updateElasticSearchCounters(result);
processStoreDocumentResult(result, esGetResult, icer);
@@ -871,23 +871,6 @@ public class CrossEntityReferenceSynchronizer extends AbstractEntitySynchronizer
IndexableCrossEntityReference icer = new IndexableCrossEntityReference();
- icer.setEntityType(resultDescriptor.getEntityName());
-
- List<String> primaryKeyValues = new ArrayList<String>();
- String pkeyValue = null;
-
- for (String keyName : resultDescriptor.getPrimaryKeyAttributeNames()) {
- pkeyValue = NodeUtils.getNodeFieldAsText(entityNode, keyName);
- if (pkeyValue != null) {
- primaryKeyValues.add(pkeyValue);
- } else {
- LOG.warn(AaiUiMsgs.ES_PKEYVALUE_NULL, resultDescriptor.getEntityName());
- }
- }
-
- final String primaryCompositeKeyValue = NodeUtils.concatArray(primaryKeyValues, "/");
- icer.setEntityPrimaryKeyValue(primaryCompositeKeyValue);
-
return icer;
}
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 a00aa75..aab7e29 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
@@ -45,8 +45,8 @@ public class SearchServiceAdapter {
private static final String SUGGEST_QUERY = "suggest";
private static final String BULK_API = "bulk";
private static final String DOCUMENT_EDNPOINT = "documents";
- private static final String SEARH_SERVICE_BULK_TEMPLATE =
- "{\"create\":{\"metaData\":{\"url\":\"%s\"},\"document\":\"%s\"}}\n";
+ private static final String SEARCH_SERVICE_BULK_TEMPLATE =
+ "[{\"update\":{\"metaData\":{\"url\":\"%s\", \"etag\":\"%s\"},\"document\":%s}}]\n";
private static final String SEARH_SERVICE_SINGLE_ENTITY_TEMPLATE =
"{\"queries\":[{\"must\":{\"match\":{\"field\":\"_id\",\"value\":\"%s\"}}}]}\n";
@@ -145,12 +145,12 @@ public class SearchServiceAdapter {
return headers;
}
-public String buildBulkImportOperationRequest(String indexName, String id, String payload){
+public String buildBulkImportOperationRequest(String indexName, String id, String version, String payload){
StringBuilder requestPayload = new StringBuilder(128);
- String SearchTarget = buildSearchServiceDocUrl(indexName,id);
+ String SearchTarget = buildSearchServiceDocBulkPayloadUrl(indexName,id);
- requestPayload.append(String.format(SEARH_SERVICE_BULK_TEMPLATE,SearchTarget,payload));
+ requestPayload.append(String.format(SEARCH_SERVICE_BULK_TEMPLATE,SearchTarget,version, payload));
return requestPayload.toString();
}
@@ -177,12 +177,17 @@ public String buildBulkImportOperationRequest(String indexName, String id, Strin
}
public String buildSearchServiceDocUrl(String indexName,String api) {
-
+
return String.format("https://%s:%s/services/search-data-service/%s/search/indexes/%s/%s/%s",
endpointConfig.getEndpointIpAddress(), endpointConfig.getEndpointServerPort(),
serviceApiVersion, indexName,DOCUMENT_EDNPOINT, api);
}
+ public String buildSearchServiceDocBulkPayloadUrl(String indexName,String api) {
+
+ return String.format("/services/search-data-service/%s/search/indexes/%s/%s/%s",
+ serviceApiVersion, indexName,DOCUMENT_EDNPOINT, api);
+ }
public String buildSearchServiceCreateDocApi(String indexName){
diff --git a/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/sync/entity/IndexableCrossEntityReference.java b/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/sync/entity/IndexableCrossEntityReference.java
index 0bad15a..c85980a 100644
--- a/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/sync/entity/IndexableCrossEntityReference.java
+++ b/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/sync/entity/IndexableCrossEntityReference.java
@@ -21,17 +21,21 @@
package org.onap.aai.sparky.sync.entity;
import java.util.ArrayList;
+import java.util.Arrays;
import org.onap.aai.sparky.util.NodeUtils;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.core.JsonProcessingException;
-
+import com.fasterxml.jackson.databind.ser.impl.SimpleBeanPropertyFilter;
+import com.fasterxml.jackson.databind.ser.impl.SimpleFilterProvider;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonInclude.Include;
/**
* The Class IndexableCrossEntityReference.
*/
-
+@JsonInclude(Include.NON_NULL)
public class IndexableCrossEntityReference extends IndexableEntity implements IndexDocument {
protected String crossReferenceEntityValues;
diff --git a/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/viewandinspect/search/ViewInspectSearchProvider.java b/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/viewandinspect/search/ViewInspectSearchProvider.java
index 1937891..77c1a69 100644
--- a/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/viewandinspect/search/ViewInspectSearchProvider.java
+++ b/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/viewandinspect/search/ViewInspectSearchProvider.java
@@ -395,7 +395,7 @@ public class ViewInspectSearchProvider implements SearchProvider {
private static final String VIUI_SEARCH_TEMPLATE =
"{ " + "\"results-start\": 0," + "\"results-size\": %d," + "\"queries\": [{" + "\"must\": {"
- + "\"match\": {" + "\"field\": \"entityType searchTags crossEntityReferenceValues\","
+ + "\"match\": {" + "\"field\": \"entityType searchTags crossReferenceEntityValues\","
+ "\"value\": \"%s\"," + "\"operator\": \"and\", "
+ "\"analyzer\": \"whitespace_analyzer\"" + "}" + "}" + "}]" + "}";
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 4877ad0..bc5e122 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
@@ -393,7 +393,7 @@ public class ViewInspectEntitySynchronizer extends AbstractEntitySynchronizer
try {
versionNumber = NodeUtils.extractFieldValueFromObject(
NodeUtils.convertJsonStrToJsonNode(esGetTxn.getOperationResult().getResult()),
- "_version");
+ "etag");
} catch (IOException exc) {
String message =
"Error extracting version number from response, aborting searchable entity sync of "
@@ -418,7 +418,7 @@ public class ViewInspectEntitySynchronizer extends AbstractEntitySynchronizer
ArrayList<JsonNode> sourceObject = new ArrayList<JsonNode>();
NodeUtils.extractObjectsByKey(
NodeUtils.convertJsonStrToJsonNode(esGetTxn.getOperationResult().getResult()),
- "_source", sourceObject);
+ "content", sourceObject);
if (!sourceObject.isEmpty()) {
String responseSource = NodeUtils.convertObjectToJson(sourceObject.get(0), false);
@@ -442,7 +442,7 @@ public class ViewInspectEntitySynchronizer extends AbstractEntitySynchronizer
if (versionNumber != null && jsonPayload != null) {
String requestPayload = searchServiceAdapter.buildBulkImportOperationRequest(getIndexName(),
- se.getId(), jsonPayload);
+ se.getId(), versionNumber, jsonPayload);
NetworkTransaction transactionTracker = new NetworkTransaction();
transactionTracker.setEntityType(esGetTxn.getEntityType());