foreach ($generalError as $error => $errorParams) { ?> <tr class="<?php echo $odd ? "odd" : ""; ?> "> <?php $ex = new KalturaAPIException(null); call_user_func_array(array($ex, 'KalturaAPIException'), array_merge(array($error), $errorParams)); ?> <td><?php echo $ex->getCode(); ?> </td> <td><?php echo $ex->getMessage(); ?> </td> </tr> <?php $odd = !$odd; } ?> </table> <p> Example of an error Response </p> <pre> <?php echo htmlentities('
public function validateForUsage($sourceObject, $propertiesToSkip = array()) { $useableProperties = array(); $reflector = KalturaTypeReflectorCacher::get(get_class($this)); if (!$reflector) { KalturaLog::err("Unable to validate usage for attribute object type [" . get_class($this) . "], type reflector not found"); throw new KalturaAPIException(KalturaErrors::PROPERTY_VALIDATION_NO_USAGE_PERMISSION, get_class($this)); } $properties = $reflector->getProperties(); if ($reflector->requiresUsagePermission() && !kPermissionManager::getUsagePermitted(get_class($this), kApiParameterPermissionItem::ALL_VALUES_IDENTIFIER)) { throw new KalturaAPIException(KalturaErrors::PROPERTY_VALIDATION_NO_USAGE_PERMISSION, get_class($this)); } foreach ($properties as $property) { /* @var $property KalturaPropertyInfo */ $propertyName = $property->getName(); if ($propertiesToSkip && is_array($propertiesToSkip) && in_array($propertyName, $propertiesToSkip)) { continue; } if ($this->{$propertyName} !== null) { // check if property value is being changed - if not, just continue to the next $objectPropertyName = $this->getObjectPropertyName($propertyName); $getter_callback = array($sourceObject, "get{$objectPropertyName}"); if (is_callable($getter_callback)) { $value = call_user_func($getter_callback); if ($value === $this->{$propertyName} || is_bool($this->{$propertyName}) && $value === (int) $this->{$propertyName}) { continue; } } // property requires update permissions, verify that the current user has it if ($property->requiresUsagePermission()) { if (!kPermissionManager::getUsagePermitted($this->getDeclaringClassName($propertyName), $propertyName)) { //throw new KalturaAPIException(KalturaErrors::PROPERTY_VALIDATION_NO_UPDATE_PERMISSION, $this->getFormattedPropertyNameWithClassName($propertyName)); //TODO: not throwing exception to not break clients that sends -1 as null for integer values (etc...) $e = new KalturaAPIException(KalturaErrors::PROPERTY_VALIDATION_NO_USAGE_PERMISSION, $this->getFormattedPropertyNameWithClassName($propertyName)); $this->{$propertyName} = null; KalturaLog::err($this->getDeclaringClassName($propertyName) . '-' . $propertyName . ' error: ' . $e->getMessage()); header($this->getDeclaringClassName($propertyName) . '-' . $propertyName . ' error: ' . $e->getMessage()); } } } } return $useableProperties; }
public function initService($serviceId, $serviceName, $actionName) { // init service and action name $this->serviceId = $serviceId; $this->serviceName = $serviceName; $this->actionName = $actionName; // impersonated partner = partner parameter from the request $this->impersonatedPartnerId = kCurrentContext::$partner_id; $this->ks = kCurrentContext::$ks_object ? kCurrentContext::$ks_object : null; // operating partner = partner from the request or the ks partner $partnerId = kCurrentContext::$partner_id ? kCurrentContext::$partner_id : kCurrentContext::$ks_partner_id; // if there is no session, assume it's partner 0 using actions that doesn't require ks if (is_null($partnerId)) { $partnerId = 0; } $this->partner = PartnerPeer::retrieveByPK($partnerId); if (!$this->partner) { $this->partner = null; } // check if current aciton is allowed and if private partner data access is allowed $allowPrivatePartnerData = false; $actionPermitted = $this->isPermitted($allowPrivatePartnerData); // action not permitted at all, not even kaltura network if (!$actionPermitted) { $e = new KalturaAPIException(APIErrors::SERVICE_FORBIDDEN, $this->serviceId . '->' . $this->actionName); //TODO: should sometimes thorow MISSING_KS instead header("X-Kaltura:error-" . $e->getCode()); header("X-Kaltura-App: exiting on error " . $e->getCode() . " - " . $e->getMessage()); throw $e; } // init partner filter parameters $this->private_partner_data = $allowPrivatePartnerData; $this->partnerGroup = kPermissionManager::getPartnerGroup($this->serviceId, $this->actionName); if ($this->globalPartnerAllowed($this->actionName)) { $this->partnerGroup = PartnerPeer::GLOBAL_PARTNER . ',' . trim($this->partnerGroup, ','); } // apply partner filters according to current context and permissions myPartnerUtils::resetAllFilters(); myPartnerUtils::applyPartnerFilters($partnerId, $this->private_partner_data, $this->partnerGroup, $this->kalturaNetworkAllowed($this->actionName)); }
public function validateForUpdate($source_object) { $updatableProperties = array(); $reflector = KalturaTypeReflectorCacher::get(get_class($this)); $properties = $reflector->getProperties(); if ($reflector->requiresUpdatePermission() && !kPermissionManager::getUpdatePermitted(get_class($this), kApiParameterPermissionItem::ALL_VALUES_IDENTIFIER)) { throw new KalturaAPIException(KalturaErrors::PROPERTY_VALIDATION_NO_UPDATE_PERMISSION, get_class($this)); } foreach ($properties as $property) { $propertyName = $property->getName(); if ($this->{$propertyName} !== null) { // check if property value is being changed - if not, just continue to the next $objectPropertyName = $this->getObjectPropertyName($propertyName); $getter_callback = array($source_object, "get{$objectPropertyName}"); if (is_callable($getter_callback)) { $value = call_user_func($getter_callback); if ($value === $this->{$propertyName}) { continue; } } if ($property->isReadOnly() || $property->isInsertOnly()) { throw new KalturaAPIException(KalturaErrors::PROPERTY_VALIDATION_NOT_UPDATABLE, $this->getFormattedPropertyNameWithClassName($propertyName)); } // property requires update permissions, verify that the current user has it if ($property->requiresUpdatePermission()) { if (!kPermissionManager::getUpdatePermitted($this->getDeclaringClassName($propertyName), $propertyName)) { //throw new KalturaAPIException(KalturaErrors::PROPERTY_VALIDATION_NO_UPDATE_PERMISSION, $this->getFormattedPropertyNameWithClassName($propertyName)); //TODO: not throwing exception to not break clients that sends -1 as null for integer values (etc...) $e = new KalturaAPIException(KalturaErrors::PROPERTY_VALIDATION_NO_UPDATE_PERMISSION, $this->getFormattedPropertyNameWithClassName($propertyName)); $this->{$propertyName} = null; header($this->getDeclaringClassName($propertyName) . '-' . $propertyName . ' error: ' . $e->getMessage()); } } } } return $updatableProperties; }