IRunner.php 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * SPDX-FileCopyrightText: 2018 Nextcloud GmbH and Nextcloud contributors
  5. * SPDX-License-Identifier: AGPL-3.0-or-later
  6. */
  7. namespace OCP\FullTextSearch\Model;
  8. /**
  9. * Interface IRunner
  10. *
  11. * The indexing process can be long and heavy, and because errors can
  12. * be encountered the process is wrapped using this interface.
  13. * It allows the any extension of FullTextSearch to communicate with the process.
  14. *
  15. * The IRunner is coming with some methods so the Search Platform can
  16. * returns important information and errors to be displayed to the admin.
  17. *
  18. * @since 15.0.0
  19. *
  20. */
  21. interface IRunner {
  22. /**
  23. * @since 15.0.0
  24. */
  25. public const RESULT_TYPE_SUCCESS = 1;
  26. /**
  27. * @since 15.0.0
  28. */
  29. public const RESULT_TYPE_WARNING = 4;
  30. /**
  31. * @since 15.0.0
  32. */
  33. public const RESULT_TYPE_FAIL = 9;
  34. /**
  35. * Info are displayed in the user interface when an admin execute the
  36. * ./occ fulltextsearch:index command.
  37. *
  38. * quick list of info that can be edited:
  39. * 'documentId', 'info', 'title', 'resultIndex', 'resultStatus',
  40. * 'content', 'documentCurrent', 'documentTotal', 'progressStatus',
  41. * 'errorCurrent', 'errorException', 'errorIndex'.
  42. *
  43. * List of all editable info can be find in the Command\Index.php of the
  44. * FullTextSearch app.
  45. * (look for a comment 'full list of info that can be edited')
  46. *
  47. * @since 15.0.0
  48. *
  49. * @param string $info
  50. * @param string $value
  51. */
  52. public function setInfo(string $info, string $value);
  53. /**
  54. * This method should be used when editing multiple info to avoid too many
  55. * refresh of the interface.
  56. *
  57. * @since 15.0.0
  58. *
  59. * @param array $data
  60. */
  61. public function setInfoArray(array $data);
  62. /**
  63. * Method used to update the current Action when an index is running.
  64. *
  65. * This method should be used instead of manually update the 'action' using
  66. * setInfo()/setInfoArray() as it is also used to keep the process alive,
  67. * manage the input, and some statistics of the load of the process.
  68. *
  69. * $action is a string with no space
  70. * $force should be set to true if the action is heavy while being executed
  71. * multiple times
  72. *
  73. * @since 15.0.0
  74. *
  75. * @param string $action
  76. * @param bool $force
  77. *
  78. * @return string
  79. * @throws \Exception
  80. */
  81. public function updateAction(string $action = '', bool $force = false): string;
  82. /**
  83. * Call this method in a Search Platform or Content Provider if there is an
  84. * issue while generating a document or while indexing the current document.
  85. * This is used to store and display errors in the UI during an index to help
  86. * admin to keep track of errors.
  87. *
  88. * @since 15.0.0
  89. *
  90. * @param IIndex $index
  91. * @param string $message
  92. * @param string $class
  93. * @param int $sev
  94. */
  95. public function newIndexError(IIndex $index, string $message, string $class = '', int $sev = 3);
  96. /**
  97. * Call this method only in a Search Platform after an index of a document.
  98. * This is used to store and display results (good or bad) in the UI during
  99. * an index to help admin to keep track of fail and successful indexes.
  100. *
  101. * @since 15.0.0
  102. *
  103. * @param IIndex $index
  104. * @param string $message
  105. * @param string $status
  106. * @param int $type
  107. */
  108. public function newIndexResult(IIndex $index, string $message, string $status, int $type);
  109. }