/android/import-contacts

To get this branch, use:
bzr branch http://bzr.ed.am/android/import-contacts

« back to all changes in this revision

Viewing changes to src/am/ed/importcontacts/Importer.java

  • Committer: edam
  • Date: 2012-12-18 13:00:43 UTC
  • Revision ID: tim@ed.am-20121218130043-4zhj1cdeaqko3c4b
cleanup; fixed some typos; updated TODO

Show diffs side-by-side

added added

removed removed

1
1
/*
2
2
 * Importer.java
3
3
 *
4
 
 * Copyright (C) 2009 to 2011 Tim Marston <edam@waxworlds.org>
 
4
 * Copyright (C) 2009 to 2012 Tim Marston <tim@ed.am>
5
5
 *
6
6
 * This file is part of the Import Contacts program (hereafter referred
7
7
 * to as "this program"). For more information, see
8
 
 * http://www.waxworlds.org/edam/software/android/import-contacts
 
8
 * http://ed.am/dev/android/import-contacts
9
9
 *
10
10
 * This program is free software: you can redistribute it and/or modify
11
11
 * it under the terms of the GNU General Public License as published by
21
21
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
22
22
 */
23
23
 
24
 
package org.waxworlds.edam.importcontacts;
 
24
package am.ed.importcontacts;
25
25
 
 
26
import java.util.Arrays;
26
27
import java.util.HashMap;
 
28
import java.util.HashSet;
27
29
import java.util.Iterator;
28
30
import java.util.Set;
29
31
import java.util.regex.Matcher;
30
32
import java.util.regex.Pattern;
31
33
 
32
 
import android.content.ContentUris;
33
 
import android.content.ContentValues;
34
34
import android.content.SharedPreferences;
35
 
import android.net.Uri;
36
35
import android.os.Message;
37
 
import android.provider.Contacts;
38
 
 
 
36
import android.provider.Contacts.PhonesColumns;
39
37
 
40
38
public class Importer extends Thread
41
39
{
55
53
        private int _last_merge_decision;
56
54
        private boolean _abort = false;
57
55
        private boolean _is_finished = false;
58
 
        private ContactsCache _contactsCache = null;
59
 
 
60
 
        @SuppressWarnings("serial")
61
 
        protected class ContactNeedsMoreInfoException extends Exception
62
 
        {
63
 
        }
 
56
        private ContactsCache _contacts_cache = null;
 
57
        private Backend _backend = null;
64
58
 
65
59
        /**
66
60
         * Data about a contact
122
116
                        }
123
117
                }
124
118
 
 
119
                @SuppressWarnings("serial")
 
120
                protected class ContactNotIdentifiableException extends Exception
 
121
                {
 
122
                }
 
123
 
125
124
                protected String _name = null;
126
125
                protected String _primary_organisation = null;
127
 
                protected boolean _primary_organisation_is_preferred = false;
 
126
                protected boolean _primary_organisation_is_preferred;
128
127
                protected String _primary_number = null;
129
 
                protected boolean _primary_number_is_preferred = false;
 
128
                protected int _primary_number_type;
 
129
                protected boolean _primary_number_is_preferred;
130
130
                protected String _primary_email = null;
131
 
                protected boolean _primary_email_is_preferred = false;
 
131
                protected boolean _primary_email_is_preferred;
132
132
                protected HashMap< String, ExtraDetail > _organisations = null;
133
133
                protected HashMap< String, PreferredDetail > _numbers = null;
134
134
                protected HashMap< String, PreferredDetail > _emails = null;
135
135
                protected HashMap< String, TypeDetail > _addresses = null;
136
136
 
 
137
                private ContactsCache.CacheIdentifier _cache_identifier = null;
 
138
 
137
139
                protected void setName( String name )
138
140
                {
139
141
                        _name = name;
173
175
                                        new ExtraDetail( 0, false, title ) );
174
176
 
175
177
                        // if this is the first organisation added, or it's a preferred
176
 
                        // organisation and a previous organisation wasn't, then remember
177
 
                        // that this is the "primary organisation".
 
178
                        // organisation and the current primary organisation isn't, then
 
179
                        // record this as the primary organisation.
178
180
                        if( _primary_organisation == null ||
179
181
                                ( is_preferred && !_primary_organisation_is_preferred ) )
180
182
                        {
221
223
                                _numbers.put( number,
222
224
                                        new PreferredDetail( type, false ) );
223
225
 
 
226
                        final Set< Integer > non_voice_types = new HashSet< Integer >(
 
227
                                Arrays.asList( PhonesColumns.TYPE_FAX_HOME,
 
228
                                        PhonesColumns.TYPE_FAX_WORK, PhonesColumns.TYPE_PAGER ) );
 
229
 
224
230
                        // if this is the first number added, or it's a preferred number
225
 
                        // and a previous number wasn't, then remember that this is the
226
 
                        // "primary number".
 
231
                        // and the current primary number isn't, or this number is on equal
 
232
                        // standing with the primary number in terms of preference and it is
 
233
                        // a voice number and the primary number isn't, then record this as
 
234
                        // the primary number.
227
235
                        if( _primary_number == null ||
228
 
                                ( is_preferred && !_primary_number_is_preferred ) )
 
236
                                ( is_preferred && !_primary_number_is_preferred ) ||
 
237
                                ( is_preferred == _primary_number_is_preferred &&
 
238
                                        !non_voice_types.contains( type ) &&
 
239
                                        non_voice_types.contains( _primary_number_type ) ) )
229
240
                        {
230
241
                                _primary_number = number;
 
242
                                _primary_number_type = type;
231
243
                                _primary_number_is_preferred = is_preferred;
232
244
                        }
233
245
                }
258
270
                        email = sanitisesEmailAddress( email );
259
271
                        if( email == null )
260
272
                        {
261
 
                                // TODO: warn that an imported email addtrss is being ignored
 
273
                                // TODO: warn that an imported email address is being ignored
262
274
                                return;
263
275
                        }
264
276
 
269
281
                        if( !_emails.containsKey( email ) )
270
282
                                _emails.put( email, new PreferredDetail( type, false ) );
271
283
 
272
 
                        // if this is the first email added, or it's a preferred email
273
 
                        // and a previous email wasn't, then remember that this is the
274
 
                        // "primary email".
 
284
                        // if this is the first email added, or it's a preferred email and
 
285
                        // the current primary organisation isn't, then record this as the
 
286
                        // primary email.
275
287
                        if( _primary_email == null ||
276
288
                                ( is_preferred && !_primary_email_is_preferred ) )
277
289
                        {
326
338
                }
327
339
 
328
340
                protected void finalise()
 
341
                        throws ContactNotIdentifiableException
329
342
                {
330
343
                        // ensure that if there is a primary number, it is preferred so
331
344
                        // that there is always one preferred number. Android will assign
349
362
                                _organisations.put( _primary_organisation,
350
363
                                        new ExtraDetail( 0, true, data.getExtra() ) );
351
364
                        }
 
365
 
 
366
                        // create a cache identifier from this contact data, which can be
 
367
                        // used to look-up an existing contact
 
368
                        _cache_identifier = ContactsCache.createIdentifier( this );
 
369
                        if( _cache_identifier == null )
 
370
                                throw new ContactNotIdentifiableException();
 
371
                }
 
372
 
 
373
                public ContactsCache.CacheIdentifier getCacheIdentifier()
 
374
                {
 
375
                        return _cache_identifier;
352
376
                }
353
377
 
354
378
                private String sanitisePhoneNumber( String number )
393
417
                        // update UI
394
418
                        setProgressMessage( R.string.doit_caching );
395
419
 
396
 
                        // build a cache of existing contacts
397
 
                        _contactsCache = new ContactsCache();
398
 
                        _contactsCache.buildCache( _doit );
 
420
                        // create the appropriate backend
 
421
//                      if( Integer.parseInt( android.os.Build.VERSION.SDK ) >= 5 )
 
422
//                              _backend = new ContactsContractBackend( _doit );
 
423
//                      else
 
424
                                _backend = new ContactsBackend( _doit );
 
425
 
 
426
                        // create a cache of existing contacts and populate it
 
427
                        _contacts_cache = new ContactsCache();
 
428
                        _backend.populateCache( _contacts_cache );
399
429
 
400
430
                        // do the import
401
431
                        onImport();
522
552
                        Doit.MESSAGE_SETPROGRESSMESSAGE, getText( res ) ) );
523
553
        }
524
554
 
525
 
        protected void setProgressMax( int maxProgress )
 
555
        protected void setProgressMax( int max_progress )
526
556
                        throws AbortImportException
527
557
        {
528
558
                checkAbort();
529
559
                _doit._handler.sendMessage( Message.obtain(
530
560
                        _doit._handler, Doit.MESSAGE_SETMAXPROGRESS,
531
 
                        new Integer( maxProgress ) ) );
 
561
                        new Integer( max_progress ) ) );
532
562
        }
533
563
 
534
 
        protected void setTmpProgress( int tmpProgress ) throws AbortImportException
 
564
        protected void setTmpProgress( int tmp_progress )
 
565
                throws AbortImportException
535
566
        {
536
567
                checkAbort();
537
568
                _doit._handler.sendMessage( Message.obtain(
538
569
                        _doit._handler, Doit.MESSAGE_SETTMPPROGRESS,
539
 
                        new Integer( tmpProgress ) ) );
 
570
                        new Integer( tmp_progress ) ) );
540
571
        }
541
572
 
542
573
        protected void setProgress( int progress ) throws AbortImportException
568
599
                return _doit.getText( res );
569
600
        }
570
601
 
571
 
        protected boolean isImportRequired( ContactData contact )
572
 
                        throws AbortImportException, ContactNeedsMoreInfoException
573
 
        {
574
 
                checkAbort();
575
 
                return isImportRequired( contact, _merge_setting );
576
 
        }
577
 
 
578
 
        synchronized private boolean isImportRequired(
579
 
                ContactData contact, int merge_setting )
580
 
                throws AbortImportException, ContactNeedsMoreInfoException
 
602
        synchronized private boolean checkForDuplicate(
 
603
                ContactsCache.CacheIdentifier cache_identifier, int merge_setting )
 
604
                throws AbortImportException
581
605
        {
582
606
                _last_merge_decision = merge_setting;
583
607
 
584
 
                // create a cache identifier which we can use to detect if this contact
585
 
                // is valid for importing
586
 
                ContactsCache.CacheIdentifier identifier =
587
 
                        ContactsCache.createIdentifier( contact );
588
 
                if( identifier == null )
589
 
                        throw new ContactNeedsMoreInfoException();
 
608
                // it is ok to use contact.getCacheIdentifier(). The contact has already
 
609
                // been finalised, which means a valid cache identifier will have been
 
610
                // created for it (or it would have been skipped)
590
611
 
591
612
                // handle special cases
592
613
                switch( merge_setting )
593
614
                {
594
615
                case Doit.ACTION_KEEP:
595
616
                        // if we keep contacts on duplicate, we better check for one
596
 
                        return !_contactsCache.canLookup( identifier );
 
617
                        return !_contacts_cache.canLookup( cache_identifier );
597
618
 
598
619
                case Doit.ACTION_PROMPT:
599
620
                        // if we are prompting on duplicate, we better check for one and if
600
621
                        // the contact doesn'te exist, we want to import it
601
 
                        if( !_contactsCache.canLookup( identifier ) )
 
622
                        if( !_contacts_cache.canLookup( cache_identifier ) )
602
623
                                return true;
603
624
 
604
625
                        // ok, it exists, so do prompt
605
626
                        _doit._handler.sendMessage( Message.obtain( _doit._handler,
606
 
                                Doit.MESSAGE_MERGEPROMPT, identifier.getDetail() ) );
 
627
                                Doit.MESSAGE_MERGEPROMPT, cache_identifier.getDetail() ) );
607
628
                        try {
608
629
                                wait();
609
630
                        }
617
638
                                _merge_setting = _response;
618
639
 
619
640
                        // recurse, with our new merge setting
620
 
                        return isImportRequired( contact, _response );
 
641
                        return checkForDuplicate( cache_identifier, _response );
621
642
                }
622
643
 
623
644
                // for all other cases (either overwriting or merging) we will need the
636
657
        {
637
658
                checkAbort();
638
659
 
 
660
                // It is expected that we use contact.getCacheIdentifier() here. The
 
661
                // contact we are passed should have been successfully finalise()d,
 
662
                // which includes generating a valid cache identifier.
 
663
                ContactsCache.CacheIdentifier cache_identifier =
 
664
                        contact.getCacheIdentifier();
 
665
 
 
666
                // check to see if this contact is a duplicate and should be skipped
 
667
                if( !checkForDuplicate( cache_identifier, _merge_setting ) ) {
 
668
                        skipContact();
 
669
                        return;
 
670
                }
 
671
 
639
672
//              if( !showContinue( "====[ IMPORTING ]====\n: " + contact._name ) )
640
673
//                      finish( ACTION_ABORT );
641
674
 
642
 
                ContentValues values = new ContentValues();
643
 
                boolean uiInformed = false;
644
 
                Long id = null;
645
 
 
646
 
                // give the contact a chance to finalise it's data
647
 
                contact.finalise();
648
 
 
649
 
                // create something, from the contact data, that we can use to identify
650
 
                // a cache entry and attempt to lookup the id of an existing contact in
651
 
                // the cache with it
652
 
                ContactsCache.CacheIdentifier identifier =
653
 
                        ContactsCache.createIdentifier( contact );
654
 
                if( identifier != null ) id = (Long)_contactsCache.lookup( identifier );
 
675
                // keep track of whether we've informed the UI of what we're doing
 
676
                boolean ui_informed = false;
 
677
 
 
678
                // attempt to lookup the id of an existing contact in the cache with
 
679
                // this contact data's cache identifier
 
680
                Long id = (Long)_contacts_cache.lookup( cache_identifier );
655
681
 
656
682
                // does contact exist already?
657
683
                if( id != null )
659
685
                        // should we skip this import altogether?
660
686
                        if( _last_merge_decision == Doit.ACTION_KEEP ) return;
661
687
 
662
 
                        // get contact's URI
663
 
                        Uri contactUri = ContentUris.withAppendedId(
664
 
                                Contacts.People.CONTENT_URI, id );
665
 
 
666
688
                        // should we destroy the existing contact before importing?
667
689
                        if( _last_merge_decision == Doit.ACTION_OVERWRITE )
668
690
                        {
669
691
                                // remove from device
670
 
                                _doit.getContentResolver().delete( contactUri, null, null );
 
692
                                _backend.deleteContact( id );
671
693
 
672
694
                                // update cache
673
 
                                _contactsCache.removeLookup( identifier );
674
 
                                _contactsCache.removeAssociatedData( id );
 
695
                                _contacts_cache.removeLookup( contact.getCacheIdentifier() );
 
696
                                _contacts_cache.removeAssociatedData( id );
675
697
 
676
698
                                // show that we're overwriting a contact
677
699
                                _doit._handler.sendEmptyMessage(
678
700
                                                Doit.MESSAGE_CONTACTOVERWRITTEN );
679
 
                                uiInformed = true;
 
701
                                ui_informed = true;
680
702
 
681
703
                                // discard the contact id
682
704
                                id = null;
683
705
                        }
684
706
                }
685
707
 
686
 
                // if we don't have a contact id yet (or if we did, but we destroyed it
 
708
                // if we don't have a contact id yet (or we did, but we destroyed it
687
709
                // when we deleted the contact), we'll have to create a new contact
688
710
                if( id == null )
689
711
                {
690
712
                        // create a new contact
691
 
                        values.put( Contacts.People.NAME, contact._name );
692
 
                        Uri contactUri = _doit.getContentResolver().insert(
693
 
                                Contacts.People.CONTENT_URI, values );
694
 
                        id = ContentUris.parseId( contactUri );
695
 
                        if( id == null || id <= 0 )
 
713
                        id = _backend.addContact( contact._name );
 
714
                        if( id == null )
696
715
                                showError( R.string.error_unabletoaddcontact );
697
716
 
698
 
                        // try to add them to the "My Contacts" group
699
 
                        try {
700
 
                                Contacts.People.addToMyContactsGroup(
701
 
                                        _doit.getContentResolver(), id );
702
 
                        }
703
 
                        catch( IllegalStateException e ) {
704
 
                                // ignore any failure
705
 
                        }
706
 
 
707
717
                        // update cache
708
 
                        _contactsCache.addLookup(
 
718
                        _contacts_cache.addLookup(
709
719
                                ContactsCache.createIdentifier( contact ), id );
710
720
 
711
721
                        // if we haven't already shown that we're overwriting a contact,
712
722
                        // show that we're creating a new contact
713
 
                        if( !uiInformed ) {
 
723
                        if( !ui_informed ) {
714
724
                                _doit._handler.sendEmptyMessage( Doit.MESSAGE_CONTACTCREATED );
715
 
                                uiInformed = true;
 
725
                                ui_informed = true;
716
726
                        }
717
727
                }
718
728
 
719
729
                // if we haven't already shown that we're overwriting or creating a
720
 
                // contact show that we're merging a contact
721
 
                if( !uiInformed )
 
730
                // contact, show that we're merging a contact
 
731
                if( !ui_informed )
722
732
                        _doit._handler.sendEmptyMessage( Doit.MESSAGE_CONTACTMERGED );
723
733
 
724
734
                // import contact parts
735
745
        private void importContactPhones( Long id,
736
746
                        HashMap< String, ContactData.PreferredDetail > datas )
737
747
        {
738
 
                // get URI to contact's phones
739
 
                Uri contactPhonesUri = Uri.withAppendedPath(
740
 
                        ContentUris.withAppendedId( Contacts.People.CONTENT_URI, id ),
741
 
                        Contacts.People.Phones.CONTENT_DIRECTORY );
742
 
                Set< String > datasKeys = datas.keySet();
743
 
 
744
748
                // add phone numbers
745
 
                Iterator< String > i = datasKeys.iterator();
 
749
                Set< String > datas_keys = datas.keySet();
 
750
                Iterator< String > i = datas_keys.iterator();
746
751
                while( i.hasNext() ) {
747
752
                        String number = i.next();
748
753
                        ContactData.PreferredDetail data = datas.get( number );
754
759
                        // if the number exists at all, it doesn't need importing. Because
755
760
                        // of this, we also can't update the cache (which we don't need to
756
761
                        // anyway, so it's not a problem).
757
 
                        if( _contactsCache.hasAssociatedNumber( id, number ) )
 
762
                        if( _contacts_cache.hasAssociatedNumber( id, number ) )
758
763
                                continue;
759
764
 
760
765
                        // add phone number
761
 
                        ContentValues values = new ContentValues();
762
 
                        values.put( Contacts.Phones.TYPE, data.getType() );
763
 
                        values.put( Contacts.Phones.NUMBER, number );
764
 
                        if( data.isPreferred() )
765
 
                                values.put( Contacts.Phones.ISPRIMARY, 1 );
766
 
                        _doit.getContentResolver().insert( contactPhonesUri, values );
 
766
                        _backend.addContactPhone( id, number, data );
767
767
 
768
768
                        // and add this address to the cache to prevent a addition of
769
769
                        // duplicate date from another file
770
 
                        _contactsCache.addAssociatedNumber( id, number );
 
770
                        _contacts_cache.addAssociatedNumber( id, number );
771
771
                }
772
772
        }
773
773
 
774
774
        private void importContactEmails( Long id,
775
775
                        HashMap< String, ContactData.PreferredDetail > datas )
776
776
        {
777
 
                // get URI to contact's contact methods
778
 
                Uri contactContactMethodsUri = Uri.withAppendedPath(
779
 
                        ContentUris.withAppendedId( Contacts.People.CONTENT_URI, id ),
780
 
                        Contacts.People.ContactMethods.CONTENT_DIRECTORY );
781
 
                Set< String > datasKeys = datas.keySet();
782
 
 
783
777
                // add email addresses
784
 
                Iterator< String > i = datasKeys.iterator();
 
778
                Set< String > datas_keys = datas.keySet();
 
779
                Iterator< String > i = datas_keys.iterator();
785
780
                while( i.hasNext() ) {
786
781
                        String email = i.next();
787
782
                        ContactData.PreferredDetail data = datas.get( email );
788
783
 
789
784
                        // we don't want to add this email address if it exists already or
790
785
                        // we would introduce duplicates.
791
 
                        if( _contactsCache.hasAssociatedEmail( id, email ) )
 
786
                        if( _contacts_cache.hasAssociatedEmail( id, email ) )
792
787
                                continue;
793
788
 
794
789
                        // add phone number
795
 
                        ContentValues values = new ContentValues();
796
 
                        values.put( Contacts.ContactMethods.KIND, Contacts.KIND_EMAIL );
797
 
                        values.put( Contacts.ContactMethods.DATA, email );
798
 
                        values.put( Contacts.ContactMethods.TYPE, data.getType() );
799
 
                        if( data.isPreferred() )
800
 
                                values.put( Contacts.ContactMethods.ISPRIMARY, 1 );
801
 
                        _doit.getContentResolver().insert( contactContactMethodsUri,
802
 
                                values );
 
790
                        _backend.addContactEmail( id, email, data );
803
791
 
804
792
                        // and add this address to the cache to prevent a addition of
805
793
                        // duplicate date from another file
806
 
                        _contactsCache.addAssociatedEmail( id, email );
 
794
                        _contacts_cache.addAssociatedEmail( id, email );
807
795
                }
808
796
        }
809
797
 
810
798
        private void importContactAddresses( Long id,
811
799
                HashMap< String, ContactData.TypeDetail > datas )
812
800
        {
813
 
                // get URI to contact's contact methods
814
 
                Uri contactContactMethodsUri = Uri.withAppendedPath(
815
 
                        ContentUris.withAppendedId( Contacts.People.CONTENT_URI, id ),
816
 
                        Contacts.People.ContactMethods.CONTENT_DIRECTORY );
817
 
 
818
801
                // add addresses
819
 
                Set< String > datasKeys = datas.keySet();
820
 
                Iterator< String > i = datasKeys.iterator();
 
802
                Set< String > datas_keys = datas.keySet();
 
803
                Iterator< String > i = datas_keys.iterator();
821
804
                while( i.hasNext() ) {
822
805
                        String address = i.next();
823
806
                        ContactData.TypeDetail data = datas.get( address );
824
807
 
825
808
                        // we don't want to add this address if it exists already or we
826
809
                        // would introduce duplicates
827
 
                        if( _contactsCache.hasAssociatedAddress( id, address ) )
 
810
                        if( _contacts_cache.hasAssociatedAddress( id, address ) )
828
811
                                continue;
829
812
 
830
813
                        // add postal address
831
 
                        ContentValues values = new ContentValues();
832
 
                        values.put( Contacts.ContactMethods.KIND, Contacts.KIND_POSTAL );
833
 
                        values.put( Contacts.ContactMethods.DATA, address );
834
 
                        values.put( Contacts.ContactMethods.TYPE, data.getType() );
835
 
                        _doit.getContentResolver().insert( contactContactMethodsUri,
836
 
                                values );
 
814
                        _backend.addContactAddresses( id, address, data );
837
815
 
838
816
                        // and add this address to the cache to prevent a addition of
839
817
                        // duplicate date from another file
840
 
                        _contactsCache.addAssociatedAddress( id, address );
 
818
                        _contacts_cache.addAssociatedAddress( id, address );
841
819
                }
842
820
        }
843
821
 
845
823
                HashMap< String, ContactData.ExtraDetail > datas )
846
824
        {
847
825
                // add addresses
848
 
                Set< String > datasKeys = datas.keySet();
849
 
                Iterator< String > i = datasKeys.iterator();
 
826
                Set< String > datas_keys = datas.keySet();
 
827
                Iterator< String > i = datas_keys.iterator();
850
828
                while( i.hasNext() ) {
851
829
                        String organisation = i.next();
852
830
                        ContactData.ExtraDetail data = datas.get( organisation );
853
831
 
854
832
                        // we don't want to add this address if it exists already or we
855
833
                        // would introduce duplicates
856
 
                        if( _contactsCache.hasAssociatedOrganisation( id, organisation ) )
 
834
                        if( _contacts_cache.hasAssociatedOrganisation( id, organisation ) )
857
835
                                continue;
858
836
 
859
837
                        // add organisation address
860
 
                        ContentValues values = new ContentValues();
861
 
                        values.put( Contacts.Organizations.PERSON_ID, id );
862
 
                        values.put( Contacts.Organizations.COMPANY, organisation );
863
 
                        values.put( Contacts.ContactMethods.TYPE,
864
 
                                Contacts.OrganizationColumns.TYPE_WORK );
865
 
                        if( data.getExtra() != null )
866
 
                                values.put( Contacts.Organizations.TITLE, data.getExtra() );
867
 
                        _doit.getContentResolver().insert(
868
 
                                Contacts.Organizations.CONTENT_URI, values );
 
838
                        _backend.addContactOrganisation( id, organisation, data );
869
839
 
870
840
                        // and add this address to the cache to prevent a addition of
871
841
                        // duplicate date from another file
872
 
                        _contactsCache.addAssociatedOrganisation( id, organisation );
 
842
                        _contacts_cache.addAssociatedOrganisation( id, organisation );
873
843
                }
874
844
        }
875
845