Commit 3ab81bc5 authored by skummer's avatar skummer

ZP-273 #comment added ConfigContentParameters to IChanges, modified...

ZP-273 #comment added ConfigContentParameters to IChanges, modified DiffBackend and all derived implementations, passing contentparameters also to ChangeMessage, DeleteMessage and SetReadFlag #time 2h 30m

git-svn-id: https://z-push.org/svn/z-push/trunk@1558 b7dd7b3b-3a3c-0410-9da9-bee62a6cc5b5
parent 33d61e2a
......@@ -251,6 +251,26 @@ class ImportChangesCombined implements IImportChanges {
ZLog::Write(LOGLEVEL_DEBUG, 'ImportChangesCombined->Config() success');
}
/**
* Configures additional parameters used for content synchronization
*
* @param ContentParameters $contentparameters
*
* @access public
* @return boolean
* @throws StatusException
*/
public function ConfigContentParameters($contentparameters) {
ZLog::Write(LOGLEVEL_DEBUG, "ImportChangesCombined->ConfigContentParameters()");
if (!$this->icc) {
ZLog::Write(LOGLEVEL_ERROR, "ImportChangesCombined->ConfigContentParameters() icc not configured");
return false;
}
$this->icc->ConfigContentParameters($contentparameters);
ZLog::Write(LOGLEVEL_DEBUG, "ImportChangesCombined->ConfigContentParameters() success");
}
/**
* Reads and returns the current state
*
......
......@@ -1107,15 +1107,22 @@ class BackendIMAP extends BackendDiff {
* @param string $folderid id of the folder
* @param string $id id of the message
* @param SyncXXX $message the SyncObject containing a message
* @param ContentParameters $contentParameters
*
* @access public
* @return array same return value as StatMessage()
* @throws StatusException could throw specific SYNC_STATUS_* exceptions
*/
public function ChangeMessage($folderid, $id, $message) {
public function ChangeMessage($folderid, $id, $message, $contentParameters) {
ZLog::Write(LOGLEVEL_DEBUG, sprintf("BackendIMAP->ChangeMessage('%s','%s','%s')", $folderid, $id, get_class($message)));
// TODO recheck implementation
// TODO this could throw several StatusExceptions like e.g. SYNC_STATUS_OBJECTNOTFOUND, SYNC_STATUS_SYNCCANNOTBECOMPLETED
// TODO SyncInterval check + ContentParameters
// see https://jira.zarafa.com/browse/ZP-258 for details
// before changing the message, it should be checked if the message is in the SyncInterval
// to determine the cutoffdate use Utils::GetCutOffDate($contentparameters->GetFilterType());
// if the message is not in the interval an StatusException with code SYNC_STATUS_SYNCCANNOTBECOMPLETED should be thrown
return false;
}
......@@ -1125,15 +1132,22 @@ class BackendIMAP extends BackendDiff {
* @param string $folderid id of the folder
* @param string $id id of the message
* @param int $flags read flag of the message
* @param ContentParameters $contentParameters
*
* @access public
* @return boolean status of the operation
* @throws StatusException could throw specific SYNC_STATUS_* exceptions
*/
public function SetReadFlag($folderid, $id, $flags) {
public function SetReadFlag($folderid, $id, $flags, $contentParameters) {
ZLog::Write(LOGLEVEL_DEBUG, sprintf("BackendIMAP->SetReadFlag('%s','%s','%s')", $folderid, $id, $flags));
$folderImapid = $this->getImapIdFromFolderId($folderid);
// TODO SyncInterval check + ContentParameters
// see https://jira.zarafa.com/browse/ZP-258 for details
// before setting the read flag, it should be checked if the message is in the SyncInterval
// to determine the cutoffdate use Utils::GetCutOffDate($contentparameters->GetFilterType());
// if the message is not in the interval an StatusException with code SYNC_STATUS_OBJECTNOTFOUND should be thrown
$this->imap_reopenFolder($folderImapid);
if ($flags == 0) {
......@@ -1152,15 +1166,22 @@ class BackendIMAP extends BackendDiff {
*
* @param string $folderid id of the folder
* @param string $id id of the message
* @param ContentParameters $contentParameters
*
* @access public
* @return boolean status of the operation
* @throws StatusException could throw specific SYNC_STATUS_* exceptions
*/
public function DeleteMessage($folderid, $id) {
public function DeleteMessage($folderid, $id, $contentParameters) {
ZLog::Write(LOGLEVEL_DEBUG, sprintf("BackendIMAP->DeleteMessage('%s','%s')", $folderid, $id));
$folderImapid = $this->getImapIdFromFolderId($folderid);
// TODO SyncInterval check + ContentParameters
// see https://jira.zarafa.com/browse/ZP-258 for details
// before deleting the message, it should be checked if the message is in the SyncInterval
// to determine the cutoffdate use Utils::GetCutOffDate($contentparameters->GetFilterType());
// if the message is not in the interval an StatusException with code SYNC_STATUS_OBJECTNOTFOUND should be thrown
$this->imap_reopenFolder($folderImapid);
$s1 = @imap_delete ($this->mbox, $id, FT_UID);
$s11 = @imap_setflag_full($this->mbox, $id, "\\Deleted", FT_UID);
......@@ -1177,16 +1198,22 @@ class BackendIMAP extends BackendDiff {
* @param string $folderid id of the source folder
* @param string $id id of the message
* @param string $newfolderid id of the destination folder
* @param ContentParameters $contentParameters
*
* @access public
* @return boolean status of the operation
* @throws StatusException could throw specific SYNC_MOVEITEMSSTATUS_* exceptions
*/
public function MoveMessage($folderid, $id, $newfolderid) {
public function MoveMessage($folderid, $id, $newfolderid, $contentParameters) {
ZLog::Write(LOGLEVEL_DEBUG, sprintf("BackendIMAP->MoveMessage('%s','%s','%s')", $folderid, $id, $newfolderid));
$folderImapid = $this->getImapIdFromFolderId($folderid);
$newfolderImapid = $this->getImapIdFromFolderId($newfolderid);
// TODO SyncInterval check + ContentParameters
// see https://jira.zarafa.com/browse/ZP-258 for details
// before moving the message, it should be checked if the message is in the SyncInterval
// to determine the cutoffdate use Utils::GetCutOffDate($contentparameters->GetFilterType());
// if the message is not in the interval an StatusException with code SYNC_MOVEITEMSSTATUS_INVALIDSOURCEID should be thrown
$this->imap_reopenFolder($folderImapid);
......
......@@ -477,12 +477,18 @@ class BackendMaildir extends BackendDiff {
* @param string $folderid id of the folder
* @param string $id id of the message
* @param SyncXXX $message the SyncObject containing a message
* @param ContentParameters $contentParameters
*
* @access public
* @return array same return value as StatMessage()
* @throws StatusException could throw specific SYNC_STATUS_* exceptions
*/
public function ChangeMessage($folderid, $id, $message) {
public function ChangeMessage($folderid, $id, $message, $contentParameters) {
// TODO SyncInterval check + ContentParameters
// see https://jira.zarafa.com/browse/ZP-258 for details
// before changing the message, it should be checked if the message is in the SyncInterval
// to determine the cutoffdate use Utils::GetCutOffDate($contentparameters->GetFilterType());
// if the message is not in the interval an StatusException with code SYNC_STATUS_SYNCCANNOTBECOMPLETED should be thrown
return false;
}
......@@ -492,15 +498,22 @@ class BackendMaildir extends BackendDiff {
* @param string $folderid id of the folder
* @param string $id id of the message
* @param int $flags read flag of the message
* @param ContentParameters $contentParameters
*
* @access public
* @return boolean status of the operation
* @throws StatusException could throw specific SYNC_STATUS_* exceptions
*/
public function SetReadFlag($folderid, $id, $flags) {
public function SetReadFlag($folderid, $id, $flags, $contentParameters) {
if($folderid != 'root')
return false;
// TODO SyncInterval check + ContentParameters
// see https://jira.zarafa.com/browse/ZP-258 for details
// before setting the read flag, it should be checked if the message is in the SyncInterval
// to determine the cutoffdate use Utils::GetCutOffDate($contentparameters->GetFilterType());
// if the message is not in the interval an StatusException with code SYNC_STATUS_OBJECTNOTFOUND should be thrown
$fn = $this->findMessage($id);
if(!$fn)
......@@ -530,15 +543,22 @@ class BackendMaildir extends BackendDiff {
*
* @param string $folderid id of the folder
* @param string $id id of the message
* @param ContentParameters $contentParameters
*
* @access public
* @return boolean status of the operation
* @throws StatusException could throw specific SYNC_STATUS_* exceptions
*/
public function DeleteMessage($folderid, $id) {
public function DeleteMessage($folderid, $id, $contentParameters) {
if($folderid != 'root')
return false;
// TODO SyncInterval check + ContentParameters
// see https://jira.zarafa.com/browse/ZP-258 for details
// before deleting the message, it should be checked if the message is in the SyncInterval
// to determine the cutoffdate use Utils::GetCutOffDate($contentparameters->GetFilterType());
// if the message is not in the interval an StatusException with code SYNC_STATUS_OBJECTNOTFOUND should be thrown
$fn = $this->findMessage($id);
if(!$fn)
......@@ -558,12 +578,13 @@ class BackendMaildir extends BackendDiff {
* @param string $folderid id of the source folder
* @param string $id id of the message
* @param string $newfolderid id of the destination folder
* @param ContentParameters $contentParameters
*
* @access public
* @return boolean status of the operation
* @throws StatusException could throw specific SYNC_MOVEITEMSSTATUS_* exceptions
*/
public function MoveMessage($folderid, $id, $newfolderid) {
public function MoveMessage($folderid, $id, $newfolderid, $contentParameters) {
return false;
}
......
......@@ -494,12 +494,13 @@ class BackendVCardDir extends BackendDiff {
* @param string $folderid id of the folder
* @param string $id id of the message
* @param SyncXXX $message the SyncObject containing a message
* @param ContentParameters $contentParameters
*
* @access public
* @return array same return value as StatMessage()
* @throws StatusException could throw specific SYNC_STATUS_* exceptions
*/
public function ChangeMessage($folderid, $id, $message) {
public function ChangeMessage($folderid, $id, $message, $contentParameters) {
ZLog::Write(LOGLEVEL_DEBUG, 'VCDir::ChangeMessage('.$folderid.', '.$id.', ..)');
$mapping = array(
'fileas' => 'FN',
......@@ -582,12 +583,13 @@ class BackendVCardDir extends BackendDiff {
* @param string $folderid id of the folder
* @param string $id id of the message
* @param int $flags read flag of the message
* @param ContentParameters $contentParameters
*
* @access public
* @return boolean status of the operation
* @throws StatusException could throw specific SYNC_STATUS_* exceptions
*/
public function SetReadFlag($folderid, $id, $flags) {
public function SetReadFlag($folderid, $id, $flags, $contentParameters) {
return false;
}
......@@ -596,12 +598,13 @@ class BackendVCardDir extends BackendDiff {
*
* @param string $folderid id of the folder
* @param string $id id of the message
* @param ContentParameters $contentParameters
*
* @access public
* @return boolean status of the operation
* @throws StatusException could throw specific SYNC_STATUS_* exceptions
*/
public function DeleteMessage($folderid, $id) {
public function DeleteMessage($folderid, $id, $contentParameters) {
return unlink($this->getPath() . '/' . $id);
}
......@@ -612,12 +615,13 @@ class BackendVCardDir extends BackendDiff {
* @param string $folderid id of the source folder
* @param string $id id of the message
* @param string $newfolderid id of the destination folder
* @param ContentParameters $contentParameters
*
* @access public
* @return boolean status of the operation
* @throws StatusException could throw specific SYNC_MOVEITEMSSTATUS_* exceptions
*/
public function MoveMessage($folderid, $id, $newfolderid) {
public function MoveMessage($folderid, $id, $newfolderid, $contentParameters) {
return false;
}
......
......@@ -69,6 +69,7 @@ class ImportChangesStream implements IImportChanges {
* Implement interface - never used
*/
public function Config($state, $flags = 0) { return true; }
public function ConfigContentParameters($contentparameters) { return true; }
public function GetState() { return false;}
public function LoadConflicts($contentparameters, $state) { return true; }
......
......@@ -308,12 +308,13 @@ abstract class BackendDiff extends Backend {
* @param string $folderid id of the folder
* @param string $id id of the message
* @param SyncXXX $message the SyncObject containing a message
* @param ContentParameters $contentParameters
*
* @access public
* @return array same return value as StatMessage()
* @throws StatusException could throw specific SYNC_STATUS_* exceptions
*/
public abstract function ChangeMessage($folderid, $id, $message);
public abstract function ChangeMessage($folderid, $id, $message, $contentParameters);
/**
* Changes the 'read' flag of a message on disk. The $flags
......@@ -326,12 +327,13 @@ abstract class BackendDiff extends Backend {
* @param string $folderid id of the folder
* @param string $id id of the message
* @param int $flags read flag of the message
* @param ContentParameters $contentParameters
*
* @access public
* @return boolean status of the operation
* @throws StatusException could throw specific SYNC_STATUS_* exceptions
*/
public abstract function SetReadFlag($folderid, $id, $flags);
public abstract function SetReadFlag($folderid, $id, $flags, $contentParameters);
/**
* Called when the user has requested to delete (really delete) a message. Usually
......@@ -342,12 +344,13 @@ abstract class BackendDiff extends Backend {
*
* @param string $folderid id of the folder
* @param string $id id of the message
* @param ContentParameters $contentParameters
*
* @access public
* @return boolean status of the operation
* @throws StatusException could throw specific SYNC_STATUS_* exceptions
*/
public abstract function DeleteMessage($folderid, $id);
public abstract function DeleteMessage($folderid, $id, $contentParameters);
/**
* Called when the user moves an item on the PDA from one folder to another. Whatever is needed
......@@ -358,12 +361,13 @@ abstract class BackendDiff extends Backend {
* @param string $folderid id of the source folder
* @param string $id id of the message
* @param string $newfolderid id of the destination folder
* @param ContentParameters $contentParameters
*
* @access public
* @return boolean status of the operation
* @throws StatusException could throw specific SYNC_MOVEITEMSSTATUS_* exceptions
*/
public abstract function MoveMessage($folderid, $id, $newfolderid);
public abstract function MoveMessage($folderid, $id, $newfolderid, $contentParameters);
}
?>
\ No newline at end of file
......@@ -52,6 +52,8 @@ class DiffState implements IChanges {
protected $syncstate;
protected $backend;
protected $flags;
protected $contentparameters;
protected $cutoffdate;
/**
* Initializes the state
......@@ -75,6 +77,20 @@ class DiffState implements IChanges {
return true;
}
/**
* Configures additional parameters used for content synchronization
*
* @param ContentParameters $contentparameters
*
* @access public
* @return boolean
* @throws StatusException
*/
public function ConfigContentParameters($contentparameters) {
$this->contentparameters = $contentparameters;
$this->cutoffdate = Utils::GetCutOffDate($contentparameters->GetFilterType());
}
/**
* Returns state
*
......
......@@ -45,8 +45,6 @@
class ExportChangesDiff extends DiffState implements IExportChanges{
private $importer;
private $folderid;
private $contentparameters;
private $cutoffdate;
private $changes;
private $step;
......@@ -64,20 +62,6 @@ class ExportChangesDiff extends DiffState implements IExportChanges{
$this->folderid = $folderid;
}
/**
* Configures additional parameters used for content synchronization
*
* @param ContentParameters $contentparameters
*
* @access public
* @return boolean
* @throws StatusException
*/
public function ConfigContentParameters($contentparameters) {
$this->contentparameters = $contentparameters;
$this->cutoffdate = Utils::GetCutOffDate($contentparameters->GetFilterType());
}
/**
* Sets the importer the exporter will sent it's changes to
* and initializes the Exporter
......
......@@ -107,7 +107,7 @@ class ImportChangesDiff extends DiffState implements IImportChanges {
throw new StatusException(sprintf("ImportChangesDiff->ImportMessageChange('%s','%s'): Conflict detected. Data from PIM will be dropped! Server overwrites PIM. User is informed.", $id, get_class($message)), SYNC_STATUS_CONFLICTCLIENTSERVEROBJECT, null, LOGLEVEL_INFO);
}
$stat = $this->backend->ChangeMessage($this->folderid, $id, $message);
$stat = $this->backend->ChangeMessage($this->folderid, $id, $message, $this->contentparameters);
if(!is_array($stat))
throw new StatusException(sprintf("ImportChangesDiff->ImportMessageChange('%s','%s'): unknown error in backend", $id, get_class($message)), SYNC_STATUS_SYNCCANNOTBECOMPLETED);
......@@ -148,7 +148,7 @@ class ImportChangesDiff extends DiffState implements IImportChanges {
return false;
}
$stat = $this->backend->DeleteMessage($this->folderid, $id);
$stat = $this->backend->DeleteMessage($this->folderid, $id, $this->contentparameters);
if(!$stat)
throw new StatusException(sprintf("ImportChangesDiff->ImportMessageDeletion('%s'): Unknown error in backend", $id), SYNC_STATUS_OBJECTNOTFOUND);
......@@ -177,7 +177,7 @@ class ImportChangesDiff extends DiffState implements IImportChanges {
$change["flags"] = $flags;
$this->updateState("flags", $change);
$stat = $this->backend->SetReadFlag($this->folderid, $id, $flags);
$stat = $this->backend->SetReadFlag($this->folderid, $id, $flags, $this->contentparameters);
if (!$stat)
throw new StatusException(sprintf("ImportChangesDiff->ImportMessageReadFlag('%s','%s'): Error, unable retrieve message from backend", $id, $flags), SYNC_STATUS_OBJECTNOTFOUND);
......@@ -199,7 +199,7 @@ class ImportChangesDiff extends DiffState implements IImportChanges {
if ($this->folderid == SYNC_FOLDER_TYPE_DUMMY || $newfolder == SYNC_FOLDER_TYPE_DUMMY)
throw new StatusException(sprintf("ImportChangesDiff->ImportMessageMove('%s'): can not be done on a dummy folder", $id), SYNC_MOVEITEMSSTATUS_CANNOTMOVE);
return $this->backend->MoveMessage($this->folderid, $id, $newfolder);
return $this->backend->MoveMessage($this->folderid, $id, $newfolder, $this->contentparameters);
}
......
......@@ -63,6 +63,17 @@ interface IChanges {
*/
public function Config($state, $flags = 0);
/**
* Configures additional parameters used for content synchronization
*
* @param ContentParameters $contentparameters
*
* @access public
* @return boolean
* @throws StatusException
*/
public function ConfigContentParameters($contentparameters);
/**
* Reads and returns the current state
*
......
......@@ -44,17 +44,6 @@
************************************************/
interface IExportChanges extends IChanges {
/**
* Configures additional parameters used for content synchronization
*
* @param ContentParameters $contentparameters
*
* @access public
* @return boolean
* @throws StatusException
*/
public function ConfigContentParameters($contentparameters);
/**
* Sets the importer where the exporter will sent its changes to
* This exporter should also be ready to accept calls after this
......
......@@ -1008,11 +1008,7 @@ class Sync extends RequestProcessor {
else
$this->importer->Config($sc->GetParameter($spa, "state"), $spa->GetConflict());
// the CPO is also needed by the importer to check if imported changes
// are inside the sync window - see ZP-258
// TODO ConfigContentParameters needs to be defined in IImportChanges and all implementing importers/backends
// this is currently only supported by the Zarafa Backend
if (method_exists($this->importer, "ConfigContentParameters"))
// the CPO is also needed by the importer to check if imported changes are inside the sync window - see ZP-258
$this->importer->ConfigContentParameters($spa->GetCPO());
}
catch (StatusException $stex) {
......
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