public void setLink(String link) {
this.link = link;
}
+
+ @Override
public String getId() {
// make sure that deliveFields() is called before getting the id
return id;
}
- Map<String, String> attributes = new HashMap<String, String>();
+ Map<String, String> attributes = new HashMap<>();
ObjectMapper mapper = new ObjectMapper();
/**
while (nodes.hasNext()) {
Map.Entry<String, JsonNode> entry = (Map.Entry<String, JsonNode>) nodes.next();
- if (!entry.getKey().equalsIgnoreCase("relationship-list")){
+ if (!"relationship-list".equalsIgnoreCase(entry.getKey())){
attributes.put(entry.getKey(), entry.getValue().asText());
}
}
}
public void copyAttributeKeyValuePair(Map<String, Object> map){
- for(String key: map.keySet()){
- if (!key.equalsIgnoreCase("relationship-list")){ // ignore relationship data which is not required in aggregation
- this.attributes.put(key, map.get(key).toString()); // not sure if entity attribute can contain an object as value
+ for(Map.Entry<String, Object> entry: map.entrySet()){
+ String key = entry.getKey();
+ Object value = entry.getValue();
+ if (!"relationship-list".equalsIgnoreCase(key)){ // ignore relationship data which is not required in aggregation
+ this.attributes.put(key, value.toString()); // not sure if entity attribute can contain an object as value
}
}
}
-
+
public void addAttributeKeyValuePair(String key, String value){
this.attributes.put(key, value);
}
ObjectNode rootNode = mapper.createObjectNode();
rootNode.put("link", this.getLink());
rootNode.put("lastmodTimestamp", lastmodTimestamp);
- for (String key: this.attributes.keySet()){
- rootNode.put(key, this.attributes.get(key));
+ for (Map.Entry<String, String> entry: this.attributes.entrySet()){
+ String key = entry.getKey();
+ String value = entry.getValue();
+ rootNode.put(key, value);
}
return rootNode.toString();
}
private Map<String, String> inputOutputData = new HashMap<>();
private Map<String, UiFilterConfig> filters = new HashMap<>();
private JSONObject filterPayload = new JSONObject();
- private StringBuffer searchSuggestionDisplayString = new StringBuffer();
+ private StringBuilder searchSuggestionDisplayString = new StringBuilder();
private JSONArray payloadFilters = new JSONArray();
private UiFiltersSchemaUtility filtersSchemaUtility = new UiFiltersSchemaUtility();
}
}
- ArrayList<String> listOfSearchSuggestionPermutations = new ArrayList<String>();
+ ArrayList<String> listOfSearchSuggestionPermutations = new ArrayList<>();
ArrayList<String> listToPermutate =
new ArrayList<>(this.getInputOutputData().values());
JSONObject rootNode = new JSONObject();
JSONArray inputArray = new JSONArray();
JSONObject payloadNode = new JSONObject();
- StringBuffer outputString = new StringBuffer();
+ StringBuilder outputString = new StringBuilder();
int payloadEntryCounter = 1;
inputOutputData.put(attribute, entityFromUebEvent.get(attribute).asText());
if(filterConfig != null) {
- JSONObject filterPayload = new JSONObject();
- filterPayload.put(FILTER_ID, filterConfig.getFilterId());
- filterPayload.put(FILTER_VALUE, entityFromUebEvent.get(attribute).asText());
- this.payloadFilters.put(filterPayload);
+ JSONObject jsonFilterPayload = new JSONObject();
+ jsonFilterPayload.put(FILTER_ID, filterConfig.getFilterId());
+ jsonFilterPayload.put(FILTER_VALUE, entityFromUebEvent.get(attribute).asText());
+ this.payloadFilters.put(jsonFilterPayload);
} else {
this.filterPayload.put(attribute, entityFromUebEvent.get(attribute).asText());
}
return id;
}
- public StringBuffer getSearchSuggestionDisplayString() {
+ public StringBuilder getSearchSuggestionDisplayString() {
return searchSuggestionDisplayString;
}
return inputOutputData;
}
- public void setSearchSuggestionDisplayString(StringBuffer searchSuggestionDisplayString) {
+ public void setSearchSuggestionDisplayString(StringBuilder searchSuggestionDisplayString) {
this.searchSuggestionDisplayString = searchSuggestionDisplayString;
}
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
+import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
private Logger logger;
private Logger metricsLogger;
- private Logger auditLogger;
public enum ResponseType {
SUCCESS, PARTIAL_SUCCESS, FAILURE;
LoggerFactory loggerFactoryInstance = LoggerFactory.getInstance();
logger = loggerFactoryInstance.getLogger(EntityEventPolicy.class.getName());
metricsLogger = loggerFactoryInstance.getMetricsLogger(EntityEventPolicy.class.getName());
- auditLogger = loggerFactoryInstance.getAuditLogger(EntityEventPolicy.class.getName());
+
srcDomain = config.getSourceDomain();
config.getSearchEndpointDocuments(),
logger);
- this.externalOxmModelProcessors = new ArrayList<ExternalOxmModelProcessor>();
+ this.externalOxmModelProcessors = new ArrayList<>();
this.externalOxmModelProcessors.add(EntityOxmReferenceHelper.getInstance());
OxmModelLoader.registerExternalOxmModelProcessors(externalOxmModelProcessors);
OxmModelLoader.loadModels();
*/
public static String convertObjectToJson(Object object, boolean pretty)
throws JsonProcessingException {
- ObjectWriter ow = null;
+ ObjectWriter ow;
if (pretty) {
ow = new ObjectMapper().writer().withDefaultPrettyPrinter();
return;
}
- UebEventHeader eventHeader = null;
+ UebEventHeader eventHeader;
eventHeader = initializeUebEventHeader(uebObjHeader.toString());
// Get src domain from header; discard event if not originated from same domain
String targetEntityUrl = entityLink;
- for (String key : crossEntityRefMap.keySet()) {
+ for (Map.Entry<String, CrossEntityReference> entry : crossEntityRefMap.entrySet()) {
/*
* if we know service-subscription is in the tree, then we can pull our all instances and
* process from there.
*/
- CrossEntityReference cerDescriptor = crossEntityRefMap.get(key);
+ String key = entry.getKey();
+ CrossEntityReference cerDescriptor = entry.getValue();
- ArrayList<JsonNode> foundNodes = new ArrayList<JsonNode>();
+ ArrayList<JsonNode> foundNodes = new ArrayList<>();
RouterServiceUtil.extractObjectsByKey(entityJsonNode, key, foundNodes);
- if (foundNodes.size() > 0) {
+ if (!foundNodes.isEmpty()) {
for (JsonNode n : foundNodes) {
- if (parentEntityType.equalsIgnoreCase("customer")){
+ if ("customer".equalsIgnoreCase(parentEntityType)){
/*
* NOTES:
* 1. prepare to hand-create url for service-instance
}
- List<String> extractedParentEntityAttributeValues = new ArrayList<String>();
+ List<String> extractedParentEntityAttributeValues = new ArrayList<>();
RouterServiceUtil.extractFieldValuesFromObject(n, cerDescriptor.getAttributeNames(),
extractedParentEntityAttributeValues);
- List<JsonNode> nestedTargetEntityInstances = new ArrayList<JsonNode>();
+ List<JsonNode> nestedTargetEntityInstances = new ArrayList<>();
RouterServiceUtil.extractObjectsByKey(n, cerDescriptor.getTargetEntityType(),
nestedTargetEntityInstances);
if (targetEntityInstance.has("link")) { // nested SI has url mentioned
targetEntityUrl = RouterServiceUtil.getNodeFieldAsText(targetEntityInstance,
"link");
- } else if (parentEntityType.equalsIgnoreCase("customer") &&
+ } else if ("customer".equalsIgnoreCase(parentEntityType) &&
targetEntityInstance.has("service-instance-id")){
targetEntityUrl += "/" + RouterServiceUtil.getNodeFieldAsText(targetEntityInstance,
"service-instance-id");
Map<String, OxmEntityDescriptor> rootDescriptor =
oxmEntities.getSuggestableEntityDescriptors();
if (!rootDescriptor.isEmpty()) {
- List<String> suggestibleAttrInPayload = new ArrayList<String>();
+ List<String> suggestibleAttrInPayload = new ArrayList<>();
List<String> suggestibleAttrInOxm = extractSuggestableAttr(oxmEntities, entityType);
if (suggestibleAttrInOxm != null) {
for (String attr: suggestibleAttrInOxm){
}
public List<String> extractSuggestableAttr(VersionedOxmEntities oxmEntities, String entityType) {
- // Extract suggestable attributes
+ // Extract suggestable attributeshandleTopographicalData
Map<String, OxmEntityDescriptor> rootDescriptor = oxmEntities.getSuggestableEntityDescriptors();
if (rootDescriptor == null) {
- return null;
+ return Collections.emptyList();
}
OxmEntityDescriptor desc = rootDescriptor.get(entityType);
if (desc == null) {
- return null;
+ return Collections.emptyList();
}
return desc.getSuggestableAttributes();
Map<String, OxmEntityDescriptor> rootDescriptor = oxmEntities.getEntityAliasDescriptors();
if (rootDescriptor == null) {
- return null;
+ return Collections.emptyList();
}
OxmEntityDescriptor desc = rootDescriptor.get(entityType);
jsonNode = mapper.readTree(mapper.getJsonFactory().createJsonParser(payload));
} catch (IOException e) {
logger.debug(EntityEventPolicyMsgs.FAILED_TO_PARSE_UEB_PAYLOAD, ENTITY_HEADER + " missing",
- payload.toString());
+ payload);
logger.error(EntityEventPolicyMsgs.FAILED_TO_PARSE_UEB_PAYLOAD, ENTITY_HEADER + " missing",
"");
}
boolean hasSearchableAttr = false;
for (String searchTagField : searchableAttr) {
- String searchTagValue = null;
+ String searchTagValue;
if (searchTagField.equalsIgnoreCase(aaiEventEntity.getEntityPrimaryKeyName())) {
searchTagValue = aaiEventEntity.getEntityPrimaryKeyValue();
} else {
d.setEntityType(resultDescriptor.getEntityName());
- List<String> primaryKeyValues = new ArrayList<String>();
- List<String> primaryKeyNames = new ArrayList<String>();
- String pkeyValue = null;
+ List<String> primaryKeyValues = new ArrayList<>();
+ List<String> primaryKeyNames = new ArrayList<>();
+ String pkeyValue;
for (String keyName : resultDescriptor.getPrimaryKeyAttributeName()) {
pkeyValue = RouterServiceUtil.getNodeFieldAsText(entityNode, keyName);
headers.put(Headers.TRANSACTION_ID, Arrays.asList(MDC.get(MdcContext.MDC_REQUEST_ID)));
String entityId = aaiEventEntity.getId();
- String jsonPayload = aaiEventEntity.getAsJson();
+ String jsonPayload;
// Run the GET to retrieve the ETAG from the search service
OperationResult storedEntity = searchAgent.getDocument(entitySearchIndex, entityId);
List<String> etag = storedEntity.getHeaders().get(Headers.ETAG);
- if (etag != null && etag.size() > 0) {
+ if (etag != null && !etag.isEmpty()) {
headers.put(Headers.IF_MATCH, etag);
} else {
logger.error(EntityEventPolicyMsgs.NO_ETAG_AVAILABLE_FAILURE,
entitySearchIndex, entityId);
}
- ArrayList<JsonNode> sourceObject = new ArrayList<JsonNode>();
+ ArrayList<JsonNode> sourceObject = new ArrayList<>();
NodeUtils.extractObjectsByKey(
NodeUtils.convertJsonStrToJsonNode(storedEntity.getResult()),
"content", sourceObject);
if (HttpUtil.isHttpResponseClassSuccess(storedEntity.getResultCode())) {
List<String> etag = storedEntity.getHeaders().get(Headers.ETAG);
- if (etag != null && etag.size() > 0) {
+ if (etag != null && !etag.isEmpty()) {
headers.put(Headers.IF_MATCH, etag);
} else {
logger.error(EntityEventPolicyMsgs.NO_ETAG_AVAILABLE_FAILURE, index,
if (HttpUtil.isHttpResponseClassSuccess(storedEntity.getResultCode())) {
List<String> etag = storedEntity.getHeaders().get(Headers.ETAG);
- if (etag != null && etag.size() > 0) {
+ if (etag != null && !etag.isEmpty()) {
headers.put(Headers.IF_MATCH, etag);
} else {
logger.error(EntityEventPolicyMsgs.NO_ETAG_AVAILABLE_FAILURE, index,
String entityPrimaryKeyFieldValue) {
Map<String, String> topoData = new HashMap<>();
- String entityLink = "";
+ String entityLink;
List<String> topographicalAttr =
getOxmAttributes(payload, oxmJaxbContext, oxmEntityType, entityType, "geoProps");
if (topographicalAttr == null) {
"Topograhical attribute not found for payload entity type '" + entityType + "'");
logger.debug(EntityEventPolicyMsgs.DISCARD_UPDATING_TOPOGRAPHY_DATA_VERBOSE,
"Topograhical attribute not found for payload entity type '" + entityType + "'",
- payload.toString());
+ payload);
} else {
entityLink = lookupValueUsingKey(payload, "entity-link");
for (String topoAttr : topographicalAttr) {