Commit 94d60adf authored by skummer's avatar skummer

ZP-502 #comment avoid warnings when attachment id is not splittable, catch...

ZP-502 #comment avoid warnings when attachment id is not splittable, catch fetch status and return it per requested object

git-svn-id: https://z-push.org/svn/z-push/trunk@1797 b7dd7b3b-3a3c-0410-9da9-bee62a6cc5b5
parent 6a567b63
...@@ -621,11 +621,12 @@ class BackendZarafa implements IBackend, ISearchProvider { ...@@ -621,11 +621,12 @@ class BackendZarafa implements IBackend, ISearchProvider {
*/ */
public function GetAttachmentData($attname) { public function GetAttachmentData($attname) {
ZLog::Write(LOGLEVEL_DEBUG, sprintf("ZarafaBackend->GetAttachmentData('%s')", $attname)); ZLog::Write(LOGLEVEL_DEBUG, sprintf("ZarafaBackend->GetAttachmentData('%s')", $attname));
list($id, $attachnum) = explode(":", $attname);
if(!isset($id) || !isset($attachnum)) if(!strpos($attname, ":"))
throw new StatusException(sprintf("ZarafaBackend->GetAttachmentData('%s'): Error, attachment requested for non-existing item", $attname), SYNC_ITEMOPERATIONSSTATUS_INVALIDATT); throw new StatusException(sprintf("ZarafaBackend->GetAttachmentData('%s'): Error, attachment requested for non-existing item", $attname), SYNC_ITEMOPERATIONSSTATUS_INVALIDATT);
list($id, $attachnum) = explode(":", $attname);
$entryid = hex2bin($id); $entryid = hex2bin($id);
$message = mapi_msgstore_openentry($this->store, $entryid); $message = mapi_msgstore_openentry($this->store, $entryid);
if(!$message) if(!$message)
......
...@@ -243,7 +243,6 @@ class ItemOperations extends RequestProcessor { ...@@ -243,7 +243,6 @@ class ItemOperations extends RequestProcessor {
// return false;//SYNC_ITEMOPERATIONS_ITEMOPERATIONS // return false;//SYNC_ITEMOPERATIONS_ITEMOPERATIONS
$status = SYNC_ITEMOPERATIONSSTATUS_SUCCESS; $status = SYNC_ITEMOPERATIONSSTATUS_SUCCESS;
//TODO status handling
self::$encoder->startWBXML(); self::$encoder->startWBXML();
...@@ -253,11 +252,50 @@ class ItemOperations extends RequestProcessor { ...@@ -253,11 +252,50 @@ class ItemOperations extends RequestProcessor {
self::$encoder->content($status); self::$encoder->content($status);
self::$encoder->endTag();//SYNC_ITEMOPERATIONS_STATUS self::$encoder->endTag();//SYNC_ITEMOPERATIONS_STATUS
// Stop here if something went wrong
if ($status != SYNC_ITEMOPERATIONSSTATUS_SUCCESS) {
self::$encoder->endTag();//SYNC_ITEMOPERATIONS_ITEMOPERATIONS
return true;
}
self::$encoder->startTag(SYNC_ITEMOPERATIONS_RESPONSE); self::$encoder->startTag(SYNC_ITEMOPERATIONS_RESPONSE);
foreach ($itemoperations as $operation) { foreach ($itemoperations as $operation) {
// fetch response // fetch response
if ($operation['operation'] == SYNC_ITEMOPERATIONS_FETCH) { if ($operation['operation'] == SYNC_ITEMOPERATIONS_FETCH) {
$status = SYNC_ITEMOPERATIONSSTATUS_SUCCESS;
// retrieve the data
// Fetch throws Sync status codes, - GetAttachmentData ItemOperations codes
if (isset($operation['filereference'])) {
try {
self::$topCollector->AnnounceInformation("Get attachment data from backend with file reference");
$data = self::$backend->GetAttachmentData($operation['filereference']);
}
catch (StatusException $stex) {
$status = $stex->getCode();
}
}
else {
try {
if (isset($operation['folderid']) && isset($operation['serverid'])) {
self::$topCollector->AnnounceInformation("Fetching data from backend with item and folder id");
$data = self::$backend->Fetch($operation['folderid'], $operation['serverid'], $operation["cpo"]);
}
else if (isset($operation['longid'])) {
self::$topCollector->AnnounceInformation("Fetching data from backend with long id");
$tmp = explode(":", $operation['longid']);
$data = self::$backend->Fetch($tmp[0], $tmp[1], $operation["cpo"]);
}
}
catch (StatusException $stex) {
// the only option to return is that we could not retrieve it
$status = SYNC_ITEMOPERATIONSSTATUS_CONVERSIONFAILED;
}
}
self::$encoder->startTag(SYNC_ITEMOPERATIONS_FETCH); self::$encoder->startTag(SYNC_ITEMOPERATIONS_FETCH);
self::$encoder->startTag(SYNC_ITEMOPERATIONS_STATUS); self::$encoder->startTag(SYNC_ITEMOPERATIONS_STATUS);
...@@ -276,10 +314,6 @@ class ItemOperations extends RequestProcessor { ...@@ -276,10 +314,6 @@ class ItemOperations extends RequestProcessor {
self::$encoder->startTag(SYNC_FOLDERTYPE); self::$encoder->startTag(SYNC_FOLDERTYPE);
self::$encoder->content("Email"); self::$encoder->content("Email");
self::$encoder->endTag(); self::$encoder->endTag();
self::$topCollector->AnnounceInformation("Fetching data from backend with item and folder id");
$data = self::$backend->Fetch($operation['folderid'], $operation['serverid'], $operation["cpo"]);
} }
if (isset($operation['longid'])) { if (isset($operation['longid'])) {
...@@ -290,26 +324,14 @@ class ItemOperations extends RequestProcessor { ...@@ -290,26 +324,14 @@ class ItemOperations extends RequestProcessor {
self::$encoder->startTag(SYNC_FOLDERTYPE); self::$encoder->startTag(SYNC_FOLDERTYPE);
self::$encoder->content("Email"); self::$encoder->content("Email");
self::$encoder->endTag(); self::$encoder->endTag();
$tmp = explode(":", $operation['longid']);
self::$topCollector->AnnounceInformation("Fetching data from backend with long id");
$data = self::$backend->Fetch($tmp[0], $tmp[1], $operation["cpo"]);
} }
if (isset($operation['filereference'])) { if (isset($operation['filereference'])) {
self::$encoder->startTag(SYNC_AIRSYNCBASE_FILEREFERENCE); self::$encoder->startTag(SYNC_AIRSYNCBASE_FILEREFERENCE);
self::$encoder->content($operation['filereference']); self::$encoder->content($operation['filereference']);
self::$encoder->endTag(); // end SYNC_AIRSYNCBASE_FILEREFERENCE self::$encoder->endTag(); // end SYNC_AIRSYNCBASE_FILEREFERENCE
self::$topCollector->AnnounceInformation("Get attachment data from backend with file reference");
$data = self::$backend->GetAttachmentData($operation['filereference']);
} }
//TODO put it in try catch block
if (isset($data)) { if (isset($data)) {
self::$topCollector->AnnounceInformation("Streaming data"); self::$topCollector->AnnounceInformation("Streaming data");
...@@ -350,9 +372,10 @@ class ItemOperations extends RequestProcessor { ...@@ -350,9 +372,10 @@ class ItemOperations extends RequestProcessor {
else { else {
self::$topCollector->AnnounceInformation("not implemented", true); self::$topCollector->AnnounceInformation("not implemented", true);
// reply with "can't do"
self::$encoder->startTag(SYNC_ITEMOPERATIONS_MOVE); self::$encoder->startTag(SYNC_ITEMOPERATIONS_MOVE);
self::$encoder->startTag(SYNC_ITEMOPERATIONS_STATUS); self::$encoder->startTag(SYNC_ITEMOPERATIONS_STATUS);
self::$encoder->content($status); self::$encoder->content(SYNC_ITEMOPERATIONSSTATUS_SERVERERROR);
self::$encoder->endTag();//SYNC_ITEMOPERATIONS_STATUS self::$encoder->endTag();//SYNC_ITEMOPERATIONS_STATUS
self::$encoder->endTag();//SYNC_ITEMOPERATIONS_MOVE self::$encoder->endTag();//SYNC_ITEMOPERATIONS_MOVE
} }
......
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