Class BatchesScriptServices

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

    @Component
    @Named("confluenceBatches")
    @Singleton
    public class BatchesScriptServices
    extends Object
    implements org.xwiki.script.service.ScriptService
    Expose various methods needed for the batch migrations.
    Since:
    1.30.2
    Version:
    $Id$
    • Constructor Detail

      • BatchesScriptServices

        public BatchesScriptServices()
    • Method Detail

      • computeBatchSize

        public String computeBatchSize​(List<String> paths)
        Computes the size of a batch.
        Parameters:
        paths - files that form the batch
        Returns:
        size of the batch
      • getZips

        public File[] getZips​(String path)
        Returns the files present in the specified directory or null if the given path is not a directory.
        Parameters:
        path - the source directory path
        Returns:
        an array of files in the directory if the path is valid; otherwise, null
      • getServerAbsolutePath

        public String getServerAbsolutePath()
        Returns the absolute path of the server to provide a hint to the user if the path given to getZips(String) is not valid.
        Returns:
        the absolute path of the server
      • createBatch

        public Map<String,​List<String>> createBatch​(String batchName,
                                                          List<String> sources,
                                                          String inputProperties,
                                                          String outputProperties,
                                                          Map<String,​String> extraParams)
                                                   throws com.fasterxml.jackson.core.JsonProcessingException,
                                                          com.xpn.xwiki.XWikiException
        Creates the batch and all its migrations.
        Parameters:
        batchName - The name of the batch.
        sources - The sources of the migration packages.
        inputProperties - The input properties of the migration.
        outputProperties - The output properties of the migration.
        extraParams - A map containing extra parameters for custom implementations that may require additional data.
        Returns:
        A map containing logs of the creation process.
        Throws:
        com.fasterxml.jackson.core.JsonProcessingException
        com.xpn.xwiki.XWikiException
      • resolveJson

        public com.fasterxml.jackson.databind.node.ObjectNode resolveJson​(String json)
                                                                   throws com.fasterxml.jackson.core.JsonProcessingException
        Receives a json in string format and returns a JSON object.
        Parameters:
        json - json string
        Returns:
        JSON object
        Throws:
        com.fasterxml.jackson.core.JsonProcessingException