Class AdminToolsScriptService

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

    @Component
    @Named("admintools")
    @Singleton
    @Unstable
    public class AdminToolsScriptService
    extends Object
    implements org.xwiki.script.service.ScriptService
    Admin Tools script services.
    Since:
    1.0
    Version:
    $Id$
    • Constructor Detail

      • AdminToolsScriptService

        public AdminToolsScriptService()
    • Method Detail

      • getJSONFromNetwork

        @Unstable
        public Map<String,​Object> getJSONFromNetwork​(String target,
                                                           Map<String,​String> parameters,
                                                           boolean useRef)
                                                    throws IOException,
                                                           InterruptedException,
                                                           org.xwiki.security.authorization.AccessDeniedException
        Retrieve JSON data from the given network endpoint.
        Parameters:
        target - the target endpoint.
        parameters - parameters to be sent with the request.
        useRef - if true, the account reference will be added to the received parameters. If false, the account and instance number will be added.
        Returns:
        the JSON retrieved from the network, or null if the user has no access.
        Throws:
        IOException - if an I/O error occurs when sending the request or receiving the response.
        InterruptedException - if the operation is interrupted.
        org.xwiki.security.authorization.AccessDeniedException - if the requesting user lacks admin rights.
        Since:
        1.3
      • getNetworkLimits

        @Unstable
        public Map<String,​Object> getNetworkLimits()
                                                  throws IOException,
                                                         InterruptedException,
                                                         org.xwiki.security.authorization.AccessDeniedException
        Get network limits for the current instance.
        Returns:
        A JSON with the instance limits.
        Throws:
        IOException - if an I/O error occurs when sending the request or receiving the response.
        InterruptedException - if the operation is interrupted.
        org.xwiki.security.authorization.AccessDeniedException - if the requesting user lacks admin rights.
        Since:
        1.3
      • checkSecurityCache

        @Unstable
        public String checkSecurityCache​(org.xwiki.model.reference.DocumentReference userRef,
                                         org.xwiki.model.reference.DocumentReference docRef)
                                  throws org.xwiki.security.authorization.AuthorizationException
        Retrieve the cached and live security rules in a table format given by the associated template.
        Parameters:
        userRef - the user for which to check the access cache rules.
        docRef - the document on which to check the security rules.
        Returns:
        the cached and live security rules in a table format given by the associated template.
        Throws:
        org.xwiki.security.authorization.AuthorizationException - if any error occurs while accessing the security entry.
        Since:
        1.2
      • extractRuleUsersGroups

        @Unstable
        public Map<String,​String> extractRuleUsersGroups​(org.xwiki.security.authorization.SecurityRule rule)
        Extract the users and groups from the given SecurityRule.
        Parameters:
        rule - the rule from which to extract the data.
        Returns:
        a Map with the 'Users' and 'Groups' as keys and the extracted info from the rule as values.
        Since:
        1.2
      • getEntityRights

        @Unstable
        public List<RightsResult> getEntityRights​(Map<String,​String> filters,
                                                  String sortColumn,
                                                  String order,
                                                  String entityType)
        Retrieves a filtered and sorted list of RightsResult representing the rights for the given parameters.
        Parameters:
        filters - a map of filters to apply.
        sortColumn - the column used for sorting.
        order - the sorting order (asc or desc).
        entityType - the type of entity for which rights are retrieved.
        Returns:
        a filtered and sorted List of RightsResult.
        Since:
        1.2
      • getConfigurationData

        @Unstable
        public String getConfigurationData()
                                    throws org.xwiki.security.authorization.AccessDeniedException
        Retrieve all the configuration information in a format given by the associated templates generated by the data providers.
        Returns:
        a String representing all templates.
        Throws:
        org.xwiki.security.authorization.AccessDeniedException
        Since:
        1.0
      • getWikisSize

        @Unstable
        public List<com.xwiki.admintools.internal.usage.wikiResult.WikiSizeResult> getWikisSize​(Map<String,​String> filters,
                                                                                                String sortColumn,
                                                                                                String order)
                                                                                         throws org.xwiki.security.authorization.AccessDeniedException
        Get a List of WikiSizeResult with the options to sort it and apply filters on it.
        Parameters:
        filters - Map of filters to be applied on the gathered list.
        sortColumn - target column to apply the sort on.
        order - the order of the sort.
        Returns:
        a filtered and sorted List of WikiSizeResult.
        Throws:
        org.xwiki.security.authorization.AccessDeniedException - if the requesting user lacks admin rights.
        Since:
        1.0
      • getConfigurationData

        @Unstable
        public String getConfigurationData​(String hint)
                                    throws org.xwiki.security.authorization.AccessDeniedException,
                                           org.xwiki.component.manager.ComponentLookupException
        Get a specific data provider information in a format given by the associated template.
        Parameters:
        hint - String representing the data provider
        Returns:
        a String representing a specific template.
        Throws:
        org.xwiki.security.authorization.AccessDeniedException
        org.xwiki.component.manager.ComponentLookupException
        Since:
        1.0
      • getSupportedDatabases

        @Unstable
        public List<String> getSupportedDatabases()
                                           throws org.xwiki.security.authorization.AccessDeniedException
        Retrieve the supported databases.
        Returns:
        inline list with supported databases separated by ",".
        Throws:
        org.xwiki.security.authorization.AccessDeniedException
        Since:
        1.0
      • getSupportedServers

        @Unstable
        public List<String> getSupportedServers()
                                         throws org.xwiki.security.authorization.AccessDeniedException
        Retrieve the supported servers.
        Returns:
        inline list with supported servers separated by ",".
        Throws:
        org.xwiki.security.authorization.AccessDeniedException
        Since:
        1.0
      • getFilesSection

        @Unstable
        public String getFilesSection()
                               throws org.xwiki.security.authorization.AccessDeniedException
        Get the rendered template for accessing the downloads UI.
        Returns:
        a String representation of the template.
        Throws:
        org.xwiki.security.authorization.AccessDeniedException
        Since:
        1.0
      • getInstanceSizeSection

        @Unstable
        public String getInstanceSizeSection()
                                      throws org.xwiki.security.authorization.AccessDeniedException
        Get the rendered template for viewing info about the size of the XWiki instance.
        Returns:
        a String representation of the template.
        Throws:
        org.xwiki.security.authorization.AccessDeniedException
        Since:
        1.0
      • getPagesOverGivenNumberOfComments

        @Unstable
        public org.apache.solr.common.SolrDocumentList getPagesOverGivenNumberOfComments​(long maxComments,
                                                                                         Map<String,​String> filters,
                                                                                         String order)
                                                                                  throws org.xwiki.security.authorization.AccessDeniedException
        Retrieve the pages that have more than a given number of comments.
        Parameters:
        maxComments - maximum number of comments below which the page is ignored.
        filters - Map of filters to be applied on the gathered list.
        order - the order of the sort.
        Returns:
        a SolrDocumentList with the needed fields set.
        Throws:
        org.xwiki.security.authorization.AccessDeniedException
        Since:
        1.0
      • getEmptyDocuments

        @Unstable
        public org.apache.solr.common.SolrDocumentList getEmptyDocuments​(Map<String,​String> filters,
                                                                         String order)
                                                                  throws org.xwiki.security.authorization.AccessDeniedException
        Retrieve the empty documents from the XWiki instance.
        Parameters:
        filters - Map of filters to be applied on the results list.
        order - the order of the sort.
        Returns:
        a SolrDocumentList with the empty documents.
        Throws:
        org.xwiki.security.authorization.AccessDeniedException
        Since:
        1.0.1
      • getMinimumSpamSize

        @Unstable
        public int getMinimumSpamSize()
                               throws org.xwiki.security.authorization.AccessDeniedException
        Retrieve the configuration settings for minimum spam size.
        Returns:
        an Integer representing the configured minimum spam size.
        Throws:
        org.xwiki.security.authorization.AccessDeniedException
        Since:
        1.0
      • runHealthChecks

        @Unstable
        public org.xwiki.job.Job runHealthChecks()
                                          throws Exception
        Check if an Admin Tools Health Check job for the wiki from where the request was made exists. If it does, return the job instance, else create a new Admin Tools health check request for the given wiki and start the execution.
        Returns:
        the asynchronous background job that will execute the request.
        Throws:
        Exception
        Since:
        1.0
      • getHealthCheckJobId

        @Unstable
        public List<String> getHealthCheckJobId()
                                         throws org.xwiki.security.authorization.AccessDeniedException
        Get the Health Check job id for the current wiki.
        Returns:
        Health check job id.
        Throws:
        org.xwiki.security.authorization.AccessDeniedException
        Since:
        1.0
      • isUsedServerCompatible

        @Unstable
        public boolean isUsedServerCompatible()
        Check if the used server is compatible with Admin tools installation.
        Returns:
        a true if the used server is compatible with the application installation, or false otherwise.
        Since:
        1.0
      • getWikisRecycleBinSize

        @Unstable
        public List<com.xwiki.admintools.internal.usage.wikiResult.WikiRecycleBins> getWikisRecycleBinSize​(Map<String,​String> filters,
                                                                                                           String sortColumn,
                                                                                                           String order)
                                                                                                    throws org.xwiki.security.authorization.AccessDeniedException,
                                                                                                           org.xwiki.wiki.manager.WikiManagerException
        Get recycle bin info for all wikis in your instance with the options to sort and apply filters on it.
        Parameters:
        filters - Map of filters to be applied on the gathered list.
        sortColumn - target column to apply the sort on.
        order - the order of the sort.
        Returns:
        Throws:
        org.xwiki.security.authorization.AccessDeniedException
        org.xwiki.wiki.manager.WikiManagerException
        Since:
        1.0