/** * Search repository by criteria * * @param \Jaspersoft\Service\Criteria\RepositorySearchCriteria $criteria * @return \Jaspersoft\Service\Result\SearchResourcesResult */ public function searchResources(RepositorySearchCriteria $criteria = null) { $url = self::makeUrl($criteria); $response = $this->service->makeRequest($url, array(200, 204), 'GET', null, true, 'application/json', 'application/json'); if ($response['statusCode'] == 204 || $response['body'] == null) { // A SearchResourceResult with 0 counts, and no items return new SearchResourcesResult(null, 0, 0, 0); } $data = $response['body']; $headers = RESTRequest::splitHeaderArray($response['headers']); // If forceTotalCount is not enabled, the server doesn't return totalCount when offset is specified if (!isset($headers['Total-Count'])) { $totalCount = null; } else { $totalCount = (int) $headers['Total-Count']; } return new SearchResourcesResult(json_decode($data), (int) $headers['Result-Count'], (int) $headers['Start-Index'], $totalCount); }
/** * This method will download an export resource, an array is returned, one with an outputResource object that * describes the type of binary data, and the "body" which is the binary content of the resource. * * @param string $executionId * @param string $exportId * @return array */ public function getExportOutputResource($executionId, $exportId) { $url = $this->makeUrl($executionId, false, false, true, true, $exportId); $response = $this->service->makeRequest($url, array(200), 'GET', null, true, 'application/json', '*/*'); $headers = RESTRequest::splitHeaderArray($response['headers']); $outputResource = BinaryOutputResource::createFromHeaders($headers); $outputResource->binaryContent = $response['body']; return $outputResource; }