adds some improvements for scheduled imports
authorPhilipp Schüle <p.schuele@metaways.de>
Wed, 18 Feb 2015 18:16:18 +0000 (19:16 +0100)
committerPhilipp Schüle <p.schuele@metaways.de>
Mon, 23 Feb 2015 12:14:41 +0000 (13:14 +0100)
* more logging
* prevents logging of passwords
* always run import with NULL timestamps

Change-Id: I546013c30e97c6116cd3beedcb962368964f605e
Reviewed-on: http://gerrit.tine20.com/customers/1673
Tested-by: Jenkins CI (http://ci.tine20.com/)
Reviewed-by: Philipp Schüle <p.schuele@metaways.de>
tine20/Calendar/Import/CalDAV.php
tine20/Tinebase/Controller/ScheduledImport.php
tine20/Tinebase/Frontend/Cli.php

index 44dd6ae..8c91cb5 100644 (file)
@@ -82,23 +82,23 @@ class Calendar_Import_CalDAV extends Tinebase_Import_Abstract
     public function import($_resource = NULL, $_clientRecordData = array())
     {
         $_resource['options'] = Zend_Json::decode($_resource['options']);
-
+        
         $credentials = new Tinebase_Model_CredentialCache(array(
             'id'    => $_resource['options']['cid'],
             'key'   => $_resource['options']['ckey']
         ));
         Tinebase_Auth_CredentialCache::getInstance()->getCachedCredentials($credentials);
-
+        
         $uri = $this->_splitUri($_resource['remoteUrl']);
-
+        
         $caldavClientOptions = array(
             'baseUri' => $uri['host'],
             'calenderUri' => $uri['path'],
             'userName' => $credentials->username,
             'password' => $credentials->password,
-            'allowDuplicateEvents' => $_resource['options']['allowDuplicateEvents'],
+            'allowDuplicateEvents' => isset($_resource['options']['allowDuplicateEvents']) ? $_resource['options']['allowDuplicateEvents'] : false,
         );
-
+        
         Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__
             . ' Trying to get calendar container Name:' . $_resource['options']['container_id']);
         $container = Tinebase_Container::getInstance()->getContainerById($this->_getImportCalendarByName($_resource['options']['container_id']));
@@ -107,14 +107,17 @@ class Calendar_Import_CalDAV extends Tinebase_Import_Abstract
             throw new Tinebase_Exception('Could not import, aborting ..');
             return false;
         }
-
+        
         $credentialCache = Tinebase_Auth_CredentialCache::getInstance()->cacheCredentials($credentials->username, $credentials->password);
         Tinebase_Core::set(Tinebase_Core::USERCREDENTIALCACHE, $credentialCache);
-
+        
+        if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) {
+            Tinebase_Core::getLogger()->debug(__METHOD__ . ' ' . __LINE__ . ' Trigger CalDAV client with URI ' . $_resource['remoteUrl']);
+        }
+        
         $this->_calDAVClient = new Calendar_Import_CalDav_Client($caldavClientOptions, 'Generic', $container->name);
         $this->_calDAVClient->setVerifyPeer(false);
         $this->_calDAVClient->getDecorator()->initCalendarImport();
-
         $this->_calDAVClient->updateAllCalendarData();
     }
     
index 815069e..b24baf4 100644 (file)
@@ -95,7 +95,6 @@ class Tinebase_Controller_ScheduledImport extends Tinebase_Controller_Record_Abs
         $filter = new Tinebase_Model_ImportFilter(array(), 'OR');
         
         $filter0 = new Tinebase_Model_ImportFilter(array(
-                array('field' => 'interval', 'operator' => 'equals', 'value' => Tinebase_Model_Import::INTERVAL_ONCE),
                 array('field' => 'timestamp', 'operator' => 'isnull', 'value' => null),
         ), 'AND');
         
@@ -132,6 +131,9 @@ class Tinebase_Controller_ScheduledImport extends Tinebase_Controller_Record_Abs
             if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) {
                 Tinebase_Core::getLogger()->debug(__METHOD__ . ' ' . __LINE__ . ' No ScheduledImport could be found.');
             }
+            if (Tinebase_Core::isLogLevel(Zend_Log::TRACE)) {
+                Tinebase_Core::getLogger()->trace(__METHOD__ . ' ' . __LINE__ . ' Filter used: ' . print_r($filter->toArray(), true));
+            }
             
             return NULL;
         }
index bf8f91c..e197a96 100644 (file)
@@ -120,7 +120,7 @@ class Tinebase_Frontend_Cli extends Tinebase_Frontend_Cli_Abstract
         $scheduler = Tinebase_Core::getScheduler();
         $responses = $scheduler->run();
         
-        if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ .' ' . print_r($responses, TRUE));
+        if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ .' ' . print_r(array_keys($responses), TRUE));
         
         $responseString = ($responses) ? implode(',', array_keys($responses)) : 'NULL';
         echo "Tine 2.0 scheduler run (" . $responseString . ") complete.\n";