public function testServiceStorage()
 {
     $service = tao_models_classes_service_StateStorage::singleton();
     $userUri = LOCAL_NAMESPACE . '#inexistentTestUser';
     // is not set
     $this->assertFalse($service->has($userUri, 'testkey'));
     $value = $service->get($userUri, 'testkey');
     $this->assertNull($value);
     //  test set
     $this->assertTrue($service->set($userUri, 'testkey', 'testvalue'));
     $this->assertTrue($service->has($userUri, 'testkey'));
     $value = $service->get($userUri, 'testkey');
     $this->assertEqual($value, 'testvalue');
     //  test replace
     $this->assertTrue($service->set($userUri, 'testkey', 'testvalue2'));
     $this->assertTrue($service->has($userUri, 'testkey'));
     $value = $service->get($userUri, 'testkey');
     $this->assertEqual($value, 'testvalue2');
     //  test delete
     $this->assertTrue($service->del($userUri, 'testkey'));
     $this->assertFalse($service->has($userUri, 'testkey'));
     $value = $service->get($userUri, 'testkey');
     $this->assertNull($value);
     $this->assertFalse($service->del($userUri, 'testkey'));
 }
 public function index()
 {
     $userId = common_session_SessionManager::getSession()->getUserUri();
     if (is_null($userId)) {
         throw new common_exception_Error('No user is logged in');
     }
     $lang = common_session_SessionManager::getSession()->getDataLanguage();
     if ($this->hasRequestParameter('serviceCallId')) {
         $serviceCallId = $this->getRequestParameter('serviceCallId');
         $variableData = tao_models_classes_service_StateStorage::singleton()->get($userId, $serviceCallId);
         $this->setData('storageData', array('serial' => $serviceCallId, 'data' => is_null($variableData) ? array() : $variableData));
     }
     $directory = $this->getDirectory($this->getRequestParameter('itemPath'));
     $basepath = $directory->getPath();
     if (!file_exists($basepath . $lang) && file_exists($basepath . DEFAULT_LANG)) {
         $lang = DEFAULT_LANG;
     }
     $this->setData('itemPath', $directory->getPublicAccessUrl() . $lang . '/index.html');
     $this->setData('itemId', $this->getRequestParameter('itemUri'));
     $this->setData('resultServerEndpoint', $this->getResultServerEndpoint());
     $this->setData('resultServerParams', $this->getResultServerParams());
     $this->setData('client_timeout', $this->getClientTimeout());
     $this->setData('client_config_url', $this->getClientConfigUrl());
     $this->selectView();
 }
 /**
  * Stores extended state information
  * @param string $testSessionId
  * @param array $extra
  */
 protected function saveExtra($testSessionId, $extra)
 {
     self::$cache[$testSessionId] = $extra;
     $storageService = \tao_models_classes_service_StateStorage::singleton();
     $userUri = \common_session_SessionManager::getSession()->getUserUri();
     $storageService->set($userUri, self::STORAGE_PREFIX . $testSessionId, json_encode($extra));
 }
 public function run()
 {
     //set_time_limit(200);
     helpers_TimeOutHelper::setTimeOutLimit(helpers_TimeOutHelper::LONG);
     $processExecutionService = wfEngine_models_classes_ProcessExecutionService::singleton();
     $activityExecutionService = wfEngine_models_classes_ActivityExecutionService::singleton();
     $processDefinitionUri = $this->getRequestParameter('processDefinition');
     $processDefinition = new core_kernel_classes_Resource($processDefinitionUri);
     if (!$this->hasRequestParameter('serviceCallId')) {
         throw new common_exception_Error('No serviceCallId on service call');
     }
     $serviceService = tao_models_classes_service_StateStorage::singleton();
     $userUri = common_session_SessionManager::getSession()->getUserUri();
     $processExecutionUri = is_null($userUri) ? null : $serviceService->get($userUri, $this->getRequestParameter('serviceCallId'));
     if (is_null($processExecutionUri)) {
         $processExecName = $processDefinition->getLabel();
         $processExecComment = 'Created in Processes server on ' . date(DATE_ISO8601);
         if (isset($_REQUEST['processVariables']) && !empty($_REQUEST['processVariables'])) {
             $processVariables = json_decode($_REQUEST['processVariables'], true);
             $processVariables = is_array($processVariables) ? $processVariables : array();
         } else {
             // none provided
             $processVariables = array();
         }
         $newProcessExecution = $processExecutionService->createProcessExecution($processDefinition, $processExecName, $processExecComment, $processVariables);
         $processExecutionUri = $newProcessExecution->getUri();
         $serviceService->set($userUri, $this->getRequestParameter('serviceCallId'), $processExecutionUri);
     }
     $processExecution = new core_kernel_classes_Resource($processExecutionUri);
     //create nonce to initial activity executions:
     foreach ($processExecutionService->getCurrentActivityExecutions($processExecution) as $initialActivityExecution) {
         $activityExecutionService->createNonce($initialActivityExecution);
     }
     helpers_TimeOutHelper::reset();
     $param = array('processUri' => urlencode($processExecution->getUri()), 'standalone' => 'true');
     $this->redirect(tao_helpers_Uri::url('index', null, null, $param));
 }
 /**
  * Sets the state of a particular item
  * @param string $serviceCallId
  * @param array $state
  * @throws common_exception_Error
  */
 public static function setItemState($serviceCallId, $state)
 {
     tao_models_classes_service_StateStorage::singleton()->set(common_session_SessionManager::getSession()->getUserUri(), $serviceCallId, json_encode($state));
 }
 public function exists($sessionId)
 {
     $storageService = tao_models_classes_service_StateStorage::singleton();
     $userUri = common_session_SessionManager::getSession()->getUserUri();
     if (is_null($userUri) === true) {
         $msg = "Could not retrieve current user URI.";
         throw new StorageException($msg, StorageException::RETRIEVAL);
     }
     return $storageService->has($userUri, $sessionId);
 }
 /**
  * Gets the StateStorage service
  * @return \tao_models_classes_service_StateStorage
  */
 protected function getStorageService()
 {
     return \tao_models_classes_service_StateStorage::singleton();
 }
예제 #8
0
 /**
  * Stores the state of the current service call
  * 
  * @param string $state
  * @return boolean
  */
 protected function setState($state)
 {
     $serviceService = tao_models_classes_service_StateStorage::singleton();
     $userUri = common_session_SessionManager::getSession()->getUserUri();
     return is_null($userUri) ? false : $serviceService->set($userUri, $this->getServiceCallId(), $state);
 }
 public static function getServiceStorage($serviceCallId)
 {
     $state = tao_models_classes_service_StateStorage::singleton()->get(common_session_SessionManager::getSession()->getUserUri(), $serviceCallId);
     $submitUrl = _url('submitState', 'ServiceModule', 'tao', array('serviceCallId' => $serviceCallId));
     return 'new StateStorage(' . tao_helpers_Javascript::buildObject($state) . ', ' . tao_helpers_Javascript::buildObject($submitUrl) . ')';
 }