public void saveProperties() {
        Element vCard = DocumentHelper.createElement(QName.get("vCard", "vcard-temp"));
        Element subelement;

        // Add name
        if (name != null && !name.trim().isEmpty()) {
            subelement = vCard.addElement("N");
            subelement.addElement("GIVEN").setText(name.trim());
        }
        // Add email
        if (email != null && !email.trim().isEmpty()) {
            subelement = vCard.addElement("EMAIL");
            subelement.addElement("INTERNET");
            subelement.addElement("USERID").setText(email.trim());
        }
        // Add Full Name
        vCard.addElement("FN").setText(fullName.trim());
        // Add nickname
        if (nickname != null && !nickname.trim().isEmpty()) {
            vCard.addElement("NICKNAME").setText(nickname.trim());
        }
        // Add birthday
        if (birthday != null && !birthday.trim().isEmpty()) {
            vCard.addElement("BDAY").setText(birthday.trim());
        }
        // Add photo/avatar
        if (photo != null && !photo.trim().isEmpty()) {
            Element element = vCard.addElement("PHOTO");
            element.addElement("TYPE").setText("image/jpeg");
            element.addElement("BINVAL").setText(photo.trim());
        }
        // Add home address
        subelement = vCard.addElement("ADR");
        subelement.addElement("HOME");
        if (homeStreet != null && !homeStreet.trim().isEmpty()) {
            subelement.addElement("STREET").setText(homeStreet.trim());
        }
        if (homeCity != null && !homeCity.trim().isEmpty()) {
            subelement.addElement("LOCALITY").setText(homeCity.trim());
        }
        if (homeState != null && !homeState.trim().isEmpty()) {
            subelement.addElement("REGION").setText(homeState.trim());
        }
        if (homeZip != null && !homeZip.trim().isEmpty()) {
            subelement.addElement("PCODE").setText(homeZip.trim());
        }
        if (homeCountry != null && !homeCountry.trim().isEmpty()) {
            subelement.addElement("CTRY").setText(homeCountry.trim());
        }
        // Add business address
        subelement = vCard.addElement("ADR");
        subelement.addElement("WORK");
        if (businessStreet != null && !businessStreet.trim().isEmpty()) {
            subelement.addElement("STREET").setText(businessStreet.trim());
        }
        if (businessCity != null && !businessCity.trim().isEmpty()) {
            subelement.addElement("LOCALITY").setText(businessCity.trim());
        }
        if (businessState != null && !businessState.trim().isEmpty()) {
            subelement.addElement("REGION").setText(businessState.trim());
        }
        if (businessZip != null && !businessZip.trim().isEmpty()) {
            subelement.addElement("PCODE").setText(businessZip.trim());
        }
        if (businessCountry != null && !businessCountry.trim().isEmpty()) {
            subelement.addElement("CTRY").setText(businessCountry.trim());
        }
        // Add home phone
        if (homePhone != null && !homePhone.trim().isEmpty()) {
            subelement = vCard.addElement("TEL");
            subelement.addElement("HOME");
            subelement.addElement("VOICE");
            subelement.addElement("NUMBER").setText(homePhone.trim());
        }
        // Add home mobile
        if (homeMobile != null && !homeMobile.trim().isEmpty()) {
            subelement = vCard.addElement("TEL");
            subelement.addElement("HOME");
            subelement.addElement("CELL");
            subelement.addElement("NUMBER").setText(homeMobile.trim());
        }
        // Add home fax
        if (homeFax != null && !homeFax.trim().isEmpty()) {
            subelement = vCard.addElement("TEL");
            subelement.addElement("HOME");
            subelement.addElement("FAX");
            subelement.addElement("NUMBER").setText(homeFax.trim());
        }
        // Add home pager
        if (homePager != null && !homePager.trim().isEmpty()) {
            subelement = vCard.addElement("TEL");
            subelement.addElement("HOME");
            subelement.addElement("PAGER");
            subelement.addElement("NUMBER").setText(homePager.trim());
        }
        // Add business phone
        if (businessPhone != null && !businessPhone.trim().isEmpty()) {
            subelement = vCard.addElement("TEL");
            subelement.addElement("WORK");
            subelement.addElement("VOICE");
            subelement.addElement("NUMBER").setText(businessPhone.trim());
        }
        // Add business mobile
        if (businessMobile != null && !businessMobile.trim().isEmpty()) {
            subelement = vCard.addElement("TEL");
            subelement.addElement("WORK");
            subelement.addElement("CELL");
            subelement.addElement("NUMBER").setText(businessMobile.trim());
        }
        // Add business fax
        if (businessFax != null && !businessFax.trim().isEmpty()) {
            subelement = vCard.addElement("TEL");
            subelement.addElement("WORK");
            subelement.addElement("FAX");
            subelement.addElement("NUMBER").setText(businessFax.trim());
        }
        // Add business pager
        if (businessPager != null && !businessPager.trim().isEmpty()) {
            subelement = vCard.addElement("TEL");
            subelement.addElement("WORK");
            subelement.addElement("PAGER");
            subelement.addElement("NUMBER").setText(businessPager.trim());
        }
        // Add job title
        if (businessJobTitle != null && !businessJobTitle.trim().isEmpty()) {
            vCard.addElement("TITLE").setText(businessJobTitle.trim());
        }
        // Add job department
        if (businessDepartment != null && !businessDepartment.trim().isEmpty()) {
            vCard.addElement("ORG").addElement("ORGUNIT").setText(businessDepartment.trim());
        }
        // Generate content to store in property
        String vcardXML;
        StringWriter writer = new StringWriter();
        OutputFormat prettyPrinter = OutputFormat.createPrettyPrint();
        XMLWriter xmlWriter = new XMLWriter(writer, prettyPrinter);
        try {
            xmlWriter.write(vCard);
            vcardXML = writer.toString();
        }
        catch (IOException e) {
            Log.error("Error pretty formating XML", e);
            vcardXML = vCard.asXML();
        }

        StringBuilder sb = new StringBuilder(vcardXML.length());
        sb.append("<![CDATA[").append(vcardXML).append("]]>");
        // Save mapping as an XML property
        JiveGlobals.setProperty("ldap.vcard-mapping", sb.toString());

        // Set that the vcard provider is LdapVCardProvider
        VCardManager.VCARD_PROVIDER.setValue(LdapVCardProvider.class);

        // Save duplicated fields in LdapManager (should be removed in the future)
        LdapManager.getInstance().setNameField(new LdapUserTester.PropertyMapping(name));
        LdapManager.getInstance().setEmailField(email.replaceAll("(\\{)([\\d\\D&&[^}]]+)(})", "$2"));

        // Store the DB storage variable in the actual database.
        LdapVCardProvider.STORE_AVATAR_IN_DB.setValue(avatarStoredInDB);
    }
Saves current configuration as XML/DB properties.
xmppserver/src/main/java/org/jivesoftware/admin/LdapUserProfile.java