Index Application

Version 102.1 by Manuel Leduc on 2022/02/10 14:41
Warning: For security reasons, the document is displayed in restricted mode as it is not the current version. There may be differences and errors due to this.

application_side_treeAn Index of all pages, attachments, orphans and deleted pages and attachments found in the wiki.
TypeXAR
Category
Developed by

XWiki Development Team

Rating
0 Votes
LicenseGNU Lesser General Public License 2.1
Bundled With

XWiki Standard

Compatibility

Since 3.5M1

Installable with the Extension Manager

Description

The Index Application offers several features

  • Page Index for the whole wiki. Displays items found in the wiki: pages, attachments, orphans, deleted pages, deleted attachments
  • A macro to display all pages in a live table, based on some parameters
  • A deprecated macro to display all spaces based on some parameters
  • Page Index for a space (replaced by the siblings/children viewer in XWiki 7.2+).

If you're looking for the list of all applications installed in the wiki, check the Application Index.

Accessing the Indexes

The Page Index is available in the drawer menu (that you can active by clicking on the top right icon):

index-allpages-drawer.png

Before the creation of the drawer menu in XWiki 7.2, there were 2 Indexes available by default:

  • One for the whole wiki which can be accessed by navigating directly to the Main.AllDocs page or more easily when using the Colibri Skin by selecting the "Document Index" entry of the "Wiki" menu:

    index-alldocs-menu.png

  • Another for the current space which can be accessed by navigating directly to the Main.SpaceIndex page (you'll need to pass in parameter the name of the space for which you wish to see information about, e.g. .../Main/SpaceIndex?space=Sandbox) or more easily when using the Colibri Skin by selecting the "Document Index" entry of the "Space" menu:

    index-spaceindex-menu.png

Features

Table View of all Pages

Lists all pages found in the wiki in a filterable table view and allows performing actions on them: view, edit, delete, change access rights:

index-alldocs-docs.png

Tree View of all Pages

Lists all pages found in the wiki in a tree view:

index-alldocs-tree.png

You can search for specific pages and attachments. The tree will expand to show the corresponding node (v6.4.1+).

index-alldocs-tree-finder.png

All Attachments

Lists all attachments found in the wiki using a live table. You can filter and sort the attachments by mime type, file name, location, file size, last modification date and author.

attachmentIndex.png

All Deleted Pages

Lists all deleted pages found in the wiki and allows restoring them from the trash or deleting them forever from the trash:

index-alldocs-deleteddocs.png

If this tab doesn't appear, you may not have sufficient administrative rights to see it.

To restore a single deleted page, find the page from the list and click the "restore page" icon.

Permanently delete all pages

Starting with XWiki 10.11RC1 it is now possible to permanently delete all pages that have been already deleted, in order to clean the recycle bin.

Restoring a Page Translation

Starting with XWiki 6.2M2 in order to be able to restore a deleted page translation, the main page (default translation) needs to be first restored or recreated. To do that you have 2 options:

  • browse through the deleted pages, find and restore a default translation of the page OR
  • click on the disabled restore button of the translation and you will be redirected to the location of the default page where you can re-create it.

After clicking on the button to restore a translation, if the wiki is multilingual, you will be redirected to the restored page in the language of the translation you have just restored.

Restoring an Entire Batch

Starting with XWiki 9.4RC1 the Deleted Batch ID column allows you to filter or sort pages that were deleted together. Clicking on a page's batch ID will take you to the page's restore screen that will allow you to either restore just that page or the entire batch of pages that were deleted together with it.

Keep in mind that what you are seeing is the current state of the deleted batch. Some pages might have been restored in the meantime and others may have been deleted from the recycle bin. You will only see the deleted pages from that batch that are still inside the recycle bin.

The process can be observed in the following screens:

The log is displayed only for advanced users.

If a page from the batch was recreated in the meantime (i.e. not restored, but a new page was created in the location of a deleted one) then the restore operation will report as failed, even if all the other pages may have been successfully restored. An advanced user can inspect the log to see which page from the batch failed to restore.

restore-failed-alreadyexists.png

Note: The batch ID is also displayed and accessible when viewing a deleted page and seeing the recycle bin entries for that page. On that screen, clicking on the batch ID will take you through the above described process.

recyclebin-view-batchId.png

All Deleted Attachments

Lists all deleted attachments found in the wiki and allows restoring them from the trash or deleting them forever from the trash:
index-alldocs-deletedattachments.png

If this tab doesn't appear, you may not have sufficient administrative rights to see it.

There's currently only one action on deleted attachments in this view: it's the ability to permanently delete it. If you wish to restore an attachment, you'll need to navigate to the history of the page it was attached to and rollback to a version before the attachment was deleted. In the future we'll need to implement a proper restore attachment action as we have for deleted pages.

All Orphaned Pages

Starting with XWiki 7.2 this tab is not visible unless you enable the Parent-Child Hierarchy Mode.

Lists all orphaned pages found in the wiki (i.e. pages that have no parent set).

index-alldocs-orphaned.png

Pages Macro

See the documentation page for the Pages Macro.

Spaces Macro

See the documentation page for the deprecated Spaces macro.

Space-level Index

This has been replaced by the siblings/children viewer in XWiki 7.2+

The Space Index is completely similar to the Page Index but only lists information for the current space. For example for the Main space:

index-spaceindex-docs.png

Asynchronous Document Static Analysis

XWiki 14.1-rc-1+ 

Asynchronous analysis of document are possible with the TaskManager component. The queued tasks are persisted. In other word, they are not lost when the server is stopped, and will be queued again when the server is restarted.

TaskManager Roles

@Role
@Unstable
public interface TaskConsumer
{
   /**
     * Consume a task.
     *
     * @param documentReference of the document to analyze
     * @param version the version of the document to analyze
     * @throws IndexException in case of error during the execution of the task
     */

   void consume(DocumentReference documentReference, String version) throws IndexException;
}
@Role
@Unstable
public interface TaskManager
{
   /**
     * Add a task to the queue.
     *
     * @param wikiId the wiki containing the document
     * @param docId the document id
     * @param version the document version
     * @param type the type of task to add
     * @return a completable future for this task
     */

    CompletableFuture<TaskData> addTask(String wikiId, long docId, String version, String type);

   /**
     * Replace all the tasks of the queue with the same document and task type with the new task.
     *
     * @param wikiId the wiki containing the document
     * @param docId the document id
     * @param version the document version
     * @param type the type of task to add
     * @return a completable future for this task
     */

    CompletableFuture<TaskData> replaceTask(String wikiId, long docId, String version, String type);

   /**
     * @return the number of tasks in the queue
     */

   long getQueueSize();

   /**
     * @param type the type of task to count
     * @return the number of  tasks of a given type in the queue
     */

   long getQueueSize(String type);
}

Adding a task to the queue

The example below is drawn for the Mentions Application implementation. The method addTask is called on TaskManager is called with the following parameters:

  • the reference of the wiki in which the document to analyze is located
  • the unique id of the document to analyze
  • the version of the document to analyze (in our example, the latest version of the document)
  • the type of the task to execute on the document (in our example, the "mention" task)
@Component
@Singleton
@Named("MentionsCreatedEventListener")
public class MentionsCreatedEventListener extends AbstractEventListener
{
   private static final List<DocumentCreatedEvent> EVENTS = singletonList(new DocumentCreatedEvent());

   @Inject
   private Logger logger;

   @Inject
   private TaskManager taskManager;

   @Inject
   private RemoteObservationManagerContext remoteObservationManagerContext;

   /**
     * Default constructor.
     */

   public MentionsCreatedEventListener()
   {
       super("MentionsCreatedEventListener", EVENTS);
   }

   @Override
   public void onEvent(Event event, Object source, Object data)
   {
       if (!(event instanceof DocumentCreatedEvent) || this.remoteObservationManagerContext.isRemoteState()) {
           return;
       }
       this.logger.debug("Event [{}] received from [{}] with data [{}].", DocumentCreatedEvent.class.getName(), source,
            data);

        XWikiDocument doc = (XWikiDocument) source;
       this.taskManager.addTask(doc.getDocumentReference().getWikiReference().getName(), doc.getId(), doc.getVersion(),
            MENTION_TASK_ID);
   }
}

Implementing a task consumer

Implementing a task consumer is done by implementing the TaskConsumer role and given a unique hint to the new component. This hint must match the type of the queued task.
For each queued task, the component corresponding to the type of the task if resolved and called.

@Component
@Singleton
@Named("mention")
public class DefaultMentionsDataConsumer implements TaskConsumer
{
   @Override
   public void consume(DocumentReference documentReference, String version) throws IndexException
   {
      // [proceed to the analysis of the document in the given version]
   }
}

JMX Monitoring

An object named org.xwiki:name=index is declared and provides two attributes:

  • getQueueSize: Returns the total number of queued tasks
  • getQueueSizePerType: Returns the total number of tasks grouped by their types

Asynchronous Document Static Analysis

XWiki 14.1-rc-1+ 

Asynchronous analysis of document are possible with the TaskManager component. The queued tasks are persisted. In other word, they are not lost when the server is stopped, and will be queued again when the server is restarted.

TaskManager Roles

@Role
@Unstable
public interface TaskConsumer
{
   /**
     * Consume a task.
     *
     * @param documentReference of the document to analyze
     * @param version the version of the document to analyze
     * @throws IndexException in case of error during the execution of the task
     */

   void consume(DocumentReference documentReference, String version) throws IndexException;
}
@Role
@Unstable
public interface TaskManager
{
   /**
     * Add a task to the queue.
     *
     * @param wikiId the wiki containing the document
     * @param docId the document id
     * @param version the document version
     * @param type the type of task to add
     * @return a completable future for this task
     */

    CompletableFuture<TaskData> addTask(String wikiId, long docId, String version, String type);

   /**
     * Replace all the tasks of the queue with the same document and task type with the new task.
     *
     * @param wikiId the wiki containing the document
     * @param docId the document id
     * @param version the document version
     * @param type the type of task to add
     * @return a completable future for this task
     */

    CompletableFuture<TaskData> replaceTask(String wikiId, long docId, String version, String type);

   /**
     * @return the number of tasks in the queue
     */

   long getQueueSize();

   /**
     * @param type the type of task to count
     * @return the number of  tasks of a given type in the queue
     */

   long getQueueSize(String type);
}

Adding a task to the queue

The example below is drawn for the Mentions Application implementation. The method addTask is called on TaskManager is called with the following parameters:

  • the reference of the wiki in which the document to analyze is located
  • the unique id of the document to analyze
  • the version of the document to analyze (in our example, the latest version of the document)
  • the type of the task to execute on the document (in our example, the "mention" task)
@Component
@Singleton
@Named("MentionsCreatedEventListener")
public class MentionsCreatedEventListener extends AbstractEventListener
{
   private static final List<DocumentCreatedEvent> EVENTS = singletonList(new DocumentCreatedEvent());

   @Inject
   private Logger logger;

   @Inject
   private TaskManager taskManager;

   @Inject
   private RemoteObservationManagerContext remoteObservationManagerContext;

   /**
     * Default constructor.
     */

   public MentionsCreatedEventListener()
   {
       super("MentionsCreatedEventListener", EVENTS);
   }

   @Override
   public void onEvent(Event event, Object source, Object data)
   {
       if (!(event instanceof DocumentCreatedEvent) || this.remoteObservationManagerContext.isRemoteState()) {
           return;
       }
       this.logger.debug("Event [{}] received from [{}] with data [{}].", DocumentCreatedEvent.class.getName(), source,
            data);

        XWikiDocument doc = (XWikiDocument) source;
       this.taskManager.addTask(doc.getDocumentReference().getWikiReference().getName(), doc.getId(), doc.getVersion(),
            MENTION_TASK_ID);
   }
}

Implementing a task consumer

Implementing a task consumer is done by implementing the TaskConsumer role and given a unique hint to the new component. This hint must match the type of the queued task.
For each queued task, the component corresponding to the type of the task if resolved and called.

@Component
@Singleton
@Named("mention")
public class DefaultMentionsDataConsumer implements TaskConsumer
{
   @Override
   public void consume(DocumentReference documentReference, String version) throws IndexException
   {
      // [proceed to the analysis of the document in the given version]
   }
}

JMX Monitoring

An object named org.xwiki:name=index is declared and provides two attributes:

  • getQueueSize: Returns the total number of queued tasks
  • getQueueSizePerType: Returns the total number of tasks grouped by their types

Asynchronous Document Static Analysis

Asynchronous analysis of document are possible with the Unknown macro: TaskManager. Click on this message for details.

Get Connected