aboutsummaryrefslogtreecommitdiffstats
path: root/aai-traversal/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'aai-traversal/src/main')
-rw-r--r--aai-traversal/src/main/java/org/onap/aai/config/SearchConfiguration.java8
-rw-r--r--aai-traversal/src/main/java/org/onap/aai/dbgraphgen/ModelBasedProcessing.java190
-rw-r--r--aai-traversal/src/main/java/org/onap/aai/dbgraphmap/SearchGraph.java99
-rw-r--r--aai-traversal/src/main/java/org/onap/aai/interceptors/AAIHeaderProperties.java19
-rw-r--r--aai-traversal/src/main/java/org/onap/aai/rest/ExceptionHandler.java28
-rw-r--r--aai-traversal/src/main/java/org/onap/aai/rest/QueryConsumer.java8
-rw-r--r--aai-traversal/src/main/java/org/onap/aai/rest/RecentAPIConsumer.java16
-rw-r--r--aai-traversal/src/main/java/org/onap/aai/rest/TraversalConsumer.java6
-rw-r--r--aai-traversal/src/main/java/org/onap/aai/rest/search/GetCustomQueryConfig.java58
-rw-r--r--aai-traversal/src/main/java/org/onap/aai/rest/search/ModelAndNamedQueryRestProvider.java8
-rw-r--r--aai-traversal/src/main/java/org/onap/aai/rest/search/NodeQueryProcessor.java16
-rw-r--r--aai-traversal/src/main/java/org/onap/aai/rest/search/SearchProvider.java5
-rw-r--r--aai-traversal/src/main/java/org/onap/aai/rest/util/ConvertQueryPropertiesToJson.java12
-rw-r--r--aai-traversal/src/main/java/org/onap/aai/rest/util/EchoResponse.java19
-rw-r--r--aai-traversal/src/main/java/org/onap/aai/service/AuthorizationService.java44
-rw-r--r--aai-traversal/src/main/java/org/onap/aai/transforms/MapTraverser.java8
-rw-r--r--aai-traversal/src/main/java/org/onap/aai/util/MakeNamedQuery.java34
17 files changed, 229 insertions, 349 deletions
diff --git a/aai-traversal/src/main/java/org/onap/aai/config/SearchConfiguration.java b/aai-traversal/src/main/java/org/onap/aai/config/SearchConfiguration.java
index b60a707..5f131bf 100644
--- a/aai-traversal/src/main/java/org/onap/aai/config/SearchConfiguration.java
+++ b/aai-traversal/src/main/java/org/onap/aai/config/SearchConfiguration.java
@@ -23,19 +23,15 @@ import org.onap.aai.dbgraphmap.SearchGraph;
import org.onap.aai.edges.EdgeIngestor;
import org.onap.aai.introspection.LoaderFactory;
-import org.onap.aai.rest.dsl.v1.DslListener;
-import org.onap.aai.rest.dsl.DslQueryProcessor;
import org.onap.aai.rest.search.CQConfig;
import org.onap.aai.rest.search.GremlinServerSingleton;
import org.onap.aai.rest.search.LocalCQConfig;
import org.onap.aai.rest.search.SchemaServiceCQConfig;
import org.onap.aai.setup.SchemaVersions;
import org.springframework.beans.factory.annotation.Value;
-import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;
-import org.springframework.context.annotation.Scope;
@Configuration
@PropertySource(value = "classpath:schema-ingest.properties", ignoreResourceNotFound = true)
@@ -43,7 +39,6 @@ import org.springframework.context.annotation.Scope;
public class SearchConfiguration {
- private static final String CONFIG_TRANSLATOR = "config";
private static final String SCHEMA_SERVICE_TRANSLATOR = "schema-service";
@Value("${schema.translator.list}")
@@ -51,8 +46,7 @@ public class SearchConfiguration {
@Bean
public SearchGraph searchGraph(LoaderFactory loaderFactory, EdgeIngestor edgeIngestor, SchemaVersions schemaVersions) {
- SearchGraph searchGraph = new SearchGraph(loaderFactory, edgeIngestor, schemaVersions);
- return searchGraph;
+ return new SearchGraph(loaderFactory, edgeIngestor, schemaVersions);
}
@Bean
diff --git a/aai-traversal/src/main/java/org/onap/aai/dbgraphgen/ModelBasedProcessing.java b/aai-traversal/src/main/java/org/onap/aai/dbgraphgen/ModelBasedProcessing.java
index f1ffb9f..de25586 100644
--- a/aai-traversal/src/main/java/org/onap/aai/dbgraphgen/ModelBasedProcessing.java
+++ b/aai-traversal/src/main/java/org/onap/aai/dbgraphgen/ModelBasedProcessing.java
@@ -22,7 +22,6 @@ package org.onap.aai.dbgraphgen;
import org.onap.aai.logging.ErrorLogHelper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import com.att.eelf.configuration.EELFManager;
import com.google.common.collect.ArrayListMultimap;
import com.google.common.collect.Multimap;
import com.google.common.util.concurrent.SimpleTimeLimiter;
@@ -41,7 +40,6 @@ import org.onap.aai.exceptions.AAIException;
import org.onap.aai.introspection.Introspector;
import org.onap.aai.introspection.Loader;
import org.onap.aai.introspection.exceptions.AAIUnknownObjectException;
-import org.onap.aai.logging.LogFormatTools;
import org.onap.aai.query.builder.QueryBuilder;
import org.onap.aai.schema.enums.PropertyMetadata;
import org.onap.aai.serialization.db.DBSerializer;
@@ -52,7 +50,6 @@ import org.onap.aai.concurrent.AaiCallable;
import org.onap.aai.config.SpringContextAware;
import java.util.*;
-import java.util.concurrent.Callable;
import java.util.concurrent.TimeUnit;
/**
@@ -60,8 +57,8 @@ import java.util.concurrent.TimeUnit;
*/
public class ModelBasedProcessing {
- private Logger LOGGER = LoggerFactory.getLogger(ModelBasedProcessing.class);
- private final int MAX_LEVELS = 50; // max depth allowed for our model - to protect against infinite loop problems
+ private static Logger logger = LoggerFactory.getLogger(ModelBasedProcessing.class);
+ private static final int MAX_LEVELS = 50; // max depth allowed for our model - to protect against infinite loop problems
private TransactionalGraphEngine engine;
private Loader loader;
@@ -83,7 +80,7 @@ public class ModelBasedProcessing {
* @param transId the trans id
* @param fromAppId the from app id
* @param passedModelVersionId the passed model-version-id -- optional (unique id for a model-ver)
- * @param passedModelId the passed model-invariant-id -- optional
+ * @param passedModelInvId the passed model-invariant-id -- optional
* @param passedModelName the passed model-name -- optional
* @param passedTopNodeType the passed top node type -- optional (needed if neither model=invariant-id nor model-version-id is passed)
* @param startNodeFilterArrayOfHashes the start node filter array of hashes -- optional (used to locate the first node(s) of instance data)
@@ -149,7 +146,7 @@ public class ModelBasedProcessing {
// Now we can look up instances that match this model's info
Iterator<Vertex> tmpStartIter = this.engine.asAdmin().getReadOnlyTraversalSource().V().has(addDBAliasedSuffix("model-invariant-id"),calcModInvId).has(addDBAliasedSuffix("model-version-id"),calcModVerId);
while( tmpStartIter.hasNext() ){
- Vertex tmpStartVert = (Vertex) tmpStartIter.next();
+ Vertex tmpStartVert = tmpStartIter.next();
startVtxList.add(tmpStartVert);
}
}
@@ -162,9 +159,9 @@ public class ModelBasedProcessing {
if( startVerts != null ){
while( startVerts.hasNext() ){
- Vertex tmpStartVert = (Vertex) startVerts.next();
+ Vertex tmpStartVert = startVerts.next();
String vid = tmpStartVert.id().toString();
- String tmpModId = tmpStartVert.<String>property(addDBAliasedSuffix("model-invariant-id")).orElse(null);
+ //String tmpModId = tmpStartVert.<String>property(addDBAliasedSuffix("model-invariant-id")).orElse(null);
String tmpModVerId = tmpStartVert.<String>property(addDBAliasedSuffix("model-version-id")).orElse(null);
startVertInfo.put(vid, tmpModVerId);
}
@@ -406,7 +403,7 @@ public class ModelBasedProcessing {
* @param modelInvariantId the model-invariant-id (unique id in model)
* @param modelName the model name
* @param topNodeType the top node type
- * @param startNodeFilterArrayOfHashes the start node filter array of hashes
+ * @param startNodeFilterArrayOfHashesVal the start node filter array of hashes
* @param apiVer the api ver
* @return the array list
* @throws AAIException the AAI exception
@@ -442,7 +439,7 @@ public class ModelBasedProcessing {
// Sorry to do this, but code that gets called with an empty hash as the first array element was causing errors
- List<Map<String,Object>> startNodeFilterArrayOfHashes = new ArrayList <Map<String,Object>>();
+ List<Map<String,Object>> startNodeFilterArrayOfHashes = new ArrayList <>();
if( !startNodeFilterArrayOfHashesVal.isEmpty() ){
Map<String,Object> tmpH = startNodeFilterArrayOfHashesVal.get(0);
if( !tmpH.isEmpty() ){
@@ -480,7 +477,7 @@ public class ModelBasedProcessing {
Set <String> snKeySet = startNode2ModelVerHash.keySet();
Iterator<String> startNodeIterator = snKeySet.iterator();
while( startNodeIterator.hasNext() ){
- String modVerIdKey = (String) startNodeIterator.next();
+ String modVerIdKey = startNodeIterator.next();
String modVerId = startNode2ModelVerHash.get(modVerIdKey);
if( !distinctModelVersHash.containsKey(modVerId) ){
// First time seeing this model-version-id
@@ -525,9 +522,9 @@ public class ModelBasedProcessing {
Set <String> keySet = distinctModelVersHash.keySet();
Iterator<String> modelVerIterator = keySet.iterator();
while( modelVerIterator.hasNext() ){
- String modVerKey = (String) modelVerIterator.next();
+ String modVerKey = modelVerIterator.next();
if( ! skipModelVerIdList.contains(modVerKey) ){
- Vertex modelVerVtx = (Vertex)distinctModelVersHash.get(modVerKey);
+ Vertex modelVerVtx = distinctModelVersHash.get(modVerKey);
Multimap<String, String> tmpTopoMap = genTopoMap4ModelVer( transId, fromAppId,
modelVerVtx, modVerKey);
validNextStepHash.put(modVerKey, tmpTopoMap);
@@ -547,7 +544,7 @@ public class ModelBasedProcessing {
snKeySet = startNode2ModelVerHash.keySet();
startNodeIterator = snKeySet.iterator();
while( startNodeIterator.hasNext() ){
- String vtxKey = (String) startNodeIterator.next();
+ String vtxKey = startNodeIterator.next();
firstStepInfoHash.put(vtxKey,startNodeType);
}
}
@@ -556,15 +553,15 @@ public class ModelBasedProcessing {
snKeySet = startNode2ModelVerHash.keySet();
startNodeIterator = snKeySet.iterator();
while( startNodeIterator.hasNext() ){
- String vtxKey = (String) startNodeIterator.next();
+ String vtxKey = startNodeIterator.next();
Iterator<Vertex> vtxIterator = this.engine.asAdmin().getReadOnlyTraversalSource().V(vtxKey);
- Vertex tmpVtx = (Vertex)vtxIterator.next();
+ Vertex tmpVtx = vtxIterator.next();
String thisVtxModelVerId = startNode2ModelVerHash.get(vtxKey);
if( skipModelVerIdList.contains(thisVtxModelVerId) ){
// Skip this vertex because it uses a model-ver that is bad
continue;
}
- Vertex modelVerVtx = (Vertex)distinctModelVersHash.get(thisVtxModelVerId);
+ Vertex modelVerVtx = distinctModelVersHash.get(thisVtxModelVerId);
Vertex modelVtx = getModelGivenModelVer( modelVerVtx, "" );
String modInvId = modelVtx.<String>property("model-invariant-id").orElse(null);
String personaModInvId = tmpVtx.<String>property(addDBAliasedSuffix("model-invariant-id")).orElse(null);
@@ -608,18 +605,15 @@ public class ModelBasedProcessing {
snKeySet = startNode2ModelVerHash.keySet();
startNodeIterator = snKeySet.iterator();
while( startNodeIterator.hasNext() ){
- String topNodeVtxId = (String) startNodeIterator.next();
- if( failedPersonaCheckVids.contains(topNodeVtxId) ){
+ String topNodeVtxId = startNodeIterator.next();
+ if( failedPersonaCheckVids.contains(topNodeVtxId) || skipStartVertVerIdList.contains(topNodeVtxId) ){
// Skip this vertex because it failed it's persona-data check above
- continue;
- }
- if( skipStartVertVerIdList.contains(topNodeVtxId) ){
// Skip this vertex because it uses a model-ver that is bad
continue;
}
Iterator<Vertex> vtxIterator = this.engine.asAdmin().getReadOnlyTraversalSource().V(topNodeVtxId);
- Vertex tmpStartVtx = (Vertex)vtxIterator.next();
+ Vertex tmpStartVtx = vtxIterator.next();
String elementLocationTrail = firstStepInfoHash.get(topNodeVtxId);
String modelVerId = startNode2ModelVerHash.get(topNodeVtxId);
Multimap<String, String> validNextStepMap = validNextStepHash.get(modelVerId);
@@ -846,6 +840,7 @@ public class ModelBasedProcessing {
// Sometimes things have already been deleted by the time we get to them - just log it.
AAIException aaiException = new AAIException("AAI_6154", thisGuyStr + ". msg = " + ex.getMessage());
ErrorLogHelper.logException(aaiException);
+
}
if( !gotVtxOK ){
@@ -856,7 +851,7 @@ public class ModelBasedProcessing {
}
else {
if( resSet.getNewDataDelFlag() != null && resSet.getNewDataDelFlag().equals("T") ){
- LOGGER.debug(">> will try to delete this one >> " + thisGuyStr);
+ logger.debug(">> will try to delete this one >> " + thisGuyStr);
try {
Boolean requireResourceVersion = false;
@@ -876,8 +871,8 @@ public class ModelBasedProcessing {
ErrorLogHelper.logException(ae);
String errText = ae.getErrorObject().getErrorText();
String errDetail = ae.getMessage();
- LOGGER.debug("Exception when deleting " + thisGuyStr + ". ErrorCode = " + errorCode +
- ", errorText = " + errText + ", details = " + errDetail);
+ logger.debug("Exception when deleting " + thisGuyStr + ". ErrorCode = " + errorCode +
+ ", errorText = " + errText + ", details = " + errDetail);
}
}
catch( Exception e ){
@@ -886,6 +881,7 @@ public class ModelBasedProcessing {
// Ignore the exception - but log it so we can see what happened.
AAIException aaiException = new AAIException("AAI_6154", thisGuyStr + ". msg = " + e.getMessage());
ErrorLogHelper.logException(aaiException);
+
}
// We can't depend on a thrown exception to tell us if a node was deleted since it may
@@ -935,7 +931,7 @@ public class ModelBasedProcessing {
*/
public List<ResultSet> queryByNamedQuery(String transId, String fromAppId,
String namedQueryUuid,
- ArrayList <Map<String,Object>> startNodeFilterArrayOfHashes,
+ List <Map<String,Object>> startNodeFilterArrayOfHashes,
String apiVer )
throws AAIException {
@@ -959,7 +955,7 @@ public class ModelBasedProcessing {
* @param namedQueryUuid the named query uuid
* @param startNodeFilterArrayOfHashes the start node filter array of hashes --used to locate the first nodes of instance data
* @param apiVer the api ver
- * @param secondaryCutPoint nodeType where we will prune if secondary filter is not met
+ * @param secondaryFilterCutPoint nodeType where we will prune if secondary filter is not met
* @param secondaryFilterHash secondary filter params
* @return resultSet
* @throws AAIException the AAI exception
@@ -1089,7 +1085,6 @@ public class ModelBasedProcessing {
if( startNodeFilterArrayOfHashes.size() == 1 ){
// If there is only one set of startFilter info given, then allow it to possibly not be
// defining just one start node.
- Map<String, Object> cleanHash = new HashMap<>();
Map<String, Object> tmpHash = startNodeFilterArrayOfHashes.get(0);
Set <String> propKeySet = tmpHash.keySet();
Iterator<String> propIter = propKeySet.iterator();
@@ -1098,7 +1093,7 @@ public class ModelBasedProcessing {
boolean foundIndexedField = false;
int propertiesSet = 0;
while( propIter.hasNext() ){
- String oldVtxKey = (String) propIter.next();
+ String oldVtxKey = propIter.next();
String newKey = oldVtxKey;
String [] parts = oldVtxKey.split("\\.");
if( parts.length == 2 ){
@@ -1226,7 +1221,7 @@ public class ModelBasedProcessing {
* Prune a result set as per a secondary filter.
*
* @param resSetVal the res set val
- * @param cutPoint the nodeType where the trim will happen
+ * @param cutPointType the nodeType where the trim will happen
* @param secFilterHash hash of properties and values to use as the secondary filter
* @return pruned result set
* @throws AAIException the AAI exception
@@ -1299,7 +1294,7 @@ public class ModelBasedProcessing {
String propNodeTypeDotName = (filtEntry.getKey()).toString();
String fpv = (filtEntry.getValue()).toString();
- int periodLoc = propNodeTypeDotName.indexOf(".");
+ int periodLoc = propNodeTypeDotName.indexOf('.');
if( periodLoc <= 0 ){
String emsg = "Bad filter param key passed in: [" + propNodeTypeDotName + "]. Expected format = [nodeName.paramName]\n";
throw new AAIException("AAI_6120", emsg);
@@ -1394,7 +1389,7 @@ public class ModelBasedProcessing {
if( resSetVal.getDoNotOutputFlag().equals("true") ){
// This ResultSet isn't to be displayed, so replace it with it's sub-ResultSets
- List<ResultSet> subResList = (ArrayList<ResultSet>) resSetVal.getSubResultSet();
+ List<ResultSet> subResList = resSetVal.getSubResultSet();
for( int k = 0; k < subResList.size(); k++ ){
List<ResultSet> newSubResList = collapseForDoNotOutput(subResList.get(k));
colResultSet.addAll(newSubResList);
@@ -1408,7 +1403,7 @@ public class ModelBasedProcessing {
// For each result set now at this level, call this same routine to collapse their sub-resultSets
for( int i = 0; i < colResultSet.size(); i++ ){
List<ResultSet> newSubSet = new ArrayList<>();
- List<ResultSet> subResList = (ArrayList<ResultSet>) colResultSet.get(i).getSubResultSet();
+ List<ResultSet> subResList = colResultSet.get(i).getSubResultSet();
for( int n = 0; n < subResList.size(); n++ ){
List<ResultSet> newSubResList = collapseForDoNotOutput(subResList.get(n));
newSubSet.addAll(newSubResList);
@@ -1430,7 +1425,6 @@ public class ModelBasedProcessing {
* @param fromAppId the from app id
* @param thisLevelElemVtx the element vtx at this level
* @param thisVertsTrail the this verts trail
- * @param elementLocationTrail -- trail of nodeTypes that got us here (this element vertex) from the top
* @param validNextStepMap the valid next step map -- hash of valid next steps (node types) for this model
* @param vidsTraversed the vids traversed -- ArrayList of vertexId's that we traversed to get to this point
* @param levelCounter the level counter
@@ -1568,7 +1562,7 @@ public class ModelBasedProcessing {
}
else {
while( modPipe.hasNext() ){
- Vertex tmpVert = (Vertex) modPipe.next();
+ Vertex tmpVert = modPipe.next();
String tmpVid = tmpVert.id().toString();
String tmpTrail = thisVertsTrail + "|" + targetStep;
if( !vidsTraversed.contains(tmpVid) ){
@@ -1596,7 +1590,6 @@ public class ModelBasedProcessing {
* @param fromAppId the from app id
* @param modelVerVertex the model-ver vertex
* @param modelVerId the model-version-id
- * @param loader the db maps
* @return MultiMap of valid next steps for each potential model-element
* @throws AAIException the AAI exception
*/
@@ -1647,11 +1640,8 @@ public class ModelBasedProcessing {
+ modelVerId);
}
- Multimap<String, String> collectedMap = collectTopology4ModelVer( transId, fromAppId,
+ return collectTopology4ModelVer( transId, fromAppId,
firstElementVertex, "", initialEmptyMap, vidsTraversed, 0, null, firstModelInvId, firstModelVersion );
-
- return collectedMap;
-
} // End of genTopoMap4ModelVer()
@@ -1660,19 +1650,16 @@ public class ModelBasedProcessing {
// Seems to be how they're defined in OXM - whether they use a "xml-wrapper" or not
// Need to translate them into ArrayLists sometimes...
- List<String> retArrList = new ArrayList<String>();
+ List<String> retArrList = new ArrayList<>();
String listString = listStringVal;
listString = listString.replace(" ", "");
listString = listString.replace("\"", "");
listString = listString.replace("[", "");
listString = listString.replace("]", "");
String [] pieces = listString.split(",");
- if( pieces != null && pieces.length > 0 ){
- for( int i = 0; i < pieces.length; i++ ){
- retArrList.add(pieces[i]);
- }
+ if(pieces.length > 0){
+ retArrList.addAll(Arrays.asList(pieces));
}
-
return retArrList;
}
@@ -1884,7 +1871,7 @@ public class ModelBasedProcessing {
}
while( constrPipe.hasNext() ){
- Vertex constrVtx = (Vertex) constrPipe.next();
+ Vertex constrVtx = constrPipe.next();
// We found a property constraint that we will need to check
String conType = constrVtx.<String>property("constraint-type").orElse(null);
if( (conType == null) || conType.equals("")){
@@ -1967,7 +1954,7 @@ public class ModelBasedProcessing {
}
while( lookPipe.hasNext() ){
- Vertex relLookupVtx = (Vertex) lookPipe.next();
+ Vertex relLookupVtx = lookPipe.next();
// We found a related-lookup record to try and use
String srcProp = relLookupVtx.<String>property("source-node-property").orElse(null);
String srcNodeType = relLookupVtx.<String>property("source-node-type").orElse(null);
@@ -2002,19 +1989,19 @@ public class ModelBasedProcessing {
if( valFromInstance == null ){
// if there is no key to use to go look up something, we should end it here and just
// note what happened - no need to try to look something up by an empty key
- LOGGER.debug("WARNING - the instance data node of type [" + srcNodeType
+ logger.debug("WARNING - the instance data node of type [" + srcNodeType
+ "] did not have a value for property [" + srcProp
+ "], so related-lookup is being abandoned.");
return retHash;
}
- Map<String,Object> propHash = new HashMap<String,Object>();
+ Map<String,Object> propHash = new HashMap<>();
propHash.put(targetProp, valFromInstance);
Optional<Vertex> result = dbMethHelper.locateUniqueVertex(targetNodeType, propHash);
if (!result.isPresent()) {
// If it can't find the lookup node, don't fail, just log that it couldn't be found ---
- LOGGER.debug("WARNING - Could not find lookup node that corresponds to nodeType ["
+ logger.debug("WARNING - Could not find lookup node that corresponds to nodeType ["
+ targetNodeType + "] propertyName = [" + srcProp
+ "], propVal = [" + valFromInstance
+ "] so related-lookup is being abandoned.");
@@ -2046,7 +2033,6 @@ public class ModelBasedProcessing {
* @param thisLevelElemVtx the element verrtx for this level
* @param incomingTrail the incoming trail -- trail of nodeTypes that got us here (this nq-element vertex) from the top
* @param currentHash the current hash
- * @param Map that got us to this point (that we will use as the base of the map we will return)
* @param vidsTraversed the vids traversed -- ArrayList of vertexId's that we traversed to get to this point
* @param levelCounter the level counter
* @return HashMap of all widget-points on a namedQuery topology with the value being the "named-query-element-uuid" for that spot.
@@ -2054,7 +2040,7 @@ public class ModelBasedProcessing {
*/
public Map<String, String> collectNQElementHash(String transId, String fromAppId,
Vertex thisLevelElemVtx, String incomingTrail,
- Map<String,String> currentHash, ArrayList <String> vidsTraversed,
+ Map<String,String> currentHash, List <String> vidsTraversed,
int levelCounter ) throws AAIException {
levelCounter++;
@@ -2092,7 +2078,7 @@ public class ModelBasedProcessing {
while( vertI != null && vertI.hasNext() ){
Vertex tmpVert = vertI.next();
String vid = tmpVert.id().toString();
- Map<String,Object> elementHash = new HashMap<String, Object>();
+ Map<String,Object> elementHash = new HashMap();
String connectToType = tmpVert.<String>property(AAIProperties.NODE_TYPE).orElse(null);
if( connectToType != null && connectToType.equals("named-query-element") ){
@@ -2128,10 +2114,8 @@ public class ModelBasedProcessing {
* @param thisLevelElemVtx the element vertex at this level
* @param incomingTrail the incoming trail -- trail of nodeTypes that got us here (this vertex) from the top
* @param currentHash the current hash
- * @param Map that got us to this point (that we will use as the base of the map we will return)
* @param vidsTraversed the vids traversed ---- ArrayList of vertexId's that we traversed to get to this point
* @param levelCounter the level counter
- * @param loader the db maps
* @param modConstraintHash the mod constraint hash
* @param overRideModelId the over ride model id
* @param overRideModelVersionId the over ride model version id
@@ -2140,7 +2124,7 @@ public class ModelBasedProcessing {
*/
public Map<String, String> collectDeleteKeyHash(String transId, String fromAppId,
Vertex thisLevelElemVtx, String incomingTrail,
- Map<String,String> currentHash, ArrayList <String> vidsTraversed,
+ Map<String,String> currentHash, List <String> vidsTraversed,
int levelCounter, Map<String, Vertex> modConstraintHash,
String overRideModelId, String overRideModelVersionId )
throws AAIException {
@@ -2307,7 +2291,7 @@ public class ModelBasedProcessing {
while( vertI != null && vertI.hasNext() ){
Vertex tmpVert = vertI.next();
String vid = tmpVert.id().toString();
- Map<String,Object> elementHash = new HashMap<String, Object>();
+ Map<String,Object> elementHash = new HashMap<>();
String connectToType = tmpVert.<String>property(AAIProperties.NODE_TYPE).orElse(null);
if( connectToType != null && connectToType.equals("model-element") ){
@@ -2396,12 +2380,11 @@ public class ModelBasedProcessing {
*
* @param transId the trans id
* @param fromAppId the from app id
- * @param modelElement vertex to collect for
+ * @param thisLevelElemVtx vertex to collect for
* @param incomingTrail the incoming trail -- trail of nodeTypes/personaInfo that got us here (this vertex) from the top
* @param currentMap the current map -- map that got us to this point (that we will use as the base of the map we will return)
* @param vidsTraversed the vids traversed -- ArrayList of vertexId's that we traversed to get to this point
* @param levelCounter the level counter
- * @param loader the db maps
* @param modConstraintHash the mod constraint hash
* @param overRideModelInvId the override model-invariant-id
* @param overRideModelVersionId the override model-version-id
@@ -2485,8 +2468,7 @@ public class ModelBasedProcessing {
// It could show up on other branches in the case where it is a sub-model which is being
// used in more than one place.
//
- List<String> thisTrailsVidsTraversed = new ArrayList <String>();
- thisTrailsVidsTraversed.addAll(vidsTraversed);
+ List<String> thisTrailsVidsTraversed = new ArrayList<>(vidsTraversed);
thisTrailsVidsTraversed.add(thisElemVid);
// Look at the elements pointed to at this level and add on their data
@@ -2495,7 +2477,7 @@ public class ModelBasedProcessing {
while( vertI != null && vertI.hasNext() ){
Vertex tmpVert = vertI.next();
String vid = tmpVert.id().toString();
- Map<String,Object> elementHash = new HashMap<String, Object>();
+ Map<String,Object> elementHash = new HashMap<>();
String connectToType = tmpVert.<String>property(AAIProperties.NODE_TYPE).orElse(null);
if( connectToType != null && connectToType.equals("model-element") ){
// A nice, regular old model-element
@@ -2527,7 +2509,7 @@ public class ModelBasedProcessing {
String tmpElNT = getModElementWidgetType( elVert, thisGuysTrail );
String tmpElStepName = getModelElementStepName( elVert, thisGuysTrail);
- List<String> linkagePtList = new ArrayList <String>();
+ List<String> linkagePtList = new ArrayList <>();
Iterator <VertexProperty<Object>> vpI = elVert.properties("linkage-points");
// I am not sure why, but since "linkage-points" is an xml-element-wrapper in the OXM definition,
@@ -2580,7 +2562,6 @@ public class ModelBasedProcessing {
*
* @param nodeTypeA the node type A
* @param nodeTypeB the node type B
- * @param loader the db maps
* @throws AAIException the AAI exception
*/
public void check4EdgeRule( String nodeTypeA, String nodeTypeB) throws AAIException {
@@ -2624,10 +2605,9 @@ public class ModelBasedProcessing {
*
* @param transId the trans id
* @param fromAppId the from app id
- * @param linkagePointStr -- Note it is in reverse order from where we connect to it.
+ * @param linkagePointStrVal -- Note it is in reverse order from where we connect to it.
* @param incomingTrail -- trail of nodeTypes that got us here (this vertex) from the top
* @param currentMap the current map -- that got us to this point (that we will use as the base of the map we will return)
- * @param loader the db maps
* @return Map of the topology
* @throws AAIException the AAI exception
*/
@@ -2644,7 +2624,7 @@ public class ModelBasedProcessing {
// before any commas (if there are any).
String [] trailSteps = thisGuysTrail.split("\\|");
- if( trailSteps == null || trailSteps.length == 0 ){
+ if(trailSteps.length == 0){
throw new AAIException("AAI_6125", "Bad incomingTrail passed to collectTopology4LinkagePoint(): [" + incomingTrail + "] ");
}
String lastStepString = trailSteps[trailSteps.length - 1];
@@ -2669,7 +2649,7 @@ public class ModelBasedProcessing {
lastStepNT = stepPieces[0];
String thisStepNT = "";
String [] linkageSteps = linkage[x].split("\\|");
- if( linkageSteps == null || linkageSteps.length == 0 ){
+ if(linkageSteps.length == 0){
throw new AAIException("AAI_6125", "Bad linkagePointStr passed to collectTopology4LinkagePoint(): [" + linkagePointStr + "] ");
}
for( int i=(linkageSteps.length - 1); i >= 0; i-- ){
@@ -2697,7 +2677,7 @@ public class ModelBasedProcessing {
// Take a constrained-element-set and figure out the total set of all the possible elements that it
// represents and return them as a Hash.
- Map<String,Object> retElementHash = new HashMap<String, Object>();
+ Map<String,Object> retElementHash = new HashMap<>();
if( constrElemSetVtx == null ){
String msg = " getNextStepElementsFromSet() called with null constrElemSetVtx ";
@@ -2711,7 +2691,7 @@ public class ModelBasedProcessing {
throw new AAIException("AAI_6125", msg);
}
- ArrayList <Vertex> choiceSetVertArray = new ArrayList<Vertex>();
+ ArrayList <Vertex> choiceSetVertArray = new ArrayList<>();
Iterator<Vertex> vertI = this.traverseIncidentEdges(EdgeType.TREE, constrElemSetVtx, "element-choice-set");
int setCount = 0;
while( vertI != null && vertI.hasNext() ){
@@ -2804,13 +2784,10 @@ public class ModelBasedProcessing {
throw new AAIException("AAI_6133", "Bad Named Query Definition: First element must correspond to a widget type model. Named Query UUID = "
+ namedQueryUuid);
}
-
- Multimap<String, String> collectedMap = collectTopology4NamedQ( transId, fromAppId,
+
+ return collectTopology4NamedQ( transId, fromAppId,
firstElementVertex, "",
initialEmptyMap, vidsTraversed, 0);
-
- return collectedMap;
-
} // End of genTopoMap4NamedQ()
@@ -3004,7 +2981,7 @@ public class ModelBasedProcessing {
throw new AAIException("AAI_6132", msg);
}
- String nodeType = modVtx.<String>property(AAIProperties.NODE_TYPE).orElse(null);;
+ String nodeType = modVtx.<String>property(AAIProperties.NODE_TYPE).orElse(null);
if( (nodeType != null) && nodeType.equals("model") ){
// Found what we were looking for.
return modVtx;
@@ -3095,7 +3072,6 @@ public class ModelBasedProcessing {
*
* @param elementVtx the model-element vtx
* @param elementTrail the element trail
- * @param loader the db maps
* @return the element step name
* @throws AAIException the AAI exception
*/
@@ -3162,7 +3138,6 @@ public class ModelBasedProcessing {
* Node type supports persona.
*
* @param nodeType the node type
- * @param loader the db maps
* @return the boolean
* @throws AAIException the AAI exception
*/
@@ -3172,21 +3147,16 @@ public class ModelBasedProcessing {
if( nodeType == null || nodeType.equals("") ){
return false;
}
- Introspector obj = null;
+ Introspector introspector = null;
try {
- obj = loader.introspectorFromName(nodeType);
+ introspector = loader.introspectorFromName(nodeType);
} catch (AAIUnknownObjectException e) {
String emsg = " Unrecognized nodeType [" + nodeType + "]\n";
throw new AAIException("AAI_6115", emsg);
}
- Collection <String> props4ThisNT = loader.introspectorFromName(nodeType).getProperties();
- if( !props4ThisNT.contains(addDBAliasedSuffix("model-invariant-id")) || !props4ThisNT.contains(addDBAliasedSuffix("model-version-id")) ){
- return false;
- }
- else {
- return true;
- }
+ Collection <String> props4ThisNT = introspector.getProperties();
+ return props4ThisNT.contains(addDBAliasedSuffix("model-invariant-id")) && props4ThisNT.contains(addDBAliasedSuffix("model-version-id"));
}// nodeTypeSupportsPersona()
@@ -3249,9 +3219,8 @@ public class ModelBasedProcessing {
// NOTE -- if the element points to a resource or service model, then we'll return the
// widget-type of the first element (crown widget) for that model.
Vertex modVerVtx = getModelVerThatElementRepresents( elementVtx, elementTrail );
- String thisElementNodeType = getModelVerTopWidgetType( modVerVtx, elementTrail );
- return thisElementNodeType;
-
+ return getModelVerTopWidgetType( modVerVtx, elementTrail );
+
}// End getModElementWidgetType()
@@ -3354,7 +3323,7 @@ public class ModelBasedProcessing {
}
else {
while( modVertsIter.hasNext() ){
- Vertex tmpModelVerVtx = (Vertex) modVertsIter.next();
+ Vertex tmpModelVerVtx = modVertsIter.next();
retVtxArr.add(tmpModelVerVtx);
}
}
@@ -3369,8 +3338,8 @@ public class ModelBasedProcessing {
*
* @param transId the trans id
* @param fromAppId the from app id
- * @param model-invariant-id (uniquely identifies a model)
- * @return the model-ver's defined for the corresponding model
+ * @param modelInvId-invariant-id (uniquely identifies a model)
+ * @return the model-ver's defined for the corresponding model
* @throws AAIException the AAI exception
*/
public Iterator<Vertex> getModVersUsingModelInvId(String transId, String fromAppId,
@@ -3401,7 +3370,7 @@ public class ModelBasedProcessing {
*
* @param transId the trans id
* @param fromAppId the from app id
- * @param model vertex
+ * @param modVtx vertex
* @return the model-ver's defined for the corresponding model
* @throws AAIException the AAI exception
*/
@@ -3424,7 +3393,7 @@ public class ModelBasedProcessing {
}
else {
while( modVerVertsIter.hasNext() ){
- Vertex tmpModelVtx = (Vertex) modVerVertsIter.next();
+ Vertex tmpModelVtx = modVerVertsIter.next();
retVtxArr.add(tmpModelVtx);
}
}
@@ -3462,7 +3431,7 @@ public class ModelBasedProcessing {
}
else {
while( modVerVertsIter.hasNext() ){
- Vertex modelVerVtx = (Vertex) modVerVertsIter.next();
+ Vertex modelVerVtx = modVerVertsIter.next();
String tmpUuid = modelVerVtx.<String>property("model-version-id").orElse(null);
if( (tmpUuid != null) && !tmpUuid.equals("") && !retArr.contains(tmpUuid) ){
retArr.add(tmpUuid);
@@ -3530,7 +3499,7 @@ public class ModelBasedProcessing {
throw new AAIException("AAI_6114", emsg);
}
while( modVerVertsIter.hasNext() ){
- Vertex tmpModVerVtx = (Vertex) modVerVertsIter.next();
+ Vertex tmpModVerVtx = modVerVertsIter.next();
String tmpNT = getModelVerTopWidgetType( tmpModVerVtx, "" );
if( lastNT != null && !lastNT.equals("") ){
if( !lastNT.equals(tmpNT) ){
@@ -3607,7 +3576,7 @@ public class ModelBasedProcessing {
*
* @param transId the trans id
* @param fromAppId the from app id
- * @param modelNameVersionId the model name version id
+ * @param modelVersionIdVal the model name version id
* @param apiVersion the api version
* @throws AAIException the AAI exception
*/
@@ -3628,8 +3597,6 @@ public class ModelBasedProcessing {
String msg = " modelVer [" + modelVersionIdVal + "] topo multiMap looks like: \n[" + topoMap + "]";
System.out.println("INFO -- " + msg );
}
- return;
-
}// End validateModel()
@@ -3656,12 +3623,11 @@ public class ModelBasedProcessing {
}
else {
//Multimap<String, String> topoMap = genTopoMap4NamedQ( "junkTransId", "junkFromAppId",
- // graph, nqVtx, namedQueryUuid );
+ // graph, nqVtx, namedQueryUuid );
//System.out.println("DEBUG -- for test only : --- ");
//System.out.println("DEBUG -- topomap = [" + topoMap + "]");
}
- return;
-
+
}// End validateNamedQuery()
@@ -3721,7 +3687,7 @@ public class ModelBasedProcessing {
}
System.out.println( propsStr );
- LOGGER.info(propsStr);
+ logger.info(propsStr);
if( !resSet.getSubResultSet().isEmpty() ){
ListIterator<ResultSet> listItr = resSet.getSubResultSet().listIterator();
@@ -3732,18 +3698,16 @@ public class ModelBasedProcessing {
}// end of showResultSet()
- private Iterator<Vertex> traverseIncidentEdges(EdgeType treeType, Vertex startV, String connectedNodeType) throws AAIUnknownObjectException, AAIException {
- QueryBuilder builder = this.engine.getQueryBuilder(startV).createEdgeTraversal(treeType, startV, loader.introspectorFromName(connectedNodeType));
- return builder;
+ private Iterator<Vertex> traverseIncidentEdges(EdgeType treeType, Vertex startV, String connectedNodeType) throws AAIException {
+ return this.engine.getQueryBuilder(startV).createEdgeTraversal(treeType, startV, loader.introspectorFromName(connectedNodeType));
}
- private Iterator<Vertex> traverseIncidentEdges(EdgeType treeType, Vertex startV, String... connectedNodeType) throws AAIUnknownObjectException, AAIException {
+ private Iterator<Vertex> traverseIncidentEdges(EdgeType treeType, Vertex startV, String... connectedNodeType) throws AAIException {
QueryBuilder[] builders = new QueryBuilder[connectedNodeType.length];
for (int i = 0; i < connectedNodeType.length; i++) {
builders[i] = this.engine.getQueryBuilder(startV).createEdgeTraversal(EdgeType.TREE, startV, loader.introspectorFromName(connectedNodeType[i]));
}
- QueryBuilder builder = this.engine.getQueryBuilder(startV).union(builders);
- return builder;
+ return this.engine.getQueryBuilder(startV).union(builders);
}
private String addDBAliasedSuffix(String propName) {
diff --git a/aai-traversal/src/main/java/org/onap/aai/dbgraphmap/SearchGraph.java b/aai-traversal/src/main/java/org/onap/aai/dbgraphmap/SearchGraph.java
index d0e881d..1ca7c82 100644
--- a/aai-traversal/src/main/java/org/onap/aai/dbgraphmap/SearchGraph.java
+++ b/aai-traversal/src/main/java/org/onap/aai/dbgraphmap/SearchGraph.java
@@ -20,7 +20,6 @@
package org.onap.aai.dbgraphmap;
import com.google.common.base.CaseFormat;
-import com.google.common.collect.ArrayListMultimap;
import com.google.common.collect.Multimap;
import edu.emory.mathcs.backport.java.util.Collections;
import org.apache.commons.lang3.StringUtils;
@@ -67,15 +66,14 @@ import org.springframework.beans.factory.annotation.Autowired;
import javax.ws.rs.core.HttpHeaders;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
-import javax.ws.rs.core.UriBuilderException;
import javax.xml.bind.JAXBException;
import java.io.UnsupportedEncodingException;
import java.net.URI;
import java.util.*;
-import java.util.stream.Collectors;
import java.util.stream.Stream;
+
/**
* Database Mapping class which acts as the middle man between the REST interface objects for the
* Search namespace
@@ -139,7 +137,7 @@ public class SearchGraph {
QueryBuilder builder = genericQueryBuilder.getDbEngine().getQueryBuilder()
.getVerticesByIndexedProperty(AAIProperties.NODE_TYPE, "service-instance");
for (String keyData : genericQueryBuilder.getStartNodeKeyParams()) {
- int colonIndex = keyData.indexOf(":");
+ int colonIndex = keyData.indexOf(':');
if (colonIndex <= 0) {
throw new AAIException("AAI_6120", "Bad key param passed in: [" + keyData + "]");
} else {
@@ -228,14 +226,14 @@ public class SearchGraph {
}
private URI craftUriFromQueryParams(Loader loader, String startNodeType, List<String> startNodeKeyParams)
- throws UnsupportedEncodingException, IllegalArgumentException, UriBuilderException, AAIException {
+ throws UnsupportedEncodingException, AAIException {
Introspector relationship = loader.introspectorFromName("relationship");
relationship.setValue("related-to", startNodeType);
List<Object> relationshipDataList = relationship.getValue("relationship-data");
for (String keyData : startNodeKeyParams) {
- int colonIndex = keyData.indexOf(":");
+ int colonIndex = keyData.indexOf(':');
if (colonIndex <= 0) {
throw new AAIException("AAI_6120", "Bad key param passed in: [" + keyData + "]");
} else {
@@ -470,21 +468,16 @@ public class SearchGraph {
* @param targetNodeType the target node type
* @param nodeType the node type
* @return the edge label
- * @throws AAIException the AAI exception
- * @throws EdgeRuleNotFoundException
+ * @throws EdgeRuleNotFoundException The Edge Rule Not Found Exception
*/
public String[] getEdgeLabel(String targetNodeType, String nodeType)
- throws AAIException, EdgeRuleNotFoundException {
+ throws EdgeRuleNotFoundException {
EdgeRuleQuery query = new EdgeRuleQuery.Builder(targetNodeType, nodeType).build();
- Multimap<String, EdgeRule> edgeRules = ArrayListMultimap.create();
- edgeRules = edgeIngestor.getRules(query);
+ Multimap<String, EdgeRule> edgeRules = edgeIngestor.getRules(query);
- // Map<String, EdgeRule> rules = EdgeRules.getInstance().getEdgeRules(targetNodeType, nodeType);
- String[] results = edgeRules.values().stream().map(rule -> rule.getLabel()).collect(Collectors.toList())
- .toArray(new String[0]);
- return results;
+ return edgeRules.values().stream().map(EdgeRule::getLabel).toArray(String[]::new);
}
@@ -621,7 +614,7 @@ public class SearchGraph {
*/
public Response executeModelOperation(String fromAppId, String transId, String queryParameters,
boolean isDelete, AAIExtensionMap aaiExtMap)
- throws AAIException, DynamicException {
+ throws AAIException {
Response response;
boolean success = true;
TransactionalGraphEngine dbEngine = null;
@@ -653,6 +646,7 @@ public class SearchGraph {
throw new AAIException("AAI_5105");
}
+
String modelVersionId = null;
String modelName = null;
String modelInvariantId = null;
@@ -721,7 +715,7 @@ public class SearchGraph {
List<Map<String, Object>> startNodeFilterHash = new ArrayList<>();
- String resourceVersion = mapInstanceFilters((DynamicEntity) modelAndNamedQuerySearch.get("instanceFilters"),
+ String resourceVersion = mapInstanceFilters( modelAndNamedQuerySearch.get("instanceFilters"),
startNodeFilterHash, jaxbContext);
if (isDelete) {
@@ -743,12 +737,11 @@ public class SearchGraph {
for (Map.Entry<String, String> ent : delResult.entrySet()) {
resultStr += "v[" + ent.getKey() + "] " + ent.getValue() + ",\n";
}
- resultStr.trim();
// Note - notifications are now done down in the individual "remove" calls done in
// runDeleteByModel() above.
- response = Response.ok(resultStr).build();
+ response = Response.ok(resultStr.trim()).build();
} else {
List<ResultSet> resultSet = processor.queryByModel(transId, fromAppId, modelVersionId, modelInvariantId,
@@ -823,7 +816,7 @@ public class SearchGraph {
for (DynamicEntity instFilt : instanceFilter) {
List<DynamicEntity> any = instFilt.get("any");
- HashMap<String, Object> thisNodeFilterHash = new HashMap<String, Object>();
+ HashMap<String, Object> thisNodeFilterHash = new HashMap<>();
for (DynamicEntity anyEnt : any) {
String clazz = anyEnt.getClass().getCanonicalName();
String simpleClazz = anyEnt.getClass().getSimpleName();
@@ -916,24 +909,22 @@ public class SearchGraph {
vertexId = objectToVertMap.get(item);
}
- if (includeTheseVertices.containsKey(vertexId)) {
- if (invResultItem.isSet("inventoryResponseItems")) {
- List<DynamicEntity> invItemList = new ArrayList<DynamicEntity>();
- DynamicEntity inventoryItems = jaxbContext.newDynamicEntity(
- "inventory.aai.att.com." + aaiExtMap.getApiVersion() + ".InventoryResponseItems");
- DynamicEntity subInventoryResponseItems = invResultItem.get("inventoryResponseItems");
- List<DynamicEntity> subInventoryResponseItemList =
- subInventoryResponseItems.get("inventoryResponseItem");
- for (DynamicEntity ent : subInventoryResponseItemList) {
- DynamicEntity invItem =
- remapInventoryItems(ent, jaxbContext, includeTheseVertices, objectToVertMap, aaiExtMap);
- if (invItem != null) {
- invItemList.add(invItem);
- }
+ if (includeTheseVertices.containsKey(vertexId) && invResultItem.isSet("inventoryResponseItems")) {
+ List<DynamicEntity> invItemList = new ArrayList<>();
+ DynamicEntity inventoryItems = jaxbContext.newDynamicEntity(
+ "inventory.aai.att.com." + aaiExtMap.getApiVersion() + ".InventoryResponseItems");
+ DynamicEntity subInventoryResponseItems = invResultItem.get("inventoryResponseItems");
+ List<DynamicEntity> subInventoryResponseItemList =
+ subInventoryResponseItems.get("inventoryResponseItem");
+ for (DynamicEntity ent : subInventoryResponseItemList) {
+ DynamicEntity invItem =
+ remapInventoryItems(ent, jaxbContext, includeTheseVertices, objectToVertMap, aaiExtMap);
+ if (invItem != null) {
+ invItemList.add(invItem);
}
- inventoryItems.set("inventoryResponseItem", invItemList);
- inventoryItem.set("inventoryResponseItems", inventoryItems);
}
+ inventoryItems.set("inventoryResponseItem", invItemList);
+ inventoryItem.set("inventoryResponseItems", inventoryItems);
}
return inventoryItem;
}
@@ -941,16 +932,13 @@ public class SearchGraph {
/**
* Unpack result set.
*
- * @param g the g
- * @param resultSetList the result set list
- * @param jaxbContext the jaxb context
- * @param aaiResources the aai resources
- * @param objectToVertMap the object to vert map
- * @param aaiExtMap the aai ext map
- * @return the array list
- * @throws AAIException the AAI exception
+ * @param resultSetList The result set list
+ * @param engine The engine
+ * @param loader The loader
+ * @param serializer The database serializer
+ * @return the array list - should return list of inventoryItems
+ * @throws AAIException The AAI Exception
*/
- // this should return an inventoryItem
private List<Object> unpackResultSet(List<ResultSet> resultSetList, TransactionalGraphEngine engine, Loader loader,
DBSerializer serializer) throws AAIException {
@@ -1006,7 +994,7 @@ public class SearchGraph {
if (propertyLimitDesc != null) {
if (PropertyLimitDesc.SHOW_NONE.equals(propertyLimitDesc)) {
- HashMap<String, Object> emptyPropertyOverRideHash = new HashMap<String, Object>();
+ HashMap<String, Object> emptyPropertyOverRideHash = new HashMap<>();
for (String key : thisObj.getAllKeys()) {
emptyPropertyOverRideHash.put(key, null);
}
@@ -1014,7 +1002,7 @@ public class SearchGraph {
} else if (PropertyLimitDesc.SHOW_ALL.equals(propertyLimitDesc)) {
// keep everything
} else if (PropertyLimitDesc.SHOW_NAME_AND_KEYS_ONLY.equals(propertyLimitDesc)) {
- HashMap<String, Object> keysAndNamesPropHash = new HashMap<String, Object>();
+ HashMap<String, Object> keysAndNamesPropHash = new HashMap<>();
for (String key : thisObj.getAllKeys()) {
keysAndNamesPropHash.put(key, null);
@@ -1051,11 +1039,11 @@ public class SearchGraph {
try {
// Try to get the modelName if we can. Otherwise, do not fail, just return what we have already.
String modelInvariantIdLocal =
- (String) vert.<String>property("model-invariant-id-local").orElse(null); // this one
+ vert.<String>property("model-invariant-id-local").orElse(null); // this one
// points at a
// model
String modelVersionIdLocal =
- (String) vert.<String>property("model-version-id-local").orElse(null); // this one
+ vert.<String>property("model-version-id-local").orElse(null); // this one
// points at a
// model-ver
@@ -1073,17 +1061,16 @@ public class SearchGraph {
}
}
}
- } catch (DynamicException e) {
- ; // it's ok, dynamic object might not have these fields
} catch (Exception e) {
- ; // it's ok, couldn't find a matching model
+ // it's ok, dynamic object might not have these fields
+ // it's ok, couldn't find a matching model
}
if (resultSet.getSubResultSet() != null) {
List<ResultSet> subResultSet = resultSet.getSubResultSet();
- if (subResultSet != null && subResultSet.size() > 0) {
+ if (subResultSet != null && !subResultSet.isEmpty()) {
List<Object> res = unpackResultSet(subResultSet, engine, loader, serializer);
- if (res.size() > 0) {
+ if (!res.isEmpty()) {
inventoryItems.setValue("inventory-response-item", res);
inventoryItem.setValue("inventory-response-items",
inventoryItems.getUnderlyingObject());
@@ -1099,9 +1086,7 @@ public class SearchGraph {
private void filterProperties(Introspector thisObj, Map<String, Object> override) {
- thisObj.getProperties().stream().filter(x -> {
- return !override.containsKey(x);
- }).forEach(prop -> {
+ thisObj.getProperties().stream().filter(x -> !override.containsKey(x)).forEach(prop -> {
if (thisObj.isSimpleType(prop)) {
thisObj.setValue(prop, null);
}
diff --git a/aai-traversal/src/main/java/org/onap/aai/interceptors/AAIHeaderProperties.java b/aai-traversal/src/main/java/org/onap/aai/interceptors/AAIHeaderProperties.java
index 6801aee..f27e4f2 100644
--- a/aai-traversal/src/main/java/org/onap/aai/interceptors/AAIHeaderProperties.java
+++ b/aai-traversal/src/main/java/org/onap/aai/interceptors/AAIHeaderProperties.java
@@ -20,20 +20,21 @@
package org.onap.aai.interceptors;
public final class AAIHeaderProperties {
-
- private AAIHeaderProperties(){}
-
+
public static final String REQUEST_CONTEXT = "aai-request-context";
-
+
public static final String HTTP_METHOD_OVERRIDE = "X-HTTP-Method-Override";
-
+
public static final String TRANSACTION_ID = "X-TransactionId";
-
+
public static final String FROM_APP_ID = "X-FromAppId";
-
+
public static final String AAI_TX_ID = "X-AAI-TXID";
-
+
public static final String AAI_REQUEST = "X-REQUEST";
-
+
public static final String AAI_REQUEST_TS = "X-REQUEST-TS";
+
+ private AAIHeaderProperties(){}
+
}
diff --git a/aai-traversal/src/main/java/org/onap/aai/rest/ExceptionHandler.java b/aai-traversal/src/main/java/org/onap/aai/rest/ExceptionHandler.java
index 4b3515b..452815e 100644
--- a/aai-traversal/src/main/java/org/onap/aai/rest/ExceptionHandler.java
+++ b/aai-traversal/src/main/java/org/onap/aai/rest/ExceptionHandler.java
@@ -43,39 +43,37 @@ import com.sun.istack.SAXParseException2;
@Provider
public class ExceptionHandler implements ExceptionMapper<Exception> {
+ private static final String AAI_4007 = "AAI_4007";
+
@Context
private HttpServletRequest request;
@Context
private HttpHeaders headers;
- /**
- * @{inheritDoc}
- */
@Override
public Response toResponse(Exception exception) {
Response response = null;
- ArrayList<String> templateVars = new ArrayList<String>();
+ ArrayList<String> templateVars = new ArrayList<>();
//the general case is that cxf will give us a WebApplicationException
//with a linked exception
if (exception instanceof WebApplicationException) {
WebApplicationException e = (WebApplicationException) exception;
- if (e.getCause() != null) {
- if (e.getCause() instanceof SAXParseException2) {
- templateVars.add("UnmarshalException");
- AAIException ex = new AAIException("AAI_4007", exception);
- response = Response
- .status(400)
- .entity(ErrorLogHelper.getRESTAPIErrorResponse(headers.getAcceptableMediaTypes(), ex, templateVars))
- .build();
- }
+ if (e.getCause() instanceof SAXParseException2) {
+ templateVars.add("UnmarshalException");
+ AAIException ex = new AAIException(AAI_4007, exception);
+ response = Response
+ .status(400)
+ .entity(ErrorLogHelper.getRESTAPIErrorResponse(headers.getAcceptableMediaTypes(), ex, templateVars))
+ .build();
+
}
} else if (exception instanceof JsonParseException) {
//jackson does it differently so we get the direct JsonParseException
templateVars.add("JsonParseException");
- AAIException ex = new AAIException("AAI_4007", exception);
+ AAIException ex = new AAIException(AAI_4007, exception);
response = Response
.status(400)
.entity(ErrorLogHelper.getRESTAPIErrorResponse(headers.getAcceptableMediaTypes(), ex, templateVars))
@@ -83,7 +81,7 @@ public class ExceptionHandler implements ExceptionMapper<Exception> {
} else if (exception instanceof JsonMappingException) {
//jackson does it differently so we get the direct JsonParseException
templateVars.add("JsonMappingException");
- AAIException ex = new AAIException("AAI_4007", exception);
+ AAIException ex = new AAIException(AAI_4007, exception);
response = Response
.status(400)
.entity(ErrorLogHelper.getRESTAPIErrorResponse(headers.getAcceptableMediaTypes(), ex, templateVars))
diff --git a/aai-traversal/src/main/java/org/onap/aai/rest/QueryConsumer.java b/aai-traversal/src/main/java/org/onap/aai/rest/QueryConsumer.java
index d91e50d..54e6d06 100644
--- a/aai-traversal/src/main/java/org/onap/aai/rest/QueryConsumer.java
+++ b/aai-traversal/src/main/java/org/onap/aai/rest/QueryConsumer.java
@@ -47,6 +47,7 @@ import org.onap.aai.serialization.queryformats.SubGraphStyle;
import org.onap.aai.setup.SchemaVersion;
import org.onap.aai.setup.SchemaVersions;
import org.onap.aai.transforms.XmlFormatTransformer;
+
import org.onap.aai.util.TraversalConstants;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -120,6 +121,7 @@ public class QueryConsumer extends TraversalConsumer {
String sourceOfTruth = headers.getRequestHeaders().getFirst("X-FromAppId");
String queryProcessor = headers.getRequestHeaders().getFirst("QueryProcessor");
QueryProcessorType processorType = this.processorType;
+
Response response;
TransactionalGraphEngine dbEngine = null;
@@ -175,7 +177,7 @@ public class QueryConsumer extends TraversalConsumer {
return( createMessageMissingQueryRequiredParameters( missingRequiredQueryParameters, headers));
}
- List<String> invalidQueryParameters = checkForInvalidQueryParameters( customQueryConfig, URITools.getQueryMap(queryURIObj));
+ List<String> invalidQueryParameters = checkForInvalidQueryParameters( customQueryConfig, URITools.getQueryMap(queryURIObj));
if ( !invalidQueryParameters.isEmpty() ) {
return( createMessageInvalidQueryParameters( invalidQueryParameters, headers));
@@ -323,7 +325,7 @@ public class QueryConsumer extends TraversalConsumer {
.entity(ErrorLogHelper.getRESTAPIErrorResponse(headers.getAcceptableMediaTypes(), e,
templateVars)).build();
}
-
+
private Response createMessageInvalidQuerySection(String invalidQuery, HttpHeaders headers) {
AAIException e = new AAIException("AAI_3014");
@@ -336,7 +338,6 @@ public class QueryConsumer extends TraversalConsumer {
templateVars)).build();
}
-
private List<String> checkForInvalidQueryParameters( CustomQueryConfig customQueryConfig, MultivaluedMap<String, String> queryParams) {
List<String> allParameters = new ArrayList<>();
@@ -352,6 +353,7 @@ public class QueryConsumer extends TraversalConsumer {
return queryParams.keySet().stream()
.filter(param -> !allParameters.contains(param))
.collect(Collectors.toList());
+
}
private Response createMessageInvalidQueryParameters(List<String> invalidQueryParams, HttpHeaders headers) {
diff --git a/aai-traversal/src/main/java/org/onap/aai/rest/RecentAPIConsumer.java b/aai-traversal/src/main/java/org/onap/aai/rest/RecentAPIConsumer.java
index 2e43e5b..86ed49d 100644
--- a/aai-traversal/src/main/java/org/onap/aai/rest/RecentAPIConsumer.java
+++ b/aai-traversal/src/main/java/org/onap/aai/rest/RecentAPIConsumer.java
@@ -55,6 +55,8 @@ import java.util.concurrent.TimeUnit;
@Path("/recents/{version: v[1-9][0-9]*|latest}")
public class RecentAPIConsumer extends RESTAPI {
+ private static final String AAI_3021 = "AAI_3021";
+
/** The introspector factory type. */
private ModelType introspectorFactoryType = ModelType.MOXY;
@@ -187,7 +189,7 @@ public class RecentAPIConsumer extends RESTAPI {
private void checkVersion(SchemaVersion version) throws AAIException {
if(!schemaVersions.getVersions().contains(version)){
- throw new AAIException("AAI_3021", "Schema Version is not valid");
+ throw new AAIException(AAI_3021, "Schema Version is not valid");
}
}
@@ -210,10 +212,10 @@ public class RecentAPIConsumer extends RESTAPI {
hours = Long.parseLong(params.getFirst("hours"));
}
catch(NumberFormatException ex){
- throw new AAIException("AAI_3021", " Invalid Hours. Valid values for hours are 1 to " + AAIConstants.HISTORY_MAX_HOURS);
+ throw new AAIException(AAI_3021, " Invalid Hours. Valid values for hours are 1 to " + AAIConstants.HISTORY_MAX_HOURS);
}
if (hours < 1 || hours > AAIConstants.HISTORY_MAX_HOURS) {
- throw new AAIException("AAI_3021", " Valid values for hours are 1 to " + AAIConstants.HISTORY_MAX_HOURS);
+ throw new AAIException(AAI_3021, " Valid values for hours are 1 to " + AAIConstants.HISTORY_MAX_HOURS);
}
}
if (params != null && params.containsKey("date-time") && params.getFirst("date-time").matches("-?\\d+")) {
@@ -224,19 +226,19 @@ public class RecentAPIConsumer extends RESTAPI {
startTime = Long.parseLong(params.getFirst("date-time"));
}
catch(NumberFormatException ex){
- throw new AAIException("AAI_3021", " Invalid Data-time. Valid values for date-time are "+minStartTime+" to " + System.currentTimeMillis() );
+ throw new AAIException(AAI_3021, " Invalid Data-time. Valid values for date-time are "+minStartTime+" to " + System.currentTimeMillis() );
}
if (startTime < minStartTime) {
- throw new AAIException("AAI_3021", " Valid values for date-time are "+minStartTime+" to " + System.currentTimeMillis() );
+ throw new AAIException(AAI_3021, " Valid values for date-time are "+minStartTime+" to " + System.currentTimeMillis() );
}
}
if(!isHoursParameter && !isDateTimeParameter){
- throw new AAIException("AAI_3021", "Send valid hours or date-time to specify the timebounds");
+ throw new AAIException(AAI_3021, "Send valid hours or date-time to specify the timebounds");
}
if(isHoursParameter && isDateTimeParameter){
- throw new AAIException("AAI_3021", "Send either hours or date-time and not both to specify the timebounds");
+ throw new AAIException(AAI_3021, "Send either hours or date-time and not both to specify the timebounds");
}
diff --git a/aai-traversal/src/main/java/org/onap/aai/rest/TraversalConsumer.java b/aai-traversal/src/main/java/org/onap/aai/rest/TraversalConsumer.java
index 4aa0888..059d2c8 100644
--- a/aai-traversal/src/main/java/org/onap/aai/rest/TraversalConsumer.java
+++ b/aai-traversal/src/main/java/org/onap/aai/rest/TraversalConsumer.java
@@ -141,9 +141,9 @@ public abstract class TraversalConsumer extends RESTAPI {
protected GraphTraversalSource getTraversalSource(TransactionalGraphEngine dbEngine, Format format, UriInfo info) throws AAIException {
if (isHistory(format)) {
- long startTime = this.getStartTime(format, info.getQueryParameters());
- long endTime = this.getEndTime(info.getQueryParameters());
- return dbEngine.asAdmin().getTraversalSource().withStrategies(getSubgraphStrategy(startTime, endTime, format));
+ long localStartTime = this.getStartTime(format, info.getQueryParameters());
+ long localEndTime = this.getEndTime(info.getQueryParameters());
+ return dbEngine.asAdmin().getTraversalSource().withStrategies(getSubgraphStrategy(localStartTime, localEndTime, format));
}
return dbEngine.asAdmin().getTraversalSource();
}
diff --git a/aai-traversal/src/main/java/org/onap/aai/rest/search/GetCustomQueryConfig.java b/aai-traversal/src/main/java/org/onap/aai/rest/search/GetCustomQueryConfig.java
index 7227815..76ecd20 100644
--- a/aai-traversal/src/main/java/org/onap/aai/rest/search/GetCustomQueryConfig.java
+++ b/aai-traversal/src/main/java/org/onap/aai/rest/search/GetCustomQueryConfig.java
@@ -19,34 +19,10 @@
*/
package org.onap.aai.rest.search;
-/*-
- * ============LICENSE_START=======================================================
- * org.onap.aai
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. 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=========================================================
- */
-
-import java.io.IOException;
import java.lang.reflect.Type;
-import java.nio.file.Files;
-import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.List;
-import org.onap.aai.util.AAIConstants;
import com.google.gson.Gson;
import com.google.gson.JsonArray;
@@ -61,14 +37,12 @@ public class GetCustomQueryConfig {
private CustomQueryConfig customQueryConfig;
- private final static String QUERY_CONFIG = "query";
- private final static String REQUIRED_CONFIG = "required-properties";
- private final static String OPTIONAL_CONFIG = "optional-properties";
- private final static String STORED_QUERIES_CONFIG = "stored-queries";
- private final static String STORED_QUERY_CONFIG = "stored-query";
+ private static final String QUERY_CONFIG = "query";
+ private static final String REQUIRED_CONFIG = "required-properties";
+ private static final String OPTIONAL_CONFIG = "optional-properties";
+ private static final String STORED_QUERIES_CONFIG = "stored-queries";
+ private static final String STORED_QUERY_CONFIG = "stored-query";
-// public static final String AAI_HOME_ETC_QUERY_JSON = AAIConstants.AAI_HOME_ETC + "query" + AAIConstants.AAI_FILESEP + "stored-queries.json";
-
public GetCustomQueryConfig(String customQueryJson ) {
init(customQueryJson);
}
@@ -104,40 +78,27 @@ public class GetCustomQueryConfig {
return toStringList(null);
}
- private String getPropertyString(JsonObject configObject, String config) {
- JsonElement subqueryConfig;
-
- if ( configObject.has(config)) {
- subqueryConfig = configObject.get(config);
- if ( subqueryConfig != null && !subqueryConfig.isJsonNull() ) {
- return subqueryConfig.getAsString();
- }
- }
- return null;
- }
-
private void getStoredQueryBlock( JsonObject configObject, String config ) {
if ( !configObject.has(config)) {
- customQueryConfig.setQueryRequiredProperties( new ArrayList<String>() );
- customQueryConfig.setQueryOptionalProperties( new ArrayList<String>() );
+ customQueryConfig.setQueryRequiredProperties( new ArrayList<>() );
+ customQueryConfig.setQueryOptionalProperties( new ArrayList<>() );
return;
}
JsonElement queryConfig;
JsonObject subObject;
- String multipleStartNodes;
List<String> propertyList;
queryConfig = configObject.get(config);
subObject = queryConfig.getAsJsonObject();
propertyList = getPropertyList(subObject, REQUIRED_CONFIG);
if ( propertyList == null ) {
- propertyList = new ArrayList<String>();
+ propertyList = new ArrayList<>();
}
customQueryConfig.setQueryRequiredProperties( propertyList );
propertyList = getPropertyList(subObject, OPTIONAL_CONFIG);
if ( propertyList == null ) {
- propertyList = new ArrayList<String>();
+ propertyList = new ArrayList<>();
}
customQueryConfig.setQueryOptionalProperties( propertyList );
@@ -150,7 +111,6 @@ public class GetCustomQueryConfig {
JsonObject configObject;
JsonElement query;
JsonElement queryConfig;
- String queryString;
for (JsonElement storedQuery : storedQueries) {
if (storedQuery.isJsonObject()) {
diff --git a/aai-traversal/src/main/java/org/onap/aai/rest/search/ModelAndNamedQueryRestProvider.java b/aai-traversal/src/main/java/org/onap/aai/rest/search/ModelAndNamedQueryRestProvider.java
index e590964..821cb09 100644
--- a/aai-traversal/src/main/java/org/onap/aai/rest/search/ModelAndNamedQueryRestProvider.java
+++ b/aai-traversal/src/main/java/org/onap/aai/rest/search/ModelAndNamedQueryRestProvider.java
@@ -109,8 +109,9 @@ public class ModelAndNamedQueryRestProvider extends RESTAPI {
Response response;
String fromAppId;
String transId;
- ArrayList<String> templateVars = new ArrayList<String>();
- try {
+
+ ArrayList<String> templateVars = new ArrayList<>();
+ try {
fromAppId = getFromAppId(headers);
transId = getTransId(headers);
@@ -134,7 +135,6 @@ public class ModelAndNamedQueryRestProvider extends RESTAPI {
response = searchGraph.runNamedQuery(fromAppId, transId, queryParameters, aaiExtMap);
metricLog.post();
- //LOGGER.info ("Completed");
} catch (AAIException e) {
// send error response
@@ -204,7 +204,6 @@ public class ModelAndNamedQueryRestProvider extends RESTAPI {
Response response;
String fromAppId;
String transId;
-
ArrayList<String> templateVars = new ArrayList<>();
try {
fromAppId = getFromAppId(headers);
@@ -236,7 +235,6 @@ public class ModelAndNamedQueryRestProvider extends RESTAPI {
response = searchGraph.executeModelOperation(fromAppId, transId, inboundPayload, false, aaiExtMap);
}
metricLog.post();
- //LOGGER.info ("Completed");
} catch (AAIException e) {
// send error response
diff --git a/aai-traversal/src/main/java/org/onap/aai/rest/search/NodeQueryProcessor.java b/aai-traversal/src/main/java/org/onap/aai/rest/search/NodeQueryProcessor.java
index 61f370b..366e7df 100644
--- a/aai-traversal/src/main/java/org/onap/aai/rest/search/NodeQueryProcessor.java
+++ b/aai-traversal/src/main/java/org/onap/aai/rest/search/NodeQueryProcessor.java
@@ -21,7 +21,6 @@ package org.onap.aai.rest.search;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import com.att.eelf.configuration.EELFManager;
import edu.emory.mathcs.backport.java.util.concurrent.TimeUnit;
@@ -42,21 +41,22 @@ import javax.ws.rs.core.MultivaluedMap;
public class NodeQueryProcessor extends GroovyShellImpl {
- private static Logger LOGGER = LoggerFactory.getLogger(NodeQueryProcessor.class);
+ private static Logger logger = LoggerFactory.getLogger(NodeQueryProcessor.class);
protected String nodeType;
- private MultivaluedMap<String, String> nodeQueryParams = new MultivaluedHashMap<String, String>();
+ private MultivaluedMap<String, String> nodeQueryParams = new MultivaluedHashMap<>();
protected final Optional<Collection<Vertex>> vertices;
protected static Pattern p = Pattern.compile("query/(.*+)");
protected Optional<String> gremlin;
protected final TransactionalGraphEngine dbEngine;
- protected GroovyQueryBuilder queryBuilder = new GroovyQueryBuilder();;
+ protected GroovyQueryBuilder queryBuilder = new GroovyQueryBuilder();
protected NodeQueryProcessor(Builder builder) {
super(builder);
this.nodeQueryParams = builder.uriParams;
- if(builder.getNodeType().isPresent())
- this.nodeType = builder.getNodeType().get();
+ if(builder.getNodeType().isPresent()) {
+ this.nodeType = builder.getNodeType().get();
+ }
this.dbEngine = builder.getDbEngine();
this.vertices = builder.getVertices();
@@ -89,8 +89,8 @@ public class NodeQueryProcessor extends GroovyShellImpl {
query = startPrefix + query;
- if (LOGGER.isDebugEnabled()) {
- LOGGER.debug("Converted to gremlin query without the start vertices \n {}", query);
+ if (logger.isDebugEnabled()) {
+ logger.debug("Converted to gremlin query without the start vertices \n {}", query);
}
return new Pair<>(query, params);
diff --git a/aai-traversal/src/main/java/org/onap/aai/rest/search/SearchProvider.java b/aai-traversal/src/main/java/org/onap/aai/rest/search/SearchProvider.java
index 75a19c9..241cffd 100644
--- a/aai-traversal/src/main/java/org/onap/aai/rest/search/SearchProvider.java
+++ b/aai-traversal/src/main/java/org/onap/aai/rest/search/SearchProvider.java
@@ -149,8 +149,6 @@ public class SearchProvider extends RESTAPI {
metricLog.post();
- //LOGGER.info("Completed");
-
} catch (AAIException e) {
// send error response
ex = e;
@@ -224,7 +222,7 @@ public class SearchProvider extends RESTAPI {
fromAppId = getFromAppId(headers);
getTransId(headers);
- String realTime = headers.getRequestHeaders().getFirst("Real-Time");
+
// only consider header value for search
final SchemaVersion version = new SchemaVersion(versionParam);
@@ -243,7 +241,6 @@ public class SearchProvider extends RESTAPI {
.setDbEngine(dbEngine).setLoader(loader).setUrlBuilder(urlBuilder));
metricLog.post();
- //LOGGER.info("Completed");
} catch (AAIException e) {
// send error response
diff --git a/aai-traversal/src/main/java/org/onap/aai/rest/util/ConvertQueryPropertiesToJson.java b/aai-traversal/src/main/java/org/onap/aai/rest/util/ConvertQueryPropertiesToJson.java
index 3bf9087..f16e700 100644
--- a/aai-traversal/src/main/java/org/onap/aai/rest/util/ConvertQueryPropertiesToJson.java
+++ b/aai-traversal/src/main/java/org/onap/aai/rest/util/ConvertQueryPropertiesToJson.java
@@ -19,21 +19,15 @@
*/
package org.onap.aai.rest.util;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.Iterator;
import java.util.List;
import java.util.Properties;
-
-import org.onap.aai.util.AAIConstants;
-
public class ConvertQueryPropertiesToJson {
- private final static int maxfilesize = 256000;
+ private static final int MAX_FILE_SIZE = 256000;
private void addStart( StringBuilder sb ) {
sb.append("{\n \"stored-queries\":[{\n");
@@ -80,7 +74,7 @@ public class ConvertQueryPropertiesToJson {
private List<String> findRqdProperties( String query) {
String[] parts = query.split("getVerticesByProperty");
- List<String> result = new ArrayList<String>();
+ List<String> result = new ArrayList<>();
if ( parts.length == 1 )
return result;
int count = 0;
@@ -96,7 +90,7 @@ public class ConvertQueryPropertiesToJson {
public String convertProperties( Properties props ) {
Enumeration<?> e = props.propertyNames();
- StringBuilder sb = new StringBuilder(maxfilesize);
+ StringBuilder sb = new StringBuilder(MAX_FILE_SIZE);
String queryName;
String query;
addStart( sb );
diff --git a/aai-traversal/src/main/java/org/onap/aai/rest/util/EchoResponse.java b/aai-traversal/src/main/java/org/onap/aai/rest/util/EchoResponse.java
index ed9e159..16c2618 100644
--- a/aai-traversal/src/main/java/org/onap/aai/rest/util/EchoResponse.java
+++ b/aai-traversal/src/main/java/org/onap/aai/rest/util/EchoResponse.java
@@ -45,7 +45,7 @@ public class EchoResponse extends RESTAPI {
protected static String authPolicyFunctionName = "util";
- public static final String echoPath = "/echo";
+ public static final String ECHO_PATH = "/echo";
/**
* Simple health-check API that echos back the X-FromAppId and X-TransactionId to clients.
@@ -59,20 +59,19 @@ public class EchoResponse extends RESTAPI {
*/
@GET
@Produces( { MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
- @Path(echoPath)
+ @Path(ECHO_PATH)
public Response echoResult(@Context HttpHeaders headers, @Context HttpServletRequest req,
@QueryParam("action") String myAction) {
- Response response = null;
-
AAIException ex = null;
- String fromAppId = null;
- String transId = null;
+ Response response;
+ String fromAppId;
+ String transId;
try {
fromAppId = getFromAppId(headers );
transId = getTransId(headers);
} catch (AAIException e) {
- ArrayList<String> templateVars = new ArrayList<String>();
+ ArrayList<String> templateVars = new ArrayList<>();
templateVars.add("PUT uebProvider");
templateVars.add("addTopic");
return Response
@@ -83,9 +82,9 @@ public class EchoResponse extends RESTAPI {
try {
- HashMap<AAIException, ArrayList<String>> exceptionList = new HashMap<AAIException, ArrayList<String>>();
+ HashMap<AAIException, ArrayList<String>> exceptionList = new HashMap<>();
- ArrayList<String> templateVars = new ArrayList<String>();
+ ArrayList<String> templateVars = new ArrayList<>();
templateVars.add(fromAppId);
templateVars.add(transId);
@@ -98,7 +97,7 @@ public class EchoResponse extends RESTAPI {
} catch (Exception e) {
ex = new AAIException("AAI_4000", e);
- ArrayList<String> templateVars = new ArrayList<String>();
+ ArrayList<String> templateVars = new ArrayList<>();
templateVars.add(Action.GET.name());
templateVars.add(fromAppId +" "+transId);
diff --git a/aai-traversal/src/main/java/org/onap/aai/service/AuthorizationService.java b/aai-traversal/src/main/java/org/onap/aai/service/AuthorizationService.java
index c0fa93e..b4fa996 100644
--- a/aai-traversal/src/main/java/org/onap/aai/service/AuthorizationService.java
+++ b/aai-traversal/src/main/java/org/onap/aai/service/AuthorizationService.java
@@ -21,7 +21,6 @@ package org.onap.aai.service;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import com.att.eelf.configuration.EELFManager;
import org.eclipse.jetty.util.security.Password;
import org.onap.aai.Profiles;
import org.onap.aai.util.AAIConstants;
@@ -30,7 +29,7 @@ import org.springframework.stereotype.Service;
import javax.annotation.PostConstruct;
import java.io.IOException;
-import java.io.UnsupportedEncodingException;
+import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.Base64;
@@ -60,38 +59,33 @@ public class AuthorizationService {
String usernamePassword = null;
String accessType = null;
- try {
- String [] userAccessType = str.split(",");
+ String [] userAccessType = str.split(",");
- if(userAccessType == null || userAccessType.length != 2){
- throw new RuntimeException("Please check the realm.properties file as it is not conforming to the basic auth");
- }
+ if(userAccessType.length != 2){
+ throw new RuntimeException("Please check the realm.properties file as it is not conforming to the basic auth");
+ }
- usernamePassword = userAccessType[0];
- accessType = userAccessType[1];
+ usernamePassword = userAccessType[0];
+ accessType = userAccessType[1];
- String[] usernamePasswordArray = usernamePassword.split(":");
+ String[] usernamePasswordArray = usernamePassword.split(":");
- if(usernamePasswordArray == null || usernamePasswordArray.length != 3){
- throw new RuntimeException("This username / pwd is not a valid entry in realm.properties");
- }
+ if(usernamePasswordArray.length != 3){
+ throw new RuntimeException("This username / pwd is not a valid entry in realm.properties");
+ }
- String username = usernamePasswordArray[0];
- String password = null;
+ String username = usernamePasswordArray[0];
+ String password = null;
- if(str.contains("OBF:")){
- password = usernamePasswordArray[1] + ":" + usernamePasswordArray[2];
- password = Password.deobfuscate(password);
- }
+ if(str.contains("OBF:")){
+ password = usernamePasswordArray[1] + ":" + usernamePasswordArray[2];
+ password = Password.deobfuscate(password);
+ }
- bytes = ENCODER.encode((username + ":" + password).getBytes("UTF-8"));
+ bytes = ENCODER.encode((username + ":" + password).getBytes(StandardCharsets.UTF_8));
- authorizedUsers.put(new String(bytes), accessType);
+ authorizedUsers.put(new String(bytes), accessType);
- } catch (UnsupportedEncodingException e)
- {
- logger.error("Unable to support the encoding of the file" + basicAuthFile);
- }
authorizedUsers.put(new String(ENCODER.encode(bytes)), accessType);
});
diff --git a/aai-traversal/src/main/java/org/onap/aai/transforms/MapTraverser.java b/aai-traversal/src/main/java/org/onap/aai/transforms/MapTraverser.java
index 9091998..f59fb10 100644
--- a/aai-traversal/src/main/java/org/onap/aai/transforms/MapTraverser.java
+++ b/aai-traversal/src/main/java/org/onap/aai/transforms/MapTraverser.java
@@ -39,7 +39,7 @@ public class MapTraverser {
Objects.ensureNotNull(map);
- Map<String, Object> modifiedMap = new HashMap<String, Object>();
+ Map<String, Object> modifiedMap = new HashMap<>();
convertKeys(map, modifiedMap);
return modifiedMap;
@@ -52,7 +52,7 @@ public class MapTraverser {
key = converter.convert(key);
Object value = entry.getValue();
if(value instanceof Map){
- modified.put(key, convertKeys((Map<String, Object>)value, new HashMap<String, Object>()));
+ modified.put(key, convertKeys((Map<String, Object>) value, new HashMap<>()));
} else if(value instanceof List){
modified.put(key, convertKeys((List<Object>) value));
} else {
@@ -65,8 +65,8 @@ public class MapTraverser {
public List<Object> convertKeys(List<Object> list){
- List<Object> modifiedList = new ArrayList<Object>();
- if(list != null && list.size() > 0){
+ List<Object> modifiedList = new ArrayList<>();
+ if(list != null && !list.isEmpty()){
for(Object o : list){
if(o instanceof Map){
diff --git a/aai-traversal/src/main/java/org/onap/aai/util/MakeNamedQuery.java b/aai-traversal/src/main/java/org/onap/aai/util/MakeNamedQuery.java
index 4a80f58..17207f3 100644
--- a/aai-traversal/src/main/java/org/onap/aai/util/MakeNamedQuery.java
+++ b/aai-traversal/src/main/java/org/onap/aai/util/MakeNamedQuery.java
@@ -20,11 +20,9 @@
package org.onap.aai.util;
import java.io.File;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
+import java.nio.charset.Charset;
+import java.util.*;
import java.util.Map.Entry;
-import java.util.UUID;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -92,7 +90,7 @@ public class MakeNamedQuery {
HashMap<String, List<Introspector>> widgetToRelationship = new HashMap<>();
for (Entry<String, Introspector> aaiResEnt : loader.getAllObjects().entrySet()) {
- Introspector meObject = loader.introspectorFromName("model");
+ Introspector meObject;
// no need for a ModelVers DynamicEntity
Introspector aaiRes = aaiResEnt.getValue();
@@ -110,16 +108,16 @@ public class MakeNamedQuery {
File f = new File(filePathString);
if (f.exists()) {
System.out.println(f.toString());
- String json = FileUtils.readFileToString(f);
+ String json = FileUtils.readFileToString(f, Charset.defaultCharset());
meObject = loader.unmarshal("Model", json);
String modelInvariantId = meObject.getValue("model-invariant-id");
if (meObject.hasProperty("model-vers")) {
Introspector modelVers = meObject.getWrappedValue("model-vers");
- List<Introspector> modelVerList = (List<Introspector>) modelVers.getWrappedListValue("model-ver");
+ List<Introspector> modelVerList = modelVers.getWrappedListValue("model-ver");
for (Introspector modelVer : modelVerList) {
- List<Introspector> relList = new ArrayList<Introspector>();
+ List<Introspector> relList = new ArrayList<>();
Introspector widgetRelationship = makeWidgetRelationship(loader, modelInvariantId,
modelVer.getValue("model-version-id").toString());
relList.add(widgetRelationship);
@@ -134,8 +132,6 @@ public class MakeNamedQuery {
//source vnf-id, related service-instance-id, all related vnfs in this service-instance-id
//this should be abstracted and moved to a file
- HashMap<String, List<Introspector>> relationshipMap = new HashMap<String, List<Introspector>>();
-
List<Introspector> genericVnfRelationship = widgetToRelationship.get("generic-vnf");
List<Introspector> vserverRelationship = widgetToRelationship.get("vserver");
List<Introspector> tenantRelationship = widgetToRelationship.get("tenant");
@@ -164,12 +160,6 @@ public class MakeNamedQuery {
System.exit(0);
- }
- private static List<Introspector> getRels(String widgetName, HashMap<String, Introspector> widgetToRelationship) {
- List<Introspector> relList = new ArrayList<Introspector>();
- Introspector genericVnfRelationship = widgetToRelationship.get(widgetName);
- relList.add(genericVnfRelationship);
- return relList;
}
private static Introspector setupNQElements (Introspector nqeObj, List<Introspector> listOfRelationships) {
@@ -183,10 +173,12 @@ public class MakeNamedQuery {
} else {
newNQElements = nqeObj.newIntrospectorInstanceOfProperty("named-query-elements");
nqeObj.setValue("named-query-elements", newNQElements.getUnderlyingObject());
- nqElementList = (List<Object>)newNQElements.getValue("named-query-element");
+ nqElementList = newNQElements.getValue("named-query-element");
}
newNQElement = loadNQElement(newNQElements, listOfRelationships);
- nqElementList.add(newNQElement.getUnderlyingObject());
+ if (newNQElement != null) {
+ nqElementList.add(newNQElement.getUnderlyingObject());
+ }
} catch (AAIUnknownObjectException e) {
logger.info("AAIUnknownObjectException in MakeNamedQuery.setupNQElements() "+e);
@@ -202,13 +194,13 @@ public class MakeNamedQuery {
Introspector newNqElement = null;
try {
newNqElement = nqElements.getLoader().introspectorFromName("named-query-element");
-
+
//newNqElement.setValue("named-query-element-uuid", UUID.randomUUID().toString());
Introspector newRelationshipList = newNqElement.getLoader().introspectorFromName("relationship-list");
newNqElement.setValue("relationship-list", newRelationshipList.getUnderlyingObject());
- List<Object> newRelationshipListList = (List<Object>)newRelationshipList.getValue("relationship");
+ List<Object> newRelationshipListList = newRelationshipList.getValue("relationship");
for (Introspector rel : listOfRelationships) {
newRelationshipListList.add(rel.getUnderlyingObject());
@@ -230,7 +222,7 @@ public class MakeNamedQuery {
try {
newRelationship = loader.introspectorFromName("relationship");
- List<Object> newRelationshipData = (List<Object>)newRelationship.getValue("relationship-data");
+ List<Object> newRelationshipData = newRelationship.getValue("relationship-data");
newRelationship.setValue("related-to", "model");