summary |
shortlog |
log |
commit | commitdiff |
review |
tree
raw |
patch |
inline | side by side (from parent 1:
bdc3fae)
- change string to formatted
Issue-ID: CPS-475
Change-Id: I59271c63f244c4d6684b145b1afe2356668e6fd8
Signed-off-by: emaclee <lee.anjella.macabuhay@est.tech>
package org.onap.cps.ncmp.api.impl.events.cmsubscription.service;
package org.onap.cps.ncmp.api.impl.events.cmsubscription.service;
-import static org.onap.cps.ncmp.api.impl.operations.DatastoreType.PASSTHROUGH_RUNNING;
import static org.onap.cps.spi.FetchDescendantsOption.OMIT_DESCENDANTS;
import java.io.Serializable;
import static org.onap.cps.spi.FetchDescendantsOption.OMIT_DESCENDANTS;
import java.io.Serializable;
private void addNewSubscriptionViaDatastore(final DatastoreType datastoreType, final String cmHandleId,
final String xpath, final String newSubscriptionId) {
private void addNewSubscriptionViaDatastore(final DatastoreType datastoreType, final String cmHandleId,
final String xpath, final String newSubscriptionId) {
- final String parentXpathFormat = "/datastores/datastore[@name='%s']/cm-handles";
- String parentXpath = "";
- if (datastoreType == PASSTHROUGH_RUNNING) {
- parentXpath = parentXpathFormat.formatted("ncmp-datastore:passthrough-running");
- } else {
- parentXpath = parentXpathFormat.formatted("ncmp-datastore:passthrough-operational");
- }
-
+ final String parentXpath = "/datastores/datastore[@name='%s']/cm-handles"
+ .formatted(datastoreType.getDatastoreName());
final String updatedJson = String.format("{\"cm-handle\":[{\"id\":\"%s\",\"filters\":{\"filter\":"
+ "[{\"xpath\":\"%s\",\"subscriptionIds\":[\"%s\"]}]}}]}", cmHandleId, xpath, newSubscriptionId);
cpsDataService.saveData(NCMP_DATASPACE_NAME, SUBSCRIPTION_ANCHOR_NAME, parentXpath, updatedJson,
final String updatedJson = String.format("{\"cm-handle\":[{\"id\":\"%s\",\"filters\":{\"filter\":"
+ "[{\"xpath\":\"%s\",\"subscriptionIds\":[\"%s\"]}]}}]}", cmHandleId, xpath, newSubscriptionId);
cpsDataService.saveData(NCMP_DATASPACE_NAME, SUBSCRIPTION_ANCHOR_NAME, parentXpath, updatedJson,