+ public List<PdpPolicyStatus> getGroupPolicyStatus(@NonNull final PfDao dao, @NonNull final String groupName)
+ throws PfModelException {
+
+ PfFilterParameters params = PfFilterParameters.builder().filterMap(Map.of("pdpGroup", groupName)).build();
+
+ return dao.getFiltered(JpaPdpPolicyStatus.class, params)
+ .stream().map(JpaPdpPolicyStatus::toAuthorative).collect(Collectors.toList());
+ }
+
+ /**
+ * Creates, updates, and deletes collections of policy status.
+ *
+ * @param dao the DAO to use to access the database
+ * @param createObjs the objects to create
+ * @param updateObjs the objects to update
+ * @param deleteObjs the objects to delete
+ */
+ public void cudPolicyStatus(@NonNull final PfDao dao, Collection<PdpPolicyStatus> createObjs,
+ Collection<PdpPolicyStatus> updateObjs, Collection<PdpPolicyStatus> deleteObjs) {
+
+ synchronized (statusLock) {
+ dao.deleteCollection(fromAuthorativeStatus(deleteObjs, "deletePdpPolicyStatusList"));
+ dao.createCollection(fromAuthorativeStatus(createObjs, "createPdpPolicyStatusList"));
+ dao.createCollection(fromAuthorativeStatus(updateObjs, "updatePdpPolicyStatusList"));
+ }
+ }
+
+ /**
+ * Converts a collection of authorative policy status to a collection of JPA policy
+ * status. Validates the resulting list.
+ *
+ * @param objs authorative policy status to convert
+ * @param fieldName name of the field containing the collection
+ * @return a collection of JPA policy status
+ */
+ private Collection<JpaPdpPolicyStatus> fromAuthorativeStatus(Collection<PdpPolicyStatus> objs, String fieldName) {
+ if (objs == null) {
+ return Collections.emptyList();
+ }
+
+ List<JpaPdpPolicyStatus> jpas = objs.stream().map(JpaPdpPolicyStatus::new).collect(Collectors.toList());
+
+ // validate the objects
+ var result = new BeanValidationResult(fieldName, jpas);
+
+ var count = 0;
+ for (JpaPdpPolicyStatus jpa: jpas) {
+ result.addResult(jpa.validate(String.valueOf(count++)));
+ }
+
+ if (!result.isValid()) {
+ throw new PfModelRuntimeException(Response.Status.BAD_REQUEST, result.getResult());
+ }
+
+ return jpas;
+ }
+
+ /**
+ * Convert JPA PDP group list to an authorative PDP group list.
+ *
+ * @param jpaPdpGroupList the list to convert
+ * @return the authorative list
+ */
+ private List<PdpGroup> asPdpGroupList(List<JpaPdpGroup> jpaPdpGroupList) {
+ List<PdpGroup> pdpGroupList = new ArrayList<>(jpaPdpGroupList.size());
+
+ for (JpaPdpGroup jpaPdpGroup : jpaPdpGroupList) {
+ pdpGroupList.add(jpaPdpGroup.toAuthorative());
+ }
+
+ return pdpGroupList;