Class DriveScriptService

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

    @Component
    @Named("drive")
    @Singleton
    public class DriveScriptService
    extends Object
    implements org.xwiki.script.service.ScriptService
    Exposes simplified APIs to execute batch jobs on a file system drive.

    All jobs work with file system paths. A path is uniquely determined either by an existing folder or by a (parent, child) pair. A file cannot specify the path alone because files can have multiple parent folders (so a file can have multiple paths). Also, a path to a new file or new folder needs to specify the parent folder. In other words, a list with a single item represents a path to a folder, while a list with two items represents a path to either a file or a new sub-folder.

    Since:
    2.0M1
    Version:
    $Id$
    • Constructor Detail

      • DriveScriptService

        public DriveScriptService()
    • Method Detail

      • move

        public String move​(Collection<String> paths,
                           String destination)
        Schedules a job to move the specified files and folders to the given destination.
        Parameters:
        paths - the files and folders to move
        destination - where to move the specified files and folders
        Returns:
        the id of the move job that has been scheduled
      • copy

        public String copy​(Collection<String> paths,
                           String destination)
        Schedules a job to copy the specified files and folders to the given destination.
        Parameters:
        paths - the files and folders to copy
        destination - where to copy the specified files and folders
        Returns:
        the id of the copy job that has been scheduled
      • delete

        public String delete​(Collection<String> paths)
        Schedules a job to delete the specified files and folders.
        Parameters:
        paths - the files and folders to delete
        Returns:
        the id of the delete job that has been scheduled
      • pack

        public String pack​(Collection<String> paths,
                           org.xwiki.model.reference.AttachmentReference outputFileReference)
        Schedules a job to pack the specified files and folders into a single ZIP archive.

        The DocumentReference part of the given AttachmentReference represents the document that is going to be used to access the output ZIP file. This means that only users with view right on this document can access the output file. The name property of the given AttachmentReference will be used as the name of the output ZIP file.

        The output file is a temporary file (deleted automatically when the server is stopped) that can be accessed through the 'temp' action, e.g.: /xwiki/temp/Space/Page/filemanager/file.zip .

        Parameters:
        paths - the files and folders to be packed
        outputFileReference - the reference to the output ZIP file
        Returns:
        the id of the pack job that has been scheduled
        Since:
        2.0M2
      • getJobStatus

        public org.xwiki.job.event.status.JobStatus getJobStatus​(String jobId)
        Parameters:
        jobId - the job whose status to return
        Returns:
        the status of the specified job
      • getActiveJobs

        public List<String> getActiveJobs()
        Returns:
        the list of file system jobs that are running or that are pending for execution on the current drive
      • getUniqueReference

        public org.xwiki.model.reference.DocumentReference getUniqueReference​(String name)
        Generates a unique reference for a file or folder with the specified name.
        Parameters:
        name - the name of the file or folder for which to generate a reference
        Returns:
        a unique file or folder reference
        Since:
        2.0RC1
      • 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