diff options
author | Liam Fallon <liam.fallon@est.tech> | 2020-12-23 18:28:33 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2020-12-23 18:28:33 +0000 |
commit | 8ad3f95cdcec48b8315a5febfd4ec07bae7aabba (patch) | |
tree | ec81ba946cee1c4c440abe04db9cf276c8eb36a9 /models-provider/src | |
parent | 7b5adac8cdcf61522644e201c50bb2ff6c4c72c8 (diff) | |
parent | b87e0242ce1a957740ee988bec3b82e3628adbed (diff) |
Merge "Add Service Template TOSCA handling"
Diffstat (limited to 'models-provider/src')
4 files changed, 156 insertions, 2 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 f2f7318e8..1e8fd24ff 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 @@ -35,6 +35,7 @@ import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyFilter; import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyType; import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyTypeFilter; import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate; +import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplateFilter; /** * This interface describes the operations that are provided to users and components for reading objects from and @@ -54,6 +55,58 @@ public interface PolicyModelsProvider extends AutoCloseable { public void close() throws PfModelException; /** + * Get service templates. + * + * @param name the name of the topology template to get, set to null to get all service templates + * @param version the version of the service template to get, set to null to get all service templates + * @return the topology templates found + * @throws PfModelException on errors getting service templates + */ + public List<ToscaServiceTemplate> getServiceTemplateList(final String name, final String version) + throws PfModelException; + + /** + * Get filtered service templates. + * + * @param filter the filter for the service templates to get + * @return the service templates found + * @throws PfModelException on errors getting service templates + */ + public List<ToscaServiceTemplate> getFilteredServiceTemplateList(@NonNull final ToscaServiceTemplateFilter filter) + throws PfModelException; + + /** + * Create service template. + * + * @param serviceTemplate the service template to be created + * @return the created service template + * @throws PfModelException on errors creating the service template + */ + public ToscaServiceTemplate createServiceTemplate(@NonNull final ToscaServiceTemplate serviceTemplate) + throws PfModelException; + + /** + * Update service template. + * + * @param serviceTemplate the service template to be updated + * @return the updated service template + * @throws PfModelException on errors updating the service template + */ + public ToscaServiceTemplate updateServiceTemplate(@NonNull final ToscaServiceTemplate serviceTemplate) + throws PfModelException; + + /** + * Delete service template. + * + * @param name the name of the service template to delete. + * @param version the version of the service template to delete. + * @return the TOSCA service template that was deleted + * @throws PfModelException on errors deleting policy types + */ + public ToscaServiceTemplate deleteServiceTemplate(@NonNull final String name, @NonNull final String version) + throws PfModelException; + + /** * Get policy types. * * @param name the name of the policy type to get, set to null to get all policy types @@ -104,7 +157,7 @@ public interface PolicyModelsProvider extends AutoCloseable { throws PfModelException; /** - * Create policy types. + * Update policy types. * * @param serviceTemplate the service template containing the definition of the policy types to be modified * @return the TOSCA service template containing the modified policy types @@ -119,7 +172,7 @@ public interface PolicyModelsProvider extends AutoCloseable { * @param name the name of the policy type to delete. * @param version the version of the policy type to delete. * @return the TOSCA service template containing the policy type that was deleted - * @throws PfModelException on errors deleting policy types + * @throws PfModelException on errors deleting the policy type */ public ToscaServiceTemplate deletePolicyType(@NonNull final String name, @NonNull final String version) throws PfModelException; 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 e27b9a43c..29b2d70b0 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 @@ -50,6 +50,7 @@ import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyType; import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyTypeFilter; import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyTypeIdentifier; import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate; +import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplateFilter; import org.onap.policy.models.tosca.authorative.provider.AuthorativeToscaProvider; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -131,6 +132,43 @@ public class DatabasePolicyModelsProviderImpl implements PolicyModelsProvider { } @Override + public List<ToscaServiceTemplate> getServiceTemplateList(final String name, final String version) + throws PfModelException { + assertInitialized(); + return new AuthorativeToscaProvider().getServiceTemplateList(pfDao, name, version); + } + + + @Override + public List<ToscaServiceTemplate> getFilteredServiceTemplateList(@NonNull ToscaServiceTemplateFilter filter) + throws PfModelException { + assertInitialized(); + return new AuthorativeToscaProvider().getFilteredServiceTemplateList(pfDao, filter); + } + + @Override + public ToscaServiceTemplate createServiceTemplate(@NonNull final ToscaServiceTemplate serviceTemplate) + throws PfModelException { + assertInitialized(); + return new AuthorativeToscaProvider().createServiceTemplate(pfDao, serviceTemplate); + } + + @Override + public ToscaServiceTemplate updateServiceTemplate(@NonNull final ToscaServiceTemplate serviceTemplate) + throws PfModelException { + assertInitialized(); + return new AuthorativeToscaProvider().updateServiceTemplate(pfDao, serviceTemplate); + } + + @Override + public ToscaServiceTemplate deleteServiceTemplate(@NonNull final String name, @NonNull final String version) + throws PfModelException { + assertInitialized(); + + return new AuthorativeToscaProvider().deleteServiceTemplate(pfDao, name, version); + } + + @Override public ToscaServiceTemplate getPolicyTypes(final String name, final String version) throws PfModelException { assertInitialized(); return new AuthorativeToscaProvider().getPolicyTypes(pfDao, name, version); 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 16f5a2b74..1d892272c 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 @@ -26,6 +26,7 @@ import java.util.ArrayList; import java.util.Date; import java.util.List; import javax.ws.rs.core.Response; +import lombok.NonNull; import org.onap.policy.common.utils.coder.StandardCoder; import org.onap.policy.common.utils.resources.ResourceUtils; import org.onap.policy.models.base.PfModelException; @@ -42,6 +43,7 @@ import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyFilter; import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyType; import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyTypeFilter; import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate; +import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplateFilter; /** * This class provides a dummy implementation of the Policy Models Provider for the ONAP Policy Framework. @@ -69,6 +71,36 @@ public class DummyPolicyModelsProviderImpl implements PolicyModelsProvider { // Not required on the dummy provider } + + @Override + public List<ToscaServiceTemplate> getServiceTemplateList(String name, String version) throws PfModelException { + return new ArrayList<>(); + } + + @Override + public List<ToscaServiceTemplate> getFilteredServiceTemplateList(@NonNull ToscaServiceTemplateFilter filter) + throws PfModelException { + return new ArrayList<>(); + } + + @Override + public ToscaServiceTemplate createServiceTemplate(@NonNull ToscaServiceTemplate serviceTemplate) + throws PfModelException { + return serviceTemplate; + } + + @Override + public ToscaServiceTemplate updateServiceTemplate(@NonNull ToscaServiceTemplate serviceTemplate) + throws PfModelException { + return serviceTemplate; + } + + @Override + public ToscaServiceTemplate deleteServiceTemplate(@NonNull String name, @NonNull String version) + throws PfModelException { + return getDummyResponse("dummyimpl/DummyToscaServiceTemplateDeleteResponse.json"); + } + @Override public ToscaServiceTemplate getPolicyTypes(final String name, final String version) throws PfModelException { return getDummyResponse("dummyimpl/DummyToscaPolicyTypeGetResponse.json"); diff --git a/models-provider/src/test/java/org/onap/policy/models/provider/impl/DummyBadProviderImpl.java b/models-provider/src/test/java/org/onap/policy/models/provider/impl/DummyBadProviderImpl.java index 453f86633..1158307b4 100644 --- a/models-provider/src/test/java/org/onap/policy/models/provider/impl/DummyBadProviderImpl.java +++ b/models-provider/src/test/java/org/onap/policy/models/provider/impl/DummyBadProviderImpl.java @@ -41,6 +41,7 @@ import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyFilter; import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyType; import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyTypeFilter; import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate; +import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplateFilter; /** * Dummy implementation of {@link PolicyModelsProvider} with bad constructor. @@ -63,6 +64,30 @@ public class DummyBadProviderImpl implements PolicyModelsProvider { } @Override + public List<ToscaServiceTemplate> getFilteredServiceTemplateList(@NonNull ToscaServiceTemplateFilter filter) + throws PfModelException { + return null; + } + + @Override + public ToscaServiceTemplate createServiceTemplate(@NonNull ToscaServiceTemplate serviceTemplate) + throws PfModelException { + return null; + } + + @Override + public ToscaServiceTemplate updateServiceTemplate(@NonNull ToscaServiceTemplate serviceTemplate) + throws PfModelException { + return null; + } + + @Override + public ToscaServiceTemplate deleteServiceTemplate(@NonNull String name, @NonNull String version) + throws PfModelException { + return null; + } + + @Override public ToscaServiceTemplate getPolicyTypes(final String name, final String version) throws PfModelException { return null; } @@ -203,4 +228,10 @@ public class DummyBadProviderImpl implements PolicyModelsProvider { // Not implemented return null; } + + @Override + public List<ToscaServiceTemplate> getServiceTemplateList(String name, String version) throws PfModelException { + // TODO Auto-generated method stub + return null; + } } |