IRunner.php 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  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. /**
  41. * @since 15.0.0
  42. */
  43. public const RESULT_TYPE_SUCCESS = 1;
  44. /**
  45. * @since 15.0.0
  46. */
  47. public const RESULT_TYPE_WARNING = 4;
  48. /**
  49. * @since 15.0.0
  50. */
  51. public const RESULT_TYPE_FAIL = 9;
  52. /**
  53. * Info are displayed in the user interface when an admin execute the
  54. * ./occ fulltextsearch:index command.
  55. *
  56. * quick list of info that can be edited:
  57. * 'documentId', 'info', 'title', 'resultIndex', 'resultStatus',
  58. * 'content', 'documentCurrent', 'documentTotal', 'progressStatus',
  59. * 'errorCurrent', 'errorException', 'errorIndex'.
  60. *
  61. * List of all editable info can be find in the Command\Index.php of the
  62. * FullTextSearch app.
  63. * (look for a comment 'full list of info that can be edited')
  64. *
  65. * @since 15.0.0
  66. *
  67. * @param string $info
  68. * @param string $value
  69. */
  70. public function setInfo(string $info, string $value);
  71. /**
  72. * This method should be used when editing multiple info to avoid too many
  73. * refresh of the interface.
  74. *
  75. * @since 15.0.0
  76. *
  77. * @param array $data
  78. */
  79. public function setInfoArray(array $data);
  80. /**
  81. * Method used to update the current Action when an index is running.
  82. *
  83. * This method should be used instead of manually update the 'action' using
  84. * setInfo()/setInfoArray() as it is also used to keep the process alive,
  85. * manage the input, and some statistics of the load of the process.
  86. *
  87. * $action is a string with no space
  88. * $force should be set to true if the action is heavy while being executed
  89. * multiple times
  90. *
  91. * @since 15.0.0
  92. *
  93. * @param string $action
  94. * @param bool $force
  95. *
  96. * @return string
  97. * @throws \Exception
  98. */
  99. public function updateAction(string $action = '', bool $force = false): string;
  100. /**
  101. * Call this method in a Search Platform or Content Provider if there is an
  102. * issue while generating a document or while indexing the current document.
  103. * This is used to store and display errors in the UI during an index to help
  104. * admin to keep track of errors.
  105. *
  106. * @since 15.0.0
  107. *
  108. * @param IIndex $index
  109. * @param string $message
  110. * @param string $class
  111. * @param int $sev
  112. */
  113. public function newIndexError(IIndex $index, string $message, string $class = '', int $sev = 3);
  114. /**
  115. * Call this method only in a Search Platform after an index of a document.
  116. * This is used to store and display results (good or bad) in the UI during
  117. * an index to help admin to keep track of fail and successful indexes.
  118. *
  119. * @since 15.0.0
  120. *
  121. * @param IIndex $index
  122. * @param string $message
  123. * @param string $status
  124. * @param int $type
  125. */
  126. public function newIndexResult(IIndex $index, string $message, string $status, int $type);
  127. }