diff options
Diffstat (limited to 'models-provider/src/main')
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. * |