Project

General

Profile

Fail to change leaf node collection config

Kelly Kuang
Added almost 3 years ago

I want to change the LeafNodeA collection from GroupA to GroupB.

After request, LeafNodeA collection value changed. But GroupA children still contain LeafNodeA and GroupB children does not contain.

I check the tigase.pubsub.modules.NodeConfigModule.java

if (!collectionOld.equals(nodeConfig.getCollection())) {
//old collection is 'GroupA' and new collection is 'GroupB'
    if (collectionOld.equals("")) {
        AbstractNodeConfig colNodeConfig = getRepository().getNodeConfig(toJid, nodeConfig.getCollection());

        if (colNodeConfig == null) {
            throw new PubSubException(Authorization.ITEM_NOT_FOUND,
                    "(#1) Node '" + nodeConfig.getCollection() + "' doesn't exists");
        }
        if (!(colNodeConfig instanceof CollectionNodeConfig)) {
            throw new PubSubException(Authorization.NOT_ALLOWED,
                    "(#1) Node '" + nodeConfig.getCollection() + "' is not collection node");
        }
        ((CollectionNodeConfig) colNodeConfig).addChildren(nodeName);
        getRepository().update(toJid, colNodeConfig.getNodeName(), colNodeConfig);
        getRepository().removeFromRootCollection(toJid, nodeName);

        IAffiliations colNodeAffiliations = getRepository().getNodeAffiliations(toJid,
                colNodeConfig.getNodeName());
        ISubscriptions colNodeSubscriptions = getRepository().getNodeSubscriptions(toJid,
                colNodeConfig.getNodeName());
        Element associateNotification = createAssociateNotification(colNodeConfig.getNodeName(), nodeName);

        publishModule.sendNotifications(associateNotification, packet.getStanzaTo(), nodeName, nodeConfig,
                colNodeAffiliations, colNodeSubscriptions);
    }
    if (nodeConfig.getCollection().equals("")) {
        AbstractNodeConfig colNodeConfig = getRepository().getNodeConfig(toJid, collectionOld);

        if ((colNodeConfig != null) && (colNodeConfig instanceof CollectionNodeConfig)) {
            ((CollectionNodeConfig) colNodeConfig).removeChildren(nodeName);
            getRepository().update(toJid, colNodeConfig.getNodeName(), colNodeConfig);
        }
        getRepository().addToRootCollection(toJid, nodeName);

        IAffiliations colNodeAffiliations = getRepository().getNodeAffiliations(toJid,
                colNodeConfig.getNodeName());
        ISubscriptions colNodeSubscriptions = getRepository().getNodeSubscriptions(toJid,
                colNodeConfig.getNodeName());
        Element disassociateNotification = createDisassociateNotification(collectionOld, nodeName);

        publishModule.sendNotifications(disassociateNotification, packet.getStanzaTo(), nodeName, nodeConfig,
                colNodeAffiliations, colNodeSubscriptions);
    }
}

Neither first if nor second if is called when old collection is 'GroupA' and new collection is 'GroupB'.

Is it just a bug? Or I need to clean LeafNodeA collection before change?