Commit 15e90f87 authored by Sebastian Kummer's avatar Sebastian Kummer

Merge pull request #372 in ZP/z-push from develop to release/2.3

* commit '6ce31187':
  ZP-1049 Cache store ressource correctly.
  ZP-1035 Catch if a store can not be found and don't try to synchronize data in this case.
parents 2e2d4ca5 6ce31187
...@@ -113,6 +113,9 @@ class Kopano extends SyncWorker { ...@@ -113,6 +113,9 @@ class Kopano extends SyncWorker {
*/ */
protected function createHiddenFolder($gabId = null, $gabName = 'default') { protected function createHiddenFolder($gabId = null, $gabName = 'default') {
$store = $this->getStore($gabId, $gabName); $store = $this->getStore($gabId, $gabName);
if (!$store) {
return false;
}
$parentfolder = $this->getRootFolder($store); $parentfolder = $this->getRootFolder($store);
// mapi_folder_createfolder() fails if a folder with this name already exists -> MAPI_E_COLLISION // mapi_folder_createfolder() fails if a folder with this name already exists -> MAPI_E_COLLISION
...@@ -145,6 +148,9 @@ class Kopano extends SyncWorker { ...@@ -145,6 +148,9 @@ class Kopano extends SyncWorker {
*/ */
protected function deleteHiddenFolder($folderid, $gabId = null, $gabName = 'default') { protected function deleteHiddenFolder($folderid, $gabId = null, $gabName = 'default') {
$store = $this->getStore($gabId, $gabName); $store = $this->getStore($gabId, $gabName);
if (!$store) {
return false;
}
$parentfolder = $this->getRootFolder($store); $parentfolder = $this->getRootFolder($store);
$folderentryid = mapi_msgstore_entryidfromsourcekey($store, hex2bin($folderid)); $folderentryid = mapi_msgstore_entryidfromsourcekey($store, hex2bin($folderid));
...@@ -169,6 +175,9 @@ class Kopano extends SyncWorker { ...@@ -169,6 +175,9 @@ class Kopano extends SyncWorker {
*/ */
protected function getHiddenFolderId($gabId = null, $gabName = 'default') { protected function getHiddenFolderId($gabId = null, $gabName = 'default') {
$store = $this->getStore($gabId, $gabName); $store = $this->getStore($gabId, $gabName);
if (!$store) {
return false;
}
$parentfolder = $this->getRootFolder($store); $parentfolder = $this->getRootFolder($store);
$table = mapi_folder_gethierarchytable($parentfolder); $table = mapi_folder_gethierarchytable($parentfolder);
...@@ -198,6 +207,9 @@ class Kopano extends SyncWorker { ...@@ -198,6 +207,9 @@ class Kopano extends SyncWorker {
protected function clearFolderContents($folderid, $gabId = null, $gabName = 'default') { protected function clearFolderContents($folderid, $gabId = null, $gabName = 'default') {
$this->Log(sprintf("Kopano->clearFolderContents: emptying folder in GAB '%s': %s", $gabName, $folderid)); $this->Log(sprintf("Kopano->clearFolderContents: emptying folder in GAB '%s': %s", $gabName, $folderid));
$store = $this->getStore($gabId, $gabName); $store = $this->getStore($gabId, $gabName);
if (!$store) {
return false;
}
$folder = $this->getFolder($store, $folderid); $folder = $this->getFolder($store, $folderid);
// empty folder! // empty folder!
...@@ -221,6 +233,9 @@ class Kopano extends SyncWorker { ...@@ -221,6 +233,9 @@ class Kopano extends SyncWorker {
*/ */
protected function clearAllNotCurrentChunkType($folderid, $gabId = null, $gabName = 'default') { protected function clearAllNotCurrentChunkType($folderid, $gabId = null, $gabName = 'default') {
$store = $this->getStore($gabId, $gabName); $store = $this->getStore($gabId, $gabName);
if (!$store) {
return false;
}
$folder = $this->getFolder($store, $folderid); $folder = $this->getFolder($store, $folderid);
$table = mapi_folder_getcontentstable($folder); $table = mapi_folder_getcontentstable($folder);
if (!$table) if (!$table)
...@@ -257,7 +272,7 @@ class Kopano extends SyncWorker { ...@@ -257,7 +272,7 @@ class Kopano extends SyncWorker {
$companies = mapi_zarafa_getcompanylist($this->store); $companies = mapi_zarafa_getcompanylist($this->store);
if (is_array($companies)) { if (is_array($companies)) {
foreach($companies as $c) { foreach($companies as $c) {
$names[$c['companyname']] = bin2hex($c['companyid']); $names[trim($c['companyname'])] = bin2hex($c['companyid']);
} }
} }
return $names; return $names;
...@@ -432,6 +447,9 @@ class Kopano extends SyncWorker { ...@@ -432,6 +447,9 @@ class Kopano extends SyncWorker {
protected function getChunkData($folderid, $chunkName, $gabId = null, $gabName = 'default') { protected function getChunkData($folderid, $chunkName, $gabId = null, $gabName = 'default') {
// find the chunk message in the folder // find the chunk message in the folder
$store = $this->getStore($gabId, $gabName); $store = $this->getStore($gabId, $gabName);
if (!$store) {
return false;
}
$chunkdata = $this->findChunk($store, $folderid, $chunkName); $chunkdata = $this->findChunk($store, $folderid, $chunkName);
if (isset($chunkdata[PR_ENTRYID])) { if (isset($chunkdata[PR_ENTRYID])) {
...@@ -466,6 +484,9 @@ class Kopano extends SyncWorker { ...@@ -466,6 +484,9 @@ class Kopano extends SyncWorker {
// find the chunk message in the folder // find the chunk message in the folder
$store = $this->getStore($gabId, $gabName); $store = $this->getStore($gabId, $gabName);
if (!$store) {
return false;
}
$chunkdata = $this->findChunk($store, $folderid, $chunkName); $chunkdata = $this->findChunk($store, $folderid, $chunkName);
$message = false; $message = false;
...@@ -619,8 +640,14 @@ class Kopano extends SyncWorker { ...@@ -619,8 +640,14 @@ class Kopano extends SyncWorker {
if (!isset($this->storeCache[$gabId])) { if (!isset($this->storeCache[$gabId])) {
$user = (strtoupper($this->targetStore) == 'SYSTEM') ? $gabName : $this->targetStore . "@" . $gabName; $user = (strtoupper($this->targetStore) == 'SYSTEM') ? $gabName : $this->targetStore . "@" . $gabName;
$store_entryid = mapi_msgstore_createentryid($this->store, $user); $store_entryid = mapi_msgstore_createentryid($this->store, $user);
$store = mapi_openmsgstore($this->session, $store_entryid); if ($store_entryid) {
$this->Log(sprintf("Kopano->getStore(): Found store of user '%s': '%s'", $user, $store)); $store = mapi_openmsgstore($this->session, $store_entryid);
$this->Log(sprintf("Kopano->getStore(): Found store of user '%s': '%s'", $user, $store));
}
else {
$this->Log(sprintf("Kopano->getStore(): No store found for '%s'", $user));
$store = false;
}
$this->storeCache[$gabId] = $store; $this->storeCache[$gabId] = $store;
} }
...@@ -636,7 +663,8 @@ class Kopano extends SyncWorker { ...@@ -636,7 +663,8 @@ class Kopano extends SyncWorker {
* @return ressource * @return ressource
*/ */
private function getRootFolder($store) { private function getRootFolder($store) {
$rootId = "root"; // stringify the store ressource
$rootId = bin2hex($store."!");
if (!isset($this->folderCache[$rootId])) { if (!isset($this->folderCache[$rootId])) {
$parentfentryid = false; $parentfentryid = false;
......
...@@ -117,6 +117,10 @@ abstract class SyncWorker { ...@@ -117,6 +117,10 @@ abstract class SyncWorker {
private function doSync($gabId = null, $gabName = 'default', $doWrite = true) { private function doSync($gabId = null, $gabName = 'default', $doWrite = true) {
// get the folderid of the hidden folder - will be created if not yet available // get the folderid of the hidden folder - will be created if not yet available
$folderid = $this->getFolderId($gabId, $gabName, $doWrite); $folderid = $this->getFolderId($gabId, $gabName, $doWrite);
if ($folderid === false) {
$this->Log(sprintf("Aborting %sGAB sync to store '%s'%s. Store not found or create not possible.", (!$doWrite?"simulated ":""), HIDDEN_FOLDERSTORE, ($gabId?" of '".$gabName."'":"")));
return;
}
$this->Log(sprintf("Starting %sGAB sync to store '%s' %s on id '%s'", (!$doWrite?"simulated ":""), HIDDEN_FOLDERSTORE, ($gabId?"of '".$gabName."'":""), $folderid)); $this->Log(sprintf("Starting %sGAB sync to store '%s' %s on id '%s'", (!$doWrite?"simulated ":""), HIDDEN_FOLDERSTORE, ($gabId?"of '".$gabName."'":""), $folderid));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment