Package com.xwiki.admintools.script
Class AdminToolsScriptService
java.lang.Object
com.xwiki.admintools.script.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$
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncheckSecurityCache(org.xwiki.model.reference.DocumentReference userRef, org.xwiki.model.reference.DocumentReference docRef) Retrieve the cached and live security rules in a table format given by the associated template.extractRuleUsersGroups(org.xwiki.security.authorization.SecurityRule rule) Extract the users and groups from the givenSecurityRule.Retrieve all the configuration information in a format given by the associated templates generated by the data providers.getConfigurationData(String hint) Get a specific data provider information in a format given by the associated template.getDetailedCacheData(String name) Get detailed statistics for a specific cache.org.apache.solr.common.SolrDocumentListgetEmptyDocuments(Map<String, String> filters, String order) Retrieve the empty documents from the XWiki instance.Retrieves a filtered and sorted list ofRightsResultrepresenting the rights for the given parameters.Get the rendered template for accessing the downloads UI.Get the Health Check job id for the current wiki.Get the rendered template for viewing info about the size of the XWiki instance.getJMXCache(String filter, String order) Get a sorted and filteredListwith the JMX managed caches.getJSONFromNetwork(String target, Map<String, String> parameters, boolean useRef) Retrieve JSON data from the given network endpoint.intRetrieve the configuration settings for minimum spam size.Get network limits for the current instance.org.apache.solr.common.SolrDocumentListgetPagesOverGivenNumberOfComments(long maxComments, Map<String, String> filters, String order) Retrieve the pages that have more than a given number of comments.Retrieve the supported databases.Retrieve the supported servers.List<com.xwiki.admintools.internal.usage.wikiResult.WikiRecycleBins>Get recycle bin info for all wikis in your instance with the options to sort and apply filters on it.List<com.xwiki.admintools.internal.usage.wikiResult.WikiSizeResult>Get aListofWikiSizeResultwith the options to sort it and apply filters on it.booleanCheck if the used server is compatible with Admin tools installation.org.xwiki.job.JobCheck if an Admin Tools Health Check job for the wiki from where the request was made exists.
-
Field Details
-
adminToolsConfig
-
-
Constructor Details
-
AdminToolsScriptService
public AdminToolsScriptService()
-
-
Method Details
-
getJMXCache
Get a sorted and filteredListwith the JMX managed caches.- Parameters:
filter- used to filter caches by nameorder- the sort order applied to the result, based on the number of entries- Returns:
- a sorted and filtered
Listwith the JMX managed caches - Throws:
org.xwiki.security.authorization.AccessDeniedException- if the requesting user lacks admin rights.Exception- Since:
- 1.4
-
getDetailedCacheData
Get detailed statistics for a specific cache. -
getJSONFromNetwork
@Unstable public Map<String,Object> getJSONFromNetwork(String target, Map<String, String> parameters, boolean useRef) throws ExceptionRetrieve JSON data from the given network endpoint.- Parameters:
target- the target endpoint.parameters- parameters to be sent with the request.useRef- iftrue, the account reference will be added to the received parameters. Iffalse, 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.Exception- Since:
- 1.3
-
getNetworkLimits
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.Exception- 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 givenSecurityRule.- Parameters:
rule- the rule from which to extract the data.- Returns:
- a
Mapwith 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 ofRightsResultrepresenting 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
ListofRightsResult. - Since:
- 1.2
-
getConfigurationData
@Unstable public String getConfigurationData() throws org.xwiki.security.authorization.AccessDeniedExceptionRetrieve all the configuration information in a format given by the associated templates generated by the data providers.- Returns:
- a
Stringrepresenting 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.AccessDeniedExceptionGet aListofWikiSizeResultwith the options to sort it and apply filters on it.- Parameters:
filters-Mapof 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
ListofWikiSizeResult. - 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. -
getSupportedDatabases
@Unstable public List<String> getSupportedDatabases() throws org.xwiki.security.authorization.AccessDeniedExceptionRetrieve 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.AccessDeniedExceptionRetrieve 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.AccessDeniedExceptionGet the rendered template for accessing the downloads UI.- Returns:
- a
Stringrepresentation of the template. - Throws:
org.xwiki.security.authorization.AccessDeniedException- Since:
- 1.0
-
getInstanceSizeSection
@Unstable public String getInstanceSizeSection() throws org.xwiki.security.authorization.AccessDeniedExceptionGet the rendered template for viewing info about the size of the XWiki instance.- Returns:
- a
Stringrepresentation 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.AccessDeniedExceptionRetrieve the pages that have more than a given number of comments.- Parameters:
maxComments- maximum number of comments below which the page is ignored.filters-Mapof filters to be applied on the gathered list.order- the order of the sort.- Returns:
- a
SolrDocumentListwith 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.AccessDeniedExceptionRetrieve the empty documents from the XWiki instance.- Parameters:
filters-Mapof filters to be applied on the results list.order- the order of the sort.- Returns:
- a
SolrDocumentListwith the empty documents. - Throws:
org.xwiki.security.authorization.AccessDeniedException- Since:
- 1.0.1
-
getMinimumSpamSize
@Unstable public int getMinimumSpamSize() throws org.xwiki.security.authorization.AccessDeniedExceptionRetrieve the configuration settings for minimum spam size.- Returns:
- an
Integerrepresenting the configured minimum spam size. - Throws:
org.xwiki.security.authorization.AccessDeniedException- Since:
- 1.0
-
runHealthChecks
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.AccessDeniedExceptionGet 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
trueif the used server is compatible with the application installation, orfalseotherwise. - 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.WikiManagerExceptionGet recycle bin info for all wikis in your instance with the options to sort and apply filters on it.- Parameters:
filters-Mapof 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.AccessDeniedExceptionorg.xwiki.wiki.manager.WikiManagerException- Since:
- 1.0
-