Class XarExtensionScriptService

  • All Implemented Interfaces:
    org.xwiki.script.service.ScriptService

    @Component
    @Named("extension.xar")
    @Singleton
    public class XarExtensionScriptService
    extends AbstractExtensionScriptService
    Various XAR oriented APIs for scripts.
    Since:
    5.3M1
    Version:
    $Id: d2d980ddd5e21f1d1f0477c126ca7c07c944b72c $
    • Constructor Detail

      • XarExtensionScriptService

        public XarExtensionScriptService()
    • Method Detail

      • repairInstalledExtension

        public org.xwiki.job.Job repairInstalledExtension​(String id,
                                                          String version,
                                                          String wiki)
        Make sure the provided XAR extension properly is registered in the installed extensions index.

        Start an asynchronous Job.

        Parameters:
        id - the extension identifier
        version - the extension version
        wiki - the wiki where the extension is installed
        Returns:
        the Job object which can be used to monitor the progress of the installation process, or null in case of failure
      • getDiffJobId

        public List<String> getDiffJobId​(String feature,
                                         String namespace)
        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..
        Parameters:
        feature - the identifier of a XAR extension (or one of its features)
        namespace - the namespace where the XAR extension is installed
        Returns:
        the id of the Job
        Since:
        9.3RC1
      • diff

        public org.xwiki.job.Job diff​(String feature,
                                      String wiki)
        Computes the differences, in unified format, between the documents of an installed XAR extension and the document from the wiki.
        Parameters:
        feature - the identifier of a XAR extension (or one of its features)
        wiki - the wiki where the XAR extension is installed
        Returns:
        the Job object which can be used to monitor the progress while the differences are being computed, or null in case of failure
        Since:
        7.0RC1
      • reset

        public boolean reset​(DocumentReference reference,
                             org.xwiki.extension.ExtensionId extensionId,
                             List<String> jobId)
        Parameters:
        reference - the reference of the document to reset to its standard state (what it looks like in the extension XAR)
        extensionId - the installed extension from which to get the standard version of the document
        jobId - the id of the job which computed the diff if any
        Returns:
        true if the reset actually did something, false otherwise (any produced error can be accessed using AbstractExtensionScriptService.getLastError())
        Since:
        9.3RC1
      • reset

        public boolean reset​(DocumentReference reference,
                             List<String> jobId)
        Parameters:
        reference - the reference of the document to reset to its standard state (what it looks like in the extension XAR)
        jobId - the id of the job which computed the diff if any
        Returns:
        true if the reset actually did something, false otherwise (any produced error can be accessed using AbstractExtensionScriptService.getLastError())
        Since:
        9.3RC1
      • getInstalledExtensions

        public Collection<org.xwiki.extension.InstalledExtension> getInstalledExtensions​(DocumentReference reference)
        Parameters:
        reference - the reference of the document
        Returns:
        the installed XAR extensions in which this document can be found
        Since:
        9.3RC1
      • getInstalledExtensionDocument

        public Document getInstalledExtensionDocument​(DocumentReference reference)
                                               throws XarExtensionException
        Parameters:
        reference - the reference of the document
        Returns:
        a Document instance of passed document when extracted from the standard extension matching this reference. Null if none could be found.
        Throws:
        XarExtensionException - when failing to get the document
        Since:
        9.3RC1
      • getInstalledExtensionDocument

        public Document getInstalledExtensionDocument​(DocumentReference reference,
                                                      org.xwiki.extension.ExtensionId extensionId)
                                               throws XarExtensionException
        Parameters:
        reference - the reference of the document
        extensionId - the id of the extension from which to get the standard version of the document
        Returns:
        a Document instance of passed document when extracted from the standard extension matching this reference. Null if none could be found.
        Throws:
        XarExtensionException - when failing to get the document
        Since:
        9.3RC1
      • getInstalledExtensionDocument

        public Document getInstalledExtensionDocument​(DocumentReference reference,
                                                      org.xwiki.extension.xar.internal.repository.XarInstalledExtension extension)
                                               throws XarExtensionException
        Parameters:
        reference - the reference of the document
        extension - the extension from which to get the standard version of the document
        Returns:
        a Document instance of passed document when extracted from the standard extension matching this reference. Null if none could be found.
        Throws:
        XarExtensionException - when failing to get the document
        Since:
        9.3RC1
      • isEditAllowed

        public boolean isEditAllowed​(DocumentReference documentReference)
        Parameters:
        documentReference - the reference of the document
        Returns:
        true if edit is allowed on the passed document
        Since:
        10.3
      • isDeleteAllowed

        public boolean isDeleteAllowed​(DocumentReference documentReference)
        Parameters:
        documentReference - the reference of the document
        Returns:
        true if edit is allowed on the passed document
        Since:
        10.3
      • getEditSecurityLevel

        public ProtectionLevel getEditSecurityLevel​(DocumentReference userReference,
                                                    DocumentReference documentReference)
        Parameters:
        userReference - the reference of the user
        documentReference - the reference of the document
        Returns:
        the protection level
        Since:
        10.5RC1
      • getDeleteSecurityLevel

        public ProtectionLevel getDeleteSecurityLevel​(DocumentReference userReference,
                                                      DocumentReference documentReference)
        Parameters:
        userReference - the reference of the user
        documentReference - the reference of the document
        Returns:
        the protection level
        Since:
        10.5RC1
      • isExtensionDocument

        public Boolean isExtensionDocument​(DocumentReference documentReference)
        Parameters:
        documentReference - a document reference
        Returns:
        true if the specified document belongs to an installed extension (either part of a XAR or generated by a mandatory document initializer)
        Since:
        11.10
      • isCustomizedExtensionDocument

        public Boolean isCustomizedExtensionDocument​(DocumentReference documentReference)
        Parameters:
        documentReference - a document reference
        Returns:
        true if the specified document is an extension document that has customizations (e.g. compared with the version from the XAR)
        Since:
        11.10