Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
compat with NC16
Signed-off-by: Maxence Lange <[email protected]>
  • Loading branch information
ArtificialOwl committed Mar 1, 2019
commit a473c5dcbb6338ee0c8f40389efc3908f0e01e91
2 changes: 1 addition & 1 deletion js/fulltextsearch.v1.navigation.js
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ var nav = {
}

if (entry.excerpts.length > 0) {
divResult.find('#extract').text(entry.excerpts[0]);
divResult.find('#extract').text(entry.excerpts[0]['excerpt']);
} else {
divResult.find('#extract').text('');
}
Expand Down
17 changes: 14 additions & 3 deletions lib/Command/DocumentProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
use OCA\FullTextSearch\Model\Index;
use OCA\FullTextSearch\Service\MiscService;
use OCA\FullTextSearch\Service\ProviderService;
use OCP\FullTextSearch\Model\IndexDocument;
use OCP\FullTextSearch\Model\IIndexDocument;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
Expand Down Expand Up @@ -119,11 +119,22 @@ protected function execute(InputInterface $input, OutputInterface $output) {

$output->writeln('Content: ');
$content = $indexDocument->getContent();
if ($indexDocument->isContentEncoded() === IndexDocument::ENCODED_BASE64) {
if ($indexDocument->isContentEncoded() === IIndexDocument::ENCODED_BASE64) {
$content = base64_decode($content, true);
}

$output->writeln(substr($content, 0, 60));
$output->writeln(substr($content, 0, 80));

$parts = $indexDocument->getParts();
$output->writeln(sizeof($parts) . ' Part(s)');
foreach (array_keys($parts) as $part) {
$output->writeln(
"'" . $part . "' " . substr($parts[$part], 0, 80) . ' (size: ' . strlen(
$parts[$part]
) . ')'
);
}

}


Expand Down
4 changes: 2 additions & 2 deletions lib/Command/Search.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
use OCA\FullTextSearch\Model\SearchResult;
use OCA\FullTextSearch\Service\MiscService;
use OCA\FullTextSearch\Service\SearchService;
use OCP\FullTextSearch\Model\IndexDocument;
use OCP\FullTextSearch\Model\IIndexDocument;
use OCP\FullTextSearch\Model\ISearchResult;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
Expand Down Expand Up @@ -126,7 +126,7 @@ private function displaySearchResult(ISearchResult $searchResult) {
echo '> ' . $searchResult->getProvider()
->getName() . "\n";

/** @var IndexDocument[] $result */
/** @var IIndexDocument[] $result */
$result = $searchResult->getDocuments();
foreach ($result as $document) {
echo ' - ' . $document->getId() . ' score:' . $document->getScore() . "\n";
Expand Down
7 changes: 4 additions & 3 deletions lib/Command/Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@

use Exception;
use OC\Core\Command\InterruptedException;
use OC\FullTextSearch\Model\DocumentAccess;
use OCA\FullTextSearch\ACommandBase;
use OCA\FullTextSearch\Exceptions\InterruptException;
use OCA\FullTextSearch\Exceptions\ProviderDoesNotExistException;
Expand All @@ -54,7 +55,7 @@
use OCP\AppFramework\QueryException;
use OCP\FullTextSearch\IFullTextSearchPlatform;
use OCP\FullTextSearch\IFullTextSearchProvider;
use OCP\FullTextSearch\Model\DocumentAccess;
use OCP\FullTextSearch\Model\IDocumentAccess;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
Expand Down Expand Up @@ -556,7 +557,7 @@ private function testUnlockingProcess(OutputInterface $output) {
* @param OutputInterface $output
* @param IFullTextSearchPlatform $testPlatform
* @param IFullTextSearchProvider $testProvider
* @param DocumentAccess $access
* @param IDocumentAccess $access
* @param string $search
* @param array $expected
* @param string $moreOutput
Expand All @@ -566,7 +567,7 @@ private function testUnlockingProcess(OutputInterface $output) {
private function search(
OutputInterface $output, IFullTextSearchPlatform $testPlatform,
IFullTextSearchProvider $testProvider,
DocumentAccess $access, string $search, array $expected, string $moreOutput = ''
IDocumentAccess $access, string $search, array $expected, string $moreOutput = ''
) {
$this->output(
$output,
Expand Down
12 changes: 6 additions & 6 deletions lib/Model/SearchResult.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
use JsonSerializable;
use OCP\FullTextSearch\IFullTextSearchPlatform;
use OCP\FullTextSearch\IFullTextSearchProvider;
use OCP\FullTextSearch\Model\IndexDocument;
use OCP\FullTextSearch\Model\IIndexDocument;
use OCP\FullTextSearch\Model\ISearchRequest;
use OCP\FullTextSearch\Model\ISearchResult;

Expand All @@ -46,7 +46,7 @@
*/
class SearchResult implements ISearchResult, JsonSerializable {

/** @var IndexDocument[] */
/** @var IIndexDocument[] */
private $documents = [];

/** @var string */
Expand Down Expand Up @@ -85,7 +85,7 @@ public function __construct(SearchRequest $searchRequest) {


/**
* @param IndexDocument[] $documents
* @param IIndexDocument[] $documents
*
* @return ISearchResult
*/
Expand All @@ -96,18 +96,18 @@ public function setDocuments(array $documents): ISearchResult {
}

/**
* @return IndexDocument[]
* @return IIndexDocument[]
*/
public function getDocuments(): array {
return $this->documents;
}

/**
* @param IndexDocument $document
* @param IIndexDocument $document
*
* @return ISearchResult
*/
public function addDocument(IndexDocument $document): ISearchResult {
public function addDocument(IIndexDocument $document): ISearchResult {
$this->documents[] = $document;

return $this;
Expand Down
23 changes: 12 additions & 11 deletions lib/Provider/TestProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
namespace OCA\FullTextSearch\Provider;


use OC\FullTextSearch\Model\SearchTemplate;
use OCA\FullTextSearch\Model\IndexOptions;
use OCA\FullTextSearch\Model\Runner;
use OCA\FullTextSearch\Service\ConfigService;
Expand All @@ -39,12 +40,12 @@
use OCP\FullTextSearch\IFullTextSearchPlatform;
use OCP\FullTextSearch\IFullTextSearchProvider;
use OCP\FullTextSearch\Model\IIndex;
use OCP\FullTextSearch\Model\IIndexDocument;
use OCP\FullTextSearch\Model\IIndexOptions;
use OCP\FullTextSearch\Model\IndexDocument;
use OCP\FullTextSearch\Model\IRunner;
use OCP\FullTextSearch\Model\ISearchRequest;
use OCP\FullTextSearch\Model\ISearchResult;
use OCP\FullTextSearch\Model\SearchTemplate;
use OCP\FullTextSearch\Model\ISearchTemplate;


/**
Expand Down Expand Up @@ -127,9 +128,9 @@ public function setIndexOptions(IIndexOptions $options) {


/**
* @return SearchTemplate
* @return ISearchTemplate
*/
public function getSearchTemplate(): SearchTemplate {
public function getSearchTemplate(): ISearchTemplate {
return new SearchTemplate();
}

Expand Down Expand Up @@ -157,7 +158,7 @@ public function generateChunks(string $userId): array {
* @param string $userId
* @param string $chunk
*
* @return IndexDocument[]
* @return IIndexDocument[]
*/
public function generateIndexableDocuments(string $userId, string $chunk): array {
$result = [];
Expand All @@ -172,28 +173,28 @@ public function generateIndexableDocuments(string $userId, string $chunk): array
/**
* generate documents prior to the indexing.
*
* @param IndexDocument $document
* @param IIndexDocument $document
*/
public function fillIndexDocument(IndexDocument $document) {
public function fillIndexDocument(IIndexDocument $document) {
}


/**
* @param IndexDocument $document
* @param IIndexDocument $document
*
* @return bool
*/
public function isDocumentUpToDate(IndexDocument $document): bool {
public function isDocumentUpToDate(IIndexDocument $document): bool {
return false;
}


/**
* @param IIndex $index
*
* @return IndexDocument
* @return IIndexDocument
*/
public function updateDocument(IIndex $index): IndexDocument {
public function updateDocument(IIndex $index): IIndexDocument {
return null;
}

Expand Down
20 changes: 10 additions & 10 deletions lib/Service/IndexService.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@
use OCP\FullTextSearch\IFullTextSearchPlatform;
use OCP\FullTextSearch\IFullTextSearchProvider;
use OCP\FullTextSearch\Model\IIndex;
use OCP\FullTextSearch\Model\IIndexDocument;
use OCP\FullTextSearch\Model\IIndexOptions;
use OCP\FullTextSearch\Model\IndexDocument;
use OCP\FullTextSearch\Model\IRunner;
use OCP\FullTextSearch\Service\IIndexService;

Expand Down Expand Up @@ -209,10 +209,10 @@ public function indexProviderContentFromUser(

/**
* @param IFullTextSearchProvider $provider
* @param IndexDocument[] $documents
* @param IIndexDocument[] $documents
* @param IIndexOptions $options
*
* @return IndexDocument[]
* @return IIndexDocument[]
* @throws Exception
*/
private function updateDocumentsWithCurrIndex(
Expand Down Expand Up @@ -259,11 +259,11 @@ private function updateDocumentsWithCurrIndex(

/**
* @param IFullTextSearchProvider $provider
* @param IndexDocument $document
* @param IIndexDocument $document
*
* @return bool
*/
private function isDocumentUpToDate(IFullTextSearchProvider $provider, IndexDocument $document
private function isDocumentUpToDate(IFullTextSearchProvider $provider, IIndexDocument $document
): bool {
$index = $document->getIndex();

Expand Down Expand Up @@ -294,7 +294,7 @@ private function getProviderIndexFromProvider(string $providerId): ProviderIndex
/**
* @param IFullTextSearchPlatform $platform
* @param IFullTextSearchProvider $provider
* @param IndexDocument[] $documents
* @param IIndexDocument[] $documents
* @param IndexOptions $options
*
* @throws Exception
Expand Down Expand Up @@ -345,11 +345,11 @@ private function indexDocuments(


/**
* @param IndexDocument $document
* @param IIndexDocument $document
*
* @throws NotIndexableDocumentException
*/
private function filterDocumentBeforeIndex(IndexDocument $document) {
private function filterDocumentBeforeIndex(IIndexDocument $document) {
// TODO - rework the index/not_index
$index = $document->getIndex();
$access = $document->getAccess();
Expand All @@ -365,12 +365,12 @@ private function filterDocumentBeforeIndex(IndexDocument $document) {

/**
* @param IFullTextSearchPlatform $platform
* @param IndexDocument $document
* @param IIndexDocument $document
*
* @return IIndex
* @throws Exception
*/
public function indexDocument(IFullTextSearchPlatform $platform, IndexDocument $document
public function indexDocument(IFullTextSearchPlatform $platform, IIndexDocument $document
): IIndex {
$this->updateRunnerAction('indexDocument', true);
$this->updateRunnerInfoArray(
Expand Down
11 changes: 6 additions & 5 deletions lib/Service/SearchService.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@

use Exception;
use OC\App\AppManager;
use OC\FullTextSearch\Model\DocumentAccess;
use OC\User\NoUserException;
use OCA\Circles\Api\v1\Circles;
use OCA\FullTextSearch\Exceptions\EmptySearchException;
Expand All @@ -41,7 +42,7 @@
use OCA\FullTextSearch\Model\SearchResult;
use OCP\FullTextSearch\IFullTextSearchPlatform;
use OCP\FullTextSearch\IFullTextSearchProvider;
use OCP\FullTextSearch\Model\DocumentAccess;
use OCP\FullTextSearch\Model\IDocumentAccess;
use OCP\FullTextSearch\Model\ISearchRequest;
use OCP\FullTextSearch\Model\ISearchResult;
use OCP\FullTextSearch\Service\ISearchService;
Expand Down Expand Up @@ -182,14 +183,14 @@ private function searchRequestCannotBeEmpty(ISearchRequest $request) {

/**
* @param IFullTextSearchPlatform $platform
* @param DocumentAccess $access
* @param IDocumentAccess $access
* @param IFullTextSearchProvider[] $providers
* @param SearchRequest $request
*
* @return ISearchResult[]
*/
private function searchFromProviders(
IFullTextSearchPlatform $platform, array $providers, DocumentAccess $access,
IFullTextSearchPlatform $platform, array $providers, IDocumentAccess $access,
SearchRequest $request
): array {
$result = [];
Expand All @@ -213,9 +214,9 @@ private function searchFromProviders(
/**
* @param IUser $user
*
* @return DocumentAccess
* @return IDocumentAccess
*/
private function getDocumentAccessFromUser(IUser $user): DocumentAccess {
private function getDocumentAccessFromUser(IUser $user): IDocumentAccess {
$rights = new DocumentAccess();

$rights->setViewerId($user->getUID());
Expand Down
Loading