Get resource by URI

@param string $uri
@param bool $expanded Return subresources as definitions and not references?
@return \Jaspersoft\Dto\Resource\Resource
541836
public function getResource($uri, $expanded = false)
    {
        if (!$expanded)
            $url = self::makeUrl(null, $uri);
        else
            $url = self::makeUrl(null, $uri, true);

        // If getting the root folder, we must use repository.folder+json
        if ($uri == "/")
            $type = "application/repository.folder+json";
        else
            $type = "application/repository.file+json";

        $response = $this->service->makeRequest($url, array(200, 204), 'GET', null, true, 'application/json', $type);

        $data = $response['body'];
        $headers = $response['headers'];
        $content_type = array_values(preg_grep("#repository\.(.*)\+#", $headers));
        preg_match("#repository\.(.*)\+#", $content_type[0], $resource_type);

        $class = RESOURCE_NAMESPACE . '\\' . ucfirst($resource_type[1]);
        if (class_exists($class) && is_subclass_of($class, RESOURCE_NAMESPACE . '\\Resource')) {
            return $class::createFromJSON(json_decode($data, true), $class);
        } else {
            return Resource::createFromJSON(json_decode($data, true));
        }
    }
728961
public function dir_opendir($uri, $options)
    {
        $parts = Uri::parse($uri);

        // Provoke ResourceNotFoundException if not found
        $resource = $this->getRepository($parts['scheme'])->get($parts['path']);

        $this->childIterator = new ResourceCollectionIterator(
            $resource->listChildren(),
            ResourceCollectionIterator::CURRENT_AS_NAME
        );

        return true;
    }
209929
public function rmdir($uri, $options)
    {
        $this->uri = $uri;

        return $this->invoke($this->getFilesystem(), 'rmdir', [$this->getTarget(), $options]);
    }
1017389
public function withUri(UriInterface $uri, $preserveHost = false)
    {
        $request = $this->copy();
        $request->uri = $uri;
        
        if (!$preserveHost) {
            $request = $request->withHeader('Host', $request->uri->getHost());
        }
        
        return $request;
    }
1233666
public function getByUri(string $uri): FedoraResource {
        if (!isset($this->cache[$uri])) {
            throw new NotInCache();
        }
        return $this->cache[$uri];
    }
34016
protected function getSystemUri($requestUri = null, $refresh = false)
    {
        if ($this->psrUri && !$refresh) {
            return $this->psrUri;
        }

        $uri = $requestUri ? new PsrUri($requestUri) : $this->getRequest()->getUri();

        $server = $this->getRequest()->getServerParams();

        // If we are working from a CGI SAPI with the 'cgi.fix_pathinfo' directive disabled we use PHP_SELF.
        if (strpos(PHP_SAPI, 'cgi') !== false && !ini_get('cgi.fix_pathinfo') && !empty($server['REQUEST_URI'])) {
            // We aren't expecting PATH_INFO within PHP_SELF so this should work.
            $uri = $uri->withPath(rtrim(\dirname((string) ServerHelper::getValue($server, 'PHP_SELF')), '/\\'));
        } else {
            // Pretty much everything else should be handled with SCRIPT_NAME.
            $uri = $uri->withPath(rtrim(\dirname((string) ServerHelper::getValue($server, 'SCRIPT_NAME')), '/\\'));
        }

        // Clear the unused parts of the requested URI.
        $uri = $uri->withFragment('');

        return $this->psrUri = $uri;
    }
437383
protected function get($uri=null)
    {
        if (!is_null($uri)) {
            if (!($this->getCrudService()->isInScope($uri))) {
                throw new common_exception_PreConditionFailure("The URI must be a valid resource under the root Class");
            }
            return $this->getCrudService()->get($uri);
        } else {
            return $this->getCrudService()->getAll();
        }
    }
161335
function makeUri($uri) {
      $a = parse_url($uri);

      if ( (isset($a['scheme'])) && (isset($a['host'])) ) {
        $this->url = $a;
      } else {
        unset($this->url['query']);
        unset($this->url['fragment']);
        $this->url = array_merge($this->url, $a);
      }

      if ($this->useProxy) {
        $requesturi = 'http://' . $this->url['host'] . (empty($this->url['port']) ? '' : ':' . $this->url['port']) . $this->url['path'] . (empty($this->url['query']) ? '' : '?' . $this->url['query']);
      } else {
        $requesturi = $this->url['path'] . (empty($this->url['query']) ? '' : '?' . $this->url['query']);
      }

      return $requesturi;
    }
887238
protected function httpGet($uri)
    {
        $results = [];
        // Start requesting at page 1
        $page = 1;
        // We dont know how many pages there are, so assume 1 until we know
        $pagecount = 1;
        while ($page <= $pagecount) {
            $this->log[] = [
                        'request' => [
                                    'method' => 'GET',
                                    'uri'    => $uri.'?page='.$page,
                                    ],
                        ];
            $response = \Httpful\Request::get($uri.'?page='.$page)
                                                    ->addHeader('X-Auth-Email', $this->email)
                                                    ->addHeader('X-Auth-Key', $this->apikey)
                                                    ->expectsType(\Httpful\Mime::JSON)
                                                    ->parseWith(function ($body) {
                                                        return \Metaclassing\Utility::decodeJson($body);
                                                    })
                                                    ->send()
                                                    ->body;
            $this->log[count($this->log) - 1]['response'] = $response;
            if ($response['success'] != true) {
                throw new \Exception("get {$uri} unsuccessful".\Metaclassing\Utility::encodeJson($response));
            }
            foreach ($response['result'] as $result) {
                array_push($results, $result);
            }
            // Now that we KNOW the pagecount, update that and increment our page counter
            $pagecount = $response['result_info']['total_pages'];
            // And get the next page ready for the next request
            $page++;
        }

        return $results;
    }
1311594
private function getPathFromUri($uri)
    {
        $uriParser = new UriParser($uri);
        // Prepare uri
        $uriParser->encode();
        $uri = $uriParser->stripFragment();
        if (strpos($uri, '/') === 0) {
            // URI is already an path
            return $uri;
        }
        if (!$uriParser->validate()) {
            throw new \InvalidArgumentException('Invalid URI');
        }
        $path = (($path = parse_url($uri, PHP_URL_PATH)) === null) ? '/' : $path;
        $query = (($query = parse_url($uri, PHP_URL_QUERY)) === null) ? '' : '?' . $query;
        return $path . $query;
    }
339534
@Override
	public <T extends Resource> T get(final String uri) {
		return doRequest(uri).get();
	}
1332827
def get_by_resource(self, resource_uri):
        
        uri = self.URI + self.RESOURCES_PATH + '/' + resource_uri
        return self._client.get(id_or_uri=uri)
1297940
public function &findPageByUri($uri)
    {
        foreach ($this->getRootSection()->getSections() as $section) {
            if ($page = $section->findPageByUri($uri)) {
                return $page;
            }
        }

        return;
    }
176259
public function retrieve(string $uri): Promise
    {
        return $this->client->textDocument->xcontent(new TextDocumentIdentifier($uri))
            ->then(function (TextDocumentItem $textDocument) {
                return $textDocument->text;
            });
    }
679294
public function asset($uri = null)
    {
        if (empty($uri)) {
            // Allow empty
        } elseif (substr($uri, 0, 7) == "http://"
            || substr($uri, 0, 8) == "https://"
            || substr($uri, 0, 2) == "//"
        ) {
            // Fully qualified, just leave as is.
            return rtrim($uri, '/');
        } elseif ($uri[0] == '/') {
            // Absolute url, prepend with staticSiteUrl
            return rtrim($this->staticSiteUrl . rtrim($uri, '/'), '/');
        }

        $baseUrl = isset($this->staticBaseUrl)
            ? $this->staticBaseUrl
            : $this->baseUrl;

        return empty($uri)
            ? $baseUrl
            : $baseUrl . '/' . $uri;
    }
1113294
public function getOrLoad(string $uri): Promise
    {
        return isset($this->documents[$uri]) ? Promise\resolve($this->documents[$uri]) : $this->load($uri);
    }
314671
private function getResourceParam($uri)
    {
        $resource = $this->injector->getInstance(ResourceInterface::class);
        $resourceResult = $resource->get->uri($uri)->eager->request();
        $fragment = parse_url($uri, PHP_URL_FRAGMENT);

        return $resourceResult[$fragment];
    }