CmSubscriptionService service layer methods

References

CPS-2023: CmSubscription service layer methodsClosed



Issues & Decisions

#

Issue

Notes

Decisions

#

Issue

Notes

Decisions

1







Overview

This page is for the list of service layer methods needed to interact with other cps service methods and the repository layer in order to fetch/persist/delete the CmSubscriptions.



#

Use Case

Method Details

#

Use Case

Method Details

1

Fetch collection of datanodes based on given datastore and list of cmhandle-ids for a given xpath



2

Persist the newly created subscription / append the subscription-id if it is an overlapping one



3

Check if there is an ongoing subscription for the given datastore , cmHandleId , xpath 

@Daniel Hanrahan 

// Check if a subscription does NOT exist in the DB boolean isNewSubscription(final String datastore, final String cmHandleId, final String xpath) { final String cpsPathQuery = "/datastores/datastore[@name='" + escapeQuotesByDoublingThem(datastore) + "']" + "/cm-handles/cm-handle[@id='" + escapeQuotesByDoublingThem(cmHandleId) + "']" + "/filters/filter[@xpath='" + escapeQuotesByDoublingThem(xpath) + "']"; final Collection<DataNode> existingNodes = queryDataNodes("NCMP-Admin", "cm-data-subscriptions", cpsPathQuery, OMIT_DESCENDANTS); return existingNodes.isEmpty() || existingNodes.iterator().next().getLeaves().get("subscribers").isEmpty(); } // This is needed in case subscribed xpath has single-quotes ' in it - that would break path query private static String escapeQuotesByDoublingThem(final String value) { return value.replace("'", "''"); } Can be called like below : final String datastoreName = cmSubscriptionPredicate.getScopeFilter().getDatastoreType().getDatastoreName(): for (final String cmHandleId : cmSubscriptionPredicate.getTargetFilter()) { for (final String xpath : cmSubscriptionPredicate.getScopeFilter().getXpathFilters()) { if (isNewSubscription(datastoreName, cmHandleId, xpath)) { // will need to send this to dmi } } }