src/net/java/sip/communicator/impl/protocol/jabber/OperationSetServerStoredAccountInfoJabberImpl.java
/**
     * Saves the list of details for this account that were ready to be stored
     * online on the server. This method performs the actual saving of details
     * online on the server and is supposed to be invoked after addDetail(),
     * replaceDetail() and/or removeDetail().
     * <p>
     * @throws OperationFailedException with code Network Failure if putting the
     * new values back online has failed.
     */
Saves the list of details for this account that were ready to be stored
online on the server. This method performs the actual saving of details
online on the server and is supposed to be invoked after addDetail(),
replaceDetail() and/or removeDetail().

@throws OperationFailedException with code Network Failure if putting the
new values back online has failed.
Saves the list of details for this account that were ready to be stored online on the server . This method performs the actual saving of details online on the server and is supposed to be invoked after addDetail () replaceDetail () and / or removeDetail () . @throws OperationFailedException with code Network Failure if putting the new values back online has failed .
public void save() throws OperationFailedException
    {
        assertConnected();
        List<GenericDetail> details = infoRetreiver.getContactDetails(uin);
        VCard vCard = new VCard();
        for (GenericDetail detail : details)
        {
            if (detail instanceof ImageDetail)
            {
                byte[] avatar = ((ImageDetail) detail).getBytes();
                if (avatar == null) vCard.setAvatar(new byte[0]);
                else vCard.setAvatar(avatar);
                fireServerStoredDetailsChangeEvent(
                    jabberProvider,
                    ServerStoredDetailsChangeEvent.DETAIL_ADDED,
                    null,
                    detail);
            }
            else if (detail.getClass().equals(FirstNameDetail.class))
            {
                vCard.setFirstName((String)detail.getDetailValue());
            }
            else if (detail.getClass().equals(MiddleNameDetail.class))
            {
                vCard.setMiddleName((String)detail.getDetailValue());
            }
            else if (detail.getClass().equals(LastNameDetail.class))
            {
                vCard.setLastName((String)detail.getDetailValue());
            }
            else if (detail.getClass().equals(NicknameDetail.class))
                vCard.setNickName((String)detail.getDetailValue());
            else if (detail.getClass().equals(URLDetail.class))
            {
                if (detail.getDetailValue() != null)
                    vCard.setField(
                        "URL", detail.getDetailValue().toString());
            }
            else if (detail.getClass().equals(BirthDateDetail.class))
            {
                if (detail.getDetailValue() != null)
                {
                    Calendar c = ((BirthDateDetail)detail).getCalendar();
                    DateFormat dateFormat =
                        new SimpleDateFormat(
                            JabberActivator.getResources().getI18NString(
                                "plugin.accountinfo.BDAY_FORMAT"));
                    String strdate = dateFormat.format(c.getTime());
                    vCard.setField("BDAY", strdate);
                }
            }
            else if (detail.getClass().equals(AddressDetail.class))
                vCard.setAddressFieldHome(
                    "STREET", (String)detail.getDetailValue());
            else if (detail.getClass().equals(CityDetail.class))
                vCard.setAddressFieldHome(
                    "LOCALITY", (String)detail.getDetailValue());
            else if (detail.getClass().equals(ProvinceDetail.class))
                vCard.setAddressFieldHome(
                    "REGION", (String)detail.getDetailValue());
            else if (detail.getClass().equals(PostalCodeDetail.class))
                vCard.setAddressFieldHome(
                    "PCODE", (String)detail.getDetailValue());
            else if (detail.getClass().equals(CountryDetail.class))
                vCard.setAddressFieldHome(
                    "CTRY", (String)detail.getDetailValue());
            else if (detail.getClass().equals(PhoneNumberDetail.class))
                vCard.setPhoneHome("VOICE", (String)detail.getDetailValue());
            else if (detail.getClass().equals(WorkPhoneDetail.class))
                vCard.setPhoneWork("VOICE", (String)detail.getDetailValue());
            else if (detail.getClass().equals(MobilePhoneDetail.class))
                vCard.setPhoneHome("CELL", (String)detail.getDetailValue());
            else if (detail.getClass().equals(VideoDetail.class))
                vCard.setPhoneHome("VIDEO", (String)detail.getDetailValue());
            else if (detail.getClass().equals(WorkVideoDetail.class))
                vCard.setPhoneWork("VIDEO", (String)detail.getDetailValue());
            else if (detail.getClass().equals(EmailAddressDetail.class))
                vCard.setEmailHome((String)detail.getDetailValue());
            else if (detail.getClass().equals(WorkEmailAddressDetail.class))
                vCard.setEmailWork((String)detail.getDetailValue());
            else if (detail.getClass().equals(WorkOrganizationNameDetail.class))
                vCard.setOrganization((String)detail.getDetailValue());
            else if (detail.getClass().equals(JobTitleDetail.class))
                vCard.setField("TITLE", (String)detail.getDetailValue());
            else if (detail.getClass().equals(AboutMeDetail.class))
                vCard.setField("ABOUTME", (String)detail.getDetailValue());
        }
        String tmp;
        tmp = infoRetreiver.checkForFullName(vCard);
        if(tmp != null)
        {
            DisplayNameDetail displayNameDetail = new DisplayNameDetail(
                StringEscapeUtils.unescapeXml(tmp));
            Iterator<GenericDetail> detailIt
                = infoRetreiver.getDetails(uin, DisplayNameDetail.class);
            while(detailIt.hasNext())
            {
                infoRetreiver.getCachedContactDetails(uin)
                    .remove(detailIt.next());
            }
            infoRetreiver.getCachedContactDetails(uin).add(displayNameDetail);
        }
        try
        {
            VCardManager
                .getInstanceFor(jabberProvider.getConnection())
                .saveVCard(vCard);
        }
        catch (XMPPException
            | InterruptedException
            | NoResponseException
            | NotConnectedException xmppe)
        {
            logger.error("Error loading/saving vcard: ", xmppe);
            throw new OperationFailedException(
                "Error loading/saving vcard: ", 1, xmppe);
        }
    }
public void save ( ) throws OperationFailedException { assertConnected ( ) ; List < GenericDetail > details = infoRetreiver . getContactDetails ( uin ) ; VCard vCard = new VCard ( ) ; for ( GenericDetail detail : details ) { if ( detail instanceof ImageDetail ) { byte [ ] avatar = ( ( ImageDetail ) detail ) . getBytes ( ) ; if ( avatar == null ) vCard . setAvatar ( new byte [ 0 ] ) ; else vCard . setAvatar ( avatar ) ; fireServerStoredDetailsChangeEvent ( jabberProvider , ServerStoredDetailsChangeEvent . DETAIL_ADDED , null , detail ) ; } else if ( detail . getClass ( ) . equals ( FirstNameDetail . class ) ) { vCard . setFirstName ( ( String ) detail . getDetailValue ( ) ) ; } else if ( detail . getClass ( ) . equals ( MiddleNameDetail . class ) ) { vCard . setMiddleName ( ( String ) detail . getDetailValue ( ) ) ; } else if ( detail . getClass ( ) . equals ( LastNameDetail . class ) ) { vCard . setLastName ( ( String ) detail . getDetailValue ( ) ) ; } else if ( detail . getClass ( ) . equals ( NicknameDetail . class ) ) vCard . setNickName ( ( String ) detail . getDetailValue ( ) ) ; else if ( detail . getClass ( ) . equals ( URLDetail . class ) ) { if ( detail . getDetailValue ( ) != null ) vCard . setField ( "URL" , detail . getDetailValue ( ) . toString ( ) ) ; } else if ( detail . getClass ( ) . equals ( BirthDateDetail . class ) ) { if ( detail . getDetailValue ( ) != null ) { Calendar c = ( ( BirthDateDetail ) detail ) . getCalendar ( ) ; DateFormat dateFormat = new SimpleDateFormat ( JabberActivator . getResources ( ) . getI18NString ( "plugin.accountinfo.BDAY_FORMAT" ) ) ; String strdate = dateFormat . format ( c . getTime ( ) ) ; vCard . setField ( "BDAY" , strdate ) ; } } else if ( detail . getClass ( ) . equals ( AddressDetail . class ) ) vCard . setAddressFieldHome ( "STREET" , ( String ) detail . getDetailValue ( ) ) ; else if ( detail . getClass ( ) . equals ( CityDetail . class ) ) vCard . setAddressFieldHome ( "LOCALITY" , ( String ) detail . getDetailValue ( ) ) ; else if ( detail . getClass ( ) . equals ( ProvinceDetail . class ) ) vCard . setAddressFieldHome ( "REGION" , ( String ) detail . getDetailValue ( ) ) ; else if ( detail . getClass ( ) . equals ( PostalCodeDetail . class ) ) vCard . setAddressFieldHome ( "PCODE" , ( String ) detail . getDetailValue ( ) ) ; else if ( detail . getClass ( ) . equals ( CountryDetail . class ) ) vCard . setAddressFieldHome ( "CTRY" , ( String ) detail . getDetailValue ( ) ) ; else if ( detail . getClass ( ) . equals ( PhoneNumberDetail . class ) ) vCard . setPhoneHome ( "VOICE" , ( String ) detail . getDetailValue ( ) ) ; else if ( detail . getClass ( ) . equals ( WorkPhoneDetail . class ) ) vCard . setPhoneWork ( "VOICE" , ( String ) detail . getDetailValue ( ) ) ; else if ( detail . getClass ( ) . equals ( MobilePhoneDetail . class ) ) vCard . setPhoneHome ( "CELL" , ( String ) detail . getDetailValue ( ) ) ; else if ( detail . getClass ( ) . equals ( VideoDetail . class ) ) vCard . setPhoneHome ( "VIDEO" , ( String ) detail . getDetailValue ( ) ) ; else if ( detail . getClass ( ) . equals ( WorkVideoDetail . class ) ) vCard . setPhoneWork ( "VIDEO" , ( String ) detail . getDetailValue ( ) ) ; else if ( detail . getClass ( ) . equals ( EmailAddressDetail . class ) ) vCard . setEmailHome ( ( String ) detail . getDetailValue ( ) ) ; else if ( detail . getClass ( ) . equals ( WorkEmailAddressDetail . class ) ) vCard . setEmailWork ( ( String ) detail . getDetailValue ( ) ) ; else if ( detail . getClass ( ) . equals ( WorkOrganizationNameDetail . class ) ) vCard . setOrganization ( ( String ) detail . getDetailValue ( ) ) ; else if ( detail . getClass ( ) . equals ( JobTitleDetail . class ) ) vCard . setField ( "TITLE" , ( String ) detail . getDetailValue ( ) ) ; else if ( detail . getClass ( ) . equals ( AboutMeDetail . class ) ) vCard . setField ( "ABOUTME" , ( String ) detail . getDetailValue ( ) ) ; } String tmp ; tmp = infoRetreiver . checkForFullName ( vCard ) ; if ( tmp != null ) { DisplayNameDetail displayNameDetail = new DisplayNameDetail ( StringEscapeUtils . unescapeXml ( tmp ) ) ; Iterator < GenericDetail > detailIt = infoRetreiver . getDetails ( uin , DisplayNameDetail . class ) ; while ( detailIt . hasNext ( ) ) { infoRetreiver . getCachedContactDetails ( uin ) . remove ( detailIt . next ( ) ) ; } infoRetreiver . getCachedContactDetails ( uin ) . add ( displayNameDetail ) ; } try { VCardManager . getInstanceFor ( jabberProvider . getConnection ( ) ) . saveVCard ( vCard ) ; } catch ( XMPPException | InterruptedException | NoResponseException | NotConnectedException xmppe ) { logger . error ( "Error loading/saving vcard: " , xmppe ) ; throw new OperationFailedException ( "Error loading/saving vcard: " , 1 , xmppe ) ; } }
Saves the list of details for this account that were ready to be stored
 online on the server.
Saves the list of details for this account that were ready to be stored online on the server .
//Fix the display name detail