public void add(String username, Element data) {
        if (!enabled)
        {
            return;
        }

        final JID owner = XMPPServer.getInstance().createJID( username, null );
        final PEPServiceManager serviceMgr = XMPPServer.getInstance().getIQPEPHandler().getServiceManager();
        PEPService pepService = serviceMgr.getPEPService( owner );
        if ( pepService == null )
        {
            pepService = serviceMgr.create( owner );
        }

        Node node = pepService.getNode( data.getNamespaceURI() );
        if ( node == null )
        {
            PubSubEngine.CreateNodeResponse response = PubSubEngine.createNodeHelper( pepService, owner, pepService.getDefaultNodeConfiguration( true ).getConfigurationForm(null).getElement(), data.getNamespaceURI(), PRIVATE_DATA_PUBLISHING_OPTIONS );
            node = response.newNode;

            if ( node == null )
            {
                Log.error( "Unable to create new PEP node, to be used to store private data. Error condition: {}", response.creationStatus.toXMPP() );
                return;
            }
        }

        if (!(node instanceof LeafNode))
        {
            Log.error( "Unable to store private data into a PEP node. The node that is available is not a leaf node." );
            return;
        }

        data.detach();
        final Element item = DocumentHelper.createElement( "item" );
        item.addAttribute( "id", "current" );
        item.add( data );

        ((LeafNode) node).publishItems( owner, Collections.singletonList( item ) );
    }
Stores private data. If the name and namespace of the element matches another
stored private data XML document, then replace it with the new one.

@param data the data to store (XML element)
@param username the username of the account where private data is being stored
xmppserver/src/main/java/org/jivesoftware/openfire/PrivateStorage.java