Class ScriptRepoHelper

    • Field Detail

      • SCRIPT_REPO

        public static final java.lang.String SCRIPT_REPO
        Id used by all script repositories. Having a well defined string allows for various repositories to all provide the same functionality.
        See Also:
        Constant Field Values
    • Method Detail

      • checkForScriptUpdates

        public void checkForScriptUpdates()
        Check for updates to scripts, modifying database accordingly. Called when Blitz is configured.
      • buildQuery

        public void buildQuery​(QueryBuilder qb)
        Adds a single clause of the form "AND (A OR B ...)" where each ScriptFileType A, B, etc. is given a chance to define its own clause.
      • findByMimetype

        protected java.util.Map.Entry<java.lang.String,​ScriptFileType> findByMimetype​(java.lang.String mimetype)
        Search through all ScriptFileType instances and find one with a matching mimetype string. Otherwise, return null.
      • getLauncher

        public java.lang.String getLauncher​(java.lang.String mimetype)
        Find an "omero.launcher..." property string for the given mimetype or return "" if none is found.
      • getProcess

        public java.lang.String getProcess​(java.lang.String mimetype)
        Find an "omero.process..." property string for the given mimetype or return "" if none is found.
      • getDefaultScriptDir

        public static java.lang.String getDefaultScriptDir()
        Directory which will be used as the root of this repository if no directory is passed to a constructor. Equivalent to "lib/scripts" from the current directory.
      • getScriptDir

        public java.lang.String getScriptDir()
        Returns the actual root of this repository.
        See Also:
        getDefaultScriptDir()
      • getUuid

        public java.lang.String getUuid()
        Uuid of this repository. In the normal case, this will equal SCRIPT_REPO.
      • countOnDisk

        public int countOnDisk()
        Returns the number of files which match scriptFilter in dir. Uses iterate() internally.
      • countInDb

        public int countInDb()
      • idsInDb

        public java.util.List<java.lang.Long> idsInDb()
      • isInRepo

        public boolean isInRepo​(long id)
      • findInDb

        public java.lang.Long findInDb​(java.lang.String path,
                                       boolean scriptsOnly)
      • findInDb

        public java.lang.Long findInDb​(RepoFile file,
                                       boolean scriptsOnly)
      • findInDb

        public java.lang.Long findInDb​(ome.util.SqlAction sql,
                                       RepoFile repoFile,
                                       boolean scriptsOnly)
        Looks to see if a path is contained in the repository.
      • iterate

        public java.util.Iterator<java.io.File> iterate()
      • loadAll

        public java.util.List<ome.model.core.OriginalFile> loadAll​(boolean modificationCheck,
                                                                   java.lang.String mimetype)
        Walks all files in the repository (via iterate() and adds them if not found in the database. If modificationCheck is true, then a change in the hash for a file in the repository will cause the old file to be removed from the repository
        (uuid == null)
        and a new file created in its place.
        Parameters:
        modificationCheck -
        mimetype - the mimetype of the scripts or null.
        Returns:
        See above.
      • loadAll

        public java.util.List<ome.model.core.OriginalFile> loadAll​(boolean modificationCheck)
        Walks all files in the repository (via iterate() and adds them if not found in the database. If modificationCheck is true, then a change in the hash for a file in the repository will cause the old file to be removed from the repository
        (uuid == null)
        and a new file created in its place.
        Parameters:
        modificationCheck -
        Returns:
        See above.
      • unregister

        protected void unregister​(java.lang.Long old,
                                  ome.util.SqlAction sqlAction)
        Unregisters a given file from the script repository by setting its Repo uuid to null.
      • read

        public java.lang.String read​(java.lang.String path)
                              throws java.io.IOException
        Throws:
        java.io.IOException
      • write

        public RepoFile write​(java.lang.String path,
                              java.lang.String text)
                       throws java.io.IOException
        Throws:
        java.io.IOException
      • write

        public RepoFile write​(RepoFile repo,
                              java.lang.String text)
                       throws java.io.IOException
        Throws:
        java.io.IOException
      • modificationCheck

        public void modificationCheck()
        Checks if
      • delete

        public boolean delete​(long id)
      • simpleDelete

        public void simpleDelete​(java.util.Map<java.lang.String,​java.lang.String> context,
                                 Executor executor,
                                 ome.system.Principal p,
                                 long id)
        Unlike delete(long) this method simply performs the DB delete on the given original file id.
        Parameters:
        context - Call context which affects which group the current user is in. Can be null to pass no call context.
        executor -
        p -
        id - Id of the OriginalFile to delete.
      • isInert

        public boolean isInert​(ome.model.core.OriginalFile f)
        Returns true if the file is an "inert" file e.g. a lut, false otherwise.
        Parameters:
        f - The file to handle.
        Returns:
        See above.