diff options
Diffstat (limited to 'src/main/java/org/openecomp')
10 files changed, 8 insertions, 1379 deletions
diff --git a/src/main/java/org/openecomp/datarouter/entity/AaiEventEntity.java b/src/main/java/org/openecomp/datarouter/entity/AaiEventEntity.java deleted file mode 100644 index 437db06..0000000 --- a/src/main/java/org/openecomp/datarouter/entity/AaiEventEntity.java +++ /dev/null @@ -1,303 +0,0 @@ -/** - * ============LICENSE_START======================================================= - * org.onap.aai - * ================================================================================ - * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * Copyright © 2017 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========================================================= - * - * ECOMP is a trademark and service mark of AT&T Intellectual Property. - */ -/* -* ============LICENSE_START======================================================= -* DataRouter -* ================================================================================ -* Copyright © 2017 AT&T Intellectual Property. -* Copyright © 2017 Amdocs -* All rights reserved. -* ================================================================================ -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -* ============LICENSE_END========================================================= -* -* ECOMP and OpenECOMP are trademarks -* and service marks of AT&T Intellectual Property. -*/ - -package org.openecomp.datarouter.entity; - -import java.io.IOException; -import java.io.Serializable; -import java.security.MessageDigest; -import java.security.NoSuchAlgorithmException; -import java.sql.Timestamp; -import java.text.SimpleDateFormat; -import java.util.ArrayList; -import java.util.List; - -import javax.json.Json; -import javax.json.JsonObject; - -import org.openecomp.datarouter.util.NodeUtils; - -/** - * Note: AAIEventEntity is a port forward of IndexDocument Has been renamed here to move forward - * with abstraction of document store technology. - */ -public class AaiEventEntity implements DocumentStoreDataEntity, Serializable { - - private static final long serialVersionUID = -5188479658230319058L; - - protected String entityType; - protected String entityPrimaryKeyName; - protected String entityPrimaryKeyValue; - protected ArrayList<String> searchTagCollection = new ArrayList<String>(); - protected ArrayList<String> searchTagIdCollection = new ArrayList<String>(); - protected ArrayList<String> crossEntityReferenceCollection = new ArrayList<String>(); - protected String lastmodTimestamp; - protected String link; - - private static final String TIMESTAMP_FORMAT = "yyyy-MM-dd'T'HH:mm:ss.SSSZ"; - /* - * Generated fields, leave the settings for junit overrides - */ - - // generated, SHA-256 digest - protected String id; - - /* - * generated based on searchTagCollection values - */ - protected String searchTags; - protected String searchTagIds; - protected String crossReferenceEntityValues; - - - private static String convertBytesToHexString(byte[] bytesToConvert) { - StringBuffer hexString = new StringBuffer(); - for (int i = 0; i < bytesToConvert.length; i++) { - hexString.append(Integer.toHexString(0xFF & bytesToConvert[i])); - } - return hexString.toString(); - } - - private static String concatArray(List<String> list, char delimiter) { - - if (list == null || list.size() == 0) { - return ""; - } - - StringBuilder result = new StringBuilder(64); - - int listSize = list.size(); - boolean firstValue = true; - - for (String item : list) { - - if (firstValue) { - result.append(item); - firstValue = false; - } else { - result.append(delimiter).append(item); - } - - } - - return result.toString(); - - } - - public AaiEventEntity() { - SimpleDateFormat dateFormat = new SimpleDateFormat(TIMESTAMP_FORMAT); - Timestamp timestamp = new Timestamp(System.currentTimeMillis()); - String currentFormattedTimeStamp = dateFormat.format(timestamp); - this.lastmodTimestamp = currentFormattedTimeStamp; - } - - public void deriveFields() throws NoSuchAlgorithmException { - this.id = NodeUtils.generateUniqueShaDigest(link); - this.searchTags = concatArray(searchTagCollection, ';'); - this.searchTagIds = concatArray(searchTagIdCollection, ';'); - this.crossReferenceEntityValues = concatArray(crossEntityReferenceCollection, ';'); - } - - - /* - * (non-Javadoc) - * - * @see org.openecomp.datarouter.entity.AAIEventEntity#getAsJson() - */ - @Override - public String getAsJson() throws IOException { - - JsonObject obj = Json.createObjectBuilder().add("entityType", entityType) - .add("entityPrimaryKeyValue", entityPrimaryKeyValue).add("searchTagIDs", searchTagIds) - .add("searchTags", searchTags).add("crossEntityReferenceValues", crossReferenceEntityValues) - .add("lastmodTimestamp", lastmodTimestamp).add("link", link).build(); - - return obj.toString(); - } - - - public void addSearchTagWithKey(String searchTag, String key) { - searchTagIdCollection.add(key); - searchTagCollection.add(searchTag); - } - - public void addCrossEntityReferenceValue(String crossEntityReferenceValue) { - if (!crossEntityReferenceCollection.contains(crossEntityReferenceValue)) { - crossEntityReferenceCollection.add(crossEntityReferenceValue); - } - } - - public String getEntityType() { - return entityType; - } - - public String getEntityPrimaryKeyName() { - return entityPrimaryKeyName; - } - - public String getEntityPrimaryKeyValue() { - return entityPrimaryKeyValue; - } - - - /* - * (non-Javadoc) - * - * @see org.openecomp.datarouter.entity.AAIEventEntity#getId() - */ - @Override - public String getId() { - return id; - } - - public ArrayList<String> getSearchTagCollection() { - return searchTagCollection; - } - - public String getSearchTags() { - return searchTags; - } - - public String getSearchTagIDs() { - return searchTagIds; - } - - public void setSearchTagIDs(String searchTagIDs) { - this.searchTagIds = searchTagIDs; - } - - public void setEntityType(String entityType) { - this.entityType = entityType; - } - - public void setId(String id) { - this.id = id; - } - - public void setSearchTagCollection(ArrayList<String> searchTagCollection) { - this.searchTagCollection = searchTagCollection; - } - - public void setSearchTags(String searchTags) { - this.searchTags = searchTags; - } - - public ArrayList<String> getSearchTagIdCollection() { - return searchTagIdCollection; - } - - public void setSearchTagIdCollection(ArrayList<String> searchTagIdCollection) { - this.searchTagIdCollection = searchTagIdCollection; - } - - public String getLastmodTimestamp() { - return lastmodTimestamp; - } - - public void setLastmodTimestamp(String lastmodTimestamp) { - this.lastmodTimestamp = lastmodTimestamp; - } - - public void setEntityPrimaryKeyName(String entityPrimaryKeyName) { - this.entityPrimaryKeyName = entityPrimaryKeyName; - } - - public void setEntityPrimaryKeyValue(String entityPrimaryKeyValue) { - this.entityPrimaryKeyValue = entityPrimaryKeyValue; - } - - public String getLink() { - return link; - } - - public void setLink(String link) { - this.link = link; - } - - /* - * public void mergeEntity(AAIEventEntity entityToMergeIn) { - * - * if ( entityToMergeIn == null ) { return; } - * - * if ( !entityToMergeIn.getEntityType().equals( entityType )) { entityType = - * entityToMergeIn.getEntityType(); } - * - * if ( !entityToMergeIn.getEntityType().equals( entityType )) { entityType = - * entityToMergeIn.getEntityType(); } - * - * } - */ - - public String getCrossReferenceEntityValues() { - return crossReferenceEntityValues; - } - - public void setCrossReferenceEntityValues(String crossReferenceEntityValues) { - this.crossReferenceEntityValues = crossReferenceEntityValues; - } - - @Override - public String toString() { - return "AAIEventEntity [" + (entityType != null ? "entityType=" + entityType + ", " : "") - + (entityPrimaryKeyName != null ? "entityPrimaryKeyName=" + entityPrimaryKeyName + ", " - : "") - + (entityPrimaryKeyValue != null ? "entityPrimaryKeyValue=" + entityPrimaryKeyValue + ", " - : "") - + (searchTagCollection != null ? "searchTagCollection=" + searchTagCollection + ", " : "") - + (searchTagIdCollection != null ? "searchTagIDCollection=" + searchTagIdCollection + ", " - : "") - + (crossEntityReferenceCollection != null - ? "crossEntityReferenceCollection=" + crossEntityReferenceCollection + ", " : "") - + "lastmodTimestamp=" + lastmodTimestamp + ", " + (id != null ? "id=" + id + ", " : "") - + (searchTags != null ? "searchTags=" + searchTags + ", " : "") - + (searchTagIds != null ? "searchTagIDs=" + searchTagIds + ", " : "") - + (crossReferenceEntityValues != null - ? "crossReferenceEntityValues=" + crossReferenceEntityValues : "") - + "]"; - } - -} diff --git a/src/main/java/org/openecomp/datarouter/entity/AggregationEntity.java b/src/main/java/org/openecomp/datarouter/entity/AggregationEntity.java deleted file mode 100644 index 57a5f5c..0000000 --- a/src/main/java/org/openecomp/datarouter/entity/AggregationEntity.java +++ /dev/null @@ -1,122 +0,0 @@ -/** - * ============LICENSE_START======================================================= - * org.onap.aai - * ================================================================================ - * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * Copyright © 2017 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========================================================= - * - * ECOMP is a trademark and service mark of AT&T Intellectual Property. - */ -package org.openecomp.datarouter.entity; - -import java.io.Serializable; -import java.util.Arrays; -import java.util.HashMap; -import java.util.Iterator; -import java.util.Map; -import java.util.Map.Entry; - -import org.openecomp.datarouter.util.NodeUtils; - -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.node.ObjectNode; - -/** - * The Class AggregationEntity. Mimics functionality of AAIUI's AggregationEntity - */ -public class AggregationEntity implements DocumentStoreDataEntity, Serializable { - private String id; - private String link; - private String lastmodTimestamp; - - public String getLink() { - return link; - } - public void setLink(String link) { - this.link = link; - } - public String getId() { - // make sure that deliveFields() is called before getting the id - return id; - } - public void setId(String id) { - this.id = id; - } - - - public String getLastmodTimestamp() { - return lastmodTimestamp; - } - public void setLastmodTimestamp(String lastmodTimestamp) { - this.lastmodTimestamp = lastmodTimestamp; - } - - - Map<String, String> attributes = new HashMap<String, String>(); - ObjectMapper mapper = new ObjectMapper(); - - /** - * Instantiates a new aggregation entity. - */ - public AggregationEntity() { } - - public void deriveFields(JsonNode uebPayload) { - - this.setId(NodeUtils.generateUniqueShaDigest(link)); - - this.setLastmodTimestamp(Long.toString(System.currentTimeMillis())); - - JsonNode entityNode = uebPayload.get("entity"); - - Iterator<Entry<String, JsonNode>> nodes = entityNode.fields(); - - while (nodes.hasNext()) { - Map.Entry<String, JsonNode> entry = (Map.Entry<String, JsonNode>) nodes.next(); - if (!entry.getKey().equalsIgnoreCase("relationship-list")){ - 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 - } - } - } - - public void addAttributeKeyValuePair(String key, String value){ - this.attributes.put(key, value); - } - - public String getAsJson() { - 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)); - } - return rootNode.toString(); - } - - @Override - public String toString() { - return "AggregationEntity [id=" + id + ", link=" + link + ", attributes=" + attributes - + ", mapper=" + mapper + "]"; - } -} diff --git a/src/main/java/org/openecomp/datarouter/entity/DocumentStoreDataEntity.java b/src/main/java/org/openecomp/datarouter/entity/DocumentStoreDataEntity.java deleted file mode 100644 index d62ab91..0000000 --- a/src/main/java/org/openecomp/datarouter/entity/DocumentStoreDataEntity.java +++ /dev/null @@ -1,33 +0,0 @@ -/** - * ============LICENSE_START======================================================= - * org.onap.aai - * ================================================================================ - * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * Copyright © 2017 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========================================================= - * - * ECOMP is a trademark and service mark of AT&T Intellectual Property. - */ -package org.openecomp.datarouter.entity; - -import java.io.IOException; - -public interface DocumentStoreDataEntity { - - public String getId(); - - public String getAsJson() throws IOException; - -} diff --git a/src/main/java/org/openecomp/datarouter/entity/OxmEntityDescriptor.java b/src/main/java/org/openecomp/datarouter/entity/OxmEntityDescriptor.java deleted file mode 100644 index cbd2b96..0000000 --- a/src/main/java/org/openecomp/datarouter/entity/OxmEntityDescriptor.java +++ /dev/null @@ -1,124 +0,0 @@ -/** - * ============LICENSE_START======================================================= - * org.onap.aai - * ================================================================================ - * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * Copyright © 2017 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========================================================= - * - * ECOMP is a trademark and service mark of AT&T Intellectual Property. - */ -package org.openecomp.datarouter.entity; - -import java.util.List; - -import org.openecomp.datarouter.util.CrossEntityReference; - - -public class OxmEntityDescriptor { - - private String entityName; - - private List<String> primaryKeyAttributeName; - - private List<String> searchableAttributes; - - private CrossEntityReference crossEntityReference; - - private List<String> alias; - - private List<String> suggestableAttributes; - - boolean isSuggestableEntity; - - public String getEntityName() { - return entityName; - } - - public void setEntityName(String entityName) { - this.entityName = entityName; - } - - public List<String> getPrimaryKeyAttributeName() { - return primaryKeyAttributeName; - } - - public void setPrimaryKeyAttributeName(List<String> primaryKeyAttributeName) { - this.primaryKeyAttributeName = primaryKeyAttributeName; - } - - public List<String> getSearchableAttributes() { - return searchableAttributes; - } - - public void setSearchableAttributes(List<String> searchableAttributes) { - this.searchableAttributes = searchableAttributes; - } - - public boolean hasSearchableAttributes() { - - if ( this.searchableAttributes == null) { - return false; - } - - if ( this.searchableAttributes.size() > 0 ) { - return true; - } - - return false; - - } - - public CrossEntityReference getCrossEntityReference() { - return crossEntityReference; - } - - public void setCrossEntityReference(CrossEntityReference crossEntityReference) { - this.crossEntityReference = crossEntityReference; - } - - public List<String> getAlias() { - return alias; - } - - public void setAlias(List<String> alias) { - this.alias = alias; - } - - public List<String> getSuggestableAttributes() { - return suggestableAttributes; - } - - public void setSuggestableAttributes(List<String> suggestableAttributes) { - this.suggestableAttributes = suggestableAttributes; - } - - public boolean isSuggestableEntity() { - return isSuggestableEntity; - } - - public void setSuggestableEntity(boolean isSuggestableEntity) { - this.isSuggestableEntity = isSuggestableEntity; - } - - @Override - public String toString() { - return "OxmEntityDescriptor [entityName=" + entityName + ", primaryKeyAttributeName=" - + primaryKeyAttributeName + ", searchableAttributes=" + searchableAttributes - + ", crossEntityReference=" + crossEntityReference + ", alias=" + alias - + ", suggestableAttributes=" + suggestableAttributes + ", isSuggestableEntity=" - + isSuggestableEntity + "]"; - } -}
\ No newline at end of file diff --git a/src/main/java/org/openecomp/datarouter/entity/PolicyResponse.java b/src/main/java/org/openecomp/datarouter/entity/PolicyResponse.java deleted file mode 100644 index 558f701..0000000 --- a/src/main/java/org/openecomp/datarouter/entity/PolicyResponse.java +++ /dev/null @@ -1,70 +0,0 @@ -/** - * ============LICENSE_START======================================================= - * org.onap.aai - * ================================================================================ - * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * Copyright © 2017 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========================================================= - * - * ECOMP is a trademark and service mark of AT&T Intellectual Property. - */ -package org.openecomp.datarouter.entity; - -/** - * Provides information about the level of success of a policy execution against a routed query. - */ -public class PolicyResponse { - - private ResponseType responseType; - - private String responseData; - - private int httpResponseCode; - - public PolicyResponse(ResponseType responseType, String responseData) { - super(); - this.responseType = responseType; - this.responseData = responseData; - } - - public ResponseType getResponseType() { - return responseType; - } - - public String getResponseData() { - return responseData; - } - - - public int getHttpResponseCode() { - return httpResponseCode; - } - - public void setHttpResponseCode(int httpResponseCode) { - this.httpResponseCode = httpResponseCode; - } - - @Override - public String toString() { - return "PolicyResponse [responseType=" + responseType + ", responseData=" + responseData - + ", httpResponseCode=" + httpResponseCode + "]"; - } - - - - public enum ResponseType { - SUCCESS, PARTIAL_SUCCESS, FAILURE; - } -} diff --git a/src/main/java/org/openecomp/datarouter/entity/SuggestionSearchEntity.java b/src/main/java/org/openecomp/datarouter/entity/SuggestionSearchEntity.java deleted file mode 100644 index 59f7f59..0000000 --- a/src/main/java/org/openecomp/datarouter/entity/SuggestionSearchEntity.java +++ /dev/null @@ -1,363 +0,0 @@ -/** - * ============LICENSE_START======================================================= - * org.onap.aai - * ================================================================================ - * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * Copyright © 2017 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========================================================= - * - * ECOMP is a trademark and service mark of AT&T Intellectual Property. - */ -package org.openecomp.datarouter.entity; - -import java.io.IOException; -import java.io.Serializable; -import java.security.NoSuchAlgorithmException; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.json.JSONArray; -import org.json.JSONObject; -import org.openecomp.datarouter.search.filters.config.UiFilterConfig; -import org.openecomp.datarouter.search.filters.config.UiFiltersConfig; -import org.openecomp.datarouter.search.filters.config.UiFiltersSchemaUtility; -import org.openecomp.datarouter.util.NodeUtils; -import org.openecomp.datarouter.util.SearchSuggestionPermutation; - -import com.fasterxml.jackson.databind.JsonNode; - -public class SuggestionSearchEntity implements DocumentStoreDataEntity, Serializable { - private static final long serialVersionUID = -3636393943669310760L; - - private static final String FILTER_ID = "filterId"; - private static final String FILTER_VALUE = "filterValue"; - private static final String FILTER_LIST = "filterList"; - - protected String id; // generated SHA-256 digest - private String entityType; - private List<String> entityTypeAliases; - private List<String> suggestionInputPermutations = new ArrayList<>(); - private List<String> statusPermutations = new ArrayList<>(); - private List<String> suggestableAttr = new ArrayList<>(); - - 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 JSONArray payloadFilters = new JSONArray(); - private UiFiltersSchemaUtility filtersSchemaUtility = new UiFiltersSchemaUtility(); - - public SuggestionSearchEntity() { - UiFiltersConfig filterConfigList = filtersSchemaUtility.loadUiFiltersConfig(); - - // Populate the map with keys that will match the suggestableAttr values - for (UiFilterConfig filter : filterConfigList.getFilters()) { - if (filter.getDataSource() != null) { - filters.put(filter.getDataSource().getFieldName(), filter); - } - } - } - - /** - * Create the search suggestion string to display to the user in the search suggestion drop-down - * - * @throws NoSuchAlgorithmException - */ - public void generateSearchSuggestionDisplayStringAndId() throws NoSuchAlgorithmException { - int payloadEntryCounter = 1; - - for (Map.Entry<String, String> outputValue : inputOutputData.entrySet()) { - if (outputValue.getValue() != null && outputValue.getValue().length() > 0) { - this.searchSuggestionDisplayString.append(outputValue.getValue()); - - if (payloadEntryCounter < inputOutputData.entrySet().size()) { - this.searchSuggestionDisplayString.append(" and "); - } else { - this.searchSuggestionDisplayString.append(" "); - } - } - - payloadEntryCounter++; - } - - this.searchSuggestionDisplayString.append(getEntityTypeAliases().get(0)); - generateSearchSuggestionId(searchSuggestionDisplayString.toString()); - } - - /** - * Generates an ID by encrypting the string to display to the user in the search suggestion - * drop-down - * - * @param outputString The string to create the encrypted ID from - */ - private void generateSearchSuggestionId(String searchSuggestionDisplayString) { - this.id = NodeUtils.generateUniqueShaDigest(searchSuggestionDisplayString); - } - - /** - * Launch pad for performing permutations of the entity type, aliases, prov status and orchestration status. - * SHA-256 will result in an ID with a guaranteed uniqueness compared to just a java hashcode value - * - * @return - */ - public List<String> generateSuggestionInputPermutations() { - List<String> entityNames = new ArrayList<>(); - entityNames.add(entityType); - - if ((entityTypeAliases != null) && !(entityTypeAliases.isEmpty())) { - for (String alias : entityTypeAliases) { - entityNames.add(alias); - } - } - - ArrayList<String> listOfSearchSuggestionPermutations = new ArrayList<String>(); - ArrayList<String> listToPermutate = - new ArrayList<>(this.getInputOutputData().values()); - - for (String entityName : entityNames) { - listToPermutate.add(entityName); - List<List<String>> lists = SearchSuggestionPermutation.getListPermutations(listToPermutate); - for (List<String> li : lists){ - listOfSearchSuggestionPermutations.add(String.join(" ", li)); - } - listToPermutate.remove(entityName); - } - - return listOfSearchSuggestionPermutations; - } - - /** - * Return a custom JSON representation of this class - */ - @Override - public String getAsJson() throws IOException { - if (entityType == null || suggestionInputPermutations == null) { - return null; - } - - JSONObject rootNode = new JSONObject(); - JSONArray inputArray = new JSONArray(); - JSONObject payloadNode = new JSONObject(); - StringBuffer outputString = new StringBuffer(); - - int payloadEntryCounter = 1; - - // Add prov and orchestration status to search suggestion string - for (Map.Entry<String, String> payload : inputOutputData.entrySet()) { - payloadNode.put(payload.getKey(), payload.getValue()); - outputString.append(payload.getValue()); - - if (payloadEntryCounter < inputOutputData.entrySet().size()) { - // Add the word "and" between prov and orchestration statuses, if both are present - outputString.append(" and "); - payloadEntryCounter++; - } - } - - /* Add entity type to search suggestion string. We've decided to use the first entity type alias - * from the OXM */ - outputString.append(" ").append(getEntityTypeAliases().get(0)); - - for (String permutation : suggestionInputPermutations) { - inputArray.put(permutation); - } - - // Build up the search suggestion as JSON - JSONObject entitySuggest = new JSONObject(); - entitySuggest.put("input", inputArray); - entitySuggest.put("output", outputString); - entitySuggest.put("payload", this.filterPayload); - rootNode.put("entity_suggest", entitySuggest); - - return rootNode.toString(); - } - - public boolean isSuggestableDoc() { - return this.getFilterPayload().length() != 0; - } - - /** - * Generate all permutations of Entity Type and (Prov Status and/or Orchestration Status) - * - * @param list The list of unique elements to create permutations of - * @param permutation A list to hold the current permutation used during - * @param size To keep track of the original size of the number of unique elements - * @param listOfSearchSuggestionPermutationList The list to hold all of the different permutations - */ - private void permutateList(List<String> list, List<String> permutation, int size, - List<String> listOfSearchSuggestionPermutationList) { - if (permutation.size() == size) { - StringBuilder newPermutation = new StringBuilder(); - - for (int i = 0; i < permutation.size(); i++) { - newPermutation.append(permutation.get(i)).append(" "); - } - - listOfSearchSuggestionPermutationList.add(newPermutation.toString().trim()); - - return; - } - - String[] availableItems = list.toArray(new String[0]); - - for (String i : availableItems) { - permutation.add(i); - list.remove(i); - permutateList(list, permutation, size, listOfSearchSuggestionPermutationList); - list.add(i); - permutation.remove(i); - } - } - - /** - * Populate a string that will represent the UI filters portion of the JSON payload that's stored in the - * search engine - * - * @param entityFromUebEvent - * @param suggestibleAttrInPayload - */ - public void setFilterBasedPayloadFromResponse(JsonNode entityFromUebEvent, - List<String> suggestibleAttrInOxm, List<String> suggestibleAttrInPayload) { - if (suggestibleAttrInOxm != null) { - for (String attribute : suggestibleAttrInOxm) { - UiFilterConfig filterConfig = filters.get(attribute); - - if (suggestibleAttrInPayload.contains(attribute)) { - 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); - } else { - this.filterPayload.put(attribute, entityFromUebEvent.get(attribute).asText()); - } - } else { - if(filterConfig != null) { - JSONObject emptyValueFilterPayload = new JSONObject(); - emptyValueFilterPayload.put(FILTER_ID, filterConfig.getFilterId()); - this.payloadFilters.put(emptyValueFilterPayload); - } - } - } - - this.filterPayload.put(FILTER_LIST, this.payloadFilters); - } - } - - public void setPayloadFromResponse(JsonNode node) { - if (suggestableAttr != null) { - for (String attribute : suggestableAttr) { - if (node.get(attribute) != null) { - inputOutputData.put(attribute, node.get(attribute).asText()); - this.filterPayload.put(attribute, node.get(attribute).asText()); - } - } - } - } - - public String getEntityType() { - return entityType; - } - - public void setEntityType(String entityType) { - this.entityType = entityType; - } - - public List<String> getEntityTypeAliases() { - return entityTypeAliases; - } - - public void setEntityTypeAliases(List<String> entityTypeAliases) { - this.entityTypeAliases = entityTypeAliases; - } - - @Override - public String getId() { - return id; - } - - public StringBuffer getSearchSuggestionDisplayString() { - return searchSuggestionDisplayString; - } - - public JSONObject getFilterPayload() { - return filterPayload; - } - - public List<String> getStatusPermutations() { - return statusPermutations; - } - - public List<String> getSuggestableAttr() { - return suggestableAttr; - } - - public List<String> getSuggestionInputPermutations() { - return this.suggestionInputPermutations; - } - - public void setId(String id) { - this.id = id; - } - - public void setInputOutputData(Map<String, String> inputOutputData) { - this.inputOutputData = inputOutputData; - } - - public Map<String, String> getInputOutputData() { - return inputOutputData; - } - - public void setSearchSuggestionDisplayString(StringBuffer searchSuggestionDisplayString) { - this.searchSuggestionDisplayString = searchSuggestionDisplayString; - } - - public void setFilterPayload(JSONObject filterPayload) { - this.filterPayload = filterPayload; - } - - public void setFiltersSchemaUtility(UiFiltersSchemaUtility filtersSchemaUtility) { - this.filtersSchemaUtility = filtersSchemaUtility; - } - - public void setStatusPermutations(List<String> statusPermutations) { - this.statusPermutations = statusPermutations; - } - - public void setSuggestableAttr(List<String> attributes) { - for (String attribute : attributes) { - this.suggestableAttr.add(attribute); - } - } - - public void setSuggestionInputPermutations(List<String> permutations) { - this.suggestionInputPermutations = permutations; - } - - @Override - public String toString() { - return "SuggestionSearchEntity [id=" + id + ", entityType=" + entityType - + ", entityTypeAliases=" + entityTypeAliases + ", suggestionInputPermutations=" - + suggestionInputPermutations + ", statusPermutations=" + statusPermutations - + ", suggestableAttr=" + suggestableAttr + ", inputOutputData=" + inputOutputData - + ", filters=" + filters + ", filterPayload=" + filterPayload - + ", searchSuggestionDisplayString=" + searchSuggestionDisplayString + ", payloadFilters=" - + payloadFilters + "]"; - } -} diff --git a/src/main/java/org/openecomp/datarouter/entity/TopographicalEntity.java b/src/main/java/org/openecomp/datarouter/entity/TopographicalEntity.java deleted file mode 100644 index 7e4aa3b..0000000 --- a/src/main/java/org/openecomp/datarouter/entity/TopographicalEntity.java +++ /dev/null @@ -1,189 +0,0 @@ -/** - * ============LICENSE_START======================================================= - * org.onap.aai - * ================================================================================ - * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * Copyright © 2017 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========================================================= - * - * ECOMP is a trademark and service mark of AT&T Intellectual Property. - */ -package org.openecomp.datarouter.entity; - -import java.io.IOException; -import java.io.Serializable; -import java.security.MessageDigest; -import java.security.NoSuchAlgorithmException; -import java.util.List; - -import javax.json.Json; -import javax.json.JsonObject; - -public class TopographicalEntity implements DocumentStoreDataEntity, Serializable { - - private static final long serialVersionUID = -5188479658230319058L; - - protected String entityType; - protected String entityPrimaryKeyValue; - protected String entityPrimaryKeyName; - protected String latitude; - protected String longitude; - protected String selfLink; - - // generated, SHA-256 digest - protected String id; - - private static String convertBytesToHexString(byte[] bytesToConvert) { - StringBuffer hexString = new StringBuffer(); - for (int i = 0; i < bytesToConvert.length; i++) { - hexString.append(Integer.toHexString(0xFF & bytesToConvert[i])); - } - return hexString.toString(); - } - - private static String concatArray(List<String> list, char delimiter) { - - if (list == null || list.size() == 0) { - return ""; - } - - StringBuilder result = new StringBuilder(64); - - int listSize = list.size(); - boolean firstValue = true; - - for (String item : list) { - - if (firstValue) { - result.append(item); - firstValue = false; - } else { - result.append(delimiter).append(item); - } - } - - return result.toString(); - } - - /* - * We'll try and create a unique identity key that we can use for - * differencing the previously imported record sets as we won't have granular - * control of what is created/removed and when. The best we can hope for is - * identification of resources by generated Id until the Identity-Service - * UUID is tagged against all resources, then we can use that instead. - */ - public static String generateUniqueShaDigest(String entityType, String fieldName, - String fieldValue) throws NoSuchAlgorithmException { - - /* - * Basically SHA-256 will result in an identity with a guaranteed - * uniqueness compared to just a java hashcode value. - */ - MessageDigest digest = MessageDigest.getInstance("SHA-256"); - digest.update(String.format("%s.%s.%s", entityType, fieldName, fieldValue).getBytes()); - return convertBytesToHexString(digest.digest()); - } - - public TopographicalEntity() {} - - /* - * (non-Javadoc) - * - * @see org.openecomp.datarouter.entity.TopographicalEntity#getAsJson() - */ - public String getAsJson() throws IOException { - - JsonObject obj = - Json.createObjectBuilder().add("entityType", entityType) - .add("pkey", entityPrimaryKeyValue) - .add("location", Json.createObjectBuilder() - .add("lat", latitude) - .add("lon", longitude)) - .add("selfLink", selfLink).build(); - - return obj.toString(); - } - - - @Override - public String toString() { - return "TopographicalEntity [" + ("entityType=" + entityType + ", ") - + ("entityPrimaryKeyValue=" + entityPrimaryKeyValue + ", ") - + ("latitude=" + latitude + ", ") + ("longitude=" + longitude + ", ") - + ("ID=" + id + ", ") - + ("selfLink=" + selfLink) + "]"; - } - - @Override - public String getId() { - return this.id; - } - - public String getEntityType() { - return entityType; - } - - public void setEntityType(String entityType) { - this.entityType = entityType; - } - - public String getEntityPrimaryKeyValue() { - return entityPrimaryKeyValue; - } - - public void setEntityPrimaryKeyValue(String entityPrimaryKeyValue) { - this.entityPrimaryKeyValue = entityPrimaryKeyValue; - } - - public String getEntityPrimaryKeyName() { - return entityPrimaryKeyName; - } - - public void setEntityPrimaryKeyName(String entityPrimaryKeyName) { - this.entityPrimaryKeyName = entityPrimaryKeyName; - } - - public String getLatitude() { - return latitude; - } - - public void setLatitude(String latitude) { - this.latitude = latitude; - } - - public String getLongitude() { - return longitude; - } - - public void setLongitude(String longitude) { - this.longitude = longitude; - } - - public String getSelfLink() { - return selfLink; - } - - public void setSelfLink(String selfLink) { - this.selfLink = selfLink; - } - - public static long getSerialversionuid() { - return serialVersionUID; - } - - public void setId(String id) { - this.id = id; - } -} diff --git a/src/main/java/org/openecomp/datarouter/entity/UebEventHeader.java b/src/main/java/org/openecomp/datarouter/entity/UebEventHeader.java deleted file mode 100644 index 5843545..0000000 --- a/src/main/java/org/openecomp/datarouter/entity/UebEventHeader.java +++ /dev/null @@ -1,167 +0,0 @@ -/** - * ============LICENSE_START======================================================= - * org.onap.aai - * ================================================================================ - * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * Copyright © 2017 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========================================================= - * - * ECOMP is a trademark and service mark of AT&T Intellectual Property. - */ -package org.openecomp.datarouter.entity; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonProperty; - -/** - * A convenience POJO for mapping the UebEventHeader from a UEB Event. - * - * @author davea - */ - -@JsonIgnoreProperties(ignoreUnknown = true) -public class UebEventHeader { - - private String timestamp; - - private String id; - - private String action; - - private String domain; - - private String sourceName; - - private String entityLink; - - private String entityType; - - private String topEntityType; - - private String sequenceNumber; - - private String eventType; - - private String version; - - public String getTimestamp() { - return timestamp; - } - - public void setTimestamp(String timestamp) { - this.timestamp = timestamp; - } - - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } - - public String getAction() { - return action; - } - - public void setAction(String action) { - this.action = action; - } - - public String getDomain() { - return domain; - } - - public void setDomain(String domain) { - this.domain = domain; - } - - public String getSourceName() { - return sourceName; - } - - @JsonProperty("source-name") - public void setSourceName(String sourceName) { - this.sourceName = sourceName; - } - - public String getEntityLink() { - return entityLink; - } - - @JsonProperty("entity-link") - public void setEntityLink(String entityLink) { - this.entityLink = entityLink; - } - - public String getEntityType() { - return entityType; - } - - @JsonProperty("entity-type") - public void setEntityType(String entityType) { - this.entityType = entityType; - } - - public String getTopEntityType() { - return topEntityType; - } - - @JsonProperty("top-entity-type") - public void setTopEntityType(String topEntityType) { - this.topEntityType = topEntityType; - } - - public String getSequenceNumber() { - return sequenceNumber; - } - - @JsonProperty("sequence-number") - public void setSequenceNumber(String sequenceNumber) { - this.sequenceNumber = sequenceNumber; - } - - public String getEventType() { - return eventType; - } - - @JsonProperty("event-type") - public void setEventType(String eventType) { - this.eventType = eventType; - } - - public String getVersion() { - return version; - } - - public void setVersion(String version) { - this.version = version; - } - - @Override - public String toString() { - return "UebEventHeader [" + (timestamp != null ? "timestamp=" + timestamp + ", " : "") - + (id != null ? "id=" + id + ", " : "") + (action != null ? "action=" + action + ", " : "") - + (domain != null ? "domain=" + domain + ", " : "") - + (sourceName != null ? "sourceName=" + sourceName + ", " : "") - + (entityLink != null ? "entityLink=" + entityLink + ", " : "") - + (entityType != null ? "entityType=" + entityType + ", " : "") - + (topEntityType != null ? "topEntityType=" + topEntityType + ", " : "") - + (sequenceNumber != null ? "sequenceNumber=" + sequenceNumber + ", " : "") - + (eventType != null ? "eventType=" + eventType + ", " : "") - + (version != null ? "version=" + version : "") + "]"; - } - -} diff --git a/src/main/java/org/openecomp/datarouter/policy/EntityEventPolicy.java b/src/main/java/org/openecomp/datarouter/policy/EntityEventPolicy.java index d6107ec..e8c3194 100644 --- a/src/main/java/org/openecomp/datarouter/policy/EntityEventPolicy.java +++ b/src/main/java/org/openecomp/datarouter/policy/EntityEventPolicy.java @@ -40,16 +40,16 @@ import org.eclipse.persistence.internal.helper.DatabaseField; import org.eclipse.persistence.jaxb.dynamic.DynamicJAXBContext; 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.openecomp.cl.api.Logger; import org.openecomp.cl.eelf.LoggerFactory; import org.openecomp.cl.mdc.MdcContext; -import org.openecomp.datarouter.entity.AaiEventEntity; -import org.openecomp.datarouter.entity.AggregationEntity; -import org.openecomp.datarouter.entity.DocumentStoreDataEntity; -import org.openecomp.datarouter.entity.OxmEntityDescriptor; -import org.openecomp.datarouter.entity.SuggestionSearchEntity; -import org.openecomp.datarouter.entity.TopographicalEntity; -import org.openecomp.datarouter.entity.UebEventHeader; import org.openecomp.datarouter.logging.EntityEventPolicyMsgs; import org.openecomp.datarouter.util.CrossEntityReference; import org.openecomp.datarouter.util.EntityOxmReferenceHelper; diff --git a/src/main/java/org/openecomp/datarouter/util/VersionedOxmEntities.java b/src/main/java/org/openecomp/datarouter/util/VersionedOxmEntities.java index f6af56c..3c3150d 100644 --- a/src/main/java/org/openecomp/datarouter/util/VersionedOxmEntities.java +++ b/src/main/java/org/openecomp/datarouter/util/VersionedOxmEntities.java @@ -40,7 +40,7 @@ import org.eclipse.persistence.internal.oxm.mappings.Descriptor; import org.eclipse.persistence.jaxb.dynamic.DynamicJAXBContext; import org.eclipse.persistence.mappings.DatabaseMapping; import org.eclipse.persistence.oxm.XMLField; -import org.openecomp.datarouter.entity.OxmEntityDescriptor; +import org.onap.aai.datarouter.entity.OxmEntityDescriptor; import org.slf4j.Logger; import org.slf4j.LoggerFactory; |