XAR

Last modified by Thomas Mortagne on 2017/04/18 10:24

Handling of XAR packages as defined in specifications.

Script service

The XAR extension handler expose a ScriptService component for XAR extension specific features.

XAR Repair

Sometimes you have pages coming from an extension in the database but lost the actual extension index. The most common use case is when upgrading from a pre extension manager version of XWiki.

To recreate index for those extension the script service provide Job repairInstalledExtension(String id, String version, String wiki) API.

   /**
     * Make sure the provided XAR extension properly is registered in the installed extensions index.
     * <p>
     * Start an asynchronous Job.
     *
     * @param id the extension identifier
     * @param version the extension version
     * @param wiki the wiki where the extension is installed
     * @return the {@link Job} object which can be used to monitor the progress of the installation process, or
     *         {@code null} in case of failure
     */

   public Job repairInstalledExtension(String id, String version, String wiki)

Extension Diff

[since 7.0]

It's possible to get a full diff between an extension and all its dependencies and what is actually in the database. For this you can use Job diff(String feature, String wiki) method.

   /**
     * Computes the differences, in unified format, between the documents of an installed XAR extension and the document
     * from the wiki.
     *
     * @param feature the identifier of a XAR extension (or one of its features)
     * @param wiki the wiki where the XAR extension is installed
     * @return the {@link Job} object which can be used to monitor the progress while the differences are being
     *         computed, or {@code null} in case of failure
     * @since 7.0RC1
     */

   public Job diff(String feature, String wiki)

   /**
     * Get the id of the previously (or currently) computed differences, in unified format, between the documents of an
     * installed XAR extension and the document from the wiki..
     *
     * @param feature the identifier of a XAR extension (or one of its features)
     * @param namespace the namespace where the XAR extension is installed
     * @return the id of the {@link Job}
     * @since 9.3RC1
     */

   public List<String> getDiffJobId(String feature, String namespace)

Conflict handling

[since 9.2]

The script service allow getting all the possible types of conflict to can get when installing/upgrading an extension.

   /**
     * @return the possible conflicts
     * @since 9.2RC1
     */

   public ConflictQuestion.ConflictType[] getConflictTypes()

Document to extension

[since 9.3]

The script service provide a set of API to link document to the installed extension where they originated from.

It's possible to:

  • get extensions associated to a specific document reference
  • it's possible to get a com.xpn.xwiki.api.Document instance of a document coming from a XAR package
  • reset a document to it's standard (as in what it looks like in the XAR package) version
   /**
     * @param reference the reference of the document to reset to its standard state (what it looks like in the
     *            extension XAR)
     * @param extensionId the installed extension from which to get the standard version of the document
     * @param jobId the id of the job which computed the diff if any
     * @return true if the reset actually did something, false otherwise (any produced error can be accessed using
     *         {@link #getLastError()})
     * @since 9.3RC1
     */

   public boolean reset(DocumentReference reference, ExtensionId extensionId, List<String> jobId)

   /**
     * @param reference the reference of the document to reset to its standard state (what it looks like in the
     *            extension XAR)
     * @param jobId the id of the job which computed the diff if any
     * @return true if the reset actually did something, false otherwise (any produced error can be accessed using
     *         {@link #getLastError()})
     * @since 9.3RC1
     */

   public boolean reset(DocumentReference reference, List<String> jobId)

   /**
     * @param reference the reference of the document
     * @return the installed XAR extensions in which this document can be found
     * @since 9.3RC1
     */

   public Collection<InstalledExtension> getInstalledExtensions(DocumentReference reference)

   /**
     * @param reference the reference of the document
     * @return a Document instance of passed document when extracted from the standard extension matching this
     *         reference. Null if none could be found.
     * @throws XarExtensionExtension when failing to get the document
     * @since 9.3RC1
     */

   public Document getInstalledExtensionDocument(DocumentReference reference) throws XarExtensionExtension
Tags:
Created by Thomas Mortagne on 2017/04/18 10:23
    

Get Connected