@@ -57,8 +57,7 @@ |
||
57 | 57 | else { |
58 | 58 | echo "grommunio-sync interprocess communication (IPC) is not available or TopCollector is disabled.\n"; |
59 | 59 | } |
60 | - } |
|
61 | - catch (GSyncException $zpe) { |
|
60 | + } catch (GSyncException $zpe) { |
|
62 | 61 | fwrite(STDERR, get_class($zpe) . ": " . $zpe->getMessage() . "\n"); |
63 | 62 | |
64 | 63 | exit(1); |
@@ -49,11 +49,9 @@ discard block |
||
49 | 49 | |
50 | 50 | // there are no SyncParameters for the hierarchy, but we use it to save the latest synckeys |
51 | 51 | $spa = self::$deviceManager->GetStateManager()->GetSynchedFolderState(false); |
52 | - } |
|
53 | - catch (StateNotFoundException $snfex) { |
|
52 | + } catch (StateNotFoundException $snfex) { |
|
54 | 53 | $status = SYNC_FSSTATUS_SYNCKEYERROR; |
55 | - } |
|
56 | - catch (StateInvalidException $sive) { |
|
54 | + } catch (StateInvalidException $sive) { |
|
57 | 55 | $status = SYNC_FSSTATUS_SYNCKEYERROR; |
58 | 56 | } |
59 | 57 | |
@@ -121,8 +119,7 @@ discard block |
||
121 | 119 | SLog::Write(LOGLEVEL_WARN, sprintf("Request->HandleFolderSync(): ignoring incoming folderchange for folder '%s' as status indicates problem.", $folder->displayname)); |
122 | 120 | self::$topCollector->AnnounceInformation("Incoming change ignored", true); |
123 | 121 | } |
124 | - } |
|
125 | - catch (StatusException $stex) { |
|
122 | + } catch (StatusException $stex) { |
|
126 | 123 | $status = $stex->getCode(); |
127 | 124 | } |
128 | 125 | } |
@@ -199,8 +196,7 @@ discard block |
||
199 | 196 | |
200 | 197 | // get the new state from the backend |
201 | 198 | $newsyncstate = (isset($exporter)) ? $exporter->GetState() : ""; |
202 | - } |
|
203 | - catch (StatusException $stex) { |
|
199 | + } catch (StatusException $stex) { |
|
204 | 200 | if ($stex->getCode() == SYNC_FSSTATUS_CODEUNKNOWN) { |
205 | 201 | $status = SYNC_FSSTATUS_SYNCKEYERROR; |
206 | 202 | } |
@@ -141,8 +141,7 @@ discard block |
||
141 | 141 | } |
142 | 142 | $spa->SetSyncKey($synckey); |
143 | 143 | } |
144 | - } |
|
145 | - catch (StateInvalidException $stie) { |
|
144 | + } catch (StateInvalidException $stie) { |
|
146 | 145 | $spa = new SyncParameters(); |
147 | 146 | $status = SYNC_STATUS_INVALIDSYNCKEY; |
148 | 147 | self::$topCollector->AnnounceInformation("State invalid - Resync folder", $this->singleFolder); |
@@ -163,8 +162,7 @@ discard block |
||
163 | 162 | try { |
164 | 163 | $spa->SetContentClass(self::$deviceManager->GetFolderClassFromCacheByID($spa->GetFolderId())); |
165 | 164 | SLog::Write(LOGLEVEL_DEBUG, sprintf("GetFolderClassFromCacheByID from Device Manager: '%s' for id:'%s'", $spa->GetContentClass(), $spa->GetFolderId())); |
166 | - } |
|
167 | - catch (NoHierarchyCacheAvailableException $nhca) { |
|
165 | + } catch (NoHierarchyCacheAvailableException $nhca) { |
|
168 | 166 | $status = SYNC_STATUS_FOLDERHIERARCHYCHANGED; |
169 | 167 | self::$deviceManager->ForceFullResync(); |
170 | 168 | } |
@@ -563,8 +561,7 @@ discard block |
||
563 | 561 | try { |
564 | 562 | // Save the updated state, which is used for the exporter later |
565 | 563 | $sc->AddParameter($spa, "state", $this->importer->GetState()); |
566 | - } |
|
567 | - catch (StatusException $stex) { |
|
564 | + } catch (StatusException $stex) { |
|
568 | 565 | $status = $stex->getCode(); |
569 | 566 | } |
570 | 567 | } |
@@ -657,13 +654,11 @@ discard block |
||
657 | 654 | // Load all collections - do not overwrite existing (received!), load states, check permissions and only load confirmed states! |
658 | 655 | try { |
659 | 656 | $sc->LoadAllCollections(false, true, true, true, true); |
660 | - } |
|
661 | - catch (StateInvalidException $siex) { |
|
657 | + } catch (StateInvalidException $siex) { |
|
662 | 658 | $status = SYNC_STATUS_INVALIDSYNCKEY; |
663 | 659 | self::$topCollector->AnnounceInformation("StateNotFoundException", $this->singleFolder); |
664 | 660 | $this->saveMultiFolderInfo("exception", "StateNotFoundException"); |
665 | - } |
|
666 | - catch (StatusException $stex) { |
|
661 | + } catch (StatusException $stex) { |
|
667 | 662 | $status = SYNC_STATUS_FOLDERHIERARCHYCHANGED; |
668 | 663 | self::$topCollector->AnnounceInformation(sprintf("StatusException code: %d", $status), $this->singleFolder); |
669 | 664 | $this->saveMultiFolderInfo("exception", "StatusException"); |
@@ -730,8 +725,7 @@ discard block |
||
730 | 725 | // always check for changes |
731 | 726 | SLog::Write(LOGLEVEL_DEBUG, sprintf("HandleSync(): Entering Heartbeat mode")); |
732 | 727 | $foundchanges = $sc->CheckForChanges($sc->GetLifetime(), $interval); |
733 | - } |
|
734 | - catch (StatusException $stex) { |
|
728 | + } catch (StatusException $stex) { |
|
735 | 729 | if ($stex->getCode() == SyncCollections::OBSOLETE_CONNECTION) { |
736 | 730 | $status = SYNC_COMMONSTATUS_SYNCSTATEVERSIONINVALID; |
737 | 731 | } |
@@ -875,8 +869,7 @@ discard block |
||
875 | 869 | if ($exporter === false) { |
876 | 870 | throw new StatusException(sprintf("HandleSync() could not get an exporter for folder id %s/%s", $spa->GetFolderId(), $spa->GetBackendFolderId()), SYNC_STATUS_FOLDERHIERARCHYCHANGED); |
877 | 871 | } |
878 | - } |
|
879 | - catch (StatusException $stex) { |
|
872 | + } catch (StatusException $stex) { |
|
880 | 873 | $status = $stex->getCode(); |
881 | 874 | } |
882 | 875 | |
@@ -891,8 +884,7 @@ discard block |
||
891 | 884 | |
892 | 885 | $changecount = $exporter->GetChangeCount(); |
893 | 886 | } |
894 | - } |
|
895 | - catch (StatusException $stex) { |
|
887 | + } catch (StatusException $stex) { |
|
896 | 888 | if ($stex->getCode() === SYNC_FSSTATUS_CODEUNKNOWN && $spa->HasSyncKey()) { |
897 | 889 | $status = SYNC_STATUS_INVALIDSYNCKEY; |
898 | 890 | } |
@@ -1150,8 +1142,7 @@ discard block |
||
1150 | 1142 | SLog::Write(LOGLEVEL_DEBUG, sprintf("HandleSync(): message not to be streamed as requested by DeviceManager, id = %s", $id)); |
1151 | 1143 | $fetchstatus = SYNC_STATUS_CLIENTSERVERCONVERSATIONERROR; |
1152 | 1144 | } |
1153 | - } |
|
1154 | - catch (StatusException $stex) { |
|
1145 | + } catch (StatusException $stex) { |
|
1155 | 1146 | $fetchstatus = $stex->getCode(); |
1156 | 1147 | } |
1157 | 1148 | |
@@ -1215,8 +1206,7 @@ discard block |
||
1215 | 1206 | if ($n % 10 == 0) { |
1216 | 1207 | self::$topCollector->AnnounceInformation(sprintf("Streamed data of %d objects out of %d", $n, (($changecount > $windowSize) ? $windowSize : $changecount))); |
1217 | 1208 | } |
1218 | - } |
|
1219 | - catch (SyncObjectBrokenException $mbe) { |
|
1209 | + } catch (SyncObjectBrokenException $mbe) { |
|
1220 | 1210 | $brokenSO = $mbe->GetSyncObject(); |
1221 | 1211 | if (!$brokenSO) { |
1222 | 1212 | SLog::Write(LOGLEVEL_ERROR, sprintf("HandleSync(): Caught SyncObjectBrokenException but broken SyncObject not available. This should be fixed in the backend.")); |
@@ -1316,8 +1306,7 @@ discard block |
||
1316 | 1306 | elseif (!$spa->HasSyncKey()) { |
1317 | 1307 | $state = ""; |
1318 | 1308 | } |
1319 | - } |
|
1320 | - catch (StatusException $stex) { |
|
1309 | + } catch (StatusException $stex) { |
|
1321 | 1310 | $status = $stex->getCode(); |
1322 | 1311 | } |
1323 | 1312 | |
@@ -1365,13 +1354,11 @@ discard block |
||
1365 | 1354 | if (!self::$backend->Setup(GSync::GetAdditionalSyncFolderStore($spa->GetBackendFolderId()))) { |
1366 | 1355 | throw new StatusException(sprintf("HandleSync() could not Setup() the backend for folder id %s/%s", $spa->GetFolderId(), $spa->GetBackendFolderId()), SYNC_STATUS_FOLDERHIERARCHYCHANGED); |
1367 | 1356 | } |
1368 | - } |
|
1369 | - catch (StateNotFoundException $snfex) { |
|
1357 | + } catch (StateNotFoundException $snfex) { |
|
1370 | 1358 | $status = SYNC_STATUS_INVALIDSYNCKEY; |
1371 | 1359 | self::$topCollector->AnnounceInformation("StateNotFoundException", $this->singleFolder); |
1372 | 1360 | $this->saveMultiFolderInfo("exception", "StateNotFoundException"); |
1373 | - } |
|
1374 | - catch (StatusException $stex) { |
|
1361 | + } catch (StatusException $stex) { |
|
1375 | 1362 | $status = $stex->getCode(); |
1376 | 1363 | self::$topCollector->AnnounceInformation(sprintf("StatusException code: %d", $status), $this->singleFolder); |
1377 | 1364 | $this->saveMultiFolderInfo("exception", "StateNotFoundException"); |
@@ -1420,8 +1407,7 @@ discard block |
||
1420 | 1407 | $this->importer->ConfigContentParameters($spa->GetCPO()); |
1421 | 1408 | $this->importer->LoadConflicts($spa->GetCPO(), $sc->GetParameter($spa, "state")); |
1422 | 1409 | } |
1423 | - } |
|
1424 | - catch (StatusException $stex) { |
|
1410 | + } catch (StatusException $stex) { |
|
1425 | 1411 | $status = $stex->getCode(); |
1426 | 1412 | } |
1427 | 1413 | |
@@ -1521,8 +1507,7 @@ discard block |
||
1521 | 1507 | |
1522 | 1508 | $actiondata["statusids"][$serverid] = SYNC_STATUS_SUCCESS; |
1523 | 1509 | } |
1524 | - } |
|
1525 | - catch (StatusException $stex) { |
|
1510 | + } catch (StatusException $stex) { |
|
1526 | 1511 | $actiondata["statusids"][$serverid] = $stex->getCode(); |
1527 | 1512 | } |
1528 | 1513 | break; |
@@ -1552,8 +1537,7 @@ discard block |
||
1552 | 1537 | $actiondata["clientids"][$clientid] = $this->importer->ImportMessageChange(false, $message); |
1553 | 1538 | $actiondata["statusids"][$clientid] = SYNC_STATUS_SUCCESS; |
1554 | 1539 | } |
1555 | - } |
|
1556 | - catch (StatusException $stex) { |
|
1540 | + } catch (StatusException $stex) { |
|
1557 | 1541 | $actiondata["statusids"][$clientid] = $stex->getCode(); |
1558 | 1542 | } |
1559 | 1543 | break; |
@@ -1587,8 +1571,7 @@ discard block |
||
1587 | 1571 | $this->importer->ImportMessageDeletion($serverid); |
1588 | 1572 | $actiondata["statusids"][$serverid] = SYNC_STATUS_SUCCESS; |
1589 | 1573 | } |
1590 | - } |
|
1591 | - catch (StatusException $stex) { |
|
1574 | + } catch (StatusException $stex) { |
|
1592 | 1575 | if ($stex->getCode() != SYNC_MOVEITEMSSTATUS_SUCCESS) { |
1593 | 1576 | $actiondata["statusids"][$serverid] = SYNC_STATUS_OBJECTNOTFOUND; |
1594 | 1577 | } |
@@ -163,8 +163,7 @@ discard block |
||
163 | 163 | throw new ServiceUnavailableException("Error connecting to KC (login)"); |
164 | 164 | } |
165 | 165 | } |
166 | - } |
|
167 | - catch (MAPIException $ex) { |
|
166 | + } catch (MAPIException $ex) { |
|
168 | 167 | throw new AuthenticationRequiredException($ex->getDisplayMessage()); |
169 | 168 | } |
170 | 169 | |
@@ -1660,8 +1659,7 @@ discard block |
||
1660 | 1659 | if (isset($stateMessageProps[PR_LAST_MODIFICATION_TIME])) { |
1661 | 1660 | return $stateMessageProps[PR_LAST_MODIFICATION_TIME]; |
1662 | 1661 | } |
1663 | - } |
|
1664 | - catch (StateNotFoundException $e) { |
|
1662 | + } catch (StateNotFoundException $e) { |
|
1665 | 1663 | } |
1666 | 1664 | |
1667 | 1665 | return "0"; |
@@ -1966,8 +1964,7 @@ discard block |
||
1966 | 1964 | |
1967 | 1965 | try { |
1968 | 1966 | $stateMessage = $this->getStateMessage($devid, $type, $key, $counter); |
1969 | - } |
|
1970 | - catch (StateNotFoundException $e) { |
|
1967 | + } catch (StateNotFoundException $e) { |
|
1971 | 1968 | // if message is not available, try to create a new one |
1972 | 1969 | $stateMessage = mapi_folder_createmessage($this->stateFolder, MAPI_ASSOCIATED); |
1973 | 1970 | SLog::Write(LOGLEVEL_DEBUG, sprintf("Grommunio->setStateMessage(): mapi_folder_createmessage 0x%08X", mapi_last_hresult())); |
@@ -165,8 +165,7 @@ discard block |
||
165 | 165 | $this->setDeviceUserData($this->type, [self::$user => $this->device], self::$devid, -1, $doCas = "merge"); |
166 | 166 | SLog::Write(LOGLEVEL_DEBUG, "DeviceManager->Save(): Device data saved"); |
167 | 167 | } |
168 | - } |
|
169 | - catch (StateNotFoundException $snfex) { |
|
168 | + } catch (StateNotFoundException $snfex) { |
|
170 | 169 | SLog::Write(LOGLEVEL_ERROR, "DeviceManager->Save(): Exception: " . $snfex->getMessage()); |
171 | 170 | } |
172 | 171 | } |
@@ -950,11 +949,9 @@ discard block |
||
950 | 949 | } |
951 | 950 | $this->stateManager->SetDevice($this->device); |
952 | 951 | } |
953 | - } |
|
954 | - catch (StateNotFoundException $snfex) { |
|
952 | + } catch (StateNotFoundException $snfex) { |
|
955 | 953 | $this->hierarchySyncRequired = true; |
956 | - } |
|
957 | - catch (UnavailableException $uaex) { |
|
954 | + } catch (UnavailableException $uaex) { |
|
958 | 955 | // This is temporary and can be ignored e.g. in PING - see https://jira.z-hub.io/browse/ZP-1054 |
959 | 956 | // If the hash was not available before we treat it like a StateNotFoundException. |
960 | 957 | if ($this->deviceHash === false) { |
@@ -101,8 +101,7 @@ discard block |
||
101 | 101 | if ($data !== false) { |
102 | 102 | $this->synchedFolders[$folderid] = $data; |
103 | 103 | } |
104 | - } |
|
105 | - catch (StateNotFoundException $ex) { |
|
104 | + } catch (StateNotFoundException $ex) { |
|
106 | 105 | } |
107 | 106 | } |
108 | 107 | |
@@ -231,8 +230,7 @@ discard block |
||
231 | 230 | |
232 | 231 | try { |
233 | 232 | return $this->statemachine->GetState($this->device->GetDeviceId(), IStateMachine::FAILSAVE, $this->uuid, $this->oldStateCounter, $this->deleteOldStates); |
234 | - } |
|
235 | - catch (StateNotFoundException $snfex) { |
|
233 | + } catch (StateNotFoundException $snfex) { |
|
236 | 234 | return false; |
237 | 235 | } |
238 | 236 | } |
@@ -60,8 +60,7 @@ discard block |
||
60 | 60 | } |
61 | 61 | |
62 | 62 | return true; |
63 | - } |
|
64 | - catch (GSyncException $e) { |
|
63 | + } catch (GSyncException $e) { |
|
65 | 64 | } |
66 | 65 | |
67 | 66 | return false; |
@@ -165,8 +164,7 @@ discard block |
||
165 | 164 | |
166 | 165 | return true; |
167 | 166 | } |
168 | - } |
|
169 | - catch (StateInvalidException $sive) { |
|
167 | + } catch (StateInvalidException $sive) { |
|
170 | 168 | // in case there is something wrong with the state, just stop here |
171 | 169 | // later when trying to retrieve the SyncParameters nothing will be found |
172 | 170 | |
@@ -193,8 +191,7 @@ discard block |
||
193 | 191 | try { |
194 | 192 | // make sure the hierarchy cache is loaded when we are loading hierarchy states |
195 | 193 | $this->addparms[$folderid]["state"] = $this->stateManager->GetSyncState($spa->GetLatestSyncKey($confirmedOnly), ($folderid === false)); |
196 | - } |
|
197 | - catch (StateNotFoundException $snfe) { |
|
194 | + } catch (StateNotFoundException $snfe) { |
|
198 | 195 | // if we can't find the state, first we should try a sync of that folder, so |
199 | 196 | // we generate a fake change, so a sync on this folder is triggered |
200 | 197 | $this->changes[$folderid] = 1; |
@@ -698,8 +695,7 @@ discard block |
||
698 | 695 | $changecount = $exporter->GetChangeCount(); |
699 | 696 | } |
700 | 697 | } |
701 | - } |
|
702 | - catch (StatusException $ste) { |
|
698 | + } catch (StatusException $ste) { |
|
703 | 699 | if ($ste->getCode() == SYNC_STATUS_FOLDERHIERARCHYCHANGED) { |
704 | 700 | SLog::Write(LOGLEVEL_WARN, "SyncCollections->CountChange(): exporter can not be re-configured due to state error, emulating change in folder to force Sync."); |
705 | 701 | $this->changes[$folderid] = 1; |
@@ -767,8 +763,7 @@ discard block |
||
767 | 763 | |
768 | 764 | $this->hierarchyExporterChecked = true; |
769 | 765 | } |
770 | - } |
|
771 | - catch (StatusException $ste) { |
|
766 | + } catch (StatusException $ste) { |
|
772 | 767 | throw new StatusException("SyncCollections->countHierarchyChange(): exporter can not be re-configured.", self::ERROR_WRONG_HIERARCHY, null, LOGLEVEL_WARN); |
773 | 768 | } |
774 | 769 |
@@ -63,8 +63,7 @@ |
||
63 | 63 | |
64 | 64 | try { |
65 | 65 | self::getLogger()->Log($loglevel, $message); |
66 | - } |
|
67 | - catch (\Exception $e) { |
|
66 | + } catch (\Exception $e) { |
|
68 | 67 | // @TODO How should we handle logging error ? |
69 | 68 | // Ignore any error. |
70 | 69 | } |
@@ -150,8 +150,7 @@ discard block |
||
150 | 150 | |
151 | 151 | // destruct backend after all data is on the stream |
152 | 152 | $backend->Logoff(); |
153 | - } |
|
154 | - catch (NoPostRequestException $nopostex) { |
|
153 | + } catch (NoPostRequestException $nopostex) { |
|
155 | 154 | if ($nopostex->getCode() == NoPostRequestException::OPTIONS_REQUEST) { |
156 | 155 | header(GSync::GetServerHeader()); |
157 | 156 | header(GSync::GetSupportedProtocolVersions()); |
@@ -166,8 +165,7 @@ discard block |
||
166 | 165 | GSync::PrintGrommunioSyncLegal('GET not supported', $nopostex->getMessage()); |
167 | 166 | } |
168 | 167 | } |
169 | - } |
|
170 | - catch (Exception $ex) { |
|
168 | + } catch (Exception $ex) { |
|
171 | 169 | // Extract any previous exception message for logging purpose. |
172 | 170 | $exclass = get_class($ex); |
173 | 171 | $exception_message = $ex->getMessage(); |