public class ScriptRepoHelper extends OnContextRefreshedEventListener
Modifier and Type | Field and Description |
---|---|
static org.apache.commons.io.filefilter.IOFileFilter |
BASE_SCRIPT_FILTER
IOFileFilter instance used during iterate() to find the
matching scripts in the given directory. |
protected org.slf4j.Logger |
log |
static java.lang.String |
SCRIPT_REPO
Id used by all script repositories.
|
Constructor and Description |
---|
ScriptRepoHelper(Executor ex,
java.lang.String sessionUuid,
ome.system.Roles roles)
Deprecated.
|
ScriptRepoHelper(Executor ex,
java.lang.String sessionUuid,
ome.system.Roles roles,
ReadOnlyStatus readOnly) |
ScriptRepoHelper(java.io.File dir,
Executor ex,
java.lang.String sessionUuid,
ome.system.Principal p,
ome.system.Roles roles)
Deprecated.
|
ScriptRepoHelper(java.io.File dir,
Executor ex,
java.lang.String sessionUuid,
ome.system.Principal p,
ome.system.Roles roles,
ReadOnlyStatus readOnly)
Deprecated.
|
ScriptRepoHelper(java.lang.String uuid,
java.io.File dir,
Executor ex,
java.lang.String sessionUuid,
ome.system.Principal p,
ome.system.Roles roles)
Deprecated.
|
ScriptRepoHelper(java.lang.String uuid,
java.io.File dir,
Executor ex,
java.lang.String sessionUuid,
ome.system.Principal p,
ome.system.Roles roles,
ReadOnlyStatus readOnly) |
Modifier and Type | Method and Description |
---|---|
ome.model.core.OriginalFile |
addOrReplace(RepoFile repoFile,
java.lang.Long old) |
protected ome.model.core.OriginalFile |
addOrReplace(org.hibernate.Session session,
ome.util.SqlAction sqlAction,
ome.system.ServiceFactory sf,
RepoFile repoFile,
java.lang.Long old) |
void |
buildQuery(QueryBuilder qb)
Adds a single clause of the form "AND (A OR B ...)" where each
ScriptFileType A, B, etc. |
void |
checkForScriptUpdates()
Check for updates to scripts, modifying database accordingly.
|
int |
countInDb() |
int |
countInDb(ome.util.SqlAction sql) |
int |
countOnDisk()
Returns the number of files which match
scriptFilter in
dir . |
boolean |
delete(long id) |
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. |
java.lang.Long |
findInDb(RepoFile file,
boolean scriptsOnly) |
java.lang.Long |
findInDb(ome.util.SqlAction sql,
RepoFile repoFile,
boolean scriptsOnly)
Looks to see if a path is contained in the repository.
|
java.lang.Long |
findInDb(java.lang.String path,
boolean scriptsOnly) |
static java.lang.String |
getDefaultScriptDir()
Directory which will be used as the root of this repository if no
directory is passed to a constructor.
|
java.lang.String |
getLauncher(java.lang.String mimetype)
Find an "omero.launcher..." property string for the given mimetype or
return "" if none is found.
|
java.lang.String |
getProcess(java.lang.String mimetype)
Find an "omero.process..." property string for the given mimetype or
return "" if none is found.
|
java.lang.String |
getScriptDir()
Returns the actual root of this repository.
|
java.lang.String |
getUuid()
Uuid of this repository.
|
void |
handleContextRefreshedEvent(org.springframework.context.event.ContextRefreshedEvent event)
Loads all
ScriptFileType instances from the context,
and uses them to initialize all scripts in the repo. |
java.util.List<java.lang.Long> |
idsInDb() |
java.util.List<java.lang.Long> |
idsInDb(ome.util.SqlAction sql) |
boolean |
isInert(ome.model.core.OriginalFile f)
Returns
true if the file is an "inert" file e.g. |
boolean |
isInRepo(long id) |
boolean |
isInRepo(ome.util.SqlAction sql,
long id) |
java.util.Iterator<java.io.File> |
iterate() |
ome.model.core.OriginalFile |
load(long id,
boolean check) |
ome.model.core.OriginalFile |
load(long id,
org.hibernate.Session s,
ome.util.SqlAction sqlAction,
boolean check) |
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. |
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. |
java.util.List<ome.model.core.OriginalFile> |
loadAll(boolean modificationCheck,
java.lang.String mimetype,
ome.system.Principal pp) |
void |
modificationCheck()
Checks if
|
java.lang.String |
read(java.lang.String path) |
long |
removeMissingFilesFromDb(ome.util.SqlAction sqlAction,
org.hibernate.Session session,
java.util.List<ome.model.core.OriginalFile> filesOnDisk)
Given the current files on disk,
unregister(Long, SqlAction)
all files which have been removed from disk. |
void |
setMimetype(ome.model.core.OriginalFile ofile) |
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. |
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.
|
ome.model.core.OriginalFile |
update(RepoFile repoFile,
java.lang.Long id,
java.util.Map<java.lang.String,java.lang.String> context) |
RepoFile |
write(RepoFile repo,
java.lang.String text) |
RepoFile |
write(java.lang.String path,
java.lang.String text) |
onApplicationEvent, setApplicationContext
public static final java.lang.String SCRIPT_REPO
public static final org.apache.commons.io.filefilter.IOFileFilter BASE_SCRIPT_FILTER
IOFileFilter
instance used during iterate()
to find the
matching scripts in the given directory.protected final org.slf4j.Logger log
@Deprecated public ScriptRepoHelper(Executor ex, java.lang.String sessionUuid, ome.system.Roles roles)
public ScriptRepoHelper(Executor ex, java.lang.String sessionUuid, ome.system.Roles roles, ReadOnlyStatus readOnly)
@Deprecated public ScriptRepoHelper(java.io.File dir, Executor ex, java.lang.String sessionUuid, ome.system.Principal p, ome.system.Roles roles)
@Deprecated public ScriptRepoHelper(java.lang.String uuid, java.io.File dir, Executor ex, java.lang.String sessionUuid, ome.system.Principal p, ome.system.Roles roles)
@Deprecated public ScriptRepoHelper(java.io.File dir, Executor ex, java.lang.String sessionUuid, ome.system.Principal p, ome.system.Roles roles, ReadOnlyStatus readOnly)
public ScriptRepoHelper(java.lang.String uuid, java.io.File dir, Executor ex, java.lang.String sessionUuid, ome.system.Principal p, ome.system.Roles roles, ReadOnlyStatus readOnly)
uuid
- Allows setting a non-default uuid for this script service.
Primarily for testing, since services rely on the repository
name for finding one another.dir
- The directory used by the repo as its root. Other constructors
use getDefaultScriptDir()
internally.ex
- p
- public void handleContextRefreshedEvent(org.springframework.context.event.ContextRefreshedEvent event)
ScriptFileType
instances from the context,
and uses them to initialize all scripts in the repo.handleContextRefreshedEvent
in class OnContextRefreshedEventListener
public void checkForScriptUpdates()
public void buildQuery(QueryBuilder qb)
ScriptFileType
A, B, etc. is given a chance to define
its own clause.public void setMimetype(ome.model.core.OriginalFile ofile)
protected java.util.Map.Entry<java.lang.String,ScriptFileType> findByMimetype(java.lang.String mimetype)
ScriptFileType
instances and find one with
a matching mimetype string. Otherwise, return null.public java.lang.String getLauncher(java.lang.String mimetype)
public java.lang.String getProcess(java.lang.String mimetype)
public static java.lang.String getDefaultScriptDir()
public java.lang.String getScriptDir()
getDefaultScriptDir()
public java.lang.String getUuid()
SCRIPT_REPO
.public int countOnDisk()
public int countInDb()
public int countInDb(ome.util.SqlAction sql)
public java.util.List<java.lang.Long> idsInDb()
public java.util.List<java.lang.Long> idsInDb(ome.util.SqlAction sql)
public boolean isInRepo(long id)
public boolean isInRepo(ome.util.SqlAction sql, long id)
public java.lang.Long findInDb(java.lang.String path, boolean scriptsOnly)
public java.lang.Long findInDb(RepoFile file, boolean scriptsOnly)
public java.lang.Long findInDb(ome.util.SqlAction sql, RepoFile repoFile, boolean scriptsOnly)
public java.util.Iterator<java.io.File> iterate()
public java.util.List<ome.model.core.OriginalFile> loadAll(boolean modificationCheck, java.lang.String mimetype)
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.
modificationCheck
- mimetype
- the mimetype of the scripts or null
.public java.util.List<ome.model.core.OriginalFile> loadAll(boolean modificationCheck, java.lang.String mimetype, ome.system.Principal pp)
public java.util.List<ome.model.core.OriginalFile> loadAll(boolean modificationCheck)
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.
modificationCheck
- public ome.model.core.OriginalFile addOrReplace(RepoFile repoFile, java.lang.Long old)
repoFile
- old
- protected ome.model.core.OriginalFile addOrReplace(org.hibernate.Session session, ome.util.SqlAction sqlAction, ome.system.ServiceFactory sf, RepoFile repoFile, java.lang.Long old)
public long removeMissingFilesFromDb(ome.util.SqlAction sqlAction, org.hibernate.Session session, java.util.List<ome.model.core.OriginalFile> filesOnDisk)
unregister(Long, SqlAction)
all files which have been removed from disk.protected void unregister(java.lang.Long old, ome.util.SqlAction sqlAction)
public ome.model.core.OriginalFile update(RepoFile repoFile, java.lang.Long id, java.util.Map<java.lang.String,java.lang.String> context)
public java.lang.String read(java.lang.String path) throws java.io.IOException
java.io.IOException
public RepoFile write(java.lang.String path, java.lang.String text) throws java.io.IOException
java.io.IOException
public RepoFile write(RepoFile repo, java.lang.String text) throws java.io.IOException
java.io.IOException
public ome.model.core.OriginalFile load(long id, boolean check)
public ome.model.core.OriginalFile load(long id, org.hibernate.Session s, ome.util.SqlAction sqlAction, boolean check)
public void modificationCheck()
public boolean delete(long id)
public void simpleDelete(java.util.Map<java.lang.String,java.lang.String> context, Executor executor, ome.system.Principal p, long id)
delete(long)
this method simply performs the DB delete
on the given original file id.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.public boolean isInert(ome.model.core.OriginalFile f)
true
if the file is an "inert" file e.g. a lut,
false
otherwise.f
- The file to handle.