From: Gunnar Wrobel Date: Tue, 3 Nov 2009 10:56:09 +0000 (+0100) Subject: Reorganize interfaces and decorators. X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=a005fd6ede20332cacf84c9ab9552f12a10b38c4;p=horde.git Reorganize interfaces and decorators. --- diff --git a/framework/Kolab_Server/lib/Horde/Kolab/Server.php b/framework/Kolab_Server/lib/Horde/Kolab/Server.php deleted file mode 100644 index d80da8db1..000000000 --- a/framework/Kolab_Server/lib/Horde/Kolab/Server.php +++ /dev/null @@ -1,184 +0,0 @@ - - * @license http://www.fsf.org/copyleft/lgpl.html LGPL - * @link http://pear.horde.org/index.php?package=Kolab_Server - */ - -/** - * This class defines the interface of a generic Kolab user database. - * - * Copyright 2008-2009 The Horde Project (http://www.horde.org/) - * - * See the enclosed file COPYING for license information (LGPL). If you - * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html. - * - * @category Kolab - * @package Kolab_Server - * @author Gunnar Wrobel - * @license http://www.fsf.org/copyleft/lgpl.html LGPL - * @link http://pear.horde.org/index.php?package=Kolab_Server - */ -interface Horde_Kolab_Server -{ - /** - * Connect to the server. - * - * @param string $guid The global unique id of the user. - * @param string $pass The password. - * - * @return NULL. - * - * @throws Horde_Kolab_Server_Exception If the connection failed. - */ - public function connectGuid($guid = '', $pass = ''); - - /** - * Get the current GUID - * - * @return string The GUID of the currently connected user. - */ - public function getGuid(); - - /** - * Get the base GUID of this server - * - * @return string The base GUID of this server. - */ - public function getBaseGuid(); - - /** - * Low level access to reading object data. - * - * This function provides direct access to the Server data. - * - * Usually you should use - * - * - * $object = $server->fetch('a server uid'); - * $variable = $object['attribute'] - * - * - * to access object attributes. This is slower but takes special object - * handling into account (e.g. custom attribute parsing). - * - * @param string $guid The object to retrieve. - * - * @return array An array of attributes. - * - * @throws Horde_Kolab_Server_Exception - */ - public function read($guid); - - /** - * Low level access to reading some object attributes. - * - * @param string $guid The object to retrieve. - * @param string $attrs Restrict to these attributes. - * - * @return array An array of attributes. - * - * @throws Horde_Kolab_Server_Exception - * - * @see Horde_Kolab_Server::read - */ - public function readAttributes($guid, array $attrs); - - /** - * Finds object data matching a given set of criteria. - * - * @param string $query The LDAP search query - * @param array $params Additional search parameters. - * - * @return Horde_Kolab_Server_Result The result object. - * - * @throws Horde_Kolab_Server_Exception - */ - public function find($query, array $params = array()); - - /** - * Finds all object data below a parent matching a given set of criteria. - * - * @param string $query The LDAP search query - * @param string $parent The parent to search below. - * @param array $params Additional search parameters. - * - * @return Horde_Kolab_Server_Result The result object. - * - * @throws Horde_Kolab_Server_Exception - */ - public function findBelow($query, $parent, array $params = array()); - - /** - * Modify existing object data. - * - * @param Horde_Kolab_Server_Object $object The object to be modified. - * @param array $data The attributes of the object - * to be stored. - * - * @return NULL - * - * @throws Horde_Kolab_Server_Exception - */ - public function save(Horde_Kolab_Server_Object $object, array $data); - - /** - * Add new object data. - * - * @param Horde_Kolab_Server_Object $object The object to be added. - * @param array $data The attributes of the object - * to be added. - * - * @return NULL - * - * @throws Horde_Kolab_Server_Exception - */ - public function add(Horde_Kolab_Server_Object $object, array $data); - - /** - * Delete an object. - * - * @param string $guid The GUID of the object to be deleted. - * - * @return NULL - * - * @throws Horde_Kolab_Server_Exception - */ - public function delete($guid); - - /** - * Rename an object. - * - * @param string $guid The GUID of the object to be renamed. - * @param string $new The new GUID of the object. - * - * @return NULL - * - * @throws Horde_Kolab_Server_Exception - */ - public function rename($guid, $new); - - /** - * Return the database schema description. - * - * @return array The schema. - * - * @throws Horde_Kolab_Server_Exception If retrieval of the schema failed. - */ - public function getSchema(); - - /** - * Get the parent GUID of this object. - * - * @param string $guid The GUID of the child. - * - * @return string the parent GUID of this object. - */ - public function getParentGuid($guid); -} \ No newline at end of file diff --git a/framework/Kolab_Server/lib/Horde/Kolab/Server/Cleaner.php b/framework/Kolab_Server/lib/Horde/Kolab/Server/Cleaner.php deleted file mode 100644 index 9df64e515..000000000 --- a/framework/Kolab_Server/lib/Horde/Kolab/Server/Cleaner.php +++ /dev/null @@ -1,263 +0,0 @@ - - * @license http://www.fsf.org/copyleft/lgpl.html LGPL - * @link http://pear.horde.org/index.php?package=Kolab_Server - */ - -/** - * A cleanup decoration for Kolab Servers that allows to remove all added - * objects. - * - * Copyright 2008-2009 The Horde Project (http://www.horde.org/) - * - * See the enclosed file COPYING for license information (LGPL). If you - * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html. - * - * @category Kolab - * @package Kolab_Server - * @author Gunnar Wrobel - * @license http://www.fsf.org/copyleft/lgpl.html LGPL - * @link http://pear.horde.org/index.php?package=Kolab_Server - */ -class Horde_Kolab_Server_Cleaner implements Horde_Kolab_Server -{ - /** - * The server we delegate to. - * - * @var Horde_Kolab_Server - */ - private $_server; - - /** - * The objects added. - * - * @var array - */ - private $_added = array(); - - /** - * Constructor. - * - * @param Horde_Kolab_Server $server The base server connection. - */ - public function __construct(Horde_Kolab_Server $server) - { - $this->_server = $server; - } - - /** - * Connect to the server. - * - * @param string $guid The global unique id of the user. - * @param string $pass The password. - * - * @return NULL. - * - * @throws Horde_Kolab_Server_Exception If the connection failed. - */ - public function connectGuid($guid = null, $pass = null) - { - $this->_server->connectGuid($guid, $pass); - } - - /** - * Get the current GUID - * - * @return string The GUID of the connected user. - */ - public function getGuid() - { - return $this->_server->getGuid(); - } - - /** - * Get the base GUID of this server - * - * @return string The base GUID of this server. - */ - public function getBaseGuid() - { - return $this->_server->getBaseGuid(); - } - - /** - * Low level access to reading object data. - * - * @param string $guid The object to retrieve. - * @param array $attrs Restrict to these attributes. - * - * @return array An array of attributes. - * - * @throws Horde_Kolab_Server_Exception If the search operation hit an error - * or returned no result. - */ - public function read($guid, array $attrs = array()) - { - return $this->_server->read($guid); - } - - /** - * Low level access to reading some object attributes. - * - * @param string $guid The object to retrieve. - * @param string $attrs Restrict to these attributes. - * - * @return array An array of attributes. - * - * @throws Horde_Kolab_Server_Exception - * - * @see Horde_Kolab_Server::read - */ - public function readAttributes($guid, array $attrs) - { - return $this->_server->readAttributes($guid, $attrs); - } - - /** - * Finds object data matching a given set of criteria. - * - * @param string $query The LDAP search query - * @param array $params Additional search parameters. - * - * @return Horde_Kolab_Server_Result The result object. - * - * @throws Horde_Kolab_Server_Exception - */ - public function find($query, array $params = array()) - { - return $this->_server->find($query, $params); - } - - /** - * Finds all object data below a parent matching a given set of criteria. - * - * @param string $query The LDAP search query - * @param string $parent The parent to search below. - * @param array $params Additional search parameters. - * - * @return Horde_Kolab_Server_Result The result object. - * - * @throws Horde_Kolab_Server_Exception - */ - public function findBelow($query, $parent, array $params = array()) - { - return $this->_server->findBelow($query, $parent, $params); - } - - /** - * Modify existing object data. - * - * @param Horde_Kolab_Server_Object $object The object to be modified. - * @param array $data The attributes of the object - * to be stored. - * - * @return NULL - * - * @throws Horde_Kolab_Server_Exception - */ - public function save(Horde_Kolab_Server_Object $object, array $data) - { - $this->_server->save($object, $data); - } - - /** - * Add new object data. - * - * @param Horde_Kolab_Server_Object $object The object to be added. - * @param array $data The attributes of the object - * to be added. - * - * @return NULL - * - * @throws Horde_Kolab_Server_Exception - */ - public function add(Horde_Kolab_Server_Object $object, array $data) - { - $this->_server->add($object, $data); - $this->_added[] = $object->getGuid(); - } - - /** - * Delete an object. - * - * @param string $guid The GUID of the object to be deleted. - * - * @return NULL - * - * @throws Horde_Kolab_Server_Exception - */ - public function delete($guid) - { - $this->_server->delete($guid); - if (in_array($guid, $this->_added)) { - $this->_added = array_diff($this->_added, array($guid)); - } - } - - /** - * Rename an object. - * - * @param string $guid The GUID of the object to be renamed. - * @param string $new The new GUID of the object. - * - * @return NULL - * - * @throws Horde_Kolab_Server_Exception - */ - public function rename($guid, $new) - { - $this->_server->rename($guid, $new); - } - - /** - * Return the ldap schema. - * - * @return Net_LDAP2_Schema The LDAP schema. - * - * @throws Horde_Kolab_Server_Exception If retrieval of the schema failed. - */ - public function getSchema() - { - return $this->_server->getSchema(); - } - - /** - * Get the parent GUID of this object. - * - * @param string $guid The GUID of the child. - * - * @return string the parent GUID of this object. - */ - public function getParentGuid($guid) - { - return $this->_server->getParentGuid($guid); - } - - /** - * Cleanup the server. - * - * @return NULL - */ - public function cleanup() - { - foreach ($this->_added as $guid) { - $this->delete($guid); - } - } - - /** - * Destructor. - */ - public function __destruct() - { - $this->cleanup(); - } -} diff --git a/framework/Kolab_Server/lib/Horde/Kolab/Server/Composite.php b/framework/Kolab_Server/lib/Horde/Kolab/Server/Composite.php deleted file mode 100644 index 78bec71ea..000000000 --- a/framework/Kolab_Server/lib/Horde/Kolab/Server/Composite.php +++ /dev/null @@ -1,129 +0,0 @@ - - * @license http://www.fsf.org/copyleft/lgpl.html LGPL - * @link http://pear.horde.org/index.php?package=Kolab_Server - */ - -/** - * A simple composition of server functionality. - * - * Copyright 2008-2009 The Horde Project (http://www.horde.org/) - * - * See the enclosed file COPYING for license information (LGPL). If you - * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html. - * - * @category Kolab - * @package Kolab_Server - * @author Gunnar Wrobel - * @license http://www.fsf.org/copyleft/lgpl.html LGPL - * @link http://pear.horde.org/index.php?package=Kolab_Server - */ -class Horde_Kolab_Server_Composite -{ - /** - * The server. - * - * @var Horde_Kolab_Server - */ - private $_server; - - /** - * The structure handler for this server. - * - * @var Horde_Kolab_Server_Structure - */ - private $_structure; - - /** - * The search handler for this server. - * - * @var Horde_Kolab_Server_Search - */ - private $_search; - - /** - * The object handler for this server. - * - * @var Horde_Kolab_Server_Objects - */ - private $_objects; - - /** - * The schema handler for this server. - * - * @var Horde_Kolab_Server_Schema - */ - private $_schema; - - /** - * Construct a new Horde_Kolab_Server object. - * - * @param array $params Parameter array. - */ - public function __construct( - Horde_Kolab_Server $server, - Horde_Kolab_Server_Objects $objects, - Horde_Kolab_Server_Structure_Interface $structure, - Horde_Kolab_Server_Search_Interface $search, - Horde_Kolab_Server_Schema $schema - ) { - $this->_server = $server; - $this->_objects = $objects; - $this->_structure = $structure; - $this->_search = $search; - $this->_schema = $schema; - - $structure->setComposite($this); - $search->setComposite($this); - $schema->setComposite($this); - $objects->setComposite($this); - } - - /** - * Retrieve an object attribute. - * - * @param string $key The name of the attribute. - * - * @return mixed The atribute value. - * - * @throws Horde_Kolab_Server_Exception If the attribute does not exist. - */ - public function __get($key) - { - $public = array('server', 'objects', 'structure', 'search', 'schema'); - if (in_array($key, $public)) { - $priv_key = '_' . $key; - return $this->$priv_key; - } - throw new Horde_Kolab_Server_Exception( - sprintf('Attribute %s not supported!', $key) - ); - } - - /** - * Connect to the server. Use this method if the user name you can provide - * does not match a DN. In this case it will be required to map this user - * name first. - * - * @param string $user The user name. - * @param string $pass The password. - * - * @return NULL. - * - * @throws Horde_Kolab_Server_Exception If the connection failed. - */ - public function connect($user = null, $pass = null) - { - /** Bind anonymously first. */ - $this->server->connectGuid(); - $guid = $this->search->searchGuidForUidOrMail($user); - $this->server->connectGuid($guid, $pass); - } -} diff --git a/framework/Kolab_Server/lib/Horde/Kolab/Server/Composite/Base.php b/framework/Kolab_Server/lib/Horde/Kolab/Server/Composite/Base.php new file mode 100644 index 000000000..369b530cc --- /dev/null +++ b/framework/Kolab_Server/lib/Horde/Kolab/Server/Composite/Base.php @@ -0,0 +1,130 @@ + + * @license http://www.fsf.org/copyleft/lgpl.html LGPL + * @link http://pear.horde.org/index.php?package=Kolab_Server + */ + +/** + * A simple composition of server functionality. + * + * Copyright 2008-2009 The Horde Project (http://www.horde.org/) + * + * See the enclosed file COPYING for license information (LGPL). If you + * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html. + * + * @category Kolab + * @package Kolab_Server + * @author Gunnar Wrobel + * @license http://www.fsf.org/copyleft/lgpl.html LGPL + * @link http://pear.horde.org/index.php?package=Kolab_Server + */ +class Horde_Kolab_Server_Composite_Base +implements Horde_Kolab_Server_Composite_Interface +{ + /** + * The server. + * + * @var Horde_Kolab_Server_Interface + */ + private $_server; + + /** + * The structure handler for this server. + * + * @var Horde_Kolab_Server_Structure_Interface + */ + private $_structure; + + /** + * The search handler for this server. + * + * @var Horde_Kolab_Server_Search_Interface + */ + private $_search; + + /** + * The object handler for this server. + * + * @var Horde_Kolab_Server_Objects_Interface + */ + private $_objects; + + /** + * The schema handler for this server. + * + * @var Horde_Kolab_Server_Schema_Interface + */ + private $_schema; + + /** + * Construct a new Horde_Kolab_Server object. + * + * @param array $params Parameter array. + */ + public function __construct( + Horde_Kolab_Server_Interface $server, + Horde_Kolab_Server_Objects_Interface $objects, + Horde_Kolab_Server_Structure_Interface $structure, + Horde_Kolab_Server_Search_Interface $search, + Horde_Kolab_Server_Schema_Interface $schema + ) { + $this->_server = $server; + $this->_objects = $objects; + $this->_structure = $structure; + $this->_search = $search; + $this->_schema = $schema; + + $structure->setComposite($this); + $search->setComposite($this); + $schema->setComposite($this); + $objects->setComposite($this); + } + + /** + * Retrieve an object attribute. + * + * @param string $key The name of the attribute. + * + * @return mixed The atribute value. + * + * @throws Horde_Kolab_Server_Exception If the attribute does not exist. + */ + public function __get($key) + { + $public = array('server', 'objects', 'structure', 'search', 'schema'); + if (in_array($key, $public)) { + $priv_key = '_' . $key; + return $this->$priv_key; + } + throw new Horde_Kolab_Server_Exception( + sprintf('Attribute %s not supported!', $key) + ); + } + + /** + * Connect to the server. Use this method if the user name you can provide + * does not match a DN. In this case it will be required to map this user + * name first. + * + * @param string $user The user name. + * @param string $pass The password. + * + * @return NULL. + * + * @throws Horde_Kolab_Server_Exception If the connection failed. + */ + public function connect($user = null, $pass = null) + { + /** Bind anonymously first. */ + $this->server->connectGuid(); + $guid = $this->search->searchGuidForUidOrMail($user); + $this->server->connectGuid($guid, $pass); + } +} diff --git a/framework/Kolab_Server/lib/Horde/Kolab/Server/Composite/Interface.php b/framework/Kolab_Server/lib/Horde/Kolab/Server/Composite/Interface.php new file mode 100644 index 000000000..6016b4a99 --- /dev/null +++ b/framework/Kolab_Server/lib/Horde/Kolab/Server/Composite/Interface.php @@ -0,0 +1,43 @@ + + * @license http://www.fsf.org/copyleft/lgpl.html LGPL + * @link http://pear.horde.org/index.php?package=Kolab_Server + */ + +/** + * Marks composite server instances. + * + * Copyright 2008-2009 The Horde Project (http://www.horde.org/) + * + * See the enclosed file COPYING for license information (LGPL). If you + * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html. + * + * @category Kolab + * @package Kolab_Server + * @author Gunnar Wrobel + * @license http://www.fsf.org/copyleft/lgpl.html LGPL + * @link http://pear.horde.org/index.php?package=Kolab_Server + */ +interface Horde_Kolab_Server_Composite_Interface +{ + /** + * Connect to the server. Use this method if the user name you can provide + * does not match a DN. In this case it will be required to map this user + * name first. + * + * @param string $user The user name. + * @param string $pass The password. + * + * @return NULL. + * + * @throws Horde_Kolab_Server_Exception If the connection failed. + */ + public function connect($user = null, $pass = null); +} diff --git a/framework/Kolab_Server/lib/Horde/Kolab/Server/Connection.php b/framework/Kolab_Server/lib/Horde/Kolab/Server/Connection.php deleted file mode 100644 index 2da34a2fe..000000000 --- a/framework/Kolab_Server/lib/Horde/Kolab/Server/Connection.php +++ /dev/null @@ -1,43 +0,0 @@ - - * @license http://www.fsf.org/copyleft/lgpl.html LGPL - * @link http://pear.horde.org/index.php?package=Kolab_Server - */ - -/** - * Interface for connection handling. - * - * Copyright 2008-2009 The Horde Project (http://www.horde.org/) - * - * See the enclosed file COPYING for license information (LGPL). If you - * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html. - * - * @category Kolab - * @package Kolab_Server - * @author Gunnar Wrobel - * @license http://www.fsf.org/copyleft/lgpl.html LGPL - * @link http://pear.horde.org/index.php?package=Kolab_Server - */ -interface Horde_Kolab_Server_Connection -{ - /** - * Get the server read connection. - * - * @return mixed The connection for reading data. - */ - public function getRead(); - - /** - * Get the server write connection. - * - * @return mixed The connection for writing data. - */ - public function getWrite(); -} \ No newline at end of file diff --git a/framework/Kolab_Server/lib/Horde/Kolab/Server/Connection/Interface.php b/framework/Kolab_Server/lib/Horde/Kolab/Server/Connection/Interface.php new file mode 100644 index 000000000..b9e868972 --- /dev/null +++ b/framework/Kolab_Server/lib/Horde/Kolab/Server/Connection/Interface.php @@ -0,0 +1,43 @@ + + * @license http://www.fsf.org/copyleft/lgpl.html LGPL + * @link http://pear.horde.org/index.php?package=Kolab_Server + */ + +/** + * Interface for connection handling. + * + * Copyright 2008-2009 The Horde Project (http://www.horde.org/) + * + * See the enclosed file COPYING for license information (LGPL). If you + * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html. + * + * @category Kolab + * @package Kolab_Server + * @author Gunnar Wrobel + * @license http://www.fsf.org/copyleft/lgpl.html LGPL + * @link http://pear.horde.org/index.php?package=Kolab_Server + */ +interface Horde_Kolab_Server_Connection_Interface +{ + /** + * Get the server read connection. + * + * @return mixed The connection for reading data. + */ + public function getRead(); + + /** + * Get the server write connection. + * + * @return mixed The connection for writing data. + */ + public function getWrite(); +} \ No newline at end of file diff --git a/framework/Kolab_Server/lib/Horde/Kolab/Server/Connection/Mock.php b/framework/Kolab_Server/lib/Horde/Kolab/Server/Connection/Mock.php index e78597fea..c3b8b9911 100644 --- a/framework/Kolab_Server/lib/Horde/Kolab/Server/Connection/Mock.php +++ b/framework/Kolab_Server/lib/Horde/Kolab/Server/Connection/Mock.php @@ -26,7 +26,7 @@ * @link http://pear.horde.org/index.php?package=Kolab_Server */ class Horde_Kolab_Server_Connection_Mock -implements Horde_Kolab_Server_Connection +implements Horde_Kolab_Server_Connection_Interface { /** * The LDAP connection handle. diff --git a/framework/Kolab_Server/lib/Horde/Kolab/Server/Connection/Mock/Ldap.php b/framework/Kolab_Server/lib/Horde/Kolab/Server/Connection/Mock/Ldap.php index c97c6718a..ac08fe94e 100644 --- a/framework/Kolab_Server/lib/Horde/Kolab/Server/Connection/Mock/Ldap.php +++ b/framework/Kolab_Server/lib/Horde/Kolab/Server/Connection/Mock/Ldap.php @@ -88,13 +88,13 @@ class Horde_Kolab_Server_Connection_Mock_Ldap throw new Horde_Kolab_Server_Exception('User does not exist!'); } - if (!isset($this->_data[$dn]['userPassword'][0])) { + if (!isset($this->_data[$dn]['data']['userPassword'][0])) { throw new Horde_Kolab_Server_Exception('User has no password entry!'); } - if ($this->_data[$dn]['userPassword'][0] != $pw) { + if ($this->_data[$dn]['data']['userPassword'][0] != $pw) { throw new Horde_Kolab_Server_Exception('Incorrect password!'); } - } else if (!empty($this->params_['no_anonymous_bind'])) { + } else if (!empty($this->_params['no_anonymous_bind'])) { throw new Horde_Kolab_Server_Exception('Anonymous bind is not allowed!'); } @@ -163,7 +163,7 @@ class Horde_Kolab_Server_Connection_Mock_Ldap if (isset($params['scope'])) { if ($params['scope'] == 'base') { if (isset($this->_data[$base])) { - $result = $this->_data[$base]; + $result[] = $this->_data[$base]; } else { $result = array(); } @@ -213,7 +213,7 @@ class Horde_Kolab_Server_Connection_Mock_Ldap if (!empty($base)) { $subtree = array(); foreach ($result as $entry) { - if (strpos($entry['dn'], $base)) { + if (strpos($entry['dn'], $base) !== false) { $subtree[] = $entry; } } diff --git a/framework/Kolab_Server/lib/Horde/Kolab/Server/Connection/Simpleldap.php b/framework/Kolab_Server/lib/Horde/Kolab/Server/Connection/Simpleldap.php index 73c903f20..b308ed907 100644 --- a/framework/Kolab_Server/lib/Horde/Kolab/Server/Connection/Simpleldap.php +++ b/framework/Kolab_Server/lib/Horde/Kolab/Server/Connection/Simpleldap.php @@ -26,7 +26,7 @@ * @link http://pear.horde.org/index.php?package=Kolab_Server */ class Horde_Kolab_Server_Connection_Simpleldap -implements Horde_Kolab_Server_Connection +implements Horde_Kolab_Server_Connection_Interface { /** * The LDAP connection handle. diff --git a/framework/Kolab_Server/lib/Horde/Kolab/Server/Connection/Splittedldap.php b/framework/Kolab_Server/lib/Horde/Kolab/Server/Connection/Splittedldap.php index b5781a7f1..7fb687238 100644 --- a/framework/Kolab_Server/lib/Horde/Kolab/Server/Connection/Splittedldap.php +++ b/framework/Kolab_Server/lib/Horde/Kolab/Server/Connection/Splittedldap.php @@ -26,7 +26,7 @@ * @link http://pear.horde.org/index.php?package=Kolab_Server */ class Horde_Kolab_Server_Connection_Splittedldap -implements Horde_Kolab_Server_Connection +implements Horde_Kolab_Server_Connection_Interface { /** * LDAP read connection handle. diff --git a/framework/Kolab_Server/lib/Horde/Kolab/Server/Decorator/Clean.php b/framework/Kolab_Server/lib/Horde/Kolab/Server/Decorator/Clean.php new file mode 100644 index 000000000..5352d747b --- /dev/null +++ b/framework/Kolab_Server/lib/Horde/Kolab/Server/Decorator/Clean.php @@ -0,0 +1,269 @@ + + * @license http://www.fsf.org/copyleft/lgpl.html LGPL + * @link http://pear.horde.org/index.php?package=Kolab_Server + */ + +/** + * A cleanup decoration for Kolab Servers that allows to remove all added + * objects. + * + * Copyright 2008-2009 The Horde Project (http://www.horde.org/) + * + * See the enclosed file COPYING for license information (LGPL). If you + * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html. + * + * @category Kolab + * @package Kolab_Server + * @author Gunnar Wrobel + * @license http://www.fsf.org/copyleft/lgpl.html LGPL + * @link http://pear.horde.org/index.php?package=Kolab_Server + */ +class Horde_Kolab_Server_Decorator_Clean +implements Horde_Kolab_Server_Interface +{ + /** + * The server we delegate to. + * + * @var Horde_Kolab_Server + */ + private $_server; + + /** + * The objects added. + * + * @var array + */ + private $_added = array(); + + /** + * Constructor. + * + * @param Horde_Kolab_Server $server The base server connection. + */ + public function __construct( + Horde_Kolab_Server_Interface $server + ) { + $this->_server = $server; + } + + /** + * Connect to the server. + * + * @param string $guid The global unique id of the user. + * @param string $pass The password. + * + * @return NULL. + * + * @throws Horde_Kolab_Server_Exception If the connection failed. + */ + public function connectGuid($guid = null, $pass = null) + { + $this->_server->connectGuid($guid, $pass); + } + + /** + * Get the current GUID + * + * @return string The GUID of the connected user. + */ + public function getGuid() + { + return $this->_server->getGuid(); + } + + /** + * Get the base GUID of this server + * + * @return string The base GUID of this server. + */ + public function getBaseGuid() + { + return $this->_server->getBaseGuid(); + } + + /** + * Low level access to reading object data. + * + * @param string $guid The object to retrieve. + * @param array $attrs Restrict to these attributes. + * + * @return array An array of attributes. + * + * @throws Horde_Kolab_Server_Exception If the search operation hit an error + * or returned no result. + */ + public function read($guid, array $attrs = array()) + { + return $this->_server->read($guid); + } + + /** + * Low level access to reading some object attributes. + * + * @param string $guid The object to retrieve. + * @param string $attrs Restrict to these attributes. + * + * @return array An array of attributes. + * + * @throws Horde_Kolab_Server_Exception + * + * @see Horde_Kolab_Server::read + */ + public function readAttributes($guid, array $attrs) + { + return $this->_server->readAttributes($guid, $attrs); + } + + /** + * Finds object data matching a given set of criteria. + * + * @param string $query The LDAP search query + * @param array $params Additional search parameters. + * + * @return Horde_Kolab_Server_Result The result object. + * + * @throws Horde_Kolab_Server_Exception + */ + public function find($query, array $params = array()) + { + return $this->_server->find($query, $params); + } + + /** + * Finds all object data below a parent matching a given set of criteria. + * + * @param string $query The LDAP search query + * @param string $parent The parent to search below. + * @param array $params Additional search parameters. + * + * @return Horde_Kolab_Server_Result The result object. + * + * @throws Horde_Kolab_Server_Exception + */ + public function findBelow($query, $parent, array $params = array()) + { + return $this->_server->findBelow($query, $parent, $params); + } + + /** + * Modify existing object data. + * + * @param Horde_Kolab_Server_Object $object The object to be modified. + * @param array $data The attributes of the object + * to be stored. + * + * @return NULL + * + * @throws Horde_Kolab_Server_Exception + */ + public function save( + Horde_Kolab_Server_Object_Interface $object, + array $data + ) { + $this->_server->save($object, $data); + } + + /** + * Add new object data. + * + * @param Horde_Kolab_Server_Object $object The object to be added. + * @param array $data The attributes of the object + * to be added. + * + * @return NULL + * + * @throws Horde_Kolab_Server_Exception + */ + public function add( + Horde_Kolab_Server_Object_Interface $object, + array $data + ) { + $this->_server->add($object, $data); + $this->_added[] = $object->getGuid(); + } + + /** + * Delete an object. + * + * @param string $guid The GUID of the object to be deleted. + * + * @return NULL + * + * @throws Horde_Kolab_Server_Exception + */ + public function delete($guid) + { + $this->_server->delete($guid); + if (in_array($guid, $this->_added)) { + $this->_added = array_diff($this->_added, array($guid)); + } + } + + /** + * Rename an object. + * + * @param string $guid The GUID of the object to be renamed. + * @param string $new The new GUID of the object. + * + * @return NULL + * + * @throws Horde_Kolab_Server_Exception + */ + public function rename($guid, $new) + { + $this->_server->rename($guid, $new); + } + + /** + * Return the ldap schema. + * + * @return Net_LDAP2_Schema The LDAP schema. + * + * @throws Horde_Kolab_Server_Exception If retrieval of the schema failed. + */ + public function getSchema() + { + return $this->_server->getSchema(); + } + + /** + * Get the parent GUID of this object. + * + * @param string $guid The GUID of the child. + * + * @return string the parent GUID of this object. + */ + public function getParentGuid($guid) + { + return $this->_server->getParentGuid($guid); + } + + /** + * Cleanup the server. + * + * @return NULL + */ + public function cleanup() + { + foreach ($this->_added as $guid) { + $this->delete($guid); + } + } + + /** + * Destructor. + */ + public function __destruct() + { + $this->cleanup(); + } +} diff --git a/framework/Kolab_Server/lib/Horde/Kolab/Server/Decorator/Count.php b/framework/Kolab_Server/lib/Horde/Kolab/Server/Decorator/Count.php new file mode 100644 index 000000000..712110b17 --- /dev/null +++ b/framework/Kolab_Server/lib/Horde/Kolab/Server/Decorator/Count.php @@ -0,0 +1,283 @@ + + * @license http://www.fsf.org/copyleft/lgpl.html LGPL + * @link http://pear.horde.org/index.php?package=Kolab_Server + */ + +/** + * A server decorator that counts the number of database calls and + * reports them via a logger. + * + * Copyright 2008-2009 The Horde Project (http://www.horde.org/) + * + * See the enclosed file COPYING for license information (LGPL). If you + * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html. + * + * @category Kolab + * @package Kolab_Server + * @author Gunnar Wrobel + * @license http://www.fsf.org/copyleft/lgpl.html LGPL + * @link http://pear.horde.org/index.php?package=Kolab_Server + */ +class Horde_Kolab_Server_Decorator_Count +implements Horde_Kolab_Server_Interface +{ + /** + * The server we delegate to. + * + * @var Horde_Kolab_Server + */ + private $_server; + + /** + * The log handler. + * + * @var Horde_Log_Logger + */ + private $_logger; + + /** + * The statistic. + * + * @var array + */ + private $_count = array(); + + /** + * Constructor. + * + * @param Horde_Kolab_Server $server The base server connection. + * @param mixed $logger The log handler. The class must at + * least provide the info() method. + */ + public function __construct( + Horde_Kolab_Server_Interface $server, + $logger + ) { + $this->_server = $server; + $this->_logger = $logger; + } + + /** + * Destructor. + * + * Logs the counted events. + */ + public function __destruct() + { + foreach ($this->_count as $method => $count) { + $this->_logger->info( + sprintf( + 'Horde_Kolab_Server: Method %s called %s times.', + $method, $count + ) + ); + } + } + + /** + * Connect to the server. + * + * @param string $guid The global unique id of the user. + * @param string $pass The password. + * + * @return NULL. + * + * @throws Horde_Kolab_Server_Exception If the connection failed. + */ + public function connectGuid($guid = null, $pass = null) + { + $this->_server->connectGuid($guid, $pass); + $this->_count['connectGuid']++; + } + + /** + * Get the current GUID + * + * @return string The GUID of the connected user. + */ + public function getGuid() + { + return $this->_server->getGuid(); + } + + /** + * Get the base GUID of this server + * + * @return string The base GUID of this server. + */ + public function getBaseGuid() + { + return $this->_server->getBaseGuid(); + } + + /** + * Low level access to reading object data. + * + * @param string $guid The object to retrieve. + * @param array $attrs Restrict to these attributes. + * + * @return array An array of attributes. + * + * @throws Horde_Kolab_Server_Exception If the search operation hit an error + * or returned no result. + */ + public function read($guid, array $attrs = array()) + { + return $this->_server->read($guid); + $this->_count['read']++; + } + + /** + * Low level access to reading some object attributes. + * + * @param string $guid The object to retrieve. + * @param string $attrs Restrict to these attributes. + * + * @return array An array of attributes. + * + * @throws Horde_Kolab_Server_Exception + * + * @see Horde_Kolab_Server::read + */ + public function readAttributes($guid, array $attrs) + { + return $this->_server->readAttributes($guid, $attrs); + $this->_count['readAttributes']++; + } + + /** + * Finds object data matching a given set of criteria. + * + * @param string $query The LDAP search query + * @param array $params Additional search parameters. + * + * @return Horde_Kolab_Server_Result The result object. + * + * @throws Horde_Kolab_Server_Exception + */ + public function find($query, array $params = array()) + { + return $this->_server->find($query, $params); + $this->_count['find']++; + } + + /** + * Finds all object data below a parent matching a given set of criteria. + * + * @param string $query The LDAP search query + * @param string $parent The parent to search below. + * @param array $params Additional search parameters. + * + * @return Horde_Kolab_Server_Result The result object. + * + * @throws Horde_Kolab_Server_Exception + */ + public function findBelow($query, $parent, array $params = array()) + { + return $this->_server->findBelow($query, $parent, $params); + $this->_count['findBelow']++; + } + + /** + * Modify existing object data. + * + * @param Horde_Kolab_Server_Object $object The object to be modified. + * @param array $data The attributes of the object + * to be stored. + * + * @return NULL + * + * @throws Horde_Kolab_Server_Exception + */ + public function save( + Horde_Kolab_Server_Object_Interface $object, + array $data + ) { + $this->_server->save($object, $data); + $this->_count['save']++; + } + + /** + * Add new object data. + * + * @param Horde_Kolab_Server_Object $object The object to be added. + * @param array $data The attributes of the object + * to be added. + * + * @return NULL + * + * @throws Horde_Kolab_Server_Exception + */ + public function add( + Horde_Kolab_Server_Object_Interface $object, + array $data + ) { + $this->_server->add($object, $data); + $this->_count['add']++; + } + + /** + * Delete an object. + * + * @param string $guid The GUID of the object to be deleted. + * + * @return NULL + * + * @throws Horde_Kolab_Server_Exception + */ + public function delete($guid) + { + $this->_server->delete($guid); + $this->_count['delete']++; + } + + /** + * Rename an object. + * + * @param string $guid The GUID of the object to be renamed. + * @param string $new The new GUID of the object. + * + * @return NULL + * + * @throws Horde_Kolab_Server_Exception + */ + public function rename($guid, $new) + { + $this->_server->rename($guid, $new); + $this->_count['rename']++; + } + + /** + * Return the ldap schema. + * + * @return Net_LDAP2_Schema The LDAP schema. + * + * @throws Horde_Kolab_Server_Exception If retrieval of the schema failed. + */ + public function getSchema() + { + return $this->_server->getSchema(); + $this->_count['getSchema']++; + } + + /** + * Get the parent GUID of this object. + * + * @param string $guid The GUID of the child. + * + * @return string the parent GUID of this object. + */ + public function getParentGuid($guid) + { + return $this->_server->getParentGuid($guid); + } +} diff --git a/framework/Kolab_Server/lib/Horde/Kolab/Server/Decorator/Log.php b/framework/Kolab_Server/lib/Horde/Kolab/Server/Decorator/Log.php new file mode 100644 index 000000000..8d9490028 --- /dev/null +++ b/framework/Kolab_Server/lib/Horde/Kolab/Server/Decorator/Log.php @@ -0,0 +1,324 @@ + + * @license http://www.fsf.org/copyleft/lgpl.html LGPL + * @link http://pear.horde.org/index.php?package=Kolab_Server + */ + +/** + * A server delegation that logs server access via Horde_Log_Logger. + * + * Copyright 2008-2009 The Horde Project (http://www.horde.org/) + * + * See the enclosed file COPYING for license information (LGPL). If you + * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html. + * + * @category Kolab + * @package Kolab_Server + * @author Gunnar Wrobel + * @license http://www.fsf.org/copyleft/lgpl.html LGPL + * @link http://pear.horde.org/index.php?package=Kolab_Server + */ +class Horde_Kolab_Server_Decorator_Log +implements Horde_Kolab_Server_Interface +{ + /** + * The server we delegate to. + * + * @var Horde_Kolab_Server + */ + private $_server; + + /** + * The log handler. + * + * @var Horde_Log_Logger + */ + private $_logger; + + /** + * Constructor. + * + * @param Horde_Kolab_Server $server The base server connection. + * @param mixed $logger The log handler. The class must at + * least provide the info() method. + */ + public function __construct( + Horde_Kolab_Server_Interface $server, + $logger + ) { + $this->_server = $server; + $this->_logger = $logger; + } + + /** + * Connect to the server. + * + * @param string $guid The global unique id of the user. + * @param string $pass The password. + * + * @return NULL. + * + * @throws Horde_Kolab_Server_Exception If the connection failed. + */ + public function connectGuid($guid = null, $pass = null) + { + try { + $this->_server->connectGuid($guid, $pass); + $this->_logger->info( + sprintf( + "Successfully connected to the Kolab Server as \"%s\".", + $guid + ) + ); + } catch (Horde_Kolab_Server_Exception $e) { + $this->_logger->info( + sprintf( + "Failed saving object \"%s\"! Error: %s", + $object->getGuid(), $e->getMessage() + ) + ); + } + } + + /** + * Get the current GUID + * + * @return string The GUID of the connected user. + */ + public function getGuid() + { + return $this->_server->getGuid(); + } + + /** + * Get the base GUID of this server + * + * @return string The base GUID of this server. + */ + public function getBaseGuid() + { + return $this->_server->getBaseGuid(); + } + + /** + * Low level access to reading object data. + * + * @param string $guid The object to retrieve. + * @param array $attrs Restrict to these attributes. + * + * @return array An array of attributes. + * + * @throws Horde_Kolab_Server_Exception If the search operation hit an error + * or returned no result. + */ + public function read($guid, array $attrs = array()) + { + return $this->_server->read($guid); + } + + /** + * Low level access to reading some object attributes. + * + * @param string $guid The object to retrieve. + * @param string $attrs Restrict to these attributes. + * + * @return array An array of attributes. + * + * @throws Horde_Kolab_Server_Exception + * + * @see Horde_Kolab_Server::read + */ + public function readAttributes($guid, array $attrs) + { + return $this->_server->readAttributes($guid, $attrs); + } + + /** + * Finds object data matching a given set of criteria. + * + * @param string $query The LDAP search query + * @param array $params Additional search parameters. + * + * @return Horde_Kolab_Server_Result The result object. + * + * @throws Horde_Kolab_Server_Exception + */ + public function find($query, array $params = array()) + { + return $this->_server->find($query, $params); + } + + /** + * Finds all object data below a parent matching a given set of criteria. + * + * @param string $query The LDAP search query + * @param string $parent The parent to search below. + * @param array $params Additional search parameters. + * + * @return Horde_Kolab_Server_Result The result object. + * + * @throws Horde_Kolab_Server_Exception + */ + public function findBelow($query, $parent, array $params = array()) + { + return $this->_server->findBelow($query, $parent, $params); + } + + /** + * Modify existing object data. + * + * @param Horde_Kolab_Server_Object $object The object to be modified. + * @param array $data The attributes of the object + * to be stored. + * + * @return NULL + * + * @throws Horde_Kolab_Server_Exception + */ + public function save( + Horde_Kolab_Server_Object_Interface $object, + array $data + ) { + try { + $this->_server->save($object, $data); + $this->_logger->info( + sprintf( + "The object \"%s\" has been successfully saved!", + $object->getGuid() + ) + ); + } catch (Horde_Kolab_Server_Exception $e) { + $this->_logger->info( + sprintf( + "Failed saving object \"%s\"! Error: %s", + $object->getGuid(), $e->getMessage() + ) + ); + + } + } + + /** + * Add new object data. + * + * @param Horde_Kolab_Server_Object $object The object to be added. + * @param array $data The attributes of the object + * to be added. + * + * @return NULL + * + * @throws Horde_Kolab_Server_Exception + */ + public function add( + Horde_Kolab_Server_Object_Interface $object, + array $data + ) { + try { + $this->_server->add($object, $data); + $this->_logger->info( + sprintf( + "The object \"%s\" has been successfully added!", + $object->getGuid() + ) + ); + } catch (Horde_Kolab_Server_Exception $e) { + $this->_logger->info( + sprintf( + "Failed adding object \"%s\"! Error: %s", + $object->getGuid(), $e->getMessage() + ) + ); + + } + } + + /** + * Delete an object. + * + * @param string $guid The GUID of the object to be deleted. + * + * @return NULL + * + * @throws Horde_Kolab_Server_Exception + */ + public function delete($guid) + { + try { + $this->_server->delete($guid); + $this->_logger->info( + sprintf("The object \"%s\" has been successfully deleted!", $guid) + ); + } catch (Horde_Kolab_Server_Exception $e) { + $this->_logger->info( + sprintf( + "Failed deleting object \"%s\"! Error: %s", + $object->getGuid(), $e->getMessage() + ) + ); + + } + + } + + /** + * Rename an object. + * + * @param string $guid The GUID of the object to be renamed. + * @param string $new The new GUID of the object. + * + * @return NULL + * + * @throws Horde_Kolab_Server_Exception + */ + public function rename($guid, $new) + { + try { + $this->_server->rename($guid, $new); + $this->_logger->info( + sprintf( + "The object \"%s\" has been successfully renamed to \"%s\"!", + $guid, $new + ) + ); + } catch (Horde_Kolab_Server_Exception $e) { + $this->_logger->info( + sprintf( + "Failed saving object \"%s\"! Error: %s", + $object->getGuid(), $e->getMessage() + ) + ); + + } + } + + /** + * Return the ldap schema. + * + * @return Net_LDAP2_Schema The LDAP schema. + * + * @throws Horde_Kolab_Server_Exception If retrieval of the schema failed. + */ + public function getSchema() + { + return $this->_server->getSchema(); + } + + /** + * Get the parent GUID of this object. + * + * @param string $guid The GUID of the child. + * + * @return string the parent GUID of this object. + */ + public function getParentGuid($guid) + { + return $this->_server->getParentGuid($guid); + } +} diff --git a/framework/Kolab_Server/lib/Horde/Kolab/Server/Decorator/Map.php b/framework/Kolab_Server/lib/Horde/Kolab/Server/Decorator/Map.php new file mode 100644 index 000000000..f5ce4ff47 --- /dev/null +++ b/framework/Kolab_Server/lib/Horde/Kolab/Server/Decorator/Map.php @@ -0,0 +1,352 @@ + + * @license http://www.fsf.org/copyleft/lgpl.html LGPL + * @link http://pear.horde.org/index.php?package=Kolab_Server + */ + +/** + * A server delegation that maps object attributes. + * + * Copyright 2008-2009 The Horde Project (http://www.horde.org/) + * + * See the enclosed file COPYING for license information (LGPL). If you + * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html. + * + * @category Kolab + * @package Kolab_Server + * @author Gunnar Wrobel + * @license http://www.fsf.org/copyleft/lgpl.html LGPL + * @link http://pear.horde.org/index.php?package=Kolab_Server + */ +class Horde_Kolab_Server_Decorator_Map +implements Horde_Kolab_Server_Interface +{ + /** + * The server we delegate to. + * + * @var Horde_Kolab_Server + */ + private $_server; + + /** + * The attribute mapping. + * + * @var array + */ + private $_mapping; + + /** + * Constructor. + * + * @param Horde_Kolab_Server $server The base server connection. + * @param array $mapping The attribute mapping. + */ + public function __construct( + Horde_Kolab_Server_Interface $server, + array $mapping + ) { + $this->_server = $server; + $this->_mapping = $mapping; + } + + /** + * Connect to the server. Use this method if the user name you can provide + * does not match a GUID. In this case it will be required to map this user + * name first. + * + * @param string $user The user name. + * @param string $pass The password. + * + * @return NULL. + * + * @throws Horde_Kolab_Server_Exception If the connection failed. + */ + public function connect($user = null, $pass = null) + { + $this->_server->connect($user, $pass); + } + + /** + * Connect to the server. + * + * @param string $guid The global unique id of the user. + * @param string $pass The password. + * + * @return NULL. + * + * @throws Horde_Kolab_Server_Exception If the connection failed. + */ + public function connectGuid($guid = '', $pass = '') + { + $this->_server->connectGuid($guid, $pass); + } + + /** + * Get the current GUID + * + * @return string The GUID of the connected user. + */ + public function getGuid() + { + $this->_server->getGuid(); + } + + /** + * Get the base GUID of this server + * + * @return string The base GUID of this server. + */ + public function getBaseGuid() + { + $this->_server->getBaseGuid(); + } + + /** + * Low level access to reading object data. + * + * @param string $guid The object to retrieve. + * @param array $attrs Restrict to these attributes. + * + * @return array An array of attributes. + * + * @throws Horde_Kolab_Server_Exception If the search operation hit an error + * or returned no result. + */ + public function read($guid, array $attrs = array()) + { + $data = $this->_server->read($guid); + $this->unmapAttributes($data); + return $data; + } + + /** + * Low level access to reading some object attributes. + * + * @param string $guid The object to retrieve. + * @param string $attrs Restrict to these attributes. + * + * @return array An array of attributes. + * + * @throws Horde_Kolab_Server_Exception + * + * @see Horde_Kolab_Server::read + */ + public function readAttributes($guid, array $attrs) + { + $this->mapKeys($attrs); + $data = $this->_server->readAttributes($guid, $attrs); + $this->unmapAttributes($data); + return $data; + } + + /** + * Finds object data matching a given set of criteria. + * + * @param string $query The LDAP search query + * @param array $params Additional search parameters. + * + * @return array The result array. + * + * @throws Horde_Kolab_Server_Exception + */ + public function find($query, array $params = array()) + { + $criteria = new Horde_Kolab_Server_Query_Element_Mapped($criteria, $this); + $data = $this->_server->find($criteria, $params); + $this->unmapAttributes($data); + return $data; + } + + /** + * Finds all object data below a parent matching a given set of criteria. + * + * @param string $query The LDAP search query + * @param string $parent The parent to search below. + * @param array $params Additional search parameters. + * + * @return array The result array. + * + * @throws Horde_Kolab_Server_Exception + */ + public function findBelow($query, $parent, array $params = array()) + { + $criteria = new Horde_Kolab_Server_Query_Element_Mapped($criteria, $this); + $data = $this->_server->findBelow($criteria, $parent, $params); + $this->unmapAttributes($data); + return $data; + } + + + /** + * Modify existing object data. + * + * @param string $guid The GUID of the object to be added. + * @param array $data The attributes of the object to be added. + * + * @return NULL + * + * @throws Horde_Kolab_Server_Exception + */ + public function save( + Horde_Kolab_Server_Object_Interface $object, + array $data + ) { + //@todo: This will not work this way as we need to map internal + // attributes. + $this->mapAttributes($data); + $this->_server->save($object, $data); + } + + /** + * Add new object data. + * + * @param string $guid The GUID of the object to be added. + * @param array $data The attributes of the object to be added. + * + * @return NULL + * + * @throws Horde_Kolab_Server_Exception + */ + public function add( + Horde_Kolab_Server_Object_Interface $object, + array $data + ) { + //@todo: This will not work this way as we need to map internal + // attributes. + $this->mapAttributes($data); + $this->_server->add($object, $data); + } + + /** + * Delete an object. + * + * @param string $guid The GUID of the object to be deleted. + * + * @return NULL + * + * @throws Horde_Kolab_Server_Exception + */ + public function delete($guid) + { + $this->_server->delete($guid); + } + + /** + * Rename an object. + * + * @param string $guid The GUID of the object to be renamed. + * @param string $new The new GUID of the object. + * + * @return NULL + * + * @throws Horde_Kolab_Server_Exception + */ + public function rename($guid, $new) + { + $this->_server->rename($guid, $new); + } + + /** + * Return the ldap schema. + * + * @return Net_LDAP2_Schema The LDAP schema. + * + * @throws Horde_Kolab_Server_Exception If retrieval of the schema failed. + */ + public function getSchema() + { + return $this->_server->getSchema(); + } + + + /** + * Map attributes defined within this library to their real world + * counterparts. + * + * @param array &$data The data that has been read and needs to be mapped. + * + * @return NULL + */ + protected function unmapAttributes(&$data) + { + foreach ($data as &$element) { + foreach ($this->mapping as $attribute => $map) { + if (isset($element[$map])) { + $element[$attribute] = $element[$map]; + unset($element[$map]); + } + } + } + } + + /** + * Map attributes defined within this library into their real world + * counterparts. + * + * @param array &$data The data to be written. + * + * @return NULL + */ + protected function mapAttributes(&$data) + { + foreach ($this->mapping as $attribute => $map) { + if (isset($data[$attribute])) { + $data[$map] = $data[$attribute]; + unset($data[$attribute]); + } + } + } + + /** + * Map attribute keys defined within this library into their real world + * counterparts. + * + * @param array &$keys The attribute keys. + * + * @return NULL + */ + protected function mapKeys(&$keys) + { + foreach ($this->mapping as $attribute => $map) { + $key = array_search($attribute, $keys); + if ($key !== false) { + $keys[$key] = $map; + } + } + } + + /** + * Map a single attribute key defined within this library into its real + * world counterpart. + * + * @param array $field The attribute name. + * + * @return The real name of this attribute on the server we connect to. + */ + public function mapField($field) + { + if (isset($this->mapping[$field])) { + return $this->mapping[$field]; + } + return $field; + } + + /** + * Get the parent GUID of this object. + * + * @param string $guid The GUID of the child. + * + * @return string the parent GUID of this object. + */ + public function getParentGuid($guid) + { + return $this->_server->getParentGuid($guid); + } +} diff --git a/framework/Kolab_Server/lib/Horde/Kolab/Server/Factory.php b/framework/Kolab_Server/lib/Horde/Kolab/Server/Factory.php deleted file mode 100644 index ec2a8950f..000000000 --- a/framework/Kolab_Server/lib/Horde/Kolab/Server/Factory.php +++ /dev/null @@ -1,95 +0,0 @@ - - * @license http://www.fsf.org/copyleft/lgpl.html LGPL - * @link http://pear.horde.org/index.php?package=Kolab_Server - */ - -/** - * The interface of Kolab server factories. - * - * Copyright 2008-2009 The Horde Project (http://www.horde.org/) - * - * See the enclosed file COPYING for license information (LGPL). If you - * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html. - * - * @category Kolab - * @package Kolab_Server - * @author Gunnar Wrobel - * @license http://www.fsf.org/copyleft/lgpl.html LGPL - * @link http://pear.horde.org/index.php?package=Kolab_Server - */ -interface Horde_Kolab_Server_Factory -{ - /** - * Returns a concrete Horde_Kolab_Server_Composite instance. - * - * @return Horde_Kolab_Server_Composite The newly created concrete - * Horde_Kolab_Server_Composite - * instance. - */ - public function getComposite(); - - /** - * Returns the conn factory. - * - * @return Horde_Kolab_Server_Factory_Conn The connection factory. - */ - public function getConnectionFactory(); - - /** - * Returns the server configuration parameters. - * - * @return array The configuration parameters. - */ - public function getConfiguration(); - - /** - * Return the server connection that should be used. - * - * @return Horde_Kolab_Server The Horde_Kolab_Server connection. - */ - public function getServer(); - - /** - * Return the server that should be used. - * - * @return Horde_Kolab_Server_Connection The connection. - */ - public function getConnection(); - - /** - * Return the object handler that should be used. - * - * @return Horde_Kolab_Server_Objects The handler for objects on the server. - */ - public function getObjects(); - - /** - * Return the structural representation that should be used. - * - * @return Horde_Kolab_Server_Structure The representation of the db - * structure. - */ - public function getStructure(); - - /** - * Return the search handler that should be used. - * - * @return Horde_Kolab_Server_Search The search handler. - */ - public function getSearch(); - - /** - * Return the db schema representation that should be used. - * - * @return Horde_Kolab_Server_Schema The db schema representation. - */ - public function getSchema(); -} \ No newline at end of file diff --git a/framework/Kolab_Server/lib/Horde/Kolab/Server/Factory/Base.php b/framework/Kolab_Server/lib/Horde/Kolab/Server/Factory/Base.php index 2f22f3d4a..5c4597efe 100644 --- a/framework/Kolab_Server/lib/Horde/Kolab/Server/Factory/Base.php +++ b/framework/Kolab_Server/lib/Horde/Kolab/Server/Factory/Base.php @@ -26,7 +26,7 @@ * @link http://pear.horde.org/index.php?package=Kolab_Server */ abstract class Horde_Kolab_Server_Factory_Base -implements Horde_Kolab_Server_Factory +implements Horde_Kolab_Server_Factory_Interface { /** * The connection factory. @@ -52,7 +52,7 @@ implements Horde_Kolab_Server_Factory * server. */ public function __construct( - Horde_Kolab_Server_Factory_Conn $factory, + Horde_Kolab_Server_Factory_Connection_Interface $factory, array $config ) { $this->_conn_factory = $factory; @@ -129,7 +129,7 @@ implements Horde_Kolab_Server_Factory */ public function getComposite() { - $composite = new Horde_Kolab_Server_Composite( + $composite = new Horde_Kolab_Server_Composite_Base( $this->getServer(), $this->getObjects(), $this->getStructure(), diff --git a/framework/Kolab_Server/lib/Horde/Kolab/Server/Factory/Cleaner.php b/framework/Kolab_Server/lib/Horde/Kolab/Server/Factory/Cleaner.php deleted file mode 100644 index 9c791082d..000000000 --- a/framework/Kolab_Server/lib/Horde/Kolab/Server/Factory/Cleaner.php +++ /dev/null @@ -1,143 +0,0 @@ - - * @license http://www.fsf.org/copyleft/lgpl.html LGPL - * @link http://pear.horde.org/index.php?package=Kolab_Server - */ - -/** - * A factory decorator that adds cleaning to the generated instances. - * - * Copyright 2009 The Horde Project (http://www.horde.org/) - * - * See the enclosed file COPYING for license information (LGPL). If you - * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html. - * - * @category Kolab - * @package Kolab_Server - * @author Gunnar Wrobel - * @license http://www.fsf.org/copyleft/lgpl.html LGPL - * @link http://pear.horde.org/index.php?package=Kolab_Server - */ -class Horde_Kolab_Server_Factory_Cleaner -implements Horde_Kolab_Server_Factory -{ - /** - * The factory used for creating the instances. - * - * @var Horde_Kolab_Server_Factory - */ - private $_factory; - - /** - * Constructor. - * - * @param Horde_Kolab_Server_Factory $factory The base factory. - */ - public function __construct(Horde_Kolab_Server_Factory $factory) - { - $this->_factory = $factory; - } - - /** - * Returns the conn factory. - * - * @return Horde_Kolab_Server_Factory_Conn The connection factory. - */ - public function getConnectionFactory() - { - return $this->_factory->getConnectionFactory(); - } - - /** - * Returns the server configuration parameters. - * - * @return array The configuration parameters. - */ - public function getConfiguration() - { - return $this->_factory->getConfiguration(); - } - - /** - * Return the server connection that should be used. - * - * @return Horde_Kolab_Server The Horde_Kolab_Server connection. - */ - public function getServer() - { - $server = $this->_factory->getServer(); - $server = new Horde_Kolab_Server_Cleaner($server); - return $server; - } - - /** - * Return the server that should be used. - * - * @return Horde_Kolab_Server_Connection The connection. - */ - public function getConnection() - { - return $this->_factory->getConnection(); - } - - /** - * Returns a concrete Horde_Kolab_Server_Composite instance. - * - * @return Horde_Kolab_Server_Composite The newly created concrete - * Horde_Kolab_Server_Composite - * instance. - */ - public function getComposite() - { - return $this->_factory->getComposite(); - } - - /** - * Return the object handler that should be used. - * - * @return Horde_Kolab_Server_Objects The handler for objects on the server. - */ - public function getObjects() - { - return $this->_factory->getObjects(); - } - - /** - * Return the structural representation that should be used. - * - * @return Horde_Kolab_Server_Structure The representation of the db - * structure. - */ - public function getStructure() - { - return $this->_factory->getStructure(); - } - - /** - * Return the search handler that should be used. - * - * @return Horde_Kolab_Server_Search The search handler. - */ - public function getSearch() - { - return $this->_factory->getSearch(); - } - - /** - * Return the db schema representation that should be used. - * - * @return Horde_Kolab_Server_Schema The db schema representation. - */ - public function getSchema() - { - return $this->_factory->getSchema(); - } - -} \ No newline at end of file diff --git a/framework/Kolab_Server/lib/Horde/Kolab/Server/Factory/Configuration.php b/framework/Kolab_Server/lib/Horde/Kolab/Server/Factory/Configuration.php index b031dd9be..3bf6964c2 100644 --- a/framework/Kolab_Server/lib/Horde/Kolab/Server/Factory/Configuration.php +++ b/framework/Kolab_Server/lib/Horde/Kolab/Server/Factory/Configuration.php @@ -26,7 +26,7 @@ * @link http://pear.horde.org/index.php?package=Kolab_Server */ class Horde_Kolab_Server_Factory_Configuration -implements Horde_Kolab_Server_Factory +implements Horde_Kolab_Server_Factory_Interface { /** * Configuration parameters for the server. @@ -49,7 +49,7 @@ implements Horde_Kolab_Server_Factory { $this->_configuration = $config; - $connection_factory = new Horde_Kolab_Server_Factory_Conn_Configuration( + $connection_factory = new Horde_Kolab_Server_Factory_Connection_Configuration( $config ); $factory = new Horde_Kolab_Server_Factory_Kolab( @@ -57,19 +57,19 @@ implements Horde_Kolab_Server_Factory ); if (isset($config['logger'])) { - $factory = new Horde_Kolab_Server_Factory_Logged( + $factory = new Horde_Kolab_Server_Factory_Decorator_Log( $factory, $config['logger'] ); } if (isset($config['map'])) { - $factory = new Horde_Kolab_Server_Factory_Mapped( + $factory = new Horde_Kolab_Server_Factory_Decorator_Map( $factory, $config['map'] ); } if (!empty($config['cleanup'])) { - $factory = new Horde_Kolab_Server_Factory_Cleaner( + $factory = new Horde_Kolab_Server_Factory_Decorator_Clean( $factory ); } diff --git a/framework/Kolab_Server/lib/Horde/Kolab/Server/Factory/Conn.php b/framework/Kolab_Server/lib/Horde/Kolab/Server/Factory/Conn.php deleted file mode 100644 index 3e2e7d7e4..000000000 --- a/framework/Kolab_Server/lib/Horde/Kolab/Server/Factory/Conn.php +++ /dev/null @@ -1,52 +0,0 @@ - - * @license http://www.fsf.org/copyleft/lgpl.html LGPL - * @link http://pear.horde.org/index.php?package=Kolab_Server - */ - -/** - * The interface of Kolab server connection factories. - * - * Copyright 2008-2009 The Horde Project (http://www.horde.org/) - * - * See the enclosed file COPYING for license information (LGPL). If you - * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html. - * - * @category Kolab - * @package Kolab_Server - * @author Gunnar Wrobel - * @license http://www.fsf.org/copyleft/lgpl.html LGPL - * @link http://pear.horde.org/index.php?package=Kolab_Server - */ -interface Horde_Kolab_Server_Factory_Conn -{ - /** - * Get the connection configuration. - * - * @return array $configuration The configuration parameters. - */ - public function getConfiguration(); - - /** - * Set the connection configuration. - * - * @param array $configuration The configuration parameters. - * - * @return NULL - */ - public function setConfiguration(array $configuration); - - /** - * Return the server connection that should be used. - * - * @return Horde_Kolab_Server_Connection The server connection. - */ - public function getConnection(); -} \ No newline at end of file diff --git a/framework/Kolab_Server/lib/Horde/Kolab/Server/Factory/Conn/Base.php b/framework/Kolab_Server/lib/Horde/Kolab/Server/Factory/Conn/Base.php deleted file mode 100644 index 1336cbdff..000000000 --- a/framework/Kolab_Server/lib/Horde/Kolab/Server/Factory/Conn/Base.php +++ /dev/null @@ -1,64 +0,0 @@ - - * @license http://www.fsf.org/copyleft/lgpl.html LGPL - * @link http://pear.horde.org/index.php?package=Kolab_Server - */ - -/** - * A base connection factory definition. - * - * Copyright 2009 The Horde Project (http://www.horde.org/) - * - * See the enclosed file COPYING for license information (LGPL). If you - * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html. - * - * @category Kolab - * @package Kolab_Server - * @author Gunnar Wrobel - * @license http://www.fsf.org/copyleft/lgpl.html LGPL - * @link http://pear.horde.org/index.php?package=Kolab_Server - */ -abstract class Horde_Kolab_Server_Factory_Conn_Base -implements Horde_Kolab_Server_Factory_Conn -{ - /** - * Connection parameters. - * - * @var array - */ - private $_configuration; - - /** - * Get the connection configuration. - * - * @return array $configuration The configuration parameters. - */ - public function getConfiguration() - { - if (!isset($this->_configuration)) { - throw new Horde_Kolab_Server_Exception( - 'The configuration has not been set!' - ); - } - return $this->_configuration; - } - - /** - * Set the connection configuration. - * - * @param array $configuration The configuration parameters. - * - * @return NULL - */ - public function setConfiguration(array $configuration) - { - $this->_configuration = $configuration; - } -} \ No newline at end of file diff --git a/framework/Kolab_Server/lib/Horde/Kolab/Server/Factory/Conn/Configuration.php b/framework/Kolab_Server/lib/Horde/Kolab/Server/Factory/Conn/Configuration.php deleted file mode 100644 index 6f4dba1dd..000000000 --- a/framework/Kolab_Server/lib/Horde/Kolab/Server/Factory/Conn/Configuration.php +++ /dev/null @@ -1,92 +0,0 @@ - - * @license http://www.fsf.org/copyleft/lgpl.html LGPL - * @link http://pear.horde.org/index.php?package=Kolab_Server - */ - -/** - * A factory that receives all required details via configuration parameters. - * - * Copyright 2009 The Horde Project (http://www.horde.org/) - * - * See the enclosed file COPYING for license information (LGPL). If you - * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html. - * - * @category Kolab - * @package Kolab_Server - * @author Gunnar Wrobel - * @license http://www.fsf.org/copyleft/lgpl.html LGPL - * @link http://pear.horde.org/index.php?package=Kolab_Server - */ -class Horde_Kolab_Server_Factory_Conn_Configuration -extends Horde_Kolab_Server_Factory_Conn_Base -{ - /** - * Configuration parameters for the connection. - * - * @var array - */ - private $_configuration; - - /** - * The factory used for creating the instances. - * - * @var Horde_Kolab_Server_Factory - */ - private $_factory; - - /** - * Constructor. - */ - public function __construct(array $config) - { - $this->setConfiguration($config); - } - - /** - * Get the connection configuration. - * - * @return array $configuration The configuration parameters. - */ - public function getConfiguration() - { - return $this->_configuration; - } - - /** - * Set the connection configuration. - * - * @param array $configuration The configuration parameters. - * - * @return NULL - */ - public function setConfiguration(array $configuration) - { - $this->_configuration = $configuration; - - if (empty($configuration['mock'])) { - $this->_factory = new Horde_Kolab_Server_Factory_Conn_Ldap(); - } else { - $this->_factory = new Horde_Kolab_Server_Factory_Conn_Mock(); - } - - $this->_factory->setConfiguration($configuration); - } - - /** - * Return the server connection that should be used. - * - * @return Horde_Kolab_Server_Connection The server connection. - */ - public function getConnection() - { - return $this->_factory->getConnection(); - } -} \ No newline at end of file diff --git a/framework/Kolab_Server/lib/Horde/Kolab/Server/Factory/Conn/Injector.php b/framework/Kolab_Server/lib/Horde/Kolab/Server/Factory/Conn/Injector.php deleted file mode 100644 index 9027b9ad3..000000000 --- a/framework/Kolab_Server/lib/Horde/Kolab/Server/Factory/Conn/Injector.php +++ /dev/null @@ -1,66 +0,0 @@ - - * @license http://www.fsf.org/copyleft/lgpl.html LGPL - * @link http://pear.horde.org/index.php?package=Kolab_Server - */ - -/** - * A factory that generates connections using the Horde_Injector. - * - * Copyright 2009 The Horde Project (http://www.horde.org/) - * - * See the enclosed file COPYING for license information (LGPL). If you - * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html. - * - * @category Kolab - * @package Kolab_Server - * @author Gunnar Wrobel - * @license http://www.fsf.org/copyleft/lgpl.html LGPL - * @link http://pear.horde.org/index.php?package=Kolab_Server - */ -class Horde_Kolab_Server_Factory_Conn_Injector -extends Horde_Kolab_Server_Factory_Conn_Base -{ - /** - * The injector providing our context. - * - * @var Horde_Injector - */ - private $_injector; - - /** - * Constructor. - * - * @param Horde_Injector The injector to use. - */ - public function __construct(Horde_Injector $injector) - { - $this->_injector = $injector; - } - - /** - * Return the server connection that should be used. - * - * @return Horde_Kolab_Server_Connection The server connection. - */ - public function getConnection() - { - $factory = $this->_injector->getInstance( - 'Horde_Kolab_Server_Factory_Conn' - ); - $factory->setConfiguration( - $this->_injector->getInstance( - 'Horde_Kolab_Server_Configuration' - ) - ); - $connection = $factory->getConnection(); - return $connection; - } -} \ No newline at end of file diff --git a/framework/Kolab_Server/lib/Horde/Kolab/Server/Factory/Conn/Ldap.php b/framework/Kolab_Server/lib/Horde/Kolab/Server/Factory/Conn/Ldap.php deleted file mode 100644 index f483de804..000000000 --- a/framework/Kolab_Server/lib/Horde/Kolab/Server/Factory/Conn/Ldap.php +++ /dev/null @@ -1,84 +0,0 @@ - - * @license http://www.fsf.org/copyleft/lgpl.html LGPL - * @link http://pear.horde.org/index.php?package=Kolab_Server - */ - -/** - * A factory that generates LDAP connections. - * - * Copyright 2009 The Horde Project (http://www.horde.org/) - * - * See the enclosed file COPYING for license information (LGPL). If you - * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html. - * - * @category Kolab - * @package Kolab_Server - * @author Gunnar Wrobel - * @license http://www.fsf.org/copyleft/lgpl.html LGPL - * @link http://pear.horde.org/index.php?package=Kolab_Server - */ -class Horde_Kolab_Server_Factory_Conn_Ldap -extends Horde_Kolab_Server_Factory_Conn_Base -{ - /** - * Set the connection configuration. - * - * @param array $configuration The configuration parameters. - * - * @return NULL - */ - public function setConfiguration(array $configuration) - { - if (!isset($configuration['basedn'])) { - throw new Horde_Kolab_Server_Exception('The base DN is missing!'); - } - - if (isset($configuration['server'])) { - $configuration['host'] = $configuration['server']; - unset($configuration['server']); - } - - if (isset($configuration['phpdn'])) { - $configuration['binddn'] = $configuration['phpdn']; - unset($configuration['phpdn']); - } - - if (isset($configuration['phppw'])) { - $configuration['bindpw'] = $configuration['phppw']; - unset($configuration['phppw']); - } - - parent::setConfiguration($configuration); - } - - /** - * Return the server connection that should be used. - * - * @return Horde_Kolab_Server_Connection The server connection. - */ - public function getConnection() - { - $configuration = $this->getConfiguration(); - $ldap_read = new Net_LDAP2($configuration); - if (isset($configuration['host_master'])) { - $configuration['host'] = $configuration['host_master']; - $ldap_write = new Net_LDAP2($configuration); - $connection = new Horde_Kolab_Server_Connection_Splittedldap( - $ldap_read, $ldap_write - ); - } else { - $connection = new Horde_Kolab_Server_Connection_Simpleldap( - $ldap_read - ); - } - return $connection; - } -} \ No newline at end of file diff --git a/framework/Kolab_Server/lib/Horde/Kolab/Server/Factory/Conn/Mock.php b/framework/Kolab_Server/lib/Horde/Kolab/Server/Factory/Conn/Mock.php deleted file mode 100644 index 253821143..000000000 --- a/framework/Kolab_Server/lib/Horde/Kolab/Server/Factory/Conn/Mock.php +++ /dev/null @@ -1,51 +0,0 @@ - - * @license http://www.fsf.org/copyleft/lgpl.html LGPL - * @link http://pear.horde.org/index.php?package=Kolab_Server - */ - -/** - * A factory that generates mock connections. - * - * Copyright 2009 The Horde Project (http://www.horde.org/) - * - * See the enclosed file COPYING for license information (LGPL). If you - * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html. - * - * @category Kolab - * @package Kolab_Server - * @author Gunnar Wrobel - * @license http://www.fsf.org/copyleft/lgpl.html LGPL - * @link http://pear.horde.org/index.php?package=Kolab_Server - */ -class Horde_Kolab_Server_Factory_Conn_Mock -extends Horde_Kolab_Server_Factory_Conn_Base -{ - /** - * Return the server connection that should be used. - * - * @return Horde_Kolab_Server_Connection The server connection. - */ - public function getConnection() - { - $config = $this->getConfiguration(); - if (isset($config['data'])) { - $data = $config['data']; - } else { - $data = array(); - } - $connection = new Horde_Kolab_Server_Connection_Mock( - new Horde_Kolab_Server_Connection_Mock_Ldap( - $config, $data - ) - ); - return $connection; - } -} \ No newline at end of file diff --git a/framework/Kolab_Server/lib/Horde/Kolab/Server/Factory/Connection/Base.php b/framework/Kolab_Server/lib/Horde/Kolab/Server/Factory/Connection/Base.php new file mode 100644 index 000000000..3e1119a8e --- /dev/null +++ b/framework/Kolab_Server/lib/Horde/Kolab/Server/Factory/Connection/Base.php @@ -0,0 +1,64 @@ + + * @license http://www.fsf.org/copyleft/lgpl.html LGPL + * @link http://pear.horde.org/index.php?package=Kolab_Server + */ + +/** + * A base connection factory definition. + * + * Copyright 2009 The Horde Project (http://www.horde.org/) + * + * See the enclosed file COPYING for license information (LGPL). If you + * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html. + * + * @category Kolab + * @package Kolab_Server + * @author Gunnar Wrobel + * @license http://www.fsf.org/copyleft/lgpl.html LGPL + * @link http://pear.horde.org/index.php?package=Kolab_Server + */ +abstract class Horde_Kolab_Server_Factory_Connection_Base +implements Horde_Kolab_Server_Factory_Connection_Interface +{ + /** + * Connection parameters. + * + * @var array + */ + private $_configuration; + + /** + * Get the connection configuration. + * + * @return array $configuration The configuration parameters. + */ + public function getConfiguration() + { + if (!isset($this->_configuration)) { + throw new Horde_Kolab_Server_Exception( + 'The configuration has not been set!' + ); + } + return $this->_configuration; + } + + /** + * Set the connection configuration. + * + * @param array $configuration The configuration parameters. + * + * @return NULL + */ + public function setConfiguration(array $configuration) + { + $this->_configuration = $configuration; + } +} \ No newline at end of file diff --git a/framework/Kolab_Server/lib/Horde/Kolab/Server/Factory/Connection/Configuration.php b/framework/Kolab_Server/lib/Horde/Kolab/Server/Factory/Connection/Configuration.php new file mode 100644 index 000000000..c64573e0d --- /dev/null +++ b/framework/Kolab_Server/lib/Horde/Kolab/Server/Factory/Connection/Configuration.php @@ -0,0 +1,92 @@ + + * @license http://www.fsf.org/copyleft/lgpl.html LGPL + * @link http://pear.horde.org/index.php?package=Kolab_Server + */ + +/** + * A factory that receives all required details via configuration parameters. + * + * Copyright 2009 The Horde Project (http://www.horde.org/) + * + * See the enclosed file COPYING for license information (LGPL). If you + * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html. + * + * @category Kolab + * @package Kolab_Server + * @author Gunnar Wrobel + * @license http://www.fsf.org/copyleft/lgpl.html LGPL + * @link http://pear.horde.org/index.php?package=Kolab_Server + */ +class Horde_Kolab_Server_Factory_Connection_Configuration +extends Horde_Kolab_Server_Factory_Connection_Base +{ + /** + * Configuration parameters for the connection. + * + * @var array + */ + private $_configuration; + + /** + * The factory used for creating the instances. + * + * @var Horde_Kolab_Server_Factory + */ + private $_factory; + + /** + * Constructor. + */ + public function __construct(array $config) + { + $this->setConfiguration($config); + } + + /** + * Get the connection configuration. + * + * @return array $configuration The configuration parameters. + */ + public function getConfiguration() + { + return $this->_configuration; + } + + /** + * Set the connection configuration. + * + * @param array $configuration The configuration parameters. + * + * @return NULL + */ + public function setConfiguration(array $configuration) + { + $this->_configuration = $configuration; + + if (empty($configuration['mock'])) { + $this->_factory = new Horde_Kolab_Server_Factory_Connection_Ldap(); + } else { + $this->_factory = new Horde_Kolab_Server_Factory_Connection_Mock(); + } + + $this->_factory->setConfiguration($configuration); + } + + /** + * Return the server connection that should be used. + * + * @return Horde_Kolab_Server_Connection The server connection. + */ + public function getConnection() + { + return $this->_factory->getConnection(); + } +} \ No newline at end of file diff --git a/framework/Kolab_Server/lib/Horde/Kolab/Server/Factory/Connection/Injector.php b/framework/Kolab_Server/lib/Horde/Kolab/Server/Factory/Connection/Injector.php new file mode 100644 index 000000000..2daf7601a --- /dev/null +++ b/framework/Kolab_Server/lib/Horde/Kolab/Server/Factory/Connection/Injector.php @@ -0,0 +1,66 @@ + + * @license http://www.fsf.org/copyleft/lgpl.html LGPL + * @link http://pear.horde.org/index.php?package=Kolab_Server + */ + +/** + * A factory that generates connections using the Horde_Injector. + * + * Copyright 2009 The Horde Project (http://www.horde.org/) + * + * See the enclosed file COPYING for license information (LGPL). If you + * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html. + * + * @category Kolab + * @package Kolab_Server + * @author Gunnar Wrobel + * @license http://www.fsf.org/copyleft/lgpl.html LGPL + * @link http://pear.horde.org/index.php?package=Kolab_Server + */ +class Horde_Kolab_Server_Factory_Connection_Injector +extends Horde_Kolab_Server_Factory_Connection_Base +{ + /** + * The injector providing our context. + * + * @var Horde_Injector + */ + private $_injector; + + /** + * Constructor. + * + * @param Horde_Injector The injector to use. + */ + public function __construct(Horde_Injector $injector) + { + $this->_injector = $injector; + } + + /** + * Return the server connection that should be used. + * + * @return Horde_Kolab_Server_Connection The server connection. + */ + public function getConnection() + { + $factory = $this->_injector->getInstance( + 'Horde_Kolab_Server_Factory_Connection_Interface' + ); + $factory->setConfiguration( + $this->_injector->getInstance( + 'Horde_Kolab_Server_Configuration' + ) + ); + $connection = $factory->getConnection(); + return $connection; + } +} \ No newline at end of file diff --git a/framework/Kolab_Server/lib/Horde/Kolab/Server/Factory/Connection/Interface.php b/framework/Kolab_Server/lib/Horde/Kolab/Server/Factory/Connection/Interface.php new file mode 100644 index 000000000..94c50f497 --- /dev/null +++ b/framework/Kolab_Server/lib/Horde/Kolab/Server/Factory/Connection/Interface.php @@ -0,0 +1,52 @@ + + * @license http://www.fsf.org/copyleft/lgpl.html LGPL + * @link http://pear.horde.org/index.php?package=Kolab_Server + */ + +/** + * The interface of Kolab server connection factories. + * + * Copyright 2008-2009 The Horde Project (http://www.horde.org/) + * + * See the enclosed file COPYING for license information (LGPL). If you + * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html. + * + * @category Kolab + * @package Kolab_Server + * @author Gunnar Wrobel + * @license http://www.fsf.org/copyleft/lgpl.html LGPL + * @link http://pear.horde.org/index.php?package=Kolab_Server + */ +interface Horde_Kolab_Server_Factory_Connection_Interface +{ + /** + * Get the connection configuration. + * + * @return array $configuration The configuration parameters. + */ + public function getConfiguration(); + + /** + * Set the connection configuration. + * + * @param array $configuration The configuration parameters. + * + * @return NULL + */ + public function setConfiguration(array $configuration); + + /** + * Return the server connection that should be used. + * + * @return Horde_Kolab_Server_Connection The server connection. + */ + public function getConnection(); +} \ No newline at end of file diff --git a/framework/Kolab_Server/lib/Horde/Kolab/Server/Factory/Connection/Ldap.php b/framework/Kolab_Server/lib/Horde/Kolab/Server/Factory/Connection/Ldap.php new file mode 100644 index 000000000..6bd28fd41 --- /dev/null +++ b/framework/Kolab_Server/lib/Horde/Kolab/Server/Factory/Connection/Ldap.php @@ -0,0 +1,84 @@ + + * @license http://www.fsf.org/copyleft/lgpl.html LGPL + * @link http://pear.horde.org/index.php?package=Kolab_Server + */ + +/** + * A factory that generates LDAP connections. + * + * Copyright 2009 The Horde Project (http://www.horde.org/) + * + * See the enclosed file COPYING for license information (LGPL). If you + * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html. + * + * @category Kolab + * @package Kolab_Server + * @author Gunnar Wrobel + * @license http://www.fsf.org/copyleft/lgpl.html LGPL + * @link http://pear.horde.org/index.php?package=Kolab_Server + */ +class Horde_Kolab_Server_Factory_Connection_Ldap +extends Horde_Kolab_Server_Factory_Connection_Base +{ + /** + * Set the connection configuration. + * + * @param array $configuration The configuration parameters. + * + * @return NULL + */ + public function setConfiguration(array $configuration) + { + if (!isset($configuration['basedn'])) { + throw new Horde_Kolab_Server_Exception('The base DN is missing!'); + } + + if (isset($configuration['server'])) { + $configuration['host'] = $configuration['server']; + unset($configuration['server']); + } + + if (isset($configuration['phpdn'])) { + $configuration['binddn'] = $configuration['phpdn']; + unset($configuration['phpdn']); + } + + if (isset($configuration['phppw'])) { + $configuration['bindpw'] = $configuration['phppw']; + unset($configuration['phppw']); + } + + parent::setConfiguration($configuration); + } + + /** + * Return the server connection that should be used. + * + * @return Horde_Kolab_Server_Connection The server connection. + */ + public function getConnection() + { + $configuration = $this->getConfiguration(); + $ldap_read = new Net_LDAP2($configuration); + if (isset($configuration['host_master'])) { + $configuration['host'] = $configuration['host_master']; + $ldap_write = new Net_LDAP2($configuration); + $connection = new Horde_Kolab_Server_Connection_Splittedldap( + $ldap_read, $ldap_write + ); + } else { + $connection = new Horde_Kolab_Server_Connection_Simpleldap( + $ldap_read + ); + } + return $connection; + } +} \ No newline at end of file diff --git a/framework/Kolab_Server/lib/Horde/Kolab/Server/Factory/Connection/Mock.php b/framework/Kolab_Server/lib/Horde/Kolab/Server/Factory/Connection/Mock.php new file mode 100644 index 000000000..67ec0bf9f --- /dev/null +++ b/framework/Kolab_Server/lib/Horde/Kolab/Server/Factory/Connection/Mock.php @@ -0,0 +1,51 @@ + + * @license http://www.fsf.org/copyleft/lgpl.html LGPL + * @link http://pear.horde.org/index.php?package=Kolab_Server + */ + +/** + * A factory that generates mock connections. + * + * Copyright 2009 The Horde Project (http://www.horde.org/) + * + * See the enclosed file COPYING for license information (LGPL). If you + * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html. + * + * @category Kolab + * @package Kolab_Server + * @author Gunnar Wrobel + * @license http://www.fsf.org/copyleft/lgpl.html LGPL + * @link http://pear.horde.org/index.php?package=Kolab_Server + */ +class Horde_Kolab_Server_Factory_Connection_Mock +extends Horde_Kolab_Server_Factory_Connection_Base +{ + /** + * Return the server connection that should be used. + * + * @return Horde_Kolab_Server_Connection The server connection. + */ + public function getConnection() + { + $config = $this->getConfiguration(); + if (isset($config['data'])) { + $data = $config['data']; + } else { + $data = array(); + } + $connection = new Horde_Kolab_Server_Connection_Mock( + new Horde_Kolab_Server_Connection_Mock_Ldap( + $config, $data + ) + ); + return $connection; + } +} \ No newline at end of file diff --git a/framework/Kolab_Server/lib/Horde/Kolab/Server/Factory/Constructor.php b/framework/Kolab_Server/lib/Horde/Kolab/Server/Factory/Constructor.php index 0762abcf0..1d8002835 100644 --- a/framework/Kolab_Server/lib/Horde/Kolab/Server/Factory/Constructor.php +++ b/framework/Kolab_Server/lib/Horde/Kolab/Server/Factory/Constructor.php @@ -74,11 +74,11 @@ extends Horde_Kolab_Server_Factory_Base * server. */ public function __construct( - Horde_Kolab_Server_Factory_Conn $factory, - Horde_Kolab_Server_Objects $objects, + Horde_Kolab_Server_Factory_Connection_Interface $factory, + Horde_Kolab_Server_Objects_Interface $objects, Horde_Kolab_Server_Structure_Interface $structure, Horde_Kolab_Server_Search_Interface $search, - Horde_Kolab_Server_Schema $schema, + Horde_Kolab_Server_Schema_Interface $schema, array $config ) { parent::__construct($factory, $config); diff --git a/framework/Kolab_Server/lib/Horde/Kolab/Server/Factory/Decorator/Clean.php b/framework/Kolab_Server/lib/Horde/Kolab/Server/Factory/Decorator/Clean.php new file mode 100644 index 000000000..7c021cc5a --- /dev/null +++ b/framework/Kolab_Server/lib/Horde/Kolab/Server/Factory/Decorator/Clean.php @@ -0,0 +1,144 @@ + + * @license http://www.fsf.org/copyleft/lgpl.html LGPL + * @link http://pear.horde.org/index.php?package=Kolab_Server + */ + +/** + * A factory decorator that adds cleaning to the generated instances. + * + * Copyright 2009 The Horde Project (http://www.horde.org/) + * + * See the enclosed file COPYING for license information (LGPL). If you + * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html. + * + * @category Kolab + * @package Kolab_Server + * @author Gunnar Wrobel + * @license http://www.fsf.org/copyleft/lgpl.html LGPL + * @link http://pear.horde.org/index.php?package=Kolab_Server + */ +class Horde_Kolab_Server_Factory_Decorator_Clean +implements Horde_Kolab_Server_Factory_Interface +{ + /** + * The factory used for creating the instances. + * + * @var Horde_Kolab_Server_Factory + */ + private $_factory; + + /** + * Constructor. + * + * @param Horde_Kolab_Server_Factory $factory The base factory. + */ + public function __construct( + Horde_Kolab_Server_Factory_Interface $factory + ) { + $this->_factory = $factory; + } + + /** + * Returns the conn factory. + * + * @return Horde_Kolab_Server_Factory_Conn The connection factory. + */ + public function getConnectionFactory() + { + return $this->_factory->getConnectionFactory(); + } + + /** + * Returns the server configuration parameters. + * + * @return array The configuration parameters. + */ + public function getConfiguration() + { + return $this->_factory->getConfiguration(); + } + + /** + * Return the server connection that should be used. + * + * @return Horde_Kolab_Server The Horde_Kolab_Server connection. + */ + public function getServer() + { + $server = $this->_factory->getServer(); + $server = new Horde_Kolab_Server_Decorator_Clean($server); + return $server; + } + + /** + * Return the server that should be used. + * + * @return Horde_Kolab_Server_Connection The connection. + */ + public function getConnection() + { + return $this->_factory->getConnection(); + } + + /** + * Returns a concrete Horde_Kolab_Server_Composite instance. + * + * @return Horde_Kolab_Server_Composite The newly created concrete + * Horde_Kolab_Server_Composite + * instance. + */ + public function getComposite() + { + return $this->_factory->getComposite(); + } + + /** + * Return the object handler that should be used. + * + * @return Horde_Kolab_Server_Objects The handler for objects on the server. + */ + public function getObjects() + { + return $this->_factory->getObjects(); + } + + /** + * Return the structural representation that should be used. + * + * @return Horde_Kolab_Server_Structure The representation of the db + * structure. + */ + public function getStructure() + { + return $this->_factory->getStructure(); + } + + /** + * Return the search handler that should be used. + * + * @return Horde_Kolab_Server_Search The search handler. + */ + public function getSearch() + { + return $this->_factory->getSearch(); + } + + /** + * Return the db schema representation that should be used. + * + * @return Horde_Kolab_Server_Schema The db schema representation. + */ + public function getSchema() + { + return $this->_factory->getSchema(); + } + +} \ No newline at end of file diff --git a/framework/Kolab_Server/lib/Horde/Kolab/Server/Factory/Decorator/Count.php b/framework/Kolab_Server/lib/Horde/Kolab/Server/Factory/Decorator/Count.php new file mode 100644 index 000000000..ef7ecdeaf --- /dev/null +++ b/framework/Kolab_Server/lib/Horde/Kolab/Server/Factory/Decorator/Count.php @@ -0,0 +1,156 @@ + + * @license http://www.fsf.org/copyleft/lgpl.html LGPL + * @link http://pear.horde.org/index.php?package=Kolab_Server + */ + +/** + * A factory decorator that adds counting to the generated instances. + * + * Copyright 2009 The Horde Project (http://www.horde.org/) + * + * See the enclosed file COPYING for license information (LGPL). If you + * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html. + * + * @category Kolab + * @package Kolab_Server + * @author Gunnar Wrobel + * @license http://www.fsf.org/copyleft/lgpl.html LGPL + * @link http://pear.horde.org/index.php?package=Kolab_Server + */ +class Horde_Kolab_Server_Factory_Decorator_Count +implements Horde_Kolab_Server_Factory_Interface +{ + /** + * The factory used for creating the instances. + * + * @var Horde_Kolab_Server_Factory + */ + private $_factory; + + /** + * The logger. + * + * @var mixed + */ + private $_logger; + + /** + * Constructor. + * + * @param Horde_Kolab_Server_Factory $factory The base factory. + * @param mixed $logger The logger isntance. + */ + public function __construct( + Horde_Kolab_Server_Factory_Interface $factory, + $logger + ) { + $this->_factory = $factory; + $this->_logger = $logger; + } + + /** + * Returns the conn factory. + * + * @return Horde_Kolab_Server_Factory_Conn The connection factory. + */ + public function getConnectionFactory() + { + return $this->_factory->getConnectionFactory(); + } + + /** + * Returns the server configuration parameters. + * + * @return array The configuration parameters. + */ + public function getConfiguration() + { + return $this->_factory->getConfiguration(); + } + + /** + * Return the server connection that should be used. + * + * @return Horde_Kolab_Server The Horde_Kolab_Server connection. + */ + public function getServer() + { + $server = $this->_factory->getServer(); + $server = new Horde_Kolab_Server_Decorator_Count( + $server, $this->_logger + ); + return $server; + } + + /** + * Return the server that should be used. + * + * @return Horde_Kolab_Server_Connection The connection. + */ + public function getConnection() + { + return $this->_factory->getConnection(); + } + + /** + * Returns a concrete Horde_Kolab_Server_Composite instance. + * + * @return Horde_Kolab_Server_Composite The newly created concrete + * Horde_Kolab_Server_Composite + * instance. + */ + public function getComposite() + { + return $this->_factory->getComposite(); + } + + /** + * Return the object handler that should be used. + * + * @return Horde_Kolab_Server_Objects The handler for objects on the server. + */ + public function getObjects() + { + return $this->_factory->getObjects(); + } + + /** + * Return the structural representation that should be used. + * + * @return Horde_Kolab_Server_Structure The representation of the db + * structure. + */ + public function getStructure() + { + return $this->_factory->getStructure(); + } + + /** + * Return the search handler that should be used. + * + * @return Horde_Kolab_Server_Search The search handler. + */ + public function getSearch() + { + return $this->_factory->getSearch(); + } + + /** + * Return the db schema representation that should be used. + * + * @return Horde_Kolab_Server_Schema The db schema representation. + */ + public function getSchema() + { + return $this->_factory->getSchema(); + } + +} \ No newline at end of file diff --git a/framework/Kolab_Server/lib/Horde/Kolab/Server/Factory/Decorator/Log.php b/framework/Kolab_Server/lib/Horde/Kolab/Server/Factory/Decorator/Log.php new file mode 100644 index 000000000..f2227c37b --- /dev/null +++ b/framework/Kolab_Server/lib/Horde/Kolab/Server/Factory/Decorator/Log.php @@ -0,0 +1,156 @@ + + * @license http://www.fsf.org/copyleft/lgpl.html LGPL + * @link http://pear.horde.org/index.php?package=Kolab_Server + */ + +/** + * A factory decorator that adds logging to the generated instances. + * + * Copyright 2008-2009 The Horde Project (http://www.horde.org/) + * + * See the enclosed file COPYING for license information (LGPL). If you + * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html. + * + * @category Kolab + * @package Kolab_Server + * @author Gunnar Wrobel + * @license http://www.fsf.org/copyleft/lgpl.html LGPL + * @link http://pear.horde.org/index.php?package=Kolab_Server + */ +class Horde_Kolab_Server_Factory_Decorator_Log +implements Horde_Kolab_Server_Factory_Interface +{ + /** + * The factory used for creating the instances. + * + * @var Horde_Kolab_Server_Factory + */ + private $_factory; + + /** + * The logger. + * + * @var mixed + */ + private $_logger; + + /** + * Constructor. + * + * @param Horde_Kolab_Server_Factory $factory The base factory. + * @param mixed $logger The logger isntance. + */ + public function __construct( + Horde_Kolab_Server_Factory_Interface $factory, + $logger + ) { + $this->_factory = $factory; + $this->_logger = $logger; + } + + /** + * Returns the conn factory. + * + * @return Horde_Kolab_Server_Factory_Conn The connection factory. + */ + public function getConnectionFactory() + { + return $this->_factory->getConnectionFactory(); + } + + /** + * Returns the server configuration parameters. + * + * @return array The configuration parameters. + */ + public function getConfiguration() + { + return $this->_factory->getConfiguration(); + } + + /** + * Return the server connection that should be used. + * + * @return Horde_Kolab_Server The Horde_Kolab_Server connection. + */ + public function getServer() + { + $server = $this->_factory->getServer(); + $server = new Horde_Kolab_Server_Decorator_Log( + $server, $this->_logger + ); + return $server; + } + + /** + * Return the server that should be used. + * + * @return Horde_Kolab_Server_Connection The connection. + */ + public function getConnection() + { + return $this->_factory->getConnection(); + } + + /** + * Returns a concrete Horde_Kolab_Server_Composite instance. + * + * @return Horde_Kolab_Server_Composite The newly created concrete + * Horde_Kolab_Server_Composite + * instance. + */ + public function getComposite() + { + return $this->_factory->getComposite(); + } + + /** + * Return the object handler that should be used. + * + * @return Horde_Kolab_Server_Objects The handler for objects on the server. + */ + public function getObjects() + { + return $this->_factory->getObjects(); + } + + /** + * Return the structural representation that should be used. + * + * @return Horde_Kolab_Server_Structure The representation of the db + * structure. + */ + public function getStructure() + { + return $this->_factory->getStructure(); + } + + /** + * Return the search handler that should be used. + * + * @return Horde_Kolab_Server_Search The search handler. + */ + public function getSearch() + { + return $this->_factory->getSearch(); + } + + /** + * Return the db schema representation that should be used. + * + * @return Horde_Kolab_Server_Schema The db schema representation. + */ + public function getSchema() + { + return $this->_factory->getSchema(); + } + +} \ No newline at end of file diff --git a/framework/Kolab_Server/lib/Horde/Kolab/Server/Factory/Decorator/Map.php b/framework/Kolab_Server/lib/Horde/Kolab/Server/Factory/Decorator/Map.php new file mode 100644 index 000000000..2e0862302 --- /dev/null +++ b/framework/Kolab_Server/lib/Horde/Kolab/Server/Factory/Decorator/Map.php @@ -0,0 +1,156 @@ + + * @license http://www.fsf.org/copyleft/lgpl.html LGPL + * @link http://pear.horde.org/index.php?package=Kolab_Server + */ + +/** + * A factory decorator that adds mapping to the generated instances. + * + * Copyright 2008-2009 The Horde Project (http://www.horde.org/) + * + * See the enclosed file COPYING for license information (LGPL). If you + * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html. + * + * @category Kolab + * @package Kolab_Server + * @author Gunnar Wrobel + * @license http://www.fsf.org/copyleft/lgpl.html LGPL + * @link http://pear.horde.org/index.php?package=Kolab_Server + */ +class Horde_Kolab_Server_Factory_Decorator_Map +implements Horde_Kolab_Server_Factory_Interface +{ + /** + * The factory used for creating the instances. + * + * @var Horde_Kolab_Server_Factory + */ + private $_factory; + + /** + * The attribute mapping. + * + * @var array + */ + private $_mapping; + + /** + * Constructor. + * + * @param Horde_Kolab_Server_Factory $factory The base factory. + * @param array $mapping The attribute mapping. + */ + public function __construct( + Horde_Kolab_Server_Factory_Interface $factory, + array $mapping) + { + $this->_factory = $factory; + $this->_mapping = $mapping; + } + + /** + * Returns the conn factory. + * + * @return Horde_Kolab_Server_Factory_Conn The connection factory. + */ + public function getConnectionFactory() + { + return $this->_factory->getConnectionFactory(); + } + + /** + * Returns the server configuration parameters. + * + * @return array The configuration parameters. + */ + public function getConfiguration() + { + return $this->_factory->getConfiguration(); + } + + /** + * Return the server connection that should be used. + * + * @return Horde_Kolab_Server The Horde_Kolab_Server connection. + */ + public function getServer() + { + $server = $this->_factory->getServer(); + $server = new Horde_Kolab_Server_Decorator_Map( + $server, $this->_mapping + ); + return $server; + } + + /** + * Return the server that should be used. + * + * @return Horde_Kolab_Server_Connection The connection. + */ + public function getConnection() + { + return $this->_factory->getConnection(); + } + + /** + * Returns a concrete Horde_Kolab_Server_Composite instance. + * + * @return Horde_Kolab_Server_Composite The newly created concrete + * Horde_Kolab_Server_Composite + * instance. + */ + public function getComposite() + { + return $this->_factory->getComposite(); + } + + /** + * Return the object handler that should be used. + * + * @return Horde_Kolab_Server_Objects The handler for objects on the server. + */ + public function getObjects() + { + return $this->_factory->getObjects(); + } + + /** + * Return the structural representation that should be used. + * + * @return Horde_Kolab_Server_Structure The representation of the db + * structure. + */ + public function getStructure() + { + return $this->_factory->getStructure(); + } + + /** + * Return the search handler that should be used. + * + * @return Horde_Kolab_Server_Search The search handler. + */ + public function getSearch() + { + return $this->_factory->getSearch(); + } + + /** + * Return the db schema representation that should be used. + * + * @return Horde_Kolab_Server_Schema The db schema representation. + */ + public function getSchema() + { + return $this->_factory->getSchema(); + } + +} \ No newline at end of file diff --git a/framework/Kolab_Server/lib/Horde/Kolab/Server/Factory/Injector.php b/framework/Kolab_Server/lib/Horde/Kolab/Server/Factory/Injector.php index e3b3ba1f3..df92422e5 100644 --- a/framework/Kolab_Server/lib/Horde/Kolab/Server/Factory/Injector.php +++ b/framework/Kolab_Server/lib/Horde/Kolab/Server/Factory/Injector.php @@ -26,7 +26,7 @@ * @link http://pear.horde.org/index.php?package=Kolab_Server */ class Horde_Kolab_Server_Factory_Injector -implements Horde_Kolab_Server_Factory +implements Horde_Kolab_Server_Factory_Interface { /** * The injector. @@ -97,7 +97,7 @@ implements Horde_Kolab_Server_Factory Horde_Injector $injector ) { $injector->bindImplementation( - 'Horde_Kolab_Server_Factory_Conn', $factory + 'Horde_Kolab_Server_Factory_Connection_Interface', $factory ); } @@ -125,7 +125,7 @@ implements Horde_Kolab_Server_Factory private function _setupObjects() { $this->_injector->bindImplementation( - 'Horde_Kolab_Server_Objects', + 'Horde_Kolab_Server_Objects_Interface', 'Horde_Kolab_Server_Objects_Base' ); } @@ -151,7 +151,7 @@ implements Horde_Kolab_Server_Factory private function _setupSchema() { $this->_injector->bindImplementation( - 'Horde_Kolab_Server_Schema', + 'Horde_Kolab_Server_Schema_Interface', 'Horde_Kolab_Server_Schema_Base' ); } @@ -183,8 +183,8 @@ implements Horde_Kolab_Server_Factory private function _setupConnection() { $this->_injector->bindFactory( - 'Horde_Kolab_Server_Connection', - 'Horde_Kolab_Server_Factory_Conn_Injector', + 'Horde_Kolab_Server_Connection_Interface', + 'Horde_Kolab_Server_Factory_Connection_Injector', 'getConnection' ); } @@ -197,7 +197,7 @@ implements Horde_Kolab_Server_Factory private function _setupServer() { $this->_injector->bindFactory( - 'Horde_Kolab_Server', + 'Horde_Kolab_Server_Interface', 'Horde_Kolab_Server_Factory_Injector', 'getServer' ); @@ -210,9 +210,10 @@ implements Horde_Kolab_Server_Factory */ private function _setupComposite() { - /** - * Nothing to do here for now as class and interface name are the same. - */ + $this->_injector->bindImplementation( + 'Horde_Kolab_Server_Composite_Interface', + 'Horde_Kolab_Server_Composite_Base' + ); } /** @@ -222,7 +223,9 @@ implements Horde_Kolab_Server_Factory */ public function getConnectionFactory() { - return $this->_injector->getInstance('Horde_Kolab_Server_Factory_Conn'); + return $this->_injector->getInstance( + 'Horde_Kolab_Server_Factory_Connection_Interface' + ); } /** @@ -232,7 +235,9 @@ implements Horde_Kolab_Server_Factory */ public function getConnection() { - return $this->_injector->getInstance('Horde_Kolab_Server_Connection'); + return $this->_injector->getInstance( + 'Horde_Kolab_Server_Connection_Interface' + ); } /** @@ -281,7 +286,9 @@ implements Horde_Kolab_Server_Factory */ public function getObjects() { - return $this->_injector->getInstance('Horde_Kolab_Server_Objects'); + return $this->_injector->getInstance( + 'Horde_Kolab_Server_Objects_Interface' + ); } /** @@ -292,7 +299,9 @@ implements Horde_Kolab_Server_Factory */ public function getStructure() { - return $this->_injector->getInstance('Horde_Kolab_Server_Structure_Interface'); + return $this->_injector->getInstance( + 'Horde_Kolab_Server_Structure_Interface' + ); } /** @@ -302,7 +311,9 @@ implements Horde_Kolab_Server_Factory */ public function getSearch() { - return $this->_injector->getInstance('Horde_Kolab_Server_Search_Interface'); + return $this->_injector->getInstance( + 'Horde_Kolab_Server_Search_Interface' + ); } /** @@ -312,7 +323,9 @@ implements Horde_Kolab_Server_Factory */ public function getSchema() { - return $this->_injector->getInstance('Horde_Kolab_Server_Schema'); + return $this->_injector->getInstance( + 'Horde_Kolab_Server_Schema_Interface' + ); } /** @@ -324,6 +337,8 @@ implements Horde_Kolab_Server_Factory */ public function getComposite() { - return $this->_injector->getInstance('Horde_Kolab_Server_Composite'); + return $this->_injector->getInstance( + 'Horde_Kolab_Server_Composite_Interface' + ); } } \ No newline at end of file diff --git a/framework/Kolab_Server/lib/Horde/Kolab/Server/Factory/Interface.php b/framework/Kolab_Server/lib/Horde/Kolab/Server/Factory/Interface.php new file mode 100644 index 000000000..9b2259a17 --- /dev/null +++ b/framework/Kolab_Server/lib/Horde/Kolab/Server/Factory/Interface.php @@ -0,0 +1,95 @@ + + * @license http://www.fsf.org/copyleft/lgpl.html LGPL + * @link http://pear.horde.org/index.php?package=Kolab_Server + */ + +/** + * The interface of Kolab server factories. + * + * Copyright 2008-2009 The Horde Project (http://www.horde.org/) + * + * See the enclosed file COPYING for license information (LGPL). If you + * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html. + * + * @category Kolab + * @package Kolab_Server + * @author Gunnar Wrobel + * @license http://www.fsf.org/copyleft/lgpl.html LGPL + * @link http://pear.horde.org/index.php?package=Kolab_Server + */ +interface Horde_Kolab_Server_Factory_Interface +{ + /** + * Returns a concrete Horde_Kolab_Server_Composite instance. + * + * @return Horde_Kolab_Server_Composite The newly created concrete + * Horde_Kolab_Server_Composite + * instance. + */ + public function getComposite(); + + /** + * Returns the conn factory. + * + * @return Horde_Kolab_Server_Factory_Conn The connection factory. + */ + public function getConnectionFactory(); + + /** + * Returns the server configuration parameters. + * + * @return array The configuration parameters. + */ + public function getConfiguration(); + + /** + * Return the server connection that should be used. + * + * @return Horde_Kolab_Server The Horde_Kolab_Server connection. + */ + public function getServer(); + + /** + * Return the server that should be used. + * + * @return Horde_Kolab_Server_Connection The connection. + */ + public function getConnection(); + + /** + * Return the object handler that should be used. + * + * @return Horde_Kolab_Server_Objects The handler for objects on the server. + */ + public function getObjects(); + + /** + * Return the structural representation that should be used. + * + * @return Horde_Kolab_Server_Structure The representation of the db + * structure. + */ + public function getStructure(); + + /** + * Return the search handler that should be used. + * + * @return Horde_Kolab_Server_Search The search handler. + */ + public function getSearch(); + + /** + * Return the db schema representation that should be used. + * + * @return Horde_Kolab_Server_Schema The db schema representation. + */ + public function getSchema(); +} \ No newline at end of file diff --git a/framework/Kolab_Server/lib/Horde/Kolab/Server/Factory/Logged.php b/framework/Kolab_Server/lib/Horde/Kolab/Server/Factory/Logged.php deleted file mode 100644 index b177ed3f0..000000000 --- a/framework/Kolab_Server/lib/Horde/Kolab/Server/Factory/Logged.php +++ /dev/null @@ -1,154 +0,0 @@ - - * @license http://www.fsf.org/copyleft/lgpl.html LGPL - * @link http://pear.horde.org/index.php?package=Kolab_Server - */ - -/** - * A factory decorator that adds logging to the generated instances. - * - * Copyright 2008-2009 The Horde Project (http://www.horde.org/) - * - * See the enclosed file COPYING for license information (LGPL). If you - * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html. - * - * @category Kolab - * @package Kolab_Server - * @author Gunnar Wrobel - * @license http://www.fsf.org/copyleft/lgpl.html LGPL - * @link http://pear.horde.org/index.php?package=Kolab_Server - */ -class Horde_Kolab_Server_Factory_Logged -implements Horde_Kolab_Server_Factory -{ - /** - * The factory used for creating the instances. - * - * @var Horde_Kolab_Server_Factory - */ - private $_factory; - - /** - * The logger. - * - * @var mixed - */ - private $_logger; - - /** - * Constructor. - * - * @param Horde_Kolab_Server_Factory $factory The base factory. - * @param mixed $logger The logger isntance. - */ - public function __construct(Horde_Kolab_Server_Factory $factory, $logger) - { - $this->_factory = $factory; - $this->_logger = $logger; - } - - /** - * Returns the conn factory. - * - * @return Horde_Kolab_Server_Factory_Conn The connection factory. - */ - public function getConnectionFactory() - { - return $this->_factory->getConnectionFactory(); - } - - /** - * Returns the server configuration parameters. - * - * @return array The configuration parameters. - */ - public function getConfiguration() - { - return $this->_factory->getConfiguration(); - } - - /** - * Return the server connection that should be used. - * - * @return Horde_Kolab_Server The Horde_Kolab_Server connection. - */ - public function getServer() - { - $server = $this->_factory->getServer(); - $server = new Horde_Kolab_Server_Logged( - $server, $this->_logger - ); - return $server; - } - - /** - * Return the server that should be used. - * - * @return Horde_Kolab_Server_Connection The connection. - */ - public function getConnection() - { - return $this->_factory->getConnection(); - } - - /** - * Returns a concrete Horde_Kolab_Server_Composite instance. - * - * @return Horde_Kolab_Server_Composite The newly created concrete - * Horde_Kolab_Server_Composite - * instance. - */ - public function getComposite() - { - return $this->_factory->getComposite(); - } - - /** - * Return the object handler that should be used. - * - * @return Horde_Kolab_Server_Objects The handler for objects on the server. - */ - public function getObjects() - { - return $this->_factory->getObjects(); - } - - /** - * Return the structural representation that should be used. - * - * @return Horde_Kolab_Server_Structure The representation of the db - * structure. - */ - public function getStructure() - { - return $this->_factory->getStructure(); - } - - /** - * Return the search handler that should be used. - * - * @return Horde_Kolab_Server_Search The search handler. - */ - public function getSearch() - { - return $this->_factory->getSearch(); - } - - /** - * Return the db schema representation that should be used. - * - * @return Horde_Kolab_Server_Schema The db schema representation. - */ - public function getSchema() - { - return $this->_factory->getSchema(); - } - -} \ No newline at end of file diff --git a/framework/Kolab_Server/lib/Horde/Kolab/Server/Factory/Mapped.php b/framework/Kolab_Server/lib/Horde/Kolab/Server/Factory/Mapped.php deleted file mode 100644 index 4424405f3..000000000 --- a/framework/Kolab_Server/lib/Horde/Kolab/Server/Factory/Mapped.php +++ /dev/null @@ -1,154 +0,0 @@ - - * @license http://www.fsf.org/copyleft/lgpl.html LGPL - * @link http://pear.horde.org/index.php?package=Kolab_Server - */ - -/** - * A factory decorator that adds mapping to the generated instances. - * - * Copyright 2008-2009 The Horde Project (http://www.horde.org/) - * - * See the enclosed file COPYING for license information (LGPL). If you - * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html. - * - * @category Kolab - * @package Kolab_Server - * @author Gunnar Wrobel - * @license http://www.fsf.org/copyleft/lgpl.html LGPL - * @link http://pear.horde.org/index.php?package=Kolab_Server - */ -class Horde_Kolab_Server_Factory_Mapped -implements Horde_Kolab_Server_Factory -{ - /** - * The factory used for creating the instances. - * - * @var Horde_Kolab_Server_Factory - */ - private $_factory; - - /** - * The attribute mapping. - * - * @var array - */ - private $_mapping; - - /** - * Constructor. - * - * @param Horde_Kolab_Server_Factory $factory The base factory. - * @param array $mapping The attribute mapping. - */ - public function __construct( - Horde_Kolab_Server_Factory $factory, - array $mapping) - { - $this->_factory = $factory; - $this->_mapping = $mapping; - } - - /** - * Returns the conn factory. - * - * @return Horde_Kolab_Server_Factory_Conn The connection factory. - */ - public function getConnectionFactory() - { - return $this->_factory->getConnectionFactory(); - } - - /** - * Returns the server configuration parameters. - * - * @return array The configuration parameters. - */ - public function getConfiguration() - { - return $this->_factory->getConfiguration(); - } - - /** - * Return the server connection that should be used. - * - * @return Horde_Kolab_Server The Horde_Kolab_Server connection. - */ - public function getServer() - { - $server = $this->_factory->getServer(); - $server = new Horde_Kolab_Server_Mapped($server, $this->_mapping); - return $server; - } - - /** - * Return the server that should be used. - * - * @return Horde_Kolab_Server_Connection The connection. - */ - public function getConnection() - { - return $this->_factory->getConnection(); - } - - /** - * Returns a concrete Horde_Kolab_Server_Composite instance. - * - * @return Horde_Kolab_Server_Composite The newly created concrete - * Horde_Kolab_Server_Composite - * instance. - */ - public function getComposite() - { - return $this->_factory->getComposite(); - } - - /** - * Return the object handler that should be used. - * - * @return Horde_Kolab_Server_Objects The handler for objects on the server. - */ - public function getObjects() - { - return $this->_factory->getObjects(); - } - - /** - * Return the structural representation that should be used. - * - * @return Horde_Kolab_Server_Structure The representation of the db - * structure. - */ - public function getStructure() - { - return $this->_factory->getStructure(); - } - - /** - * Return the search handler that should be used. - * - * @return Horde_Kolab_Server_Search The search handler. - */ - public function getSearch() - { - return $this->_factory->getSearch(); - } - - /** - * Return the db schema representation that should be used. - * - * @return Horde_Kolab_Server_Schema The db schema representation. - */ - public function getSchema() - { - return $this->_factory->getSchema(); - } - -} \ No newline at end of file diff --git a/framework/Kolab_Server/lib/Horde/Kolab/Server/Interface.php b/framework/Kolab_Server/lib/Horde/Kolab/Server/Interface.php new file mode 100644 index 000000000..0b06ce136 --- /dev/null +++ b/framework/Kolab_Server/lib/Horde/Kolab/Server/Interface.php @@ -0,0 +1,190 @@ + + * @license http://www.fsf.org/copyleft/lgpl.html LGPL + * @link http://pear.horde.org/index.php?package=Kolab_Server + */ + +/** + * This class defines the interface of a generic Kolab user database. + * + * Copyright 2008-2009 The Horde Project (http://www.horde.org/) + * + * See the enclosed file COPYING for license information (LGPL). If you + * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html. + * + * @category Kolab + * @package Kolab_Server + * @author Gunnar Wrobel + * @license http://www.fsf.org/copyleft/lgpl.html LGPL + * @link http://pear.horde.org/index.php?package=Kolab_Server + */ +interface Horde_Kolab_Server_Interface +{ + /** + * Connect to the server. + * + * @param string $guid The global unique id of the user. + * @param string $pass The password. + * + * @return NULL. + * + * @throws Horde_Kolab_Server_Exception If the connection failed. + */ + public function connectGuid($guid = '', $pass = ''); + + /** + * Get the current GUID + * + * @return string The GUID of the currently connected user. + */ + public function getGuid(); + + /** + * Get the base GUID of this server + * + * @return string The base GUID of this server. + */ + public function getBaseGuid(); + + /** + * Low level access to reading object data. + * + * This function provides direct access to the Server data. + * + * Usually you should use + * + * + * $object = $server->fetch('a server uid'); + * $variable = $object['attribute'] + * + * + * to access object attributes. This is slower but takes special object + * handling into account (e.g. custom attribute parsing). + * + * @param string $guid The object to retrieve. + * + * @return array An array of attributes. + * + * @throws Horde_Kolab_Server_Exception + */ + public function read($guid); + + /** + * Low level access to reading some object attributes. + * + * @param string $guid The object to retrieve. + * @param string $attrs Restrict to these attributes. + * + * @return array An array of attributes. + * + * @throws Horde_Kolab_Server_Exception + * + * @see Horde_Kolab_Server::read + */ + public function readAttributes($guid, array $attrs); + + /** + * Finds object data matching a given set of criteria. + * + * @param string $query The LDAP search query + * @param array $params Additional search parameters. + * + * @return Horde_Kolab_Server_Result The result object. + * + * @throws Horde_Kolab_Server_Exception + */ + public function find($query, array $params = array()); + + /** + * Finds all object data below a parent matching a given set of criteria. + * + * @param string $query The LDAP search query + * @param string $parent The parent to search below. + * @param array $params Additional search parameters. + * + * @return Horde_Kolab_Server_Result The result object. + * + * @throws Horde_Kolab_Server_Exception + */ + public function findBelow($query, $parent, array $params = array()); + + /** + * Modify existing object data. + * + * @param Horde_Kolab_Server_Object $object The object to be modified. + * @param array $data The attributes of the object + * to be stored. + * + * @return NULL + * + * @throws Horde_Kolab_Server_Exception + */ + public function save( + Horde_Kolab_Server_Object_Interface $object, + array $data + ); + + /** + * Add new object data. + * + * @param Horde_Kolab_Server_Object $object The object to be added. + * @param array $data The attributes of the object + * to be added. + * + * @return NULL + * + * @throws Horde_Kolab_Server_Exception + */ + public function add( + Horde_Kolab_Server_Object_Interface $object, + array $data + ); + + /** + * Delete an object. + * + * @param string $guid The GUID of the object to be deleted. + * + * @return NULL + * + * @throws Horde_Kolab_Server_Exception + */ + public function delete($guid); + + /** + * Rename an object. + * + * @param string $guid The GUID of the object to be renamed. + * @param string $new The new GUID of the object. + * + * @return NULL + * + * @throws Horde_Kolab_Server_Exception + */ + public function rename($guid, $new); + + /** + * Return the database schema description. + * + * @return array The schema. + * + * @throws Horde_Kolab_Server_Exception If retrieval of the schema failed. + */ + public function getSchema(); + + /** + * Get the parent GUID of this object. + * + * @param string $guid The GUID of the child. + * + * @return string the parent GUID of this object. + */ + public function getParentGuid($guid); +} \ No newline at end of file diff --git a/framework/Kolab_Server/lib/Horde/Kolab/Server/Ldap.php b/framework/Kolab_Server/lib/Horde/Kolab/Server/Ldap.php index c40f9646f..1adfdd521 100644 --- a/framework/Kolab_Server/lib/Horde/Kolab/Server/Ldap.php +++ b/framework/Kolab_Server/lib/Horde/Kolab/Server/Ldap.php @@ -26,7 +26,8 @@ * @license http://www.fsf.org/copyleft/lgpl.html LGPL * @link http://pear.horde.org/index.php?package=Kolab_Server */ -abstract class Horde_Kolab_Server_Ldap implements Horde_Kolab_Server +abstract class Horde_Kolab_Server_Ldap +implements Horde_Kolab_Server_Interface { /** * The GUID of the current user. @@ -58,7 +59,7 @@ abstract class Horde_Kolab_Server_Ldap implements Horde_Kolab_Server * to all queries. */ public function __construct( - Horde_Kolab_Server_Connection $connection, + Horde_Kolab_Server_Connection_Interface $connection, $base_dn ) { $this->_conn = $connection; @@ -190,8 +191,10 @@ abstract class Horde_Kolab_Server_Ldap implements Horde_Kolab_Server * * @throws Horde_Kolab_Server_Exception */ - public function save(Horde_Kolab_Server_Object $object, array $data) - { + public function save( + Horde_Kolab_Server_Object_Interface $object, + array $data + ) { $changes = new Horde_Kolab_Server_Ldap_Changes($object, $data); $entry = $this->_conn->getWrite()->getEntry( $object->getGuid(), array_keys($data) @@ -214,8 +217,10 @@ abstract class Horde_Kolab_Server_Ldap implements Horde_Kolab_Server * * @throws Horde_Kolab_Server_Exception */ - public function add(Horde_Kolab_Server_Object $object, array $data) - { + public function add( + Horde_Kolab_Server_Object_Interface $object, + array $data + ) { $entry = Net_LDAP2_Entry::createFresh($object->getGuid(), $data); $this->_handleError($entry, Horde_Kolab_Server_Exception::SYSTEM); $this->_handleError( diff --git a/framework/Kolab_Server/lib/Horde/Kolab/Server/Ldap/Changes.php b/framework/Kolab_Server/lib/Horde/Kolab/Server/Ldap/Changes.php index 259977582..f9c38ef0c 100644 --- a/framework/Kolab_Server/lib/Horde/Kolab/Server/Ldap/Changes.php +++ b/framework/Kolab_Server/lib/Horde/Kolab/Server/Ldap/Changes.php @@ -48,8 +48,10 @@ class Horde_Kolab_Server_Ldap_Changes * @param array $data The attributes of the object * to be stored. */ - public function __construct(Horde_Kolab_Server_Object $object, array $data) - { + public function __construct( + Horde_Kolab_Server_Object_Interface $object, + array $data + ) { $this->_object = $object; $this->_data = $data; } diff --git a/framework/Kolab_Server/lib/Horde/Kolab/Server/Ldap/Filtered.php b/framework/Kolab_Server/lib/Horde/Kolab/Server/Ldap/Filtered.php index e172f6f6b..54c897a1c 100644 --- a/framework/Kolab_Server/lib/Horde/Kolab/Server/Ldap/Filtered.php +++ b/framework/Kolab_Server/lib/Horde/Kolab/Server/Ldap/Filtered.php @@ -44,7 +44,7 @@ class Horde_Kolab_Server_Ldap_Filtered extends Horde_Kolab_Server_Ldap * to all queries. */ public function __construct( - Horde_Kolab_Server_Connection $connection, + Horde_Kolab_Server_Connection_Interface $connection, $base_dn, $filter = null ) { diff --git a/framework/Kolab_Server/lib/Horde/Kolab/Server/Ldap/Standard.php b/framework/Kolab_Server/lib/Horde/Kolab/Server/Ldap/Standard.php index cc740a34b..23f4238cd 100644 --- a/framework/Kolab_Server/lib/Horde/Kolab/Server/Ldap/Standard.php +++ b/framework/Kolab_Server/lib/Horde/Kolab/Server/Ldap/Standard.php @@ -41,6 +41,6 @@ class Horde_Kolab_Server_Ldap_Standard extends Horde_Kolab_Server_Ldap */ public function findBelow($query, $parent, array $params = array()) { - return $this->_search((string) $query, $params, $parent); + return $this->_search($query, $params, $parent); } } diff --git a/framework/Kolab_Server/lib/Horde/Kolab/Server/List.php b/framework/Kolab_Server/lib/Horde/Kolab/Server/List.php deleted file mode 100644 index 7a9ad87d6..000000000 --- a/framework/Kolab_Server/lib/Horde/Kolab/Server/List.php +++ /dev/null @@ -1,43 +0,0 @@ - - * @license http://www.fsf.org/copyleft/lgpl.html LGPL - * @link http://pear.horde.org/index.php?package=Kolab_Server - */ - -/** - * Interface for server lists. - * - * Copyright 2008-2009 The Horde Project (http://www.horde.org/) - * - * See the enclosed file COPYING for license information (LGPL). If you - * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html. - * - * @category Kolab - * @package Kolab_Server - * @author Gunnar Wrobel - * @license http://www.fsf.org/copyleft/lgpl.html LGPL - * @link http://pear.horde.org/index.php?package=Kolab_Server - */ -interface Horde_Kolab_Server_List -{ - /** - * List all objects of a specific type. - * - * @param string $type The type of the objects to be listed - * @param array $params Additional parameters. - * - * @return array An array of Kolab objects. - * - * @throws Horde_Kolab_Server_Exception - * - * @todo Sorting - */ - public function listObjects($type, $params = null); -} \ No newline at end of file diff --git a/framework/Kolab_Server/lib/Horde/Kolab/Server/List/Interface.php b/framework/Kolab_Server/lib/Horde/Kolab/Server/List/Interface.php new file mode 100644 index 000000000..7a9ad87d6 --- /dev/null +++ b/framework/Kolab_Server/lib/Horde/Kolab/Server/List/Interface.php @@ -0,0 +1,43 @@ + + * @license http://www.fsf.org/copyleft/lgpl.html LGPL + * @link http://pear.horde.org/index.php?package=Kolab_Server + */ + +/** + * Interface for server lists. + * + * Copyright 2008-2009 The Horde Project (http://www.horde.org/) + * + * See the enclosed file COPYING for license information (LGPL). If you + * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html. + * + * @category Kolab + * @package Kolab_Server + * @author Gunnar Wrobel + * @license http://www.fsf.org/copyleft/lgpl.html LGPL + * @link http://pear.horde.org/index.php?package=Kolab_Server + */ +interface Horde_Kolab_Server_List +{ + /** + * List all objects of a specific type. + * + * @param string $type The type of the objects to be listed + * @param array $params Additional parameters. + * + * @return array An array of Kolab objects. + * + * @throws Horde_Kolab_Server_Exception + * + * @todo Sorting + */ + public function listObjects($type, $params = null); +} \ No newline at end of file diff --git a/framework/Kolab_Server/lib/Horde/Kolab/Server/Logged.php b/framework/Kolab_Server/lib/Horde/Kolab/Server/Logged.php deleted file mode 100644 index c71e5f56e..000000000 --- a/framework/Kolab_Server/lib/Horde/Kolab/Server/Logged.php +++ /dev/null @@ -1,317 +0,0 @@ - - * @license http://www.fsf.org/copyleft/lgpl.html LGPL - * @link http://pear.horde.org/index.php?package=Kolab_Server - */ - -/** - * A server delegation that logs server access via Horde_Log_Logger. - * - * Copyright 2008-2009 The Horde Project (http://www.horde.org/) - * - * See the enclosed file COPYING for license information (LGPL). If you - * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html. - * - * @category Kolab - * @package Kolab_Server - * @author Gunnar Wrobel - * @license http://www.fsf.org/copyleft/lgpl.html LGPL - * @link http://pear.horde.org/index.php?package=Kolab_Server - */ -class Horde_Kolab_Server_Logged implements Horde_Kolab_Server -{ - /** - * The server we delegate to. - * - * @var Horde_Kolab_Server - */ - private $_server; - - /** - * The log handler. - * - * @var Horde_Log_Logger - */ - private $_logger; - - /** - * Constructor. - * - * @param Horde_Kolab_Server $server The base server connection. - * @param mixed $logger The log handler. The class must at - * least provide the info() method. - */ - public function __construct(Horde_Kolab_Server $server, $logger) - { - $this->_server = $server; - $this->_logger = $logger; - } - - /** - * Connect to the server. - * - * @param string $guid The global unique id of the user. - * @param string $pass The password. - * - * @return NULL. - * - * @throws Horde_Kolab_Server_Exception If the connection failed. - */ - public function connectGuid($guid = null, $pass = null) - { - try { - $this->_server->connectGuid($guid, $pass); - $this->_logger->info( - sprintf( - "Successfully connected to the Kolab Server as \"%s\".", - $guid - ) - ); - } catch (Horde_Kolab_Server_Exception $e) { - $this->_logger->info( - sprintf( - "Failed saving object \"%s\"! Error: %s", - $object->getGuid(), $e->getMessage() - ) - ); - } - } - - /** - * Get the current GUID - * - * @return string The GUID of the connected user. - */ - public function getGuid() - { - return $this->_server->getGuid(); - } - - /** - * Get the base GUID of this server - * - * @return string The base GUID of this server. - */ - public function getBaseGuid() - { - return $this->_server->getBaseGuid(); - } - - /** - * Low level access to reading object data. - * - * @param string $guid The object to retrieve. - * @param array $attrs Restrict to these attributes. - * - * @return array An array of attributes. - * - * @throws Horde_Kolab_Server_Exception If the search operation hit an error - * or returned no result. - */ - public function read($guid, array $attrs = array()) - { - return $this->_server->read($guid); - } - - /** - * Low level access to reading some object attributes. - * - * @param string $guid The object to retrieve. - * @param string $attrs Restrict to these attributes. - * - * @return array An array of attributes. - * - * @throws Horde_Kolab_Server_Exception - * - * @see Horde_Kolab_Server::read - */ - public function readAttributes($guid, array $attrs) - { - return $this->_server->readAttributes($guid, $attrs); - } - - /** - * Finds object data matching a given set of criteria. - * - * @param string $query The LDAP search query - * @param array $params Additional search parameters. - * - * @return Horde_Kolab_Server_Result The result object. - * - * @throws Horde_Kolab_Server_Exception - */ - public function find($query, array $params = array()) - { - return $this->_server->find($query, $params); - } - - /** - * Finds all object data below a parent matching a given set of criteria. - * - * @param string $query The LDAP search query - * @param string $parent The parent to search below. - * @param array $params Additional search parameters. - * - * @return Horde_Kolab_Server_Result The result object. - * - * @throws Horde_Kolab_Server_Exception - */ - public function findBelow($query, $parent, array $params = array()) - { - return $this->_server->findBelow($query, $parent, $params); - } - - /** - * Modify existing object data. - * - * @param Horde_Kolab_Server_Object $object The object to be modified. - * @param array $data The attributes of the object - * to be stored. - * - * @return NULL - * - * @throws Horde_Kolab_Server_Exception - */ - public function save(Horde_Kolab_Server_Object $object, array $data) - { - try { - $this->_server->save($object, $data); - $this->_logger->info( - sprintf( - "The object \"%s\" has been successfully saved!", - $object->getGuid() - ) - ); - } catch (Horde_Kolab_Server_Exception $e) { - $this->_logger->info( - sprintf( - "Failed saving object \"%s\"! Error: %s", - $object->getGuid(), $e->getMessage() - ) - ); - - } - } - - /** - * Add new object data. - * - * @param Horde_Kolab_Server_Object $object The object to be added. - * @param array $data The attributes of the object - * to be added. - * - * @return NULL - * - * @throws Horde_Kolab_Server_Exception - */ - public function add(Horde_Kolab_Server_Object $object, array $data) - { - try { - $this->_server->add($object, $data); - $this->_logger->info( - sprintf( - "The object \"%s\" has been successfully added!", - $object->getGuid() - ) - ); - } catch (Horde_Kolab_Server_Exception $e) { - $this->_logger->info( - sprintf( - "Failed adding object \"%s\"! Error: %s", - $object->getGuid(), $e->getMessage() - ) - ); - - } - } - - /** - * Delete an object. - * - * @param string $guid The GUID of the object to be deleted. - * - * @return NULL - * - * @throws Horde_Kolab_Server_Exception - */ - public function delete($guid) - { - try { - $this->_server->delete($guid); - $this->_logger->info( - sprintf("The object \"%s\" has been successfully deleted!", $guid) - ); - } catch (Horde_Kolab_Server_Exception $e) { - $this->_logger->info( - sprintf( - "Failed deleting object \"%s\"! Error: %s", - $object->getGuid(), $e->getMessage() - ) - ); - - } - - } - - /** - * Rename an object. - * - * @param string $guid The GUID of the object to be renamed. - * @param string $new The new GUID of the object. - * - * @return NULL - * - * @throws Horde_Kolab_Server_Exception - */ - public function rename($guid, $new) - { - try { - $this->_server->rename($guid, $new); - $this->_logger->info( - sprintf( - "The object \"%s\" has been successfully renamed to \"%s\"!", - $guid, $new - ) - ); - } catch (Horde_Kolab_Server_Exception $e) { - $this->_logger->info( - sprintf( - "Failed saving object \"%s\"! Error: %s", - $object->getGuid(), $e->getMessage() - ) - ); - - } - } - - /** - * Return the ldap schema. - * - * @return Net_LDAP2_Schema The LDAP schema. - * - * @throws Horde_Kolab_Server_Exception If retrieval of the schema failed. - */ - public function getSchema() - { - return $this->_server->getSchema(); - } - - /** - * Get the parent GUID of this object. - * - * @param string $guid The GUID of the child. - * - * @return string the parent GUID of this object. - */ - public function getParentGuid($guid) - { - return $this->_server->getParentGuid($guid); - } -} diff --git a/framework/Kolab_Server/lib/Horde/Kolab/Server/Mapped.php b/framework/Kolab_Server/lib/Horde/Kolab/Server/Mapped.php deleted file mode 100644 index f911d748b..000000000 --- a/framework/Kolab_Server/lib/Horde/Kolab/Server/Mapped.php +++ /dev/null @@ -1,345 +0,0 @@ - - * @license http://www.fsf.org/copyleft/lgpl.html LGPL - * @link http://pear.horde.org/index.php?package=Kolab_Server - */ - -/** - * A server delegation that maps object attributes. - * - * Copyright 2008-2009 The Horde Project (http://www.horde.org/) - * - * See the enclosed file COPYING for license information (LGPL). If you - * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html. - * - * @category Kolab - * @package Kolab_Server - * @author Gunnar Wrobel - * @license http://www.fsf.org/copyleft/lgpl.html LGPL - * @link http://pear.horde.org/index.php?package=Kolab_Server - */ -class Horde_Kolab_Server_Mapped implements Horde_Kolab_Server -{ - /** - * The server we delegate to. - * - * @var Horde_Kolab_Server - */ - private $_server; - - /** - * The attribute mapping. - * - * @var array - */ - private $_mapping; - - /** - * Constructor. - * - * @param Horde_Kolab_Server $server The base server connection. - * @param array $mapping The attribute mapping. - */ - public function __construct(Horde_Kolab_Server $server, array $mapping) - { - $this->_server = $server; - $this->_mapping = $mapping; - } - - /** - * Connect to the server. Use this method if the user name you can provide - * does not match a GUID. In this case it will be required to map this user - * name first. - * - * @param string $user The user name. - * @param string $pass The password. - * - * @return NULL. - * - * @throws Horde_Kolab_Server_Exception If the connection failed. - */ - public function connect($user = null, $pass = null) - { - $this->_server->connect($user, $pass); - } - - /** - * Connect to the server. - * - * @param string $guid The global unique id of the user. - * @param string $pass The password. - * - * @return NULL. - * - * @throws Horde_Kolab_Server_Exception If the connection failed. - */ - public function connectGuid($guid = '', $pass = '') - { - $this->_server->connectGuid($guid, $pass); - } - - /** - * Get the current GUID - * - * @return string The GUID of the connected user. - */ - public function getGuid() - { - $this->_server->getGuid(); - } - - /** - * Get the base GUID of this server - * - * @return string The base GUID of this server. - */ - public function getBaseGuid() - { - $this->_server->getBaseGuid(); - } - - /** - * Low level access to reading object data. - * - * @param string $guid The object to retrieve. - * @param array $attrs Restrict to these attributes. - * - * @return array An array of attributes. - * - * @throws Horde_Kolab_Server_Exception If the search operation hit an error - * or returned no result. - */ - public function read($guid, array $attrs = array()) - { - $data = $this->_server->read($guid); - $this->unmapAttributes($data); - return $data; - } - - /** - * Low level access to reading some object attributes. - * - * @param string $guid The object to retrieve. - * @param string $attrs Restrict to these attributes. - * - * @return array An array of attributes. - * - * @throws Horde_Kolab_Server_Exception - * - * @see Horde_Kolab_Server::read - */ - public function readAttributes($guid, array $attrs) - { - $this->mapKeys($attrs); - $data = $this->_server->readAttributes($guid, $attrs); - $this->unmapAttributes($data); - return $data; - } - - /** - * Finds object data matching a given set of criteria. - * - * @param string $query The LDAP search query - * @param array $params Additional search parameters. - * - * @return array The result array. - * - * @throws Horde_Kolab_Server_Exception - */ - public function find($query, array $params = array()) - { - $criteria = new Horde_Kolab_Server_Query_Element_Mapped($criteria, $this); - $data = $this->_server->find($criteria, $params); - $this->unmapAttributes($data); - return $data; - } - - /** - * Finds all object data below a parent matching a given set of criteria. - * - * @param string $query The LDAP search query - * @param string $parent The parent to search below. - * @param array $params Additional search parameters. - * - * @return array The result array. - * - * @throws Horde_Kolab_Server_Exception - */ - public function findBelow($query, $parent, array $params = array()) - { - $criteria = new Horde_Kolab_Server_Query_Element_Mapped($criteria, $this); - $data = $this->_server->findBelow($criteria, $parent, $params); - $this->unmapAttributes($data); - return $data; - } - - - /** - * Modify existing object data. - * - * @param string $guid The GUID of the object to be added. - * @param array $data The attributes of the object to be added. - * - * @return NULL - * - * @throws Horde_Kolab_Server_Exception - */ - public function save(Horde_Kolab_Server_Object $object, array $data) - { - //@todo: This will not work this way as we need to map internal - // attributes. - $this->mapAttributes($data); - $this->_server->save($object, $data); - } - - /** - * Add new object data. - * - * @param string $guid The GUID of the object to be added. - * @param array $data The attributes of the object to be added. - * - * @return NULL - * - * @throws Horde_Kolab_Server_Exception - */ - public function add(Horde_Kolab_Server_Object $object, array $data) - { - //@todo: This will not work this way as we need to map internal - // attributes. - $this->mapAttributes($data); - $this->_server->add($object, $data); - } - - /** - * Delete an object. - * - * @param string $guid The GUID of the object to be deleted. - * - * @return NULL - * - * @throws Horde_Kolab_Server_Exception - */ - public function delete($guid) - { - $this->_server->delete($guid); - } - - /** - * Rename an object. - * - * @param string $guid The GUID of the object to be renamed. - * @param string $new The new GUID of the object. - * - * @return NULL - * - * @throws Horde_Kolab_Server_Exception - */ - public function rename($guid, $new) - { - $this->_server->rename($guid, $new); - } - - /** - * Return the ldap schema. - * - * @return Net_LDAP2_Schema The LDAP schema. - * - * @throws Horde_Kolab_Server_Exception If retrieval of the schema failed. - */ - public function getSchema() - { - return $this->_server->getSchema(); - } - - - /** - * Map attributes defined within this library to their real world - * counterparts. - * - * @param array &$data The data that has been read and needs to be mapped. - * - * @return NULL - */ - protected function unmapAttributes(&$data) - { - foreach ($data as &$element) { - foreach ($this->mapping as $attribute => $map) { - if (isset($element[$map])) { - $element[$attribute] = $element[$map]; - unset($element[$map]); - } - } - } - } - - /** - * Map attributes defined within this library into their real world - * counterparts. - * - * @param array &$data The data to be written. - * - * @return NULL - */ - protected function mapAttributes(&$data) - { - foreach ($this->mapping as $attribute => $map) { - if (isset($data[$attribute])) { - $data[$map] = $data[$attribute]; - unset($data[$attribute]); - } - } - } - - /** - * Map attribute keys defined within this library into their real world - * counterparts. - * - * @param array &$keys The attribute keys. - * - * @return NULL - */ - protected function mapKeys(&$keys) - { - foreach ($this->mapping as $attribute => $map) { - $key = array_search($attribute, $keys); - if ($key !== false) { - $keys[$key] = $map; - } - } - } - - /** - * Map a single attribute key defined within this library into its real - * world counterpart. - * - * @param array $field The attribute name. - * - * @return The real name of this attribute on the server we connect to. - */ - public function mapField($field) - { - if (isset($this->mapping[$field])) { - return $this->mapping[$field]; - } - return $field; - } - - /** - * Get the parent GUID of this object. - * - * @param string $guid The GUID of the child. - * - * @return string the parent GUID of this object. - */ - public function getParentGuid($guid) - { - return $this->_server->getParentGuid($guid); - } -} diff --git a/framework/Kolab_Server/lib/Horde/Kolab/Server/Object.php b/framework/Kolab_Server/lib/Horde/Kolab/Server/Object.php deleted file mode 100644 index bd13a29e1..000000000 --- a/framework/Kolab_Server/lib/Horde/Kolab/Server/Object.php +++ /dev/null @@ -1,138 +0,0 @@ - - * @license http://www.fsf.org/copyleft/lgpl.html LGPL - * @link http://pear.horde.org/index.php?package=Kolab_Server - */ - -/** - * Interface describing Kolab objects stored in the server database. - * - * Copyright 2008-2009 The Horde Project (http://www.horde.org/) - * - * See the enclosed file COPYING for license information (LGPL). If you - * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html. - * - * @category Kolab - * @package Kolab_Server - * @author Gunnar Wrobel - * @license http://www.fsf.org/copyleft/lgpl.html LGPL - * @link http://pear.horde.org/index.php?package=Kolab_Server - */ -interface Horde_Kolab_Server_Object -{ - /** - * Get the GUID of this object - * - * @return string the GUID of this object - */ - public function getGuid(); - - /** - * Get the external attributes supported by this object. - * - * @return array The external attributes supported by this object. This is a - * list of abbreviated attribute class names. - */ - public function getExternalAttributes(); - - /** - * Get the internal attributes supported by this object. - * - * @return array The internal attributes supported by this object. This is - * an association of internal attribute names an the correspodning attribute - * class names. - */ - public function getInternalAttributes(); - - /** - * Does the object exist? - * - * @return boolean True if the object exists, false otherwise. - */ - public function exists(); - - /** - * Read the object into the cache - * - * @return array The read data. - */ - public function readInternal(); - - /** - * Get the specified attribute of this object - * - * @param string $attr The attribute to read - * - * @return array The value(s) of this attribute - */ - public function getInternal($attr); - - /** - * Get the specified attribute of this object. - * - * @param string $attr The attribute to read. - * - * @return mixed The value of this attribute. - */ - public function getExternal($attr); - - /** - * Saves object information. This may either create a new entry or modify an - * existing entry. - * - * Please note that fields with multiple allowed values require the callee - * to provide the full set of values for the field. Any old values that are - * not resubmitted will be considered to be deleted. - * - * @param array $info The information about the object. - * - * @return NULL - * - * @throws Horde_Kolab_Server_Exception If saving the data failed. - */ - public function save(array $info); - - /** - * Delete this object. - * - * @return NULL - * - * @throws Horde_Kolab_Server_Exception If deleting the object failed. - */ - public function delete(); - - /** - * Generates an ID for the given information. - * - * @param array &$info The data of the object. - * - * @return string The ID. - */ - public function generateId(array &$info); - - /** - * Distill the server side object information to save. - * - * @param array &$info The information about the object. - * - * @return NULL. - * - * @throws Horde_Kolab_Server_Exception If the given information contains errors. - */ - public function prepareObjectInformation(array &$info); - - /** - * Returns the set of actions supported by this object type. - * - * @return array An array of supported actions. - */ - public function getActions(); - -} diff --git a/framework/Kolab_Server/lib/Horde/Kolab/Server/Object/Attribute.php b/framework/Kolab_Server/lib/Horde/Kolab/Server/Object/Attribute.php deleted file mode 100644 index 6d6b38ec5..000000000 --- a/framework/Kolab_Server/lib/Horde/Kolab/Server/Object/Attribute.php +++ /dev/null @@ -1,89 +0,0 @@ - - * @license http://www.fsf.org/copyleft/lgpl.html LGPL - * @link http://pear.horde.org/index.php?package=Kolab_Server - */ - -/** - * The interface representing Kolab object attributes. - * - * Copyright 2008-2009 The Horde Project (http://www.horde.org/) - * - * See the enclosed file COPYING for license information (LGPL). If you - * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html. - * - * @category Kolab - * @package Kolab_Server - * @author Gunnar Wrobel - * @license http://www.fsf.org/copyleft/lgpl.html LGPL - * @link http://pear.horde.org/index.php?package=Kolab_Server - */ -interface Horde_Kolab_Server_Object_Attribute -{ - /** - * Return the value of this attribute. - * - * @return array The value(s) of this attribute. - * - * @throws Horde_Kolab_Server_Exception If retrieval of the value failed. - */ - public function value(); - - /** - * Return the new internal state for this attribute. - * - * @param array $changes The object data that should be updated. - * - * @return array The resulting internal state. - * - * @throws Horde_Kolab_Server_Exception If storing the value failed. - */ - public function update(array $changes); - - /** - * Return the object this attribute belongs to. - * - * @return Horde_Kolab_Server_Object The object. - */ - public function getObject(); - - /** - * Return the internal name of this attribute. - * - * @return string The name of this object. - */ - public function getInternalName(); - - /** - * Return the external name of this attribute. - * - * @return string The name of this object. - */ - public function getExternalName(); - - /** - * Return if this attribute is undefined in the given data array. - * - * @param array $changes The data array to test. - * - * @return string The name of this object. - */ - public function isEmpty(array $changes); - - /** - * Indicate that a value will be saved by deleting it from the original data - * array. - * - * @param array &$changes The object data that should be changed. - * - * @return NULL - */ - public function consume(array &$changes); -} \ No newline at end of file diff --git a/framework/Kolab_Server/lib/Horde/Kolab/Server/Object/Attribute/Base.php b/framework/Kolab_Server/lib/Horde/Kolab/Server/Object/Attribute/Base.php index c3e63b253..3ed439d9d 100644 --- a/framework/Kolab_Server/lib/Horde/Kolab/Server/Object/Attribute/Base.php +++ b/framework/Kolab_Server/lib/Horde/Kolab/Server/Object/Attribute/Base.php @@ -26,7 +26,7 @@ * @link http://pear.horde.org/index.php?package=Kolab_Server */ abstract class Horde_Kolab_Server_Object_Attribute_Base -implements Horde_Kolab_Server_Object_Attribute +implements Horde_Kolab_Server_Object_Attribute_Interface { /** * The attribute name on the internal side. @@ -65,15 +65,15 @@ implements Horde_Kolab_Server_Object_Attribute * @param string $name The name of this attribute. */ public function __construct( - Horde_Kolab_Server_Object $object, - Horde_Kolab_Server_Composite $composite, + Horde_Kolab_Server_Object_Interface $object, + Horde_Kolab_Server_Composite_Interface $composite, $external ) { $this->_object = $object; $this->_composite = $composite; $this->_external = $external; - $this->_internal = $this->_composite->structure->getInternalAttribute( + $this->_internal = $this->_composite->structure->mapExternalToInternalAttribute( $this->_external ); } diff --git a/framework/Kolab_Server/lib/Horde/Kolab/Server/Object/Attribute/Decorator.php b/framework/Kolab_Server/lib/Horde/Kolab/Server/Object/Attribute/Decorator.php index 2142c5e37..5e7884930 100644 --- a/framework/Kolab_Server/lib/Horde/Kolab/Server/Object/Attribute/Decorator.php +++ b/framework/Kolab_Server/lib/Horde/Kolab/Server/Object/Attribute/Decorator.php @@ -26,7 +26,7 @@ * @link http://pear.horde.org/index.php?package=Kolab_Server */ class Horde_Kolab_Server_Object_Attribute_Decorator -implements Horde_Kolab_Server_Object_Attribute +implements Horde_Kolab_Server_Object_Attribute_Interface { /** * The decorated attribute. @@ -42,7 +42,7 @@ implements Horde_Kolab_Server_Object_Attribute * attribute. */ public function __construct( - Horde_Kolab_Server_Object_Attribute $attribute + Horde_Kolab_Server_Object_Attribute_Interface $attribute ) { $this->_attribute = $attribute; } diff --git a/framework/Kolab_Server/lib/Horde/Kolab/Server/Object/Attribute/Interface.php b/framework/Kolab_Server/lib/Horde/Kolab/Server/Object/Attribute/Interface.php new file mode 100644 index 000000000..5e3b8eb03 --- /dev/null +++ b/framework/Kolab_Server/lib/Horde/Kolab/Server/Object/Attribute/Interface.php @@ -0,0 +1,89 @@ + + * @license http://www.fsf.org/copyleft/lgpl.html LGPL + * @link http://pear.horde.org/index.php?package=Kolab_Server + */ + +/** + * The interface representing Kolab object attributes. + * + * Copyright 2008-2009 The Horde Project (http://www.horde.org/) + * + * See the enclosed file COPYING for license information (LGPL). If you + * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html. + * + * @category Kolab + * @package Kolab_Server + * @author Gunnar Wrobel + * @license http://www.fsf.org/copyleft/lgpl.html LGPL + * @link http://pear.horde.org/index.php?package=Kolab_Server + */ +interface Horde_Kolab_Server_Object_Attribute_Interface +{ + /** + * Return the value of this attribute. + * + * @return array The value(s) of this attribute. + * + * @throws Horde_Kolab_Server_Exception If retrieval of the value failed. + */ + public function value(); + + /** + * Return the new internal state for this attribute. + * + * @param array $changes The object data that should be updated. + * + * @return array The resulting internal state. + * + * @throws Horde_Kolab_Server_Exception If storing the value failed. + */ + public function update(array $changes); + + /** + * Return the object this attribute belongs to. + * + * @return Horde_Kolab_Server_Object The object. + */ + public function getObject(); + + /** + * Return the internal name of this attribute. + * + * @return string The name of this object. + */ + public function getInternalName(); + + /** + * Return the external name of this attribute. + * + * @return string The name of this object. + */ + public function getExternalName(); + + /** + * Return if this attribute is undefined in the given data array. + * + * @param array $changes The data array to test. + * + * @return string The name of this object. + */ + public function isEmpty(array $changes); + + /** + * Indicate that a value will be saved by deleting it from the original data + * array. + * + * @param array &$changes The object data that should be changed. + * + * @return NULL + */ + public function consume(array &$changes); +} \ No newline at end of file diff --git a/framework/Kolab_Server/lib/Horde/Kolab/Server/Object/Attribute/Objectclass.php b/framework/Kolab_Server/lib/Horde/Kolab/Server/Object/Attribute/Objectclass.php index eed3ebd29..aed9a9f3f 100644 --- a/framework/Kolab_Server/lib/Horde/Kolab/Server/Object/Attribute/Objectclass.php +++ b/framework/Kolab_Server/lib/Horde/Kolab/Server/Object/Attribute/Objectclass.php @@ -36,8 +36,8 @@ extends Horde_Kolab_Server_Object_Attribute_Decorator * @param Horde_Kolab_Server_Composite $composite The link to the server. */ public function __construct( - Horde_Kolab_Server_Object $object, - Horde_Kolab_Server_Composite $composite + Horde_Kolab_Server_Object_Interface $object, + Horde_Kolab_Server_Composite_Interface $composite ) { $this->_attribute = new Horde_Kolab_Server_Object_Attribute_Required( new Horde_Kolab_Server_Object_Attribute_Locked( diff --git a/framework/Kolab_Server/lib/Horde/Kolab/Server/Object/Base.php b/framework/Kolab_Server/lib/Horde/Kolab/Server/Object/Base.php index 17e6d149a..cf89916c2 100644 --- a/framework/Kolab_Server/lib/Horde/Kolab/Server/Object/Base.php +++ b/framework/Kolab_Server/lib/Horde/Kolab/Server/Object/Base.php @@ -28,7 +28,7 @@ * @link http://pear.horde.org/index.php?package=Kolab_Server */ abstract class Horde_Kolab_Server_Object_Base -implements Horde_Kolab_Server_Object +implements Horde_Kolab_Server_Object_Interface { /** * Link to the Kolab server. @@ -51,7 +51,7 @@ implements Horde_Kolab_Server_Object * @param string $guid GUID of the object. */ public function __construct( - Horde_Kolab_Server_Composite $composite, + Horde_Kolab_Server_Composite_Interface $composite, $guid = null ) { $this->_composite = $composite; diff --git a/framework/Kolab_Server/lib/Horde/Kolab/Server/Object/Factory.php b/framework/Kolab_Server/lib/Horde/Kolab/Server/Object/Factory.php index 01150765e..da6ef99a0 100644 --- a/framework/Kolab_Server/lib/Horde/Kolab/Server/Object/Factory.php +++ b/framework/Kolab_Server/lib/Horde/Kolab/Server/Object/Factory.php @@ -34,16 +34,17 @@ class Horde_Kolab_Server_Object_Factory * @param mixed $type The type of the Horde_Kolab_Server_Object subclass * to return. * @param string $uid UID of the object - * @param array &$storage A link to the Kolab_Server class handling read/write. + * @param array $storage A link to the Kolab_Server class handling read/write. * @param array $data A possible array of data for the object * * @return Horde_Kolab_Server_Object|PEAR_Error The newly created concrete * Horde_Kolab_Server_Object instance. */ - static public function &factory($type, $uid, &$storage, $data = null) - { - $result = Horde_Kolab_Server_Object::loadClass($type); - + static public function factory( + $type, $uid, + Horde_Kolab_Server_Composite $storage, + $data = null + ) { if (class_exists($type)) { $object = new $type($storage, $uid, $data); } else { @@ -53,6 +54,7 @@ class Horde_Kolab_Server_Object_Factory return $object; } + /** * Attempts to load the concrete Horde_Kolab_Server_Object class based on * $type. @@ -69,5 +71,4 @@ class Horde_Kolab_Server_Object_Factory throw new Horde_Kolab_Server_Exception('Class definition of ' . $type . ' not found.'); } } - } diff --git a/framework/Kolab_Server/lib/Horde/Kolab/Server/Object/Groupofnames.php b/framework/Kolab_Server/lib/Horde/Kolab/Server/Object/Groupofnames.php index 874979925..ac82299a4 100644 --- a/framework/Kolab_Server/lib/Horde/Kolab/Server/Object/Groupofnames.php +++ b/framework/Kolab_Server/lib/Horde/Kolab/Server/Object/Groupofnames.php @@ -27,6 +27,9 @@ */ class Horde_Kolab_Server_Object_Groupofnames extends Horde_Kolab_Server_Object_Top { + /** The specific object class of this object type */ + const OBJECTCLASS_GROUPOFNAMES = 'groupOfNames'; + /** Define attributes specific to this object type */ /** The common name */ @@ -35,9 +38,6 @@ class Horde_Kolab_Server_Object_Groupofnames extends Horde_Kolab_Server_Object_T /** The members of this group */ const ATTRIBUTE_MEMBER = 'member'; - /** The specific object class of this object type */ - const OBJECTCLASS_GROUPOFNAMES = 'groupOfNames'; - /** * A structure to initialize the attribute structure for this class. * @@ -159,71 +159,4 @@ class Horde_Kolab_Server_Object_Groupofnames extends Horde_Kolab_Server_Object_T return true; } } - - /** - * Returns the set of search operations supported by this object type. - * - * @return array An array of supported search operations. - */ - static public function getSearchOperations() - { - $searches = array( -/* 'gidForSearch', */ -/* 'getGroups', */ - ); - return $searches; - } - - /** - * @todo: This method belongs somewhere where we are aware of groups - * Identify the GID for the first group found using the specified - * search criteria - * - * @param array $criteria The search parameters as array. - * @param int $restrict A Horde_Kolab_Server::RESULT_* result restriction. - * - * @return boolean|string|array The GID(s) or false if there was no result. - * - * @throws Horde_Kolab_Server_Exception - */ - static public function gidForSearch($server, $criteria, - $restrict = 0) - { - $groups = array('field' => self::ATTRIBUTE_OC, - 'op' => '=', - 'test' => self::OBJECTCLASS_GROUPOFNAMES); - if (!empty($criteria)) { - $criteria = array('AND' => array($groups, $criteria)); - } else { - $criteria = array('AND' => array($groups)); - } - return self::basicUidForSearch($server, $criteria, $restrict); - } - - /** - * Get the groups for this object. - * - * @param string $uid The UID of the object to fetch. - * - * @return array An array of group ids. - * - * @throws Horde_Kolab_Server_Exception - */ - static public function getGroups($server, $uid) - { - $criteria = array('AND' => - array( - array('field' => self::ATTRIBUTE_MEMBER, - 'op' => '=', - 'test' => $uid), - ), - ); - - $result = self::gidForSearch($server, $criteria, self::RESULT_MANY); - if (empty($result)) { - return array(); - } - return $result; - } - } diff --git a/framework/Kolab_Server/lib/Horde/Kolab/Server/Object/Hash.php b/framework/Kolab_Server/lib/Horde/Kolab/Server/Object/Hash.php index c5e38f96a..c8486b9a3 100644 --- a/framework/Kolab_Server/lib/Horde/Kolab/Server/Object/Hash.php +++ b/framework/Kolab_Server/lib/Horde/Kolab/Server/Object/Hash.php @@ -26,7 +26,7 @@ * @link http://pear.horde.org/index.php?package=Kolab_Server */ class Horde_Kolab_Server_Object_Hash -implements Horde_Kolab_Server_Object +implements Horde_Kolab_Server_Object_Interface //@todo: Implement ArrayAccess { /** diff --git a/framework/Kolab_Server/lib/Horde/Kolab/Server/Object/Inetorgperson.php b/framework/Kolab_Server/lib/Horde/Kolab/Server/Object/Inetorgperson.php index 408f995b6..8255c5fb1 100644 --- a/framework/Kolab_Server/lib/Horde/Kolab/Server/Object/Inetorgperson.php +++ b/framework/Kolab_Server/lib/Horde/Kolab/Server/Object/Inetorgperson.php @@ -88,105 +88,105 @@ class Horde_Kolab_Server_Object_Inetorgperson extends Horde_Kolab_Server_Object_ * * @var array */ - static public $init_attributes = array( - 'defined' => array( - self::ATTRIBUTE_SID, - self::ATTRIBUTE_GIVENNAME, - self::ATTRIBUTE_MAIL, - self::ATTRIBUTE_LABELEDURI, - self::ATTRIBUTE_HOMEPOSTALADDRESS, - self::ATTRIBUTE_ORGANIZATION, - self::ATTRIBUTE_BUSINESSCATEGORY, - self::ATTRIBUTE_HOMEPHONE, - self::ATTRIBUTE_MOBILE, - self::ATTRIBUTE_PHOTO, - self::ATTRIBUTE_JPEGPHOTO, - self::ATTRIBUTE_SMIMECERTIFICATE, - ), - 'derived' => array( - self::ATTRARRAY_HOMEPOSTALADDRESS => array( - 'base' => array( - self::ATTRIBUTE_HOMEPOSTALADDRESS, - self::ATTRIBUTE_GIVENNAME, - self::ATTRIBUTE_SN - ), - 'method' => 'getHomePostalAddressHash', - ), - self::ATTRARRAY_LABELEDURI => array( - 'base' => array( - self::ATTRIBUTE_LABELEDURI, - ), - 'method' => 'getLabeledUriHash', - ), - self::ATTRIBUTE_GIVENNAME => array( - 'base' => array( - self::ATTRIBUTE_GIVENNAME, - ), - 'method' => 'getField', - 'args' => array( - self::ATTRIBUTE_GIVENNAME, - 0, - ' ' - ), - ), - self::ATTRIBUTE_MIDDLENAMES => array( - 'base' => array( - self::ATTRIBUTE_GIVENNAME, - ), - 'method' => 'getField', - 'args' => array( - self::ATTRIBUTE_GIVENNAME, - 1, - ' ', - 2 - ), - ), - self::ATTRIBUTE_FNLN => array( - 'base' => array( - self::ATTRIBUTE_GIVENNAME, - self::ATTRIBUTE_SN - ), - 'method' => 'getFnLn', - ), - self::ATTRIBUTE_LNFN => array( - 'base' => array( - self::ATTRIBUTE_GIVENNAME, - self::ATTRIBUTE_SN - ), - 'method' => 'getLnFn', - ), - ), - 'collapsed' => array( - self::ATTRIBUTE_GIVENNAME => array( - 'base' => array( - self::ATTRIBUTE_GIVENNAME, - self::ATTRIBUTE_MIDDLENAMES, - ), - 'method' => 'setField', - 'args' => array( - ' ', - ), - ), - self::ATTRIBUTE_LABELEDURI => array( - 'base' => array( - self::ATTRARRAY_LABELEDURI, - ), - 'method' => 'setLabeledUriHash', - ), - self::ATTRIBUTE_HOMEPOSTALADDRESS => array( - 'base' => array( - self::ATTRARRAY_HOMEPOSTALADDRESS, - ), - 'method' => 'setHomePostalAddressHash', - ), - ), - 'locked' => array( - self::ATTRIBUTE_MAIL, - ), - 'object_classes' => array( - self::OBJECTCLASS_INETORGPERSON, - ), - ); +/* static public $init_attributes = array( */ +/* 'defined' => array( */ +/* self::ATTRIBUTE_SID, */ +/* self::ATTRIBUTE_GIVENNAME, */ +/* self::ATTRIBUTE_MAIL, */ +/* self::ATTRIBUTE_LABELEDURI, */ +/* self::ATTRIBUTE_HOMEPOSTALADDRESS, */ +/* self::ATTRIBUTE_ORGANIZATION, */ +/* self::ATTRIBUTE_BUSINESSCATEGORY, */ +/* self::ATTRIBUTE_HOMEPHONE, */ +/* self::ATTRIBUTE_MOBILE, */ +/* self::ATTRIBUTE_PHOTO, */ +/* self::ATTRIBUTE_JPEGPHOTO, */ +/* self::ATTRIBUTE_SMIMECERTIFICATE, */ +/* ), */ +/* 'derived' => array( */ +/* self::ATTRARRAY_HOMEPOSTALADDRESS => array( */ +/* 'base' => array( */ +/* self::ATTRIBUTE_HOMEPOSTALADDRESS, */ +/* self::ATTRIBUTE_GIVENNAME, */ +/* self::ATTRIBUTE_SN */ +/* ), */ +/* 'method' => 'getHomePostalAddressHash', */ +/* ), */ +/* self::ATTRARRAY_LABELEDURI => array( */ +/* 'base' => array( */ +/* self::ATTRIBUTE_LABELEDURI, */ +/* ), */ +/* 'method' => 'getLabeledUriHash', */ +/* ), */ +/* self::ATTRIBUTE_GIVENNAME => array( */ +/* 'base' => array( */ +/* self::ATTRIBUTE_GIVENNAME, */ +/* ), */ +/* 'method' => 'getField', */ +/* 'args' => array( */ +/* self::ATTRIBUTE_GIVENNAME, */ +/* 0, */ +/* ' ' */ +/* ), */ +/* ), */ +/* self::ATTRIBUTE_MIDDLENAMES => array( */ +/* 'base' => array( */ +/* self::ATTRIBUTE_GIVENNAME, */ +/* ), */ +/* 'method' => 'getField', */ +/* 'args' => array( */ +/* self::ATTRIBUTE_GIVENNAME, */ +/* 1, */ +/* ' ', */ +/* 2 */ +/* ), */ +/* ), */ +/* self::ATTRIBUTE_FNLN => array( */ +/* 'base' => array( */ +/* self::ATTRIBUTE_GIVENNAME, */ +/* self::ATTRIBUTE_SN */ +/* ), */ +/* 'method' => 'getFnLn', */ +/* ), */ +/* self::ATTRIBUTE_LNFN => array( */ +/* 'base' => array( */ +/* self::ATTRIBUTE_GIVENNAME, */ +/* self::ATTRIBUTE_SN */ +/* ), */ +/* 'method' => 'getLnFn', */ +/* ), */ +/* ), */ +/* 'collapsed' => array( */ +/* self::ATTRIBUTE_GIVENNAME => array( */ +/* 'base' => array( */ +/* self::ATTRIBUTE_GIVENNAME, */ +/* self::ATTRIBUTE_MIDDLENAMES, */ +/* ), */ +/* 'method' => 'setField', */ +/* 'args' => array( */ +/* ' ', */ +/* ), */ +/* ), */ +/* self::ATTRIBUTE_LABELEDURI => array( */ +/* 'base' => array( */ +/* self::ATTRARRAY_LABELEDURI, */ +/* ), */ +/* 'method' => 'setLabeledUriHash', */ +/* ), */ +/* self::ATTRIBUTE_HOMEPOSTALADDRESS => array( */ +/* 'base' => array( */ +/* self::ATTRARRAY_HOMEPOSTALADDRESS, */ +/* ), */ +/* 'method' => 'setHomePostalAddressHash', */ +/* ), */ +/* ), */ +/* 'locked' => array( */ +/* self::ATTRIBUTE_MAIL, */ +/* ), */ +/* 'object_classes' => array( */ +/* self::OBJECTCLASS_INETORGPERSON, */ +/* ), */ +/* ); */ /** * Return the filter string to retrieve this object type. diff --git a/framework/Kolab_Server/lib/Horde/Kolab/Server/Object/Interface.php b/framework/Kolab_Server/lib/Horde/Kolab/Server/Object/Interface.php new file mode 100644 index 000000000..c82fc53bf --- /dev/null +++ b/framework/Kolab_Server/lib/Horde/Kolab/Server/Object/Interface.php @@ -0,0 +1,138 @@ + + * @license http://www.fsf.org/copyleft/lgpl.html LGPL + * @link http://pear.horde.org/index.php?package=Kolab_Server + */ + +/** + * Interface describing Kolab objects stored in the server database. + * + * Copyright 2008-2009 The Horde Project (http://www.horde.org/) + * + * See the enclosed file COPYING for license information (LGPL). If you + * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html. + * + * @category Kolab + * @package Kolab_Server + * @author Gunnar Wrobel + * @license http://www.fsf.org/copyleft/lgpl.html LGPL + * @link http://pear.horde.org/index.php?package=Kolab_Server + */ +interface Horde_Kolab_Server_Object_Interface +{ + /** + * Get the GUID of this object + * + * @return string the GUID of this object + */ + public function getGuid(); + + /** + * Get the external attributes supported by this object. + * + * @return array The external attributes supported by this object. This is a + * list of abbreviated attribute class names. + */ + public function getExternalAttributes(); + + /** + * Get the internal attributes supported by this object. + * + * @return array The internal attributes supported by this object. This is + * an association of internal attribute names an the correspodning attribute + * class names. + */ + public function getInternalAttributes(); + + /** + * Does the object exist? + * + * @return boolean True if the object exists, false otherwise. + */ + public function exists(); + + /** + * Read the object into the cache + * + * @return array The read data. + */ + public function readInternal(); + + /** + * Get the specified attribute of this object + * + * @param string $attr The attribute to read + * + * @return array The value(s) of this attribute + */ + public function getInternal($attr); + + /** + * Get the specified attribute of this object. + * + * @param string $attr The attribute to read. + * + * @return mixed The value of this attribute. + */ + public function getExternal($attr); + + /** + * Saves object information. This may either create a new entry or modify an + * existing entry. + * + * Please note that fields with multiple allowed values require the callee + * to provide the full set of values for the field. Any old values that are + * not resubmitted will be considered to be deleted. + * + * @param array $info The information about the object. + * + * @return NULL + * + * @throws Horde_Kolab_Server_Exception If saving the data failed. + */ + public function save(array $info); + + /** + * Delete this object. + * + * @return NULL + * + * @throws Horde_Kolab_Server_Exception If deleting the object failed. + */ + public function delete(); + + /** + * Generates an ID for the given information. + * + * @param array &$info The data of the object. + * + * @return string The ID. + */ + public function generateId(array &$info); + + /** + * Distill the server side object information to save. + * + * @param array &$info The information about the object. + * + * @return NULL. + * + * @throws Horde_Kolab_Server_Exception If the given information contains errors. + */ + public function prepareObjectInformation(array &$info); + + /** + * Returns the set of actions supported by this object type. + * + * @return array An array of supported actions. + */ + public function getActions(); + +} diff --git a/framework/Kolab_Server/lib/Horde/Kolab/Server/Object/Kolab/User.php b/framework/Kolab_Server/lib/Horde/Kolab/Server/Object/Kolab/User.php index 344afdaa6..d962f8390 100644 --- a/framework/Kolab_Server/lib/Horde/Kolab/Server/Object/Kolab/User.php +++ b/framework/Kolab_Server/lib/Horde/Kolab/Server/Object/Kolab/User.php @@ -48,15 +48,15 @@ class Horde_Kolab_Server_Object_Kolab_User extends Horde_Kolab_Server_Object_Kol * * @var array */ - static public $init_attributes = array( - 'derived' => array( - self::ATTRIBUTE_USERTYPE => array(), - self::ATTRIBUTE_FN => array(), - ), - 'required' => array( - self::ATTRIBUTE_USERPASSWORD, - ), - ); +/* static public $init_attributes = array( */ +/* 'derived' => array( */ +/* self::ATTRIBUTE_USERTYPE => array(), */ +/* self::ATTRIBUTE_FN => array(), */ +/* ), */ +/* 'required' => array( */ +/* self::ATTRIBUTE_USERPASSWORD, */ +/* ), */ +/* ); */ /** * Return the filter string to retrieve this object type. diff --git a/framework/Kolab_Server/lib/Horde/Kolab/Server/Object/Kolabinetorgperson.php b/framework/Kolab_Server/lib/Horde/Kolab/Server/Object/Kolabinetorgperson.php index 9f4e85017..9a4c3a1f0 100644 --- a/framework/Kolab_Server/lib/Horde/Kolab/Server/Object/Kolabinetorgperson.php +++ b/framework/Kolab_Server/lib/Horde/Kolab/Server/Object/Kolabinetorgperson.php @@ -59,66 +59,66 @@ class Horde_Kolab_Server_Object_Kolabinetorgperson extends Horde_Kolab_Server_Ob * * @var array */ - static public $init_attributes = array( - 'defined' => array( - self::ATTRIBUTE_ALIAS, - self::ATTRIBUTE_DELEGATE, - self::ATTRIBUTE_DELETED, - self::ATTRIBUTE_FBFUTURE, - self::ATTRIBUTE_HOMESERVER, - self::ATTRIBUTE_FREEBUSYHOST, - self::ATTRIBUTE_IMAPHOST, - self::ATTRIBUTE_IPOLICY, - self::ATTRIBUTE_SALUTATION, - self::ATTRIBUTE_GENDER, - self::ATTRIBUTE_MARITALSTATUS, - self::ATTRIBUTE_HOMEFAX, - self::ATTRIBUTE_GERMANTAXID, - self::ATTRIBUTE_COUNTRY, - self::ATTRIBUTE_QUOTA, - self::ATTRIBUTE_ALLOWEDRECIPIENTS, - self::ATTRIBUTE_ALLOWEDFROM, - self::ATTRIBUTE_DATEOFBIRTH, - self::ATTRIBUTE_PLACEOFBIRTH, - self::ATTRIBUTE_BIRTHNAME, - self::ATTRIBUTE_PSEUDONYM, - self::ATTRIBUTE_COUNTRYCITIZENSHIP, - self::ATTRIBUTE_LEGALFORM, - self::ATTRIBUTE_REGISTEREDCAPITAL, - self::ATTRIBUTE_BYLAWURI, - self::ATTRIBUTE_DATEOFINCORPORATION, - self::ATTRIBUTE_LEGALREPRESENTATIVE, - self::ATTRIBUTE_COMMERCIALPROCURATION, - self::ATTRIBUTE_LEGALREPRESENTATIONPOLICY, - self::ATTRIBUTE_ACTINGDEPUTY, - self::ATTRIBUTE_VATNUMBER, - self::ATTRIBUTE_OTHERLEGAL, - self::ATTRIBUTE_INLIQUIDATION, - self::ATTRIBUTE_TRTYPE, - self::ATTRIBUTE_TRLOCATION, - self::ATTRIBUTE_TRIDENTIFIER, - self::ATTRIBUTE_TRURI, - self::ATTRIBUTE_TRLASTCHANGED, - self::ATTRIBUTE_DC, - ), - 'locked' => array( - self::ATTRIBUTE_MAIL, - ), - /** - * Derived attributes are calculated based on other attribute values. - */ - 'derived' => array( - self::ATTRDATE_DATEOFBIRTH => array( - 'method' => 'getDate', - 'args' => array( - self::ATTRIBUTE_DATEOFBIRTH, - ), - ), - ), - 'object_classes' => array( - self::OBJECTCLASS_KOLABINETORGPERSON, - ), - ); +/* static public $init_attributes = array( */ +/* 'defined' => array( */ +/* self::ATTRIBUTE_ALIAS, */ +/* self::ATTRIBUTE_DELEGATE, */ +/* self::ATTRIBUTE_DELETED, */ +/* self::ATTRIBUTE_FBFUTURE, */ +/* self::ATTRIBUTE_HOMESERVER, */ +/* self::ATTRIBUTE_FREEBUSYHOST, */ +/* self::ATTRIBUTE_IMAPHOST, */ +/* self::ATTRIBUTE_IPOLICY, */ +/* self::ATTRIBUTE_SALUTATION, */ +/* self::ATTRIBUTE_GENDER, */ +/* self::ATTRIBUTE_MARITALSTATUS, */ +/* self::ATTRIBUTE_HOMEFAX, */ +/* self::ATTRIBUTE_GERMANTAXID, */ +/* self::ATTRIBUTE_COUNTRY, */ +/* self::ATTRIBUTE_QUOTA, */ +/* self::ATTRIBUTE_ALLOWEDRECIPIENTS, */ +/* self::ATTRIBUTE_ALLOWEDFROM, */ +/* self::ATTRIBUTE_DATEOFBIRTH, */ +/* self::ATTRIBUTE_PLACEOFBIRTH, */ +/* self::ATTRIBUTE_BIRTHNAME, */ +/* self::ATTRIBUTE_PSEUDONYM, */ +/* self::ATTRIBUTE_COUNTRYCITIZENSHIP, */ +/* self::ATTRIBUTE_LEGALFORM, */ +/* self::ATTRIBUTE_REGISTEREDCAPITAL, */ +/* self::ATTRIBUTE_BYLAWURI, */ +/* self::ATTRIBUTE_DATEOFINCORPORATION, */ +/* self::ATTRIBUTE_LEGALREPRESENTATIVE, */ +/* self::ATTRIBUTE_COMMERCIALPROCURATION, */ +/* self::ATTRIBUTE_LEGALREPRESENTATIONPOLICY, */ +/* self::ATTRIBUTE_ACTINGDEPUTY, */ +/* self::ATTRIBUTE_VATNUMBER, */ +/* self::ATTRIBUTE_OTHERLEGAL, */ +/* self::ATTRIBUTE_INLIQUIDATION, */ +/* self::ATTRIBUTE_TRTYPE, */ +/* self::ATTRIBUTE_TRLOCATION, */ +/* self::ATTRIBUTE_TRIDENTIFIER, */ +/* self::ATTRIBUTE_TRURI, */ +/* self::ATTRIBUTE_TRLASTCHANGED, */ +/* self::ATTRIBUTE_DC, */ +/* ), */ +/* 'locked' => array( */ +/* self::ATTRIBUTE_MAIL, */ +/* ), */ +/* /\** */ +/* * Derived attributes are calculated based on other attribute values. */ +/* *\/ */ +/* 'derived' => array( */ +/* self::ATTRDATE_DATEOFBIRTH => array( */ +/* 'method' => 'getDate', */ +/* 'args' => array( */ +/* self::ATTRIBUTE_DATEOFBIRTH, */ +/* ), */ +/* ), */ +/* ), */ +/* 'object_classes' => array( */ +/* self::OBJECTCLASS_KOLABINETORGPERSON, */ +/* ), */ +/* ); */ /** * Generates an ID for the given information. diff --git a/framework/Kolab_Server/lib/Horde/Kolab/Server/Object/Mcached.php b/framework/Kolab_Server/lib/Horde/Kolab/Server/Object/Mcached.php index ae57cfcf0..74eeaba06 100644 --- a/framework/Kolab_Server/lib/Horde/Kolab/Server/Object/Mcached.php +++ b/framework/Kolab_Server/lib/Horde/Kolab/Server/Object/Mcached.php @@ -26,7 +26,7 @@ * @link http://pear.horde.org/index.php?package=Kolab_Server */ class Horde_Kolab_Server_Object_Mcached -implements Horde_Kolab_Server_Object +implements Horde_Kolab_Server_Object_Interface { /** * Link to the decorated object. diff --git a/framework/Kolab_Server/lib/Horde/Kolab/Server/Object/Organizationalperson.php b/framework/Kolab_Server/lib/Horde/Kolab/Server/Object/Organizationalperson.php index 9f864a844..584507696 100644 --- a/framework/Kolab_Server/lib/Horde/Kolab/Server/Object/Organizationalperson.php +++ b/framework/Kolab_Server/lib/Horde/Kolab/Server/Object/Organizationalperson.php @@ -58,32 +58,32 @@ class Horde_Kolab_Server_Object_Organizationalperson extends Horde_Kolab_Server_ * * @var array */ - static public $init_attributes = array( - 'defined' => array( - self::ATTRIBUTE_JOBTITLE, - self::ATTRIBUTE_STREET, - self::ATTRIBUTE_POSTOFFICEBOX, - self::ATTRIBUTE_POSTALCODE, - self::ATTRIBUTE_CITY, - self::ATTRIBUTE_FAX, - self::ATTRIBUTE_POSTALADDRESS, - ), - 'collapsed' => array( - self::ATTRIBUTE_POSTALADDRESS => array( - 'base' => array( - self::ATTRIBUTE_SN, - self::ATTRIBUTE_STREET, - self::ATTRIBUTE_POSTOFFICEBOX, - self::ATTRIBUTE_POSTALCODE, - self::ATTRIBUTE_CITY, - ), - 'method' => 'setPostalAddress', - ), - ), - 'object_classes' => array( - self::OBJECTCLASS_ORGANIZATIONALPERSON, - ), - ); +/* static public $init_attributes = array( */ +/* 'defined' => array( */ +/* self::ATTRIBUTE_JOBTITLE, */ +/* self::ATTRIBUTE_STREET, */ +/* self::ATTRIBUTE_POSTOFFICEBOX, */ +/* self::ATTRIBUTE_POSTALCODE, */ +/* self::ATTRIBUTE_CITY, */ +/* self::ATTRIBUTE_FAX, */ +/* self::ATTRIBUTE_POSTALADDRESS, */ +/* ), */ +/* 'collapsed' => array( */ +/* self::ATTRIBUTE_POSTALADDRESS => array( */ +/* 'base' => array( */ +/* self::ATTRIBUTE_SN, */ +/* self::ATTRIBUTE_STREET, */ +/* self::ATTRIBUTE_POSTOFFICEBOX, */ +/* self::ATTRIBUTE_POSTALCODE, */ +/* self::ATTRIBUTE_CITY, */ +/* ), */ +/* 'method' => 'setPostalAddress', */ +/* ), */ +/* ), */ +/* 'object_classes' => array( */ +/* self::OBJECTCLASS_ORGANIZATIONALPERSON, */ +/* ), */ +/* ); */ /** * Return the filter string to retrieve this object type. diff --git a/framework/Kolab_Server/lib/Horde/Kolab/Server/Objects.php b/framework/Kolab_Server/lib/Horde/Kolab/Server/Objects.php deleted file mode 100644 index 5b941e5cd..000000000 --- a/framework/Kolab_Server/lib/Horde/Kolab/Server/Objects.php +++ /dev/null @@ -1,120 +0,0 @@ - - * @license http://www.fsf.org/copyleft/lgpl.html LGPL - * @link http://pear.horde.org/index.php?package=Kolab_Server - */ - -/** - * Interface for a server object list. - * - * Copyright 2008-2009 The Horde Project (http://www.horde.org/) - * - * See the enclosed file COPYING for license information (LGPL). If you - * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html. - * - * @category Kolab - * @package Kolab_Server - * @author Gunnar Wrobel - * @license http://www.fsf.org/copyleft/lgpl.html LGPL - * @link http://pear.horde.org/index.php?package=Kolab_Server - */ -interface Horde_Kolab_Server_Objects -{ - /** - * Set the composite server reference for this object. - * - * @param Horde_Kolab_Server_Composite $composite A link to the composite - * server handler. - */ - public function setComposite(Horde_Kolab_Server_Composite $composite); - - /** - * Add a Kolab object. - * - * @param array $info The object to store. - * - * @return Kolab_Object The newly created Kolab object. - * - * @throws Horde_Kolab_Server_Exception If the type of the object to add has - * been left undefined or the object - * already exists. - */ - public function add(array $info); - - /** - * Fetch a Kolab object. - * - * This method will not retrieve any data from the server - * immediately. Instead it will simply generate a new instance for the - * desired object. - * - * The server data will only be accessed once you start reading the object - * data. - * - * This method can also be used in order to fetch non-existing objects that - * will be saved later. This is however not recommended and you should - * rather use the add($info) method for that. - * - * If you do not provide the object type the server will try to determine it - * automatically based on the uid. As this requires reading data from the - * server it is recommended to specify the object type whenever it is known. - * - * If you do not specify a uid the object corresponding to the user bound to - * the server will be returned. - * - * @param string $uid The UID of the object to fetch. - * @param string $type The type of the object to fetch. - * - * @return Kolab_Object The corresponding Kolab object. - * - * @throws Horde_Kolab_Server_Exception - */ - public function fetch($uid = null, $type = null); - - /** - * List all objects of a specific type - * - * @param string $type The type of the objects to be listed - * @param array $params Additional parameters. - * - * @return array An array of Kolab objects. - * - * @throws Horde_Kolab_Server_Exception - */ - public function listObjects($type, $params = null); - - /** - * Generate a hash representation for a list of objects. - * - * The approach taken here is somewhat slow as the server data gets fetched - * into objects first which are then converted to hashes again. Since a - * server search will usually deliver the result as a hash the intermediate - * object conversion is inefficient. - * - * But as the object classes are able to treat the attributes returned from - * the server with custom parsing, this is currently the preferred - * method. Especially for large result sets it would be better if this - * method would call a static object class function that operate on the - * result array returned from the server without using objects. - * - * @param string $type The type of the objects to be listed - * @param array $params Additional parameters. - * - * @return array An array of Kolab objects. - * - * @throws Horde_Kolab_Server_Exception - * - * @todo The LDAP driver needs a more efficient version of this call as it - * is not required to generate objects before returning data as a - * hash. It can be derived directly from the LDAP result. - */ - public function listHash($type, $params = null); - -} \ No newline at end of file diff --git a/framework/Kolab_Server/lib/Horde/Kolab/Server/Objects/Base.php b/framework/Kolab_Server/lib/Horde/Kolab/Server/Objects/Base.php index 1c38fbdab..6d58d60c0 100644 --- a/framework/Kolab_Server/lib/Horde/Kolab/Server/Objects/Base.php +++ b/framework/Kolab_Server/lib/Horde/Kolab/Server/Objects/Base.php @@ -26,7 +26,8 @@ * @license http://www.fsf.org/copyleft/lgpl.html LGPL * @link http://pear.horde.org/index.php?package=Kolab_Server */ -class Horde_Kolab_Server_Objects_Base implements Horde_Kolab_Server_Objects +class Horde_Kolab_Server_Objects_Base +implements Horde_Kolab_Server_Objects_Interface { /** * A link to the composite server handler. @@ -43,8 +44,9 @@ class Horde_Kolab_Server_Objects_Base implements Horde_Kolab_Server_Objects * * @return NULL */ - public function setComposite(Horde_Kolab_Server_Composite $composite) - { + public function setComposite( + Horde_Kolab_Server_Composite_Interface $composite + ) { $this->_composite = $composite; } @@ -85,8 +87,8 @@ class Horde_Kolab_Server_Objects_Base implements Horde_Kolab_Server_Objects $type = $this->_composite->structure->determineType($guid); } - $object = &Horde_Kolab_Server_Object_Factory::factory( - $type, $guid, $this->_composite->server + $object = Horde_Kolab_Server_Object_Factory::factory( + $type, $guid, $this->_composite ); return $object; } diff --git a/framework/Kolab_Server/lib/Horde/Kolab/Server/Objects/Interface.php b/framework/Kolab_Server/lib/Horde/Kolab/Server/Objects/Interface.php new file mode 100644 index 000000000..7e1e2a4f0 --- /dev/null +++ b/framework/Kolab_Server/lib/Horde/Kolab/Server/Objects/Interface.php @@ -0,0 +1,122 @@ + + * @license http://www.fsf.org/copyleft/lgpl.html LGPL + * @link http://pear.horde.org/index.php?package=Kolab_Server + */ + +/** + * Interface for a server object list. + * + * Copyright 2008-2009 The Horde Project (http://www.horde.org/) + * + * See the enclosed file COPYING for license information (LGPL). If you + * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html. + * + * @category Kolab + * @package Kolab_Server + * @author Gunnar Wrobel + * @license http://www.fsf.org/copyleft/lgpl.html LGPL + * @link http://pear.horde.org/index.php?package=Kolab_Server + */ +interface Horde_Kolab_Server_Objects_Interface +{ + /** + * Set the composite server reference for this object. + * + * @param Horde_Kolab_Server_Composite $composite A link to the composite + * server handler. + */ + public function setComposite( + Horde_Kolab_Server_Composite_Interface $composite + ); + + /** + * Add a Kolab object. + * + * @param array $info The object to store. + * + * @return Kolab_Object The newly created Kolab object. + * + * @throws Horde_Kolab_Server_Exception If the type of the object to add has + * been left undefined or the object + * already exists. + */ + public function add(array $info); + + /** + * Fetch a Kolab object. + * + * This method will not retrieve any data from the server + * immediately. Instead it will simply generate a new instance for the + * desired object. + * + * The server data will only be accessed once you start reading the object + * data. + * + * This method can also be used in order to fetch non-existing objects that + * will be saved later. This is however not recommended and you should + * rather use the add($info) method for that. + * + * If you do not provide the object type the server will try to determine it + * automatically based on the uid. As this requires reading data from the + * server it is recommended to specify the object type whenever it is known. + * + * If you do not specify a uid the object corresponding to the user bound to + * the server will be returned. + * + * @param string $uid The UID of the object to fetch. + * @param string $type The type of the object to fetch. + * + * @return Kolab_Object The corresponding Kolab object. + * + * @throws Horde_Kolab_Server_Exception + */ + public function fetch($uid = null, $type = null); + + /** + * List all objects of a specific type + * + * @param string $type The type of the objects to be listed + * @param array $params Additional parameters. + * + * @return array An array of Kolab objects. + * + * @throws Horde_Kolab_Server_Exception + */ + public function listObjects($type, $params = null); + + /** + * Generate a hash representation for a list of objects. + * + * The approach taken here is somewhat slow as the server data gets fetched + * into objects first which are then converted to hashes again. Since a + * server search will usually deliver the result as a hash the intermediate + * object conversion is inefficient. + * + * But as the object classes are able to treat the attributes returned from + * the server with custom parsing, this is currently the preferred + * method. Especially for large result sets it would be better if this + * method would call a static object class function that operate on the + * result array returned from the server without using objects. + * + * @param string $type The type of the objects to be listed + * @param array $params Additional parameters. + * + * @return array An array of Kolab objects. + * + * @throws Horde_Kolab_Server_Exception + * + * @todo The LDAP driver needs a more efficient version of this call as it + * is not required to generate objects before returning data as a + * hash. It can be derived directly from the LDAP result. + */ + public function listHash($type, $params = null); + +} \ No newline at end of file diff --git a/framework/Kolab_Server/lib/Horde/Kolab/Server/Query.php b/framework/Kolab_Server/lib/Horde/Kolab/Server/Query.php deleted file mode 100644 index 706e2ebd1..000000000 --- a/framework/Kolab_Server/lib/Horde/Kolab/Server/Query.php +++ /dev/null @@ -1,126 +0,0 @@ - - * @license http://www.fsf.org/copyleft/lgpl.html LGPL - * @link http://pear.horde.org/index.php?package=Kolab_Server - */ - -/** - * Interface for server queries. - * - * Copyright 2008-2009 The Horde Project (http://www.horde.org/) - * - * See the enclosed file COPYING for license information (LGPL). If you - * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html. - * - * @category Kolab - * @package Kolab_Server - * @author Gunnar Wrobel - * @license http://www.fsf.org/copyleft/lgpl.html LGPL - * @link http://pear.horde.org/index.php?package=Kolab_Server - */ -interface Horde_Kolab_Server_Query -{ - /** - * Return the query as a string. - * - * @return string The query in string format. - */ - public function __toString(); - - /** - * Convert the equals element to query format. - * - * @param Horde_Kolab_Server_Query_Element_Single $single The element to convert. - * - * @return mixed The query element in query format. - */ - public function convertEquals(Horde_Kolab_Server_Query_Element_Equals $equals); - - /** - * Convert the begins element to query format. - * - * @param Horde_Kolab_Server_Query_Element_Single $single The element to convert. - * - * @return mixed The query element in query format. - */ - public function convertBegins(Horde_Kolab_Server_Query_Element_Begins $begins); - - /** - * Convert the ends element to query format. - * - * @param Horde_Kolab_Server_Query_Element_Single $single The element to convert. - * - * @return mixed The query element in query format. - */ - public function convertEnds(Horde_Kolab_Server_Query_Element_Ends $ends); - - /** - * Convert the contains element to query format. - * - * @param Horde_Kolab_Server_Query_Element_Single $single The element to convert. - * - * @return mixed The query element in query format. - */ - public function convertContains(Horde_Kolab_Server_Query_Element_Contains $contains); - - /** - * Convert the less element to query format. - * - * @param Horde_Kolab_Server_Query_Element_Single $single The element to convert. - * - * @return mixed The query element in query format. - */ - public function convertLess(Horde_Kolab_Server_Query_Element_Less $less); - - /** - * Convert the greater element to query format. - * - * @param Horde_Kolab_Server_Query_Element_Single $single The element to convert. - * - * @return mixed The query element in query format. - */ - public function convertGreater(Horde_Kolab_Server_Query_Element_Greater $greater); - - /** - * Convert the approx element to query format. - * - * @param Horde_Kolab_Server_Query_Element_Single $single The element to convert. - * - * @return mixed The query element in query format. - */ - public function convertApprox(Horde_Kolab_Server_Query_Element_Approx $approx); - - /** - * Convert the not element to query format. - * - * @param Horde_Kolab_Server_Query_Element_Group $group The element to convert. - * - * @return mixed The query element in query format. - */ - public function convertNot(Horde_Kolab_Server_Query_Element_Not $not); - - /** - * Convert the and element to query format. - * - * @param Horde_Kolab_Server_Query_Element_Group $group The element to convert. - * - * @return mixed The query element in query format. - */ - public function convertAnd(Horde_Kolab_Server_Query_Element_And $and); - - /** - * Convert the or element to query format. - * - * @param Horde_Kolab_Server_Query_Element_Group $group The element to convert. - * - * @return mixed The query element in query format. - */ - public function convertOr(Horde_Kolab_Server_Query_Element_Group $or); -} \ No newline at end of file diff --git a/framework/Kolab_Server/lib/Horde/Kolab/Server/Query/Element.php b/framework/Kolab_Server/lib/Horde/Kolab/Server/Query/Element.php deleted file mode 100644 index 3071c6a96..000000000 --- a/framework/Kolab_Server/lib/Horde/Kolab/Server/Query/Element.php +++ /dev/null @@ -1,58 +0,0 @@ - - * @license http://www.fsf.org/copyleft/lgpl.html LGPL - * @link http://pear.horde.org/index.php?package=Kolab_Server - */ - -/** - * Interface for server query elements. - * - * Copyright 2008-2009 The Horde Project (http://www.horde.org/) - * - * See the enclosed file COPYING for license information (LGPL). If you - * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html. - * - * @category Kolab - * @package Kolab_Server - * @author Gunnar Wrobel - * @license http://www.fsf.org/copyleft/lgpl.html LGPL - * @link http://pear.horde.org/index.php?package=Kolab_Server - */ -interface Horde_Kolab_Server_Query_Element -{ - /** - * Return the query element name. - * - * @return string The name of the query element. - */ - public function getName(); - - /** - * Return the value of this element. - * - * @return mixed The query value. - */ - public function getValue(); - - /** - * Return the elements of this group. - * - * @return mixed The group elements. - */ - public function getElements(); - - /** - * Convert this element to a query element. - * - * @return mixedd The element as query. - */ - public function convert(Horde_Kolab_Server_Query $writer); - -} \ No newline at end of file diff --git a/framework/Kolab_Server/lib/Horde/Kolab/Server/Query/Element/And.php b/framework/Kolab_Server/lib/Horde/Kolab/Server/Query/Element/And.php index abe52bacd..a6621ea8d 100644 --- a/framework/Kolab_Server/lib/Horde/Kolab/Server/Query/Element/And.php +++ b/framework/Kolab_Server/lib/Horde/Kolab/Server/Query/Element/And.php @@ -33,8 +33,9 @@ extends Horde_Kolab_Server_Query_Element_Group * * @return mixed The element as query. */ - public function convert(Horde_Kolab_Server_Query $writer) - { + public function convert( + Horde_Kolab_Server_Query_Interface $writer + ) { return $writer->convertAnd($this); } } \ No newline at end of file diff --git a/framework/Kolab_Server/lib/Horde/Kolab/Server/Query/Element/Approx.php b/framework/Kolab_Server/lib/Horde/Kolab/Server/Query/Element/Approx.php index 486ce564c..de5222791 100644 --- a/framework/Kolab_Server/lib/Horde/Kolab/Server/Query/Element/Approx.php +++ b/framework/Kolab_Server/lib/Horde/Kolab/Server/Query/Element/Approx.php @@ -33,8 +33,9 @@ extends Horde_Kolab_Server_Query_Element_Single * * @return mixed The element as query. */ - public function convert(Horde_Kolab_Server_Query $writer) - { + public function convert( + Horde_Kolab_Server_Query_Interface $writer + ) { return $writer->convertApprox($this); } } \ No newline at end of file diff --git a/framework/Kolab_Server/lib/Horde/Kolab/Server/Query/Element/Begins.php b/framework/Kolab_Server/lib/Horde/Kolab/Server/Query/Element/Begins.php index 3686bc373..2d330362f 100644 --- a/framework/Kolab_Server/lib/Horde/Kolab/Server/Query/Element/Begins.php +++ b/framework/Kolab_Server/lib/Horde/Kolab/Server/Query/Element/Begins.php @@ -33,8 +33,9 @@ extends Horde_Kolab_Server_Query_Element_Single * * @return mixed The element as query. */ - public function convert(Horde_Kolab_Server_Query $writer) - { + public function convert( + Horde_Kolab_Server_Query_Interface $writer + ) { return $writer->convertBegins($this); } } \ No newline at end of file diff --git a/framework/Kolab_Server/lib/Horde/Kolab/Server/Query/Element/Contains.php b/framework/Kolab_Server/lib/Horde/Kolab/Server/Query/Element/Contains.php index 224d187f6..480e1b8c8 100644 --- a/framework/Kolab_Server/lib/Horde/Kolab/Server/Query/Element/Contains.php +++ b/framework/Kolab_Server/lib/Horde/Kolab/Server/Query/Element/Contains.php @@ -33,8 +33,9 @@ extends Horde_Kolab_Server_Query_Element_Single * * @return mixed The element as query. */ - public function convert(Horde_Kolab_Server_Query $writer) - { + public function convert( + Horde_Kolab_Server_Query_Interface $writer + ) { return $writer->convertContains($this); } } \ No newline at end of file diff --git a/framework/Kolab_Server/lib/Horde/Kolab/Server/Query/Element/Ends.php b/framework/Kolab_Server/lib/Horde/Kolab/Server/Query/Element/Ends.php index 742f9ba68..035b58991 100644 --- a/framework/Kolab_Server/lib/Horde/Kolab/Server/Query/Element/Ends.php +++ b/framework/Kolab_Server/lib/Horde/Kolab/Server/Query/Element/Ends.php @@ -33,8 +33,9 @@ extends Horde_Kolab_Server_Query_Element_Single * * @return mixed The element as query. */ - public function convert(Horde_Kolab_Server_Query $writer) - { + public function convert( + Horde_Kolab_Server_Query_Interface $writer + ) { return $writer->convertEnds($this); } } \ No newline at end of file diff --git a/framework/Kolab_Server/lib/Horde/Kolab/Server/Query/Element/Equals.php b/framework/Kolab_Server/lib/Horde/Kolab/Server/Query/Element/Equals.php index c8164ae67..2f24224fc 100644 --- a/framework/Kolab_Server/lib/Horde/Kolab/Server/Query/Element/Equals.php +++ b/framework/Kolab_Server/lib/Horde/Kolab/Server/Query/Element/Equals.php @@ -33,8 +33,9 @@ extends Horde_Kolab_Server_Query_Element_Single * * @return mixed The element as query. */ - public function convert(Horde_Kolab_Server_Query $writer) - { + public function convert( + Horde_Kolab_Server_Query_Interface $writer + ) { return $writer->convertEquals($this); } } \ No newline at end of file diff --git a/framework/Kolab_Server/lib/Horde/Kolab/Server/Query/Element/Greater.php b/framework/Kolab_Server/lib/Horde/Kolab/Server/Query/Element/Greater.php index a7f843cbd..9ca000187 100644 --- a/framework/Kolab_Server/lib/Horde/Kolab/Server/Query/Element/Greater.php +++ b/framework/Kolab_Server/lib/Horde/Kolab/Server/Query/Element/Greater.php @@ -33,8 +33,9 @@ extends Horde_Kolab_Server_Query_Element_Single * * @return mixed The element as query. */ - public function convert(Horde_Kolab_Server_Query $writer) - { + public function convert( + Horde_Kolab_Server_Query_Interface $writer + ) { return $writer->convertGreater($this); } } \ No newline at end of file diff --git a/framework/Kolab_Server/lib/Horde/Kolab/Server/Query/Element/Group.php b/framework/Kolab_Server/lib/Horde/Kolab/Server/Query/Element/Group.php index d861d1a61..9038af0af 100644 --- a/framework/Kolab_Server/lib/Horde/Kolab/Server/Query/Element/Group.php +++ b/framework/Kolab_Server/lib/Horde/Kolab/Server/Query/Element/Group.php @@ -26,7 +26,7 @@ * @link http://pear.horde.org/index.php?package=Kolab_Server */ abstract class Horde_Kolab_Server_Query_Element_Group -implements Horde_Kolab_Server_Query_Element +implements Horde_Kolab_Server_Query_Element_Interface { /** * The group elements. diff --git a/framework/Kolab_Server/lib/Horde/Kolab/Server/Query/Element/Interface.php b/framework/Kolab_Server/lib/Horde/Kolab/Server/Query/Element/Interface.php new file mode 100644 index 000000000..0c4a256b0 --- /dev/null +++ b/framework/Kolab_Server/lib/Horde/Kolab/Server/Query/Element/Interface.php @@ -0,0 +1,59 @@ + + * @license http://www.fsf.org/copyleft/lgpl.html LGPL + * @link http://pear.horde.org/index.php?package=Kolab_Server + */ + +/** + * Interface for server query elements. + * + * Copyright 2008-2009 The Horde Project (http://www.horde.org/) + * + * See the enclosed file COPYING for license information (LGPL). If you + * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html. + * + * @category Kolab + * @package Kolab_Server + * @author Gunnar Wrobel + * @license http://www.fsf.org/copyleft/lgpl.html LGPL + * @link http://pear.horde.org/index.php?package=Kolab_Server + */ +interface Horde_Kolab_Server_Query_Element_Interface +{ + /** + * Return the query element name. + * + * @return string The name of the query element. + */ + public function getName(); + + /** + * Return the value of this element. + * + * @return mixed The query value. + */ + public function getValue(); + + /** + * Return the elements of this group. + * + * @return mixed The group elements. + */ + public function getElements(); + + /** + * Convert this element to a query element. + * + * @return mixedd The element as query. + */ + public function convert( + Horde_Kolab_Server_Query_Interface $writer + ); +} \ No newline at end of file diff --git a/framework/Kolab_Server/lib/Horde/Kolab/Server/Query/Element/Less.php b/framework/Kolab_Server/lib/Horde/Kolab/Server/Query/Element/Less.php index 00df41fb2..6c37b0567 100644 --- a/framework/Kolab_Server/lib/Horde/Kolab/Server/Query/Element/Less.php +++ b/framework/Kolab_Server/lib/Horde/Kolab/Server/Query/Element/Less.php @@ -33,8 +33,9 @@ extends Horde_Kolab_Server_Query_Element_Single * * @return mixed The element as query. */ - public function convert(Horde_Kolab_Server_Query $writer) - { + public function convert( + Horde_Kolab_Server_Query_Interface $writer + ) { return $writer->convertLess($this); } } \ No newline at end of file diff --git a/framework/Kolab_Server/lib/Horde/Kolab/Server/Query/Element/Mapped.php b/framework/Kolab_Server/lib/Horde/Kolab/Server/Query/Element/Mapped.php index 2cd6123f8..fb01c87f6 100644 --- a/framework/Kolab_Server/lib/Horde/Kolab/Server/Query/Element/Mapped.php +++ b/framework/Kolab_Server/lib/Horde/Kolab/Server/Query/Element/Mapped.php @@ -26,7 +26,7 @@ * @link http://pear.horde.org/index.php?package=Kolab_Server */ class Horde_Kolab_Server_Query_Element_Mapped -implements Horde_Kolab_Server_Query_Element +implements Horde_Kolab_Server_Query_Element_Interface { /** * Delegated element. @@ -49,8 +49,8 @@ implements Horde_Kolab_Server_Query_Element * @param Horde_Kolab_Server_Mapped $mapper The mapping handler. */ public function __construct( - Horde_Kolab_Server_Query_Element $element, - Horde_Kolab_Server_Mapped $mapper + Horde_Kolab_Server_Query_Element_Interface $element, + Horde_Kolab_Server_Decorator_Map $mapper ) { $this->_element = $element; $this->_mapper = $mapper; @@ -97,8 +97,9 @@ implements Horde_Kolab_Server_Query_Element * * @return string The query string of the element. */ - public function convert(Horde_Kolab_Server_Query $writer) - { + public function convert( + Horde_Kolab_Server_Query_Interface $writer + ) { return $this->_element->convert($writer); } } \ No newline at end of file diff --git a/framework/Kolab_Server/lib/Horde/Kolab/Server/Query/Element/Not.php b/framework/Kolab_Server/lib/Horde/Kolab/Server/Query/Element/Not.php index 2f7340de5..e5e74926e 100644 --- a/framework/Kolab_Server/lib/Horde/Kolab/Server/Query/Element/Not.php +++ b/framework/Kolab_Server/lib/Horde/Kolab/Server/Query/Element/Not.php @@ -33,7 +33,9 @@ extends Horde_Kolab_Server_Query_Element_Group * * @param array $elements The group elements. */ - public function __construct(Horde_Kolab_Server_Query_Element $element) { + public function __construct( + Horde_Kolab_Server_Query_Element_Interface $element + ) { parent::__construct(array($element)); } @@ -42,8 +44,9 @@ extends Horde_Kolab_Server_Query_Element_Group * * @return mixed The element as query. */ - public function convert(Horde_Kolab_Server_Query $writer) - { + public function convert( + Horde_Kolab_Server_Query_Interface $writer + ) { return $writer->convertNot($this); } } \ No newline at end of file diff --git a/framework/Kolab_Server/lib/Horde/Kolab/Server/Query/Element/Or.php b/framework/Kolab_Server/lib/Horde/Kolab/Server/Query/Element/Or.php index 6e89b2892..38797551b 100644 --- a/framework/Kolab_Server/lib/Horde/Kolab/Server/Query/Element/Or.php +++ b/framework/Kolab_Server/lib/Horde/Kolab/Server/Query/Element/Or.php @@ -33,8 +33,9 @@ extends Horde_Kolab_Server_Query_Element_Group * * @return mixed The element as query. */ - public function convert(Horde_Kolab_Server_Query $writer) - { + public function convert( + Horde_Kolab_Server_Query_Interface $writer + ) { return $writer->convertOr($this); } } \ No newline at end of file diff --git a/framework/Kolab_Server/lib/Horde/Kolab/Server/Query/Element/Single.php b/framework/Kolab_Server/lib/Horde/Kolab/Server/Query/Element/Single.php index 59b6cc576..ea9067583 100644 --- a/framework/Kolab_Server/lib/Horde/Kolab/Server/Query/Element/Single.php +++ b/framework/Kolab_Server/lib/Horde/Kolab/Server/Query/Element/Single.php @@ -26,7 +26,7 @@ * @link http://pear.horde.org/index.php?package=Kolab_Server */ abstract class Horde_Kolab_Server_Query_Element_Single -implements Horde_Kolab_Server_Query_Element +implements Horde_Kolab_Server_Query_Element_Interface { /** * The element name. diff --git a/framework/Kolab_Server/lib/Horde/Kolab/Server/Query/Interface.php b/framework/Kolab_Server/lib/Horde/Kolab/Server/Query/Interface.php new file mode 100644 index 000000000..b1e65e314 --- /dev/null +++ b/framework/Kolab_Server/lib/Horde/Kolab/Server/Query/Interface.php @@ -0,0 +1,126 @@ + + * @license http://www.fsf.org/copyleft/lgpl.html LGPL + * @link http://pear.horde.org/index.php?package=Kolab_Server + */ + +/** + * Interface for server queries. + * + * Copyright 2008-2009 The Horde Project (http://www.horde.org/) + * + * See the enclosed file COPYING for license information (LGPL). If you + * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html. + * + * @category Kolab + * @package Kolab_Server + * @author Gunnar Wrobel + * @license http://www.fsf.org/copyleft/lgpl.html LGPL + * @link http://pear.horde.org/index.php?package=Kolab_Server + */ +interface Horde_Kolab_Server_Query_Interface +{ + /** + * Return the query as a string. + * + * @return string The query in string format. + */ + public function __toString(); + + /** + * Convert the equals element to query format. + * + * @param Horde_Kolab_Server_Query_Element_Single $single The element to convert. + * + * @return mixed The query element in query format. + */ + public function convertEquals(Horde_Kolab_Server_Query_Element_Equals $equals); + + /** + * Convert the begins element to query format. + * + * @param Horde_Kolab_Server_Query_Element_Single $single The element to convert. + * + * @return mixed The query element in query format. + */ + public function convertBegins(Horde_Kolab_Server_Query_Element_Begins $begins); + + /** + * Convert the ends element to query format. + * + * @param Horde_Kolab_Server_Query_Element_Single $single The element to convert. + * + * @return mixed The query element in query format. + */ + public function convertEnds(Horde_Kolab_Server_Query_Element_Ends $ends); + + /** + * Convert the contains element to query format. + * + * @param Horde_Kolab_Server_Query_Element_Single $single The element to convert. + * + * @return mixed The query element in query format. + */ + public function convertContains(Horde_Kolab_Server_Query_Element_Contains $contains); + + /** + * Convert the less element to query format. + * + * @param Horde_Kolab_Server_Query_Element_Single $single The element to convert. + * + * @return mixed The query element in query format. + */ + public function convertLess(Horde_Kolab_Server_Query_Element_Less $less); + + /** + * Convert the greater element to query format. + * + * @param Horde_Kolab_Server_Query_Element_Single $single The element to convert. + * + * @return mixed The query element in query format. + */ + public function convertGreater(Horde_Kolab_Server_Query_Element_Greater $greater); + + /** + * Convert the approx element to query format. + * + * @param Horde_Kolab_Server_Query_Element_Single $single The element to convert. + * + * @return mixed The query element in query format. + */ + public function convertApprox(Horde_Kolab_Server_Query_Element_Approx $approx); + + /** + * Convert the not element to query format. + * + * @param Horde_Kolab_Server_Query_Element_Group $group The element to convert. + * + * @return mixed The query element in query format. + */ + public function convertNot(Horde_Kolab_Server_Query_Element_Not $not); + + /** + * Convert the and element to query format. + * + * @param Horde_Kolab_Server_Query_Element_Group $group The element to convert. + * + * @return mixed The query element in query format. + */ + public function convertAnd(Horde_Kolab_Server_Query_Element_And $and); + + /** + * Convert the or element to query format. + * + * @param Horde_Kolab_Server_Query_Element_Group $group The element to convert. + * + * @return mixed The query element in query format. + */ + public function convertOr(Horde_Kolab_Server_Query_Element_Group $or); +} \ No newline at end of file diff --git a/framework/Kolab_Server/lib/Horde/Kolab/Server/Query/Ldap.php b/framework/Kolab_Server/lib/Horde/Kolab/Server/Query/Ldap.php index ae24422ad..51815c37c 100644 --- a/framework/Kolab_Server/lib/Horde/Kolab/Server/Query/Ldap.php +++ b/framework/Kolab_Server/lib/Horde/Kolab/Server/Query/Ldap.php @@ -25,7 +25,8 @@ * @license http://www.fsf.org/copyleft/lgpl.html LGPL * @link http://pear.horde.org/index.php?package=Kolab_Server */ -class Horde_Kolab_Server_Query_Ldap implements Horde_Kolab_Server_Query +class Horde_Kolab_Server_Query_Ldap +implements Horde_Kolab_Server_Query_Interface { /** * The query criteria. @@ -47,7 +48,7 @@ class Horde_Kolab_Server_Query_Ldap implements Horde_Kolab_Server_Query * @param array $criteria The query criteria. */ public function __construct( - Horde_Kolab_Server_Query_Element $criteria, + Horde_Kolab_Server_Query_Element_Interface $criteria, Horde_Kolab_Server_Structure_Interface $structure ) { $this->_criteria = $criteria; @@ -185,7 +186,9 @@ class Horde_Kolab_Server_Query_Ldap implements Horde_Kolab_Server_Query $operator ) { $result = Net_LDAP2_Filter::create( - $this->_structure->getInternalAttribute($single->getName()), + $this->_structure->mapExternalToInternalAttribute( + $single->getName() + ), $operator, $single->getValue() ); diff --git a/framework/Kolab_Server/lib/Horde/Kolab/Server/Result.php b/framework/Kolab_Server/lib/Horde/Kolab/Server/Result.php deleted file mode 100644 index bf365fdce..000000000 --- a/framework/Kolab_Server/lib/Horde/Kolab/Server/Result.php +++ /dev/null @@ -1,50 +0,0 @@ - - * @license http://www.fsf.org/copyleft/lgpl.html LGPL - * @link http://pear.horde.org/index.php?package=Kolab_Server - */ - -/** - * Interface for query results. - * - * Copyright 2008-2009 The Horde Project (http://www.horde.org/) - * - * See the enclosed file COPYING for license information (LGPL). If you - * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html. - * - * @category Kolab - * @package Kolab_Server - * @author Gunnar Wrobel - * @license http://www.fsf.org/copyleft/lgpl.html LGPL - * @link http://pear.horde.org/index.php?package=Kolab_Server - */ -interface Horde_Kolab_Server_Result -{ - /** - * The number of result entries. - * - * @return int The number of elements. - */ - public function count(); - - /** - * Test if the last search exceeded the size limit. - * - * @return boolean True if the last search exceeded the size limit. - */ - public function sizeLimitExceeded(); - - /** - * Return the result as an array. - * - * @return array The resulting array. - */ - public function asArray(); -} \ No newline at end of file diff --git a/framework/Kolab_Server/lib/Horde/Kolab/Server/Result/Interface.php b/framework/Kolab_Server/lib/Horde/Kolab/Server/Result/Interface.php new file mode 100644 index 000000000..cfb28b88a --- /dev/null +++ b/framework/Kolab_Server/lib/Horde/Kolab/Server/Result/Interface.php @@ -0,0 +1,50 @@ + + * @license http://www.fsf.org/copyleft/lgpl.html LGPL + * @link http://pear.horde.org/index.php?package=Kolab_Server + */ + +/** + * Interface for query results. + * + * Copyright 2008-2009 The Horde Project (http://www.horde.org/) + * + * See the enclosed file COPYING for license information (LGPL). If you + * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html. + * + * @category Kolab + * @package Kolab_Server + * @author Gunnar Wrobel + * @license http://www.fsf.org/copyleft/lgpl.html LGPL + * @link http://pear.horde.org/index.php?package=Kolab_Server + */ +interface Horde_Kolab_Server_Result_Interface +{ + /** + * The number of result entries. + * + * @return int The number of elements. + */ + public function count(); + + /** + * Test if the last search exceeded the size limit. + * + * @return boolean True if the last search exceeded the size limit. + */ + public function sizeLimitExceeded(); + + /** + * Return the result as an array. + * + * @return array The resulting array. + */ + public function asArray(); +} \ No newline at end of file diff --git a/framework/Kolab_Server/lib/Horde/Kolab/Server/Result/Ldap.php b/framework/Kolab_Server/lib/Horde/Kolab/Server/Result/Ldap.php index 7494569bd..ecab1351b 100644 --- a/framework/Kolab_Server/lib/Horde/Kolab/Server/Result/Ldap.php +++ b/framework/Kolab_Server/lib/Horde/Kolab/Server/Result/Ldap.php @@ -25,7 +25,8 @@ * @license http://www.fsf.org/copyleft/lgpl.html LGPL * @link http://pear.horde.org/index.php?package=Kolab_Server */ -class Horde_Kolab_Server_Result_Ldap implements Horde_Kolab_Server_Result +class Horde_Kolab_Server_Result_Ldap +implements Horde_Kolab_Server_Result_Interface { /** * The search result. diff --git a/framework/Kolab_Server/lib/Horde/Kolab/Server/Schema.php b/framework/Kolab_Server/lib/Horde/Kolab/Server/Schema.php deleted file mode 100644 index 0d2dda9d0..000000000 --- a/framework/Kolab_Server/lib/Horde/Kolab/Server/Schema.php +++ /dev/null @@ -1,83 +0,0 @@ - - * @license http://www.fsf.org/copyleft/lgpl.html LGPL - * @link http://pear.horde.org/index.php?package=Kolab_Server - */ - -/** - * Interface for the structural handler of a Kolab database. - * - * Copyright 2008-2009 The Horde Project (http://www.horde.org/) - * - * See the enclosed file COPYING for license information (LGPL). If you - * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html. - * - * @category Kolab - * @package Kolab_Server - * @author Gunnar Wrobel - * @license http://www.fsf.org/copyleft/lgpl.html LGPL - * @link http://pear.horde.org/index.php?package=Kolab_Server - */ -interface Horde_Kolab_Server_Schema -{ - /** - * Set the composite server reference for this object. - * - * @param Horde_Kolab_Server_Composite $composite A link to the composite - * server handler. - */ - public function setComposite(Horde_Kolab_Server_Composite $composite); - - /** - * Return the schema for the given objectClass. - * - * @param string $objectclass Fetch the schema for this objectClass. - * - * @return array The schema for the given objectClass. - * - * @throws Horde_Kolab_Server_Exception If retrieval of the schema failed. - */ - public function getObjectclassSchema($objectclass); - - /** - * Return the schema for the given attribute. - * - * @param string $attribute Fetch the schema for this attribute. - * - * @return array The schema for the given attribute. - * - * @throws Horde_Kolab_Server_Exception If retrieval of the schema failed. - */ - public function getAttributeSchema($attribute); - - /** - * Return the external attributes supported by the given object class. - * - * @param Horde_Kolab_Server_Object $object Determine the external - * attributes for this class. - * - * @return array The supported attributes. - * - * @throws Horde_Kolab_Server_Exception If the schema analysis fails. - */ - public function getExternalAttributes($object); - - /** - * Return the internal attributes supported by the given object class. - * - * @param Horde_Kolab_Server_Object $object Determine the internal - * attributes for this class. - * - * @return array The supported attributes. - * - * @throws Horde_Kolab_Server_Exception If the schema analysis fails. - */ - public function getInternalAttributes($object); -} \ No newline at end of file diff --git a/framework/Kolab_Server/lib/Horde/Kolab/Server/Schema/Base.php b/framework/Kolab_Server/lib/Horde/Kolab/Server/Schema/Base.php index 4193e93c9..5ac063d80 100644 --- a/framework/Kolab_Server/lib/Horde/Kolab/Server/Schema/Base.php +++ b/framework/Kolab_Server/lib/Horde/Kolab/Server/Schema/Base.php @@ -1,6 +1,6 @@ composite = $composite; } diff --git a/framework/Kolab_Server/lib/Horde/Kolab/Server/Schema/Decorator/Cache.php b/framework/Kolab_Server/lib/Horde/Kolab/Server/Schema/Decorator/Cache.php new file mode 100644 index 000000000..ef2bfc6b7 --- /dev/null +++ b/framework/Kolab_Server/lib/Horde/Kolab/Server/Schema/Decorator/Cache.php @@ -0,0 +1,280 @@ + + * @license http://www.fsf.org/copyleft/lgpl.html LGPL + * @link http://pear.horde.org/index.php?package=Kolab_Server + */ + +/** + * This class handles the db schema. + * + * Copyright 2008-2009 The Horde Project (http://www.horde.org/) + * + * See the enclosed file COPYING for license information (LGPL). If you + * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html. + * + * @category Kolab + * @package Kolab_Server + * @author Gunnar Wrobel + * @license http://www.fsf.org/copyleft/lgpl.html LGPL + * @link http://pear.horde.org/index.php?package=Kolab_Server + */ +class Horde_Kolab_Server_Schema_Base +implements Horde_Kolab_Server_Schema_Interface +{ + /** Maximum accepted level for the object class hierarchy */ + const MAX_HIERARCHY = 100; + + /** + * A cache for object attribute definitions. + * + * @var array + */ + protected $attributes; + + /** + * A link to the composite server handler. + * + * @var Horde_Kolab_Server_Composite + */ + protected $composite; + + /** + * Set the composite server reference for this object. + * + * @param Horde_Kolab_Server_Composite $composite A link to the composite + * server handler. + * + * @return NULL + */ + public function setComposite(Horde_Kolab_Server_Composite $composite) + { + $this->composite = $composite; + } + + /** + * Return the schema for the given objectClass. + * + * @param string $objectclass Fetch the schema for this objectClass. + * + * @return array The schema for the given objectClass. + * + * @throws Horde_Kolab_Server_Exception If retrieval of the schema failed. + */ + public function getObjectclassSchema($objectclass) + { + if (!empty($this->_config['schema_support'])) { + $schema = $this->_getSchema(); + $info = $schema->get('objectclass', $objectclass); + $this->_handleError($info, Horde_Kolab_Server_Exception::SYSTEM); + return $info; + } + return parent::getObjectclassSchema($objectclass); + } + + /** + * Return the schema for the given attribute. + * + * @param string $attribute Fetch the schema for this attribute. + * + * @return array The schema for the given attribute. + * + * @throws Horde_Kolab_Server_Exception If retrieval of the schema failed. + */ + public function getAttributeSchema($attribute) + { + if (!empty($this->_config['schema_support'])) { + $schema = $this->_getSchema(); + $info = $schema->get('attribute', $attribute); + $this->_handleError($info, Horde_Kolab_Server_Exception::SYSTEM); + return $info; + } + return parent::getAttributeSchema($attribute); + } + + /** + * Return the attributes supported by the given object class. + * + * @param string $class Determine the attributes for this class. + * + * @return array The supported attributes. + * + * @throws Horde_Kolab_Server_Exception If the schema analysis fails. + */ + public function getExternalAttributes($class) + { + if (!isset($this->attributes)) { + if (isset($this->cache)) { + register_shutdown_function(array($this, 'shutdown')); + } + } + if (empty($this->attributes[$class])) { + + if (isset($this->cache)) { + $this->attributes[$class] = @unserialize($cache->get('attributes_' . $class, + $this->params['cache_lifetime'])); + } + + if (empty($this->attributes[$class])) { + + $childclass = $class; + $classes = array(); + $level = 0; + while ($childclass != 'Horde_Kolab_Server_Object' + && $level < self::MAX_HIERARCHY) { + $classes[] = $childclass; + $childclass = get_parent_class($childclass); + $level++; + } + + /** Finally add the basic object class */ + $classes[] = $childclass; + + if ($level == self::MAX_HIERARCHY) { + if (isset($this->logger)) { + $logger->err(sprintf('The maximal level of the object hierarchy has been exceeded for class \"%s\"!', + $class)); + } + } + + /** + * Collect attributes from bottom to top. + */ + $classes = array_reverse($classes); + + $types = array('defined', 'required', 'derived', 'collapsed', + 'defaults', 'locked', 'object_classes'); + foreach ($types as $type) { + $$type = array(); + } + + foreach ($classes as $childclass) { + $vars = get_class_vars($childclass); + if (isset($vars['init_attributes'])) { + foreach ($types as $type) { + /** + * If the user wishes to adhere to the schema + * information from the server we will skip the + * attributes defined within the object class here. + */ + if (!empty($this->params['schema_override']) + && in_array($type, 'defined', 'required')) { + continue; + } + if (isset($vars['init_attributes'][$type])) { + $$type = array_merge($$type, + $vars['init_attributes'][$type]); + } + } + } + } + + $attrs = array(); + + foreach ($object_classes as $object_class) { + $info = $this->getObjectclassSchema($object_class); + if (isset($info['may'])) { + $defined = array_merge($defined, $info['may']); + } + if (isset($info['must'])) { + $defined = array_merge($defined, $info['must']); + $required = array_merge($required, $info['must']); + } + foreach ($defined as $attribute) { + try { + $attrs[$attribute] = $this->getAttributeSchema($attribute); + } catch (Horde_Kolab_Server_Exception $e) { + /** + * If the server considers the attribute to be + * invalid we mark it. + */ + $attrs[$attribute] = array('invalid' => true); + } + } + foreach ($required as $attribute) { + $attrs[$attribute]['required'] = true; + } + foreach ($locked as $attribute) { + $attrs[$attribute]['locked'] = true; + } + foreach ($defaults as $attribute => $default) { + $attrs[$attribute]['default'] = $default; + } + $attrs[Horde_Kolab_Server_Object::ATTRIBUTE_OC]['default'] = $object_classes; + } + foreach ($derived as $key => $attributes) { + $supported = true; + if (isset($attributes['base'])) { + foreach ($attributes['base'] as $attribute) { + /** + * Usually derived attribute are determined on basis + * of one or more attributes. If any of these is not + * supported the derived attribute should not be + * included into the set of supported attributes. + */ + if (!isset($attrs[$attribute])) { + unset($derived[$attribute]); + $supported = false; + break; + } + } + } + if ($supported) { + $attrs[$key] = $attributes; + } + } + $check_collapsed = $collapsed; + foreach ($check_collapsed as $key => $attributes) { + if (isset($attributes['base'])) { + foreach ($attributes['base'] as $attribute) { + /** + * Usually collapsed attribute are determined on basis + * of one or more attributes. If any of these is not + * supported the collapsed attribute should not be + * included into the set of supported attributes. + */ + if (!isset($attrs[$attribute])) { + unset($collapsed[$attribute]); + } + } + } + } + $this->attributes[$class] = array($attrs, + array( + 'derived' => array_keys($derived), + 'collapsed' => $collapsed, + 'locked' => $locked, + 'required' => $required)); + } + } + return $this->attributes[$class]; + } + + public function getInternalAttributes($class) + { + } + + /** + * Stores the attribute definitions in the cache. + * + * @return Horde_Kolab_Server The concrete Horde_Kolab_Server reference. + */ + public function shutdown() + { + if (isset($this->attributes)) { + if (isset($this->cache)) { + foreach ($this->attributes as $key => $value) { + $this->cache->set('attributes_' . $key, @serialize($value)); + } + } + } + } + + +} \ No newline at end of file diff --git a/framework/Kolab_Server/lib/Horde/Kolab/Server/Schema/Interface.php b/framework/Kolab_Server/lib/Horde/Kolab/Server/Schema/Interface.php new file mode 100644 index 000000000..23b26a78f --- /dev/null +++ b/framework/Kolab_Server/lib/Horde/Kolab/Server/Schema/Interface.php @@ -0,0 +1,85 @@ + + * @license http://www.fsf.org/copyleft/lgpl.html LGPL + * @link http://pear.horde.org/index.php?package=Kolab_Server + */ + +/** + * Interface for the schema handler of a Kolab database. + * + * Copyright 2008-2009 The Horde Project (http://www.horde.org/) + * + * See the enclosed file COPYING for license information (LGPL). If you + * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html. + * + * @category Kolab + * @package Kolab_Server + * @author Gunnar Wrobel + * @license http://www.fsf.org/copyleft/lgpl.html LGPL + * @link http://pear.horde.org/index.php?package=Kolab_Server + */ +interface Horde_Kolab_Server_Schema_Interface +{ + /** + * Set the composite server reference for this object. + * + * @param Horde_Kolab_Server_Composite $composite A link to the composite + * server handler. + */ + public function setComposite( + Horde_Kolab_Server_Composite_Interface $composite + ); + + /** + * Return the schema for the given objectClass. + * + * @param string $objectclass Fetch the schema for this objectClass. + * + * @return array The schema for the given objectClass. + * + * @throws Horde_Kolab_Server_Exception If retrieval of the schema failed. + */ + public function getObjectclassSchema($objectclass); + + /** + * Return the schema for the given attribute. + * + * @param string $attribute Fetch the schema for this attribute. + * + * @return array The schema for the given attribute. + * + * @throws Horde_Kolab_Server_Exception If retrieval of the schema failed. + */ + public function getAttributeSchema($attribute); + + /** + * Return the external attributes supported by the given object class. + * + * @param Horde_Kolab_Server_Object $object Determine the external + * attributes for this class. + * + * @return array The supported attributes. + * + * @throws Horde_Kolab_Server_Exception If the schema analysis fails. + */ + public function getExternalAttributes($object); + + /** + * Return the internal attributes supported by the given object class. + * + * @param Horde_Kolab_Server_Object $object Determine the internal + * attributes for this class. + * + * @return array The supported attributes. + * + * @throws Horde_Kolab_Server_Exception If the schema analysis fails. + */ + public function getInternalAttributes($object); +} \ No newline at end of file diff --git a/framework/Kolab_Server/lib/Horde/Kolab/Server/Search/Base.php b/framework/Kolab_Server/lib/Horde/Kolab/Server/Search/Base.php index 0f3042a22..40b94c96f 100644 --- a/framework/Kolab_Server/lib/Horde/Kolab/Server/Search/Base.php +++ b/framework/Kolab_Server/lib/Horde/Kolab/Server/Search/Base.php @@ -52,8 +52,9 @@ implements Horde_Kolab_Server_Search_Interface * * @return NULL */ - public function setComposite(Horde_Kolab_Server_Composite $composite) - { + public function setComposite( + Horde_Kolab_Server_Composite_Interface $composite + ) { $this->_composite = $composite; $this->_searches = $this->_getSearchOperations(); } diff --git a/framework/Kolab_Server/lib/Horde/Kolab/Server/Search/Interface.php b/framework/Kolab_Server/lib/Horde/Kolab/Server/Search/Interface.php index 740b49462..281c0ef7e 100644 --- a/framework/Kolab_Server/lib/Horde/Kolab/Server/Search/Interface.php +++ b/framework/Kolab_Server/lib/Horde/Kolab/Server/Search/Interface.php @@ -33,7 +33,9 @@ interface Horde_Kolab_Server_Search_Interface * @param Horde_Kolab_Server_Composite $composite A link to the composite * server handler. */ - public function setComposite(Horde_Kolab_Server_Composite $composite); + public function setComposite( + Horde_Kolab_Server_Composite_Interface $composite + ); /** * Returns the set of search operations supported by this server type. diff --git a/framework/Kolab_Server/lib/Horde/Kolab/Server/Search/Operation/Base.php b/framework/Kolab_Server/lib/Horde/Kolab/Server/Search/Operation/Base.php index 17df4fbb7..7f4b44fe0 100644 --- a/framework/Kolab_Server/lib/Horde/Kolab/Server/Search/Operation/Base.php +++ b/framework/Kolab_Server/lib/Horde/Kolab/Server/Search/Operation/Base.php @@ -65,8 +65,9 @@ implements Horde_Kolab_Server_Search_Operation_Interface * * @return boolean|array The GUID(s) or false if there was no result. */ - protected function guidFromResult(Horde_Kolab_Server_Result $result) - { + protected function guidFromResult( + Horde_Kolab_Server_Result_Interface $result + ) { return array_keys($result->asArray()); } } \ No newline at end of file diff --git a/framework/Kolab_Server/lib/Horde/Kolab/Server/Search/Operation/Groupsformember.php b/framework/Kolab_Server/lib/Horde/Kolab/Server/Search/Operation/Groupsformember.php new file mode 100644 index 000000000..ff27eefc4 --- /dev/null +++ b/framework/Kolab_Server/lib/Horde/Kolab/Server/Search/Operation/Groupsformember.php @@ -0,0 +1,47 @@ + + * @license http://www.fsf.org/copyleft/lgpl.html LGPL + * @link http://pear.horde.org/index.php?package=Kolab_Server + */ + +/** + * Return the groups for the given member element. + * + * Copyright 2008-2009 The Horde Project (http://www.horde.org/) + * + * See the enclosed file COPYING for license information (LGPL). If you + * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html. + * + * @category Kolab + * @package Kolab_Server + * @author Gunnar Wrobel + * @license http://www.fsf.org/copyleft/lgpl.html LGPL + * @link http://pear.horde.org/index.php?package=Kolab_Server + */ +class Horde_Kolab_Server_Search_Operation_Groupsformember +extends Horde_Kolab_Server_Search_Operation_Restrictgroups +{ + /** + * Return the groups for the given member element. + * + * @param string $guid The guid of the member. + * + * @return array The group GUID(s). + * + * @throws Horde_Kolab_Server_Exception + */ + public function searchGroupsForMember($guid) + { + $criteria = new Horde_Kolab_Server_Query_Element_Equals( + 'member', $guid + ); + return parent::searchRestrictGroups($criteria); + } +} \ No newline at end of file diff --git a/framework/Kolab_Server/lib/Horde/Kolab/Server/Search/Operation/Guid.php b/framework/Kolab_Server/lib/Horde/Kolab/Server/Search/Operation/Guid.php index d0049bc0c..ffc646694 100644 --- a/framework/Kolab_Server/lib/Horde/Kolab/Server/Search/Operation/Guid.php +++ b/framework/Kolab_Server/lib/Horde/Kolab/Server/Search/Operation/Guid.php @@ -35,8 +35,9 @@ extends Horde_Kolab_Server_Search_Operation_Base * * @return array The search result. */ - public function searchGuid(Horde_Kolab_Server_Query_Element $criteria) - { + public function searchGuid( + Horde_Kolab_Server_Query_Element_Interface $criteria + ) { $params = array( 'attributes' => 'Guid' ); diff --git a/framework/Kolab_Server/lib/Horde/Kolab/Server/Search/Operation/Restrictgroups.php b/framework/Kolab_Server/lib/Horde/Kolab/Server/Search/Operation/Restrictgroups.php new file mode 100644 index 000000000..942727aad --- /dev/null +++ b/framework/Kolab_Server/lib/Horde/Kolab/Server/Search/Operation/Restrictgroups.php @@ -0,0 +1,54 @@ + + * @license http://www.fsf.org/copyleft/lgpl.html LGPL + * @link http://pear.horde.org/index.php?package=Kolab_Server + */ + +/** + * Restrict a search to groupOfNames. + * + * Copyright 2008-2009 The Horde Project (http://www.horde.org/) + * + * See the enclosed file COPYING for license information (LGPL). If you + * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html. + * + * @category Kolab + * @package Kolab_Server + * @author Gunnar Wrobel + * @license http://www.fsf.org/copyleft/lgpl.html LGPL + * @link http://pear.horde.org/index.php?package=Kolab_Server + */ +class Horde_Kolab_Server_Search_Operation_Restrictgroups +extends Horde_Kolab_Server_Search_Operation_Guid +{ + /** + * Restrict a search to groupOfNames. + * + * @param Horde_Kolab_Server_Query_Element $criteria The search criteria. + * + * @return array The GUID(s). + * + * @throws Horde_Kolab_Server_Exception + */ + public function searchRestrictGroups( + Horde_Kolab_Server_Query_Element $criteria + ) { + $criteria = new Horde_Kolab_Server_Query_Element_And( + array( + new Horde_Kolab_Server_Query_Element_Equals( + 'Objectclass', + Horde_Kolab_Server_Object_Groupofnames::OBJECTCLASS_GROUPOFNAMES + ), + $criteria + ) + ); + return parent::searchGuid($criteria); + } +} \ No newline at end of file diff --git a/framework/Kolab_Server/lib/Horde/Kolab/Server/Structure/Base.php b/framework/Kolab_Server/lib/Horde/Kolab/Server/Structure/Base.php index a851db8ec..565b4a6a6 100644 --- a/framework/Kolab_Server/lib/Horde/Kolab/Server/Structure/Base.php +++ b/framework/Kolab_Server/lib/Horde/Kolab/Server/Structure/Base.php @@ -46,7 +46,7 @@ implements Horde_Kolab_Server_Structure_Interface * @throws Horde_Kolab_Server_Exception */ public function find( - Horde_Kolab_Server_Query_Element $criteria, + Horde_Kolab_Server_Query_Element_Interface $criteria, array $params = array() ) { $query = new Horde_Kolab_Server_Query_Ldap($criteria, $this); @@ -67,7 +67,7 @@ implements Horde_Kolab_Server_Structure_Interface * @throws Horde_Kolab_Server_Exception */ public function findBelow( - Horde_Kolab_Server_Query_Element $criteria, + Horde_Kolab_Server_Query_Element_Interface $criteria, $parent, array $params = array() ) { @@ -85,8 +85,9 @@ implements Horde_Kolab_Server_Structure_Interface * * @return NULL */ - public function setComposite(Horde_Kolab_Server_Composite $composite) - { + public function setComposite( + Horde_Kolab_Server_Composite_Interface $composite + ) { $this->_composite = $composite; } diff --git a/framework/Kolab_Server/lib/Horde/Kolab/Server/Structure/Interface.php b/framework/Kolab_Server/lib/Horde/Kolab/Server/Structure/Interface.php index 01f2d12e9..a6a2ebc11 100644 --- a/framework/Kolab_Server/lib/Horde/Kolab/Server/Structure/Interface.php +++ b/framework/Kolab_Server/lib/Horde/Kolab/Server/Structure/Interface.php @@ -39,7 +39,7 @@ interface Horde_Kolab_Server_Structure_Interface * @throws Horde_Kolab_Server_Exception */ public function find( - Horde_Kolab_Server_Query_Element $criteria, + Horde_Kolab_Server_Query_Element_Interface $criteria, array $params = array() ); @@ -55,7 +55,7 @@ interface Horde_Kolab_Server_Structure_Interface * @throws Horde_Kolab_Server_Exception */ public function findBelow( - Horde_Kolab_Server_Query_Element $criteria, + Horde_Kolab_Server_Query_Element_Interface $criteria, $parent, array $params = array() ); @@ -68,7 +68,9 @@ interface Horde_Kolab_Server_Structure_Interface * * @return NULL */ - public function setComposite(Horde_Kolab_Server_Composite $composite); + public function setComposite( + Horde_Kolab_Server_Composite_Interface $composite + ); /** * Returns the set of objects supported by this structure. @@ -91,7 +93,7 @@ interface Horde_Kolab_Server_Structure_Interface * * @return string The internal attribute name. */ - public function getInternalAttribute($external); + public function mapExternalToInternalAttribute($external); /** * Determine the type of an object by its tree position and other diff --git a/framework/Kolab_Server/lib/Horde/Kolab/Server/Structure/Kolab.php b/framework/Kolab_Server/lib/Horde/Kolab/Server/Structure/Kolab.php index 819a9b970..e763b354d 100644 --- a/framework/Kolab_Server/lib/Horde/Kolab/Server/Structure/Kolab.php +++ b/framework/Kolab_Server/lib/Horde/Kolab/Server/Structure/Kolab.php @@ -77,6 +77,7 @@ class Horde_Kolab_Server_Structure_Kolab extends Horde_Kolab_Server_Structure_Ld 'Horde_Kolab_Server_Search_Operation_Guidforuidormailoralias', 'Horde_Kolab_Server_Search_Operation_Mailforuidormail', 'Horde_Kolab_Server_Search_Operation_Addressesforuidormail', + 'Horde_Kolab_Server_Search_Operation_Groupsformember', ); return $searches; } @@ -111,7 +112,7 @@ class Horde_Kolab_Server_Structure_Kolab extends Horde_Kolab_Server_Structure_Ld return parent::_determineType($guid, $ocs); } - $groups = $this->getComposite()->search->getGroups($guid); + $groups = $this->getComposite()->search->searchGroupsForMember($guid); if (!empty($groups)) { $base = $this->getComposite()->server->getBaseGuid(); if (in_array('cn=admin,cn=internal,' . $base, $groups)) { diff --git a/framework/Kolab_Server/lib/Horde/Kolab/Server/Structure/Ldap.php b/framework/Kolab_Server/lib/Horde/Kolab/Server/Structure/Ldap.php index 64f0f028d..bf047c2a6 100644 --- a/framework/Kolab_Server/lib/Horde/Kolab/Server/Structure/Ldap.php +++ b/framework/Kolab_Server/lib/Horde/Kolab/Server/Structure/Ldap.php @@ -154,7 +154,7 @@ class Horde_Kolab_Server_Structure_Ldap extends Horde_Kolab_Server_Structure_Bas * * @return string The internal attribute name. */ - public function getInternalAttribute($external) + public function mapExternalToInternalAttribute($external) { switch ($external) { case 'Objectclass': diff --git a/framework/Kolab_Server/package.xml b/framework/Kolab_Server/package.xml index 898267f92..89d8a1084 100644 --- a/framework/Kolab_Server/package.xml +++ b/framework/Kolab_Server/package.xml @@ -59,13 +59,14 @@ http://pear.php.net/dtd/package-2.0.xsd"> - - - - + + + + + @@ -74,41 +75,47 @@ http://pear.php.net/dtd/package-2.0.xsd"> + + + + + + - - - - + + - + + + + + + + + - - + - - - - @@ -118,6 +125,7 @@ http://pear.php.net/dtd/package-2.0.xsd"> + @@ -132,6 +140,7 @@ http://pear.php.net/dtd/package-2.0.xsd"> + @@ -152,13 +161,11 @@ http://pear.php.net/dtd/package-2.0.xsd"> - + - - @@ -168,21 +175,23 @@ http://pear.php.net/dtd/package-2.0.xsd"> + + - + - + @@ -196,6 +205,7 @@ http://pear.php.net/dtd/package-2.0.xsd"> + @@ -207,6 +217,7 @@ http://pear.php.net/dtd/package-2.0.xsd"> + @@ -236,12 +247,12 @@ http://pear.php.net/dtd/package-2.0.xsd"> - + - + @@ -332,42 +343,43 @@ http://pear.php.net/dtd/package-2.0.xsd"> - - - - + + + + + + + - - - - - - - - + + + + + + + + + + + - - + - - - - @@ -375,6 +387,7 @@ http://pear.php.net/dtd/package-2.0.xsd"> + @@ -389,6 +402,7 @@ http://pear.php.net/dtd/package-2.0.xsd"> + @@ -406,10 +420,8 @@ http://pear.php.net/dtd/package-2.0.xsd"> - - - + @@ -418,16 +430,18 @@ http://pear.php.net/dtd/package-2.0.xsd"> + - + - + + @@ -436,6 +450,7 @@ http://pear.php.net/dtd/package-2.0.xsd"> + @@ -447,6 +462,7 @@ http://pear.php.net/dtd/package-2.0.xsd"> + @@ -461,10 +477,10 @@ http://pear.php.net/dtd/package-2.0.xsd"> - - - - + + + + diff --git a/framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/CleanerTest.php b/framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/CleanerTest.php deleted file mode 100644 index cf72621d2..000000000 --- a/framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/CleanerTest.php +++ /dev/null @@ -1,210 +0,0 @@ - - * @license http://www.fsf.org/copyleft/lgpl.html LGPL - * @link http://pear.horde.org/index.php?package=Kolab_Server - */ - -/** - * Prepare the test setup. - */ -require_once dirname(__FILE__) . '/../../Autoload.php'; - -/** - * Test the cleanup decorator for the server. - * - * Copyright 2009 The Horde Project (http://www.horde.org/) - * - * See the enclosed file COPYING for license information (LGPL). If you - * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html. - * - * @category Kolab - * @package Kolab_Server - * @author Gunnar Wrobel - * @license http://www.fsf.org/copyleft/lgpl.html LGPL - * @link http://pear.horde.org/index.php?package=Kolab_Server - */ -class Horde_Kolab_Server_Class_Server_CleanerTest extends PHPUnit_Framework_TestCase -{ - public function setUp() - { - parent::setUp(); - - $this->server = $this->getMock('Horde_Kolab_Server'); - $this->cleaner = new Horde_Kolab_Server_Cleaner($this->server); - } - - public function testMethodGetbaseguidHasPostconditionThatTheCallWasDelegatedToTheServer() - { - $this->server->expects($this->exactly(1)) - ->method('getBaseGuid') - ->will($this->returnValue('base')); - $this->assertEquals('base', $this->cleaner->getBaseGuid()); - } - - public function testMethodGetuidHasPostconditionThatTheCallWasDelegatedToTheServer() - { - $this->server->expects($this->exactly(1)) - ->method('getGuid') - ->will($this->returnValue('guid')); - $this->assertEquals('guid', $this->cleaner->getGuid()); - } - - public function testMethodConnectguidHasPostconditionThatTheCallWasDelegatedToTheServer() - { - $this->server->expects($this->exactly(1)) - ->method('connectGuid') - ->with('user', 'pass'); - $this->cleaner->connectGuid('user', 'pass'); - } - - public function testMethodReadHasPostconditionThatTheCallWasDelegatedToTheServer() - { - $this->server->expects($this->exactly(1)) - ->method('read') - ->with('guid') - ->will($this->returnValue(array())); - $this->assertEquals(array(), $this->cleaner->read('guid')); - } - - public function testMethodReadattributesHasPostconditionThatTheCallWasDelegatedToTheServer() - { - $this->server->expects($this->exactly(1)) - ->method('readAttributes') - ->with('guid', array('a')) - ->will($this->returnValue(array())); - $this->assertEquals( - array(), $this->cleaner->readAttributes('guid', array('a')) - ); - } - - public function testMethodFindHasPostconditionThatTheCallWasDelegatedToTheServer() - { - $result = $this->getMock('Horde_Kolab_Server_Result'); - $query = $this->getMock( - 'Horde_Kolab_Server_Query_Element', array(), array(), '', false - ); - $this->server->expects($this->exactly(1)) - ->method('find') - ->with($query) - ->will($this->returnValue($result)); - $this->assertType( - 'Horde_Kolab_Server_Result', - $this->cleaner->find($query) - ); - } - - public function testMethodFindbelowHasPostconditionThatTheCallWasDelegatedToTheServer() - { - $result = $this->getMock('Horde_Kolab_Server_Result'); - $query = $this->getMock( - 'Horde_Kolab_Server_Query_Element', array(), array(), '', false - ); - $this->server->expects($this->exactly(1)) - ->method('findBelow') - ->with($query, 'none') - ->will($this->returnValue($result)); - $this->assertType( - 'Horde_Kolab_Server_Result', - $this->cleaner->findBelow($query, 'none') - ); - } - - public function testMethodSaveHasPostconditionThatTheCallWasDelegatedToTheServer() - { - $object = $this->getMock( - 'Horde_Kolab_Server_Object', array(), array(), '', false - ); - $this->server->expects($this->exactly(1)) - ->method('save') - ->with($object, array('a' => 'a')); - $this->cleaner->save($object, array('a' => 'a')); - } - - public function testMethodAddHasPostconditionThatTheCallWasDelegatedToTheServer() - { - $object = $this->getMock( - 'Horde_Kolab_Server_Object', array(), array(), '', false - ); - $this->server->expects($this->exactly(1)) - ->method('add') - ->with($object, array('a' => 'a')); - $this->cleaner->add($object, array('a' => 'a')); - } - - public function testMethodDeleteHasPostconditionThatTheCallWasDelegatedToTheServer() - { - $this->server->expects($this->exactly(1)) - ->method('delete') - ->with('a'); - $this->cleaner->delete('a'); - } - - public function testMethodRenameHasPostconditionThatTheCallWasDelegatedToTheServer() - { - $this->server->expects($this->exactly(1)) - ->method('rename') - ->with('a', 'b'); - $this->cleaner->rename('a', 'b'); - } - - public function testMethodGetschemaHasPostconditionThatTheCallWasDelegatedToTheServer() - { - $this->server->expects($this->exactly(1)) - ->method('getSchema'); - $this->cleaner->getSchema(); - } - - public function testMethodGetparentguidHasPostconditionThatTheCallWasDelegatedToTheServer() - { - $this->server->expects($this->exactly(1)) - ->method('getParentGuid') - ->will($this->returnValue('parent')); - $this->assertEquals('parent', $this->cleaner->getParentGuid('child')); - } - - public function testMethodAddHasPostconditionThatTheGuidOfTheAddedObjectIsRememberedAndDeletedOnDestruction() - { - $object = $this->getMock( - 'Horde_Kolab_Server_Object', array(), array(), '', false - ); - $object->expects($this->exactly(1)) - ->method('getGuid') - ->will($this->returnValue('a')); - $this->server->expects($this->exactly(1)) - ->method('add') - ->with($object, array('a' => 'a')); - $this->server->expects($this->exactly(1)) - ->method('delete') - ->with('a'); - $this->cleaner->add($object, array('a' => 'a')); - unset($this->cleaner); - } - - public function testMethodAddHasPostconditionThatTheGuidOfTheAddedObjectIsNotDeletedOnDestructionIfItWasDeletedBefore() - { - $object = $this->getMock( - 'Horde_Kolab_Server_Object', array(), array(), '', false - ); - $object->expects($this->exactly(1)) - ->method('getGuid') - ->will($this->returnValue('a')); - $this->server->expects($this->exactly(1)) - ->method('add') - ->with($object, array('a' => 'a')); - $this->server->expects($this->exactly(1)) - ->method('delete') - ->with('a'); - $this->cleaner->add($object, array('a' => 'a')); - $this->cleaner->delete('a'); - unset($this->cleaner); - } - - -} \ No newline at end of file diff --git a/framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/Composite/BaseTest.php b/framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/Composite/BaseTest.php new file mode 100644 index 000000000..74a6088ff --- /dev/null +++ b/framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/Composite/BaseTest.php @@ -0,0 +1,63 @@ + + * @license http://www.fsf.org/copyleft/lgpl.html LGPL + * @link http://pear.horde.org/index.php?package=Kolab_Server + */ + +/** + * Prepare the test setup. + */ +require_once dirname(__FILE__) . '/../../../TestCase.php'; + +/** + * Test the composite server. + * + * Copyright 2009 The Horde Project (http://www.horde.org/) + * + * See the enclosed file COPYING for license information (LGPL). If you + * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html. + * + * @category Kolab + * @package Kolab_Server + * @author Gunnar Wrobel + * @license http://www.fsf.org/copyleft/lgpl.html LGPL + * @link http://pear.horde.org/index.php?package=Kolab_Server + */ +class Horde_Kolab_Server_Class_Server_Composite_BaseTest extends Horde_Kolab_Server_TestCase +{ + public function testMethodGetReturnsServerElement() + { + $composite = $this->getMockedComposite(); + $this->assertType('Horde_Kolab_Server_Interface', $composite->server); + $this->assertType('Horde_Kolab_Server_Objects_Interface', $composite->objects); + $this->assertType('Horde_Kolab_Server_Structure_Interface', $composite->structure); + $this->assertType('Horde_Kolab_Server_Search_Interface', $composite->search); + $this->assertType('Horde_Kolab_Server_Schema_Interface', $composite->schema); + try { + $a = $composite->something; + $this->fail('No exception!'); + } catch (Horde_Kolab_Server_Exception $e) { + $this->assertEquals( + 'Attribute something not supported!', $e->getMessage() + ); + } + } + + public function testMethodConnectHasPostconditionThatTheServerIsBound() + { + $composite = $this->getMockedComposite(); + $composite->server->expects($this->exactly(2)) + ->method('connectGuid'); + $composite->search->expects($this->exactly(1)) + ->method('__call') + ->with('searchGuidForUidOrMail', array('user')); + $composite->connect('user', 'pass'); + } +} \ No newline at end of file diff --git a/framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/CompositeTest.php b/framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/CompositeTest.php deleted file mode 100644 index dcdabf534..000000000 --- a/framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/CompositeTest.php +++ /dev/null @@ -1,63 +0,0 @@ - - * @license http://www.fsf.org/copyleft/lgpl.html LGPL - * @link http://pear.horde.org/index.php?package=Kolab_Server - */ - -/** - * Prepare the test setup. - */ -require_once dirname(__FILE__) . '/../../TestCase.php'; - -/** - * Test the composite server. - * - * Copyright 2009 The Horde Project (http://www.horde.org/) - * - * See the enclosed file COPYING for license information (LGPL). If you - * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html. - * - * @category Kolab - * @package Kolab_Server - * @author Gunnar Wrobel - * @license http://www.fsf.org/copyleft/lgpl.html LGPL - * @link http://pear.horde.org/index.php?package=Kolab_Server - */ -class Horde_Kolab_Server_Class_Server_CompositeTest extends Horde_Kolab_Server_TestCase -{ - public function testMethodGetReturnsServerElement() - { - $composite = $this->getMockedComposite(); - $this->assertType('Horde_Kolab_Server', $composite->server); - $this->assertType('Horde_Kolab_Server_Objects', $composite->objects); - $this->assertType('Horde_Kolab_Server_Structure_Interface', $composite->structure); - $this->assertType('Horde_Kolab_Server_Search_Interface', $composite->search); - $this->assertType('Horde_Kolab_Server_Schema', $composite->schema); - try { - $a = $composite->something; - $this->fail('No exception!'); - } catch (Horde_Kolab_Server_Exception $e) { - $this->assertEquals( - 'Attribute something not supported!', $e->getMessage() - ); - } - } - - public function testMethodConnectHasPostconditionThatTheServerIsBound() - { - $composite = $this->getMockedComposite(); - $composite->server->expects($this->exactly(2)) - ->method('connectGuid'); - $composite->search->expects($this->exactly(1)) - ->method('__call') - ->with('searchGuidForUidOrMail', array('user')); - $composite->connect('user', 'pass'); - } -} \ No newline at end of file diff --git a/framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/Decorator/CleanTest.php b/framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/Decorator/CleanTest.php new file mode 100644 index 000000000..0b61e09f2 --- /dev/null +++ b/framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/Decorator/CleanTest.php @@ -0,0 +1,202 @@ + + * @license http://www.fsf.org/copyleft/lgpl.html LGPL + * @link http://pear.horde.org/index.php?package=Kolab_Server + */ + +/** + * Prepare the test setup. + */ +require_once dirname(__FILE__) . '/../../../Autoload.php'; + +/** + * Test the cleanup decorator for the server. + * + * Copyright 2009 The Horde Project (http://www.horde.org/) + * + * See the enclosed file COPYING for license information (LGPL). If you + * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html. + * + * @category Kolab + * @package Kolab_Server + * @author Gunnar Wrobel + * @license http://www.fsf.org/copyleft/lgpl.html LGPL + * @link http://pear.horde.org/index.php?package=Kolab_Server + */ +class Horde_Kolab_Server_Class_Server_Decorator_CleanTest extends PHPUnit_Framework_TestCase +{ + public function setUp() + { + parent::setUp(); + + $this->server = $this->getMock('Horde_Kolab_Server_Interface'); + $this->cleaner = new Horde_Kolab_Server_Decorator_Clean($this->server); + } + + public function testMethodGetbaseguidHasPostconditionThatTheCallWasDelegatedToTheServer() + { + $this->server->expects($this->exactly(1)) + ->method('getBaseGuid') + ->will($this->returnValue('base')); + $this->assertEquals('base', $this->cleaner->getBaseGuid()); + } + + public function testMethodGetuidHasPostconditionThatTheCallWasDelegatedToTheServer() + { + $this->server->expects($this->exactly(1)) + ->method('getGuid') + ->will($this->returnValue('guid')); + $this->assertEquals('guid', $this->cleaner->getGuid()); + } + + public function testMethodConnectguidHasPostconditionThatTheCallWasDelegatedToTheServer() + { + $this->server->expects($this->exactly(1)) + ->method('connectGuid') + ->with('user', 'pass'); + $this->cleaner->connectGuid('user', 'pass'); + } + + public function testMethodReadHasPostconditionThatTheCallWasDelegatedToTheServer() + { + $this->server->expects($this->exactly(1)) + ->method('read') + ->with('guid') + ->will($this->returnValue(array())); + $this->assertEquals(array(), $this->cleaner->read('guid')); + } + + public function testMethodReadattributesHasPostconditionThatTheCallWasDelegatedToTheServer() + { + $this->server->expects($this->exactly(1)) + ->method('readAttributes') + ->with('guid', array('a')) + ->will($this->returnValue(array())); + $this->assertEquals( + array(), $this->cleaner->readAttributes('guid', array('a')) + ); + } + + public function testMethodFindHasPostconditionThatTheCallWasDelegatedToTheServer() + { + $result = $this->getMock('Horde_Kolab_Server_Result'); + $query = $this->getMock( + 'Horde_Kolab_Server_Query_Element', array(), array(), '', false + ); + $this->server->expects($this->exactly(1)) + ->method('find') + ->with($query) + ->will($this->returnValue($result)); + $this->assertType( + 'Horde_Kolab_Server_Result', + $this->cleaner->find($query) + ); + } + + public function testMethodFindbelowHasPostconditionThatTheCallWasDelegatedToTheServer() + { + $result = $this->getMock('Horde_Kolab_Server_Result_Interface'); + $query = $this->getMock( + 'Horde_Kolab_Server_Query_Element', array(), array(), '', false + ); + $this->server->expects($this->exactly(1)) + ->method('findBelow') + ->with($query, 'none') + ->will($this->returnValue($result)); + $this->assertType( + 'Horde_Kolab_Server_Result_Interface', + $this->cleaner->findBelow($query, 'none') + ); + } + + public function testMethodSaveHasPostconditionThatTheCallWasDelegatedToTheServer() + { + $object = $this->getMock('Horde_Kolab_Server_Object_Interface'); + $this->server->expects($this->exactly(1)) + ->method('save') + ->with($object, array('a' => 'a')); + $this->cleaner->save($object, array('a' => 'a')); + } + + public function testMethodAddHasPostconditionThatTheCallWasDelegatedToTheServer() + { + $object = $this->getMock('Horde_Kolab_Server_Object_Interface'); + $this->server->expects($this->exactly(1)) + ->method('add') + ->with($object, array('a' => 'a')); + $this->cleaner->add($object, array('a' => 'a')); + } + + public function testMethodDeleteHasPostconditionThatTheCallWasDelegatedToTheServer() + { + $this->server->expects($this->exactly(1)) + ->method('delete') + ->with('a'); + $this->cleaner->delete('a'); + } + + public function testMethodRenameHasPostconditionThatTheCallWasDelegatedToTheServer() + { + $this->server->expects($this->exactly(1)) + ->method('rename') + ->with('a', 'b'); + $this->cleaner->rename('a', 'b'); + } + + public function testMethodGetschemaHasPostconditionThatTheCallWasDelegatedToTheServer() + { + $this->server->expects($this->exactly(1)) + ->method('getSchema'); + $this->cleaner->getSchema(); + } + + public function testMethodGetparentguidHasPostconditionThatTheCallWasDelegatedToTheServer() + { + $this->server->expects($this->exactly(1)) + ->method('getParentGuid') + ->will($this->returnValue('parent')); + $this->assertEquals('parent', $this->cleaner->getParentGuid('child')); + } + + public function testMethodAddHasPostconditionThatTheGuidOfTheAddedObjectIsRememberedAndDeletedOnDestruction() + { + $object = $this->getMock('Horde_Kolab_Server_Object_Interface'); + $object->expects($this->exactly(1)) + ->method('getGuid') + ->will($this->returnValue('a')); + $this->server->expects($this->exactly(1)) + ->method('add') + ->with($object, array('a' => 'a')); + $this->server->expects($this->exactly(1)) + ->method('delete') + ->with('a'); + $this->cleaner->add($object, array('a' => 'a')); + unset($this->cleaner); + } + + public function testMethodAddHasPostconditionThatTheGuidOfTheAddedObjectIsNotDeletedOnDestructionIfItWasDeletedBefore() + { + $object = $this->getMock('Horde_Kolab_Server_Object_Interface'); + $object->expects($this->exactly(1)) + ->method('getGuid') + ->will($this->returnValue('a')); + $this->server->expects($this->exactly(1)) + ->method('add') + ->with($object, array('a' => 'a')); + $this->server->expects($this->exactly(1)) + ->method('delete') + ->with('a'); + $this->cleaner->add($object, array('a' => 'a')); + $this->cleaner->delete('a'); + unset($this->cleaner); + } + + +} \ No newline at end of file diff --git a/framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/Decorator/LogTest.php b/framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/Decorator/LogTest.php new file mode 100644 index 000000000..b03e4e767 --- /dev/null +++ b/framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/Decorator/LogTest.php @@ -0,0 +1,220 @@ + + * @license http://www.fsf.org/copyleft/lgpl.html LGPL + * @link http://pear.horde.org/index.php?package=Kolab_Server + */ + +/** + * Prepare the test setup. + */ +require_once dirname(__FILE__) . '/../../../Autoload.php'; + +/** + * Test the log decorator for the server. + * + * Copyright 2009 The Horde Project (http://www.horde.org/) + * + * See the enclosed file COPYING for license information (LGPL). If you + * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html. + * + * @category Kolab + * @package Kolab_Server + * @author Gunnar Wrobel + * @license http://www.fsf.org/copyleft/lgpl.html LGPL + * @link http://pear.horde.org/index.php?package=Kolab_Server + */ +class Horde_Kolab_Server_Class_Server_Decorator_LogTest extends PHPUnit_Framework_TestCase +{ + public function setUp() + { + parent::setUp(); + + $this->logger = $this->getMock('Horde_Log_Logger'); + $this->server = $this->getMock('Horde_Kolab_Server_Interface'); + $this->logged = new Horde_Kolab_Server_Decorator_Log( + $this->server, $this->logger + ); + } + + public function testMethodGetbaseguidHasPostconditionThatTheCallWasDelegatedToTheServer() + { + $this->server->expects($this->exactly(1)) + ->method('getBaseGuid') + ->will($this->returnValue('base')); + $this->assertEquals('base', $this->logged->getBaseGuid()); + } + + public function testMethodGetuidHasPostconditionThatTheCallWasDelegatedToTheServer() + { + $this->server->expects($this->exactly(1)) + ->method('getGuid') + ->will($this->returnValue('guid')); + $this->assertEquals('guid', $this->logged->getGuid()); + } + + public function testMethodConnectguidHasPostconditionThatTheCallWasDelegatedToTheServer() + { + $this->server->expects($this->exactly(1)) + ->method('connectGuid') + ->with('user', 'pass'); + $this->logged->connectGuid('user', 'pass'); + } + + public function testMethodReadHasPostconditionThatTheCallWasDelegatedToTheServer() + { + $this->server->expects($this->exactly(1)) + ->method('read') + ->with('guid') + ->will($this->returnValue(array())); + $this->assertEquals(array(), $this->logged->read('guid')); + } + + public function testMethodReadattributesHasPostconditionThatTheCallWasDelegatedToTheServer() + { + $this->server->expects($this->exactly(1)) + ->method('readAttributes') + ->with('guid', array('a')) + ->will($this->returnValue(array())); + $this->assertEquals( + array(), $this->logged->readAttributes('guid', array('a')) + ); + } + + public function testMethodFindHasPostconditionThatTheCallWasDelegatedToTheServer() + { + $result = $this->getMock('Horde_Kolab_Server_Result'); + $query = $this->getMock( + 'Horde_Kolab_Server_Query_Element', array(), array(), '', false + ); + $this->server->expects($this->exactly(1)) + ->method('find') + ->with($query) + ->will($this->returnValue($result)); + $this->assertType( + 'Horde_Kolab_Server_Result', + $this->logged->find($query) + ); + } + + public function testMethodFindbelowHasPostconditionThatTheCallWasDelegatedToTheServer() + { + $result = $this->getMock('Horde_Kolab_Server_Result'); + $query = $this->getMock( + 'Horde_Kolab_Server_Query_Element', array(), array(), '', false + ); + $this->server->expects($this->exactly(1)) + ->method('findBelow') + ->with($query, 'none') + ->will($this->returnValue($result)); + $this->assertType( + 'Horde_Kolab_Server_Result', + $this->logged->findBelow($query, 'none') + ); + } + + public function testMethodSaveHasPostconditionThatTheCallWasDelegatedToTheServer() + { + $object = $this->getMock('Horde_Kolab_Server_Object_Interface'); + $this->server->expects($this->exactly(1)) + ->method('save') + ->with($object, array('a' => 'a')); + $this->logged->save($object, array('a' => 'a')); + } + + public function testMethodAddHasPostconditionThatTheCallWasDelegatedToTheServer() + { + $object = $this->getMock('Horde_Kolab_Server_Object_Interface'); + $this->server->expects($this->exactly(1)) + ->method('add') + ->with($object, array('a' => 'a')); + $this->logged->add($object, array('a' => 'a')); + } + + public function testMethodDeleteHasPostconditionThatTheCallWasDelegatedToTheServer() + { + $this->server->expects($this->exactly(1)) + ->method('delete') + ->with('a'); + $this->logged->delete('a'); + } + + public function testMethodRenameHasPostconditionThatTheCallWasDelegatedToTheServer() + { + $this->server->expects($this->exactly(1)) + ->method('rename') + ->with('a', 'b'); + $this->logged->rename('a', 'b'); + } + + public function testMethodGetschemaHasPostconditionThatTheCallWasDelegatedToTheServer() + { + $this->server->expects($this->exactly(1)) + ->method('getSchema'); + $this->logged->getSchema(); + } + + public function testMethodSaveHasPostconditionThatTheEventWasLogged() + { + $object = $this->getMock('Horde_Kolab_Server_Object_Interface'); + $object->expects($this->once()) + ->method('getGuid') + ->will($this->returnValue('a')); + $this->logger->expects($this->once()) + ->method('__call') + ->with( + 'info', array('The object "a" has been successfully saved!') + ); + $this->logged->save($object, array('a' => 'a')); + } + + public function testMethodAddHasPostconditionThatTheEventWasLogged() + { + $object = $this->getMock('Horde_Kolab_Server_Object_Interface'); + $object->expects($this->once()) + ->method('getGuid') + ->will($this->returnValue('a')); + $this->logger->expects($this->once()) + ->method('__call') + ->with( + 'info', array('The object "a" has been successfully added!') + ); + $this->logged->add($object, array('a' => 'a')); + } + + public function testMethodDeleteHasPostconditionThatTheEventWasLogged() + { + $this->logger->expects($this->once()) + ->method('__call') + ->with( + 'info', array('The object "a" has been successfully deleted!') + ); + $this->logged->delete('a'); + } + + public function testMethodRenameHasPostconditionThatTheEventWasLogged() + { + $this->logger->expects($this->once()) + ->method('__call') + ->with( + 'info', + array('The object "a" has been successfully renamed to "b"!') + ); + $this->logged->rename('a', 'b'); + } + + public function testMethodGetparentguidHasPostconditionThatTheCallWasDelegatedToTheServer() + { + $this->server->expects($this->exactly(1)) + ->method('getParentGuid') + ->will($this->returnValue('parent')); + $this->assertEquals('parent', $this->logged->getParentGuid('child')); + } + +} \ No newline at end of file diff --git a/framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/Factory/CleanerTest.php b/framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/Factory/CleanerTest.php deleted file mode 100644 index 4a7a23477..000000000 --- a/framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/Factory/CleanerTest.php +++ /dev/null @@ -1,149 +0,0 @@ - - * @license http://www.fsf.org/copyleft/lgpl.html LGPL - * @link http://pear.horde.org/index.php?package=Kolab_Server - */ - -/** - * Prepare the test setup. - */ -require_once dirname(__FILE__) . '/../../../Autoload.php'; - -/** - * Test the cleaner server factory. - * - * Copyright 2009 The Horde Project (http://www.horde.org/) - * - * See the enclosed file COPYING for license information (LGPL). If you - * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html. - * - * @category Kolab - * @package Kolab_Server - * @author Gunnar Wrobel - * @license http://www.fsf.org/copyleft/lgpl.html LGPL - * @link http://pear.horde.org/index.php?package=Kolab_Server - */ -class Horde_Kolab_Server_Class_Server_Factory_CleanerTest -extends PHPUnit_Framework_TestCase -{ - public function setUp() - { - $this->factory = $this->getMock('Horde_Kolab_Server_Factory'); - } - - public function testMethodGetserverHasResultCleanerServerIfACleanedWasProvidedInTheConfiguration() - { - $this->factory->expects($this->once()) - ->method('getServer') - ->will($this->returnValue($this->getMock('Horde_Kolab_Server'))); - $factory = new Horde_Kolab_Server_Factory_Cleaner( - $this->factory, array('cleanup' => true) - ); - $this->assertType('Horde_Kolab_Server_Cleaner', $factory->getServer()); - } - - public function testMethodConstructHasParametersFactory() - { - $factory = new Horde_Kolab_Server_Factory_Cleaner( - $this->factory - ); - } - - public function testMethodGetconnectionfactoryGetsDelegated() - { - $this->factory->expects($this->once()) - ->method('getConnectionFactory'); - $factory = new Horde_Kolab_Server_Factory_Cleaner( - $this->factory, array() - ); - $factory->getConnectionFactory(); - } - - public function testMethodGetserverGetsDelegated() - { - $this->factory->expects($this->once()) - ->method('getServer') - ->will($this->returnValue($this->getMock('Horde_Kolab_Server'))); - $factory = new Horde_Kolab_Server_Factory_Cleaner( - $this->factory, array() - ); - $factory->getServer(); - } - - public function testMethodGetconfigurationGetsDelegated() - { - $this->factory->expects($this->once()) - ->method('getConfiguration'); - $factory = new Horde_Kolab_Server_Factory_Cleaner( - $this->factory, array() - ); - $factory->getConfiguration(); - } - - public function testMethodGetconnectionGetsDelegated() - { - $this->factory->expects($this->once()) - ->method('getConnection'); - $factory = new Horde_Kolab_Server_Factory_Cleaner( - $this->factory, array() - ); - $factory->getConnection(); - } - - public function testMethodGetcompositeGetsDelegated() - { - $this->factory->expects($this->once()) - ->method('getComposite'); - $factory = new Horde_Kolab_Server_Factory_Cleaner( - $this->factory, array() - ); - $factory->getComposite(); - } - - public function testMethodGetobjectsGetsDelegated() - { - $this->factory->expects($this->once()) - ->method('getObjects'); - $factory = new Horde_Kolab_Server_Factory_Cleaner( - $this->factory, array() - ); - $factory->getObjects(); - } - - public function testMethodGetstructureGetsDelegated() - { - $this->factory->expects($this->once()) - ->method('getStructure'); - $factory = new Horde_Kolab_Server_Factory_Cleaner( - $this->factory, array() - ); - $factory->getStructure(); - } - - public function testMethodGetsearchGetsDelegated() - { - $this->factory->expects($this->once()) - ->method('getSearch'); - $factory = new Horde_Kolab_Server_Factory_Cleaner( - $this->factory, array() - ); - $factory->getSearch(); - } - - public function testMethodGetschemaGetsDelegated() - { - $this->factory->expects($this->once()) - ->method('getSchema'); - $factory = new Horde_Kolab_Server_Factory_Cleaner( - $this->factory, array() - ); - $factory->getSchema(); - } -} \ No newline at end of file diff --git a/framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/Factory/ConfigurationTest.php b/framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/Factory/ConfigurationTest.php index 5939ce322..4eec53d00 100644 --- a/framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/Factory/ConfigurationTest.php +++ b/framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/Factory/ConfigurationTest.php @@ -39,7 +39,9 @@ extends Horde_Kolab_Server_LdapTestCase $factory = new Horde_Kolab_Server_Factory_Configuration( array('logger' => 'set', 'basedn' => '') ); - $this->assertType('Horde_Kolab_Server_Logged', $factory->getServer()); + $this->assertType( + 'Horde_Kolab_Server_Decorator_Log', $factory->getServer() + ); } public function testMethodGetserverHasResultMappedServerIfAMappedWasProvidedInTheConfiguration() @@ -48,7 +50,9 @@ extends Horde_Kolab_Server_LdapTestCase $factory = new Horde_Kolab_Server_Factory_Configuration( array('map' => array(), 'basedn' => '') ); - $this->assertType('Horde_Kolab_Server_Mapped', $factory->getServer()); + $this->assertType( + 'Horde_Kolab_Server_Decorator_Map', $factory->getServer() + ); } public function testMethodGetserverHasResultCleanerServerIfACleanedWasProvidedInTheConfiguration() @@ -57,7 +61,9 @@ extends Horde_Kolab_Server_LdapTestCase $factory = new Horde_Kolab_Server_Factory_Configuration( array('cleanup' => true, 'basedn' => '') ); - $this->assertType('Horde_Kolab_Server_Cleaner', $factory->getServer()); + $this->assertType( + 'Horde_Kolab_Server_Decorator_Clean', $factory->getServer() + ); } public function testMethodConstructHasParametersArrayParameters() @@ -73,7 +79,7 @@ extends Horde_Kolab_Server_LdapTestCase array('basedn' => '') ); $this->assertType( - 'Horde_Kolab_Server_Factory_Conn', + 'Horde_Kolab_Server_Factory_Connection_Interface', $factory->getConnectionFactory() ); } @@ -85,7 +91,7 @@ extends Horde_Kolab_Server_LdapTestCase array('basedn' => '') ); $this->assertType( - 'Horde_Kolab_Server', + 'Horde_Kolab_Server_Interface', $factory->getServer() ); } @@ -108,7 +114,7 @@ extends Horde_Kolab_Server_LdapTestCase array('basedn' => '') ); $this->assertType( - 'Horde_Kolab_Server_Connection', + 'Horde_Kolab_Server_Connection_Interface', $factory->getConnection() ); } @@ -120,7 +126,7 @@ extends Horde_Kolab_Server_LdapTestCase array('basedn' => '') ); $this->assertType( - 'Horde_Kolab_Server_Composite', + 'Horde_Kolab_Server_Composite_Interface', $factory->getComposite() ); } @@ -131,7 +137,7 @@ extends Horde_Kolab_Server_LdapTestCase array('basedn' => '') ); $this->assertType( - 'Horde_Kolab_Server_Objects', + 'Horde_Kolab_Server_Objects_Interface', $factory->getObjects() ); } @@ -164,7 +170,7 @@ extends Horde_Kolab_Server_LdapTestCase array('basedn' => '') ); $this->assertType( - 'Horde_Kolab_Server_Schema', + 'Horde_Kolab_Server_Schema_Interface', $factory->getSchema() ); } diff --git a/framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/Factory/Conn/ConfigurationTest.php b/framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/Factory/Conn/ConfigurationTest.php deleted file mode 100644 index 746c67381..000000000 --- a/framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/Factory/Conn/ConfigurationTest.php +++ /dev/null @@ -1,80 +0,0 @@ - - * @license http://www.fsf.org/copyleft/lgpl.html LGPL - * @link http://pear.horde.org/index.php?package=Kolab_Server - */ - -/** - * Require our basic test case definition - */ -require_once dirname(__FILE__) . '/../../../../LdapTestCase.php'; - -/** - * Test the configuration based connection factory. - * - * Copyright 2009 The Horde Project (http://www.horde.org/) - * - * See the enclosed file COPYING for license information (LGPL). If you - * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html. - * - * @category Kolab - * @package Kolab_Server - * @author Gunnar Wrobel - * @license http://www.fsf.org/copyleft/lgpl.html LGPL - * @link http://pear.horde.org/index.php?package=Kolab_Server - */ -class Horde_Kolab_Server_Class_Server_Factory_Conn_ConfigurationTest -extends Horde_Kolab_Server_LdapTestCase -{ - public function testMethodConstructHasParameterArrayConfiguration() - { - $factory = new Horde_Kolab_Server_Factory_Conn_Configuration( - array('basedn' => 'a') - ); - } - - public function testMethodConstructHasPostconditionThatTheConfigurationWasSaved() - { - $factory = new Horde_Kolab_Server_Factory_Conn_Configuration( - array('basedn' => 'a') - ); - $this->assertEquals(array('basedn' => 'a'), $factory->getConfiguration()); - } - - public function testMethodConstructHasResultArrayTheConfiguration() - { - $factory = new Horde_Kolab_Server_Factory_Conn_Configuration( - array('basedn' => 'a') - ); - $this->assertType('array', $factory->getConfiguration()); - } - - public function testMethodConstructHasPostconditionThatTheConnectionFactoryHasBeenSet() - { - $factory = new Horde_Kolab_Server_Factory_Conn_Configuration( - array('mock' => true) - ); - $this->assertType('Horde_Kolab_Server_Connection_Mock', $factory->getConnection()); - } - - public function testMethodGetconnectionHasResultMockConnectionIfConfiguredThatWay() - { - $this->testMethodConstructHasPostconditionThatTheConnectionFactoryHasBeenSet(); - } - - public function testMethodGetconnectionHasResultLdapConnectionIfConfiguredThatWay() - { - $this->skipIfNoLdap(); - $factory = new Horde_Kolab_Server_Factory_Conn_Configuration( - array('basedn' => 'a') - ); - $this->assertType('Horde_Kolab_Server_Connection_Simpleldap', $factory->getConnection()); - } -} \ No newline at end of file diff --git a/framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/Factory/Conn/InjectorTest.php b/framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/Factory/Conn/InjectorTest.php deleted file mode 100644 index 7ecff3fb9..000000000 --- a/framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/Factory/Conn/InjectorTest.php +++ /dev/null @@ -1,53 +0,0 @@ - - * @license http://www.fsf.org/copyleft/lgpl.html LGPL - * @link http://pear.horde.org/index.php?package=Kolab_Server - */ - -/** - * Prepare the test setup. - */ -require_once dirname(__FILE__) . '/../../../../Autoload.php'; - -/** - * Test the injector based connection factory. - * - * Copyright 2009 The Horde Project (http://www.horde.org/) - * - * See the enclosed file COPYING for license information (LGPL). If you - * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html. - * - * @category Kolab - * @package Kolab_Server - * @author Gunnar Wrobel - * @license http://www.fsf.org/copyleft/lgpl.html LGPL - * @link http://pear.horde.org/index.php?package=Kolab_Server - */ -class Horde_Kolab_Server_Class_Server_Factory_Conn_InjectorTest -extends PHPUnit_Framework_TestCase -{ - public function testMethodGetconnectionHasResultConnection() - { - $injector = new Horde_Injector(new Horde_Injector_TopLevel()); - $injector->bindImplementation( - 'Horde_Kolab_Server_Factory_Conn', - 'Horde_Kolab_Server_Factory_Conn_Mock' - ); - $injector->setInstance( - 'Horde_Kolab_Server_Configuration', - array() - ); - $factory = new Horde_Kolab_Server_Factory_Conn_Injector($injector); - $this->assertType( - 'Horde_Kolab_Server_Connection', - $factory->getConnection() - ); - } -} \ No newline at end of file diff --git a/framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/Factory/Conn/LdapTest.php b/framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/Factory/Conn/LdapTest.php deleted file mode 100644 index 880b81626..000000000 --- a/framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/Factory/Conn/LdapTest.php +++ /dev/null @@ -1,125 +0,0 @@ - - * @license http://www.fsf.org/copyleft/lgpl.html LGPL - * @link http://pear.horde.org/index.php?package=Kolab_Server - */ - -/** - * Require our basic test case definition - */ -require_once dirname(__FILE__) . '/../../../../LdapTestCase.php'; - -/** - * Test the ldap connection factory. - * - * Copyright 2009 The Horde Project (http://www.horde.org/) - * - * See the enclosed file COPYING for license information (LGPL). If you - * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html. - * - * @category Kolab - * @package Kolab_Server - * @author Gunnar Wrobel - * @license http://www.fsf.org/copyleft/lgpl.html LGPL - * @link http://pear.horde.org/index.php?package=Kolab_Server - */ -class Horde_Kolab_Server_Class_Server_Factory_Conn_LdapTest -extends Horde_Kolab_Server_LdapTestCase -{ - public function testMethodSetconfigurationHasPostconditionThatTheServerParameterWasRewritten() - { - $factory = new Horde_Kolab_Server_Factory_Conn_Ldap(); - $factory->setConfiguration( - array( - 'basedn' => 'test', - 'server' => '1' - ) - ); - $this->assertEquals( - array( - 'basedn' => 'test', - 'host' => '1' - ), - $factory->getConfiguration() - ); - } - - public function testMethodSetconfigurationHasPostconditionThatThePhpdnParameterWasRewritten() - { - $factory = new Horde_Kolab_Server_Factory_Conn_Ldap(); - $factory->setConfiguration( - array( - 'basedn' => 'test', - 'phpdn' => '1' - ) - ); - $this->assertEquals( - array( - 'basedn' => 'test', - 'binddn' => '1' - ), - $factory->getConfiguration() - ); - } - - public function testMethodSetconfigurationHasPostconditionThatThePhppwParameterWasRewritten() - { - $factory = new Horde_Kolab_Server_Factory_Conn_Ldap(); - $factory->setConfiguration( - array( - 'basedn' => 'test', - 'phppw' => '1' - ) - ); - $this->assertEquals( - array( - 'basedn' => 'test', - 'bindpw' => '1' - ), - $factory->getConfiguration() - ); - } - - public function testMethodSetconfigurationThrowsExceptionIfTheBasednIsNotSet() - { - $factory = new Horde_Kolab_Server_Factory_Conn_Ldap(); - try { - $factory->setConfiguration(array()); - $this->fail('No exception!'); - } catch (Horde_Kolab_Server_Exception $e) { - $this->assertEquals( - 'The base DN is missing!', - $e->getMessage() - ); - } - } - - public function testMethodGetconnectionHasResultConnectionSimpleldap() - { - $this->skipIfNoLdap(); - $factory = new Horde_Kolab_Server_Factory_Conn_Ldap(); - $factory->setConfiguration(array('basedn' => 'test')); - $this->assertType( - 'Horde_Kolab_Server_Connection_Simpleldap', - $factory->getConnection() - ); - } - - public function testMethodGetconnectionHasResultConnectionSplittedldapIfTheHostMasterIsSet() - { - $this->skipIfNoLdap(); - $factory = new Horde_Kolab_Server_Factory_Conn_Ldap(); - $factory->setConfiguration(array('basedn' => 'test', 'host_master' => 'dummy')); - $this->assertType( - 'Horde_Kolab_Server_Connection_Splittedldap', - $factory->getConnection() - ); - } -} \ No newline at end of file diff --git a/framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/Factory/Conn/MockTest.php b/framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/Factory/Conn/MockTest.php deleted file mode 100644 index 5e741204a..000000000 --- a/framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/Factory/Conn/MockTest.php +++ /dev/null @@ -1,84 +0,0 @@ - - * @license http://www.fsf.org/copyleft/lgpl.html LGPL - * @link http://pear.horde.org/index.php?package=Kolab_Server - */ - -/** - * Prepare the test setup. - */ -require_once dirname(__FILE__) . '/../../../../Autoload.php'; - -/** - * Test the mock connection factory. - * - * Copyright 2009 The Horde Project (http://www.horde.org/) - * - * See the enclosed file COPYING for license information (LGPL). If you - * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html. - * - * @category Kolab - * @package Kolab_Server - * @author Gunnar Wrobel - * @license http://www.fsf.org/copyleft/lgpl.html LGPL - * @link http://pear.horde.org/index.php?package=Kolab_Server - */ -class Horde_Kolab_Server_Class_Server_Factory_Conn_MockTest -extends PHPUnit_Framework_TestCase -{ - public function testMethodGetconfigurationHasResultArrayTheConnectionConfiguration() - { - $factory = new Horde_Kolab_Server_Factory_Conn_Mock(); - $factory->setConfiguration(array('basedn' => 'test')); - $this->assertEquals( - array('basedn' => 'test'), - $factory->getConfiguration() - ); - } - - public function testMethodSetconfigurationHasPostconditionThatTheConfigurationWasSaved() - { - $factory = new Horde_Kolab_Server_Factory_Conn_Mock(); - $factory->setConfiguration(array()); - $this->assertEquals( - array(), - $factory->getConfiguration() - ); - } - - public function testMethodGetconfigurationThrowsExceptionIfNoConfigurationHasBeenSet() - { - $factory = new Horde_Kolab_Server_Factory_Conn_Mock(); - try { - $factory->getConfiguration(); - $this->fail('No exception!'); - } catch (Horde_Kolab_Server_Exception $e) { - $this->assertEquals( - 'The configuration has not been set!', - $e->getMessage() - ); - } - } - - public function testMethodGetconnectionHasResultConnectionmock() - { - $factory = new Horde_Kolab_Server_Factory_Conn_Mock(); - $factory->setConfiguration( - array( - 'basedn' => 'test', - 'data' => array() - ) - ); - $this->assertType( - 'Horde_Kolab_Server_Connection_Mock', - $factory->getConnection() - ); - } -} \ No newline at end of file diff --git a/framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/Factory/Connection/ConfigurationTest.php b/framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/Factory/Connection/ConfigurationTest.php new file mode 100644 index 000000000..c3f529567 --- /dev/null +++ b/framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/Factory/Connection/ConfigurationTest.php @@ -0,0 +1,80 @@ + + * @license http://www.fsf.org/copyleft/lgpl.html LGPL + * @link http://pear.horde.org/index.php?package=Kolab_Server + */ + +/** + * Require our basic test case definition + */ +require_once dirname(__FILE__) . '/../../../../LdapTestCase.php'; + +/** + * Test the configuration based connection factory. + * + * Copyright 2009 The Horde Project (http://www.horde.org/) + * + * See the enclosed file COPYING for license information (LGPL). If you + * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html. + * + * @category Kolab + * @package Kolab_Server + * @author Gunnar Wrobel + * @license http://www.fsf.org/copyleft/lgpl.html LGPL + * @link http://pear.horde.org/index.php?package=Kolab_Server + */ +class Horde_Kolab_Server_Class_Server_Factory_Connection_ConfigurationTest +extends Horde_Kolab_Server_LdapTestCase +{ + public function testMethodConstructHasParameterArrayConfiguration() + { + $factory = new Horde_Kolab_Server_Factory_Connection_Configuration( + array('basedn' => 'a') + ); + } + + public function testMethodConstructHasPostconditionThatTheConfigurationWasSaved() + { + $factory = new Horde_Kolab_Server_Factory_Connection_Configuration( + array('basedn' => 'a') + ); + $this->assertEquals(array('basedn' => 'a'), $factory->getConfiguration()); + } + + public function testMethodConstructHasResultArrayTheConfiguration() + { + $factory = new Horde_Kolab_Server_Factory_Connection_Configuration( + array('basedn' => 'a') + ); + $this->assertType('array', $factory->getConfiguration()); + } + + public function testMethodConstructHasPostconditionThatTheConnectionFactoryHasBeenSet() + { + $factory = new Horde_Kolab_Server_Factory_Connection_Configuration( + array('mock' => true) + ); + $this->assertType('Horde_Kolab_Server_Connection_Mock', $factory->getConnection()); + } + + public function testMethodGetconnectionHasResultMockConnectionIfConfiguredThatWay() + { + $this->testMethodConstructHasPostconditionThatTheConnectionFactoryHasBeenSet(); + } + + public function testMethodGetconnectionHasResultLdapConnectionIfConfiguredThatWay() + { + $this->skipIfNoLdap(); + $factory = new Horde_Kolab_Server_Factory_Connection_Configuration( + array('basedn' => 'a') + ); + $this->assertType('Horde_Kolab_Server_Connection_Simpleldap', $factory->getConnection()); + } +} \ No newline at end of file diff --git a/framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/Factory/Connection/InjectorTest.php b/framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/Factory/Connection/InjectorTest.php new file mode 100644 index 000000000..f6882c343 --- /dev/null +++ b/framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/Factory/Connection/InjectorTest.php @@ -0,0 +1,53 @@ + + * @license http://www.fsf.org/copyleft/lgpl.html LGPL + * @link http://pear.horde.org/index.php?package=Kolab_Server + */ + +/** + * Prepare the test setup. + */ +require_once dirname(__FILE__) . '/../../../../Autoload.php'; + +/** + * Test the injector based connection factory. + * + * Copyright 2009 The Horde Project (http://www.horde.org/) + * + * See the enclosed file COPYING for license information (LGPL). If you + * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html. + * + * @category Kolab + * @package Kolab_Server + * @author Gunnar Wrobel + * @license http://www.fsf.org/copyleft/lgpl.html LGPL + * @link http://pear.horde.org/index.php?package=Kolab_Server + */ +class Horde_Kolab_Server_Class_Server_Factory_Connection_InjectorTest +extends PHPUnit_Framework_TestCase +{ + public function testMethodGetconnectionHasResultConnection() + { + $injector = new Horde_Injector(new Horde_Injector_TopLevel()); + $injector->bindImplementation( + 'Horde_Kolab_Server_Factory_Connection_Interface', + 'Horde_Kolab_Server_Factory_Connection_Mock' + ); + $injector->setInstance( + 'Horde_Kolab_Server_Configuration', + array() + ); + $factory = new Horde_Kolab_Server_Factory_Connection_Injector($injector); + $this->assertType( + 'Horde_Kolab_Server_Connection_Interface', + $factory->getConnection() + ); + } +} \ No newline at end of file diff --git a/framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/Factory/Connection/LdapTest.php b/framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/Factory/Connection/LdapTest.php new file mode 100644 index 000000000..612f25cdb --- /dev/null +++ b/framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/Factory/Connection/LdapTest.php @@ -0,0 +1,125 @@ + + * @license http://www.fsf.org/copyleft/lgpl.html LGPL + * @link http://pear.horde.org/index.php?package=Kolab_Server + */ + +/** + * Require our basic test case definition + */ +require_once dirname(__FILE__) . '/../../../../LdapTestCase.php'; + +/** + * Test the ldap connection factory. + * + * Copyright 2009 The Horde Project (http://www.horde.org/) + * + * See the enclosed file COPYING for license information (LGPL). If you + * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html. + * + * @category Kolab + * @package Kolab_Server + * @author Gunnar Wrobel + * @license http://www.fsf.org/copyleft/lgpl.html LGPL + * @link http://pear.horde.org/index.php?package=Kolab_Server + */ +class Horde_Kolab_Server_Class_Server_Factory_Connection_LdapTest +extends Horde_Kolab_Server_LdapTestCase +{ + public function testMethodSetconfigurationHasPostconditionThatTheServerParameterWasRewritten() + { + $factory = new Horde_Kolab_Server_Factory_Connection_Ldap(); + $factory->setConfiguration( + array( + 'basedn' => 'test', + 'server' => '1' + ) + ); + $this->assertEquals( + array( + 'basedn' => 'test', + 'host' => '1' + ), + $factory->getConfiguration() + ); + } + + public function testMethodSetconfigurationHasPostconditionThatThePhpdnParameterWasRewritten() + { + $factory = new Horde_Kolab_Server_Factory_Connection_Ldap(); + $factory->setConfiguration( + array( + 'basedn' => 'test', + 'phpdn' => '1' + ) + ); + $this->assertEquals( + array( + 'basedn' => 'test', + 'binddn' => '1' + ), + $factory->getConfiguration() + ); + } + + public function testMethodSetconfigurationHasPostconditionThatThePhppwParameterWasRewritten() + { + $factory = new Horde_Kolab_Server_Factory_Connection_Ldap(); + $factory->setConfiguration( + array( + 'basedn' => 'test', + 'phppw' => '1' + ) + ); + $this->assertEquals( + array( + 'basedn' => 'test', + 'bindpw' => '1' + ), + $factory->getConfiguration() + ); + } + + public function testMethodSetconfigurationThrowsExceptionIfTheBasednIsNotSet() + { + $factory = new Horde_Kolab_Server_Factory_Connection_Ldap(); + try { + $factory->setConfiguration(array()); + $this->fail('No exception!'); + } catch (Horde_Kolab_Server_Exception $e) { + $this->assertEquals( + 'The base DN is missing!', + $e->getMessage() + ); + } + } + + public function testMethodGetconnectionHasResultConnectionSimpleldap() + { + $this->skipIfNoLdap(); + $factory = new Horde_Kolab_Server_Factory_Connection_Ldap(); + $factory->setConfiguration(array('basedn' => 'test')); + $this->assertType( + 'Horde_Kolab_Server_Connection_Simpleldap', + $factory->getConnection() + ); + } + + public function testMethodGetconnectionHasResultConnectionSplittedldapIfTheHostMasterIsSet() + { + $this->skipIfNoLdap(); + $factory = new Horde_Kolab_Server_Factory_Connection_Ldap(); + $factory->setConfiguration(array('basedn' => 'test', 'host_master' => 'dummy')); + $this->assertType( + 'Horde_Kolab_Server_Connection_Splittedldap', + $factory->getConnection() + ); + } +} \ No newline at end of file diff --git a/framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/Factory/Connection/MockTest.php b/framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/Factory/Connection/MockTest.php new file mode 100644 index 000000000..844817084 --- /dev/null +++ b/framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/Factory/Connection/MockTest.php @@ -0,0 +1,84 @@ + + * @license http://www.fsf.org/copyleft/lgpl.html LGPL + * @link http://pear.horde.org/index.php?package=Kolab_Server + */ + +/** + * Prepare the test setup. + */ +require_once dirname(__FILE__) . '/../../../../Autoload.php'; + +/** + * Test the mock connection factory. + * + * Copyright 2009 The Horde Project (http://www.horde.org/) + * + * See the enclosed file COPYING for license information (LGPL). If you + * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html. + * + * @category Kolab + * @package Kolab_Server + * @author Gunnar Wrobel + * @license http://www.fsf.org/copyleft/lgpl.html LGPL + * @link http://pear.horde.org/index.php?package=Kolab_Server + */ +class Horde_Kolab_Server_Class_Server_Factory_Connection_MockTest +extends PHPUnit_Framework_TestCase +{ + public function testMethodGetconfigurationHasResultArrayTheConnectionConfiguration() + { + $factory = new Horde_Kolab_Server_Factory_Connection_Mock(); + $factory->setConfiguration(array('basedn' => 'test')); + $this->assertEquals( + array('basedn' => 'test'), + $factory->getConfiguration() + ); + } + + public function testMethodSetconfigurationHasPostconditionThatTheConfigurationWasSaved() + { + $factory = new Horde_Kolab_Server_Factory_Connection_Mock(); + $factory->setConfiguration(array()); + $this->assertEquals( + array(), + $factory->getConfiguration() + ); + } + + public function testMethodGetconfigurationThrowsExceptionIfNoConfigurationHasBeenSet() + { + $factory = new Horde_Kolab_Server_Factory_Connection_Mock(); + try { + $factory->getConfiguration(); + $this->fail('No exception!'); + } catch (Horde_Kolab_Server_Exception $e) { + $this->assertEquals( + 'The configuration has not been set!', + $e->getMessage() + ); + } + } + + public function testMethodGetconnectionHasResultConnectionmock() + { + $factory = new Horde_Kolab_Server_Factory_Connection_Mock(); + $factory->setConfiguration( + array( + 'basedn' => 'test', + 'data' => array() + ) + ); + $this->assertType( + 'Horde_Kolab_Server_Connection_Mock', + $factory->getConnection() + ); + } +} \ No newline at end of file diff --git a/framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/Factory/ConstructorTest.php b/framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/Factory/ConstructorTest.php index 0fc37e604..8f0a65298 100644 --- a/framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/Factory/ConstructorTest.php +++ b/framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/Factory/ConstructorTest.php @@ -36,11 +36,21 @@ extends Horde_Kolab_Server_LdapTestCase public function setUp() { parent::setUp(); - $this->factory = $this->getMock('Horde_Kolab_Server_Factory_Conn'); - $this->objects = $this->getMock('Horde_Kolab_Server_Objects'); - $this->structure = $this->getMock('Horde_Kolab_Server_Structure_Interface'); - $this->search = $this->getMock('Horde_Kolab_Server_Search_Interface'); - $this->schema = $this->getMock('Horde_Kolab_Server_Schema'); + $this->factory = $this->getMock( + 'Horde_Kolab_Server_Factory_Connection_Interface' + ); + $this->objects = $this->getMock( + 'Horde_Kolab_Server_Objects_Interface' + ); + $this->structure = $this->getMock( + 'Horde_Kolab_Server_Structure_Interface' + ); + $this->search = $this->getMock( + 'Horde_Kolab_Server_Search_Interface' + ); + $this->schema = $this->getMock( + 'Horde_Kolab_Server_Schema_Interface' + ); } public function testMethodConstructHasParametersFactoryObjectsStructureSearchSchemaConfig() @@ -58,14 +68,16 @@ extends Horde_Kolab_Server_LdapTestCase ->method('getConnection') ->will( $this->returnValue( - $this->getMock('Horde_Kolab_Server_Connection') + $this->getMock( + 'Horde_Kolab_Server_Connection_Interface' + ) ) ); $factory = new Horde_Kolab_Server_Factory_Constructor( $this->factory, $this->objects, $this->structure, $this->search, $this->schema, array('basedn' => 'test') ); - $this->assertType('Horde_Kolab_Server', $factory->getServer()); + $this->assertType('Horde_Kolab_Server_Interface', $factory->getServer()); } public function testMethodGetconfigurationReturnsArrayConfiguration() @@ -105,7 +117,9 @@ extends Horde_Kolab_Server_LdapTestCase ->method('getConnection') ->will( $this->returnValue( - $this->getMock('Horde_Kolab_Server_Connection') + $this->getMock( + 'Horde_Kolab_Server_Connection_Interface' + ) ) ); $factory = new Horde_Kolab_Server_Factory_Constructor( @@ -113,7 +127,7 @@ extends Horde_Kolab_Server_LdapTestCase $this->search, $this->schema, array('basedn' => 'test') ); $this->assertType( - 'Horde_Kolab_Server_Composite', + 'Horde_Kolab_Server_Composite_Interface', $factory->getComposite() ); } diff --git a/framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/Factory/Decorator/CleanTest.php b/framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/Factory/Decorator/CleanTest.php new file mode 100644 index 000000000..f7bbadf48 --- /dev/null +++ b/framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/Factory/Decorator/CleanTest.php @@ -0,0 +1,166 @@ + + * @license http://www.fsf.org/copyleft/lgpl.html LGPL + * @link http://pear.horde.org/index.php?package=Kolab_Server + */ + +/** + * Prepare the test setup. + */ +require_once dirname(__FILE__) . '/../../../../Autoload.php'; + +/** + * Test the cleaner server factory. + * + * Copyright 2009 The Horde Project (http://www.horde.org/) + * + * See the enclosed file COPYING for license information (LGPL). If you + * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html. + * + * @category Kolab + * @package Kolab_Server + * @author Gunnar Wrobel + * @license http://www.fsf.org/copyleft/lgpl.html LGPL + * @link http://pear.horde.org/index.php?package=Kolab_Server + */ +class Horde_Kolab_Server_Class_Server_Factory_Decorator_CleanTest +extends PHPUnit_Framework_TestCase +{ + public function setUp() + { + $this->factory = $this->getMock( + 'Horde_Kolab_Server_Factory_Interface' + ); + } + + public function testMethodGetserverHasResultCleanerServerIfACleanedWasProvidedInTheConfiguration() + { + $this->factory->expects($this->once()) + ->method('getServer') + ->will( + $this->returnValue( + $this->getMock( + 'Horde_Kolab_Server_Interface' + ) + ) + ); + $factory = new Horde_Kolab_Server_Factory_Decorator_Clean( + $this->factory, array('cleanup' => true) + ); + $this->assertType( + 'Horde_Kolab_Server_Decorator_Clean', + $factory->getServer() + ); + } + + public function testMethodConstructHasParametersFactory() + { + $factory = new Horde_Kolab_Server_Factory_Decorator_Clean( + $this->factory + ); + } + + public function testMethodGetconnectionfactoryGetsDelegated() + { + $this->factory->expects($this->once()) + ->method('getConnectionFactory'); + $factory = new Horde_Kolab_Server_Factory_Decorator_Clean( + $this->factory, array() + ); + $factory->getConnectionFactory(); + } + + public function testMethodGetserverGetsDelegated() + { + $this->factory->expects($this->once()) + ->method('getServer') + ->will( + $this->returnValue( + $this->getMock( + 'Horde_Kolab_Server_Interface' + ) + ) + ); + $factory = new Horde_Kolab_Server_Factory_Decorator_Clean( + $this->factory, array() + ); + $factory->getServer(); + } + + public function testMethodGetconfigurationGetsDelegated() + { + $this->factory->expects($this->once()) + ->method('getConfiguration'); + $factory = new Horde_Kolab_Server_Factory_Decorator_Clean( + $this->factory, array() + ); + $factory->getConfiguration(); + } + + public function testMethodGetconnectionGetsDelegated() + { + $this->factory->expects($this->once()) + ->method('getConnection'); + $factory = new Horde_Kolab_Server_Factory_Decorator_Clean( + $this->factory, array() + ); + $factory->getConnection(); + } + + public function testMethodGetcompositeGetsDelegated() + { + $this->factory->expects($this->once()) + ->method('getComposite'); + $factory = new Horde_Kolab_Server_Factory_Decorator_Clean( + $this->factory, array() + ); + $factory->getComposite(); + } + + public function testMethodGetobjectsGetsDelegated() + { + $this->factory->expects($this->once()) + ->method('getObjects'); + $factory = new Horde_Kolab_Server_Factory_Decorator_Clean( + $this->factory, array() + ); + $factory->getObjects(); + } + + public function testMethodGetstructureGetsDelegated() + { + $this->factory->expects($this->once()) + ->method('getStructure'); + $factory = new Horde_Kolab_Server_Factory_Decorator_Clean( + $this->factory, array() + ); + $factory->getStructure(); + } + + public function testMethodGetsearchGetsDelegated() + { + $this->factory->expects($this->once()) + ->method('getSearch'); + $factory = new Horde_Kolab_Server_Factory_Decorator_Clean( + $this->factory, array() + ); + $factory->getSearch(); + } + + public function testMethodGetschemaGetsDelegated() + { + $this->factory->expects($this->once()) + ->method('getSchema'); + $factory = new Horde_Kolab_Server_Factory_Decorator_Clean( + $this->factory, array() + ); + $factory->getSchema(); + } +} \ No newline at end of file diff --git a/framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/Factory/Decorator/LogTest.php b/framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/Factory/Decorator/LogTest.php new file mode 100644 index 000000000..bb2b0f121 --- /dev/null +++ b/framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/Factory/Decorator/LogTest.php @@ -0,0 +1,163 @@ + + * @license http://www.fsf.org/copyleft/lgpl.html LGPL + * @link http://pear.horde.org/index.php?package=Kolab_Server + */ + +/** + * Prepare the test setup. + */ +require_once dirname(__FILE__) . '/../../../../Autoload.php'; + +/** + * Test the log decorator server factory. + * + * Copyright 2009 The Horde Project (http://www.horde.org/) + * + * See the enclosed file COPYING for license information (LGPL). If you + * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html. + * + * @category Kolab + * @package Kolab_Server + * @author Gunnar Wrobel + * @license http://www.fsf.org/copyleft/lgpl.html LGPL + * @link http://pear.horde.org/index.php?package=Kolab_Server + */ +class Horde_Kolab_Server_Class_Server_Factory_Decorator_LogTest +extends PHPUnit_Framework_TestCase +{ + public function setUp() + { + $this->factory = $this->getMock( + 'Horde_Kolab_Server_Factory_Interface' + ); + } + + public function testMethodGetserverHasResultLoggedServerIfALoggerWasProvidedInTheConfiguration() + { + $this->factory->expects($this->once()) + ->method('getServer') + ->will( + $this->returnValue( + $this->getMock( + 'Horde_Kolab_Server_Interface' + ) + ) + ); + $factory = new Horde_Kolab_Server_Factory_Decorator_Log( + $this->factory, 'logger' + ); + $this->assertType('Horde_Kolab_Server_Decorator_Log', $factory->getServer()); + } + + public function testMethodConstructHasParametersFactoryAndMixedLoggerParameter() + { + $factory = new Horde_Kolab_Server_Factory_Decorator_Log( + $this->factory, 'logger' + ); + } + + public function testMethodGetconnectionfactoryGetsDelegated() + { + $this->factory->expects($this->once()) + ->method('getConnectionFactory'); + $factory = new Horde_Kolab_Server_Factory_Decorator_Log( + $this->factory, 'logger' + ); + $factory->getConnectionFactory(); + } + + public function testMethodGetserverGetsDelegated() + { + $this->factory->expects($this->once()) + ->method('getServer') + ->will( + $this->returnValue( + $this->getMock( + 'Horde_Kolab_Server_Interface' + ) + ) + ); + $factory = new Horde_Kolab_Server_Factory_Decorator_Log( + $this->factory, 'logger' + ); + $factory->getServer(); + } + + public function testMethodGetconfigurationGetsDelegated() + { + $this->factory->expects($this->once()) + ->method('getConfiguration'); + $factory = new Horde_Kolab_Server_Factory_Decorator_Log( + $this->factory, 'logger' + ); + $factory->getConfiguration(); + } + + public function testMethodGetconnectionGetsDelegated() + { + $this->factory->expects($this->once()) + ->method('getConnection'); + $factory = new Horde_Kolab_Server_Factory_Decorator_Log( + $this->factory, 'logger' + ); + $factory->getConnection(); + } + + public function testMethodGetcompositeGetsDelegated() + { + $this->factory->expects($this->once()) + ->method('getComposite'); + $factory = new Horde_Kolab_Server_Factory_Decorator_Log( + $this->factory, 'logger' + ); + $factory->getComposite(); + } + + public function testMethodGetobjectsGetsDelegated() + { + $this->factory->expects($this->once()) + ->method('getObjects'); + $factory = new Horde_Kolab_Server_Factory_Decorator_Log( + $this->factory, 'logger' + ); + $factory->getObjects(); + } + + public function testMethodGetstructureGetsDelegated() + { + $this->factory->expects($this->once()) + ->method('getStructure'); + $factory = new Horde_Kolab_Server_Factory_Decorator_Log( + $this->factory, 'logger' + ); + $factory->getStructure(); + } + + public function testMethodGetsearchGetsDelegated() + { + $this->factory->expects($this->once()) + ->method('getSearch'); + $factory = new Horde_Kolab_Server_Factory_Decorator_Log( + $this->factory, 'logger' + ); + $factory->getSearch(); + } + + public function testMethodGetschemaGetsDelegated() + { + $this->factory->expects($this->once()) + ->method('getSchema'); + $factory = new Horde_Kolab_Server_Factory_Decorator_Log( + $this->factory, 'logger' + ); + $factory->getSchema(); + } +} \ No newline at end of file diff --git a/framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/Factory/Decorator/MapTest.php b/framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/Factory/Decorator/MapTest.php new file mode 100644 index 000000000..96688835e --- /dev/null +++ b/framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/Factory/Decorator/MapTest.php @@ -0,0 +1,164 @@ + + * @license http://www.fsf.org/copyleft/lgpl.html LGPL + * @link http://pear.horde.org/index.php?package=Kolab_Server + */ + +/** + * Prepare the test setup. + */ +require_once dirname(__FILE__) . '/../../../../Autoload.php'; + +/** + * Test the mapping server factory. + * + * Copyright 2009 The Horde Project (http://www.horde.org/) + * + * See the enclosed file COPYING for license information (LGPL). If you + * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html. + * + * @category Kolab + * @package Kolab_Server + * @author Gunnar Wrobel + * @license http://www.fsf.org/copyleft/lgpl.html LGPL + * @link http://pear.horde.org/index.php?package=Kolab_Server + */ +class Horde_Kolab_Server_Class_Server_Factory_Decorator_MapTest +extends PHPUnit_Framework_TestCase +{ + public function setUp() + { + $this->factory = $this->getMock( + 'Horde_Kolab_Server_Factory_Interface' + ); + } + + public function testMethodGetserverHasResultMappedServer() + { + $this->factory->expects($this->once()) + ->method('getServer') + ->will( + $this->returnValue( + $this->getMock('Horde_Kolab_Server_Interface') + ) + ); + $factory = new Horde_Kolab_Server_Factory_Decorator_Map( + $this->factory, array() + ); + $this->assertType( + 'Horde_Kolab_Server_Decorator_Map', + $factory->getServer() + ); + } + + public function testMethodConstructHasParametersFactoryAndArrayMapping() + { + $factory = new Horde_Kolab_Server_Factory_Decorator_Map( + $this->factory, array() + ); + } + + public function testMethodGetconnectionfactoryGetsDelegated() + { + $this->factory->expects($this->once()) + ->method('getConnectionFactory'); + $factory = new Horde_Kolab_Server_Factory_Decorator_Map( + $this->factory, array() + ); + $factory->getConnectionFactory(); + } + + public function testMethodGetserverGetsDelegated() + { + $this->factory->expects($this->once()) + ->method('getServer') + ->will( + $this->returnValue( + $this->getMock( + 'Horde_Kolab_Server_Interface' + ) + ) + ); + $factory = new Horde_Kolab_Server_Factory_Decorator_Map( + $this->factory, array() + ); + $factory->getServer(); + } + + public function testMethodGetconfigurationGetsDelegated() + { + $this->factory->expects($this->once()) + ->method('getConfiguration'); + $factory = new Horde_Kolab_Server_Factory_Decorator_Map( + $this->factory, array() + ); + $factory->getConfiguration(); + } + + public function testMethodGetconnectionGetsDelegated() + { + $this->factory->expects($this->once()) + ->method('getConnection'); + $factory = new Horde_Kolab_Server_Factory_Decorator_Map( + $this->factory, array() + ); + $factory->getConnection(); + } + + public function testMethodGetcompositeGetsDelegated() + { + $this->factory->expects($this->once()) + ->method('getComposite'); + $factory = new Horde_Kolab_Server_Factory_Decorator_Map( + $this->factory, array() + ); + $factory->getComposite(); + } + + public function testMethodGetobjectsGetsDelegated() + { + $this->factory->expects($this->once()) + ->method('getObjects'); + $factory = new Horde_Kolab_Server_Factory_Decorator_Map( + $this->factory, array() + ); + $factory->getObjects(); + } + + public function testMethodGetstructureGetsDelegated() + { + $this->factory->expects($this->once()) + ->method('getStructure'); + $factory = new Horde_Kolab_Server_Factory_Decorator_Map( + $this->factory, array() + ); + $factory->getStructure(); + } + + public function testMethodGetsearchGetsDelegated() + { + $this->factory->expects($this->once()) + ->method('getSearch'); + $factory = new Horde_Kolab_Server_Factory_Decorator_Map( + $this->factory, array() + ); + $factory->getSearch(); + } + + public function testMethodGetschemaGetsDelegated() + { + $this->factory->expects($this->once()) + ->method('getSchema'); + $factory = new Horde_Kolab_Server_Factory_Decorator_Map( + $this->factory, array() + ); + $factory->getSchema(); + } +} \ No newline at end of file diff --git a/framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/Factory/InjectorTest.php b/framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/Factory/InjectorTest.php index 024b50f3e..de20a2f81 100644 --- a/framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/Factory/InjectorTest.php +++ b/framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/Factory/InjectorTest.php @@ -37,7 +37,7 @@ extends Horde_Kolab_Server_LdapTestCase { $injector = new Horde_Injector(new Horde_Injector_TopLevel()); Horde_Kolab_Server_Factory_Injector::setup( - 'Horde_Kolab_Server_Factory_Conn_Mock', + 'Horde_Kolab_Server_Factory_Connection_Mock', $configuration, $injector ); @@ -49,7 +49,7 @@ extends Horde_Kolab_Server_LdapTestCase public function testMethodGetconnectionfactoryHasResultConnectionfactory() { $this->assertType( - 'Horde_Kolab_Server_Factory_Conn', + 'Horde_Kolab_Server_Factory_Connection_Interface', $this->_getFactory(array())->getConnectionFactory() ); } @@ -58,7 +58,7 @@ extends Horde_Kolab_Server_LdapTestCase { $factory = $this->_getFactory(array()); $this->assertType( - 'Horde_Kolab_Server_Connection', + 'Horde_Kolab_Server_Connection_Interface', $factory->getConnection() ); } @@ -101,7 +101,7 @@ extends Horde_Kolab_Server_LdapTestCase { $factory = $this->_getFactory(array()); $this->assertType( - 'Horde_Kolab_Server_Objects', + 'Horde_Kolab_Server_Objects_Interface', $factory->getObjects() ); } @@ -143,7 +143,7 @@ extends Horde_Kolab_Server_LdapTestCase { $factory = $this->_getFactory(array()); $this->assertType( - 'Horde_Kolab_Server_Schema', + 'Horde_Kolab_Server_Schema_Interface', $factory->getSchema() ); } @@ -153,7 +153,7 @@ extends Horde_Kolab_Server_LdapTestCase $this->skipIfNoLdap(); $factory = $this->_getFactory(array('basedn' => 'test')); $this->assertType( - 'Horde_Kolab_Server_Composite', + 'Horde_Kolab_Server_Composite_Interface', $factory->getComposite() ); } diff --git a/framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/Factory/KolabTest.php b/framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/Factory/KolabTest.php index e0bb3eb94..e5afa79f5 100644 --- a/framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/Factory/KolabTest.php +++ b/framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/Factory/KolabTest.php @@ -35,8 +35,12 @@ extends Horde_Kolab_Server_LdapTestCase { public function setUp() { - $this->conn_factory = $this->getMock('Horde_Kolab_Server_Factory_Conn'); - $this->connection = $this->getMock('Horde_Kolab_Server_Connection'); + $this->conn_factory = $this->getMock( + 'Horde_Kolab_Server_Factory_Connection_Interface' + ); + $this->connection = $this->getMock( + 'Horde_Kolab_Server_Connection_Interface' + ); } public function testMethodConstructHasParametersConnectionfactoryAndArrayParameters() @@ -74,7 +78,7 @@ extends Horde_Kolab_Server_LdapTestCase $this->conn_factory, array() ); $this->assertType( - 'Horde_Kolab_Server_Connection', + 'Horde_Kolab_Server_Connection_Interface', $factory->getConnection() ); } @@ -176,7 +180,7 @@ extends Horde_Kolab_Server_LdapTestCase $this->conn_factory, array('basedn' => 'test') ); $this->assertType( - 'Horde_Kolab_Server_Composite', + 'Horde_Kolab_Server_Composite_Interface', $factory->getComposite() ); } diff --git a/framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/Factory/LoggedTest.php b/framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/Factory/LoggedTest.php deleted file mode 100644 index 9f299be6d..000000000 --- a/framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/Factory/LoggedTest.php +++ /dev/null @@ -1,149 +0,0 @@ - - * @license http://www.fsf.org/copyleft/lgpl.html LGPL - * @link http://pear.horde.org/index.php?package=Kolab_Server - */ - -/** - * Prepare the test setup. - */ -require_once dirname(__FILE__) . '/../../../Autoload.php'; - -/** - * Test the log decorator server factory. - * - * Copyright 2009 The Horde Project (http://www.horde.org/) - * - * See the enclosed file COPYING for license information (LGPL). If you - * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html. - * - * @category Kolab - * @package Kolab_Server - * @author Gunnar Wrobel - * @license http://www.fsf.org/copyleft/lgpl.html LGPL - * @link http://pear.horde.org/index.php?package=Kolab_Server - */ -class Horde_Kolab_Server_Class_Server_Factory_LoggedTest -extends PHPUnit_Framework_TestCase -{ - public function setUp() - { - $this->factory = $this->getMock('Horde_Kolab_Server_Factory'); - } - - public function testMethodGetserverHasResultLoggedServerIfALoggerWasProvidedInTheConfiguration() - { - $this->factory->expects($this->once()) - ->method('getServer') - ->will($this->returnValue($this->getMock('Horde_Kolab_Server'))); - $factory = new Horde_Kolab_Server_Factory_Logged( - $this->factory, 'logger' - ); - $this->assertType('Horde_Kolab_Server_Logged', $factory->getServer()); - } - - public function testMethodConstructHasParametersFactoryAndMixedLoggerParameter() - { - $factory = new Horde_Kolab_Server_Factory_Logged( - $this->factory, 'logger' - ); - } - - public function testMethodGetconnectionfactoryGetsDelegated() - { - $this->factory->expects($this->once()) - ->method('getConnectionFactory'); - $factory = new Horde_Kolab_Server_Factory_Logged( - $this->factory, 'logger' - ); - $factory->getConnectionFactory(); - } - - public function testMethodGetserverGetsDelegated() - { - $this->factory->expects($this->once()) - ->method('getServer') - ->will($this->returnValue($this->getMock('Horde_Kolab_Server'))); - $factory = new Horde_Kolab_Server_Factory_Logged( - $this->factory, 'logger' - ); - $factory->getServer(); - } - - public function testMethodGetconfigurationGetsDelegated() - { - $this->factory->expects($this->once()) - ->method('getConfiguration'); - $factory = new Horde_Kolab_Server_Factory_Logged( - $this->factory, 'logger' - ); - $factory->getConfiguration(); - } - - public function testMethodGetconnectionGetsDelegated() - { - $this->factory->expects($this->once()) - ->method('getConnection'); - $factory = new Horde_Kolab_Server_Factory_Logged( - $this->factory, 'logger' - ); - $factory->getConnection(); - } - - public function testMethodGetcompositeGetsDelegated() - { - $this->factory->expects($this->once()) - ->method('getComposite'); - $factory = new Horde_Kolab_Server_Factory_Logged( - $this->factory, 'logger' - ); - $factory->getComposite(); - } - - public function testMethodGetobjectsGetsDelegated() - { - $this->factory->expects($this->once()) - ->method('getObjects'); - $factory = new Horde_Kolab_Server_Factory_Logged( - $this->factory, 'logger' - ); - $factory->getObjects(); - } - - public function testMethodGetstructureGetsDelegated() - { - $this->factory->expects($this->once()) - ->method('getStructure'); - $factory = new Horde_Kolab_Server_Factory_Logged( - $this->factory, 'logger' - ); - $factory->getStructure(); - } - - public function testMethodGetsearchGetsDelegated() - { - $this->factory->expects($this->once()) - ->method('getSearch'); - $factory = new Horde_Kolab_Server_Factory_Logged( - $this->factory, 'logger' - ); - $factory->getSearch(); - } - - public function testMethodGetschemaGetsDelegated() - { - $this->factory->expects($this->once()) - ->method('getSchema'); - $factory = new Horde_Kolab_Server_Factory_Logged( - $this->factory, 'logger' - ); - $factory->getSchema(); - } -} \ No newline at end of file diff --git a/framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/Factory/MappedTest.php b/framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/Factory/MappedTest.php deleted file mode 100644 index c2ea0b1e2..000000000 --- a/framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/Factory/MappedTest.php +++ /dev/null @@ -1,149 +0,0 @@ - - * @license http://www.fsf.org/copyleft/lgpl.html LGPL - * @link http://pear.horde.org/index.php?package=Kolab_Server - */ - -/** - * Prepare the test setup. - */ -require_once dirname(__FILE__) . '/../../../Autoload.php'; - -/** - * Test the mapping server factory. - * - * Copyright 2009 The Horde Project (http://www.horde.org/) - * - * See the enclosed file COPYING for license information (LGPL). If you - * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html. - * - * @category Kolab - * @package Kolab_Server - * @author Gunnar Wrobel - * @license http://www.fsf.org/copyleft/lgpl.html LGPL - * @link http://pear.horde.org/index.php?package=Kolab_Server - */ -class Horde_Kolab_Server_Class_Server_Factory_MappedTest -extends PHPUnit_Framework_TestCase -{ - public function setUp() - { - $this->factory = $this->getMock('Horde_Kolab_Server_Factory'); - } - - public function testMethodGetserverHasResultMappedServer() - { - $this->factory->expects($this->once()) - ->method('getServer') - ->will($this->returnValue($this->getMock('Horde_Kolab_Server'))); - $factory = new Horde_Kolab_Server_Factory_Mapped( - $this->factory, array() - ); - $this->assertType('Horde_Kolab_Server_Mapped', $factory->getServer()); - } - - public function testMethodConstructHasParametersFactoryAndArrayMapping() - { - $factory = new Horde_Kolab_Server_Factory_Mapped( - $this->factory, array() - ); - } - - public function testMethodGetconnectionfactoryGetsDelegated() - { - $this->factory->expects($this->once()) - ->method('getConnectionFactory'); - $factory = new Horde_Kolab_Server_Factory_Mapped( - $this->factory, array() - ); - $factory->getConnectionFactory(); - } - - public function testMethodGetserverGetsDelegated() - { - $this->factory->expects($this->once()) - ->method('getServer') - ->will($this->returnValue($this->getMock('Horde_Kolab_Server'))); - $factory = new Horde_Kolab_Server_Factory_Mapped( - $this->factory, array() - ); - $factory->getServer(); - } - - public function testMethodGetconfigurationGetsDelegated() - { - $this->factory->expects($this->once()) - ->method('getConfiguration'); - $factory = new Horde_Kolab_Server_Factory_Mapped( - $this->factory, array() - ); - $factory->getConfiguration(); - } - - public function testMethodGetconnectionGetsDelegated() - { - $this->factory->expects($this->once()) - ->method('getConnection'); - $factory = new Horde_Kolab_Server_Factory_Mapped( - $this->factory, array() - ); - $factory->getConnection(); - } - - public function testMethodGetcompositeGetsDelegated() - { - $this->factory->expects($this->once()) - ->method('getComposite'); - $factory = new Horde_Kolab_Server_Factory_Mapped( - $this->factory, array() - ); - $factory->getComposite(); - } - - public function testMethodGetobjectsGetsDelegated() - { - $this->factory->expects($this->once()) - ->method('getObjects'); - $factory = new Horde_Kolab_Server_Factory_Mapped( - $this->factory, array() - ); - $factory->getObjects(); - } - - public function testMethodGetstructureGetsDelegated() - { - $this->factory->expects($this->once()) - ->method('getStructure'); - $factory = new Horde_Kolab_Server_Factory_Mapped( - $this->factory, array() - ); - $factory->getStructure(); - } - - public function testMethodGetsearchGetsDelegated() - { - $this->factory->expects($this->once()) - ->method('getSearch'); - $factory = new Horde_Kolab_Server_Factory_Mapped( - $this->factory, array() - ); - $factory->getSearch(); - } - - public function testMethodGetschemaGetsDelegated() - { - $this->factory->expects($this->once()) - ->method('getSchema'); - $factory = new Horde_Kolab_Server_Factory_Mapped( - $this->factory, array() - ); - $factory->getSchema(); - } -} \ No newline at end of file diff --git a/framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/Ldap/ChangesTest.php b/framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/Ldap/ChangesTest.php index a0c47bc69..fcbaf848e 100644 --- a/framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/Ldap/ChangesTest.php +++ b/framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/Ldap/ChangesTest.php @@ -35,21 +35,21 @@ class Horde_Kolab_Server_Class_Server_Ldap_ChangesTest extends PHPUnit_Framework public function testMethodConstructHasParameterServerobject() { $changes = new Horde_Kolab_Server_Ldap_Changes( - $this->getMock('Horde_Kolab_Server_Object'), array() + $this->getMock('Horde_Kolab_Server_Object_Interface'), array() ); } public function testMethodConstructHasParameterArrayDataToBeStored() { $changes = new Horde_Kolab_Server_Ldap_Changes( - $this->getMock('Horde_Kolab_Server_Object'), + $this->getMock('Horde_Kolab_Server_Object_Interface'), array('store' => 'value') ); } public function testMethodGetchangesetHasResultArrayEmptyIfOldAndNewDatasetsWereEmpty() { - $object = $this->getMock('Horde_Kolab_Server_Object'); + $object = $this->getMock('Horde_Kolab_Server_Object_Interface'); $object->expects($this->once()) ->method('readInternal') ->will($this->returnValue(array())); @@ -61,7 +61,7 @@ class Horde_Kolab_Server_Class_Server_Ldap_ChangesTest extends PHPUnit_Framework public function testMethodGetchangesetHasResultArrayEmptyIfOldAndNewDatasetsWereEqual() { - $object = $this->getMock('Horde_Kolab_Server_Object'); + $object = $this->getMock('Horde_Kolab_Server_Object_Interface'); $object->expects($this->once()) ->method('readInternal') ->will($this->returnValue(array('a' => array('a')))); @@ -73,7 +73,7 @@ class Horde_Kolab_Server_Class_Server_Ldap_ChangesTest extends PHPUnit_Framework public function testMethodGetchangesetHasResultArrayNewAttributesInNewDatasetAsAdded() { - $object = $this->getMock('Horde_Kolab_Server_Object'); + $object = $this->getMock('Horde_Kolab_Server_Object_Interface'); $object->expects($this->once()) ->method('readInternal') ->will($this->returnValue(array())); @@ -92,7 +92,7 @@ class Horde_Kolab_Server_Class_Server_Ldap_ChangesTest extends PHPUnit_Framework public function testMethodGetchangesetHasResultArrayMissingValuesInNewDatasetAsDeleted() { - $object = $this->getMock('Horde_Kolab_Server_Object'); + $object = $this->getMock('Horde_Kolab_Server_Object_Interface'); $object->expects($this->once()) ->method('readInternal') ->will($this->returnValue(array('old' => 'a'))); @@ -111,7 +111,7 @@ class Horde_Kolab_Server_Class_Server_Ldap_ChangesTest extends PHPUnit_Framework public function testMethodGetchangesetHasResultArraySingleValuesWithDifferencesAsReplaced() { - $object = $this->getMock('Horde_Kolab_Server_Object'); + $object = $this->getMock('Horde_Kolab_Server_Object_Interface'); $object->expects($this->once()) ->method('readInternal') ->will($this->returnValue(array('value' => 'a'))); @@ -130,7 +130,7 @@ class Horde_Kolab_Server_Class_Server_Ldap_ChangesTest extends PHPUnit_Framework public function testMethodGetchangesetHasResultArrayTheNewValuesAsAdded() { - $object = $this->getMock('Horde_Kolab_Server_Object'); + $object = $this->getMock('Horde_Kolab_Server_Object_Interface'); $object->expects($this->once()) ->method('readInternal') ->will($this->returnValue(array('value' => array('a', 'b', 'c')))); @@ -149,7 +149,7 @@ class Horde_Kolab_Server_Class_Server_Ldap_ChangesTest extends PHPUnit_Framework public function testMethodGetchangesetHasResultArrayTheRemovedValuesAsDeleted() { - $object = $this->getMock('Horde_Kolab_Server_Object'); + $object = $this->getMock('Horde_Kolab_Server_Object_Interface'); $object->expects($this->once()) ->method('readInternal') ->will($this->returnValue(array('value' => array('a', 'b', 'c')))); @@ -168,7 +168,7 @@ class Horde_Kolab_Server_Class_Server_Ldap_ChangesTest extends PHPUnit_Framework public function testMethodGetchangesetHasResultArrayTheNewValuesAsAddedAndTheRemovedValuesAsDeleted() { - $object = $this->getMock('Horde_Kolab_Server_Object'); + $object = $this->getMock('Horde_Kolab_Server_Object_Interface'); $object->expects($this->once()) ->method('readInternal') ->will($this->returnValue(array('value' => array('a', 'b', 'c')))); diff --git a/framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/LdapTest.php b/framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/LdapTest.php index 6316fe055..e6d7de9a5 100644 --- a/framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/LdapTest.php +++ b/framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/LdapTest.php @@ -265,9 +265,7 @@ class Horde_Kolab_Server_Class_Server_LdapTest extends Horde_Kolab_Server_LdapTe $entry = $this->getMock( 'Net_LDAP2_Entry', array(), array(), '', false ); - $object = $this->getMock( - 'Horde_Kolab_Server_Object', array(), array(), '', false - ); + $object = $this->getMock('Horde_Kolab_Server_Object_Interface'); $this->ldap_write->expects($this->exactly(1)) ->method('getEntry') ->will($this->returnValue($entry)); @@ -285,9 +283,7 @@ class Horde_Kolab_Server_Class_Server_LdapTest extends Horde_Kolab_Server_LdapTe $entry = $this->getMock( 'Net_LDAP2_Entry', array(), array(), '', false ); - $object = $this->getMock( - 'Horde_Kolab_Server_Object', array(), array(), '', false - ); + $object = $this->getMock('Horde_Kolab_Server_Object_Interface'); $this->ldap_write->expects($this->exactly(1)) ->method('getEntry') ->will($this->returnValue($entry)); @@ -305,9 +301,7 @@ class Horde_Kolab_Server_Class_Server_LdapTest extends Horde_Kolab_Server_LdapTe $entry = $this->getMock( 'Net_LDAP2_Entry', array(), array(), '', false ); - $object = $this->getMock( - 'Horde_Kolab_Server_Object', array(), array(), '', false - ); + $object = $this->getMock('Horde_Kolab_Server_Object_Interface'); $this->ldap_write->expects($this->exactly(1)) ->method('getEntry') ->will($this->returnValue($entry)); @@ -322,9 +316,7 @@ class Horde_Kolab_Server_Class_Server_LdapTest extends Horde_Kolab_Server_LdapTe public function testMethodSaveThrowsExceptionIfSavingDataFailed() { - $object = $this->getMock( - 'Horde_Kolab_Server_Object', array(), array(), '', false - ); + $object = $this->getMock('Horde_Kolab_Server_Object_Interface'); $this->ldap_write->expects($this->exactly(1)) ->method('modify') ->will($this->returnValue(new PEAR_Error('Saving failed!'))); @@ -342,9 +334,7 @@ class Horde_Kolab_Server_Class_Server_LdapTest extends Horde_Kolab_Server_LdapTe public function testMethodAddHasParameterObjectTheObjectToAddToTheServer() { - $object = $this->getMock( - 'Horde_Kolab_Server_Object', array(), array(), '', false - ); + $object = $this->getMock('Horde_Kolab_Server_Object_Interface'); $this->ldap_write->expects($this->exactly(1)) ->method('add') ->with(new PHPUnit_Framework_Constraint_IsInstanceOf('Net_LDAP2_Entry')); @@ -353,9 +343,7 @@ class Horde_Kolab_Server_Class_Server_LdapTest extends Horde_Kolab_Server_LdapTe public function testMethodAddHasParameterArrayData() { - $object = $this->getMock( - 'Horde_Kolab_Server_Object', array(), array(), '', false - ); + $object = $this->getMock('Horde_Kolab_Server_Object_Interface'); $this->ldap_write->expects($this->exactly(1)) ->method('add') ->with(new PHPUnit_Framework_Constraint_IsInstanceOf('Net_LDAP2_Entry')); @@ -364,9 +352,7 @@ class Horde_Kolab_Server_Class_Server_LdapTest extends Horde_Kolab_Server_LdapTe public function testMethodAddHasPostconditionThatTheEntryWasModified() { - $object = $this->getMock( - 'Horde_Kolab_Server_Object', array(), array(), '', false - ); + $object = $this->getMock('Horde_Kolab_Server_Object_Interface'); $this->ldap_write->expects($this->exactly(1)) ->method('add') ->with(new PHPUnit_Framework_Constraint_IsInstanceOf('Net_LDAP2_Entry')); @@ -375,9 +361,7 @@ class Horde_Kolab_Server_Class_Server_LdapTest extends Horde_Kolab_Server_LdapTe public function testMethodAddThrowsExceptionIfSavingDataFailed() { - $object = $this->getMock( - 'Horde_Kolab_Server_Object', array(), array(), '', false - ); + $object = $this->getMock('Horde_Kolab_Server_Object_Interface'); $this->ldap_write->expects($this->exactly(1)) ->method('add') ->will($this->returnValue(new PEAR_Error('Saving failed!'))); diff --git a/framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/LoggedTest.php b/framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/LoggedTest.php deleted file mode 100644 index f094ee9cc..000000000 --- a/framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/LoggedTest.php +++ /dev/null @@ -1,228 +0,0 @@ - - * @license http://www.fsf.org/copyleft/lgpl.html LGPL - * @link http://pear.horde.org/index.php?package=Kolab_Server - */ - -/** - * Prepare the test setup. - */ -require_once dirname(__FILE__) . '/../../Autoload.php'; - -/** - * Test the log decorator for the server. - * - * Copyright 2009 The Horde Project (http://www.horde.org/) - * - * See the enclosed file COPYING for license information (LGPL). If you - * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html. - * - * @category Kolab - * @package Kolab_Server - * @author Gunnar Wrobel - * @license http://www.fsf.org/copyleft/lgpl.html LGPL - * @link http://pear.horde.org/index.php?package=Kolab_Server - */ -class Horde_Kolab_Server_Class_Server_LoggedTest extends PHPUnit_Framework_TestCase -{ - public function setUp() - { - parent::setUp(); - - $this->logger = $this->getMock('Horde_Log_Logger'); - $this->server = $this->getMock('Horde_Kolab_Server'); - $this->logged = new Horde_Kolab_Server_Logged( - $this->server, $this->logger - ); - } - - public function testMethodGetbaseguidHasPostconditionThatTheCallWasDelegatedToTheServer() - { - $this->server->expects($this->exactly(1)) - ->method('getBaseGuid') - ->will($this->returnValue('base')); - $this->assertEquals('base', $this->logged->getBaseGuid()); - } - - public function testMethodGetuidHasPostconditionThatTheCallWasDelegatedToTheServer() - { - $this->server->expects($this->exactly(1)) - ->method('getGuid') - ->will($this->returnValue('guid')); - $this->assertEquals('guid', $this->logged->getGuid()); - } - - public function testMethodConnectguidHasPostconditionThatTheCallWasDelegatedToTheServer() - { - $this->server->expects($this->exactly(1)) - ->method('connectGuid') - ->with('user', 'pass'); - $this->logged->connectGuid('user', 'pass'); - } - - public function testMethodReadHasPostconditionThatTheCallWasDelegatedToTheServer() - { - $this->server->expects($this->exactly(1)) - ->method('read') - ->with('guid') - ->will($this->returnValue(array())); - $this->assertEquals(array(), $this->logged->read('guid')); - } - - public function testMethodReadattributesHasPostconditionThatTheCallWasDelegatedToTheServer() - { - $this->server->expects($this->exactly(1)) - ->method('readAttributes') - ->with('guid', array('a')) - ->will($this->returnValue(array())); - $this->assertEquals( - array(), $this->logged->readAttributes('guid', array('a')) - ); - } - - public function testMethodFindHasPostconditionThatTheCallWasDelegatedToTheServer() - { - $result = $this->getMock('Horde_Kolab_Server_Result'); - $query = $this->getMock( - 'Horde_Kolab_Server_Query_Element', array(), array(), '', false - ); - $this->server->expects($this->exactly(1)) - ->method('find') - ->with($query) - ->will($this->returnValue($result)); - $this->assertType( - 'Horde_Kolab_Server_Result', - $this->logged->find($query) - ); - } - - public function testMethodFindbelowHasPostconditionThatTheCallWasDelegatedToTheServer() - { - $result = $this->getMock('Horde_Kolab_Server_Result'); - $query = $this->getMock( - 'Horde_Kolab_Server_Query_Element', array(), array(), '', false - ); - $this->server->expects($this->exactly(1)) - ->method('findBelow') - ->with($query, 'none') - ->will($this->returnValue($result)); - $this->assertType( - 'Horde_Kolab_Server_Result', - $this->logged->findBelow($query, 'none') - ); - } - - public function testMethodSaveHasPostconditionThatTheCallWasDelegatedToTheServer() - { - $object = $this->getMock( - 'Horde_Kolab_Server_Object', array(), array(), '', false - ); - $this->server->expects($this->exactly(1)) - ->method('save') - ->with($object, array('a' => 'a')); - $this->logged->save($object, array('a' => 'a')); - } - - public function testMethodAddHasPostconditionThatTheCallWasDelegatedToTheServer() - { - $object = $this->getMock( - 'Horde_Kolab_Server_Object', array(), array(), '', false - ); - $this->server->expects($this->exactly(1)) - ->method('add') - ->with($object, array('a' => 'a')); - $this->logged->add($object, array('a' => 'a')); - } - - public function testMethodDeleteHasPostconditionThatTheCallWasDelegatedToTheServer() - { - $this->server->expects($this->exactly(1)) - ->method('delete') - ->with('a'); - $this->logged->delete('a'); - } - - public function testMethodRenameHasPostconditionThatTheCallWasDelegatedToTheServer() - { - $this->server->expects($this->exactly(1)) - ->method('rename') - ->with('a', 'b'); - $this->logged->rename('a', 'b'); - } - - public function testMethodGetschemaHasPostconditionThatTheCallWasDelegatedToTheServer() - { - $this->server->expects($this->exactly(1)) - ->method('getSchema'); - $this->logged->getSchema(); - } - - public function testMethodSaveHasPostconditionThatTheEventWasLogged() - { - $object = $this->getMock( - 'Horde_Kolab_Server_Object', array(), array(), '', false - ); - $object->expects($this->once()) - ->method('getGuid') - ->will($this->returnValue('a')); - $this->logger->expects($this->once()) - ->method('__call') - ->with( - 'info', array('The object "a" has been successfully saved!') - ); - $this->logged->save($object, array('a' => 'a')); - } - - public function testMethodAddHasPostconditionThatTheEventWasLogged() - { - $object = $this->getMock( - 'Horde_Kolab_Server_Object', array(), array(), '', false - ); - $object->expects($this->once()) - ->method('getGuid') - ->will($this->returnValue('a')); - $this->logger->expects($this->once()) - ->method('__call') - ->with( - 'info', array('The object "a" has been successfully added!') - ); - $this->logged->add($object, array('a' => 'a')); - } - - public function testMethodDeleteHasPostconditionThatTheEventWasLogged() - { - $this->logger->expects($this->once()) - ->method('__call') - ->with( - 'info', array('The object "a" has been successfully deleted!') - ); - $this->logged->delete('a'); - } - - public function testMethodRenameHasPostconditionThatTheEventWasLogged() - { - $this->logger->expects($this->once()) - ->method('__call') - ->with( - 'info', - array('The object "a" has been successfully renamed to "b"!') - ); - $this->logged->rename('a', 'b'); - } - - public function testMethodGetparentguidHasPostconditionThatTheCallWasDelegatedToTheServer() - { - $this->server->expects($this->exactly(1)) - ->method('getParentGuid') - ->will($this->returnValue('parent')); - $this->assertEquals('parent', $this->logged->getParentGuid('child')); - } - -} \ No newline at end of file diff --git a/framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/Object/Attribute/BaseTest.php b/framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/Object/Attribute/BaseTest.php index 0b10da10d..043060f5d 100644 --- a/framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/Object/Attribute/BaseTest.php +++ b/framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/Object/Attribute/BaseTest.php @@ -36,7 +36,7 @@ extends Horde_Kolab_Server_TestCase public function setUp() { $this->object = $this->getMock( - 'Horde_Kolab_Server_Object', array(), array(), '', false + 'Horde_Kolab_Server_Object_Interface' ); $this->composite = $this->getMockedComposite(); } @@ -54,13 +54,16 @@ extends Horde_Kolab_Server_TestCase public function testMethodGetobjectReturnsObjectAssociatedWithThisAttribute() { $attribute = new Attribute_Mock($this->object, $this->composite, ''); - $this->assertType('Horde_Kolab_Server_Object', $attribute->getObject()); + $this->assertType( + 'Horde_Kolab_Server_Object_Interface', + $attribute->getObject() + ); } public function testMethodGetnameReturnsStringTheNameOfTheAttribute() { $this->composite->structure->expects($this->exactly(1)) - ->method('getInternalAttribute') + ->method('mapExternalToInternalAttribute') ->with('name') ->will($this->returnValue('name')); $attribute = new Attribute_Mock($this->object, $this->composite, 'name'); diff --git a/framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/Object/BaseTest.php b/framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/Object/BaseTest.php index 26932b5c7..32e2a8b21 100644 --- a/framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/Object/BaseTest.php +++ b/framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/Object/BaseTest.php @@ -74,7 +74,7 @@ class Horde_Kolab_Server_Class_Server_Object_BaseTest extends Horde_Kolab_Server $composite = $this->getMockedComposite(); $composite->schema->expects($this->once()) ->method('getExternalAttributes') - ->with($this->isInstanceOf('Horde_Kolab_Server_Object')) + ->with($this->isInstanceOf('Horde_Kolab_Server_Object_Interface')) ->will($this->returnValue(array('external'))); $object = new Object_Mock($composite, 'guid'); $this->assertEquals(array('external'), $object->getExternalAttributes()); @@ -85,7 +85,7 @@ class Horde_Kolab_Server_Class_Server_Object_BaseTest extends Horde_Kolab_Server $composite = $this->getMockedComposite(); $composite->schema->expects($this->once()) ->method('getInternalAttributes') - ->with($this->isInstanceOf('Horde_Kolab_Server_Object')) + ->with($this->isInstanceOf('Horde_Kolab_Server_Object_Interface')) ->will($this->returnValue(array('internal' => 'Internal'))); $object = new Object_Mock($composite, 'guid'); $this->assertEquals(array('internal' => 'Internal'), $object->getInternalAttributes()); @@ -103,7 +103,7 @@ class Horde_Kolab_Server_Class_Server_Object_BaseTest extends Horde_Kolab_Server $composite = $this->getMockedComposite(); $composite->schema->expects($this->once()) ->method('getInternalAttributes') - ->with($this->isInstanceOf('Horde_Kolab_Server_Object')) + ->with($this->isInstanceOf('Horde_Kolab_Server_Object_Interface')) ->will($this->returnValue(array('internal' => 'Internal'))); $composite->server->expects($this->once()) ->method('readAttributes') @@ -118,7 +118,7 @@ class Horde_Kolab_Server_Class_Server_Object_BaseTest extends Horde_Kolab_Server $composite = $this->getMockedComposite(); $composite->schema->expects($this->once()) ->method('getInternalAttributes') - ->with($this->isInstanceOf('Horde_Kolab_Server_Object')) + ->with($this->isInstanceOf('Horde_Kolab_Server_Object_Interface')) ->will($this->returnValue(array('internal' => 'Internal'))); $composite->server->expects($this->once()) ->method('readAttributes') @@ -133,7 +133,7 @@ class Horde_Kolab_Server_Class_Server_Object_BaseTest extends Horde_Kolab_Server $composite = $this->getMockedComposite(); $composite->schema->expects($this->once()) ->method('getInternalAttributes') - ->with($this->isInstanceOf('Horde_Kolab_Server_Object')) + ->with($this->isInstanceOf('Horde_Kolab_Server_Object_Interface')) ->will($this->returnValue(array('internal' => 'Internal'))); $composite->server->expects($this->once()) ->method('readAttributes') @@ -150,7 +150,7 @@ class Horde_Kolab_Server_Class_Server_Object_BaseTest extends Horde_Kolab_Server $composite = $this->getMockedComposite(); $composite->schema->expects($this->exactly(2)) ->method('getInternalAttributes') - ->with($this->isInstanceOf('Horde_Kolab_Server_Object')) + ->with($this->isInstanceOf('Horde_Kolab_Server_Object_Interface')) ->will($this->returnValue(array('internal' => 'Internal'))); $composite->server->expects($this->once()) ->method('readAttributes') @@ -167,7 +167,7 @@ class Horde_Kolab_Server_Class_Server_Object_BaseTest extends Horde_Kolab_Server $composite = $this->getMockedComposite(); $composite->schema->expects($this->once()) ->method('getInternalAttributes') - ->with($this->isInstanceOf('Horde_Kolab_Server_Object')) + ->with($this->isInstanceOf('Horde_Kolab_Server_Object_Interface')) ->will($this->returnValue(array('internal' => 'Internal'))); $object = new Object_Mock($composite, 'guid'); try { @@ -183,7 +183,7 @@ class Horde_Kolab_Server_Class_Server_Object_BaseTest extends Horde_Kolab_Server $composite = $this->getMockedComposite(); $composite->schema->expects($this->exactly(2)) ->method('getInternalAttributes') - ->with($this->isInstanceOf('Horde_Kolab_Server_Object')) + ->with($this->isInstanceOf('Horde_Kolab_Server_Object_Interface')) ->will( $this->returnValue( array('internal' => 'Internal', 'test' => 'Test') @@ -206,16 +206,16 @@ class Horde_Kolab_Server_Class_Server_Object_BaseTest extends Horde_Kolab_Server { $composite = $this->getMockedComposite(); $composite->structure->expects($this->exactly(1)) - ->method('getInternalAttribute') + ->method('mapExternalToInternalAttribute') ->with('Objectclass') ->will($this->returnValue('objectClass')); $composite->schema->expects($this->exactly(1)) ->method('getExternalAttributes') - ->with($this->isInstanceOf('Horde_Kolab_Server_Object')) + ->with($this->isInstanceOf('Horde_Kolab_Server_Object_Interface')) ->will($this->returnValue(array('Objectclass'))); $composite->schema->expects($this->exactly(2)) ->method('getInternalAttributes') - ->with($this->isInstanceOf('Horde_Kolab_Server_Object')) + ->with($this->isInstanceOf('Horde_Kolab_Server_Object_Interface')) ->will($this->returnValue(array('objectClass' => 'Objectclass'))); $composite->server->expects($this->once()) ->method('readAttributes') @@ -232,7 +232,7 @@ class Horde_Kolab_Server_Class_Server_Object_BaseTest extends Horde_Kolab_Server $composite = $this->getMockedComposite(); $composite->schema->expects($this->once()) ->method('getExternalAttributes') - ->with($this->isInstanceOf('Horde_Kolab_Server_Object')) + ->with($this->isInstanceOf('Horde_Kolab_Server_Object_Interface')) ->will($this->returnValue(array('external'))); $object = new Object_Mock($composite, 'guid'); try { @@ -248,7 +248,7 @@ class Horde_Kolab_Server_Class_Server_Object_BaseTest extends Horde_Kolab_Server $composite = $this->getMockedComposite(); $composite->schema->expects($this->once()) ->method('getExternalAttributes') - ->with($this->isInstanceOf('Horde_Kolab_Server_Object')) + ->with($this->isInstanceOf('Horde_Kolab_Server_Object_Interface')) ->will($this->returnValue(array('Test'))); $object = new Object_Mock($composite, 'guid'); try { @@ -274,7 +274,7 @@ class Horde_Kolab_Server_Class_Server_Object_BaseTest extends Horde_Kolab_Server $composite = $this->getMockedComposite(); $composite->schema->expects($this->exactly(3)) ->method('getInternalAttributes') - ->with($this->isInstanceOf('Horde_Kolab_Server_Object')) + ->with($this->isInstanceOf('Horde_Kolab_Server_Object_Interface')) ->will( $this->returnValue( array( @@ -295,12 +295,12 @@ class Horde_Kolab_Server_Class_Server_Object_BaseTest extends Horde_Kolab_Server { $composite = $this->getMockedComposite(); $composite->structure->expects($this->exactly(1)) - ->method('getInternalAttribute') + ->method('mapExternalToInternalAttribute') ->with('Objectclass') ->will($this->returnValue('objectClass')); $composite->schema->expects($this->exactly(1)) ->method('getInternalAttributes') - ->with($this->isInstanceOf('Horde_Kolab_Server_Object')) + ->with($this->isInstanceOf('Horde_Kolab_Server_Object_Interface')) ->will( $this->returnValue( array( @@ -324,7 +324,7 @@ class Horde_Kolab_Server_Class_Server_Object_BaseTest extends Horde_Kolab_Server ); $composite->server->expects($this->exactly(1)) ->method('add') - ->with($this->isInstanceOf('Horde_Kolab_Server_Object'), array('objectClass' => array('top'))); + ->with($this->isInstanceOf('Horde_Kolab_Server_Object_Interface'), array('objectClass' => array('top'))); $object = new Object_Mock($composite); $object->save(array('Objectclass' => 'top')); } diff --git a/framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/Query/LdapTest.php b/framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/Query/LdapTest.php index 9b5d05aa2..dd669a3f7 100644 --- a/framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/Query/LdapTest.php +++ b/framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/Query/LdapTest.php @@ -40,7 +40,6 @@ class Horde_Kolab_Server_Class_Server_Query_LdapTest extends Horde_Kolab_Server_ ); } - public function testMethodConstructHasParameterQueryelementTheQueryCriteria() { $equals = new Horde_Kolab_Server_Query_Element_Equals('equals', 'equals'); @@ -50,7 +49,7 @@ class Horde_Kolab_Server_Class_Server_Query_LdapTest extends Horde_Kolab_Server_ public function testMethodConstructHasPostconditionThatTheQueryCriteriaWereSaved() { $this->structure->expects($this->once()) - ->method('getInternalAttribute') + ->method('mapExternalToInternalAttribute') ->will($this->returnValue('equals')); $equals = new Horde_Kolab_Server_Query_Element_Equals('equals', 'equals'); $query = new Horde_Kolab_Server_Query_Ldap($equals, $this->structure); @@ -63,7 +62,7 @@ class Horde_Kolab_Server_Class_Server_Query_LdapTest extends Horde_Kolab_Server_ public function testMethodTostringHasResultStringTheQuery() { $this->structure->expects($this->exactly(2)) - ->method('getInternalAttribute') + ->method('mapExternalToInternalAttribute') ->will($this->returnValue('internal')); $equals = new Horde_Kolab_Server_Query_Element_Equals('equals', 'equals'); $contains = new Horde_Kolab_Server_Query_Element_Equals('contains', 'contains'); @@ -78,7 +77,7 @@ class Horde_Kolab_Server_Class_Server_Query_LdapTest extends Horde_Kolab_Server_ public function testMethodConvertequealsHasResultNetldapfilter() { $this->structure->expects($this->once()) - ->method('getInternalAttribute') + ->method('mapExternalToInternalAttribute') ->will($this->returnValue('equals')); $equals = new Horde_Kolab_Server_Query_Element_Equals('equals', 'equals'); $query = new Horde_Kolab_Server_Query_Ldap($equals, $this->structure); @@ -91,7 +90,7 @@ class Horde_Kolab_Server_Class_Server_Query_LdapTest extends Horde_Kolab_Server_ public function testMethodConvertbeginsHasResultNetldapfilter() { $this->structure->expects($this->once()) - ->method('getInternalAttribute') + ->method('mapExternalToInternalAttribute') ->will($this->returnValue('begins')); $begins = new Horde_Kolab_Server_Query_Element_Begins('begins', 'begins'); $query = new Horde_Kolab_Server_Query_Ldap($begins, $this->structure); @@ -104,7 +103,7 @@ class Horde_Kolab_Server_Class_Server_Query_LdapTest extends Horde_Kolab_Server_ public function testMethodConvertendsHasResultNetldapfilter() { $this->structure->expects($this->once()) - ->method('getInternalAttribute') + ->method('mapExternalToInternalAttribute') ->will($this->returnValue('ends')); $ends = new Horde_Kolab_Server_Query_Element_Ends('ends', 'ends'); $query = new Horde_Kolab_Server_Query_Ldap($ends, $this->structure); @@ -117,7 +116,7 @@ class Horde_Kolab_Server_Class_Server_Query_LdapTest extends Horde_Kolab_Server_ public function testMethodConvertcontainsHasResultNetldapfilter() { $this->structure->expects($this->once()) - ->method('getInternalAttribute') + ->method('mapExternalToInternalAttribute') ->will($this->returnValue('contains')); $contains = new Horde_Kolab_Server_Query_Element_Contains('contains', 'contains'); $query = new Horde_Kolab_Server_Query_Ldap($contains, $this->structure); @@ -130,7 +129,7 @@ class Horde_Kolab_Server_Class_Server_Query_LdapTest extends Horde_Kolab_Server_ public function testMethodConvertlessHasResultNetldapfilter() { $this->structure->expects($this->once()) - ->method('getInternalAttribute') + ->method('mapExternalToInternalAttribute') ->will($this->returnValue('less')); $less = new Horde_Kolab_Server_Query_Element_Less('less', 'less'); $query = new Horde_Kolab_Server_Query_Ldap($less, $this->structure); @@ -143,7 +142,7 @@ class Horde_Kolab_Server_Class_Server_Query_LdapTest extends Horde_Kolab_Server_ public function testMethodConvertgreaterHasResultNetldapfilter() { $this->structure->expects($this->once()) - ->method('getInternalAttribute') + ->method('mapExternalToInternalAttribute') ->will($this->returnValue('greater')); $greater = new Horde_Kolab_Server_Query_Element_Greater('greater', 'greater'); $query = new Horde_Kolab_Server_Query_Ldap($greater, $this->structure); @@ -156,7 +155,7 @@ class Horde_Kolab_Server_Class_Server_Query_LdapTest extends Horde_Kolab_Server_ public function testMethodConvertapproxHasResultNetldapfilter() { $this->structure->expects($this->once()) - ->method('getInternalAttribute') + ->method('mapExternalToInternalAttribute') ->will($this->returnValue('approx')); $approx = new Horde_Kolab_Server_Query_Element_Approx('approx', 'approx'); $query = new Horde_Kolab_Server_Query_Ldap($approx, $this->structure); @@ -169,7 +168,7 @@ class Horde_Kolab_Server_Class_Server_Query_LdapTest extends Horde_Kolab_Server_ public function testMethodConvertnotHasResultNetldapfilter() { $this->structure->expects($this->once()) - ->method('getInternalAttribute') + ->method('mapExternalToInternalAttribute') ->will($this->returnValue('equals')); $equals = new Horde_Kolab_Server_Query_Element_Equals('equals', 'equals'); $not = new Horde_Kolab_Server_Query_Element_Not($equals, $this->structure); @@ -183,7 +182,7 @@ class Horde_Kolab_Server_Class_Server_Query_LdapTest extends Horde_Kolab_Server_ public function testMethodConvertandHasResultNetldapfilter() { $this->structure->expects($this->exactly(2)) - ->method('getInternalAttribute') + ->method('mapExternalToInternalAttribute') ->will($this->returnValue('internal')); $equals = new Horde_Kolab_Server_Query_Element_Equals('equals', 'equals'); $contains = new Horde_Kolab_Server_Query_Element_Equals('contains', 'contains'); @@ -198,7 +197,7 @@ class Horde_Kolab_Server_Class_Server_Query_LdapTest extends Horde_Kolab_Server_ public function testMethodConvertorHasResultNetldapfilter() { $this->structure->expects($this->exactly(2)) - ->method('getInternalAttribute') + ->method('mapExternalToInternalAttribute') ->will($this->returnValue('internal')); $equals = new Horde_Kolab_Server_Query_Element_Equals('equals', 'equals'); $contains = new Horde_Kolab_Server_Query_Element_Equals('contains', 'contains'); diff --git a/framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/Search/Operation/GuidTest.php b/framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/Search/Operation/GuidTest.php index fd268c64d..0f605a369 100644 --- a/framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/Search/Operation/GuidTest.php +++ b/framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/Search/Operation/GuidTest.php @@ -57,37 +57,41 @@ extends PHPUnit_Framework_TestCase public function testMethodSearchguidHasResultArrayTheGuidsOfTheSearchResult() { - $result = $this->getMock('Horde_Kolab_Server_Result'); + $result = $this->getMock('Horde_Kolab_Server_Result_Interface'); $result->expects($this->once()) ->method('asArray') ->will($this->returnValue(array('a' => 'a'))); $this->structure->expects($this->once()) ->method('find') ->with( - $this->isInstanceOf('Horde_Kolab_Server_Query_Element'), + $this->isInstanceOf( + 'Horde_Kolab_Server_Query_Element_Interface' + ), array('attributes' => 'Guid') ) ->will($this->returnValue($result)); $search = new Horde_Kolab_Server_Search_Operation_Guid($this->structure); - $criteria = $this->getMock('Horde_Kolab_Server_Query_Element'); + $criteria = $this->getMock('Horde_Kolab_Server_Query_Element_Interface'); $this->assertEquals(array('a'), $search->searchGuid($criteria)); } public function testMethodSearchguidHasResultArrayEmptyIfTheSearchReturnedNoResults() { - $result = $this->getMock('Horde_Kolab_Server_Result'); + $result = $this->getMock('Horde_Kolab_Server_Result_Interface'); $result->expects($this->once()) ->method('asArray') ->will($this->returnValue(array())); $this->structure->expects($this->once()) ->method('find') ->with( - $this->isInstanceOf('Horde_Kolab_Server_Query_Element'), + $this->isInstanceOf( + 'Horde_Kolab_Server_Query_Element_Interface' + ), array('attributes' => 'Guid') ) ->will($this->returnValue($result)); $search = new Horde_Kolab_Server_Search_Operation_Guid($this->structure); - $criteria = $this->getMock('Horde_Kolab_Server_Query_Element'); + $criteria = $this->getMock('Horde_Kolab_Server_Query_Element_Interface'); $this->assertEquals(array(), $search->searchGuid($criteria)); } } diff --git a/framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/Structure/KolabTest.php b/framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/Structure/KolabTest.php index 5930dcc74..1864e9e8e 100644 --- a/framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/Structure/KolabTest.php +++ b/framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/Structure/KolabTest.php @@ -34,13 +34,13 @@ class Horde_Kolab_Server_Class_Server_Structure_KolabTest extends PHPUnit_Framew { public function setUp() { - $server = $this->getMock('Horde_Kolab_Server'); - $this->composite = new Horde_Kolab_Server_Composite( + $server = $this->getMock('Horde_Kolab_Server_Interface'); + $this->composite = new Horde_Kolab_Server_Composite_Base( $server, - $this->getMock('Horde_Kolab_Server_Objects'), + $this->getMock('Horde_Kolab_Server_Objects_Interface'), new Horde_Kolab_Server_Structure_Kolab(), $this->getMock('Horde_Kolab_Server_Search_Interface'), - $this->getMock('Horde_Kolab_Server_Schema') + $this->getMock('Horde_Kolab_Server_Schema_Interface') ); } @@ -102,7 +102,7 @@ class Horde_Kolab_Server_Class_Server_Structure_KolabTest extends PHPUnit_Framew ); $this->composite->search->expects($this->exactly(1)) ->method('__call') - ->with('getGroups', array('guid')) + ->with('searchGroupsForMember', array('guid')) ->will( $this->returnValue( array( @@ -135,7 +135,7 @@ class Horde_Kolab_Server_Class_Server_Structure_KolabTest extends PHPUnit_Framew ->will($this->returnValue('base')); $this->composite->search->expects($this->exactly(1)) ->method('__call') - ->with('getGroups', array('guid')) + ->with('searchGroupsForMember', array('guid')) ->will( $this->returnValue( array( @@ -169,7 +169,7 @@ class Horde_Kolab_Server_Class_Server_Structure_KolabTest extends PHPUnit_Framew ->will($this->returnValue('base')); $this->composite->search->expects($this->exactly(1)) ->method('__call') - ->with('getGroups', array('guid')) + ->with('searchGroupsForMember', array('guid')) ->will( $this->returnValue( array( @@ -203,7 +203,7 @@ class Horde_Kolab_Server_Class_Server_Structure_KolabTest extends PHPUnit_Framew ->will($this->returnValue('base')); $this->composite->search->expects($this->exactly(1)) ->method('__call') - ->with('getGroups', array('guid')) + ->with('searchGroupsForMember', array('guid')) ->will( $this->returnValue( array( @@ -234,7 +234,7 @@ class Horde_Kolab_Server_Class_Server_Structure_KolabTest extends PHPUnit_Framew ); $this->composite->search->expects($this->exactly(1)) ->method('__call') - ->with('getGroups', array('guid,cn=external')) + ->with('searchGroupsForMember', array('guid,cn=external')) ->will( $this->returnValue( array( diff --git a/framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/Structure/LdapTest.php b/framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/Structure/LdapTest.php index ac4a9908b..8b3220de6 100644 --- a/framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/Structure/LdapTest.php +++ b/framework/Kolab_Server/test/Horde/Kolab/Server/Class/Server/Structure/LdapTest.php @@ -34,13 +34,13 @@ class Horde_Kolab_Server_Class_Server_Structure_LdapTest extends Horde_Kolab_Ser { public function setUp() { - $server = $this->getMock('Horde_Kolab_Server'); - $this->composite = new Horde_Kolab_Server_Composite( + $server = $this->getMock('Horde_Kolab_Server_Interface'); + $this->composite = new Horde_Kolab_Server_Composite_Base( $server, - $this->getMock('Horde_Kolab_Server_Objects'), + $this->getMock('Horde_Kolab_Server_Objects_Interface'), new Horde_Kolab_Server_Structure_Ldap(), $this->getMock('Horde_Kolab_Server_Search_Interface'), - $this->getMock('Horde_Kolab_Server_Schema') + $this->getMock('Horde_Kolab_Server_Schema_Interface') ); } @@ -170,7 +170,7 @@ class Horde_Kolab_Server_Class_Server_Structure_LdapTest extends Horde_Kolab_Ser { $structure = new Horde_Kolab_Server_Structure_Ldap(); try { - $structure->getInternalAttribute('undefined'); + $structure->mapExternalToInternalAttribute('undefined'); $this->fail('No exception!'); } catch (Horde_Kolab_Server_Exception $e) { $this->assertEquals( diff --git a/framework/Kolab_Server/test/Horde/Kolab/Server/TestCase.php b/framework/Kolab_Server/test/Horde/Kolab/Server/TestCase.php index a4a7bcd0f..6de7c27e1 100644 --- a/framework/Kolab_Server/test/Horde/Kolab/Server/TestCase.php +++ b/framework/Kolab_Server/test/Horde/Kolab/Server/TestCase.php @@ -35,28 +35,18 @@ class Horde_Kolab_Server_TestCase extends PHPUnit_Framework_TestCase protected function getComposite() { return $this->getMock( - 'Horde_Kolab_Server_Composite', array(), array(), '', false + 'Horde_Kolab_Server_Composite_Interface' ); } protected function getMockedComposite() { - return new Horde_Kolab_Server_Composite( - $this->getMock( - 'Horde_Kolab_Server', array(), array(), '', false - ), - $this->getMock( - 'Horde_Kolab_Server_Objects', array(), array(), '', false - ), - $this->getMock( - 'Horde_Kolab_Server_Structure_Interface', array(), array(), '', false - ), - $this->getMock( - 'Horde_Kolab_Server_Search_Interface', array(), array(), '', false - ), - $this->getMock( - 'Horde_Kolab_Server_Schema', array(), array(), '', false - ) + return new Horde_Kolab_Server_Composite_Base( + $this->getMock('Horde_Kolab_Server_Interface'), + $this->getMock('Horde_Kolab_Server_Objects_Interface'), + $this->getMock('Horde_Kolab_Server_Structure_Interface'), + $this->getMock('Horde_Kolab_Server_Search_Interface'), + $this->getMock('Horde_Kolab_Server_Schema_Interface') ); } } \ No newline at end of file