/** * Request handeling */ public static function handle($uri) { self::$controller = \App::make('Tdt\\Triples\\Controllers\\TriplesController'); switch ($uri) { case 'triples': // Set permission Auth::requirePermissions('tdt.triples.view'); // Get list of triples return self::listTriples(); break; case 'triples/add': // Set permission Auth::requirePermissions('tdt.triples.create'); // Create new triple return self::addTriple(); break; case preg_match('/^triples\\/delete/i', $uri) ? true : false: // Set permission Auth::requirePermissions('tdt.triples.delete'); // Delete a triple return self::deleteTriple($uri); break; } return false; }
public function handle() { // Propagate the request based on the HTTPMethod of the request. $method = \Request::getMethod(); switch ($method) { case "PUT": Auth::requirePermissions('tdt.input.create'); $uri = $this->getUri(); return $this->createJob($uri); break; case "GET": Auth::requirePermissions('tdt.input.view'); return $this->getJob(); break; case "DELETE": Auth::requirePermissions('tdt.input.delete'); return $this->deleteJob(); break; case "POST": Auth::requirePermissions('tdt.input.edit'); return $this->editJob(); break; default: \App::abort(400, "The method {$method} is not supported by the jobs."); break; } }
/** * Request handling * * TODO: Change everything to work with $id */ public function handle($uri) { switch ($uri) { case 'jobs': // Set permission Auth::requirePermissions('tdt.input.view'); // Get list of jobs return $this->listJobs(); break; case 'jobs/add': // Set permission Auth::requirePermissions('tdt.input.create'); // Create new job return $this->addJob(); break; case preg_match('/^jobs\\/edit/i', $uri) ? true : false: // Set permission Auth::requirePermissions('tdt.input.edit'); // Edit a job return $this->editJob($uri); break; case preg_match('/^jobs\\/delete/i', $uri) ? true : false: // Set permission Auth::requirePermissions('tdt.input.delete'); // Delete a job return $this->deleteJob($uri); break; } return false; }
public function get($uri) { // Set permission Auth::requirePermissions('info.view'); $ontologies = $this->ontologies->getAll(); return $this->makeResponse($ontologies); }
public function get($uri) { // Set permission Auth::requirePermissions('info.view'); // Split for an (optional) extension preg_match('/([^\\.]*)(?:\\.(.*))?$/', $uri, $matches); // URI is always the first match $uri = $matches[1]; return $this->getInfo($uri); }
public function get($uri) { // Ask permission Auth::requirePermissions('info.view'); // Default format is ttl for dcat if (empty($extension)) { $extension = 'ttl'; } $dcat = $this->createDcat(); // Allow content nego. for dcat return ContentNegotiator::getResponse($dcat, $extension); }
/** * Admin.group.update */ public function postUpdate($id = null) { // Set permission Auth::requirePermissions('admin.group.update'); try { if (empty($id)) { $id = \Input::get('id'); } // Find the user using the group id $group = \Sentry::findGroupById($id); $permissions_save = \Input::get('btn_save_permissions'); if (empty($permissions_save)) { // Update group if ($id > 2) { $group->name = \Input::get('name'); } $group->save(); } else { if ($group->id > 2) { // Update permissions $permission_data = \Input::get(); $permissions = array(); // Unset previous permissions $group_permissions = $group->getPermissions(); foreach ($group_permissions as $p => $value) { $permissions[$p] = 0; } // Add new ones foreach ($permission_data as $p => $value) { // Skip extra information if ($p == 'id' || $p == 'btn_save_permissions') { continue; } // Form undo transform $p = str_replace('_', '.', $p); // Permission set $permissions[$p] = 1; } // Save permissions $group->permissions = $permissions; $group->save(); } } } catch (\Cartalyst\Sentry\Groups\NameRequiredException $e) { Flash::set('Name is required'); } catch (\Cartalyst\Sentry\Users\UserNotFoundException $e) { // Ignore and redirect back } catch (\Cartalyst\Sentry\Groups\GroupNotFoundException $e) { // Ignore and redirect back } return \Redirect::to('api/admin/groups'); }
public function get($uri = null) { // Set permission Auth::requirePermissions('discovery.view'); $discovery_document = self::createDiscoveryDocument(); // If the input package is installed, add it to the discovery document if (class_exists('Tdt\\Input\\Controllers\\DiscoveryController')) { $discovery_class = 'tdt\\input\\controllers\\DiscoveryController'; $discovery_document->resources->input = $discovery_class::createDiscoveryDocument(); } // If the triples package is installed, add it to the discovery document if (class_exists('Tdt\\Triples\\TriplesServiceProvider')) { $discovery_class = 'Tdt\\Triples\\Controllers\\DiscoveryController'; $discovery_document->resources->triples = $discovery_class::createDiscoveryDocument(); } return self::makeResponse(str_replace("\\/", "/", json_encode($discovery_document))); }
/** * Admin.settings.update */ public function postIndex() { // Set permission Auth::requirePermissions('admin.dataset.view'); $settings_allowed = array('catalog_title', 'catalog_description', 'catalog_language', 'catalog_publisher_uri', 'catalog_publisher_name'); $values = \Input::all(); foreach ($values as $key => $value) { if (in_array($key, $settings_allowed)) { if ($key === 'catalog_publisher_uri') { if (!filter_var($values['catalog_publisher_uri'], FILTER_VALIDATE_URL)) { Flash::set('Publisher URI is not a valid URI.'); continue; } } $this->settings->storeValue($key, $value); } } return \Redirect::to('api/admin/settings'); }
/** * Admin.user.update */ public function postUpdate($id = null) { // Set permission Auth::requirePermissions('admin.user.update'); try { if (empty($id)) { $id = \Input::get('id'); } // Find the user using the user id $user = \Sentry::findUserById($id); // Update account if ($id > 2 && \Input::get('name')) { $user->email = strtolower(\Input::get('name')); } // Update password (not for the everyone account) if ($id > 1 && \Input::get('password')) { $resetCode = $user->getResetPasswordCode(); $user->attemptResetPassword($resetCode, \Input::get('password')); } $user->save(); // Find the group using the group id $group = \Sentry::findGroupById(\Input::get('group')); if ($id > 2) { // Remove user from previous groups foreach ($user->getGroups() as $g) { $user->removeGroup($g); } // Assign the group to the user $user->addGroup($group); } } catch (\Cartalyst\Sentry\Users\UserNotFoundException $e) { // Ignore and redirect back } catch (\Cartalyst\Sentry\Groups\GroupNotFoundException $e) { // Ignore and redirect back } return \Redirect::to('api/admin/users'); }
public function get($uri) { // Set permission Auth::requirePermissions('info.view'); return $this->makeResponse($this->licenses->getAll()); }
public function get($uri) { // Set permission Auth::requirePermissions('info.view'); return $this->getKeywords(); }
public function get($uri) { // Set permission Auth::requirePermissions('info.view'); return $this->getLanguages($uri); }
/** * Return a HEAD response indicating if a URI is reachable for the user agent * * @param string $uri The identifier that identifies a resource * * @return \Response */ public function head($uri) { // Check permissions Auth::requirePermissions('dataset.view'); // Split for an (optional) extension list($uri, $extension) = $this->processURI($uri); // Get definition $definition = $this->definition->getByIdentifier($uri); $response = new \Response(); if ($definition) { $response = \Response::make(null, 200); } else { $response = \Response::make(null, 404); } return $response; }
/** * Delete a configured semantic source * * @param integer $id The id of the semantic source * * @return \Response */ public function delete($id) { Auth::requirePermissions('dataset.delete'); $result = $this->semantic_source->delete($id); // Delete the corresponding graph that cached the triples $this->triple_store->removeTriples($id); if ($result) { $response = \Response::make("", 200); } else { $response = \Response::make("", 404); } return $response; }
public function get($uri) { // Set permission Auth::requirePermissions('definition.view'); if (!empty($uri)) { if (!$this->definition->exists($uri)) { \App::abort(404, "No resource was found identified with " . $uri); } $description = $this->definition->getFullDescription($uri); $result = new Data(); $result->data = $description; return ContentNegotiator::getResponse($result, 'json'); } list($limit, $offset) = Pager::calculateLimitAndOffset(); $definitions = $this->definition->getAllFullDescriptions($limit, $offset); $definition_count = $this->definition->count(); $result = new Data(); $result->paging = Pager::calculatePagingHeaders($limit, $offset, $definition_count); $result->data = $definitions; return ContentNegotiator::getResponse($result, 'json'); }
/** * Admin.dataset.delete */ public function getDelete($id) { // Set permission Auth::requirePermissions('admin.dataset.delete'); if (is_numeric($id)) { $definition = \Definition::find($id); if ($definition) { // Delete it (with cascade) $definition->delete(); } } return \Redirect::to('api/admin/datasets'); }