/**
  * 
  * @param core_kernel_classes_Resource $resource
  * @param string $oldVersion
  * @param string $message
  * @param string $newVersion
  * @return \oat\taoRevision\model\Revision
  */
 public static function restore(core_kernel_classes_Resource $resource, $oldVersion, $message, $newVersion = null)
 {
     $lockManager = LockManager::getImplementation();
     if ($lockManager->isLocked($resource)) {
         $userId = common_session_SessionManager::getSession()->getUser()->getIdentifier();
         $lockManager->releaseLock($resource, $userId);
     }
     $oldRevision = RepositoryProxy::getRevision($resource->getUri(), $oldVersion);
     $success = RepositoryProxy::restore($oldRevision);
     if ($success) {
         $newVersion = is_null($newVersion) ? self::getNextVersion($resource->getUri()) : $newVersion;
         $newRevision = RevisionService::commit($resource, $message, $newVersion);
         return $newRevision;
     } else {
         throw \common_exception_Error('Unable to restore version ' . $oldVersion . ' of resource ' . $resource->getUri());
     }
 }
 private function findExtensionId($controllerClass)
 {
     if (strpos($controllerClass, '\\') === false) {
         $parts = explode('_', $controllerClass);
         if (count($parts) == 3) {
             return $parts[0];
         } else {
             throw common_exception_Error('Unknown controller ' . $controllerClass);
         }
     } else {
         foreach (common_ext_ExtensionsManager::singleton()->getEnabledExtensions() as $ext) {
             foreach ($ext->getManifest()->getRoutes() as $routePrefix => $namespace) {
                 if (is_string($namespace) && substr($controllerClass, 0, strlen($namespace)) == $namespace) {
                     return $ext->getId();
                 }
             }
         }
         throw new common_exception_Error('Unknown controller ' . $controllerClass);
     }
 }