/**
  * create folder
  *
  * @param string|Felamimail_Model_Account $_accountId
  * @param string $_folderName to create
  * @param string $_parentFolder
  * @return Felamimail_Model_Folder
  * @throws Felamimail_Exception_IMAPServiceUnavailable
  */
 public function create($_accountId, $_folderName, $_parentFolder = '')
 {
     $account = $_accountId instanceof Felamimail_Controller_Account ? $_accountId : Felamimail_Controller_Account::getInstance()->get($_accountId);
     $this->_delimiter = $account->delimiter;
     $foldername = $this->_prepareFolderName($_folderName);
     $globalname = empty($_parentFolder) ? $foldername : $_parentFolder . $this->_delimiter . $foldername;
     if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) {
         Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' Trying to create new folder: ' . $globalname . ' (parent: ' . $_parentFolder . ')');
     }
     $imap = Felamimail_Backend_ImapFactory::factory($account);
     try {
         $imap->createFolder(Felamimail_Model_Folder::encodeFolderName($foldername), empty($_parentFolder) ? NULL : Felamimail_Model_Folder::encodeFolderName($_parentFolder), $this->_delimiter);
         // create new folder
         $folder = new Felamimail_Model_Folder(array('localname' => $foldername, 'globalname' => $globalname, 'account_id' => $account->getId(), 'parent' => $_parentFolder));
         $folder = $this->_backend->create($folder);
         if (Tinebase_Core::isLogLevel(Zend_Log::INFO)) {
             Tinebase_Core::getLogger()->info(__METHOD__ . '::' . __LINE__ . ' Create new folder: ' . $globalname);
         }
     } catch (Zend_Mail_Storage_Exception $zmse) {
         // perhaps the folder already exists
         if (Tinebase_Core::isLogLevel(Zend_Log::INFO)) {
             Tinebase_Core::getLogger()->info(__METHOD__ . '::' . __LINE__ . ' Could not create new folder: ' . $globalname . ' (' . $zmse->getMessage() . ')');
         }
         // reload folder cache of parent
         $parentSubs = $this->_cacheController->update($account, $_parentFolder);
         $folder = $parentSubs->filter('globalname', $globalname)->getFirstRecord();
         if ($folder === NULL) {
             throw new Felamimail_Exception_IMAPServiceUnavailable($zmse->getMessage());
         }
     }
     // update parent (has_children)
     $this->_updateHasChildren($_accountId, $_parentFolder, 1);
     return $folder;
 }