diff options
-rw-r--r-- | aai-core/pom.xml | 13 | ||||
-rw-r--r-- | aai-core/src/main/java/org/onap/aai/rest/db/HttpEntry.java | 187 | ||||
-rw-r--r-- | aai-core/src/test/java/org/onap/aai/rest/db/HttpEntryTest.java | 15 | ||||
-rw-r--r-- | aai-els-onap-logging/src/main/java/org/onap/logging/filter/base/MDCSetup.java | 22 | ||||
-rw-r--r-- | aai-parent/pom.xml | 8 | ||||
-rw-r--r-- | aai-rest/pom.xml | 2 | ||||
-rw-r--r-- | aai-schema-ingest/.classpath | 57 | ||||
-rw-r--r-- | aai-schema-ingest/pom.xml | 1 |
8 files changed, 38 insertions, 267 deletions
diff --git a/aai-core/pom.xml b/aai-core/pom.xml index 30820d80..cd78bff2 100644 --- a/aai-core/pom.xml +++ b/aai-core/pom.xml @@ -198,6 +198,11 @@ limitations under the License. </exclusions> </dependency> <dependency> + <groupId>org.janusgraph</groupId> + <artifactId>janusgraph-inmemory</artifactId> + <scope>test</scope> + </dependency> + <dependency> <groupId>com.fasterxml.jackson.jaxrs</groupId> <artifactId>jackson-jaxrs-json-provider</artifactId> </dependency> @@ -282,10 +287,6 @@ limitations under the License. <version>1.4.01</version> </dependency> <dependency> - <groupId>com.beust</groupId> - <artifactId>jcommander</artifactId> - </dependency> - <dependency> <groupId>org.json</groupId> <artifactId>json</artifactId> </dependency> @@ -314,10 +315,6 @@ limitations under the License. <artifactId>activemq-openwire-legacy</artifactId> </dependency> <dependency> - <groupId>com.opencsv</groupId> - <artifactId>opencsv</artifactId> - </dependency> - <dependency> <groupId>org.freemarker</groupId> <artifactId>freemarker</artifactId> </dependency> diff --git a/aai-core/src/main/java/org/onap/aai/rest/db/HttpEntry.java b/aai-core/src/main/java/org/onap/aai/rest/db/HttpEntry.java index 7c652079..85c87667 100644 --- a/aai-core/src/main/java/org/onap/aai/rest/db/HttpEntry.java +++ b/aai-core/src/main/java/org/onap/aai/rest/db/HttpEntry.java @@ -95,11 +95,6 @@ public class HttpEntry { private boolean processSingle = true; - private int paginationBucket = -1; - private int paginationIndex = -1; - private int totalVertices = 0; - private int totalPaginationBuckets = 0; - @Autowired private NodeIngestor nodeIngestor; @@ -178,132 +173,26 @@ public class HttpEntry { return this; } - /** - * Gets the introspector factory type. - * - * @return the introspector factory type - */ public ModelType getIntrospectorFactoryType() { return introspectorFactoryType; } - /** - * Gets the query style. - * - * @return the query style - */ public QueryStyle getQueryStyle() { return queryStyle; } - /** - * Gets the version. - * - * @return the version - */ public SchemaVersion getVersion() { return version; } - /** - * Gets the loader. - * - * @return the loader - */ public Loader getLoader() { return loader; } - /** - * Gets the db engine. - * - * @return the db engine - */ public TransactionalGraphEngine getDbEngine() { return dbEngine; } - /** - * Checks the pagination bucket and pagination index variables to determine whether or not the user - * requested paginated results - * - * @return a boolean true/false of whether the user requested paginated results - */ - public boolean isPaginated() { - return this.paginationBucket > -1 && this.paginationIndex > -1; - } - - /** - * Returns the pagination size - * - * @return integer of the size of results to be returned when paginated - */ - public int getPaginationBucket() { - return this.paginationBucket; - } - - /** - * Setter for the pagination bucket variable which stores in this object the size of results to return - * - * @param pb - */ - public void setPaginationBucket(int pb) { - this.paginationBucket = pb; - } - - /** - * Getter to return the pagination index requested by the user when requesting paginated results - * - * @return - */ - public int getPaginationIndex() { - return this.paginationIndex; - } - - /** - * Sets the pagination index that was passed in by the user, to determine which index or results to retrieve when - * paginated - * - * @param pi - */ - public void setPaginationIndex(int pi) { - if (pi == 0) { - pi = 1; - } - this.paginationIndex = pi; - } - - /** - * Sets the total vertices variables and calculates the amount of pages based on size and total vertices - * - * @param totalVertices - * @param paginationBucketSize - */ - public void setTotalsForPaging(int totalVertices, int paginationBucketSize) { - this.totalVertices = totalVertices; - // set total number of buckets equal to full pages - this.totalPaginationBuckets = totalVertices / paginationBucketSize; - // conditionally add a page for the remainder - if (totalVertices % paginationBucketSize > 0) { - this.totalPaginationBuckets++; - } - } - - /** - * @return the total amount of pages - */ - public int getTotalPaginationBuckets() { - return this.totalPaginationBuckets; - } - - /** - * - * @return the total number of vertices when paginated - */ - public int getTotalVertices() { - return this.totalVertices; - } - public Pair<Boolean, List<Pair<URI, Response>>> process(List<DBRequest> requests, String sourceOfTruth) throws AAIException { return this.process(requests, sourceOfTruth, true); } @@ -679,8 +568,10 @@ public class HttpEntry { ) { String myvertid = v.id().toString(); if (paginationResult != null && paginationResult.getTotalCount() != null) { + long totalPages = getTotalPages(queryOptions, paginationResult); response = Response.status(status).header("vertex-id", myvertid) .header("total-results", paginationResult.getTotalCount()) + .header("total-pages", totalPages) .entity(result) .type(outputMediaType).build(); } else { @@ -741,6 +632,17 @@ public class HttpEntry { return Pair.with(success, responses); } + private long getTotalPages(QueryOptions queryOptions, PaginationResult<Vertex> paginationResult) { + long totalCount = paginationResult.getTotalCount(); + int pageSize = queryOptions.getPageable().getPageSize(); + long totalPages = totalCount / pageSize; + // conditionally add a page for the remainder + if (totalCount % pageSize > 0) { + totalPages++; + } + return totalPages; + } + private List<Vertex> executeQuery(QueryParser query, QueryOptions queryOptions) { return (queryOptions != null && queryOptions.getSort() != null) ? query.getQueryBuilder().sort(queryOptions.getSort()).toList() @@ -1122,67 +1024,4 @@ public class HttpEntry { } } } - - public void setPaginationParameters(String resultIndex, String resultSize) { - if (resultIndex != null && !"-1".equals(resultIndex) && resultSize != null && !"-1".equals(resultSize)) { - this.setPaginationIndex(Integer.parseInt(resultIndex)); - this.setPaginationBucket(Integer.parseInt(resultSize)); - } - } - - @Deprecated - public List<Object> getPaginatedVertexListForAggregateFormat(List<Object> aggregateVertexList) throws AAIException { - List<Object> finalList = new Vector<>(); - if (this.isPaginated()) { - if (aggregateVertexList != null && !aggregateVertexList.isEmpty()) { - int listSize = aggregateVertexList.size(); - if (listSize == 1) { - List<Object> vertexList = (List<Object>) aggregateVertexList.get(0); - this.setTotalsForPaging(vertexList.size(), this.getPaginationBucket()); - int startIndex = (this.getPaginationIndex() - 1) * this.getPaginationBucket(); - int endIndex = - Math.min((this.getPaginationBucket() * this.getPaginationIndex()), vertexList.size()); - if (startIndex > endIndex) { - throw new AAIException("AAI_6150", - " ResultIndex is not appropriate for the result set, Needs to be <= " + endIndex); - } - finalList.add(new ArrayList<Object>()); - for (int i = startIndex; i < endIndex; i++) { - ((ArrayList<Object>) finalList.get(0)) - .add(((ArrayList<Object>) aggregateVertexList.get(0)).get(i)); - } - return finalList; - } - } - } - // If the list size is greater than 1 or if pagination is not needed, return the original list. - return aggregateVertexList; - } - - /** - * This method is used to paginate the vertex list based on the pagination index and bucket size - * - * @deprecated - * This method is no longer supported. Use {@link #process(List, String, Set, boolean, QueryOptions)} instead. - * @param vertexList - * @return - * @throws AAIException - */ - @Deprecated - public List<Object> getPaginatedVertexList(List<Object> vertexList) throws AAIException { - List<Object> vertices; - if (this.isPaginated()) { - this.setTotalsForPaging(vertexList.size(), this.getPaginationBucket()); - int startIndex = (this.getPaginationIndex() - 1) * this.getPaginationBucket(); - int endIndex = Math.min((this.getPaginationBucket() * this.getPaginationIndex()), vertexList.size()); - if (startIndex > endIndex) { - throw new AAIException("AAI_6150", - " ResultIndex is not appropriate for the result set, Needs to be <= " + endIndex); - } - vertices = vertexList.subList(startIndex, endIndex); - } else { - vertices = vertexList; - } - return vertices; - } } diff --git a/aai-core/src/test/java/org/onap/aai/rest/db/HttpEntryTest.java b/aai-core/src/test/java/org/onap/aai/rest/db/HttpEntryTest.java index 0dcec24d..3bf991ec 100644 --- a/aai-core/src/test/java/org/onap/aai/rest/db/HttpEntryTest.java +++ b/aai-core/src/test/java/org/onap/aai/rest/db/HttpEntryTest.java @@ -319,8 +319,10 @@ public class HttpEntryTest extends AAISetup { Response response = doRequest(traversalHttpEntry, loader, dbEngine, HttpMethod.GET, uri, queryOptions); JSONObject actualResponseBody = new JSONObject(response.getEntity().toString()); String totalCount = response.getHeaderString("total-results"); + String totalPages = response.getHeaderString("total-pages"); assertEquals(2, Integer.parseInt(totalCount)); + assertEquals(2, Integer.parseInt(totalPages)); assertEquals(1, actualResponseBody.getJSONArray("pserver").length()); assertEquals("Expected the pservers to be returned", 200, response.getStatus()); verify(validationService, times(1)).validate(any()); @@ -986,19 +988,6 @@ public class HttpEntryTest extends AAISetup { } @Test - public void testSetGetPaginationMethods() { - traversalHttpEntry.setHttpEntryProperties(schemaVersions.getDefaultVersion()); - traversalHttpEntry.setPaginationBucket(10); - traversalHttpEntry.setPaginationIndex(1); - traversalHttpEntry.setTotalsForPaging(101, traversalHttpEntry.getPaginationBucket()); - assertEquals("Expected the pagination bucket size to be 10", 10, traversalHttpEntry.getPaginationBucket()); - assertEquals("Expected the total number of pagination buckets to be 11", 11, - traversalHttpEntry.getTotalPaginationBuckets()); - assertEquals("Expected the pagination index to be 1", 1, traversalHttpEntry.getPaginationIndex()); - assertEquals("Expected the total amount of vertices to be 101", 101, traversalHttpEntry.getTotalVertices()); - } - - @Test public void setDepthTest() throws AAIException { System.setProperty("AJSC_HOME", "."); System.setProperty("BUNDLECONFIG_DIR", "src/main/test/resources"); diff --git a/aai-els-onap-logging/src/main/java/org/onap/logging/filter/base/MDCSetup.java b/aai-els-onap-logging/src/main/java/org/onap/logging/filter/base/MDCSetup.java index 9b2503b7..1b48eb9b 100644 --- a/aai-els-onap-logging/src/main/java/org/onap/logging/filter/base/MDCSetup.java +++ b/aai-els-onap-logging/src/main/java/org/onap/logging/filter/base/MDCSetup.java @@ -7,9 +7,9 @@ * 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. @@ -168,13 +168,17 @@ public class MDCSetup { } public void setElapsedTime() { - DateTimeFormatter timeFormatter = DateTimeFormatter.ISO_ZONED_DATE_TIME; - ZonedDateTime entryTimestamp = - ZonedDateTime.parse(MDC.get(ONAPLogConstants.MDCs.ENTRY_TIMESTAMP), timeFormatter); - ZonedDateTime endTimestamp = ZonedDateTime.parse(MDC.get(ONAPLogConstants.MDCs.LOG_TIMESTAMP), timeFormatter); - - MDC.put(ONAPLogConstants.MDCs.ELAPSED_TIME, - Long.toString(ChronoUnit.MILLIS.between(entryTimestamp, endTimestamp))); + String entryTimestampString = MDC.get(ONAPLogConstants.MDCs.ENTRY_TIMESTAMP); + String elapsedTime = "elapsedTimeIsNotAvailable"; + if(entryTimestampString != null) { + DateTimeFormatter timeFormatter = DateTimeFormatter.ISO_ZONED_DATE_TIME; + ZonedDateTime entryTimestamp = + ZonedDateTime.parse(entryTimestampString, timeFormatter); + String logTimestamp = MDC.get(ONAPLogConstants.MDCs.LOG_TIMESTAMP); + ZonedDateTime endTimestamp = ZonedDateTime.parse(logTimestamp, timeFormatter); + elapsedTime = Long.toString(ChronoUnit.MILLIS.between(entryTimestamp, endTimestamp)); + } + MDC.put(ONAPLogConstants.MDCs.ELAPSED_TIME, elapsedTime); } public void setElapsedTimeInvokeTimestamp() { diff --git a/aai-parent/pom.xml b/aai-parent/pom.xml index 84b79a4a..e86f1012 100644 --- a/aai-parent/pom.xml +++ b/aai-parent/pom.xml @@ -62,8 +62,8 @@ limitations under the License. <eelf.core.version>2.0.0-oss</eelf.core.version> <freemarker.version>2.3.31</freemarker.version> <google.guava.version>31.1-jre</google.guava.version> - <gremlin.version>3.4.0</gremlin.version> - <janusgraph.version>0.4.0</janusgraph.version> + <gremlin.version>3.4.13</gremlin.version> + <janusgraph.version>0.5.0</janusgraph.version> <groovy.version>2.5.15</groovy.version> <gson.version>2.9.1</gson.version> <hamcrest.junit.version>2.0.0.0</hamcrest.junit.version> @@ -315,7 +315,7 @@ limitations under the License. <dependency> <groupId>org.janusgraph</groupId> - <artifactId>janusgraph-cassandra</artifactId> + <artifactId>janusgraph-cql</artifactId> <version>${janusgraph.version}</version> </dependency> @@ -330,7 +330,7 @@ limitations under the License. <dependency> <groupId>org.janusgraph</groupId> - <artifactId>janusgraph-cql</artifactId> + <artifactId>janusgraph-inmemory</artifactId> <version>${janusgraph.version}</version> </dependency> diff --git a/aai-rest/pom.xml b/aai-rest/pom.xml index a9dddc51..f4ed8dbd 100644 --- a/aai-rest/pom.xml +++ b/aai-rest/pom.xml @@ -37,8 +37,6 @@ <properties> <onap.nexus.url>https://nexus.onap.org</onap.nexus.url> - <spring.boot.starter.web.version>1.5.21.RELEASE</spring.boot.starter.web.version> - <spring.boot.starter.parent.version>1.5.21.RELEASE</spring.boot.starter.parent.version> <spring.security.version>1.0.8.RELEASE</spring.security.version> </properties> diff --git a/aai-schema-ingest/.classpath b/aai-schema-ingest/.classpath deleted file mode 100644 index 5811926a..00000000 --- a/aai-schema-ingest/.classpath +++ /dev/null @@ -1,57 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<classpath> - <classpathentry kind="src" output="target/classes" path="src/main/java"> - <attributes> - <attribute name="optional" value="true"/> - <attribute name="maven.pomderived" value="true"/> - </attributes> - </classpathentry> - <classpathentry kind="src" output="target/test-classes" path="src/test/java"> - <attributes> - <attribute name="optional" value="true"/> - <attribute name="maven.pomderived" value="true"/> - <attribute name="test" value="true"/> - </attributes> - </classpathentry> - <classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources"> - <attributes> - <attribute name="maven.pomderived" value="true"/> - <attribute name="test" value="true"/> - <attribute name="optional" value="true"/> - </attributes> - </classpathentry> - <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"> - <attributes> - <attribute name="maven.pomderived" value="true"/> - </attributes> - </classpathentry> - <classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER"> - <attributes> - <attribute name="maven.pomderived" value="true"/> - </attributes> - </classpathentry> - <classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources"> - <attributes> - <attribute name="maven.pomderived" value="true"/> - <attribute name="optional" value="true"/> - </attributes> - </classpathentry> - <classpathentry kind="src" path="target/generated-sources/annotations"> - <attributes> - <attribute name="optional" value="true"/> - <attribute name="maven.pomderived" value="true"/> - <attribute name="ignore_optional_problems" value="true"/> - <attribute name="m2e-apt" value="true"/> - </attributes> - </classpathentry> - <classpathentry kind="src" output="target/test-classes" path="target/generated-test-sources/test-annotations"> - <attributes> - <attribute name="optional" value="true"/> - <attribute name="maven.pomderived" value="true"/> - <attribute name="ignore_optional_problems" value="true"/> - <attribute name="m2e-apt" value="true"/> - <attribute name="test" value="true"/> - </attributes> - </classpathentry> - <classpathentry kind="output" path="target/classes"/> -</classpath> diff --git a/aai-schema-ingest/pom.xml b/aai-schema-ingest/pom.xml index 4ee8226e..817e9f51 100644 --- a/aai-schema-ingest/pom.xml +++ b/aai-schema-ingest/pom.xml @@ -127,6 +127,7 @@ limitations under the License. <dependency> <groupId>org.springframework</groupId> <artifactId>spring-test</artifactId> + <scope>test</scope> </dependency> <dependency> <groupId>org.springframework.boot</groupId> |