summaryrefslogtreecommitdiffstats
path: root/models-provider/src/main
diff options
context:
space:
mode:
authorliamfallon <liam.fallon@est.tech>2020-01-07 10:24:12 +0000
committerliamfallon <liam.fallon@est.tech>2020-01-07 14:45:06 +0000
commitf69b6681486e4d1c5859f649a3293488c1859712 (patch)
tree92664e117820ab4a4cdfdc0b5694388e39752724 /models-provider/src/main
parent4fab7a327737ebdfaf7b55c39c49f0239ff627c8 (diff)
Support persistence of data types
Data types must be persisted to the database in order for them to be retrieved in policy type queries and later for policy validation. Issue-ID: POLICY-2315 Change-Id: Iacb88501a597aeee8f6d8bcc3d9604c13dc09090 Signed-off-by: liamfallon <liam.fallon@est.tech>
Diffstat (limited to 'models-provider/src/main')
-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.java4
2 files changed, 12 insertions, 11 deletions
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 1ac24585f..d154910bb 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
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2019 Nordix Foundation.
+ * Copyright (C) 2019-2020 Nordix Foundation.
* Modifications Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -26,8 +26,11 @@ import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.Properties;
+
import javax.ws.rs.core.Response;
+
import lombok.NonNull;
+
import org.eclipse.persistence.config.PersistenceUnitProperties;
import org.onap.policy.models.base.PfModelException;
import org.onap.policy.models.base.PfModelRuntimeException;
@@ -65,7 +68,7 @@ import org.slf4j.LoggerFactory;
*/
public class DatabasePolicyModelsProviderImpl implements PolicyModelsProvider {
- private static final Logger LOGGER = LoggerFactory.getLogger(DefaultPfDao.class);
+ private static final Logger LOGGER = LoggerFactory.getLogger(DatabasePolicyModelsProviderImpl.class);
private final PolicyModelsProviderParameters parameters;
@@ -116,7 +119,6 @@ public class DatabasePolicyModelsProviderImpl implements PolicyModelsProvider {
} catch (Exception exc) {
String errorMessage = "could not create Data Access Object (DAO) using url \"" + parameters.getDatabaseUrl()
+ "\" and persistence unit \"" + parameters.getPersistenceUnit() + "\"";
- LOGGER.warn(errorMessage, exc);
this.close();
throw new PfModelException(Response.Status.NOT_ACCEPTABLE, errorMessage, exc);
@@ -207,7 +209,6 @@ public class DatabasePolicyModelsProviderImpl implements PolicyModelsProvider {
return new AuthorativeToscaProvider().getFilteredPolicyList(pfDao, filter);
}
-
@Override
public ToscaServiceTemplate createPolicies(@NonNull final ToscaServiceTemplate serviceTemplate)
throws PfModelException {
@@ -265,15 +266,15 @@ public class DatabasePolicyModelsProviderImpl implements PolicyModelsProvider {
}
@Override
- public Map<String, LegacyGuardPolicyOutput> createGuardPolicy(
- @NonNull final LegacyGuardPolicyInput legacyGuardPolicy) throws PfModelException {
+ public Map<String, LegacyGuardPolicyOutput>
+ createGuardPolicy(@NonNull final LegacyGuardPolicyInput legacyGuardPolicy) throws PfModelException {
assertInitialized();
return new LegacyProvider().createGuardPolicy(pfDao, legacyGuardPolicy);
}
@Override
- public Map<String, LegacyGuardPolicyOutput> updateGuardPolicy(
- @NonNull final LegacyGuardPolicyInput legacyGuardPolicy) throws PfModelException {
+ public Map<String, LegacyGuardPolicyOutput>
+ updateGuardPolicy(@NonNull final LegacyGuardPolicyInput legacyGuardPolicy) throws PfModelException {
assertInitialized();
return new LegacyProvider().updateGuardPolicy(pfDao, legacyGuardPolicy);
}
@@ -291,7 +292,6 @@ public class DatabasePolicyModelsProviderImpl implements PolicyModelsProvider {
return new PdpProvider().getPdpGroups(pfDao, name);
}
-
@Override
public List<PdpGroup> getFilteredPdpGroups(@NonNull PdpGroupFilter filter) throws PfModelException {
assertInitialized();
@@ -357,7 +357,6 @@ public class DatabasePolicyModelsProviderImpl implements PolicyModelsProvider {
return new PdpStatisticsProvider().updatePdpStatistics(pfDao, pdpStatisticsList);
}
-
@Override
public List<PdpStatistics> deletePdpStatistics(@NonNull final String name, final Date timestamp)
throws PfModelException {
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 2c88bcacd..c0a6e2c2a 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
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2019 Nordix Foundation.
+ * Copyright (C) 2019-2020 Nordix Foundation.
* Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -26,7 +26,9 @@ import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+
import javax.ws.rs.core.Response;
+
import org.onap.policy.common.utils.coder.StandardCoder;
import org.onap.policy.common.utils.resources.ResourceUtils;
import org.onap.policy.models.base.PfModelException;