aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChenfei Gao <cgao@research.att.com>2019-01-31 16:09:09 -0500
committerChenfei Gao <cgao@research.att.com>2019-02-07 09:19:38 -0500
commit6ea2e1bb9f7ee330f04fe8e28fd94fbf398a06ec (patch)
tree9c2f3845f222a31b080929763446ef1cb20858bd
parentf437d629aac23467dc505d081bbe1634a5ef63b8 (diff)
Add changes to basic structure of api component
Includes: 1) Changed logging from FlexLogger to slf4j and used the logback.xml aligned with v1.2 logging requirements. 2) Added https as a configurable parameter of api rest server. 3) Added aaf as a condfigurable parameter of api rest server. 4) Added AafFilter classes for healthcheck and statistics. 5) Added api statistics REST entry point. 6) Created related junit tests. 7) Packaged docker Issue-ID: POLICY-1270 Change-Id: I638f61361bb052545e8597531ba3d58019bf1f24 Signed-off-by: Chenfei Gao <cgao@research.att.com>
-rw-r--r--LICENSE.txt2
-rw-r--r--main/pom.xml14
-rw-r--r--main/src/main/java/org/onap/policy/api/main/exception/PolicyApiException.java (renamed from main/src/main/java/org/onap/policy/api/main/PolicyApiException.java)2
-rw-r--r--main/src/main/java/org/onap/policy/api/main/exception/PolicyApiRuntimeException.java (renamed from main/src/main/java/org/onap/policy/api/main/PolicyApiRuntimeException.java)2
-rw-r--r--main/src/main/java/org/onap/policy/api/main/parameters/ApiParameterHandler.java15
-rw-r--r--main/src/main/java/org/onap/policy/api/main/parameters/RestServerParameters.java48
-rw-r--r--main/src/main/java/org/onap/policy/api/main/rest/ApiRestController.java22
-rw-r--r--main/src/main/java/org/onap/policy/api/main/rest/ApiRestServer.java24
-rw-r--r--main/src/main/java/org/onap/policy/api/main/rest/ApiStatisticsManager.java340
-rw-r--r--main/src/main/java/org/onap/policy/api/main/rest/HealthCheckProvider.java5
-rw-r--r--main/src/main/java/org/onap/policy/api/main/rest/StatisticsProvider.java59
-rw-r--r--main/src/main/java/org/onap/policy/api/main/rest/StatisticsReport.java376
-rw-r--r--main/src/main/java/org/onap/policy/api/main/rest/aaf/AafApiFilter.java39
-rw-r--r--main/src/main/java/org/onap/policy/api/main/startstop/ApiActivator.java19
-rw-r--r--main/src/main/java/org/onap/policy/api/main/startstop/ApiCommandLineArguments.java5
-rw-r--r--main/src/main/java/org/onap/policy/api/main/startstop/Main.java19
-rw-r--r--main/src/test/java/org/onap/policy/api/main/parameters/CommonTestData.java15
-rw-r--r--main/src/test/java/org/onap/policy/api/main/parameters/TestApiParameterGroup.java7
-rw-r--r--main/src/test/java/org/onap/policy/api/main/parameters/TestApiParameterHandler.java51
-rw-r--r--main/src/test/java/org/onap/policy/api/main/rest/TestApiRestServer.java57
-rw-r--r--main/src/test/java/org/onap/policy/api/main/rest/TestApiStatistics.java152
-rw-r--r--main/src/test/java/org/onap/policy/api/main/rest/TestHttpsApiRestServer.java135
-rw-r--r--main/src/test/java/org/onap/policy/api/main/rest/TestHttpsStatisticApiRestServer.java151
-rw-r--r--main/src/test/java/org/onap/policy/api/main/rest/TestStatisticsReport.java47
-rw-r--r--main/src/test/java/org/onap/policy/api/main/startstop/TestApiActivator.java12
-rw-r--r--main/src/test/java/org/onap/policy/api/main/startstop/TestMain.java18
-rw-r--r--main/src/test/resources/parameters/ApiConfigParameters_Https.json10
-rw-r--r--main/src/test/resources/ssl/policy-keystorebin0 -> 4311 bytes
-rw-r--r--packages/policy-api-docker/pom.xml176
-rw-r--r--packages/policy-api-docker/src/main/docker/Dockerfile46
-rw-r--r--packages/policy-api-docker/src/main/docker/policy-api.sh43
-rw-r--r--packages/policy-api-tarball/pom.xml65
-rw-r--r--packages/policy-api-tarball/src/main/package/tarball/assembly.xml62
-rw-r--r--packages/policy-api-tarball/src/main/resources/etc/defaultConfig.json11
-rw-r--r--packages/policy-api-tarball/src/main/resources/etc/logback.xml166
-rw-r--r--packages/policy-api-tarball/src/main/resources/etc/s3pConfig.json11
-rw-r--r--packages/policy-api-tarball/src/main/resources/etc/ssl/policy-keystorebin0 -> 4311 bytes
-rw-r--r--packages/policy-api-tarball/src/main/resources/etc/ssl/policy-truststorebin0 -> 124180 bytes
-rw-r--r--packages/pom.xml52
-rw-r--r--pom.xml27
40 files changed, 2148 insertions, 157 deletions
diff --git a/LICENSE.txt b/LICENSE.txt
index 6ec4ee51..469b7cbc 100644
--- a/LICENSE.txt
+++ b/LICENSE.txt
@@ -1,4 +1,4 @@
-Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
+Copyright � 2017-2019 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.
diff --git a/main/pom.xml b/main/pom.xml
index c0a75907..13839887 100644
--- a/main/pom.xml
+++ b/main/pom.xml
@@ -2,6 +2,7 @@
============LICENSE_START=======================================================
Copyright (C) 2018 Ericsson. All rights reserved.
Modified Copyright (C) 2018 Samsung Electronics Co., Ltd.
+ Copyright (C) 2019 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.
@@ -18,7 +19,8 @@
SPDX-License-Identifier: Apache-2.0
============LICENSE_END=========================================================
-->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
@@ -39,11 +41,6 @@
<version>${policy.common.version}</version>
</dependency>
<dependency>
- <groupId>org.onap.policy.common</groupId>
- <artifactId>policy-endpoints</artifactId>
- <version>${policy.common.version}</version>
- </dependency>
- <dependency>
<groupId>commons-cli</groupId>
<artifactId>commons-cli</artifactId>
</dependency>
@@ -56,11 +53,6 @@
<artifactId>common-parameters</artifactId>
<version>${policy.common.version}</version>
</dependency>
- <dependency>
- <groupId>org.onap.policy.common</groupId>
- <artifactId>ONAP-Logging</artifactId>
- <version>${policy.common.version}</version>
- </dependency>
</dependencies>
<build>
diff --git a/main/src/main/java/org/onap/policy/api/main/PolicyApiException.java b/main/src/main/java/org/onap/policy/api/main/exception/PolicyApiException.java
index 8dedc8ad..1fccb06d 100644
--- a/main/src/main/java/org/onap/policy/api/main/PolicyApiException.java
+++ b/main/src/main/java/org/onap/policy/api/main/exception/PolicyApiException.java
@@ -18,7 +18,7 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.policy.api.main;
+package org.onap.policy.api.main.exception;
/**
* This exception will be called if an error occurs in policy api external service.
diff --git a/main/src/main/java/org/onap/policy/api/main/PolicyApiRuntimeException.java b/main/src/main/java/org/onap/policy/api/main/exception/PolicyApiRuntimeException.java
index a9ec07db..ea6b55f6 100644
--- a/main/src/main/java/org/onap/policy/api/main/PolicyApiRuntimeException.java
+++ b/main/src/main/java/org/onap/policy/api/main/exception/PolicyApiRuntimeException.java
@@ -18,7 +18,7 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.policy.api.main;
+package org.onap.policy.api.main.exception;
/**
* This runtime exception will be called if a runtime error occurs when using policy api.
diff --git a/main/src/main/java/org/onap/policy/api/main/parameters/ApiParameterHandler.java b/main/src/main/java/org/onap/policy/api/main/parameters/ApiParameterHandler.java
index 92923d0d..b660b883 100644
--- a/main/src/main/java/org/onap/policy/api/main/parameters/ApiParameterHandler.java
+++ b/main/src/main/java/org/onap/policy/api/main/parameters/ApiParameterHandler.java
@@ -1,6 +1,9 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2018 Samsung Electronics Co., Ltd. All rights reserved.
+ * ONAP Policy API
+ * ================================================================================
+ * Copyright (C) 2018 Samsung Electronics Co., Ltd. All rights reserved.
+ * Copyright (C) 2019 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.
@@ -23,18 +26,19 @@ package org.onap.policy.api.main.parameters;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import java.io.FileReader;
-import org.onap.policy.api.main.PolicyApiException;
+import org.onap.policy.api.main.exception.PolicyApiException;
import org.onap.policy.api.main.startstop.ApiCommandLineArguments;
-import org.onap.policy.common.logging.flexlogger.FlexLogger;
-import org.onap.policy.common.logging.flexlogger.Logger;
import org.onap.policy.common.parameters.GroupValidationResult;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* This class handles reading, parsing and validating of policy api parameters from JSON files.
*/
public class ApiParameterHandler {
- private static final Logger LOGGER = FlexLogger.getLogger(ApiParameterHandler.class);
+ private static final Logger LOGGER = LoggerFactory.getLogger(ApiParameterHandler.class);
+
/**
* Read the parameters from the parameter file.
*
@@ -55,7 +59,6 @@ public class ApiParameterHandler {
} catch (final Exception e) {
final String errorMessage = "error reading parameters from \"" + arguments.getConfigurationFilePath()
+ "\"\n" + "(" + e.getClass().getSimpleName() + "):" + e.getMessage();
- LOGGER.error(errorMessage, e);
throw new PolicyApiException(errorMessage, e);
}
diff --git a/main/src/main/java/org/onap/policy/api/main/parameters/RestServerParameters.java b/main/src/main/java/org/onap/policy/api/main/parameters/RestServerParameters.java
index 33ecff37..0a9894ea 100644
--- a/main/src/main/java/org/onap/policy/api/main/parameters/RestServerParameters.java
+++ b/main/src/main/java/org/onap/policy/api/main/parameters/RestServerParameters.java
@@ -1,6 +1,9 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2018 Samsung Electronics Co., Ltd. All rights reserved.
+ * ONAP Policy API
+ * ================================================================================
+ * Copyright (C) 2018 Samsung Electronics Co., Ltd. All rights reserved.
+ * Copyright (C) 2019 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.
@@ -35,7 +38,9 @@ public class RestServerParameters implements ParameterGroup {
private int port;
private String userName;
private String password;
-
+ private boolean https;
+ private boolean aaf;
+
/**
* Constructor for instantiating RestServerParameters.
*
@@ -50,6 +55,29 @@ public class RestServerParameters implements ParameterGroup {
this.port = port;
this.userName = userName;
this.password = password;
+ this.https = false;
+ this.aaf = false;
+ }
+
+ /**
+ * Constructor for instantiating RestServerParameters.
+ *
+ * @param host the host name
+ * @param port the port
+ * @param userName the user name
+ * @param password the password
+ * @param https the https
+ * @param aaf the aaf
+ */
+ public RestServerParameters(final String host, final int port, final String userName, final String password,
+ final boolean https, final boolean aaf) {
+ super();
+ this.host = host;
+ this.port = port;
+ this.userName = userName;
+ this.password = password;
+ this.https = https;
+ this.aaf = aaf;
}
/**
@@ -97,6 +125,22 @@ public class RestServerParameters implements ParameterGroup {
public String getPassword() {
return password;
}
+
+ /**
+ * Return the https flag of this RestServerParameters instance.
+ * @return the https
+ */
+ public boolean isHttps() {
+ return https;
+ }
+
+ /**
+ * Return the aaf flag of this RestServerParameters instance.
+ * @return the aaf
+ */
+ public boolean isAaf() {
+ return aaf;
+ }
/**
* Set the name of this RestServerParameters instance.
diff --git a/main/src/main/java/org/onap/policy/api/main/rest/ApiRestController.java b/main/src/main/java/org/onap/policy/api/main/rest/ApiRestController.java
index 9b4d75df..ca211b67 100644
--- a/main/src/main/java/org/onap/policy/api/main/rest/ApiRestController.java
+++ b/main/src/main/java/org/onap/policy/api/main/rest/ApiRestController.java
@@ -1,6 +1,9 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2018 Samsung Electronics Co., Ltd. All rights reserved.
+ * ONAP Policy API
+ * ================================================================================
+ * Copyright (C) 2018 Samsung Electronics Co., Ltd. All rights reserved.
+ * Copyright (C) 2019 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.
@@ -33,16 +36,15 @@ import javax.ws.rs.core.Response;
import org.onap.policy.common.endpoints.report.HealthCheckReport;
/**
- * Class to provide api REST services.
- *
+ * Class to provide REST API services.
*/
@Path("/")
@Api
@Produces(MediaType.APPLICATION_JSON)
@SwaggerDefinition(
- info = @Info(description = "Policy Api Service", version = "v1.0", title = "Policy Api"),
+ info = @Info(description = "Policy Api Service", version = "v2.0", title = "Policy Api"),
consumes = { MediaType.APPLICATION_JSON }, produces = { MediaType.APPLICATION_JSON },
- schemes = { SwaggerDefinition.Scheme.HTTP },
+ schemes = { SwaggerDefinition.Scheme.HTTP, SwaggerDefinition.Scheme.HTTPS },
tags = { @Tag(name = "policy-api", description = "Policy Api Service Operations") })
public class ApiRestController {
@@ -54,4 +56,14 @@ public class ApiRestController {
public Response healthcheck() {
return Response.status(Response.Status.OK).entity(new HealthCheckProvider().performHealthCheck()).build();
}
+
+ @GET
+ @Path("statistics")
+ @Produces(MediaType.APPLICATION_JSON)
+ @ApiOperation(value = "Fetch current statistics",
+ notes = "Provides current statistics of the Policy API component",
+ response = StatisticsReport.class)
+ public Response statistics() {
+ return Response.status(Response.Status.OK).entity(new StatisticsProvider().fetchCurrentStatistics()).build();
+ }
}
diff --git a/main/src/main/java/org/onap/policy/api/main/rest/ApiRestServer.java b/main/src/main/java/org/onap/policy/api/main/rest/ApiRestServer.java
index b6d69602..cf27bacb 100644
--- a/main/src/main/java/org/onap/policy/api/main/rest/ApiRestServer.java
+++ b/main/src/main/java/org/onap/policy/api/main/rest/ApiRestServer.java
@@ -1,6 +1,9 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2018 Samsung Electronics Co., Ltd. All rights reserved.
+ * ONAP Policy API
+ * ================================================================================
+ * Copyright (C) 2018 Samsung Electronics Co., Ltd. All rights reserved.
+ * Copyright (C) 2019 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.
@@ -24,10 +27,11 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Properties;
import org.onap.policy.api.main.parameters.RestServerParameters;
+import org.onap.policy.api.main.rest.aaf.AafApiFilter;
import org.onap.policy.common.capabilities.Startable;
import org.onap.policy.common.endpoints.http.server.HttpServletServer;
-import org.onap.policy.common.logging.flexlogger.FlexLogger;
-import org.onap.policy.common.logging.flexlogger.Logger;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* Class to manage life cycle of api rest server.
@@ -37,7 +41,8 @@ public class ApiRestServer implements Startable {
private static final String SEPARATOR = ".";
private static final String HTTP_SERVER_SERVICES = "http.server.services";
- private static final Logger LOGGER = FlexLogger.getLogger(ApiRestServer.class);
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(ApiRestServer.class);
private List<HttpServletServer> servers = new ArrayList<>();
@@ -59,7 +64,10 @@ public class ApiRestServer implements Startable {
public boolean start() {
try {
servers = HttpServletServer.factory.build(getServerProperties());
- for (final HttpServletServer server : servers) {
+ for (HttpServletServer server : servers) {
+ if (server.isAaf()) {
+ server.addFilterClass(null, AafApiFilter.class.getCanonicalName());
+ }
server.start();
}
} catch (final Exception exp) {
@@ -68,7 +76,7 @@ public class ApiRestServer implements Startable {
}
return true;
}
-
+
/**
* Creates the server properties object using restServerParameters.
*
@@ -89,6 +97,10 @@ public class ApiRestServer implements Startable {
restServerParameters.getUserName());
props.setProperty(HTTP_SERVER_SERVICES + SEPARATOR + restServerParameters.getName() + ".password",
restServerParameters.getPassword());
+ props.setProperty(HTTP_SERVER_SERVICES + SEPARATOR + restServerParameters.getName() + ".https",
+ String.valueOf(restServerParameters.isHttps()));
+ props.setProperty(HTTP_SERVER_SERVICES + SEPARATOR + restServerParameters.getName() + ".aaf",
+ String.valueOf(restServerParameters.isAaf()));
return props;
}
diff --git a/main/src/main/java/org/onap/policy/api/main/rest/ApiStatisticsManager.java b/main/src/main/java/org/onap/policy/api/main/rest/ApiStatisticsManager.java
new file mode 100644
index 00000000..55c8cee1
--- /dev/null
+++ b/main/src/main/java/org/onap/policy/api/main/rest/ApiStatisticsManager.java
@@ -0,0 +1,340 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP Policy API
+ * ================================================================================
+ * Copyright (C) 2019 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.api.main.rest;
+
+/**
+ * Class to hold statistical data for API access.
+ */
+public class ApiStatisticsManager {
+
+ private static long totalApiCallCount;
+ private static long apiCallSuccessCount;
+ private static long apiCallFailureCount;
+ private static long totalPolicyGetCount;
+ private static long totalPolicyPostCount;
+ private static long totalTemplateGetCount;
+ private static long totalTemplatePostCount;
+ private static long policyGetSuccessCount;
+ private static long policyGetFailureCount;
+ private static long policyPostSuccessCount;
+ private static long policyPostFailureCount;
+ private static long templateGetSuccessCount;
+ private static long templateGetFailureCount;
+ private static long templatePostSuccessCount;
+ private static long templatePostFailureCount;
+
+ private ApiStatisticsManager() {
+ throw new IllegalStateException("Instantiation of the class is not allowed");
+ }
+
+ /**
+ * Method to update the total api call count.
+ *
+ * @return the updated value of totalApiCallCount
+ */
+ public static long updateTotalApiCallCount() {
+ return ++totalApiCallCount;
+ }
+
+ /**
+ * Method to update the successful api call count.
+ *
+ * @return the updated value of apiCallSuccessCount
+ */
+ public static long updateApiCallSuccessCount() {
+ return ++apiCallSuccessCount;
+ }
+
+ /**
+ * Method to update the failed api call count.
+ *
+ * @return the updated value of apiCallFailureCount
+ */
+ public static long updateApiCallFailureCount() {
+ return ++apiCallFailureCount;
+ }
+
+ /**
+ * Method to update the total policy GET count.
+ *
+ * @return the updated value of totalPolicyGetCount
+ */
+ public static long updateTotalPolicyGetCount() {
+ return ++totalPolicyGetCount;
+ }
+
+ /**
+ * Method to update the total policy POST count.
+ *
+ * @return the updated value of totalPolicyPostCount
+ */
+ public static long updateTotalPolicyPostCount() {
+ return ++totalPolicyPostCount;
+ }
+
+ /**
+ * Method to update the total template GET count.
+ *
+ * @return the updated value of totalTemplateGetCount
+ */
+ public static long updateTotalTemplateGetCount() {
+ return ++totalTemplateGetCount;
+ }
+
+ /**
+ * Method to update the total template POST count.
+ *
+ * @return the updated value of totalTemplatePostCount
+ */
+ public static long updateTotalTemplatePostCount() {
+ return ++totalTemplatePostCount;
+ }
+
+ /**
+ * Method to update successful policy GET count.
+ *
+ * @return the updated value of policyGetSuccessCount
+ */
+ public static long updatePolicyGetSuccessCount() {
+ return ++policyGetSuccessCount;
+ }
+
+ /**
+ * Method to update failed policy GET count.
+ *
+ * @return the updated value of policyGetFailureCount
+ */
+ public static long updatePolicyGetFailureCount() {
+ return ++policyGetFailureCount;
+ }
+
+ /**
+ * Method to update successful policy POST count.
+ *
+ * @return the updated value of policyPostSuccessCount
+ */
+ public static long updatePolicyPostSuccessCount() {
+ return ++policyPostSuccessCount;
+ }
+
+ /**
+ * Method to update failed policy POST count.
+ *
+ * @return the updated value of policyPostFailureCount
+ */
+ public static long updatePolicyPostFailureCount() {
+ return ++policyPostFailureCount;
+ }
+
+ /**
+ * Method to update successful template GET count.
+ *
+ * @return the updated value of templateGetSuccessCount
+ */
+ public static long updateTemplateGetSuccessCount() {
+ return ++templateGetSuccessCount;
+ }
+
+ /**
+ * Method to update failed template GET count.
+ *
+ * @return the updated value of templateGetFailureCount
+ */
+ public static long updateTemplateGetFailureCount() {
+ return ++templateGetFailureCount;
+ }
+
+ /**
+ * Method to update successful template POST count.
+ *
+ * @return the updated value of templatePostSuccessCount
+ */
+ public static long updateTemplatePostSuccessCount() {
+ return ++templatePostSuccessCount;
+ }
+
+ /**
+ * Method to update failed template POST count.
+ *
+ * @return the updated value of templatePostFailureCount
+ */
+ public static long updateTemplatePostFailureCount() {
+ return ++templatePostFailureCount;
+ }
+
+ /**
+ * Returns the current value of totalApiCallCount.
+ *
+ * @return the totalApiCallCount
+ */
+ public static long getTotalApiCallCount() {
+ return totalApiCallCount;
+ }
+
+ /**
+ * Returns the current value of apiCallSuccessCount.
+ *
+ * @return the apiCallSuccessCount
+ */
+ public static long getApiCallSuccessCount() {
+ return apiCallSuccessCount;
+ }
+
+ /**
+ * Returns the current value of apiCallFailureCount.
+ *
+ * @return the apiCallFailureCount
+ */
+ public static long getApiCallFailureCount() {
+ return apiCallFailureCount;
+ }
+
+ /**
+ * Returns the current value of totalPolicyGetCount.
+ *
+ * @return the totalPolicyGetCount
+ */
+ public static long getTotalPolicyGetCount() {
+ return totalPolicyGetCount;
+ }
+
+ /**
+ * Returns the current value of totalPolicyPostCount.
+ *
+ * @return the totalPolicyPostCount
+ */
+ public static long getTotalPolicyPostCount() {
+ return totalPolicyPostCount;
+ }
+
+ /**
+ * Returns the current value of totalTemplateGetCount.
+ *
+ * @return the totalTemplateGetCount
+ */
+ public static long getTotalTemplateGetCount() {
+ return totalTemplateGetCount;
+ }
+
+ /**
+ * Returns the current value of totalTemplatePostCount.
+ *
+ * @return the totalTemplatePostCount
+ */
+ public static long getTotalTemplatePostCount() {
+ return totalTemplatePostCount;
+ }
+
+ /**
+ * Returns the current value of policyGetSuccessCount.
+ *
+ * @return the policyGetSuccessCount
+ */
+ public static long getPolicyGetSuccessCount() {
+ return policyGetSuccessCount;
+ }
+
+ /**
+ * Returns the current value of policyGetFailureCount.
+ *
+ * @return the policyGetFailureCount
+ */
+ public static long getPolicyGetFailureCount() {
+ return policyGetFailureCount;
+ }
+
+ /**
+ * Returns the current value of policyPostSuccessCount.
+ *
+ * @return the policyPostSuccessCount
+ */
+ public static long getPolicyPostSuccessCount() {
+ return policyPostSuccessCount;
+ }
+
+ /**
+ * Returns the current value of policyPostFailureCount.
+ *
+ * @return the policyPostFailureCount
+ */
+ public static long getPolicyPostFailureCount() {
+ return policyPostFailureCount;
+ }
+
+ /**
+ * Returns the current value of templateGetSuccessCount.
+ *
+ * @return the templateGetSuccessCount
+ */
+ public static long getTemplateGetSuccessCount() {
+ return templateGetSuccessCount;
+ }
+
+ /**
+ * Returns the current value of templateGetFailureCount.
+ *
+ * @return the templateGetFailureCount
+ */
+ public static long getTemplateGetFailureCount() {
+ return templateGetFailureCount;
+ }
+
+ /**
+ * Returns the current value of templatePostSuccessCount.
+ *
+ * @return the templatePostSuccessCount
+ */
+ public static long getTemplatePostSuccessCount() {
+ return templatePostSuccessCount;
+ }
+
+ /**
+ * Returns the current value of templatePostFailureCount.
+ *
+ * @return the templatePostFailureCount
+ */
+ public static long getTemplatePostFailureCount() {
+ return templatePostFailureCount;
+ }
+
+ /**
+ * Reset all the statistics counts to 0.
+ */
+ public static void resetAllStatistics() {
+ totalApiCallCount = 0L;
+ apiCallSuccessCount = 0L;
+ apiCallFailureCount = 0L;
+ totalPolicyGetCount = 0L;
+ totalPolicyPostCount = 0L;
+ totalTemplateGetCount = 0L;
+ totalTemplatePostCount = 0L;
+ policyGetSuccessCount = 0L;
+ policyGetFailureCount = 0L;
+ policyPostSuccessCount = 0L;
+ policyPostFailureCount = 0L;
+ templateGetSuccessCount = 0L;
+ templateGetFailureCount = 0L;
+ templatePostSuccessCount = 0L;
+ templatePostFailureCount = 0L;
+ }
+}
diff --git a/main/src/main/java/org/onap/policy/api/main/rest/HealthCheckProvider.java b/main/src/main/java/org/onap/policy/api/main/rest/HealthCheckProvider.java
index dd223384..48387336 100644
--- a/main/src/main/java/org/onap/policy/api/main/rest/HealthCheckProvider.java
+++ b/main/src/main/java/org/onap/policy/api/main/rest/HealthCheckProvider.java
@@ -1,6 +1,9 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2018 Samsung Electronics Co., Ltd. All rights reserved.
+ * ONAP Policy API
+ * ================================================================================
+ * Copyright (C) 2018 Samsung Electronics Co., Ltd. All rights reserved.
+ * Copyright (C) 2019 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.
diff --git a/main/src/main/java/org/onap/policy/api/main/rest/StatisticsProvider.java b/main/src/main/java/org/onap/policy/api/main/rest/StatisticsProvider.java
new file mode 100644
index 00000000..e8f18404
--- /dev/null
+++ b/main/src/main/java/org/onap/policy/api/main/rest/StatisticsProvider.java
@@ -0,0 +1,59 @@
+/*-
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP Policy API
+ * ================================================================================
+ * Copyright (C) 2019 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.api.main.rest;
+
+import org.onap.policy.api.main.startstop.ApiActivator;
+
+/**
+ * Class to fetch API statistics.
+ */
+public class StatisticsProvider {
+
+ /**
+ * Return the current API statistics.
+ *
+ * @return Report containing API statistics
+ */
+ public StatisticsReport fetchCurrentStatistics() {
+ final StatisticsReport report = new StatisticsReport();
+ report.setCode(ApiActivator.isAlive() ? 200 : 500);
+ report.setTotalApiCallCount(ApiStatisticsManager.getTotalApiCallCount());
+ report.setApiCallSuccessCount(ApiStatisticsManager.getApiCallSuccessCount());
+ report.setApiCallFailureCount(ApiStatisticsManager.getApiCallFailureCount());
+ report.setTotalPolicyGetCount(ApiStatisticsManager.getTotalPolicyGetCount());
+ report.setTotalPolicyPostCount(ApiStatisticsManager.getTotalPolicyPostCount());
+ report.setTotalTemplateGetCount(ApiStatisticsManager.getTotalTemplateGetCount());
+ report.setTotalTemplatePostCount(ApiStatisticsManager.getTotalTemplatePostCount());
+ report.setPolicyGetSuccessCount(ApiStatisticsManager.getPolicyGetSuccessCount());
+ report.setPolicyGetFailureCount(ApiStatisticsManager.getPolicyGetFailureCount());
+ report.setPolicyPostSuccessCount(ApiStatisticsManager.getPolicyPostSuccessCount());
+ report.setPolicyPostFailureCount(ApiStatisticsManager.getPolicyPostFailureCount());
+ report.setTemplateGetSuccessCount(ApiStatisticsManager.getTemplateGetSuccessCount());
+ report.setTemplateGetFailureCount(ApiStatisticsManager.getTemplateGetFailureCount());
+ report.setTemplatePostSuccessCount(ApiStatisticsManager.getTemplatePostSuccessCount());
+ report.setTemplatePostFailureCount(ApiStatisticsManager.getTemplatePostFailureCount());
+ return report;
+ }
+}
+
diff --git a/main/src/main/java/org/onap/policy/api/main/rest/StatisticsReport.java b/main/src/main/java/org/onap/policy/api/main/rest/StatisticsReport.java
new file mode 100644
index 00000000..03bc9590
--- /dev/null
+++ b/main/src/main/java/org/onap/policy/api/main/rest/StatisticsReport.java
@@ -0,0 +1,376 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP Policy API
+ * ================================================================================
+ * Copyright (C) 2019 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.api.main.rest;
+
+/**
+ * Class to represent API statistics report.
+ */
+public class StatisticsReport {
+
+ private int code;
+ private long totalApiCallCount;
+ private long apiCallSuccessCount;
+ private long apiCallFailureCount;
+ private long totalPolicyGetCount;
+ private long totalPolicyPostCount;
+ private long totalTemplateGetCount;
+ private long totalTemplatePostCount;
+ private long policyGetSuccessCount;
+ private long policyGetFailureCount;
+ private long policyPostSuccessCount;
+ private long policyPostFailureCount;
+ private long templateGetSuccessCount;
+ private long templateGetFailureCount;
+ private long templatePostSuccessCount;
+ private long templatePostFailureCount;
+
+ /**
+ * Returns the code of this {@link StatisticsReport} instance.
+ *
+ * @return the code
+ */
+ public int getCode() {
+ return code;
+ }
+
+ /**
+ * Set code in this {@link StatisticsReport} instance.
+ *
+ * @param code the code to set
+ */
+ public void setCode(final int code) {
+ this.code = code;
+ }
+
+ /**
+ * Returns the totalApiCallCount of this {@link StatisticsReport} instance.
+ *
+ * @return the totalApiCallCount
+ */
+ public long getTotalApiCallCount() {
+ return totalApiCallCount;
+ }
+
+ /**
+ * Set totalApiCallCount in this {@link StatisticsReport} instance.
+ *
+ * @param totalApiCallCount the totalApiCallCount to set
+ */
+ public void setTotalApiCallCount(final long totalApiCallCount) {
+ this.totalApiCallCount = totalApiCallCount;
+ }
+
+ /**
+ * Returns the apiCallSuccessCount of this {@link StatisticsReport} instance.
+ *
+ * @return the apiCallSuccessCount
+ */
+ public long getApiCallSuccessCount() {
+ return apiCallSuccessCount;
+ }
+
+ /**
+ * Set apiCallSuccessCount in this {@link StatisticsReport} instance.
+ *
+ * @param apiCallSuccessCount the apiCallSuccessCount to set
+ */
+ public void setApiCallSuccessCount(final long apiCallSuccessCount) {
+ this.apiCallSuccessCount = apiCallSuccessCount;
+ }
+
+ /**
+ * Returns the apiCallFailureCount of this {@link StatisticsReport} instance.
+ *
+ * @return the apiCallFailureCount
+ */
+ public long getApiCallFailureCount() {
+ return apiCallFailureCount;
+ }
+
+ /**
+ * Set apiCallFailureCount in this {@link StatisticsReport} instance.
+ *
+ * @param apiCallFailureCount the apiCallFailureCount to set
+ */
+ public void setApiCallFailureCount(final long apiCallFailureCount) {
+ this.apiCallFailureCount = apiCallFailureCount;
+ }
+
+ /**
+ * Returns the totalPolicyGetCount of this {@link StatisticsReport} instance.
+ *
+ * @return the totalPolicyGetCount
+ */
+ public long getTotalPolicyGetCount() {
+ return totalPolicyGetCount;
+ }
+
+ /**
+ * Set totalPolicyGetCount in this {@link StatisticsReport} instance.
+ *
+ * @param totalPolicyGetCount the totalPolicyGetCount to set
+ */
+ public void setTotalPolicyGetCount(final long totalPolicyGetCount) {
+ this.totalPolicyGetCount = totalPolicyGetCount;
+ }
+
+ /**
+ * Returns the totalPolicyPostCount of this {@link StatisticsReport} instance.
+ *
+ * @return the totalPolicyPostCount
+ */
+ public long getTotalPolicyPostCount() {
+ return totalPolicyPostCount;
+ }
+
+ /**
+ * Set totalPolicyPostCount in this {@link StatisticsReport} instance.
+ *
+ * @param totalPolicyPostCount the totalPolicyPostCount to set
+ */
+ public void setTotalPolicyPostCount(final long totalPolicyPostCount) {
+ this.totalPolicyPostCount = totalPolicyPostCount;
+ }
+
+ /**
+ * Returns the totalTemplateGetCount of this {@link StatisticsReport} instance.
+ *
+ * @return the totalTemplateGetCount
+ */
+ public long getTotalTemplateGetCount() {
+ return totalTemplateGetCount;
+ }
+
+ /**
+ * Set totalTemplateGetCount in this {@link StatisticsReport} instance.
+ *
+ * @param totalTemplateGetCount the totalTemplateGetCount to set
+ */
+ public void setTotalTemplateGetCount(final long totalTemplateGetCount) {
+ this.totalTemplateGetCount = totalTemplateGetCount;
+ }
+
+ /**
+ * Returns the totalTemplatePostCount of this {@link StatisticsReport} instance.
+ *
+ * @return the totalTemplatePostCount
+ */
+ public long getTotalTemplatePostCount() {
+ return totalTemplatePostCount;
+ }
+
+ /**
+ * Set totalTemplatePostCount in this {@link StatisticsReport} instance.
+ *
+ * @param totalTemplatePostCount the totalTemplatePostCount to set
+ */
+ public void setTotalTemplatePostCount(final long totalTemplatePostCount) {
+ this.totalTemplatePostCount = totalTemplatePostCount;
+ }
+
+ /**
+ * Returns the policyGetSuccessCount of this {@link StatisticsReport} instance.
+ *
+ * @return the policyGetSuccessCount
+ */
+ public long getPolicyGetSuccessCount() {
+ return policyGetSuccessCount;
+ }
+
+ /**
+ * Set policyGetSuccessCount in this {@link StatisticsReport} instance.
+ *
+ * @param policyGetSuccessCount the policyGetSuccessCount to set
+ */
+ public void setPolicyGetSuccessCount(final long policyGetSuccessCount) {
+ this.policyGetSuccessCount = policyGetSuccessCount;
+ }
+
+ /**
+ * Returns the policyGetFailureCount of this {@link StatisticsReport} instance.
+ *
+ * @return the policyGetFailureCount
+ */
+ public long getPolicyGetFailureCount() {
+ return policyGetFailureCount;
+ }
+
+ /**
+ * Set policyGetFailureCount in this {@link StatisticsReport} instance.
+ *
+ * @param policyGetFailureCount the policyGetFailureCount to set
+ */
+ public void setPolicyGetFailureCount(final long policyGetFailureCount) {
+ this.policyGetFailureCount = policyGetFailureCount;
+ }
+
+ /**
+ * Returns the policyPostSuccessCount of this {@link StatisticsReport} instance.
+ *
+ * @return the policyPostSuccessCount
+ */
+ public long getPolicyPostSuccessCount() {
+ return policyPostSuccessCount;
+ }
+
+ /**
+ * Set policyPostSuccessCount in this {@link StatisticsReport} instance.
+ *
+ * @param policyPostSuccessCount the policyPostSuccessCount to set
+ */
+ public void setPolicyPostSuccessCount(final long policyPostSuccessCount) {
+ this.policyPostSuccessCount = policyPostSuccessCount;
+ }
+
+ /**
+ * Returns the policyPostFailureCount of this {@link StatisticsReport} instance.
+ *
+ * @return the policyPostFailureCount
+ */
+ public long getPolicyPostFailureCount() {
+ return policyPostFailureCount;
+ }
+
+ /**
+ * Set policyPostFailureCount in this {@link StatisticsReport} instance.
+ *
+ * @param policyPostFailureCount the policyPostFailureCount to set
+ */
+ public void setPolicyPostFailureCount(final long policyPostFailureCount) {
+ this.policyPostFailureCount = policyPostFailureCount;
+ }
+
+ /**
+ * Returns the templateGetSuccessCount of this {@link StatisticsReport} instance.
+ *
+ * @return the templateGetSuccessCount
+ */
+ public long getTemplateGetSuccessCount() {
+ return templateGetSuccessCount;
+ }
+
+ /**
+ * Set templateGetSuccessCount in this {@link StatisticsReport} instance.
+ *
+ * @param templateGetSuccessCount the templateGetSuccessCount to set
+ */
+ public void setTemplateGetSuccessCount(final long templateGetSuccessCount) {
+ this.templateGetSuccessCount = templateGetSuccessCount;
+ }
+
+ /**
+ * Returns the templateGetFailureCount of this {@link StatisticsReport} instance.
+ *
+ * @return the templateGetFailureCount
+ */
+ public long getTemplateGetFailureCount() {
+ return templateGetFailureCount;
+ }
+
+ /**
+ * Set templateGetFailureCount in this {@link StatisticsReport} instance.
+ *
+ * @param templateGetFailureCount the templateGetFailureCount to set
+ */
+ public void setTemplateGetFailureCount(final long templateGetFailureCount) {
+ this.templateGetFailureCount = templateGetFailureCount;
+ }
+
+ /**
+ * Returns the templatePostSuccessCount of this {@link StatisticsReport} instance.
+ *
+ * @return the templatePostSuccessCount
+ */
+ public long getTemplatePostSuccessCount() {
+ return templatePostSuccessCount;
+ }
+
+ /**
+ * Set templatePostSuccessCount in this {@link StatisticsReport} instance.
+ *
+ * @param templatePostSuccessCount the templatePostSuccessCount to set
+ */
+ public void setTemplatePostSuccessCount(final long templatePostSuccessCount) {
+ this.templatePostSuccessCount = templatePostSuccessCount;
+ }
+
+ /**
+ * Returns the templatePostFailureCount of this {@link StatisticsReport} instance.
+ *
+ * @return the templatePostFailureCount
+ */
+ public long getTemplatePostFailureCount() {
+ return templatePostFailureCount;
+ }
+
+ /**
+ * Set templatePostFailureCount in this {@link StatisticsReport} instance.
+ *
+ * @param templatePostFailureCount the templatePostFailureCount to set
+ */
+ public void setTemplatePostFailureCount(final long templatePostFailureCount) {
+ this.templatePostFailureCount = templatePostFailureCount;
+ }
+
+ /**
+ * {@inheritDoc}}.
+ */
+ @Override
+ public String toString() {
+ final StringBuilder builder = new StringBuilder();
+ builder.append("StatisticsReport [code=");
+ builder.append(getCode());
+ builder.append(", totalApiCallCount=");
+ builder.append(getTotalApiCallCount());
+ builder.append(", apiCallSuccessCount=");
+ builder.append(getApiCallSuccessCount());
+ builder.append(", apiCallFailureCount=");
+ builder.append(getApiCallFailureCount());
+ builder.append(", totalPolicyGetCount=");
+ builder.append(getTotalPolicyGetCount());
+ builder.append(", totalPolicyPostCount=");
+ builder.append(getTotalPolicyPostCount());
+ builder.append(", totalTemplateGetCount=");
+ builder.append(getTotalTemplateGetCount());
+ builder.append(", totalTemplatePostCount=");
+ builder.append(getTotalTemplatePostCount());
+ builder.append(", policyGetSuccessCount=");
+ builder.append(getPolicyGetSuccessCount());
+ builder.append(", policyGetFailureCount=");
+ builder.append(getPolicyGetFailureCount());
+ builder.append(", policyPostSuccessCount=");
+ builder.append(getPolicyPostSuccessCount());
+ builder.append(", policyPostFailureCount=");
+ builder.append(getPolicyPostFailureCount());
+ builder.append(", templateGetSuccessCount=");
+ builder.append(getTemplateGetSuccessCount());
+ builder.append(", templateGetFailureCount=");
+ builder.append(getTemplateGetFailureCount());
+ builder.append(", templatePostSuccessCount=");
+ builder.append(getTemplatePostSuccessCount());
+ builder.append(", templatePostFailureCount=");
+ builder.append(getTemplatePostFailureCount());
+ builder.append("]");
+ return builder.toString();
+ }
+}
diff --git a/main/src/main/java/org/onap/policy/api/main/rest/aaf/AafApiFilter.java b/main/src/main/java/org/onap/policy/api/main/rest/aaf/AafApiFilter.java
new file mode 100644
index 00000000..dea12ee7
--- /dev/null
+++ b/main/src/main/java/org/onap/policy/api/main/rest/aaf/AafApiFilter.java
@@ -0,0 +1,39 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP Policy API
+ * ================================================================================
+ * Copyright (C) 2019 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.api.main.rest.aaf;
+
+import org.onap.policy.common.endpoints.http.server.aaf.AafGranularAuthFilter;
+
+/**
+ * Api AAF authorization filter.
+ */
+public class AafApiFilter extends AafGranularAuthFilter {
+
+ public static final String AAF_NODETYPE = "policy-api";
+ public static final String AAF_ROOT_PERMISSION = DEFAULT_NAMESPACE + "." + AAF_NODETYPE;
+
+ @Override
+ public String getPermissionTypeRoot() {
+ return AAF_ROOT_PERMISSION;
+ }
+}
diff --git a/main/src/main/java/org/onap/policy/api/main/startstop/ApiActivator.java b/main/src/main/java/org/onap/policy/api/main/startstop/ApiActivator.java
index 1f7b05aa..4cd98849 100644
--- a/main/src/main/java/org/onap/policy/api/main/startstop/ApiActivator.java
+++ b/main/src/main/java/org/onap/policy/api/main/startstop/ApiActivator.java
@@ -1,6 +1,9 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2018 Samsung Electronics Co., Ltd. All rights reserved.
+ * ONAP Policy API
+ * ================================================================================
+ * Copyright (C) 2018 Samsung Electronics Co., Ltd. All rights reserved.
+ * Copyright (C) 2019 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.
@@ -20,22 +23,21 @@
package org.onap.policy.api.main.startstop;
-import org.onap.policy.api.main.PolicyApiException;
+import org.onap.policy.api.main.exception.PolicyApiException;
import org.onap.policy.api.main.parameters.ApiParameterGroup;
import org.onap.policy.api.main.rest.ApiRestServer;
-import org.onap.policy.common.logging.flexlogger.FlexLogger;
-import org.onap.policy.common.logging.flexlogger.Logger;
import org.onap.policy.common.parameters.ParameterService;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* This class wraps a distributor so that it can be activated as a complete service together with all its api
* and forwarding handlers.
*/
public class ApiActivator {
- // The logger for this class
- private static final Logger LOGGER = FlexLogger.getLogger(ApiActivator.class);
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(ApiActivator.class);
- // The parameters of this policy api activator
private final ApiParameterGroup apiParameterGroup;
private static boolean alive = false;
@@ -91,8 +93,7 @@ public class ApiActivator {
// Stop the api rest server
restServer.stop();
} catch (final Exception exp) {
- LOGGER.error("Policy api service termination failed", exp);
- throw new PolicyApiException(exp.getMessage(), exp);
+ throw new PolicyApiException("Policy api service termination failed", exp);
}
}
diff --git a/main/src/main/java/org/onap/policy/api/main/startstop/ApiCommandLineArguments.java b/main/src/main/java/org/onap/policy/api/main/startstop/ApiCommandLineArguments.java
index f165b16f..f6c1c781 100644
--- a/main/src/main/java/org/onap/policy/api/main/startstop/ApiCommandLineArguments.java
+++ b/main/src/main/java/org/onap/policy/api/main/startstop/ApiCommandLineArguments.java
@@ -31,11 +31,10 @@ import org.apache.commons.cli.HelpFormatter;
import org.apache.commons.cli.Option;
import org.apache.commons.cli.Options;
import org.apache.commons.cli.ParseException;
-import org.onap.policy.api.main.PolicyApiException;
-import org.onap.policy.api.main.PolicyApiRuntimeException;
+import org.onap.policy.api.main.exception.PolicyApiException;
+import org.onap.policy.api.main.exception.PolicyApiRuntimeException;
import org.onap.policy.common.utils.resources.ResourceUtils;
-
/**
* This class reads and handles command line parameters for the policy api main program.
*/
diff --git a/main/src/main/java/org/onap/policy/api/main/startstop/Main.java b/main/src/main/java/org/onap/policy/api/main/startstop/Main.java
index 00d36873..97d53ade 100644
--- a/main/src/main/java/org/onap/policy/api/main/startstop/Main.java
+++ b/main/src/main/java/org/onap/policy/api/main/startstop/Main.java
@@ -1,6 +1,9 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2018 Samsung Electronics Co., Ltd. All rights reserved.
+ * ONAP Policy API
+ * ================================================================================
+ * Copyright (C) 2018 Samsung Electronics Co., Ltd. All rights reserved.
+ * Copyright (C) 2019 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.
@@ -21,18 +24,19 @@
package org.onap.policy.api.main.startstop;
import java.util.Arrays;
-import org.onap.policy.api.main.PolicyApiException;
+import org.onap.policy.api.main.exception.PolicyApiException;
import org.onap.policy.api.main.parameters.ApiParameterGroup;
import org.onap.policy.api.main.parameters.ApiParameterHandler;
-import org.onap.policy.common.logging.flexlogger.FlexLogger;
-import org.onap.policy.common.logging.flexlogger.Logger;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* This class initiates ONAP Policy Framework policy api.
*
*/
public class Main {
- private static final Logger LOGGER = FlexLogger.getLogger(Main.class);
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(Main.class);
// The policy api Activator that activates the policy api service
private ApiActivator activator;
@@ -47,7 +51,7 @@ public class Main {
*/
public Main(final String[] args) {
final String argumentString = Arrays.toString(args);
- LOGGER.info("Starting policy api service with arguments - " + argumentString);
+ LOGGER.info("Starting policy api service with arguments - {}", argumentString);
// Check the arguments
final ApiCommandLineArguments arguments = new ApiCommandLineArguments();
@@ -81,8 +85,7 @@ public class Main {
try {
activator.initialize();
} catch (final PolicyApiException e) {
- LOGGER.error("start of policy api service failed, used parameters are " + Arrays.toString(args),
- e);
+ LOGGER.error("start of policy api service failed, used parameters are {} ", argumentString, e);
return;
}
diff --git a/main/src/test/java/org/onap/policy/api/main/parameters/CommonTestData.java b/main/src/test/java/org/onap/policy/api/main/parameters/CommonTestData.java
index f86c8570..8ff2f98e 100644
--- a/main/src/test/java/org/onap/policy/api/main/parameters/CommonTestData.java
+++ b/main/src/test/java/org/onap/policy/api/main/parameters/CommonTestData.java
@@ -1,6 +1,9 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2018 Samsung Electronics Co., Ltd. All rights reserved.
+ * ONAP Policy API
+ * ================================================================================
+ * Copyright (C) 2018 Samsung Electronics Co., Ltd. All rights reserved.
+ * Copyright (C) 2019 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.
@@ -30,21 +33,23 @@ public class CommonTestData {
private static final String REST_SERVER_USER = "healthcheck";
private static final int REST_SERVER_PORT = 6969;
private static final String REST_SERVER_HOST = "0.0.0.0";
+ private static final boolean REST_SERVER_HTTPS = false;
+ private static final boolean REST_SERVER_AAF = false;
public static final String API_GROUP_NAME = "ApiGroup";
/**
- * Returns an instance of ReceptionHandlerParameters for test cases.
+ * Returns an instance of RestServerParameters for test cases.
*
* @param isEmpty boolean value to represent that object created should be empty or not
- * @return the restServerParameters object
+ * @return the RestServerParameters object
*/
public RestServerParameters getRestServerParameters(final boolean isEmpty) {
final RestServerParameters restServerParameters;
if (!isEmpty) {
restServerParameters = new RestServerParameters(REST_SERVER_HOST, REST_SERVER_PORT, REST_SERVER_USER,
- REST_SERVER_PASSWORD);
+ REST_SERVER_PASSWORD, REST_SERVER_HTTPS, REST_SERVER_AAF);
} else {
- restServerParameters = new RestServerParameters(null, 0, null, null);
+ restServerParameters = new RestServerParameters(null, 0, null, null, false, false);
}
return restServerParameters;
}
diff --git a/main/src/test/java/org/onap/policy/api/main/parameters/TestApiParameterGroup.java b/main/src/test/java/org/onap/policy/api/main/parameters/TestApiParameterGroup.java
index 7a59dad6..93fbfc64 100644
--- a/main/src/test/java/org/onap/policy/api/main/parameters/TestApiParameterGroup.java
+++ b/main/src/test/java/org/onap/policy/api/main/parameters/TestApiParameterGroup.java
@@ -1,6 +1,9 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2018 Samsung Electronics Co., Ltd. All rights reserved.
+ * ONAP Policy API
+ * ================================================================================
+ * Copyright (C) 2018 Samsung Electronics Co., Ltd. All rights reserved.
+ * Copyright (C) 2019 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.
@@ -47,6 +50,8 @@ public class TestApiParameterGroup {
apiParameters.getRestServerParameters().getUserName());
assertEquals(restServerParameters.getPassword(),
apiParameters.getRestServerParameters().getPassword());
+ assertEquals(restServerParameters.isHttps(), apiParameters.getRestServerParameters().isHttps());
+ assertEquals(restServerParameters.isAaf(), apiParameters.getRestServerParameters().isAaf());
assertEquals(CommonTestData.API_GROUP_NAME, apiParameters.getName());
}
diff --git a/main/src/test/java/org/onap/policy/api/main/parameters/TestApiParameterHandler.java b/main/src/test/java/org/onap/policy/api/main/parameters/TestApiParameterHandler.java
index 7a065240..71d8c357 100644
--- a/main/src/test/java/org/onap/policy/api/main/parameters/TestApiParameterHandler.java
+++ b/main/src/test/java/org/onap/policy/api/main/parameters/TestApiParameterHandler.java
@@ -1,6 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2018 Samsung Electronics Co., Ltd. All rights reserved.
+ * Copyright (C) 2019 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.
@@ -29,7 +30,7 @@ import java.nio.file.Files;
import java.nio.file.Paths;
import org.junit.Test;
-import org.onap.policy.api.main.PolicyApiException;
+import org.onap.policy.api.main.exception.PolicyApiException;
import org.onap.policy.api.main.startstop.ApiCommandLineArguments;
/**
@@ -39,9 +40,7 @@ import org.onap.policy.api.main.startstop.ApiCommandLineArguments;
public class TestApiParameterHandler {
@Test
public void testParameterHandlerNoParameterFile() throws PolicyApiException {
- final String[] noArgumentString =
- { "-c", "parameters/NoParameterFile.json" };
-
+ final String[] noArgumentString = { "-c", "parameters/NoParameterFile.json" };
final ApiCommandLineArguments noArguments = new ApiCommandLineArguments();
noArguments.parse(noArgumentString);
@@ -55,9 +54,7 @@ public class TestApiParameterHandler {
@Test
public void testParameterHandlerEmptyParameters() throws PolicyApiException {
- final String[] emptyArgumentString =
- { "-c", "parameters/EmptyParameters.json" };
-
+ final String[] emptyArgumentString = { "-c", "parameters/EmptyParameters.json" };
final ApiCommandLineArguments emptyArguments = new ApiCommandLineArguments();
emptyArguments.parse(emptyArgumentString);
@@ -71,9 +68,7 @@ public class TestApiParameterHandler {
@Test
public void testParameterHandlerBadParameters() throws PolicyApiException {
- final String[] badArgumentString =
- { "-c", "parameters/BadParameters.json" };
-
+ final String[] badArgumentString = { "-c", "parameters/BadParameters.json" };
final ApiCommandLineArguments badArguments = new ApiCommandLineArguments();
badArguments.parse(badArgumentString);
@@ -89,9 +84,7 @@ public class TestApiParameterHandler {
@Test
public void testParameterHandlerInvalidParameters() throws PolicyApiException {
- final String[] invalidArgumentString =
- { "-c", "parameters/InvalidParameters.json" };
-
+ final String[] invalidArgumentString = { "-c", "parameters/InvalidParameters.json" };
final ApiCommandLineArguments invalidArguments = new ApiCommandLineArguments();
invalidArguments.parse(invalidArgumentString);
@@ -107,9 +100,7 @@ public class TestApiParameterHandler {
@Test
public void testParameterHandlerNoParameters() throws PolicyApiException {
- final String[] noArgumentString =
- { "-c", "parameters/NoParameters.json" };
-
+ final String[] noArgumentString = { "-c", "parameters/NoParameters.json" };
final ApiCommandLineArguments noArguments = new ApiCommandLineArguments();
noArguments.parse(noArgumentString);
@@ -127,24 +118,18 @@ public class TestApiParameterHandler {
@Test
public void testParameterHandlerMinumumParameters() throws PolicyApiException {
- final String[] minArgumentString =
- { "-c", "parameters/MinimumParameters.json" };
-
+ final String[] minArgumentString = { "-c", "parameters/MinimumParameters.json" };
final ApiCommandLineArguments minArguments = new ApiCommandLineArguments();
minArguments.parse(minArgumentString);
-
final ApiParameterGroup parGroup = new ApiParameterHandler().getParameters(minArguments);
assertEquals(CommonTestData.API_GROUP_NAME, parGroup.getName());
}
@Test
public void testApiParameterGroup() throws PolicyApiException {
- final String[] apiConfigParameters =
- { "-c", "parameters/ApiConfigParameters.json" };
-
+ final String[] apiConfigParameters = { "-c", "parameters/ApiConfigParameters.json" };
final ApiCommandLineArguments arguments = new ApiCommandLineArguments();
arguments.parse(apiConfigParameters);
-
final ApiParameterGroup parGroup = new ApiParameterHandler().getParameters(arguments);
assertTrue(arguments.checkSetConfigurationFilePath());
assertEquals(CommonTestData.API_GROUP_NAME, parGroup.getName());
@@ -152,9 +137,7 @@ public class TestApiParameterHandler {
@Test
public void testApiParameterGroup_InvalidName() throws PolicyApiException {
- final String[] apiConfigParameters =
- { "-c", "parameters/ApiConfigParameters_InvalidName.json" };
-
+ final String[] apiConfigParameters = { "-c", "parameters/ApiConfigParameters_InvalidName.json" };
final ApiCommandLineArguments arguments = new ApiCommandLineArguments();
arguments.parse(apiConfigParameters);
@@ -170,9 +153,8 @@ public class TestApiParameterHandler {
@Test
public void testApiParameterGroup_InvalidRestServerParameters()
throws PolicyApiException, IOException {
- final String[] apiConfigParameters =
- { "-c", "parameters/ApiConfigParameters_InvalidRestServerParameters.json" };
-
+ final String[] apiConfigParameters =
+ { "-c", "parameters/ApiConfigParameters_InvalidRestServerParameters.json" };
final ApiCommandLineArguments arguments = new ApiCommandLineArguments();
arguments.parse(apiConfigParameters);
@@ -189,8 +171,7 @@ public class TestApiParameterHandler {
@Test
public void testApiVersion() throws PolicyApiException {
- final String[] apiConfigParameters =
- { "-v" };
+ final String[] apiConfigParameters = { "-v" };
final ApiCommandLineArguments arguments = new ApiCommandLineArguments();
final String version = arguments.parse(apiConfigParameters);
assertTrue(version.startsWith("ONAP Policy Framework Api Service"));
@@ -198,8 +179,7 @@ public class TestApiParameterHandler {
@Test
public void testApiHelp() throws PolicyApiException {
- final String[] apiConfigParameters =
- { "-h" };
+ final String[] apiConfigParameters = { "-h" };
final ApiCommandLineArguments arguments = new ApiCommandLineArguments();
final String help = arguments.parse(apiConfigParameters);
assertTrue(help.startsWith("usage:"));
@@ -207,8 +187,7 @@ public class TestApiParameterHandler {
@Test
public void testApiInvalidOption() throws PolicyApiException {
- final String[] apiConfigParameters =
- { "-d" };
+ final String[] apiConfigParameters = { "-d" };
final ApiCommandLineArguments arguments = new ApiCommandLineArguments();
try {
arguments.parse(apiConfigParameters);
diff --git a/main/src/test/java/org/onap/policy/api/main/rest/TestApiRestServer.java b/main/src/test/java/org/onap/policy/api/main/rest/TestApiRestServer.java
index ad63d0f1..1ea42e0e 100644
--- a/main/src/test/java/org/onap/policy/api/main/rest/TestApiRestServer.java
+++ b/main/src/test/java/org/onap/policy/api/main/rest/TestApiRestServer.java
@@ -1,6 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2018 Samsung Electronics Co., Ltd. All rights reserved.
+ * Copyright (C) 2019 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.
@@ -22,6 +23,9 @@ package org.onap.policy.api.main.rest;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.io.IOException;
import javax.ws.rs.client.Client;
import javax.ws.rs.client.ClientBuilder;
@@ -32,13 +36,14 @@ import javax.ws.rs.core.MediaType;
import org.glassfish.jersey.client.ClientConfig;
import org.glassfish.jersey.client.authentication.HttpAuthenticationFeature;
import org.junit.Test;
-import org.onap.policy.api.main.PolicyApiException;
+import org.onap.policy.api.main.exception.PolicyApiException;
import org.onap.policy.api.main.parameters.CommonTestData;
import org.onap.policy.api.main.parameters.RestServerParameters;
import org.onap.policy.api.main.startstop.Main;
import org.onap.policy.common.endpoints.report.HealthCheckReport;
-import org.onap.policy.common.logging.flexlogger.FlexLogger;
-import org.onap.policy.common.logging.flexlogger.Logger;
+import org.onap.policy.common.utils.network.NetworkUtil;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* Class to perform unit test of HealthCheckMonitor.
@@ -46,7 +51,7 @@ import org.onap.policy.common.logging.flexlogger.Logger;
*/
public class TestApiRestServer {
- private static final Logger LOGGER = FlexLogger.getLogger(TestApiRestServer.class);
+ private static final Logger LOGGER = LoggerFactory.getLogger(TestApiRestServer.class);
private static final String NOT_ALIVE = "not alive";
private static final String ALIVE = "alive";
private static final String SELF = "self";
@@ -55,10 +60,15 @@ public class TestApiRestServer {
@Test
public void testHealthCheckSuccess() throws PolicyApiException, InterruptedException {
final String reportString = "Report [name=Policy API, url=self, healthy=true, code=200, message=alive]";
- final Main main = startApiService();
- final HealthCheckReport report = performHealthCheck();
- validateReport(NAME, SELF, true, 200, ALIVE, reportString, report);
- stopApiService(main);
+ try {
+ final Main main = startApiService();
+ final HealthCheckReport report = performHealthCheck();
+ validateReport(NAME, SELF, true, 200, ALIVE, reportString, report);
+ stopApiService(main);
+ } catch (final Exception exp) {
+ LOGGER.error("testHealthCheckSuccess failed", exp);
+ fail("Test should not throw an exception");
+ }
}
@Test
@@ -67,12 +77,17 @@ public class TestApiRestServer {
final RestServerParameters restServerParams = new CommonTestData().getRestServerParameters(false);
restServerParams.setName(CommonTestData.API_GROUP_NAME);
final ApiRestServer restServer = new ApiRestServer(restServerParams);
- restServer.start();
- final HealthCheckReport report = performHealthCheck();
- validateReport(NAME, SELF, false, 500, NOT_ALIVE, reportString, report);
- assertTrue(restServer.isAlive());
- assertTrue(restServer.toString().startsWith("ApiRestServer [servers="));
- restServer.shutdown();
+ try {
+ restServer.start();
+ final HealthCheckReport report = performHealthCheck();
+ validateReport(NAME, SELF, false, 500, NOT_ALIVE, reportString, report);
+ assertTrue(restServer.isAlive());
+ assertTrue(restServer.toString().startsWith("ApiRestServer [servers="));
+ restServer.shutdown();
+ } catch (final Exception exp) {
+ LOGGER.error("testHealthCheckFailure failed", exp);
+ fail("Test should not throw an exception");
+ }
}
private Main startApiService() {
@@ -84,8 +99,7 @@ public class TestApiRestServer {
main.shutdown();
}
- private HealthCheckReport performHealthCheck() throws InterruptedException {
- HealthCheckReport response = null;
+ private HealthCheckReport performHealthCheck() throws InterruptedException, IOException {
final ClientConfig clientConfig = new ClientConfig();
final HttpAuthenticationFeature feature = HttpAuthenticationFeature.basic("healthcheck", "zb!XztG34");
@@ -95,14 +109,11 @@ public class TestApiRestServer {
final WebTarget webTarget = client.target("http://localhost:6969/healthcheck");
final Invocation.Builder invocationBuilder = webTarget.request(MediaType.APPLICATION_JSON);
- while (response == null) {
- try {
- response = invocationBuilder.get(HealthCheckReport.class);
- } catch (final Exception exp) {
- LOGGER.info("the server is not started yet. We will retry again");
- }
+
+ if (!NetworkUtil.isTcpPortOpen("localhost", 6969, 6, 10000L)) {
+ throw new IllegalStateException("cannot connect to port 6969");
}
- return response;
+ return invocationBuilder.get(HealthCheckReport.class);
}
private void validateReport(final String name, final String url, final boolean healthy, final int code,
diff --git a/main/src/test/java/org/onap/policy/api/main/rest/TestApiStatistics.java b/main/src/test/java/org/onap/policy/api/main/rest/TestApiStatistics.java
new file mode 100644
index 00000000..5d535678
--- /dev/null
+++ b/main/src/test/java/org/onap/policy/api/main/rest/TestApiStatistics.java
@@ -0,0 +1,152 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP Policy API
+ * ================================================================================
+ * Copyright (C) 2019 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.api.main.rest;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
+
+import java.io.IOException;
+
+import javax.ws.rs.client.Client;
+import javax.ws.rs.client.ClientBuilder;
+import javax.ws.rs.client.Invocation;
+import javax.ws.rs.client.WebTarget;
+import javax.ws.rs.core.MediaType;
+
+import org.glassfish.jersey.client.ClientConfig;
+import org.glassfish.jersey.client.authentication.HttpAuthenticationFeature;
+import org.junit.Test;
+import org.onap.policy.api.main.exception.PolicyApiException;
+import org.onap.policy.api.main.parameters.CommonTestData;
+import org.onap.policy.api.main.parameters.RestServerParameters;
+import org.onap.policy.api.main.startstop.Main;
+import org.onap.policy.common.utils.network.NetworkUtil;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Class to perform unit test of {@link ApiRestController}.
+ */
+public class TestApiStatistics {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(TestApiStatistics.class);
+
+ @Test
+ public void testApiStatistics_200() throws PolicyApiException, InterruptedException {
+ try {
+ final Main main = startApiService();
+ StatisticsReport report = getApiStatistics();
+ validateReport(report, 0, 200);
+ updateApiStatistics();
+ report = getApiStatistics();
+ validateReport(report, 1, 200);
+ stopApiService(main);
+ ApiStatisticsManager.resetAllStatistics();
+ } catch (final Exception exp) {
+ LOGGER.error("testApiStatistics_200 failed", exp);
+ fail("Test should not throw an exception");
+ }
+ }
+
+ @Test
+ public void testApiStatistics_500() throws InterruptedException {
+ final RestServerParameters restServerParams = new CommonTestData().getRestServerParameters(false);
+ restServerParams.setName(CommonTestData.API_GROUP_NAME);
+
+ final ApiRestServer restServer = new ApiRestServer(restServerParams);
+ try {
+ restServer.start();
+ final StatisticsReport report = getApiStatistics();
+ validateReport(report, 0, 500);
+ restServer.shutdown();
+ ApiStatisticsManager.resetAllStatistics();
+ } catch (final Exception exp) {
+ LOGGER.error("testApiStatistics_500 failed", exp);
+ fail("Test should not throw an exception");
+ }
+ }
+
+
+ private Main startApiService() {
+ final String[] distributionConfigParameters = { "-c", "parameters/ApiConfigParameters.json" };
+ return new Main(distributionConfigParameters);
+ }
+
+ private void stopApiService(final Main main) throws PolicyApiException {
+ main.shutdown();
+ }
+
+ private StatisticsReport getApiStatistics() throws InterruptedException, IOException {
+ final ClientConfig clientConfig = new ClientConfig();
+
+ final HttpAuthenticationFeature feature = HttpAuthenticationFeature.basic("healthcheck", "zb!XztG34");
+ clientConfig.register(feature);
+
+ final Client client = ClientBuilder.newClient(clientConfig);
+ final WebTarget webTarget = client.target("http://localhost:6969/statistics");
+
+ final Invocation.Builder invocationBuilder = webTarget.request(MediaType.APPLICATION_JSON);
+
+ if (!NetworkUtil.isTcpPortOpen("localhost", 6969, 6, 10000L)) {
+ throw new IllegalStateException("cannot connect to port 6969");
+ }
+ return invocationBuilder.get(StatisticsReport.class);
+ }
+
+ private void updateApiStatistics() {
+ ApiStatisticsManager.updateTotalApiCallCount();
+ ApiStatisticsManager.updateApiCallSuccessCount();
+ ApiStatisticsManager.updateApiCallFailureCount();
+ ApiStatisticsManager.updateTotalPolicyGetCount();
+ ApiStatisticsManager.updateTotalPolicyPostCount();
+ ApiStatisticsManager.updateTotalTemplateGetCount();
+ ApiStatisticsManager.updateTotalTemplatePostCount();
+ ApiStatisticsManager.updatePolicyGetSuccessCount();
+ ApiStatisticsManager.updatePolicyGetFailureCount();
+ ApiStatisticsManager.updatePolicyPostSuccessCount();
+ ApiStatisticsManager.updatePolicyPostFailureCount();
+ ApiStatisticsManager.updateTemplateGetSuccessCount();
+ ApiStatisticsManager.updateTemplateGetFailureCount();
+ ApiStatisticsManager.updateTemplatePostSuccessCount();
+ ApiStatisticsManager.updateTemplatePostFailureCount();
+ }
+
+ private void validateReport(final StatisticsReport report, final int count, final int code) {
+ assertEquals(code, report.getCode());
+ assertEquals(count, report.getTotalApiCallCount());
+ assertEquals(count, report.getApiCallSuccessCount());
+ assertEquals(count, report.getApiCallFailureCount());
+ assertEquals(count, report.getTotalPolicyGetCount());
+ assertEquals(count, report.getTotalPolicyPostCount());
+ assertEquals(count, report.getTotalTemplateGetCount());
+ assertEquals(count, report.getTotalTemplatePostCount());
+ assertEquals(count, report.getPolicyGetSuccessCount());
+ assertEquals(count, report.getPolicyGetFailureCount());
+ assertEquals(count, report.getPolicyPostSuccessCount());
+ assertEquals(count, report.getPolicyPostFailureCount());
+ assertEquals(count, report.getTemplateGetSuccessCount());
+ assertEquals(count, report.getTemplateGetFailureCount());
+ assertEquals(count, report.getTemplatePostSuccessCount());
+ assertEquals(count, report.getTemplatePostFailureCount());
+ }
+}
diff --git a/main/src/test/java/org/onap/policy/api/main/rest/TestHttpsApiRestServer.java b/main/src/test/java/org/onap/policy/api/main/rest/TestHttpsApiRestServer.java
new file mode 100644
index 00000000..d080350a
--- /dev/null
+++ b/main/src/test/java/org/onap/policy/api/main/rest/TestHttpsApiRestServer.java
@@ -0,0 +1,135 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP Policy API
+ * ================================================================================
+ * Copyright (C) 2019 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.api.main.rest;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
+
+import java.security.SecureRandom;
+import java.security.cert.X509Certificate;
+import java.util.Properties;
+
+import javax.net.ssl.SSLContext;
+import javax.net.ssl.TrustManager;
+import javax.net.ssl.X509TrustManager;
+
+import javax.ws.rs.client.Client;
+import javax.ws.rs.client.ClientBuilder;
+import javax.ws.rs.client.Invocation;
+import javax.ws.rs.client.WebTarget;
+import javax.ws.rs.core.MediaType;
+
+import org.glassfish.jersey.client.authentication.HttpAuthenticationFeature;
+import org.junit.Test;
+import org.onap.policy.api.main.exception.PolicyApiException;
+import org.onap.policy.api.main.startstop.Main;
+import org.onap.policy.common.endpoints.report.HealthCheckReport;
+import org.onap.policy.common.utils.network.NetworkUtil;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Class to perform unit test of https set on API REST server.
+ */
+public class TestHttpsApiRestServer {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(TestHttpsApiRestServer.class);
+ private static final String ALIVE = "alive";
+ private static final String SELF = "self";
+ private static final String NAME = "Policy API";
+ private static String KEYSTORE = System.getProperty("user.dir") + "/src/test/resources/ssl/policy-keystore";
+
+ @Test
+ public void testHttpsHealthCheckSuccess() {
+ final String reportString = "Report [name=Policy API, url=self, healthy=true, code=200, message=alive]";
+ try {
+ final Main main = startApiService();
+ final HealthCheckReport report = performHealthCheck();
+ validateReport(NAME, SELF, true, 200, ALIVE, reportString, report);
+ stopApiService(main);
+ } catch (final Exception exp) {
+ LOGGER.error("testHttpsHealthCheckSuccess failed", exp);
+ fail("Test should not throw an exception");
+ }
+ }
+
+ private Main startApiService() {
+ final Properties systemProps = System.getProperties();
+ systemProps.put("javax.net.ssl.keyStore", KEYSTORE);
+ systemProps.put("javax.net.ssl.keyStorePassword", "Pol1cy_0nap");
+ System.setProperties(systemProps);
+
+ final String[] apiConfigParameters = { "-c", "parameters/ApiConfigParameters_Https.json" };
+ return new Main(apiConfigParameters);
+ }
+
+ private void stopApiService(final Main main) throws PolicyApiException {
+ main.shutdown();
+ }
+
+ private HealthCheckReport performHealthCheck() throws Exception {
+
+ final TrustManager[] noopTrustManager = new TrustManager[] { new X509TrustManager() {
+
+ @Override
+ public X509Certificate[] getAcceptedIssuers() {
+ return new X509Certificate[0];
+ }
+
+ @Override
+ public void checkClientTrusted(final java.security.cert.X509Certificate[] certs, final String authType) {
+ }
+
+ @Override
+ public void checkServerTrusted(final java.security.cert.X509Certificate[] certs, final String authType) {
+ }
+ } };
+
+ final SSLContext sc = SSLContext.getInstance("TLSv1.2");
+ sc.init(null, noopTrustManager, new SecureRandom());
+ final ClientBuilder clientBuilder =
+ ClientBuilder.newBuilder().sslContext(sc).hostnameVerifier((host, session) -> true);
+ final Client client = clientBuilder.build();
+ final HttpAuthenticationFeature feature = HttpAuthenticationFeature.basic("healthcheck", "zb!XztG34");
+ client.register(feature);
+
+ final WebTarget webTarget = client.target("https://localhost:6969/healthcheck");
+
+ final Invocation.Builder invocationBuilder = webTarget.request(MediaType.APPLICATION_JSON);
+
+ if (!NetworkUtil.isTcpPortOpen("localhost", 6969, 6, 10000L)) {
+ throw new IllegalStateException("cannot connect to port 6969");
+ }
+ return invocationBuilder.get(HealthCheckReport.class);
+ }
+
+ private void validateReport(final String name, final String url, final boolean healthy, final int code,
+ final String message, final String reportString, final HealthCheckReport report) {
+ assertEquals(name, report.getName());
+ assertEquals(url, report.getUrl());
+ assertEquals(healthy, report.isHealthy());
+ assertEquals(code, report.getCode());
+ assertEquals(message, report.getMessage());
+ assertEquals(reportString, report.toString());
+ }
+}
diff --git a/main/src/test/java/org/onap/policy/api/main/rest/TestHttpsStatisticApiRestServer.java b/main/src/test/java/org/onap/policy/api/main/rest/TestHttpsStatisticApiRestServer.java
new file mode 100644
index 00000000..6b992442
--- /dev/null
+++ b/main/src/test/java/org/onap/policy/api/main/rest/TestHttpsStatisticApiRestServer.java
@@ -0,0 +1,151 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP Policy API
+ * ================================================================================
+ * Copyright (C) 2019 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.api.main.rest;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
+
+import java.security.KeyManagementException;
+import java.security.NoSuchAlgorithmException;
+import java.security.SecureRandom;
+import java.security.cert.X509Certificate;
+import java.util.Properties;
+
+import javax.net.ssl.SSLContext;
+import javax.net.ssl.TrustManager;
+import javax.net.ssl.X509TrustManager;
+
+import javax.ws.rs.client.Client;
+import javax.ws.rs.client.ClientBuilder;
+import javax.ws.rs.client.Invocation;
+import javax.ws.rs.client.WebTarget;
+import javax.ws.rs.core.MediaType;
+
+import org.glassfish.jersey.client.authentication.HttpAuthenticationFeature;
+import org.junit.Test;
+import org.onap.policy.api.main.exception.PolicyApiException;
+import org.onap.policy.api.main.startstop.Main;
+import org.onap.policy.common.utils.network.NetworkUtil;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Class to perform unit test of API statistics via https set on API REST server.
+ */
+public class TestHttpsStatisticApiRestServer {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(TestHttpsStatisticApiRestServer.class);
+ private static String KEYSTORE = System.getProperty("user.dir") + "/src/test/resources/ssl/policy-keystore";
+
+ @Test
+ public void testHttpsApiStatistic()
+ throws PolicyApiException, InterruptedException, KeyManagementException, NoSuchAlgorithmException {
+ final String reportString = "StatisticsReport [code=200, totalApiCallCount=0, apiCallSuccessCount=0, "
+ + "apiCallFailureCount=0, " + "totalPolicyGetCount=0, totalPolicyPostCount=0, "
+ + "totalTemplateGetCount=0, totalTemplatePostCount=0, "
+ + "policyGetSuccessCount=0, policyGetFailureCount=0, "
+ + "policyPostSuccessCount=0, policyPostFailureCount=0, "
+ + "templateGetSuccessCount=0, templateGetFailureCount=0, "
+ + "templatePostSuccessCount=0, templatePostFailureCount=0]";
+ try {
+ final Main main = startApiService();
+ final StatisticsReport report = performStatisticCheck();
+ validateReport(200, 0, reportString, report);
+ stopApiService(main);
+ } catch (final Exception exp) {
+ LOGGER.error("testHttpsApiStatistic failed", exp);
+ fail("Test should not throw an exception");
+ }
+ }
+
+ private Main startApiService() {
+ final Properties systemProps = System.getProperties();
+ systemProps.put("javax.net.ssl.keyStore", KEYSTORE);
+ systemProps.put("javax.net.ssl.keyStorePassword", "Pol1cy_0nap");
+ System.setProperties(systemProps);
+
+ final String[] apiConfigParameters = { "-c", "parameters/ApiConfigParameters_Https.json" };
+ return new Main(apiConfigParameters);
+ }
+
+ private void stopApiService(final Main main) throws PolicyApiException {
+ main.shutdown();
+ }
+
+ private StatisticsReport performStatisticCheck() throws Exception {
+
+ final TrustManager[] noopTrustManager = new TrustManager[] { new X509TrustManager() {
+
+ @Override
+ public X509Certificate[] getAcceptedIssuers() {
+ return new X509Certificate[0];
+ }
+
+ @Override
+ public void checkClientTrusted(final java.security.cert.X509Certificate[] certs, final String authType) {
+ }
+
+ @Override
+ public void checkServerTrusted(final java.security.cert.X509Certificate[] certs, final String authType) {
+ }
+ } };
+
+ final SSLContext sc = SSLContext.getInstance("TLSv1.2");
+ sc.init(null, noopTrustManager, new SecureRandom());
+ final ClientBuilder clientBuilder =
+ ClientBuilder.newBuilder().sslContext(sc).hostnameVerifier((host, session) -> true);
+ final Client client = clientBuilder.build();
+ final HttpAuthenticationFeature feature = HttpAuthenticationFeature.basic("healthcheck", "zb!XztG34");
+ client.register(feature);
+
+ final WebTarget webTarget = client.target("https://localhost:6969/statistics");
+
+ final Invocation.Builder invocationBuilder = webTarget.request(MediaType.APPLICATION_JSON);
+
+ if (!NetworkUtil.isTcpPortOpen("localhost", 6969, 6, 10000L)) {
+ throw new IllegalStateException("cannot connect to port 6969");
+ }
+ return invocationBuilder.get(StatisticsReport.class);
+ }
+
+ private void validateReport(final int code, final int count,
+ final String reportString, final StatisticsReport report) {
+ assertEquals(code, report.getCode());
+ assertEquals(count, report.getTotalApiCallCount());
+ assertEquals(count, report.getApiCallSuccessCount());
+ assertEquals(count, report.getApiCallFailureCount());
+ assertEquals(count, report.getTotalPolicyGetCount());
+ assertEquals(count, report.getTotalPolicyPostCount());
+ assertEquals(count, report.getTotalTemplateGetCount());
+ assertEquals(count, report.getTotalTemplatePostCount());
+ assertEquals(count, report.getPolicyGetSuccessCount());
+ assertEquals(count, report.getPolicyGetFailureCount());
+ assertEquals(count, report.getPolicyPostSuccessCount());
+ assertEquals(count, report.getPolicyPostFailureCount());
+ assertEquals(count, report.getTemplateGetSuccessCount());
+ assertEquals(count, report.getTemplateGetFailureCount());
+ assertEquals(count, report.getTemplatePostSuccessCount());
+ assertEquals(count, report.getTemplatePostFailureCount());
+ assertEquals(reportString, report.toString());
+ }
+}
diff --git a/main/src/test/java/org/onap/policy/api/main/rest/TestStatisticsReport.java b/main/src/test/java/org/onap/policy/api/main/rest/TestStatisticsReport.java
new file mode 100644
index 00000000..75b89c15
--- /dev/null
+++ b/main/src/test/java/org/onap/policy/api/main/rest/TestStatisticsReport.java
@@ -0,0 +1,47 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP Policy API
+ * ================================================================================
+ * Copyright (C) 2019 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.api.main.rest;
+
+import com.openpojo.reflection.filters.FilterClassName;
+import com.openpojo.validation.Validator;
+import com.openpojo.validation.ValidatorBuilder;
+import com.openpojo.validation.rule.impl.SetterMustExistRule;
+import com.openpojo.validation.test.impl.GetterTester;
+import com.openpojo.validation.test.impl.SetterTester;
+
+import org.junit.Test;
+import org.onap.policy.common.utils.validation.ToStringTester;
+
+/**
+ * Class to perform unit testing of {@link StatisticsReport}.
+ */
+public class TestStatisticsReport {
+
+ @Test
+ public void testStatisticsReport() {
+ final Validator validator = ValidatorBuilder.create().with(new ToStringTester()).with(new SetterMustExistRule())
+ .with(new SetterTester()).with(new GetterTester()).build();
+ validator.validate(StatisticsReport.class.getPackage().getName(),
+ new FilterClassName(StatisticsReport.class.getName()));
+ }
+}
diff --git a/main/src/test/java/org/onap/policy/api/main/startstop/TestApiActivator.java b/main/src/test/java/org/onap/policy/api/main/startstop/TestApiActivator.java
index e5ab8101..01cd77c6 100644
--- a/main/src/test/java/org/onap/policy/api/main/startstop/TestApiActivator.java
+++ b/main/src/test/java/org/onap/policy/api/main/startstop/TestApiActivator.java
@@ -1,6 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2018 Samsung Electronics Co., Ltd. All rights reserved.
+ * Copyright (C) 2019 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.
@@ -24,7 +25,7 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import org.junit.Test;
-import org.onap.policy.api.main.PolicyApiException;
+import org.onap.policy.api.main.exception.PolicyApiException;
import org.onap.policy.api.main.parameters.ApiParameterGroup;
import org.onap.policy.api.main.parameters.ApiParameterHandler;
import org.onap.policy.api.main.parameters.CommonTestData;
@@ -38,14 +39,9 @@ public class TestApiActivator {
@Test
public void testApiActivator() throws PolicyApiException {
- final String[] apiConfigParameters =
- { "-c", "parameters/ApiConfigParameters.json" };
-
- final ApiCommandLineArguments arguments =
- new ApiCommandLineArguments(apiConfigParameters);
-
+ final String[] apiConfigParameters = { "-c", "parameters/ApiConfigParameters.json" };
+ final ApiCommandLineArguments arguments = new ApiCommandLineArguments(apiConfigParameters);
final ApiParameterGroup parGroup = new ApiParameterHandler().getParameters(arguments);
-
final ApiActivator activator = new ApiActivator(parGroup);
activator.initialize();
assertTrue(activator.getParameterGroup().isValid());
diff --git a/main/src/test/java/org/onap/policy/api/main/startstop/TestMain.java b/main/src/test/java/org/onap/policy/api/main/startstop/TestMain.java
index 47725349..2f68e852 100644
--- a/main/src/test/java/org/onap/policy/api/main/startstop/TestMain.java
+++ b/main/src/test/java/org/onap/policy/api/main/startstop/TestMain.java
@@ -1,6 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2018 Samsung Electronics Co., Ltd. All rights reserved.
+ * Copyright (C) 2019 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.
@@ -24,7 +25,7 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import org.junit.Test;
-import org.onap.policy.api.main.PolicyApiException;
+import org.onap.policy.api.main.exception.PolicyApiException;
import org.onap.policy.api.main.parameters.CommonTestData;
/**
@@ -35,8 +36,7 @@ public class TestMain {
@Test
public void testMain() throws PolicyApiException {
- final String[] apiConfigParameters =
- { "-c", "parameters/ApiConfigParameters.json" };
+ final String[] apiConfigParameters = { "-c", "parameters/ApiConfigParameters.json" };
final Main main = new Main(apiConfigParameters);
assertTrue(main.getParameters().isValid());
assertEquals(CommonTestData.API_GROUP_NAME, main.getParameters().getName());
@@ -45,31 +45,27 @@ public class TestMain {
@Test
public void testMain_NoArguments() {
- final String[] apiConfigParameters =
- {};
+ final String[] apiConfigParameters = {};
final Main main = new Main(apiConfigParameters);
assertTrue(main.getParameters() == null);
}
@Test
public void testMain_InvalidArguments() {
- final String[] apiConfigParameters =
- { "parameters/ApiConfigParameters.json" };
+ final String[] apiConfigParameters = { "parameters/ApiConfigParameters.json" };
final Main main = new Main(apiConfigParameters);
assertTrue(main.getParameters() == null);
}
@Test
public void testMain_Help() {
- final String[] apiConfigParameters =
- { "-h" };
+ final String[] apiConfigParameters = { "-h" };
Main.main(apiConfigParameters);
}
@Test
public void testMain_InvalidParameters() {
- final String[] apiConfigParameters =
- { "-c", "parameters/ApiConfigParameters_InvalidName.json" };
+ final String[] apiConfigParameters = { "-c", "parameters/ApiConfigParameters_InvalidName.json" };
final Main main = new Main(apiConfigParameters);
assertTrue(main.getParameters() == null);
}
diff --git a/main/src/test/resources/parameters/ApiConfigParameters_Https.json b/main/src/test/resources/parameters/ApiConfigParameters_Https.json
new file mode 100644
index 00000000..ec732132
--- /dev/null
+++ b/main/src/test/resources/parameters/ApiConfigParameters_Https.json
@@ -0,0 +1,10 @@
+{
+ "name":"ApiGroup",
+ "restServerParameters":{
+ "host":"0.0.0.0",
+ "port":6969,
+ "userName":"healthcheck",
+ "password":"zb!XztG34",
+ "https":true
+ }
+}
diff --git a/main/src/test/resources/ssl/policy-keystore b/main/src/test/resources/ssl/policy-keystore
new file mode 100644
index 00000000..7d2b1ecc
--- /dev/null
+++ b/main/src/test/resources/ssl/policy-keystore
Binary files differ
diff --git a/packages/policy-api-docker/pom.xml b/packages/policy-api-docker/pom.xml
new file mode 100644
index 00000000..e918513b
--- /dev/null
+++ b/packages/policy-api-docker/pom.xml
@@ -0,0 +1,176 @@
+<!--
+ ============LICENSE_START=======================================================
+ Copyright (C) 2019 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.
+
+ SPDX-License-Identifier: Apache-2.0
+ ============LICENSE_END=========================================================
+-->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.onap.policy.api</groupId>
+ <artifactId>packages</artifactId>
+ <version>2.0.0-SNAPSHOT</version>
+ </parent>
+
+ <packaging>pom</packaging>
+ <artifactId>policy-api-docker</artifactId>
+ <name>Policy api docker image</name>
+ <description>Policy api docker image</description>
+
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
+ <dist.project.version>${project.version}</dist.project.version>
+ <docker.skip>false</docker.skip>
+ <docker.skip.build>false</docker.skip.build>
+ <docker.skip.push>false</docker.skip.push>
+ <docker.pull.registry>nexus3.onap.org:10001</docker.pull.registry>
+ <docker.push.registry>nexus3.onap.org:10003</docker.push.registry>
+ <maven.build.timestamp.format>yyyyMMdd'T'HHmm</maven.build.timestamp.format>
+ </properties>
+
+ <build>
+ <finalName>${project.artifactId}-${project.version}</finalName>
+ <plugins>
+ <plugin>
+ <groupId>org.codehaus.groovy.maven</groupId>
+ <artifactId>gmaven-plugin</artifactId>
+ <version>1.0</version>
+ <executions>
+ <execution>
+ <phase>validate</phase>
+ <goals>
+ <goal>execute</goal>
+ </goals>
+ <configuration>
+ <source>
+ println 'Project version: ' + project.properties['dist.project.version'];
+ def versionArray;
+ if ( project.properties['dist.project.version'] != null ) {
+ versionArray = project.properties['dist.project.version'].split('-');
+ }
+
+ if ( project.properties['dist.project.version'].endsWith("-SNAPSHOT") ) {
+ project.properties['project.docker.latesttag.version']=versionArray[0] + "-SNAPSHOT-latest";
+ } else {
+ project.properties['project.docker.latesttag.version']=versionArray[0] + "-STAGING-latest";
+ }
+
+ println 'New tag for docker: ' + project.properties['project.docker.latesttag.version'];
+ </source>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+
+ <plugin>
+ <groupId>io.fabric8</groupId>
+ <artifactId>docker-maven-plugin</artifactId>
+ <version>0.19.1</version>
+
+ <configuration>
+ <verbose>true</verbose>
+ <apiVersion>1.23</apiVersion>
+ <pullRegistry>${docker.pull.registry}</pullRegistry>
+ <pushRegistry>${docker.push.registry}</pushRegistry>
+
+ <images>
+ <image>
+ <name>onap/policy-api</name>
+ <build>
+ <cleanup>try</cleanup>
+ <dockerFile>Dockerfile</dockerFile>
+ <tags>
+ <tag>${project.version}</tag>
+ <tag>${project.version}-${maven.build.timestamp}</tag>
+ <tag>${project.docker.latesttag.version}</tag>
+ </tags>
+ <assembly>
+ <inline>
+ <dependencySets>
+ <dependencySet>
+ <includes>
+ <include>org.onap.policy.api:policy-api-tarball</include>
+ </includes>
+ <outputDirectory>/lib</outputDirectory>
+ <outputFileNameMapping>policy-api.tar.gz</outputFileNameMapping>
+ </dependencySet>
+ </dependencySets>
+ </inline>
+ </assembly>
+ </build>
+ </image>
+ </images>
+ </configuration>
+
+ <executions>
+ <execution>
+ <id>clean-images</id>
+ <phase>pre-clean</phase>
+ <goals>
+ <goal>remove</goal>
+ </goals>
+ <configuration>
+ <removeAll>true</removeAll>
+ </configuration>
+ </execution>
+
+ <execution>
+ <id>generate-images</id>
+ <phase>generate-sources</phase>
+ <goals>
+ <goal>build</goal>
+ </goals>
+ </execution>
+
+ <execution>
+ <id>push-images</id>
+ <phase>deploy</phase>
+ <goals>
+ <goal>build</goal>
+ <goal>push</goal>
+ </goals>
+ <configuration>
+ <image>onap/policy-api</image>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-deploy-plugin</artifactId>
+ <configuration>
+ <skip>true</skip>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.onap.policy.api</groupId>
+ <artifactId>policy-api-tarball</artifactId>
+ <version>${project.version}</version>
+ <classifier>tarball</classifier>
+ <type>tar.gz</type>
+ </dependency>
+ </dependencies>
+</project>
diff --git a/packages/policy-api-docker/src/main/docker/Dockerfile b/packages/policy-api-docker/src/main/docker/Dockerfile
new file mode 100644
index 00000000..0d4b3b91
--- /dev/null
+++ b/packages/policy-api-docker/src/main/docker/Dockerfile
@@ -0,0 +1,46 @@
+FROM ubuntu:14.04
+
+ARG HTTP_PROXY=${HTTP_PROXY}
+ARG HTTPS_PROXY=${HTTPS_PROXY}
+ARG BUILD_VERSION=${BUILD_VERSION}
+ARG POLICY_LOGS=/var/log/onap/policy/api
+
+ENV http_proxy $HTTP_PROXY
+ENV https_proxy $HTTPS_PROXY
+ENV BUILD_VERSION ${BUILD_VERSION}
+ENV POLICY_LOGS ${POLICY_LOGS}
+
+ENV POLICY_HOME=/opt/app/policy
+ENV POLICY_API_HOME=${POLICY_HOME}/api
+
+RUN \
+ apt-get clean && \
+ apt-get update && \
+ apt-get install -y zip unzip curl wget ssh telnet maven && \
+ apt-get install -y software-properties-common && \
+ apt-get install -y jq httpie && \
+ apt-get install -y python-pip && \
+ add-apt-repository ppa:openjdk-r/ppa && \
+ apt-get clean && \
+ apt-get update && \
+ apt-get install -y openjdk-8-jdk
+
+RUN groupadd policy
+RUN useradd --create-home --shell /bin/bash -g policy policy
+
+RUN mkdir -p ${POLICY_API_HOME} ${POLICY_LOGS} ${POLICY_HOME}/etc/ssl ${POLICY_API_HOME}/bin && \
+ chown -R policy:policy ${POLICY_HOME} ${POLICY_API_HOME} ${POLICY_LOGS}
+
+RUN mkdir /packages
+COPY /maven/* /packages
+RUN tar xvfz /packages/policy-api.tar.gz --directory ${POLICY_API_HOME}
+RUN rm /packages/policy-api.tar.gz
+
+WORKDIR ${POLICY_API_HOME}
+COPY policy-api.sh bin/.
+RUN chown -R policy:policy * && chmod +x bin/*.sh
+RUN cp ${POLICY_API_HOME}/etc/ssl/* ${POLICY_HOME}/etc/ssl && chown policy:policy ${POLICY_HOME}/etc/ssl/*
+
+USER policy
+WORKDIR ${POLICY_API_HOME}/bin
+ENTRYPOINT [ "bash", "./policy-api.sh" ]
diff --git a/packages/policy-api-docker/src/main/docker/policy-api.sh b/packages/policy-api-docker/src/main/docker/policy-api.sh
new file mode 100644
index 00000000..21d8326b
--- /dev/null
+++ b/packages/policy-api-docker/src/main/docker/policy-api.sh
@@ -0,0 +1,43 @@
+#!/bin/bash
+#
+# ============LICENSE_START=======================================================
+# Copyright (C) 2019 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.
+#
+# SPDX-License-Identifier: Apache-2.0
+# ============LICENSE_END=========================================================
+#
+
+JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64/
+POLICY_API_HOME=/opt/app/policy/api
+KEYSTORE="${POLICY_HOME}/etc/ssl/policy-keystore"
+KEYSTORE_PASSWD="Pol1cy_0nap"
+TRUSTSTORE="${POLICY_HOME}/etc/ssl/policy-truststore"
+TRUSTSTORE_PASSWD="Pol1cy_0nap"
+
+
+if [ "$#" -eq 1 ]; then
+ CONFIG_FILE=$1
+else
+ CONFIG_FILE=${CONFIG_FILE}
+fi
+
+if [ -z "$CONFIG_FILE" ]
+ then
+ CONFIG_FILE="$POLICY_API_HOME/etc/defaultConfig.json"
+fi
+
+echo "Policy api config file: $CONFIG_FILE"
+
+$JAVA_HOME/bin/java -cp "$POLICY_API_HOME/etc:$POLICY_API_HOME/lib/*" -Djavax.net.ssl.keyStore="$KEYSTORE" -Djavax.net.ssl.keyStorePassword="$KEYSTORE_PASSWD" -Djavax.net.ssl.trustStore="$TRUSTSTORE" -Djavax.net.ssl.trustStorePassword="$TRUSTSTORE_PASSWD" org.onap.policy.api.main.startstop.Main -c $CONFIG_FILE
diff --git a/packages/policy-api-tarball/pom.xml b/packages/policy-api-tarball/pom.xml
new file mode 100644
index 00000000..cdb68c24
--- /dev/null
+++ b/packages/policy-api-tarball/pom.xml
@@ -0,0 +1,65 @@
+<!--
+ ============LICENSE_START=======================================================
+ Copyright (C) 2019 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.
+
+ SPDX-License-Identifier: Apache-2.0
+ ============LICENSE_END=========================================================
+-->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.onap.policy.api</groupId>
+ <artifactId>packages</artifactId>
+ <version>2.0.0-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>policy-api-tarball</artifactId>
+ <name>${project.artifactId}</name>
+ <description>[${project.parent.artifactId}]</description>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.onap.policy.api</groupId>
+ <artifactId>main</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-assembly-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>generate-complete-tar</id>
+ <phase>package</phase>
+ <goals>
+ <goal>single</goal>
+ </goals>
+ <configuration>
+ <descriptors>
+ <descriptor>src/main/package/tarball/assembly.xml</descriptor>
+ </descriptors>
+ <finalName>${project.artifactId}-${project.version}</finalName>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/packages/policy-api-tarball/src/main/package/tarball/assembly.xml b/packages/policy-api-tarball/src/main/package/tarball/assembly.xml
new file mode 100644
index 00000000..e08be24d
--- /dev/null
+++ b/packages/policy-api-tarball/src/main/package/tarball/assembly.xml
@@ -0,0 +1,62 @@
+<!--
+ ============LICENSE_START=======================================================
+ Copyright (C) 2019 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.
+
+ SPDX-License-Identifier: Apache-2.0
+ ============LICENSE_END=========================================================
+-->
+
+<assembly>
+ <id>tarball</id>
+ <formats>
+ <format>tar.gz</format>
+ </formats>
+ <includeBaseDirectory>false</includeBaseDirectory>
+ <dependencySets>
+ <dependencySet>
+ <useProjectArtifact>true</useProjectArtifact>
+ <outputDirectory>/lib</outputDirectory>
+ <unpack>false</unpack>
+ <scope>runtime</scope>
+ <includes>
+ <include>*:jar</include>
+ </includes>
+ </dependencySet>
+ </dependencySets>
+ <fileSets>
+ <fileSet>
+ <directory>${project.basedir}/src/main/resources/etc
+ </directory>
+ <includes>
+ <include>*.json</include>
+ <include>*.xml</include>
+ </includes>
+ <outputDirectory>/etc</outputDirectory>
+ <lineEnding>unix</lineEnding>
+ <excludes>
+ <exclude>*.formatted</exclude>
+ </excludes>
+ </fileSet>
+ <fileSet>
+ <directory>${project.basedir}/src/main/resources/etc/ssl
+ </directory>
+ <includes>
+ <include>policy*</include>
+ </includes>
+ <outputDirectory>/etc/ssl</outputDirectory>
+ <lineEnding>keep</lineEnding>
+ </fileSet>
+ </fileSets>
+</assembly>
diff --git a/packages/policy-api-tarball/src/main/resources/etc/defaultConfig.json b/packages/policy-api-tarball/src/main/resources/etc/defaultConfig.json
new file mode 100644
index 00000000..f7aaf393
--- /dev/null
+++ b/packages/policy-api-tarball/src/main/resources/etc/defaultConfig.json
@@ -0,0 +1,11 @@
+{
+ "name": "ApiGroup",
+ "restServerParameters": {
+ "host": "0.0.0.0",
+ "port": 6969,
+ "userName": "healthcheck",
+ "password": "zb!XztG34",
+ "https": true,
+ "aaf": false
+ }
+}
diff --git a/packages/policy-api-tarball/src/main/resources/etc/logback.xml b/packages/policy-api-tarball/src/main/resources/etc/logback.xml
new file mode 100644
index 00000000..234695ee
--- /dev/null
+++ b/packages/policy-api-tarball/src/main/resources/etc/logback.xml
@@ -0,0 +1,166 @@
+<!--
+ ============LICENSE_START=======================================================
+ policy-api
+ ================================================================================
+ Copyright (C) 2017-2019 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=========================================================
+ -->
+
+<configuration scan="true" scanPeriod="30 seconds" debug="false">
+
+ <property name="logDir" value="${POLICY_LOGS}" />
+
+ <property name="errorLog" value="error" />
+ <property name="debugLog" value="debug" />
+ <property name="networkLog" value="network" />
+
+ <property name="metricLog" value="metric" />
+ <property name="transactionLog" value="audit" />
+
+ <property name="debugPattern"
+ value="[%d{yyyy-MM-dd'T'HH:mm:ss.SSS+00:00, UTC}|%level|%logger{0}|%thread] %msg%n" />
+ <property name="errorPattern" value="${debugPattern}" />
+ <property name="networkPattern"
+ value="[%d{yyyy-MM-dd'T'HH:mm:ss.SSS+00:00, UTC}|%t]%m%n" />
+
+ <property name="metricPattern"
+ value="%X{RequestID}|%X{InvocationID}|%X{ServiceName}|%X{PartnerName}|%X{BeginTimestamp}|%X{EndTimestamp}|%X{ElapsedTime}|%X{ServiceInstanceID}|%X{VirtualServerName}|%X{StatusCode}|%X{ResponseCode}|%X{ResponseDescription}|%X{InstanceUUID}|%X{Severity}|%X{TargetEntity}|%X{TargetServiceName}|%X{Server}|%X{ServerIPAddress}|%X{ServerFQDN}|%X{ClientIPAddress}|%X{ProcessKey}|%X{RemoteHost}|%X{AlertSeverity}|%X{TargetVirtualEntity}|%level|%thread| %msg%n" />
+ <property name="transactionPattern" value="${metricPattern}" />
+
+ <appender name="ErrorOut"
+ class="ch.qos.logback.core.rolling.RollingFileAppender">
+ <file>${logDir}/${errorLog}.log</file>
+ <rollingPolicy
+ class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
+ <fileNamePattern>${logDir}/${errorLog}.%d{yyyy-MM-dd}.%i.log.zip
+ </fileNamePattern>
+ <maxFileSize>50MB</maxFileSize>
+ <maxHistory>30</maxHistory>
+ <totalSizeCap>10GB</totalSizeCap>
+ </rollingPolicy>
+ <filter class="ch.qos.logback.classic.filter.ThresholdFilter">
+ <level>WARN</level>
+ </filter>
+ <encoder>
+ <pattern>${errorPattern}</pattern>
+ </encoder>
+ </appender>
+
+ <appender name="AsyncErrorOut"
+ class="ch.qos.logback.classic.AsyncAppender">
+ <appender-ref ref="ErrorOut" />
+ </appender>
+
+ <appender name="DebugOut"
+ class="ch.qos.logback.core.rolling.RollingFileAppender">
+ <file>${logDir}/${debugLog}.log</file>
+ <rollingPolicy
+ class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
+ <fileNamePattern>${logDir}/${debugLog}.%d{yyyy-MM-dd}.%i.log.zip
+ </fileNamePattern>
+ <maxFileSize>50MB</maxFileSize>
+ <maxHistory>30</maxHistory>
+ <totalSizeCap>10GB</totalSizeCap>
+ </rollingPolicy>
+ <encoder>
+ <pattern>${debugPattern}</pattern>
+ </encoder>
+ </appender>
+
+ <appender name="AsyncDebugOut"
+ class="ch.qos.logback.classic.AsyncAppender">
+ <appender-ref ref="DebugOut" />
+ </appender>
+
+ <appender name="NetworkOut"
+ class="ch.qos.logback.core.rolling.RollingFileAppender">
+ <file>${logDir}/${networkLog}.log</file>
+ <rollingPolicy
+ class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
+ <fileNamePattern>${logDir}/${networkLog}.%d{yyyy-MM-dd}.%i.log.zip
+ </fileNamePattern>
+ <maxFileSize>50MB</maxFileSize>
+ <maxHistory>30</maxHistory>
+ <totalSizeCap>10GB</totalSizeCap>
+ </rollingPolicy>
+ <encoder>
+ <pattern>${networkPattern}</pattern>
+ </encoder>
+ </appender>
+
+ <appender name="AsyncNetworkOut"
+ class="ch.qos.logback.classic.AsyncAppender">
+ <appender-ref ref="NetworkOut" />
+ </appender>
+
+ <appender name="MetricOut"
+ class="ch.qos.logback.core.rolling.RollingFileAppender">
+ <file>${logDir}/${metricLog}.log</file>
+ <rollingPolicy
+ class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
+ <fileNamePattern>${logDir}/${metricLog}.%d{yyyy-MM-dd}.%i.log.zip
+ </fileNamePattern>
+ <maxFileSize>50MB</maxFileSize>
+ <maxHistory>30</maxHistory>
+ <totalSizeCap>10GB</totalSizeCap>
+ </rollingPolicy>
+ <encoder>
+ <pattern>${metricPattern}</pattern>
+ </encoder>
+ </appender>
+
+ <appender name="AsyncMetricOut"
+ class="ch.qos.logback.classic.AsyncAppender">
+ <appender-ref ref="MetricOut" />
+ </appender>
+
+ <appender name="TransactionOut"
+ class="ch.qos.logback.core.rolling.RollingFileAppender">
+ <file>${logDir}/${transactionLog}.log</file>
+ <rollingPolicy
+ class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
+ <fileNamePattern>${logDir}/${transactionLog}.%d{yyyy-MM-dd}.%i.log.zip
+ </fileNamePattern>
+ <maxFileSize>50MB</maxFileSize>
+ <maxHistory>30</maxHistory>
+ <totalSizeCap>10GB</totalSizeCap>
+ </rollingPolicy>
+ <encoder>
+ <pattern>${transactionPattern}</pattern>
+ </encoder>
+ </appender>
+
+ <appender name="AsyncTransactionOut"
+ class="ch.qos.logback.classic.AsyncAppender">
+ <appender-ref ref="TransactionOut" />
+ </appender>
+
+ <logger name="network" level="INFO" additivity="false">
+ <appender-ref ref="AsyncNetworkOut" />
+ </logger>
+
+ <logger name="org.eclipse.jetty.server.RequestLog" level="info"
+ additivity="false">
+ <appender-ref ref="AsyncNetworkOut" />
+ </logger>
+
+ <root level="INFO">
+ <appender-ref ref="AsyncDebugOut" />
+ <appender-ref ref="AsyncErrorOut" />
+ <appender-ref ref="AsyncMetricOut" />
+ <appender-ref ref="AsyncTransactionOut" />
+ </root>
+
+</configuration>
diff --git a/packages/policy-api-tarball/src/main/resources/etc/s3pConfig.json b/packages/policy-api-tarball/src/main/resources/etc/s3pConfig.json
new file mode 100644
index 00000000..6df43f77
--- /dev/null
+++ b/packages/policy-api-tarball/src/main/resources/etc/s3pConfig.json
@@ -0,0 +1,11 @@
+{
+ "name": "ApiGroup",
+ "restServerParameters": {
+ "host": "0.0.0.0",
+ "port": 6969,
+ "userName": "healthcheck",
+ "password": "zb!XztG34",
+ "https": true,
+ "aaf": false
+ }
+} \ No newline at end of file
diff --git a/packages/policy-api-tarball/src/main/resources/etc/ssl/policy-keystore b/packages/policy-api-tarball/src/main/resources/etc/ssl/policy-keystore
new file mode 100644
index 00000000..7d2b1ecc
--- /dev/null
+++ b/packages/policy-api-tarball/src/main/resources/etc/ssl/policy-keystore
Binary files differ
diff --git a/packages/policy-api-tarball/src/main/resources/etc/ssl/policy-truststore b/packages/policy-api-tarball/src/main/resources/etc/ssl/policy-truststore
new file mode 100644
index 00000000..8834ac25
--- /dev/null
+++ b/packages/policy-api-tarball/src/main/resources/etc/ssl/policy-truststore
Binary files differ
diff --git a/packages/pom.xml b/packages/pom.xml
new file mode 100644
index 00000000..8efc1cc1
--- /dev/null
+++ b/packages/pom.xml
@@ -0,0 +1,52 @@
+<!--
+ ============LICENSE_START=======================================================
+ Copyright (C) 2019 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.
+
+ SPDX-License-Identifier: Apache-2.0
+ ============LICENSE_END=========================================================
+-->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.onap.policy.api</groupId>
+ <artifactId>policy-api</artifactId>
+ <version>2.0.0-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>packages</artifactId>
+ <packaging>pom</packaging>
+ <name>Policy api packages</name>
+
+
+ <profiles>
+ <profile>
+ <id>default</id>
+ <activation>
+ <activeByDefault>true</activeByDefault>
+ </activation>
+ </profile>
+ <profile>
+ <id>docker</id>
+ <modules>
+ <module>policy-api-tarball</module>
+ <module>policy-api-docker</module>
+ </modules>
+ <properties>
+ <docker.skip.push>false</docker.skip.push>
+ </properties>
+ </profile>
+ </profiles>
+</project>
diff --git a/pom.xml b/pom.xml
index 791c3633..671df216 100644
--- a/pom.xml
+++ b/pom.xml
@@ -2,8 +2,8 @@
============LICENSE_START=======================================================
ONAP Policy API
================================================================================
- Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
- Modified Copyright (C) 2018 Samsung Electronics Co., Ltd.
+ Copyright (C) 2018 Samsung Electronics Co., Ltd. All rights reserved.
+ Copyright (C) 2017-2019 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.
@@ -46,11 +46,12 @@
<sonar.jacoco.itReportPath>${project.basedir}/../target/code-coverage/jacoco-it.exec</sonar.jacoco.itReportPath>
<sonar.dynamicAnalysis>reuseReports</sonar.dynamicAnalysis>
- <policy.common.version>1.3.1</policy.common.version>
+ <policy.common.version>1.4.0-SNAPSHOT</policy.common.version>
</properties>
<modules>
<module>main</module>
+ <module>packages</module>
</modules>
<dependencies>
@@ -59,22 +60,10 @@
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-ext</artifactId>
- <version>1.8.0-beta2</version>
- </dependency>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-api</artifactId>
- </dependency>
- <dependency>
- <groupId>ch.qos.logback</groupId>
- <artifactId>logback-core</artifactId>
- </dependency>
- <dependency>
- <groupId>ch.qos.logback</groupId>
- <artifactId>logback-classic</artifactId>
+ <dependency>
+ <groupId>org.onap.policy.common</groupId>
+ <artifactId>policy-endpoints</artifactId>
+ <version>${policy.common.version}</version>
</dependency>
</dependencies>