/**
  * handle duplicate exceptions
  * 
  * @param Tinebase_Exception_Duplicate $ted
  * @param integer $recordIndex
  * @param Tinebase_Record_Abstract|array $record
  * @param boolean $allowToResolveDuplicates
  * @return array|null exception
  */
 protected function _handleDuplicateExceptions(Tinebase_Exception_Duplicate $ted, $recordIndex, $record = null, $allowToResolveDuplicates = true)
 {
     $firstDuplicateRecord = $ted->getData()->getFirstRecord();
     $resolveStrategy = isset($this->_options['duplicateResolveStrategy']) ? $this->_options['duplicateResolveStrategy'] : null;
     // switch to keep strategy for records of current import run
     if (in_array($firstDuplicateRecord->getId(), $this->_importResult['results']->getArrayOfIds())) {
         $allowToResolveDuplicates = true;
         $resolveStrategy = 'keep';
     }
     if ($resolveStrategy && $allowToResolveDuplicates) {
         if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) {
             Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' Trying to resolve with configured strategy: ' . $resolveStrategy);
         }
         try {
             if ($resolveStrategy === 'keep') {
                 $updatedRecord = $this->_importAndResolveConflict($ted->getClientRecord(), $resolveStrategy);
                 $this->_importResult['totalcount']++;
             } else {
                 $updatedRecord = $this->_importAndResolveConflict($firstDuplicateRecord, $resolveStrategy, $ted->getClientRecord());
                 $this->_importResult['updatecount']++;
             }
             $this->_importResult['results']->addRecord($updatedRecord);
         } catch (Exception $newException) {
             if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) {
                 Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . " Resolving failed. Don't try to resolve duplicates this time");
             }
             $this->_handleImportException($newException, $recordIndex, $record, false);
         }
         $result = null;
     } else {
         $this->_importResult['duplicatecount']++;
         $result = $ted->toArray();
     }
     return $result;
 }
 /**
  * handle duplicate exceptions
  * 
  * @param Tinebase_Exception_Duplicate $ted
  * @param integer $recordIndex
  * @param Tinebase_Record_Abstract|array $record
  * @param boolean $allowToResolveDuplicates
  * @return array|null exception
  */
 protected function _handleDuplicateExceptions(Tinebase_Exception_Duplicate $ted, $recordIndex, $record = null, $allowToResolveDuplicates = true)
 {
     if (!empty($this->_options['duplicateResolveStrategy']) && $allowToResolveDuplicates) {
         if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) {
             Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' Trying to resolve with configured strategy: ' . $this->_options['duplicateResolveStrategy']);
         }
         try {
             $updatedRecord = $this->_importAndResolveConflict($ted->getData()->getFirstRecord(), $this->_options['duplicateResolveStrategy'], $ted->getClientRecord());
             $this->_importResult['updatecount']++;
             $this->_importResult['results']->addRecord($updatedRecord);
         } catch (Exception $newException) {
             if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) {
                 Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . " Resolving failed. Don't try to resolve duplicates this time");
             }
             $this->_handleImportException($newException, $recordIndex, $record, false);
         }
         $result = null;
     } else {
         $this->_importResult['duplicatecount']++;
         $result = $ted->toArray();
     }
     return $result;
 }