/** * Short description of method init * * @access public * @author Sam * @param array configuration * @return boolean */ public function init($configuration) { parent::init($configuration); $this->data = array(); $this->archivers = array(); if (isset($configuration['local_server_comment'])) { $this->comment = strval($configuration['local_server_comment']); } foreach ($configuration['archivers'] as $archiverConfig) { if (isset($archiverConfig['class'])) { $classname = $archiverConfig['class']; if (!class_exists($classname)) { $classname = 'common_profiler_archiver_' . $classname; } if (class_exists($classname)) { $archiver = new $classname(); try { if ($archiver instanceof common_profiler_archiver_Archiver && !is_null($archiver) && $archiver->init($archiverConfig)) { $this->archivers[] = $archiver; } } catch (InvalidArgumentException $e) { common_Logger::w('archiver configuration issue: ' . $e->getMessage()); } } } } return true; }
public function initElements() { $class = $this->data['class']; if (!$class instanceof \core_kernel_classes_Class) { throw new \common_Exception('missing class in simple delivery creation form'); } $classUriElt = \tao_helpers_form_FormFactory::getElement('classUri', 'Hidden'); $classUriElt->setValue($class->getUri()); $this->form->addElement($classUriElt); //create the element to select the import format $formatElt = \tao_helpers_form_FormFactory::getElement('test', 'Combobox'); $formatElt->setDescription(__('Select the test you want to publish to the test-takers')); $testClass = new \core_kernel_classes_Class(TAO_TEST_CLASS); $options = array(); $testService = \taoTests_models_classes_TestsService::singleton(); foreach ($testClass->getInstances(true) as $test) { try { $testItems = $testService->getTestItems($test); //Filter tests which has no items if (!empty($testItems)) { $options[$test->getUri()] = $test->getLabel(); } } catch (\Exception $e) { \common_Logger::w('Unable to load items for test ' . $test->getUri()); } } if (empty($options)) { throw new NoTestsException(); } $formatElt->setOptions($options); $formatElt->addValidator(\tao_helpers_form_FormFactory::getValidator('NotEmpty')); $this->form->addElement($formatElt); }
/** * Log in a user into Generis that has one of the provided $allowedRoles. * * @access public * @author Jerome Bogaerts, <*****@*****.**> * @param string login The login of the user. * @param string password the md5 hash of the password. * @param allowedRoles A Role or an array of Roles that are allowed to be logged in. If the user has a Role that matches one or more Roles in this array, the login request will be accepted. * @return boolean */ public function login(common_user_auth_Adapter $adapter, $allowedRoles = array()) { $returnValue = (bool) false; try { $user = $adapter->authenticate(); if (!empty($allowedRoles)) { // Role can be either a scalar value or a collection. $allowedRoles = is_array($allowedRoles) ? $allowedRoles : array($allowedRoles); $roles = array(); foreach ($allowedRoles as $r) { $roles[] = $r instanceof core_kernel_classes_Resource ? $r->getUri() : $r; } unset($allowedRoles); $intersect = array_intersect($roles, $user->getRoles()); if (empty($intersect)) { common_Logger::w('User ' . $user->getIdentifier() . ' does not have the nescessary role'); return false; } } $returnValue = $this->startSession($user); } catch (common_user_auth_AuthFailedException $exception) { // failed return false; } return (bool) $returnValue; }
/** * Maps a fuly qualified or abbreviated lti role * to an existing tao role * * @param string $role * @throws common_Exception * @throws common_exception_Error * @return core_kernel_classes_Resource the tao role or null */ public static function mapLTIRole2TaoRole($role) { $taoRole = null; if (filter_var($role, FILTER_VALIDATE_URL)) { // url found $taoRole = new core_kernel_classes_Resource($role); } else { // if not fully qualified prepend LIS context role NS if (strtolower(substr($role, 0, 4)) !== 'urn:') { $role = self::LIS_CONTEXT_ROLE_NAMESPACE . $role; } list($prefix, $nid, $nss) = explode(':', $role, 3); if ($nid != 'lti') { common_Logger::w('Non LTI URN ' . $role . ' passed via LTI'); } $urn = 'urn:' . strtolower($nid) . ':' . $nss; // search for fitting role $class = new core_kernel_classes_Class(CLASS_LTI_ROLES); $cand = $class->searchInstances(array(PROPERTY_LTI_ROLES_URN => $urn)); if (count($cand) > 1) { throw new common_exception_Error('Multiple instances share the URN ' . $urn); } if (count($cand) == 1) { $taoRole = current($cand); } else { common_Logger::w('Unknown LTI role with urn: ' . $urn); } } if (!is_null($taoRole) && $taoRole->exists()) { return $taoRole->getUri(); } else { return null; } }
public function importDelivery(core_kernel_classes_Class $deliveryClass, $archiveFile) { $folder = tao_helpers_File::createTempDir(); $zip = new ZipArchive(); if ($zip->open($archiveFile) !== true) { return common_report_Report::createFailure(__('Unable to export Archive')); } $zip->extractTo($folder); $zip->close(); $manifestPath = $folder . self::MANIFEST_FILE; if (!file_exists($manifestPath)) { return common_report_Report::createFailure(__('Manifest not found in assembly')); } $manifest = json_decode(file_get_contents($manifestPath), true); try { $this->importDeliveryFiles($deliveryClass, $manifest, $folder); $delivery = $this->importDeliveryResource($deliveryClass, $manifest); $report = common_report_Report::createSuccess(__('Delivery "%s" successfully imported', $delivery->getUri()), $delivery); } catch (Exception $e) { common_Logger::w($e->getMessage()); if (isset($delivery) && $delivery instanceof core_kernel_classes_Resource) { $delivery->delete(); } $report = common_report_Report::createFailure(__('Unkown error during impoort')); } return $report; }
/** * * @param string $currentVersion * @return string $versionUpdatedTo */ public function update($initialVersion) { $currentVersion = $initialVersion; //migrate from 2.6 to 2.6.1 if ($currentVersion == '2.6') { //data upgrade OntologyUpdater::syncModels(); $currentVersion = '2.6.1'; } if ($currentVersion == '2.6.1') { $ext = \common_ext_ExtensionsManager::singleton()->getExtensionById('taoDelivery'); $className = $ext->getConfig(\taoDelivery_models_classes_execution_ServiceProxy::CONFIG_KEY); if (is_string($className)) { $impl = null; switch ($className) { case 'taoDelivery_models_classes_execution_OntologyService': $impl = new \taoDelivery_models_classes_execution_OntologyService(); break; case 'taoDelivery_models_classes_execution_KeyValueService': $impl = new \taoDelivery_models_classes_execution_KeyValueService(array(\taoDelivery_models_classes_execution_KeyValueService::OPTION_PERSISTENCE => 'deliveryExecution')); break; default: \common_Logger::w('Unable to migrate custom execution service'); } if (!is_null($impl)) { $proxy = \taoDelivery_models_classes_execution_ServiceProxy::singleton(); $proxy->setImplementation($impl); $currentVersion = '2.6.2'; } } } return $currentVersion; }
public static function buildDirectory(core_kernel_classes_Resource $test, $lang, $relPath = '/', $depth = 1, $filters = array()) { $baseDir = self::getBaseDir($test); $path = $baseDir . ltrim($relPath, '/'); $data = array('path' => $relPath); if ($depth > 0) { $children = array(); if (is_dir($path)) { foreach (new DirectoryIterator($path) as $fileinfo) { if (!$fileinfo->isDot()) { $subPath = rtrim($relPath, '/') . '/' . $fileinfo->getFilename(); if ($fileinfo->isDir()) { $children[] = self::buildDirectory($test, $lang, $subPath, $depth - 1, $filters); } else { $file = self::buildFile($test, $lang, $subPath, $filters); if (!is_null($file)) { $children[] = $file; } } } } } else { common_Logger::w('"' . $path . '" is not a directory'); } $data['children'] = $children; } else { $data['url'] = _url('files', 'TestContent', 'taoQtiTest', array('uri' => $test->getUri(), 'lang' => $lang, 'path' => $relPath)); } return $data; }
/** * Create a formatted failure report and log a warning * * @param $userMessage * @param null $model * @return Report */ private function createFailure($userMessage, $model = null) { $typeIdentifier = is_null($model) ? 'unknown type' : $model->getTypeIdentifier(); $message = 'The portable element cannot be registered "' . $typeIdentifier . '", reason: ' . $userMessage; \common_Logger::w($message); return Report::createFailure($message); }
public function isDeliveryExecutionAllowed(core_kernel_classes_Resource $delivery, User $user) { $userUri = $user->getIdentifier(); if (is_null($delivery)) { common_Logger::w("Attempt to start the compiled delivery " . $delivery->getUri() . " related to no delivery"); return false; } //first check the user is assigned if (!taoDelivery_models_classes_AssignmentService::singleton()->isUserAssigned($delivery, $user)) { common_Logger::w("User " . $userUri . " attempts to start the compiled delivery " . $delivery->getUri() . " he was not assigned to."); return false; } $settings = $this->getDeliverySettings($delivery); //check Tokens $usedTokens = count(taoDelivery_models_classes_execution_ServiceProxy::singleton()->getUserExecutions($delivery, $userUri)); if ($settings[TAO_DELIVERY_MAXEXEC_PROP] != 0 and $usedTokens >= $settings[TAO_DELIVERY_MAXEXEC_PROP]) { common_Logger::d("Attempt to start the compiled delivery " . $delivery->getUri() . "without tokens"); return false; } //check time $startDate = date_create('@' . $settings[TAO_DELIVERY_START_PROP]); $endDate = date_create('@' . $settings[TAO_DELIVERY_END_PROP]); if (!$this->areWeInRange($startDate, $endDate)) { common_Logger::d("Attempt to start the compiled delivery " . $delivery->getUri() . " at the wrong date"); return false; } return true; }
/** * (non-PHPdoc) * @see \oat\tao\model\media\MediaBrowser::getDirectory */ public function getDirectory($parentLink = '/', $acceptableMime = array(), $depth = 1) { $sysPath = $this->getSysPath($parentLink); $label = substr($parentLink, strrpos($parentLink, '/') + 1); if (!$label) { $label = 'local'; } $data = array('path' => $parentLink, 'label' => $label); if ($depth > 0) { $children = array(); if (is_dir($sysPath)) { foreach (new DirectoryIterator($sysPath) as $fileinfo) { if (!$fileinfo->isDot()) { $subPath = rtrim($parentLink, '/') . '/' . $fileinfo->getFilename(); if ($fileinfo->isDir()) { $children[] = $this->getDirectory($subPath, $acceptableMime, $depth - 1); } else { $file = $this->getFileInfo($subPath, $acceptableMime); if (!is_null($file) && (count($acceptableMime) == 0 || in_array($file['mime'], $acceptableMime))) { $children[] = $file; } } } } } else { common_Logger::w('"' . $sysPath . '" is not a directory'); } $data['children'] = $children; } else { $data['url'] = _url('files', 'ItemContent', 'taoItems', array('uri' => $this->item->getUri(), 'lang' => $this->lang, 'path' => $parentLink)); } return $data; }
public function getStrings($values) { $contentStrings = array(); $xmlTokenizer = new taoItems_models_classes_search_XmlItemContentTokenizer(); foreach ($values as $valueUri) { $file = new core_kernel_file_File($valueUri); try { $content = file_get_contents($file->getAbsolutePath()); if ($content === false) { common_Logger::w('File ' . $file->getAbsolutePath() . ' not found for item'); } else { // Try to make it a DOM Document... $dom = new DOMDocument('1.0', 'UTF-8'); if (@$dom->loadXML($content) === true) { $contentStrings = array_merge($contentStrings, $xmlTokenizer->getStrings($dom)); unset($dom); } else { common_Logger::d('Skipped non XML content for ' . $file->getUri()); } } } catch (common_Exception $exc) { common_Logger::w('Invalid file ' . $valueUri . ' for ItemContentTokenizer: ' . $exc->getMessage()); } } return $contentStrings; }
private function getUncached($property) { $value = array(); switch ($property) { case PROPERTY_USER_DEFLG: case PROPERTY_USER_UILG: $resource = $this->getUserResource()->getOnePropertyValue(new \core_kernel_classes_Property($property)); if (!is_null($resource)) { if ($resource instanceof \core_kernel_classes_Resource) { return array($resource->getUniquePropertyValue(new \core_kernel_classes_Property(RDF_VALUE))); } else { common_Logger::w('Language ' . $resource . ' is not a resource'); return array(DEFAULT_LANG); } } else { return array(DEFAULT_LANG); } break; case PROPERTY_USER_ROLES: return array("http://www.tao.lu/Ontologies/TAOItem.rdf#TestAuthor", "http://www.tao.lu/Ontologies/TAOItem.rdf#ItemAuthor"); case "http://www.tao.lu/Ontologies/TAO.rdf#FirstTimeInTao": return array("http://www.tao.lu/Ontologies/generis.rdf#False"); case "http://www.tao.lu/Ontologies/TAO.rdf#LastExtensionUsed": return array("tao/Main/index?structure=items&ext=taoItems"); default: return $this->getUserResource()->getPropertyValues(new \core_kernel_classes_Property($property)); } }
/** * Returns a json encoded array describign a directory * * @throws common_exception_MissingParameter * @return string */ public function files() { if (!$this->hasRequestParameter('uri')) { throw new common_exception_MissingParameter('uri', __METHOD__); } $testUri = $this->getRequestParameter('uri'); $test = new core_kernel_classes_Resource($testUri); if (!$this->hasRequestParameter('lang')) { throw new common_exception_MissingParameter('lang', __METHOD__); } $testLang = $this->getRequestParameter('lang'); $subPath = $this->hasRequestParameter('path') ? $this->getRequestParameter('path') : '/'; $depth = $this->hasRequestParameter('depth') ? $this->getRequestParameter('depth') : 1; //build filters $filters = array(); if ($this->hasRequestParameter('filters')) { $filterParameter = $this->getRequestParameter('filters'); if (!empty($filterParameter)) { if (preg_match('/\\/\\*/', $filterParameter)) { common_Logger::w('Stars mime type are not yet supported, filter "' . $filterParameter . '" will fail'); } $filters = array_map('trim', explode(',', $filterParameter)); } } $data = taoQtiTest_helpers_ResourceManager::buildDirectory($test, $testLang, $subPath, $depth, $filters); echo json_encode($data); }
/** * Verify that a given delivery execution is allowed to be executed * * @param DeliveryExecution $deliveryExecution * @param User $user * @throws \common_exception_Unauthorized */ public function verifyResumeAuthorization(DeliveryExecution $deliveryExecution, User $user) { $stateId = $deliveryExecution->getState()->getUri(); if (!in_array($stateId, $this->getResumableStates())) { \common_Logger::w('Unexpected state "' . $stateId); throw new \common_exception_Unauthorized(); } }
public static function getPersistence($driverId) { $returnValue = common_persistence_Manager::getPersistence($driverId); $class = get_called_class(); if (!$returnValue instanceof $class) { common_Logger::w('Got a ', get_class($returnValue) . ' instead of ' . $class); } return $returnValue; }
/** * Builds a simple Diagram of the Process * * @access public * @author Joel Bout, <*****@*****.**> * @param Resource process * @return string */ public static function buildDiagramData(core_kernel_classes_Resource $process) { $returnValue = (string) ''; common_Logger::i("Building diagram for " . $process->getLabel()); $authoringService = wfAuthoring_models_classes_ProcessService::singleton(); $activityService = wfEngine_models_classes_ActivityService::singleton(); $connectorService = wfEngine_models_classes_ConnectorService::singleton(); $activityCardinalityService = wfEngine_models_classes_ActivityCardinalityService::singleton(); $activities = $authoringService->getActivitiesByProcess($process); $todo = array(); foreach ($activities as $activity) { if ($activityService->isInitial($activity)) { $todo[] = $activity; } } $currentLevel = 0; $diagram = new wfAuthoring_models_classes_ProcessDiagram(); $done = array(); while (!empty($todo)) { $nextLevel = array(); $posOnLevel = 0; foreach ($todo as $item) { $next = array(); if ($activityService->isActivity($item)) { // add this activity $diagram->addActivity($item, 54 + 200 * $posOnLevel + 10 * $currentLevel, 35 + 80 * $currentLevel); $next = array_merge($next, $activityService->getNextConnectors($item)); common_Logger::d('Activity added ' . $item->getUri()); } elseif ($connectorService->isConnector($item)) { // add this connector $diagram->addConnector($item, 100 + 200 * $posOnLevel + 10 * $currentLevel, 40 + 80 * $currentLevel); $next = array_merge($next, $connectorService->getNextActivities($item)); } else { common_Logger::w('unexpected ressource in process ' . $item->getUri()); } //replace cardinalities foreach ($next as $key => $destination) { if ($activityCardinalityService->isCardinality($destination)) { // not represented on diagram $next[$key] = $activityCardinalityService->getDestination($destination); } } //add arrows foreach ($next as $destination) { $diagram->addArrow($item, $destination); } $posOnLevel++; $nextLevel = array_merge($nextLevel, $next); } $done = array_merge($done, $todo); $todo = array_diff($nextLevel, $done); $currentLevel++; } $returnValue = $diagram->toJSON(); return (string) $returnValue; }
/** * Gets the available deliveries using JSON format */ public function deliveries() { try { $deliveries = $this->getDeliveries(); $this->returnJson(array('entries' => $deliveries)); } catch (ServiceNotFoundException $e) { \common_Logger::w('No delivery service defined for proctoring'); $this->returnError('Proctoring interface not available'); } }
/** * Delete a subclass * * @access public * @author Joel Bout, <*****@*****.**> * @param Class clazz * @return boolean */ public function deleteClass(core_kernel_classes_Class $clazz) { $returnValue = (bool) false; if ($clazz->isSubClassOf($this->getRootClass()) && !$clazz->equals($this->getRootClass())) { $returnValue = $clazz->delete(); } else { common_Logger::w('Tried to delete class ' . $clazz->getUri() . ' as if it were a subclass of ' . $this->getRootClass()->getUri()); } return (bool) $returnValue; }
/** * Load a test plugin from the given data * @param array $data * @return TestPlugin|null */ private function loadPlugin(array $data) { $plugin = null; try { $plugin = TestPlugin::fromArray($data); } catch (\common_exception_InconsistentData $dataException) { \common_Logger::w('Got inconsistent plugin data, skipping.'); } return $plugin; }
public static function onError($errno, $errstr, $errfile, $errline) { common_Logger::w($errfile . ':' . $errline . ' - ' . $errstr, 'INSTALL'); switch ($errno) { case E_ERROR: throw new tao_install_utils_Exception($errfile . ':' . $errline . ' - ' . $errstr); break; default: return true; } }
public static function stateChange(DeliveryExecutionState $event) { /** @var DeliveryMonitoringService $service */ $service = ServiceManager::getServiceManager()->get(DeliveryMonitoringService::CONFIG_ID); $deliveryExecution = $event->getDeliveryExecution(); $data = $service->getData($deliveryExecution, true); $success = $service->save($data); if (!$success) { \common_Logger::w('monitor cache for delivery ' . $deliveryExecution->getIdentifier() . ' could not be created'); } }
/** * Create and run task * @param \oat\oatbox\action\Action|string $action action instance, classname or callback function * @param $parameters parameters to be passed to the action * @param boolean $recall Parameter which indicates that task has been created repeatedly after fail of previous. * For current implementation in means that the second call will not be executed to avoid loop. * @return SyncTask */ public function createTask($action, $parameters, $recall = false) { if ($recall) { \common_Logger::w("Repeated call of action'; Execution canceled."); return false; } $task = new SyncTask($action, $parameters); $this->tasks[$task->getId()] = $task; $this->runTask($task); return $task; }
/** * Enable you to map an rdf property to a form element using the Widget * * @access public * @author Bertrand Chevrier, <*****@*****.**> * @param Property property * @return tao_helpers_form_FormElement */ public static function elementMap(core_kernel_classes_Property $property) { $returnValue = null; //create the element from the right widget $property->feed(); $widgetResource = $property->getWidget(); if (is_null($widgetResource)) { return null; } //authoring widget is not used in standalone mode if ($widgetResource->getUri() == 'http://www.tao.lu/datatypes/WidgetDefinitions.rdf#Authoring' && tao_helpers_Context::check('STANDALONE_MODE')) { return null; } // horrible hack to fix file widget if ($widgetResource->getUri() == 'http://www.tao.lu/datatypes/WidgetDefinitions.rdf#AsyncFile') { $widgetResource = new core_kernel_classes_Resource('http://www.tao.lu/datatypes/WidgetDefinitions.rdf#GenerisAsyncFile'); } $element = tao_helpers_form_FormFactory::getElementByWidget(tao_helpers_Uri::encode($property->getUri()), $widgetResource); if (!is_null($element)) { if ($element->getWidget() != $widgetResource->getUri()) { common_Logger::w('Widget definition differs from implementation: ' . $element->getWidget() . ' != ' . $widgetResource->getUri()); return null; } //use the property label as element description $propDesc = strlen(trim($property->getLabel())) > 0 ? $property->getLabel() : str_replace(LOCAL_NAMESPACE, '', $property->getUri()); $element->setDescription($propDesc); //multi elements use the property range as options if (method_exists($element, 'setOptions')) { $range = $property->getRange(); if ($range != null) { $options = array(); if ($element instanceof tao_helpers_form_elements_Treeview) { if ($property->getUri() == RDFS_RANGE) { $options = self::rangeToTree(new core_kernel_classes_Class(RDFS_RESOURCE)); } else { $options = self::rangeToTree($range); } } else { foreach ($range->getInstances(true) as $rangeInstance) { $options[tao_helpers_Uri::encode($rangeInstance->getUri())] = $rangeInstance->getLabel(); } //set the default value to an empty space if (method_exists($element, 'setEmptyOption')) { $element->setEmptyOption(' '); } } //complete the options listing $element->setOptions($options); } } $returnValue = $element; } return $returnValue; }
/** * Short description of method feed * * @access public * @author Joel Bout, <*****@*****.**> */ public function feed() { common_Logger::t('Evaluating AsyncFile ' . $this->getName(), array('TAO')); if (isset($_POST[$this->name])) { $struct = json_decode($_POST[$this->name], true); if ($struct !== false) { $this->setValue($struct); } else { common_Logger::w('Could not unserialise AsyncFile field ' . $this->getName(), array('TAO')); } } }
/** * Short description of method getLanguageByCode * * @access public * @author Joel Bout, <*****@*****.**> * @param string code * @return core_kernel_classes_Resource */ public function getLanguageByCode($code) { $returnValue = null; $langClass = new core_kernel_classes_Class(CLASS_LANGUAGES); $langs = $langClass->searchInstances(array(RDF_VALUE => $code), array('like' => false)); if (count($langs) == 1) { $returnValue = current($langs); } else { common_Logger::w('Could not find language with code ' . $code); } return $returnValue; }
/** * Lazy loading access to the data * * @param string $key * @return mixed */ protected function getData($key) { if (is_null($this->data)) { $this->data = $this->getFactory()->loadReference($this->serial); } if (isset($this->data[$key])) { return $this->data[$key]; } else { \common_Logger::w('Undefined key ' . $key); return null; } }
/** * Short description of method add * * @access public * @author Jehan Bihin, <*****@*****.**> * @param string roleUri * @param string accessUri * @return mixed */ public function add($roleUri, $accessUri) { $module = new core_kernel_classes_Resource($accessUri); $role = new core_kernel_classes_Resource($roleUri); $moduleAccessProperty = new core_kernel_classes_Property(PROPERTY_ACL_GRANTACCESS); $values = $role->getPropertyValues($moduleAccessProperty); if (!in_array($module->getUri(), $values)) { $role->setPropertyValue($moduleAccessProperty, $module->getUri()); funcAcl_helpers_Cache::cacheModule($module); } else { common_Logger::w('Tried to add role ' . $role->getUri() . ' again to controller ' . $accessUri); } }
public static function testStateChange(QtiTestChangeEvent $event) { /** @var DeliveryMonitoringService $service */ $service = ServiceManager::getServiceManager()->get(DeliveryMonitoringService::CONFIG_ID); $deliveryExecution = \taoDelivery_models_classes_execution_ServiceProxy::singleton()->getDeliveryExecution($event->getServiceCallId()); $data = $service->getData($deliveryExecution, false); $data->setTestSession($event->getSession()); $data->updateData([DeliveryMonitoringService::STATUS, DeliveryMonitoringService::CURRENT_ASSESSMENT_ITEM, DeliveryMonitoringService::START_TIME, DeliveryMonitoringService::END_TIME, DeliveryMonitoringService::REMAINING_TIME, DeliveryMonitoringService::EXTRA_TIME]); $success = $service->save($data); if (!$success) { \common_Logger::w('monitor cache for teststate could not be updated'); } }
/** * Release all remaining locks, to trigger cleanup * * @param LockSystem $lockService */ protected function releaseAll(LockSystem $lockService) { $sql = $lockService->getStorage()->getPersistence(); $result = $sql->query('SELECT ' . SqlStorage::FIELD_OWNER . ',' . SqlStorage::FIELD_RESOURCE . ' FROM ' . SqlStorage::TABLE_NAME); $locked = $result->fetchAll(\PDO::FETCH_ASSOC); foreach ($locked as $data) { try { $resource = $this->getResource($data[SqlStorage::FIELD_RESOURCE]); $lockService->releaseLock($resource, $data[SqlStorage::FIELD_OWNER]); } catch (\Exception $e) { \common_Logger::w('Failed to release resource ' . $data[SqlStorage::FIELD_RESOURCE] . ': ' . $e->getMessage()); } } }
public function getDeliveryExecutionsByStatus($userUri, $status) { $returnValue = array(); $data = $this->getPersistence()->get(self::USER_EXECUTIONS_PREFIX . $userUri . $status); $keys = $data !== false ? json_decode($data) : array(); if (is_array($keys)) { foreach ($keys as $key) { $returnValue[$key] = $this->getDeliveryExecution($key); } } else { common_Logger::w('Non array "' . gettype($keys) . '" received as active Delivery Keys for user ' . $userUri); } return $returnValue; }