IRunner.php 3.9 KB

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