Class AbstractExtensionScriptService

    • Field Detail

      • EXTENSIONERROR_KEY

        public static final String EXTENSIONERROR_KEY
        The key under which the last encountered error is stored in the current execution context.
        See Also:
        Constant Field Values
      • PROPERTY_CONTEXT_WIKI

        protected static final String PROPERTY_CONTEXT_WIKI
        Extension request property that specifies from which wiki the job was started.
        See Also:
        Constant Field Values
      • PROPERTY_CONTEXT_ACTION

        protected static final String PROPERTY_CONTEXT_ACTION
        Extension request property that specifies from which document action the job was started.
        See Also:
        Constant Field Values
      • WIKI_NAMESPACE_PREFIX

        protected static final String WIKI_NAMESPACE_PREFIX
        The prefix used for wiki namespace id.
        See Also:
        Constant Field Values
      • scriptProvider

        @Inject
        protected org.xwiki.script.internal.safe.ScriptSafeProvider scriptProvider
      • execution

        @Inject
        protected org.xwiki.context.Execution execution
        Provides access to the current context.
      • documentAccessBridge

        @Inject
        protected org.xwiki.bridge.DocumentAccessBridge documentAccessBridge
        Needed for getting the current user reference.
      • xcontextProvider

        @Inject
        protected javax.inject.Provider<XWikiContext> xcontextProvider
      • jobExecutor

        @Inject
        protected org.xwiki.job.JobExecutor jobExecutor
      • authorization

        @Inject
        protected org.xwiki.security.authorization.ContextualAuthorizationManager authorization
    • Constructor Detail

      • AbstractExtensionScriptService

        public AbstractExtensionScriptService()
    • Method Detail

      • safe

        protected <S> S safe​(Object unsafe)
        Type Parameters:
        S - the type of the safe object version
        Parameters:
        unsafe - the unsafe object
        Returns:
        the safe version of the passed object
      • setRightsProperties

        protected <T extends org.xwiki.job.AbstractRequest> void setRightsProperties​(T extensionRequest)
      • getCallerDocument

        protected XWikiDocument getCallerDocument()
      • getJobStatus

        protected org.xwiki.job.event.status.JobStatus getJobStatus​(List<String> jobId)
      • toWikiId

        protected String toWikiId​(String namespace)
        Parameters:
        namespace - the namespace
        Returns:
        the wiki identifier
        Since:
        8.1M1
      • fromWikitoNamespace

        protected String fromWikitoNamespace​(String wiki)
        Parameters:
        wiki - the wiki identifier
        Returns:
        the namespace
        Since:
        8.1M1
      • contextualize

        public void contextualize​(org.xwiki.job.AbstractRequest request)
        Add to the job request various information about the current context.
        Parameters:
        request - the job request
        Since:
        9.5
      • getLastError

        public Exception getLastError()
        Get the error generated while performing the previously called action.
        Returns:
        an eventual exception or null if no exception was thrown
      • setError

        protected void setError​(Exception e)
        Store a caught exception in the context, so that it can be later retrieved using getLastError().
        Parameters:
        e - the exception to store, can be null to clear the previously stored exception
        See Also:
        getLastError()
      • wrapError

        protected <R> R wrapError​(Callable<R> callable)
        Call the passed callable but try/catch and return null in case of exception (and update the last error).
        Type Parameters:
        R - the result type of method call
        Parameters:
        callable - a task that returns a result and may throw an exception
        Returns:
        the computed result
        Since:
        11.10
      • safeWrapError

        protected <R> R safeWrapError​(Callable<R> callable)
        Call the passed callable but try/catch and return null in case of exception (and update the last error). A safe verison of the result is returned.
        Type Parameters:
        R - the result type of method call
        Parameters:
        callable - a task that returns a result and may throw an exception
        Returns:
        the safe version of the computed result
        Since:
        11.10