Beispiel #1
0
 /**
  * Update Category
  * 
  * @action update
  * @param int $id
  * @param KalturaCategory $category
  * @return KalturaCategory
  */
 function updateAction($id, KalturaCategory $category)
 {
     $categoryDb = categoryPeer::retrieveByPK($id);
     if (!$categoryDb) {
         throw new KalturaAPIException(KalturaErrors::CATEGORY_NOT_FOUND, $id);
     }
     if ($category->name !== null) {
         $category->validatePropertyMinLength("name", 1);
         $category->validatePropertyMaxLength("name", categoryPeer::MAX_CATEGORY_NAME);
     }
     if ($category->parentId !== null) {
         $category->validateParentId($category);
     }
     if ($this->getPartner()->isCategoriesLocked()) {
         throw new KalturaAPIException(KalturaErrors::CATEGORIES_LOCKED, Partner::CATEGORIES_LOCK_TIMEOUT);
     }
     try {
         $this->getPartner()->lockCategories();
         $category->toUpdatableObject($categoryDb);
         $categoryDb->save();
         $this->getPartner()->unlockCategories();
     } catch (Exception $ex) {
         $this->getPartner()->unlockCategories();
         if ($ex instanceof kCoreException) {
             $this->handleCoreException($ex, $categoryDb, $category);
         } else {
             throw $ex;
         }
     }
     $category = new KalturaCategory();
     $category->fromObject($categoryDb);
     return $category;
 }