* ================================================================================
* Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
* Copyright © 2017-2018 Amdocs
+ * Modifications Copyright (C) 2019 IBM
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
import org.eclipse.persistence.dynamic.DynamicType;
import org.eclipse.persistence.internal.helper.DatabaseField;
import org.eclipse.persistence.jaxb.dynamic.DynamicJAXBContext;
+import org.eclipse.persistence.oxm.MediaType;
import org.json.JSONException;
import org.json.JSONObject;
import org.onap.aai.datarouter.entity.AaiEventEntity;
import org.onap.aai.datarouter.entity.AggregationEntity;
import org.onap.aai.datarouter.entity.DocumentStoreDataEntity;
-import org.onap.aai.datarouter.entity.OxmEntityDescriptor;
import org.onap.aai.datarouter.entity.SuggestionSearchEntity;
import org.onap.aai.datarouter.entity.TopographicalEntity;
import org.onap.aai.datarouter.entity.UebEventHeader;
import org.onap.aai.datarouter.logging.EntityEventPolicyMsgs;
-import org.onap.aai.datarouter.util.CrossEntityReference;
-import org.onap.aai.datarouter.util.EntityOxmReferenceHelper;
-import org.onap.aai.datarouter.util.ExternalOxmModelProcessor;
import org.onap.aai.datarouter.util.NodeUtils;
-import org.onap.aai.datarouter.util.OxmModelLoader;
import org.onap.aai.datarouter.util.RouterServiceUtil;
import org.onap.aai.datarouter.util.SearchServiceAgent;
import org.onap.aai.datarouter.util.SearchSuggestionPermutation;
-import org.onap.aai.datarouter.util.Version;
-import org.onap.aai.datarouter.util.VersionedOxmEntities;
+import org.onap.aai.entity.OxmEntityDescriptor;
+import org.onap.aai.util.CrossEntityReference;
+import org.onap.aai.util.EntityOxmReferenceHelper;
+import org.onap.aai.util.ExternalOxmModelProcessor;
+import org.onap.aai.schema.OxmModelLoader;
+import org.onap.aai.setup.SchemaVersions;
+import org.onap.aai.util.Version;
+import org.onap.aai.util.VersionedOxmEntities;
import org.onap.aai.cl.api.Logger;
import org.onap.aai.cl.eelf.LoggerFactory;
import org.onap.aai.cl.mdc.MdcContext;
this.externalOxmModelProcessors = new ArrayList<>();
this.externalOxmModelProcessors.add(EntityOxmReferenceHelper.getInstance());
OxmModelLoader.registerExternalOxmModelProcessors(externalOxmModelProcessors);
- OxmModelLoader.loadModels();
+ OxmModelLoader.loadModels(config.getSchemaVersions(), config.getSchemaLocationsBean());
oxmVersionContextMap = OxmModelLoader.getVersionContextMap();
parseLatestOxmVersion();
}
String uebPayload = exchange.getIn().getBody().toString();
- JsonNode uebAsJson =null;
+ JsonNode uebAsJson = null;
ObjectMapper mapper = new ObjectMapper();
try{
uebAsJson = mapper.readTree(uebPayload);
return;
}
- DynamicJAXBContext oxmJaxbContext = loadOxmContext(oxmVersion.toLowerCase());
+ DynamicJAXBContext oxmJaxbContext = loadOxmContext(oxmVersion);
if (oxmJaxbContext == null) {
logger.error(EntityEventPolicyMsgs.OXM_VERSION_NOT_SUPPORTED, oxmVersion);
logger.debug(EntityEventPolicyMsgs.DISCARD_EVENT_VERBOSE, "OXM version mismatch",
// Process for building AaiEventEntity object
- String[] entityTypeArr = entityType.split("-");
- String oxmEntityType = "";
- for (String entityWord : entityTypeArr) {
- oxmEntityType += entityWord.substring(0, 1).toUpperCase() + entityWord.substring(1);
- }
+ String oxmEntityType = new OxmEntityTypeConverter().convert(entityType);
List<String> searchableAttr =
getOxmAttributes(uebPayload, oxmJaxbContext, oxmEntityType, entityType, "searchable");
* Use the versioned OXM Entity class to get access to cross-entity reference helper collections
*/
VersionedOxmEntities oxmEntities =
- EntityOxmReferenceHelper.getInstance().getVersionedOxmEntities(Version.valueOf(oxmVersion));
+ EntityOxmReferenceHelper.getInstance().getVersionedOxmEntities(Version.valueOf(oxmVersion.toLowerCase()));
/**
* NOTES:
JSONObject entityJsonObject = getUebEntity(uebPayload);
- JsonNode entityJsonNode = convertToJsonNode(entityJsonObject.toString());
+ JsonNode entityJsonNode =
+ convertToJsonNode(entityJsonObject !=null ? entityJsonObject.toString() : "");
String parentEntityType = entityType;
if (!sourceObject.isEmpty()) {
JsonNode node = sourceObject.get(0);
final String sourceCer = NodeUtils.extractFieldValueFromObject(node,
- "crossEntityReferenceValues");
+ "crossReferenceEntityValues");
String newCer = aaiEventEntity.getCrossReferenceEntityValues();
boolean hasNewCer = true;
if (sourceCer != null && sourceCer.length() > 0){ // already has CER
if (hasNewCer){
// Do the PUT with new CER
- ((ObjectNode)node).put("crossEntityReferenceValues", newCer);
+ ((ObjectNode)node).put("crossReferenceEntityValues", newCer);
jsonPayload = NodeUtils.convertObjectToJson(node, false);
searchAgent.putDocument(entitySearchIndex, entityId, jsonPayload, headers);
}
logger.error(EntityEventPolicyMsgs.NO_ETAG_AVAILABLE_FAILURE, index,
entityId);
}
+
+ /*
+ * The Spring-Boot version of the search-data-service rejects the DELETE operation unless
+ * we specify a Content-Type.
+ */
+
+ headers.put("Content-Type", Arrays.asList(MediaType.APPLICATION_JSON.getMediaType()));
searchAgent.deleteDocument(index, eventEntity.getId(), headers);
} else {