package org.onap.policy.models.pdp.persistence.provider;
+import java.util.ArrayList;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+
import lombok.NonNull;
+import org.apache.commons.lang3.tuple.Pair;
import org.onap.policy.models.base.PfModelException;
import org.onap.policy.models.dao.PfDao;
+import org.onap.policy.models.pdp.concepts.PdpGroup;
import org.onap.policy.models.pdp.concepts.PdpGroups;
+import org.onap.policy.models.pdp.concepts.PdpStatistics;
+import org.onap.policy.models.pdp.concepts.PdpSubGroup;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicy;
/**
* This class provides the provision of information on PAP concepts in the database to callers.
* Get PDP groups.
*
* @param dao the DAO to use to access the database
- * @param pdpGroupFilter a filter for the get
+ * @param name the name of the policy to get, null to get all PDP groups
+ * @param version the version of the policy to get, null to get all versions of a PDP group
* @return the PDP groups found
* @throws PfModelException on errors getting PDP groups
*/
- public PdpGroups getPdpGroups(@NonNull final PfDao dao, @NonNull final String pdpGroupFilter)
+ public PdpGroups getPdpGroups(@NonNull final PfDao dao, final String name, final String version)
throws PfModelException {
return new PdpGroups();
}
+ /**
+ * Get latest PDP Groups.
+ *
+ * @param dao the DAO to use to access the database
+ * @param name the name of the PDP group to get, null to get all PDP groups
+ * @return the PDP groups found
+ * @throws PfModelException on errors getting policies
+ */
+ public PdpGroups getLatestPdpGroups(@NonNull final PfDao dao, final String name) throws PfModelException {
+ return new PdpGroups();
+ }
+
+ /**
+ * Get a filtered list of PDP groups.
+ *
+ * @param dao the DAO to use to access the database
+ * @param pdpType The PDP type filter for the returned PDP groups
+ * @param supportedPolicyTypes a list of policy type name/version pairs that the PDP groups must support.
+ * @return the PDP groups found
+ */
+ public PdpGroups getFilteredPdpGroups(@NonNull final PfDao dao, @NonNull final String pdpType,
+ @NonNull final List<Pair<String, String>> supportedPolicyTypes) {
+ return new PdpGroups();
+ }
+
/**
* Creates PDP groups.
*
return new PdpGroups();
}
+
+ /**
+ * Update a PDP subgroup.
+ *
+ * @param dao the DAO to use to access the database
+ * @param pdpGroupName the name of the PDP group of the PDP subgroup
+ * @param pdpGroupVersion the version of the PDP group of the PDP subgroup
+ * @param pdpSubGroup the PDP subgroup to be updated
+ * @throws PfModelException on errors updating PDP subgroups
+ */
+ public void updatePdpSubGroup(@NonNull final PfDao dao, @NonNull final String pdpGroupName,
+ @NonNull final String pdpGroupVersion, @NonNull final PdpSubGroup pdpSubGroup) throws PfModelException {
+ // Not implemented yet
+ }
+
/**
- * Delete PDP groups.
+ * Delete a PDP group.
*
* @param dao the DAO to use to access the database
- * @param pdpGroupFilter a filter for the get
- * @return the PDP groups deleted
+ * @param name the name of the policy to get, null to get all PDP groups
+ * @param version the version of the policy to get, null to get all versions of a PDP group
+ * @return the PDP group deleted
* @throws PfModelException on errors deleting PDP groups
*/
- public PdpGroups deletePdpGroups(@NonNull final PfDao dao, @NonNull final String pdpGroupFilter)
+ public PdpGroup deletePdpGroup(@NonNull final PfDao dao, @NonNull final String name, @NonNull final String version)
throws PfModelException {
- return new PdpGroups();
+ return new PdpGroup();
+
+ }
+
+ /**
+ * Get PDP statistics.
+ *
+ * @param dao the DAO to use to access the database
+ * @param name the name of the PDP group to get statistics for, null to get all PDP groups
+ * @param version the version of the PDP group to get statistics for, null to get all versions of a PDP group
+ * @return the statistics found
+ * @throws PfModelException on errors getting statistics
+ */
+ public List<PdpStatistics> getPdpStatistics(@NonNull final PfDao dao, final String name, final String version)
+ throws PfModelException {
+ return new ArrayList<>();
+ }
+
+ /**
+ * Update PDP statistics for a PDP.
+ *
+ * @param dao the DAO to use to access the database
+ * @param pdpGroupName the name of the PDP group containing the PDP that the statistics are for
+ * @param pdpGroupVersion the version of the PDP group containing the PDP that the statistics are for
+ * @param pdpType the PDP type of the subgroup containing the PDP that the statistics are for
+ * @param pdpInstanceId the instance ID of the PDP to update statistics for
+ * @throws PfModelException on errors updating statistics
+ */
+ public void updatePdpStatistics(@NonNull final PfDao dao, @NonNull final String pdpGroupName,
+ @NonNull final String pdpGroupVersion, @NonNull final String pdpType, @NonNull final String pdpInstanceId,
+ @NonNull final PdpStatistics pdppStatistics) throws PfModelException {
+ // Not implemented yet
+ }
+
+ /**
+ * Get deployed policies.
+ *
+ * @param dao the DAO to use to access the database
+ * @param name the name of the policy to get, null to get all policies
+ * @return the policies deployed as a map of policy lists keyed by PDP group
+ * @throws PfModelException on errors getting policies
+ */
+ public Map<PdpGroup, List<ToscaPolicy>> getDeployedPolicyList(@NonNull final PfDao dao, final String name)
+ throws PfModelException {
+ return new LinkedHashMap<>();
}
}
package org.onap.policy.models.provider;
+import java.util.List;
import java.util.Map;
import lombok.NonNull;
+import org.apache.commons.lang3.tuple.Pair;
import org.onap.policy.models.base.PfModelException;
+import org.onap.policy.models.pdp.concepts.PdpGroup;
import org.onap.policy.models.pdp.concepts.PdpGroups;
+import org.onap.policy.models.pdp.concepts.PdpStatistics;
+import org.onap.policy.models.pdp.concepts.PdpSubGroup;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicy;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyType;
import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;
import org.onap.policy.models.tosca.legacy.concepts.LegacyGuardPolicyInput;
import org.onap.policy.models.tosca.legacy.concepts.LegacyGuardPolicyOutput;
/**
* Get policy types.
*
- * @param name the name of the policy type to get.
- * @param version the version of the policy type to get.
+ * @param name the name of the policy type to get, set to null to get all policy types
+ * @param version the version of the policy type to get, set to null to get all versions
* @return the policy types found
* @throws PfModelException on errors getting policy types
*/
- public ToscaServiceTemplate getPolicyTypes(@NonNull final String name, @NonNull final String version)
- throws PfModelException;
+ public ToscaServiceTemplate getPolicyTypes(final String name, 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
+ * @param version the version of the policy type to get, set to null to get all versions
+ * @return the policy types found
+ * @throws PfModelException on errors getting policy types
+ */
+ public List<ToscaPolicyType> getPolicyTypeList(final String name, final String version) throws PfModelException;
+
+ /**
+ * Get latest policy types.
+ *
+ * @param name the name of the policy type to get, set to null to get all policy types
+ * @return the policy types found
+ * @throws PfModelException on errors getting policy types
+ */
+ public ToscaServiceTemplate getLatestPolicyTypes(final String name) throws PfModelException;
+
+ /**
+ * Get latest policy types.
+ *
+ * @param name the name of the policy type to get, set to null to get all policy types
+ * @return the policy types found
+ * @throws PfModelException on errors getting policy types
+ */
+ public List<ToscaPolicyType> getLatestPolicyTypeList(final String name) throws PfModelException;
/**
* Create policy types.
throws PfModelException;
/**
- * Delete policy types.
+ * Delete policy type.
*
* @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 types that were deleted
+ * @return the TOSCA service template containing the policy type that was deleted
* @throws PfModelException on errors deleting policy types
*/
- public ToscaServiceTemplate deletePolicyTypes(@NonNull final String name, @NonNull final String version)
+ public ToscaServiceTemplate deletePolicyType(@NonNull final String name, @NonNull final String version)
throws PfModelException;
/**
* Get policies.
*
- * @param name the name of the policy to get.
- * @param version the version of the policy to get.
+ * @param name the name of the policy to get, null to get all policies
+ * @param version the version of the policy to get, null to get all versions of a policy
* @return the policies found
* @throws PfModelException on errors getting policies
*/
- public ToscaServiceTemplate getPolicies(@NonNull final String name, @NonNull final String version)
- throws PfModelException;
+ public ToscaServiceTemplate getPolicies(final String name, final String version) throws PfModelException;
+
+ /**
+ * Get policies.
+ *
+ * @param name the name of the policy to get, null to get all policies
+ * @param version the version of the policy to get, null to get all versions of a policy
+ * @return the policies found
+ * @throws PfModelException on errors getting policies
+ */
+ public List<ToscaPolicy> getPolicyList(final String name, final String version) throws PfModelException;
+
+ /**
+ * Get policies for a policy type name.
+ *
+ * @param policyTypeName the name of the policy type for which to get policies
+ * @return the policies found
+ * @throws PfModelException on errors getting policies
+ */
+ public List<ToscaPolicy> getPolicyList4PolicyType(@NonNull final String policyTypeName) throws PfModelException;
+
+ /**
+ * Get latest policies.
+ *
+ * @param name the name of the policy to get, null to get all policies
+ * @return the policies found
+ * @throws PfModelException on errors getting policies
+ */
+ public ToscaServiceTemplate getLatestPolicies(final String name) throws PfModelException;
+
+ /**
+ * Get latest policies.
+ *
+ * @param name the name of the policy to get, null to get all policies
+ * @return the policies found
+ * @throws PfModelException on errors getting policies
+ */
+ public List<ToscaPolicy> getLatestPolicyList(final String name) throws PfModelException;
/**
* Create policies.
public ToscaServiceTemplate createPolicies(@NonNull final ToscaServiceTemplate serviceTemplate)
throws PfModelException;
-
/**
* Update policies.
*
throws PfModelException;
/**
- * Delete policies.
+ * Delete policy.
*
* @param name the name of the policy to delete.
* @param version the version of the policy to delete.
- * @return the TOSCA service template containing the policy types that were deleted
- * @throws PfModelException on errors deleting policies
+ * @return the TOSCA service template containing the policy that was deleted
+ * @throws PfModelException on errors deleting a policy
*/
- public ToscaServiceTemplate deletePolicies(@NonNull final String name, @NonNull final String version)
+ public ToscaServiceTemplate deletePolicy(@NonNull final String name, @NonNull final String version)
throws PfModelException;
/**
/**
* Get PDP groups.
*
- * @param pdpGroupFilter a filter for the get
+ * @param name the name of the policy to get, null to get all PDP groups
+ * @param version the version of the policy to get, null to get all versions of a PDP group
* @return the PDP groups found
* @throws PfModelException on errors getting PDP groups
*/
- public PdpGroups getPdpGroups(@NonNull final String pdpGroupFilter) throws PfModelException;
+ public PdpGroups getPdpGroups(final String name, final String version) throws PfModelException;
+
+ /**
+ * Get latest PDP Groups.
+ *
+ * @param name the name of the PDP group to get, null to get all PDP groups
+ * @return the PDP groups found
+ * @throws PfModelException on errors getting policies
+ */
+ public PdpGroups getLatestPdpGroups(final String name) throws PfModelException;
+
+ /**
+ * Get a filtered list of PDP groups.
+ *
+ * @param pdpType The PDP type filter for the returned PDP groups
+ * @param supportedPolicyTypes a list of policy type name/version pairs that the PDP groups must support.
+ * @return the PDP groups found
+ */
+ public PdpGroups getFilteredPdpGroups(@NonNull final String pdpType,
+ @NonNull final List<Pair<String, String>> supportedPolicyTypes);
/**
* Creates PDP groups.
*/
public PdpGroups updatePdpGroups(@NonNull final PdpGroups pdpGroups) throws PfModelException;
+
+ /**
+ * Update a PDP subgroup.
+ *
+ * @param pdpGroupName the name of the PDP group of the PDP subgroup
+ * @param pdpGroupVersion the version of the PDP group of the PDP subgroup
+ * @param pdpSubGroup the PDP subgroup to be updated
+ * @throws PfModelException on errors updating PDP subgroups
+ */
+ public void updatePdpSubGroup(@NonNull final String pdpGroupName, @NonNull final String pdpGroupVersion,
+ @NonNull final PdpSubGroup pdpSubGroup) throws PfModelException;
+
/**
- * Delete PDP groups.
+ * Delete a PDP group.
*
- * @param pdpGroupFilter a filter for the get
- * @return the PDP groups deleted
+ * @param name the name of the policy to get, null to get all PDP groups
+ * @param version the version of the policy to get, null to get all versions of a PDP group
+ * @return the PDP group deleted
* @throws PfModelException on errors deleting PDP groups
*/
- public PdpGroups deletePdpGroups(@NonNull final String pdpGroupFilter) throws PfModelException;
+ public PdpGroup deletePdpGroup(@NonNull final String name, @NonNull final String version) throws PfModelException;
+
+ /**
+ * Get PDP statistics.
+ *
+ * @param name the name of the PDP group to get statistics for, null to get all PDP groups
+ * @param version the version of the PDP group to get statistics for, null to get all versions of a PDP group
+ * @return the statistics found
+ * @throws PfModelException on errors getting statistics
+ */
+ public List<PdpStatistics> getPdpStatistics(final String name, final String version) throws PfModelException;
+
+ /**
+ * Update PDP statistics for a PDP.
+ *
+ * @param pdpGroupName the name of the PDP group containing the PDP that the statistics are for
+ * @param pdpGroupVersion the version of the PDP group containing the PDP that the statistics are for
+ * @param pdpType the PDP type of the subgroup containing the PDP that the statistics are for
+ * @param pdpInstanceId the instance ID of the PDP to update statistics for
+ * @throws PfModelException on errors updating statistics
+ */
+ public void updatePdpStatistics(@NonNull final String pdpGroupName, @NonNull final String pdpGroupVersion,
+ @NonNull final String pdpType, @NonNull final String pdpInstanceId,
+ @NonNull final PdpStatistics pdppStatistics) throws PfModelException;
+
+ /**
+ * Get deployed policies.
+ *
+ * @param name the name of the policy to get, null to get all policies
+ * @return the policies deployed as a map of policy lists keyed by PDP group
+ * @throws PfModelException on errors getting policies
+ */
+ public Map<PdpGroup, List<ToscaPolicy>> getDeployedPolicyList(final String name) throws PfModelException;
}
import java.sql.Connection;
import java.sql.DriverManager;
import java.util.Base64;
+import java.util.List;
import java.util.Map;
import javax.ws.rs.core.Response;
import lombok.NonNull;
+import org.apache.commons.lang3.tuple.Pair;
import org.onap.policy.models.base.PfModelException;
import org.onap.policy.models.base.PfModelRuntimeException;
import org.onap.policy.models.dao.DaoParameters;
import org.onap.policy.models.dao.PfDao;
import org.onap.policy.models.dao.PfDaoFactory;
import org.onap.policy.models.dao.impl.DefaultPfDao;
+import org.onap.policy.models.pdp.concepts.PdpGroup;
import org.onap.policy.models.pdp.concepts.PdpGroups;
+import org.onap.policy.models.pdp.concepts.PdpStatistics;
+import org.onap.policy.models.pdp.concepts.PdpSubGroup;
import org.onap.policy.models.pdp.persistence.provider.PdpProvider;
import org.onap.policy.models.provider.PolicyModelsProvider;
import org.onap.policy.models.provider.PolicyModelsProviderParameters;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicy;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyType;
import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;
import org.onap.policy.models.tosca.authorative.provider.AuthorativeToscaProvider;
import org.onap.policy.models.tosca.legacy.concepts.LegacyGuardPolicyInput;
}
@Override
- public ToscaServiceTemplate getPolicyTypes(@NonNull final String name, @NonNull final String version)
- throws PfModelException {
+ public ToscaServiceTemplate getPolicyTypes(final String name, final String version) throws PfModelException {
assertInitilized();
return new AuthorativeToscaProvider().getPolicyTypes(pfDao, name, version);
}
+ @Override
+ public List<ToscaPolicyType> getPolicyTypeList(final String name, final String version) throws PfModelException {
+ assertInitilized();
+ return new AuthorativeToscaProvider().getPolicyTypeList(pfDao, name, version);
+ }
+
+ @Override
+ public ToscaServiceTemplate getLatestPolicyTypes(final String name) throws PfModelException {
+ assertInitilized();
+ return new AuthorativeToscaProvider().getLatestPolicyTypes(pfDao, name);
+ }
+
+ @Override
+ public List<ToscaPolicyType> getLatestPolicyTypeList(final String name) throws PfModelException {
+ assertInitilized();
+ return new AuthorativeToscaProvider().getLatestPolicyTypeList(pfDao, name);
+ }
+
@Override
public ToscaServiceTemplate createPolicyTypes(@NonNull final ToscaServiceTemplate serviceTemplate)
throws PfModelException {
}
@Override
- public ToscaServiceTemplate deletePolicyTypes(@NonNull final String name, @NonNull final String version)
+ public ToscaServiceTemplate deletePolicyType(@NonNull final String name, @NonNull final String version)
throws PfModelException {
assertInitilized();
- return new AuthorativeToscaProvider().deletePolicyTypes(pfDao, name, version);
+ return new AuthorativeToscaProvider().deletePolicyType(pfDao, name, version);
}
@Override
- public ToscaServiceTemplate getPolicies(@NonNull final String name, @NonNull final String version)
- throws PfModelException {
+ public ToscaServiceTemplate getPolicies(final String name, final String version) throws PfModelException {
assertInitilized();
return new AuthorativeToscaProvider().getPolicies(pfDao, name, version);
}
+ @Override
+ public List<ToscaPolicy> getPolicyList(final String name, final String version) throws PfModelException {
+ assertInitilized();
+ return new AuthorativeToscaProvider().getPolicyList(pfDao, name, version);
+ }
+
+ @Override
+ public List<ToscaPolicy> getPolicyList4PolicyType(@NonNull final String policyTypeName) throws PfModelException {
+ assertInitilized();
+ return new AuthorativeToscaProvider().getPolicyList4PolicyType(pfDao, policyTypeName);
+ }
+
+ @Override
+ public ToscaServiceTemplate getLatestPolicies(final String name) throws PfModelException {
+ assertInitilized();
+ return new AuthorativeToscaProvider().getLatestPolicies(pfDao, name);
+ }
+
+ @Override
+ public List<ToscaPolicy> getLatestPolicyList(final String name) throws PfModelException {
+ assertInitilized();
+ return new AuthorativeToscaProvider().getLatestPolicyList(pfDao, name);
+ }
+
@Override
public ToscaServiceTemplate createPolicies(@NonNull final ToscaServiceTemplate serviceTemplate)
throws PfModelException {
}
@Override
- public ToscaServiceTemplate deletePolicies(@NonNull final String name, @NonNull final String version)
+ public ToscaServiceTemplate deletePolicy(@NonNull final String name, @NonNull final String version)
throws PfModelException {
assertInitilized();
- return new AuthorativeToscaProvider().deletePolicies(pfDao, name, version);
+ return new AuthorativeToscaProvider().deletePolicy(pfDao, name, version);
}
@Override
}
@Override
- public PdpGroups getPdpGroups(@NonNull String pdpGroupFilter) throws PfModelException {
+ public PdpGroups getPdpGroups(final String name, final String version) throws PfModelException {
+ assertInitilized();
+ return new PdpProvider().getPdpGroups(pfDao, name, version);
+ }
+
+ @Override
+ public PdpGroups getLatestPdpGroups(final String name) throws PfModelException {
assertInitilized();
- return new PdpProvider().getPdpGroups(pfDao, pdpGroupFilter);
+ return new PdpProvider().getLatestPdpGroups(pfDao, name);
}
@Override
- public PdpGroups createPdpGroups(@NonNull PdpGroups pdpGroups) throws PfModelException {
+ public PdpGroups getFilteredPdpGroups(@NonNull final String pdpType,
+ @NonNull final List<Pair<String, String>> supportedPolicyTypes) {
+ assertInitilized();
+ return new PdpProvider().getFilteredPdpGroups(pfDao, pdpType, supportedPolicyTypes);
+ }
+
+ @Override
+ public PdpGroups createPdpGroups(@NonNull final PdpGroups pdpGroups) throws PfModelException {
assertInitilized();
return new PdpProvider().createPdpGroups(pfDao, pdpGroups);
}
@Override
- public PdpGroups updatePdpGroups(@NonNull PdpGroups pdpGroups) throws PfModelException {
+ public PdpGroups updatePdpGroups(@NonNull final PdpGroups pdpGroups) throws PfModelException {
assertInitilized();
return new PdpProvider().updatePdpGroups(pfDao, pdpGroups);
}
@Override
- public PdpGroups deletePdpGroups(@NonNull String pdpGroupFilter) throws PfModelException {
+ public void updatePdpSubGroup(@NonNull final String pdpGroupName, @NonNull final String pdpGroupVersion,
+ @NonNull final PdpSubGroup pdpSubGroup) throws PfModelException {
+ assertInitilized();
+ new PdpProvider().updatePdpSubGroup(pfDao, pdpGroupName, pdpGroupVersion, pdpSubGroup);
+ }
+
+ @Override
+ public PdpGroup deletePdpGroup(@NonNull final String name, @NonNull final String version) throws PfModelException {
+ assertInitilized();
+ return new PdpProvider().deletePdpGroup(pfDao, name, version);
+ }
+
+ @Override
+ public List<PdpStatistics> getPdpStatistics(final String name, final String version) throws PfModelException {
+ assertInitilized();
+ return new PdpProvider().getPdpStatistics(pfDao, name, version);
+ }
+
+ @Override
+ public void updatePdpStatistics(@NonNull final String pdpGroupName, @NonNull final String pdpGroupVersion,
+ @NonNull final String pdpType, @NonNull final String pdpInstanceId,
+ @NonNull final PdpStatistics pdppStatistics) throws PfModelException {
+ assertInitilized();
+ new PdpProvider().updatePdpStatistics(pfDao, pdpGroupName, pdpGroupVersion, pdpType, pdpInstanceId,
+ pdppStatistics);
+ }
+
+ @Override
+ public Map<PdpGroup, List<ToscaPolicy>> getDeployedPolicyList(final String name) throws PfModelException {
assertInitilized();
- return new PdpProvider().deletePdpGroups(pfDao, pdpGroupFilter);
+ return new PdpProvider().getDeployedPolicyList(pfDao, name);
}
/**
package org.onap.policy.models.provider.impl;
+import java.util.ArrayList;
import java.util.HashMap;
+import java.util.List;
import java.util.Map;
import javax.ws.rs.core.Response;
import lombok.NonNull;
+import org.apache.commons.lang3.tuple.Pair;
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.pdp.concepts.PdpGroup;
import org.onap.policy.models.pdp.concepts.PdpGroups;
+import org.onap.policy.models.pdp.concepts.PdpStatistics;
+import org.onap.policy.models.pdp.concepts.PdpSubGroup;
import org.onap.policy.models.provider.PolicyModelsProvider;
import org.onap.policy.models.provider.PolicyModelsProviderParameters;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicy;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyType;
import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;
import org.onap.policy.models.tosca.legacy.concepts.LegacyGuardPolicyInput;
import org.onap.policy.models.tosca.legacy.concepts.LegacyGuardPolicyOutput;
}
@Override
- public ToscaServiceTemplate getPolicyTypes(@NonNull final String name, @NonNull final String version)
- throws PfModelException {
+ public ToscaServiceTemplate getPolicyTypes(final String name, final String version) throws PfModelException {
return getDummyResponse("dummyimpl/DummyToscaPolicyTypeGetResponse.json");
}
+ @Override
+ public List<ToscaPolicyType> getPolicyTypeList(final String name, final String version) throws PfModelException {
+ return new ArrayList<>();
+ }
+
+ @Override
+ public ToscaServiceTemplate getLatestPolicyTypes(final String name) throws PfModelException {
+ return null;
+ }
+
+ @Override
+ public List<ToscaPolicyType> getLatestPolicyTypeList(final String name) throws PfModelException {
+ return new ArrayList<>();
+ }
+
@Override
public ToscaServiceTemplate createPolicyTypes(@NonNull final ToscaServiceTemplate serviceTemplate)
throws PfModelException {
}
@Override
- public ToscaServiceTemplate deletePolicyTypes(@NonNull final String name, @NonNull final String version)
+ public ToscaServiceTemplate deletePolicyType(@NonNull final String name, @NonNull final String version)
throws PfModelException {
return getDummyResponse("dummyimpl/DummyToscaPolicyTypeDeleteResponse.json");
}
@Override
- public ToscaServiceTemplate getPolicies(@NonNull final String name, @NonNull final String version)
- throws PfModelException {
+ public ToscaServiceTemplate getPolicies(final String name, final String version) throws PfModelException {
return getDummyResponse("dummyimpl/DummyToscaPolicyGetResponse.json");
}
+ @Override
+ public List<ToscaPolicy> getPolicyList(final String name, final String version) throws PfModelException {
+ return new ArrayList<>();
+ }
+
+ @Override
+ public List<ToscaPolicy> getPolicyList4PolicyType(@NonNull final String policyTypeName) throws PfModelException {
+ return new ArrayList<>();
+ }
+
+ @Override
+ public ToscaServiceTemplate getLatestPolicies(final String name) throws PfModelException {
+ return null;
+ }
+
+ @Override
+ public List<ToscaPolicy> getLatestPolicyList(final String name) throws PfModelException {
+ return new ArrayList<>();
+ }
+
@Override
public ToscaServiceTemplate createPolicies(@NonNull final ToscaServiceTemplate serviceTemplate)
throws PfModelException {
}
@Override
- public ToscaServiceTemplate deletePolicies(@NonNull final String name, @NonNull final String version)
+ public ToscaServiceTemplate deletePolicy(@NonNull final String name, @NonNull final String version)
throws PfModelException {
return getDummyResponse("dummyimpl/DummyToscaPolicyDeleteResponse.json");
}
}
@Override
- public PdpGroups getPdpGroups(@NonNull String pdpGroupFilter) throws PfModelException {
- return new PdpGroups();
+ public PdpGroups getPdpGroups(final String name, final String version) throws PfModelException {
+ return null;
+ }
+
+ @Override
+ public PdpGroups getLatestPdpGroups(final String name) throws PfModelException {
+ return null;
+ }
+
+ @Override
+ public PdpGroups getFilteredPdpGroups(@NonNull final String pdpType,
+ @NonNull final List<Pair<String, String>> supportedPolicyTypes) {
+ return null;
+ }
+
+ @Override
+ public PdpGroups createPdpGroups(@NonNull final PdpGroups pdpGroups) throws PfModelException {
+ return null;
+ }
+
+ @Override
+ public PdpGroups updatePdpGroups(@NonNull final PdpGroups pdpGroups) throws PfModelException {
+ return null;
+ }
+
+ @Override
+ public void updatePdpSubGroup(@NonNull final String pdpGroupName, @NonNull final String pdpGroupVersion,
+ @NonNull final PdpSubGroup pdpSubGroup) throws PfModelException {
+ // Not implemented
+ }
+
+ @Override
+ public PdpGroup deletePdpGroup(@NonNull final String name, @NonNull final String version) throws PfModelException {
+ return null;
}
@Override
- public PdpGroups createPdpGroups(@NonNull PdpGroups pdpGroups) throws PfModelException {
- return new PdpGroups();
+ public List<PdpStatistics> getPdpStatistics(final String name, final String version) throws PfModelException {
+ return new ArrayList<>();
}
@Override
- public PdpGroups updatePdpGroups(@NonNull PdpGroups pdpGroups) throws PfModelException {
- return new PdpGroups();
+ public void updatePdpStatistics(@NonNull final String pdpGroupName, @NonNull final String pdpGroupVersion,
+ @NonNull final String pdpType, @NonNull final String pdpInstanceId,
+ @NonNull final PdpStatistics pdppStatistics) throws PfModelException {
+ // Not implemented
}
@Override
- public PdpGroups deletePdpGroups(@NonNull String pdpGroupFilter) throws PfModelException {
- return new PdpGroups();
+ public Map<PdpGroup, List<ToscaPolicy>> getDeployedPolicyList(final String name) throws PfModelException {
+ return null;
}
/**
}).hasMessage("serviceTemplate is marked @NonNull but is null");
assertThatThrownBy(() -> {
- databaseProvider.deletePolicyTypes(null, null);
+ databaseProvider.deletePolicyType(null, null);
}).hasMessage("name is marked @NonNull but is null");
assertThatThrownBy(() -> {
- databaseProvider.deletePolicyTypes("aaa", null);
+ databaseProvider.deletePolicyType("aaa", null);
}).hasMessage("version is marked @NonNull but is null");
assertThatThrownBy(() -> {
- databaseProvider.deletePolicyTypes(null, "aaa");
+ databaseProvider.deletePolicyType(null, "aaa");
}).hasMessage("name is marked @NonNull but is null");
assertThatThrownBy(() -> {
}).hasMessage("serviceTemplate is marked @NonNull but is null");
assertThatThrownBy(() -> {
- databaseProvider.deletePolicies(null, null);
+ databaseProvider.deletePolicy(null, null);
}).hasMessage("name is marked @NonNull but is null");
assertThatThrownBy(() -> {
- databaseProvider.deletePolicies(null, "aaa");
+ databaseProvider.deletePolicy(null, "aaa");
}).hasMessage("name is marked @NonNull but is null");
assertThatThrownBy(() -> {
- databaseProvider.deletePolicies("aaa", null);
+ databaseProvider.deletePolicy("aaa", null);
}).hasMessage("version is marked @NonNull but is null");
assertThatThrownBy(() -> {
databaseProvider.deleteGuardPolicy(null);
}).hasMessage("policyId is marked @NonNull but is null");
- assertThatThrownBy(() -> {
- databaseProvider.getPdpGroups(null);
- }).hasMessage("pdpGroupFilter is marked @NonNull but is null");
-
assertThatThrownBy(() -> {
databaseProvider.createPdpGroups(null);
}).hasMessage("pdpGroups is marked @NonNull but is null");
}).hasMessage("pdpGroups is marked @NonNull but is null");
assertThatThrownBy(() -> {
- databaseProvider.deletePdpGroups(null);
- }).hasMessage("pdpGroupFilter is marked @NonNull but is null");
+ databaseProvider.deletePdpGroup(null, null);
+ }).hasMessage("name is marked @NonNull but is null");
databaseProvider.close();
}).hasMessage("no policy types specified on service template");
assertThatThrownBy(() -> {
- databaseProvider.deletePolicyTypes("name", "version");
+ databaseProvider.deletePolicyType("name", "version");
}).hasMessage("policy type not found: name:version");
assertThatThrownBy(() -> {
}).hasMessage("topology template not specified on service template");
assertThatThrownBy(() -> {
- databaseProvider.deletePolicies("name", "version");
+ databaseProvider.deletePolicy("name", "version");
}).hasMessage("policy not found: name:version");
assertThatThrownBy(() -> {
databaseProvider.deleteGuardPolicy("policy_id");
}).hasMessage("no policy found for policy ID: policy_id");
- assertNotNull(databaseProvider.getPdpGroups("filter"));
+ assertNotNull(databaseProvider.getPdpGroups("name", "version"));
assertNotNull(databaseProvider.createPdpGroups(new PdpGroups()));
assertNotNull(databaseProvider.updatePdpGroups(new PdpGroups()));
- assertNotNull(databaseProvider.deletePdpGroups("filter"));
+ assertNotNull(databaseProvider.deletePdpGroup("name", "version"));
} catch (Exception exc) {
LOGGER.warn("test should not throw an exception", exc);
package org.onap.policy.models.provider.impl;
+import java.util.List;
import java.util.Map;
import javax.ws.rs.core.Response;
import lombok.NonNull;
+import org.apache.commons.lang3.tuple.Pair;
import org.onap.policy.models.base.PfModelException;
import org.onap.policy.models.base.PfModelRuntimeException;
+import org.onap.policy.models.pdp.concepts.PdpGroup;
import org.onap.policy.models.pdp.concepts.PdpGroups;
+import org.onap.policy.models.pdp.concepts.PdpStatistics;
+import org.onap.policy.models.pdp.concepts.PdpSubGroup;
import org.onap.policy.models.provider.PolicyModelsProvider;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicy;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyType;
import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;
import org.onap.policy.models.tosca.legacy.concepts.LegacyGuardPolicyInput;
import org.onap.policy.models.tosca.legacy.concepts.LegacyGuardPolicyOutput;
}
@Override
- public ToscaServiceTemplate deletePolicyTypes(final String name, final String version) throws PfModelException {
+ public ToscaServiceTemplate deletePolicyType(final String name, final String version) throws PfModelException {
return null;
}
}
@Override
- public ToscaServiceTemplate deletePolicies(final String name, final String version) throws PfModelException {
+ public ToscaServiceTemplate deletePolicy(final String name, final String version) throws PfModelException {
return null;
}
}
@Override
- public PdpGroups getPdpGroups(@NonNull String pdpGroupFilter) throws PfModelException {
+ public PdpGroups getPdpGroups(String name, String version) throws PfModelException {
return null;
}
}
@Override
- public PdpGroups deletePdpGroups(@NonNull String pdpGroupFilter) throws PfModelException {
+ public PdpGroup deletePdpGroup(@NonNull String name, @NonNull String verison) throws PfModelException {
+ return null;
+ }
+
+ @Override
+ public List<ToscaPolicyType> getPolicyTypeList(String name, String version) throws PfModelException {
+ return null;
+ }
+
+ @Override
+ public ToscaServiceTemplate getLatestPolicyTypes(String name) throws PfModelException {
+ return null;
+ }
+
+ @Override
+ public List<ToscaPolicyType> getLatestPolicyTypeList(String name) throws PfModelException {
+ return null;
+ }
+
+ @Override
+ public List<ToscaPolicy> getPolicyList(String name, String version) throws PfModelException {
+ return null;
+ }
+
+ @Override
+ public List<ToscaPolicy> getPolicyList4PolicyType(@NonNull String policyTypeName) throws PfModelException {
+ return null;
+ }
+
+ @Override
+ public ToscaServiceTemplate getLatestPolicies(String name) throws PfModelException {
+ return null;
+ }
+
+ @Override
+ public List<ToscaPolicy> getLatestPolicyList(String name) throws PfModelException {
+ return null;
+ }
+
+ @Override
+ public PdpGroups getLatestPdpGroups(String name) throws PfModelException {
+ return null;
+ }
+
+ @Override
+ public PdpGroups getFilteredPdpGroups(@NonNull String pdpType,
+ @NonNull List<Pair<String, String>> supportedPolicyTypes) {
+ return null;
+ }
+
+ @Override
+ public void updatePdpSubGroup(@NonNull String pdpGroupName, @NonNull String pdpGroupVersion,
+ @NonNull PdpSubGroup pdpSubGroup) throws PfModelException {
+ }
+
+ @Override
+ public List<PdpStatistics> getPdpStatistics(String name, String version) throws PfModelException {
+ return null;
+ }
+
+ @Override
+ public void updatePdpStatistics(@NonNull String pdpGroupName, @NonNull String pdpGroupVersion,
+ @NonNull String pdpType, @NonNull String pdpInstanceId, @NonNull PdpStatistics pdppStatistics) {
+ }
+
+ @Override
+ public Map<PdpGroup, List<ToscaPolicy>> getDeployedPolicyList(String name) throws PfModelException {
return null;
}
}
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
import static org.junit.Assert.fail;
import org.junit.Test;
assertNotNull(dummyProvider.getPolicyTypes("name", "version"));
assertNotNull(dummyProvider.createPolicyTypes(new ToscaServiceTemplate()));
assertNotNull(dummyProvider.updatePolicyTypes(new ToscaServiceTemplate()));
- assertNotNull(dummyProvider.deletePolicyTypes("name", "version"));
+ assertNotNull(dummyProvider.deletePolicyType("name", "version"));
assertNotNull(dummyProvider.getPolicies("name", "version"));
assertNotNull(dummyProvider.createPolicies(new ToscaServiceTemplate()));
assertNotNull(dummyProvider.updatePolicies(new ToscaServiceTemplate()));
- assertNotNull(dummyProvider.deletePolicies("name", "version"));
+ assertNotNull(dummyProvider.deletePolicy("name", "version"));
assertNotNull(dummyProvider.getOperationalPolicy("policy_id"));
assertNotNull(dummyProvider.createOperationalPolicy(new LegacyOperationalPolicy()));
assertNotNull(dummyProvider.updateGuardPolicy(new LegacyGuardPolicyInput()));
assertNotNull(dummyProvider.deleteGuardPolicy("policy_id"));
- assertNotNull(dummyProvider.getPdpGroups("filter"));
- assertNotNull(dummyProvider.createPdpGroups(new PdpGroups()));
- assertNotNull(dummyProvider.updatePdpGroups(new PdpGroups()));
- assertNotNull(dummyProvider.deletePdpGroups("filter"));
+ assertNull(dummyProvider.getPdpGroups("name", "version"));
+ assertNull(dummyProvider.createPdpGroups(new PdpGroups()));
+ assertNull(dummyProvider.updatePdpGroups(new PdpGroups()));
+ assertNull(dummyProvider.deletePdpGroup("name", "version"));
- assertThatThrownBy(() -> {
- dummyProvider.getPolicyTypes(null, null);
- }).hasMessage("name is marked @NonNull but is null");
- assertThatThrownBy(() -> {
- dummyProvider.createPolicyTypes(null);
- }).hasMessage("serviceTemplate is marked @NonNull but is null");
- assertThatThrownBy(() -> {
- dummyProvider.updatePolicyTypes(null);
- }).hasMessage("serviceTemplate is marked @NonNull but is null");
- assertThatThrownBy(() -> {
- dummyProvider.deletePolicyTypes(null, null);
- }).hasMessage("name is marked @NonNull but is null");
-
- assertThatThrownBy(() -> {
- dummyProvider.getPolicies(null, null);
- }).hasMessage("name is marked @NonNull but is null");
- assertThatThrownBy(() -> {
- dummyProvider.createPolicies(null);
- }).hasMessage("serviceTemplate is marked @NonNull but is null");
- assertThatThrownBy(() -> {
- dummyProvider.updatePolicies(null);
- }).hasMessage("serviceTemplate is marked @NonNull but is null");
- assertThatThrownBy(() -> {
- dummyProvider.deletePolicies(null, null);
- }).hasMessage("name is marked @NonNull but is null");
assertThatThrownBy(() -> {
dummyProvider.getOperationalPolicy(null);
dummyProvider.deleteGuardPolicy(null);
}).hasMessage("policyId is marked @NonNull but is null");
- assertThatThrownBy(() -> {
- dummyProvider.getPdpGroups(null);
- }).hasMessage("pdpGroupFilter is marked @NonNull but is null");
assertThatThrownBy(() -> {
dummyProvider.createPdpGroups(null);
}).hasMessage("pdpGroups is marked @NonNull but is null");
dummyProvider.updatePdpGroups(null);
}).hasMessage("pdpGroups is marked @NonNull but is null");
assertThatThrownBy(() -> {
- dummyProvider.deletePdpGroups(null);
- }).hasMessage("pdpGroupFilter is marked @NonNull but is null");
+ dummyProvider.deletePdpGroup(null, null);
+ }).hasMessage("name is marked @NonNull but is null");
dummyProvider.close();
}
package org.onap.policy.models.tosca.authorative.provider;
+import java.util.ArrayList;
+import java.util.List;
+
import lombok.NonNull;
import org.onap.policy.models.base.PfConceptKey;
import org.onap.policy.models.base.PfModelException;
import org.onap.policy.models.dao.PfDao;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicy;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyType;
import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;
import org.onap.policy.models.tosca.simple.concepts.JpaToscaServiceTemplate;
import org.onap.policy.models.tosca.simple.provider.SimpleToscaProvider;
* @return the policy types found
* @throws PfModelException on errors getting policy types
*/
- public ToscaServiceTemplate getPolicyTypes(@NonNull final PfDao dao, @NonNull final String name,
- @NonNull final String version) throws PfModelException {
+ public ToscaServiceTemplate getPolicyTypes(@NonNull final PfDao dao, final String name, final String version)
+ throws PfModelException {
return new SimpleToscaProvider().getPolicyTypes(dao, new PfConceptKey(name, version)).toAuthorative();
}
+ /**
+ * Get policy types.
+ *
+ * @param dao the DAO to use to access the database
+ * @param name the name of the policy type to get, set to null to get all policy types
+ * @param version the version of the policy type to get, set to null to get all versions
+ * @return the policy types found
+ * @throws PfModelException on errors getting policy types
+ */
+ public List<ToscaPolicyType> getPolicyTypeList(@NonNull final PfDao dao, final String name, final String version)
+ throws PfModelException {
+ return new ArrayList<>();
+ }
+
+ /**
+ * Get latest policy types.
+ *
+ * @param dao the DAO to use to access the database
+ * @param name the name of the policy type to get, set to null to get all policy types
+ * @return the policy types found
+ * @throws PfModelException on errors getting policy types
+ */
+ public ToscaServiceTemplate getLatestPolicyTypes(@NonNull final PfDao dao, final String name)
+ throws PfModelException {
+ return null;
+ }
+
+ /**
+ * Get latest policy types.
+ *
+ * @param dao the DAO to use to access the database
+ * @param name the name of the policy type to get, set to null to get all policy types
+ * @return the policy types found
+ * @throws PfModelException on errors getting policy types
+ */
+ public List<ToscaPolicyType> getLatestPolicyTypeList(@NonNull final PfDao dao, final String name)
+ throws PfModelException {
+ return new ArrayList<>();
+ }
+
/**
* Create policy types.
*
}
/**
- * Delete policy types.
+ * Delete policy type.
*
* @param dao the DAO to use to access the database
* @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 types that were deleted
+ * @return the TOSCA service template containing the policy type that was deleted
* @throws PfModelException on errors deleting policy types
*/
- public ToscaServiceTemplate deletePolicyTypes(@NonNull final PfDao dao, @NonNull final String name,
+ public ToscaServiceTemplate deletePolicyType(@NonNull final PfDao dao, @NonNull final String name,
@NonNull final String version) throws PfModelException {
- return new SimpleToscaProvider().deletePolicyTypes(dao, new PfConceptKey(name, version)).toAuthorative();
+ return new SimpleToscaProvider().deletePolicyType(dao, new PfConceptKey(name, version)).toAuthorative();
}
/**
return new SimpleToscaProvider().getPolicies(dao, new PfConceptKey(name, version)).toAuthorative();
}
+ /**
+ * Get policies.
+ *
+ * @param dao the DAO to use to access the database
+ * @param name the name of the policy to get, null to get all policies
+ * @param version the version of the policy to get, null to get all versions of a policy
+ * @return the policies found
+ * @throws PfModelException on errors getting policies
+ */
+ public List<ToscaPolicy> getPolicyList(@NonNull final PfDao dao, final String name, final String version)
+ throws PfModelException {
+ return new ArrayList<>();
+ }
+
+ /**
+ * Get policies for a policy type name.
+ *
+ * @param dao the DAO to use to access the database
+ * @param policyTypeName the name of the policy type for which to get policies
+ * @return the policies found
+ * @throws PfModelException on errors getting policies
+ */
+ public List<ToscaPolicy> getPolicyList4PolicyType(@NonNull final PfDao dao, @NonNull final String policyTypeName)
+ throws PfModelException {
+ return new ArrayList<>();
+ }
+
+ /**
+ * Get latest policies.
+ *
+ * @param dao the DAO to use to access the database
+ * @param name the name of the policy to get, null to get all policies
+ * @return the policies found
+ * @throws PfModelException on errors getting policies
+ */
+ public ToscaServiceTemplate getLatestPolicies(@NonNull final PfDao dao, final String name) throws PfModelException {
+ return null;
+ }
+
+ /**
+ * Get latest policies.
+ *
+ * @param dao the DAO to use to access the database
+ * @param name the name of the policy to get, null to get all policies
+ * @return the policies found
+ * @throws PfModelException on errors getting policies
+ */
+ public List<ToscaPolicy> getLatestPolicyList(@NonNull final PfDao dao, final String name) throws PfModelException {
+ return new ArrayList<>();
+ }
+
/**
* Create policies.
*
}
/**
- * Delete policies.
+ * Delete policy.
*
* @param dao the DAO to use to access the database
* @param name the name of the policy to delete.
* @param version the version of the policy to delete.
- * @return the TOSCA service template containing the policies that were deleted
+ * @return the TOSCA service template containing the policy that weas deleted
* @throws PfModelException on errors deleting policies
*/
- public ToscaServiceTemplate deletePolicies(@NonNull final PfDao dao, @NonNull final String name,
+ public ToscaServiceTemplate deletePolicy(@NonNull final PfDao dao, @NonNull final String name,
@NonNull final String version) throws PfModelException {
- return new SimpleToscaProvider().deletePolicies(dao, new PfConceptKey(name, version)).toAuthorative();
+ return new SimpleToscaProvider().deletePolicy(dao, new PfConceptKey(name, version)).toAuthorative();
}
}
* @return the TOSCA service template containing the policy types that were deleted
* @throws PfModelException on errors deleting policy types
*/
- public JpaToscaServiceTemplate deletePolicyTypes(@NonNull final PfDao dao,
+ public JpaToscaServiceTemplate deletePolicyType(@NonNull final PfDao dao,
@NonNull final PfConceptKey policyTypeKey)
throws PfModelException {
* @return the TOSCA service template containing the policies that were deleted
* @throws PfModelException on errors deleting policies
*/
- public JpaToscaServiceTemplate deletePolicies(@NonNull final PfDao dao, @NonNull final PfConceptKey policyKey)
+ public JpaToscaServiceTemplate deletePolicy(@NonNull final PfDao dao, @NonNull final PfConceptKey policyKey)
throws PfModelException {
JpaToscaServiceTemplate serviceTemplate = getPolicies(dao, policyKey);
@Test
public void testPoliciesDelete() throws Exception {
try {
- new SimpleToscaProvider().deletePolicies(null, null);
+ new SimpleToscaProvider().deletePolicy(null, null);
fail("test should throw an exception here");
} catch (Exception exc) {
assertEquals("dao is marked @NonNull but is null", exc.getMessage());
}
try {
- new SimpleToscaProvider().deletePolicies(null, new PfConceptKey());
+ new SimpleToscaProvider().deletePolicy(null, new PfConceptKey());
fail("test should throw an exception here");
} catch (Exception exc) {
assertEquals("dao is marked @NonNull but is null", exc.getMessage());
}
try {
- new SimpleToscaProvider().deletePolicies(pfDao, null);
+ new SimpleToscaProvider().deletePolicy(pfDao, null);
fail("test should throw an exception here");
} catch (Exception exc) {
assertEquals("policyKey is marked @NonNull but is null", exc.getMessage());
PfConceptKey policyKey = new PfConceptKey("onap.restart.tca:1.0.0");
JpaToscaServiceTemplate deletedServiceTemplate =
- new SimpleToscaProvider().deletePolicies(pfDao, new PfConceptKey(policyKey));
+ new SimpleToscaProvider().deletePolicy(pfDao, new PfConceptKey(policyKey));
assertEquals(originalServiceTemplate.getTopologyTemplate().getPolicies().get(policyKey),
deletedServiceTemplate.getTopologyTemplate().getPolicies().get(policyKey));