private function _getNamespace($type, $prefix = null)
{
$matching = array();
foreach ($this->_namespaces as $namespace) {
if ($namespace->getType() == $type && ($prefix === null || $namespace->getName() === $prefix)) {
$matching[] = $namespace;
}
}
if (count($matching) == 1) {
return $matching[0];
} else {
if (count($matching) > 1) {
throw new Horde_Kolab_Storage_Exception('Multiple namespaces of the same type!');
} else {
throw new Horde_Kolab_Storage_Exception(sprintf('No namespace of the type %s%s!', $type, $prefix !== null ? ' with prefix \\"' . $prefix . '\\"' : ''));
}
}
}