Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
13 changes: 12 additions & 1 deletion lib/Command/DocumentIndex.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,12 @@

use Exception;
use OC\Core\Command\Base;
use OCA\FullTextSearch\Exceptions\IndexDoesNotExistException;
use OCA\FullTextSearch\Model\Index;
use OCA\FullTextSearch\Service\IndexService;
use OCA\FullTextSearch\Service\PlatformService;
use OCA\FullTextSearch\Service\ProviderService;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
Expand All @@ -22,6 +25,7 @@ class DocumentIndex extends Base {
public function __construct(
private ProviderService $providerService,
private PlatformService $platformService,
private IndexService $indexService,
) {
parent::__construct();
}
Expand All @@ -36,7 +40,8 @@ protected function configure() {
->setDescription('index one specific document')
->addArgument('userId', InputArgument::REQUIRED, 'userId')
->addArgument('providerId', InputArgument::REQUIRED, 'providerId')
->addArgument('documentId', InputArgument::REQUIRED, 'documentId');
->addArgument('documentId', InputArgument::REQUIRED, 'documentId')
->addOption('collection', null, InputOption::VALUE_OPTIONAL, 'collection to look the existing index up in, defaults to the internal collection');
}

/**
Expand All @@ -50,13 +55,19 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$providerId = $input->getArgument('providerId');
$documentId = $input->getArgument('documentId');
$userId = $input->getArgument('userId');
$collection = $input->getOption('collection');

$providerWrapper = $this->providerService->getProvider($providerId);
$provider = $providerWrapper->getProvider();

$index = new Index($providerId, $documentId);
$index->setOwnerId($userId);
$index->setStatus(Index::INDEX_FULL);
try {
$index = $this->indexService->getIndex($providerId, $documentId, $collection);
} catch (IndexDoesNotExistException $e) {
$output->writeln('<error>Index not found: index attributes have been set to default values</error>');
}
$indexDocument = $provider->updateDocument($index);
if (!$indexDocument->hasIndex()) {
$indexDocument->setIndex($index);
Expand Down
12 changes: 11 additions & 1 deletion lib/Command/DocumentProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@

use Exception;
use OC\Core\Command\Base;
use OCA\FullTextSearch\Exceptions\IndexDoesNotExistException;
use OCA\FullTextSearch\Model\Index;
use OCA\FullTextSearch\Service\IndexService;
use OCA\FullTextSearch\Service\ProviderService;
use OCP\FullTextSearch\Model\IIndexDocument;
use Symfony\Component\Console\Input\InputArgument;
Expand All @@ -22,6 +24,7 @@
class DocumentProvider extends Base {
public function __construct(
private ProviderService $providerService,
private IndexService $indexService,
) {
parent::__construct();
}
Expand All @@ -37,7 +40,8 @@ protected function configure() {
->addArgument('userId', InputArgument::REQUIRED, 'userId')
->addArgument('providerId', InputArgument::REQUIRED, 'providerId')
->addArgument('documentId', InputArgument::REQUIRED, 'documentId')
->addOption('content', 'c', InputOption::VALUE_NONE, 'return some content');
->addOption('content', 'c', InputOption::VALUE_NONE, 'return some content')
->addOption('collection', null, InputOption::VALUE_OPTIONAL, 'collection to look the existing index up in, defaults to the internal collection');
}


Expand All @@ -51,13 +55,19 @@ protected function execute(InputInterface $input, OutputInterface $output) {
$providerId = $input->getArgument('providerId');
$documentId = $input->getArgument('documentId');
$userId = $input->getArgument('userId');
$collection = $input->getOption('collection');

$providerWrapper = $this->providerService->getProvider($providerId);
$provider = $providerWrapper->getProvider();

$index = new Index($providerId, $documentId);
$index->setOwnerId($userId);
$index->setStatus(Index::INDEX_FULL);
try {
$index = $this->indexService->getIndex($providerId, $documentId, $collection);
} catch (IndexDoesNotExistException $e) {
$output->writeln('<error>Index not found: index attributes have been set to default values</error>');
}
$indexDocument = $provider->updateDocument($index);

$index->setOwnerId($indexDocument->getAccess()->getOwnerId());
Expand Down
Loading