summaryrefslogtreecommitdiffstats
path: root/models-provider/src/main
diff options
context:
space:
mode:
authoradheli.tavares <adheli.tavares@est.tech>2021-06-03 10:37:35 +0100
committeradheli.tavares <adheli.tavares@est.tech>2021-06-03 12:50:14 +0100
commitd72a2ab96255ccc7a9c3a3506eab5509cbcf9ac9 (patch)
treeff63a01bc3ca1bf5c8430b98ed0437c3dafec246 /models-provider/src/main
parent443f9f35fe733fdb88b51ab9c574949f5dd4c03c (diff)
Exposing the Audit provider through Models provider.
Change-Id: I4a3a28b6dbbfbad533a69cf46c545ece7e0b147e Issue-ID: POLICY-2899 Signed-off-by: adheli.tavares <adheli.tavares@est.tech>
Diffstat (limited to 'models-provider/src/main')
-rw-r--r--models-provider/src/main/java/org/onap/policy/models/provider/PolicyModelsProvider.java17
-rw-r--r--models-provider/src/main/java/org/onap/policy/models/provider/impl/DatabasePolicyModelsProviderImpl.java19
-rw-r--r--models-provider/src/main/java/org/onap/policy/models/provider/impl/DummyPolicyModelsProviderImpl.java13
3 files changed, 49 insertions, 0 deletions
diff --git a/models-provider/src/main/java/org/onap/policy/models/provider/PolicyModelsProvider.java b/models-provider/src/main/java/org/onap/policy/models/provider/PolicyModelsProvider.java
index 3af069e24..5321e8597 100644
--- a/models-provider/src/main/java/org/onap/policy/models/provider/PolicyModelsProvider.java
+++ b/models-provider/src/main/java/org/onap/policy/models/provider/PolicyModelsProvider.java
@@ -27,6 +27,8 @@ import java.util.Collection;
import java.util.List;
import lombok.NonNull;
import org.onap.policy.models.base.PfModelException;
+import org.onap.policy.models.pap.concepts.PolicyAudit;
+import org.onap.policy.models.pap.persistence.provider.PolicyAuditProvider.AuditFilter;
import org.onap.policy.models.pdp.concepts.Pdp;
import org.onap.policy.models.pdp.concepts.PdpGroup;
import org.onap.policy.models.pdp.concepts.PdpGroupFilter;
@@ -408,4 +410,19 @@ public interface PolicyModelsProvider extends AutoCloseable {
*/
public void cudPolicyStatus(Collection<PdpPolicyStatus> createObjs, Collection<PdpPolicyStatus> updateObjs,
Collection<PdpPolicyStatus> deleteObjs);
+
+ /**
+ * Creates records for audit actions on policies.
+ *
+ * @param auditRecords the objects to create
+ */
+ public void createAuditRecords(@NonNull List<PolicyAudit> auditRecords);
+
+ /**
+ * Collect the audit records.
+ * @param auditFilter filter for search
+ * @param numRecords max number of records to be collected
+ * @return list of {@link PolicyAudit} or empty if none or not match with filter
+ */
+ public List<PolicyAudit> getAuditRecords(AuditFilter auditFilter, @NonNull Integer numRecords);
}
diff --git a/models-provider/src/main/java/org/onap/policy/models/provider/impl/DatabasePolicyModelsProviderImpl.java b/models-provider/src/main/java/org/onap/policy/models/provider/impl/DatabasePolicyModelsProviderImpl.java
index a90dc895c..3bba1518a 100644
--- a/models-provider/src/main/java/org/onap/policy/models/provider/impl/DatabasePolicyModelsProviderImpl.java
+++ b/models-provider/src/main/java/org/onap/policy/models/provider/impl/DatabasePolicyModelsProviderImpl.java
@@ -29,6 +29,9 @@ import javax.ws.rs.core.Response;
import lombok.NonNull;
import org.onap.policy.models.base.PfModelException;
import org.onap.policy.models.base.PfModelRuntimeException;
+import org.onap.policy.models.pap.concepts.PolicyAudit;
+import org.onap.policy.models.pap.persistence.provider.PolicyAuditProvider;
+import org.onap.policy.models.pap.persistence.provider.PolicyAuditProvider.AuditFilter;
import org.onap.policy.models.pdp.concepts.Pdp;
import org.onap.policy.models.pdp.concepts.PdpGroup;
import org.onap.policy.models.pdp.concepts.PdpGroupFilter;
@@ -309,6 +312,22 @@ public class DatabasePolicyModelsProviderImpl extends AbstractModelsProvider imp
new PdpProvider().cudPolicyStatus(getPfDao(), createObjs, updateObjs, deleteObjs);
}
+ @Override
+ public void createAuditRecords(List<PolicyAudit> auditRecords) {
+ assertInitialized();
+ new PolicyAuditProvider().createAuditRecords(getPfDao(), auditRecords);
+ }
+
+ @Override
+ public List<PolicyAudit> getAuditRecords(AuditFilter auditFilter, @NonNull Integer numRecords) {
+ assertInitialized();
+ if (auditFilter == null || auditFilter.isEmpty()) {
+ return new PolicyAuditProvider().getAuditRecords(getPfDao(), numRecords);
+ } else {
+ return new PolicyAuditProvider().getAuditRecords(getPfDao(), auditFilter, numRecords);
+ }
+ }
+
/**
* Check if the model provider is initialized.
*/
diff --git a/models-provider/src/main/java/org/onap/policy/models/provider/impl/DummyPolicyModelsProviderImpl.java b/models-provider/src/main/java/org/onap/policy/models/provider/impl/DummyPolicyModelsProviderImpl.java
index f47f4d464..dbeccfaeb 100644
--- a/models-provider/src/main/java/org/onap/policy/models/provider/impl/DummyPolicyModelsProviderImpl.java
+++ b/models-provider/src/main/java/org/onap/policy/models/provider/impl/DummyPolicyModelsProviderImpl.java
@@ -32,6 +32,8 @@ import org.onap.policy.common.utils.coder.StandardCoder;
import org.onap.policy.common.utils.resources.ResourceUtils;
import org.onap.policy.models.base.PfModelException;
import org.onap.policy.models.base.PfModelRuntimeException;
+import org.onap.policy.models.pap.concepts.PolicyAudit;
+import org.onap.policy.models.pap.persistence.provider.PolicyAuditProvider.AuditFilter;
import org.onap.policy.models.pdp.concepts.Pdp;
import org.onap.policy.models.pdp.concepts.PdpGroup;
import org.onap.policy.models.pdp.concepts.PdpGroupFilter;
@@ -267,6 +269,17 @@ public class DummyPolicyModelsProviderImpl implements PolicyModelsProvider {
// Not implemented
}
+ @Override
+ public void createAuditRecords(List<PolicyAudit> auditRecords) {
+ // Not implemented
+ }
+
+ @Override
+ public List<PolicyAudit> getAuditRecords(AuditFilter auditFilter, @NonNull Integer numRecords) {
+ // Not implemented
+ return new ArrayList<>();
+ }
+
/**
* Return a ToscaServicetemplate dummy response.
*