• kouidri nour
  • NEWBIE
  • 0 Points
  • Member since 2017

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 2
    Replies
global class BatchMergeContact implements Database.Batchable<sObject>{

    global BatchMergeContact(){
    }
    
    global Database.QueryLocator start(Database.BatchableContext BC){
        List<AggregateResult> queryAggregate = new List<AggregateResult>();
         
        List<String> querys = new List<String>();
        List<Contact> cont = new List <Contact>();
        queryAggregate = [select count(id), D_doublonnage_Email__c from contact group by D_doublonnage_Email__c having count(id)>1];
        
       
        for(AggregateResult ag : queryAggregate){
            querys.add((String)ag.get('D_doublonnage_Email__c'));
        }
        
        String query = 'select id, D_doublonnage_Email__c '+
                        'from Contact '+
                        'Where D_doublonnage_Email__c in :querys';
        System.debug('KOUIDRI NOUR query : '+ query);
       return Database.getQueryLocator(query);
        
    }

    global void execute(Database.BatchableContext BC, List<contact> scope){
        
        Set<String> keyDedou = new Set<String>();
        
        Map<String, List<contact>> ContactDouble = new Map<String, List<contact>>();
        
        for(contact con :scope){
            keyDedou.add(con.D_doublonnage_Email__c);
        }
        for(contact allCon : scope){
            if(keyDedou.contains(allCon.D_doublonnage_Email__c)){
                if(ContactDouble.keySet().contains(allCon.D_doublonnage_Email__c)){
                    ContactDouble.get(allCon.D_doublonnage_Email__c).add(allCon);
                }
                else{
                    ContactDouble.put(allCon.D_doublonnage_Email__c,new List<Contact>());
                    ContactDouble.get(allCon.D_doublonnage_Email__c).add(allCon);
                }
            }
            
        }
        Contact master = new Contact();
        for(List<Contact> listContact : ContactDouble.values()){
            if(listContact.size()==2){
                Database.MergeResult results = Database.merge(listContact[0], listContact[1]);
            }
            else if (listContact.size()==3){
                
                master=listContact.remove(0);
                
                Database.MergeResult[] results = Database.merge(master, listContact);
            }
        }
    }

    global void finish(Database.BatchableContext BC){
        List<AggregateResult> result = [SELECT D_doublonnage_Email__c, count(Id) FROM Contact GROUP BY D_doublonnage_Email__c Having count(Id)>1];
        if(result.size()>0){
            //Database.executeBatch(new BatchMergeContact());
        }        
    }
}

Hi,

I know similar questions on this have been asked before, but jus tin case someone has an answer.

I am making SOAP callouts from asynchrous code and it was all working fine until the certs expired on the server I was calling.

 

the certs were replaced, but now I get the following error:

Failed to loginSystem.CalloutException: IO Exception: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target

 

Is it possible that Salesforce is caching the cert somewhere?

 

I tried deleting the remote site in the security controls and recreating it, but it made no difference.

 

The guy in charge of the server I am calling has come back with this:

I checked the following link: http://wiki.developerforce.com/index.php/Outbound_Messaging_SSL_CA_Certificates

Our certificate was signed by the following root certificate: COMODO High-Assurance Secure Server CA

Which in turn was signed by AddTrust External CA Root

This I can find in the list: http://wiki.developerforce.com/index.php/Outbound_Messaging_SSL_CA_Certificates#addtrustexternalca

 

The values seem to match, so the certificate should be recognised fine.