IRunner.php 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * FullTextSearch - Full text search framework for Nextcloud
  5. *
  6. * This file is licensed under the Affero General Public License version 3 or
  7. * later. See the COPYING file.
  8. *
  9. * @author Maxence Lange <maxence@artificial-owl.com>
  10. * @copyright 2018
  11. * @license GNU AGPL version 3 or any later version
  12. *
  13. * This program is free software: you can redistribute it and/or modify
  14. * it under the terms of the GNU Affero General Public License as
  15. * published by the Free Software Foundation, either version 3 of the
  16. * License, or (at your option) any later version.
  17. *
  18. * This program is distributed in the hope that it will be useful,
  19. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  20. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  21. * GNU Affero General Public License for more details.
  22. *
  23. * You should have received a copy of the GNU Affero General Public License
  24. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  25. *
  26. */
  27. namespace OCP\FullTextSearch\Model;
  28. /**
  29. * Interface IRunner
  30. *
  31. * The indexing process can be long and heavy, and because errors can
  32. * be encountered the process is wrapped using this interface.
  33. * It allows the any extension of FullTextSearch to communicate with the process.
  34. *
  35. * The IRunner is coming with some methods so the Search Platform can
  36. * returns important information and errors to be displayed to the admin.
  37. *
  38. * @since 15.0.0
  39. *
  40. * @package OCP\FullTextSearch\Model
  41. */
  42. interface IRunner {
  43. const RESULT_TYPE_SUCCESS = 1;
  44. const RESULT_TYPE_WARNING = 4;
  45. const RESULT_TYPE_FAIL = 9;
  46. /**
  47. * Info are displayed in the user interface when an admin execute the
  48. * ./occ fulltextsearch:index command.
  49. *
  50. * quick list of info that can be edited:
  51. * 'documentId', 'info', 'title', 'resultIndex', 'resultStatus',
  52. * 'content', 'documentCurrent', 'documentTotal', 'progressStatus',
  53. * 'errorCurrent', 'errorException', 'errorIndex'.
  54. *
  55. * List of all editable info can be find in the Command\Index.php of the
  56. * FullTextSearch app.
  57. * (look for a comment 'full list of info that can be edited')
  58. *
  59. * @since 15.0.0
  60. *
  61. * @param string $info
  62. * @param string $value
  63. */
  64. public function setInfo(string $info, string $value);
  65. /**
  66. * This method should be used when editing multiple info to avoid too many
  67. * refresh of the interface.
  68. *
  69. * @since 15.0.0
  70. *
  71. * @param array $data
  72. */
  73. public function setInfoArray(array $data);
  74. /**
  75. * Method used to update the current Action when an index is running.
  76. *
  77. * This method should be used instead of manually update the 'action' using
  78. * setInfo()/setInfoArray() as it is also used to keep the process alive,
  79. * manage the input, and some statistics of the load of the process.
  80. *
  81. * $action is a string with no space
  82. * $force should be set to true if the action is heavy while being executed
  83. * multiple times
  84. *
  85. * @since 15.0.0
  86. *
  87. * @param string $action
  88. * @param bool $force
  89. *
  90. * @return string
  91. * @throws \Exception
  92. */
  93. public function updateAction(string $action = '', bool $force = false): string;
  94. /**
  95. * Call this method in a Search Platform or Content Provider if there is an
  96. * issue while generating a document or while indexing the current document.
  97. * This is used to store and display errors in the UI during an index to help
  98. * admin to keep track of errors.
  99. *
  100. * @since 15.0.0
  101. *
  102. * @param IIndex $index
  103. * @param string $message
  104. * @param string $class
  105. * @param int $sev
  106. */
  107. public function newIndexError(IIndex $index, string $message, string $class = '', int $sev = 3);
  108. /**
  109. * Call this method only in a Search Platform after an index of a document.
  110. * This is used to store and display results (good or bad) in the UI during
  111. * an index to help admin to keep track of fail and successful indexes.
  112. *
  113. * @since 15.0.0
  114. *
  115. * @param IIndex $index
  116. * @param string $message
  117. * @param string $status
  118. * @param int $type
  119. */
  120. public function newIndexResult(IIndex $index, string $message, string $status, int $type);
  121. }