From f69b6681486e4d1c5859f649a3293488c1859712 Mon Sep 17 00:00:00 2001 From: liamfallon Date: Tue, 7 Jan 2020 10:24:12 +0000 Subject: 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 --- .../impl/DatabasePolicyModelsProviderImpl.java | 19 +++++++++---------- .../provider/impl/DummyPolicyModelsProviderImpl.java | 4 +++- 2 files changed, 12 insertions(+), 11 deletions(-) (limited to 'models-provider/src/main/java') 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 createGuardPolicy( - @NonNull final LegacyGuardPolicyInput legacyGuardPolicy) throws PfModelException { + public Map + createGuardPolicy(@NonNull final LegacyGuardPolicyInput legacyGuardPolicy) throws PfModelException { assertInitialized(); return new LegacyProvider().createGuardPolicy(pfDao, legacyGuardPolicy); } @Override - public Map updateGuardPolicy( - @NonNull final LegacyGuardPolicyInput legacyGuardPolicy) throws PfModelException { + public Map + 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 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 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; -- cgit 1.2.3-korg