--- /dev/null
+<?php
+/**
+ * A cache decorator for the Kolab storage handler.
+ *
+ * PHP version 5
+ *
+ * @category Kolab
+ * @package Kolab_Storage
+ * @author Gunnar Wrobel <wrobel@pardus.de>
+ * @license http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @link http://pear.horde.org/index.php?package=Kolab_Storage
+ */
+
+/**
+ * A cache decorator for the Kolab storage handler.
+ *
+ * Copyright 2004-2010 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_Storage
+ * @author Gunnar Wrobel <wrobel@pardus.de>
+ * @license http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @link http://pear.horde.org/index.php?package=Kolab_Storage
+ */
+class Horde_Kolab_Storage_Decorator_Cache
+implements Horde_Kolab_Storage
+{
+ /**
+ * The decorated storage handler.
+ *
+ * @var Horde_Kolab_Storage
+ */
+ private $_storage;
+
+ /**
+ * The cache.
+ *
+ * @var Horde_Kolab_Storage_Cache
+ */
+ private $_cache;
+
+ /**
+ * Constructor.
+ *
+ * @param Horde_Kolab_Storage $storage The storage handler.
+ * @param Horde_Kolab_Storage_Cache $cache The cache.
+ */
+ public function __construct(
+ Horde_Kolab_Storage $storage,
+ Horde_Kolab_Storage_Cache $cache
+ ) {
+ $this->_storage = $storage;
+ $this->_cache = $cache;
+ }
+
+ /**
+ * Get the folder list object.
+ *
+ * @return Horde_Kolab_Storage_List The handler for the list of folders
+ * present in the Kolab backend.
+ */
+ public function getList()
+ {
+ return new Horde_Kolab_Storage_List_Decorator_Cache(
+ $this->_storage->getList(),
+ $this->_cache
+ );
+ }
+
+ /**
+ * Get a Folder object.
+ *
+ * @param string $folder The folder name.
+ *
+ * @return Horde_Kolab_Storage_Folder The Kolab folder object.
+ */
+ public function getFolder($folder)
+ {
+ return $this->_storage->getFolder();
+ }
+
+ /**
+ * Return a data handler for accessing data in the specified
+ * folder.
+ *
+ * @param string $folder The name of the folder.
+ * @param string $type The type of data we want to
+ * access in the folder.
+ *
+ * @return Horde_Kolab_Data The data object.
+ */
+ public function getData($folder, $type)
+ {
+ return $this->_storage->getData();
+ }
+
+}
\ No newline at end of file
--- /dev/null
+<?php
+/**
+ * The cache decorator for folder lists from Kolab storage.
+ *
+ * PHP version 5
+ *
+ * @category Kolab
+ * @package Kolab_Storage
+ * @author Gunnar Wrobel <wrobel@pardus.de>
+ * @license http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @link http://pear.horde.org/index.php?package=Kolab_Storage
+ */
+
+/**
+ * The cache decorator for folder lists from Kolab storage.
+ *
+ * Copyright 2010 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_Storage
+ * @author Gunnar Wrobel <wrobel@pardus.de>
+ * @license http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @link http://pear.horde.org/index.php?package=Kolab_Storage
+ */
+class Horde_Kolab_Storage_List_Decorator_Cache
+implements Horde_Kolab_Storage_List
+{
+ /**
+ * Decorated list handler.
+ *
+ * @var Horde_Kolab_Storage_List
+ */
+ private $_list;
+
+ /**
+ * The cache.
+ *
+ * @var Horde_Kolab_Storage_Cache
+ */
+ private $_cache;
+
+ /**
+ * Constructor.
+ *
+ * @param Horde_Kolab_Storage_List $list The original list handler.
+ * @param Horde_Kolab_Storage_Cache $cache The cache storing data for this
+ * decorator.
+ */
+ public function __construct(
+ Horde_Kolab_Storage_List $list,
+ Horde_Kolab_Storage_Cache $cache
+ ) {
+ $this->_list = $list;
+ $this->_cache = $cache;
+ }
+
+ /**
+ * Returns the list of folders visible to the current user.
+ *
+ * @return array The list of folders, represented as a list of strings.
+ */
+ public function listFolders()
+ {
+ $result = $this->_list->listFolders();
+ return $result;
+ }
+
+ /**
+ * Returns the folder types as associative array.
+ *
+ * @return array The list folder types with the folder names as key and the
+ * type as values.
+ */
+ public function listTypes()
+ {
+ $result = $this->_list->listTypes();
+ return $result;
+ }
+
+ /**
+ * Returns the folder type annotation as associative array.
+ *
+ * @return array The list folder types with the folder names as key and the
+ * type handler as values.
+ */
+ public function listFolderTypeAnnotations()
+ {
+ $result = $this->_list->listFolderTypeAnnotations();
+ return $result;
+ }
+
+ /**
+ * Return the specified query type.
+ *
+ * @param string $name The query name.
+ *
+ * @return Horde_Kolab_Storage_Query A query handler.
+ *
+ * @throws Horde_Kolab_Storage_Exception In case the requested query is not supported.
+ */
+ public function getQuery($name)
+ {
+ return $this->_list->getQueryWithParent($name, $this);
+ }
+
+}
\ No newline at end of file
<email>jan@horde.org</email>
<active>yes</active>
</lead>
- <date>2010-12-28</date>
- <time>22:52:37</time>
+ <date>2011-01-02</date>
+ <time>07:30:52</time>
<version>
<release>0.4.0</release>
<api>0.1.0</api>
<dir name="Kolab">
<dir name="Storage">
<dir name="Decorator">
+ <file name="Cache.php" role="php" />
<file name="Log.php" role="php" />
</dir> <!-- /lib/Horde/Kolab/Storage/Decorator -->
<dir name="Driver">
</dir> <!-- /lib/Horde/Kolab/Storage/Folder -->
<dir name="List">
<dir name="Decorator">
+ <file name="Cache.php" role="php" />
<file name="Log.php" role="php" />
</dir> <!-- /lib/Horde/Kolab/Storage/List/Decorator -->
<dir name="Query">
</dir> <!-- /test/Horde/Kolab/Storage/Server -->
<dir name="Unit">
<dir name="Decorator">
+ <file name="CacheTest.php" role="test" />
<file name="LogTest.php" role="test" />
</dir> <!-- /test/Horde/Kolab/Storage/Unit/Decorator -->
<dir name="Driver">
<install as="Horde/Kolab/Storage/Queriable.php" name="lib/Horde/Kolab/Storage/Queriable.php" />
<install as="Horde/Kolab/Storage/Query.php" name="lib/Horde/Kolab/Storage/Query.php" />
<install as="Horde/Kolab/Storage/Translation.php" name="lib/Horde/Kolab/Storage/Translation.php" />
+ <install as="Horde/Kolab/Storage/Decorator/Cache.php" name="lib/Horde/Kolab/Storage/Decorator/Cache.php" />
<install as="Horde/Kolab/Storage/Decorator/Log.php" name="lib/Horde/Kolab/Storage/Decorator/Log.php" />
<install as="Horde/Kolab/Storage/Driver/Base.php" name="lib/Horde/Kolab/Storage/Driver/Base.php" />
<install as="Horde/Kolab/Storage/Driver/Cclient.php" name="lib/Horde/Kolab/Storage/Driver/Cclient.php" />
<install as="Horde/Kolab/Storage/Folder/Permission/Element/Guest.php" name="lib/Horde/Kolab/Storage/Folder/Permission/Element/Guest.php" />
<install as="Horde/Kolab/Storage/Folder/Permission/Element/User.php" name="lib/Horde/Kolab/Storage/Folder/Permission/Element/User.php" />
<install as="Horde/Kolab/Storage/List/Base.php" name="lib/Horde/Kolab/Storage/List/Base.php" />
+ <install as="Horde/Kolab/Storage/List/Decorator/Cache.php" name="lib/Horde/Kolab/Storage/List/Decorator/Cache.php" />
<install as="Horde/Kolab/Storage/List/Decorator/Log.php" name="lib/Horde/Kolab/Storage/List/Decorator/Log.php" />
<install as="Horde/Kolab/Storage/List/Query/Base.php" name="lib/Horde/Kolab/Storage/List/Query/Base.php" />
<install as="locale/Horde_Kolab_Storage.pot" name="locale/Horde_Kolab_Storage.pot" />
<install as="Horde/Kolab/Storage/Server/DriverTest.php" name="test/Horde/Kolab/Storage/Server/DriverTest.php" />
<install as="Horde/Kolab/Storage/Unit/BaseTest.php" name="test/Horde/Kolab/Storage/Unit/BaseTest.php" />
<install as="Horde/Kolab/Storage/Unit/FactoryTest.php" name="test/Horde/Kolab/Storage/Unit/FactoryTest.php" />
+ <install as="Horde/Kolab/Storage/Unit/Decorator/CacheTest.php" name="test/Horde/Kolab/Storage/Unit/Decorator/CacheTest.php" />
<install as="Horde/Kolab/Storage/Unit/Decorator/LogTest.php" name="test/Horde/Kolab/Storage/Unit/Decorator/LogTest.php" />
<install as="Horde/Kolab/Storage/Unit/Driver/CclientTest.php" name="test/Horde/Kolab/Storage/Unit/Driver/CclientTest.php" />
<install as="Horde/Kolab/Storage/Unit/Driver/ImapTest.php" name="test/Horde/Kolab/Storage/Unit/Driver/ImapTest.php" />
<release>alpha</release>
<api>alpha</api>
</stability>
- <date>2010-12-28</date>
+ <date>2011-01-02</date>
<license uri="http://www.gnu.org/copyleft/lesser.html">LGPL</license>
<notes>
* Added namespace support (Bug #6691).
--- /dev/null
+<?php
+/**
+ * Test the cache decorator for the storage handler.
+ *
+ * PHP version 5
+ *
+ * @category Kolab
+ * @package Kolab_Storage
+ * @subpackage UnitTests
+ * @author Gunnar Wrobel <wrobel@pardus.de>
+ * @license http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @link http://pear.horde.org/index.php?package=Kolab_Storage
+ */
+
+/**
+ * Prepare the test setup.
+ */
+require_once dirname(__FILE__) . '/../../Autoload.php';
+
+/**
+ * Test the cache decorator for the storage handler.
+ *
+ * Copyright 2010 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_Storage
+ * @subpackage UnitTests
+ * @author Gunnar Wrobel <wrobel@pardus.de>
+ * @license http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @link http://pear.horde.org/index.php?package=Kolab_Storage
+ */
+class Horde_Kolab_Storage_Unit_Decorator_CacheTest
+extends Horde_Kolab_Storage_TestCase
+{
+ public function testDecoratedList()
+ {
+ $storage = new Horde_Kolab_Storage_Decorator_Cache(
+ new Horde_Kolab_Storage_Base(
+ $this->getNullMock(),
+ new Horde_Kolab_Storage_Factory()
+ ),
+ new Horde_Kolab_Storage_Cache(null)
+ );
+ $this->assertInstanceOf(
+ 'Horde_Kolab_Storage_List_Decorator_Cache',
+ $storage->getList()
+ );
+ }
+}