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.ScriptServiceAdmin Tools script services.- Since:
- 1.0
- Version:
- $Id$
-
-
Field Summary
Fields Modifier and Type Field Description protected AdminToolsConfigurationadminToolsConfig
-
Constructor Summary
Constructors Constructor Description AdminToolsScriptService()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description StringcheckSecurityCache(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.Map<String,String>extractRuleUsersGroups(org.xwiki.security.authorization.SecurityRule rule)Extract the users and groups from the givenSecurityRule.StringgetConfigurationData()Retrieve all the configuration information in a format given by the associated templates generated by the data providers.StringgetConfigurationData(String hint)Get a specific data provider information in a format given by the associated template.org.apache.solr.common.SolrDocumentListgetEmptyDocuments(Map<String,String> filters, String order)Retrieve the empty documents from the XWiki instance.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.StringgetFilesSection()Get the rendered template for accessing the downloads UI.List<String>getHealthCheckJobId()Get the Health Check job id for the current wiki.StringgetInstanceSizeSection()Get the rendered template for viewing info about the size of the XWiki instance.Map<String,Object>getJSONFromNetwork(String target, Map<String,String> parameters, boolean useRef)Retrieve JSON data from the given network endpoint.intgetMinimumSpamSize()Retrieve the configuration settings for minimum spam size.Map<String,Object>getNetworkLimits()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.List<String>getSupportedDatabases()Retrieve the supported databases.List<String>getSupportedServers()Retrieve the supported servers.List<com.xwiki.admintools.internal.usage.wikiResult.WikiRecycleBins>getWikisRecycleBinSize(Map<String,String> filters, String sortColumn, String order)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>getWikisSize(Map<String,String> filters, String sortColumn, String order)Get aListofWikiSizeResultwith the options to sort it and apply filters on it.booleanisUsedServerCompatible()Check if the used server is compatible with Admin tools installation.org.xwiki.job.JobrunHealthChecks()Check if an Admin Tools Health Check job for the wiki from where the request was made exists.
-
-
-
Field Detail
-
adminToolsConfig
@Inject @Named("default") protected AdminToolsConfiguration adminToolsConfig
-
-
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- 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.- 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 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.AccessDeniedException
Retrieve 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.AccessDeniedException
Get 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.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
Stringrepresentation 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
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.AccessDeniedException
Retrieve 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
@Unstable public org.xwiki.job.Job runHealthChecks() throws ExceptionCheck 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
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.WikiManagerException
Get 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
-
-