public class RepositoryDaoImpl extends java.lang.Object implements RepositoryDao
| Modifier and Type | Field and Description |
|---|---|
protected ome.services.util.Executor |
executor |
protected java.lang.String |
fileRepoSecretKey |
protected ome.security.basic.OmeroInterceptor |
interceptor |
protected ome.system.Principal |
principal |
protected ome.system.Roles |
roles |
protected ome.services.util.Executor |
statefulExecutor |
| Constructor and Description |
|---|
RepositoryDaoImpl(ome.system.Principal principal,
ome.services.util.Executor executor)
Previous constructor which should no longer be used.
|
RepositoryDaoImpl(ome.system.Principal principal,
ome.system.Roles roles,
ome.services.util.Executor executor,
ome.services.util.Executor statefulExecutor,
ome.security.basic.OmeroInterceptor interceptor,
java.lang.String fileRepoSecretKey)
Primary constructor which takes all final fields.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
canUpdate(IObject obj,
Ice.Current current)
Delegates to IAdmin#canUpdate
|
protected void |
canWriteParentDirectory(ome.system.ServiceFactory sf,
ome.util.SqlAction sql,
java.lang.String repoUuid,
CheckedPath parent)
Throw a
SecurityViolation if the current
context cannot write to the parent directory. |
void |
createOrFixUserDir(java.lang.String repoUuid,
java.util.List<CheckedPath> checkedPaths,
org.hibernate.Session s,
ome.system.ServiceFactory sf,
ome.util.SqlAction sql)
Checks that the given
CheckedPath objects exist (via
RepositoryDao.findRepoFile(String, CheckedPath, String, Ice.Current))
and are in the "user" group. |
protected java.util.List<ome.model.core.OriginalFile> |
createOriginalFile(ome.system.ServiceFactory sf,
ome.util.SqlAction sql,
java.lang.String repoUuid,
java.util.List<CheckedPath> checked,
ChecksumAlgorithm checksumAlgorithm,
java.lang.String mimetype,
org.hibernate.Session session)
Primary location for creating original files from a
CheckedPath
instance. |
protected ome.system.Principal |
currentUser(Ice.Current __current) |
java.util.List<java.lang.Integer> |
deleteRepoDeleteLogs(java.util.List<ome.util.SqlAction.DeleteLog> templates,
Ice.Current current)
Call
SqlAction.deleteRepoDeleteLogs(DeleteLog) with the current
context for a number of templates. |
int |
deleteRepoDeleteLogs(ome.util.SqlAction.DeleteLog template,
Ice.Current current)
Call
SqlAction.deleteRepoDeleteLogs(DeleteLog) with the current
context. |
protected java.util.Map<java.lang.String,java.lang.String> |
fileContext(long fileId,
Ice.Current current)
Create a String-String map which can be used as the context for a call
to Executor.execute based on the group of the file object.
|
java.util.List<java.lang.Long> |
filterFilesByRepository(java.lang.String repo,
java.util.List<java.lang.Long> ids,
Ice.Current current)
Find the original file IDs among those given that are in the given repository.
|
java.util.List<java.util.List<ome.util.SqlAction.DeleteLog>> |
findRepoDeleteLogs(java.util.List<ome.util.SqlAction.DeleteLog> templates,
Ice.Current current)
As
findRepoDeleteLogs(DeleteLog, Current) but for a collection
of templates. |
java.util.List<ome.util.SqlAction.DeleteLog> |
findRepoDeleteLogs(ome.util.SqlAction.DeleteLog template,
Ice.Current current)
Call
SqlAction.findRepoDeleteLogs(DeleteLog) with the current
context. |
ome.model.core.OriginalFile |
findRepoFile(ome.system.ServiceFactory sf,
ome.util.SqlAction sql,
java.lang.String uuid,
CheckedPath checked,
java.lang.String mimetype)
As
RepositoryDao.findRepoFile(String, CheckedPath, String, Current) but
can be called from within a transaction. |
OriginalFile |
findRepoFile(java.lang.String uuid,
CheckedPath checked,
java.lang.String mimetype,
Ice.Current current)
Delegate to
SqlAction.findRepoFile(String, String, String, String)
for looking up the id of the file, and then load it normally via
IQuery. |
ome.model.enums.ChecksumAlgorithm |
getChecksumAlgorithm(java.lang.String name,
Ice.Current current)
Retrieve the checksum algorithm of the given name.
|
EventContext |
getEventContext(Ice.Current curr)
Look up information for the current session as specified in the ctx
field of the current.
|
FsFile |
getFile(long id,
Ice.Current current,
java.lang.String repoUuid)
Get an
FsFile object based on its ID. |
OriginalFile |
getOriginalFile(long repoId,
Ice.Current current)
Gets the original file instance for a given file ID.
|
protected java.util.List<ome.model.core.OriginalFile> |
getOriginalFiles(ome.system.ServiceFactory sf,
ome.util.SqlAction sql,
java.lang.String repoUuid,
CheckedPath checked) |
java.util.List<OriginalFile> |
getOriginalFiles(java.lang.String repoUuid,
CheckedPath checked,
Ice.Current current)
Return a non-null, possibly empty list of
OriginalFile elements
which are accessible to the given user at the given path. |
ome.model.core.OriginalFile |
getOriginalFileWithHasher(long id,
Ice.Current current)
Retrieve the original file of the given ID.
|
ome.api.RawFileStore |
getRawFileStore(long fileId,
CheckedPath checked,
java.lang.String mode,
Ice.Current current)
Create a
RawFileBean (i.e. |
java.lang.String |
getUserInstitution(long userId,
Ice.Current current)
Get the current user's institution.
|
java.lang.String |
getUserInstitution(long userId,
ome.system.ServiceFactory sf)
Get the current user's institution.
|
protected java.util.Map<java.lang.String,java.lang.String> |
groupContext(java.lang.Long groupId,
Ice.Current current)
Creates a copy of the
Current.ctx map and if groupId is
not null, sets the "omero.group" key to be a string version of the
id. |
protected void |
internalMkdir(CheckedPath file)
This method should only be used by the register public method in order to
guarantee that the DB is kept in sync with the file system.
|
java.util.List<Fileset> |
loadFilesets(java.util.List<java.lang.Long> ids,
Ice.Current current)
Load filesets by id.
|
void |
makeDirs(PublicRepositoryI repo,
java.util.List<CheckedPath> dirs,
boolean parents,
Ice.Current __current)
Create a number of directories in a single transaction, using the
PublicRepositoryI instance as a callback for implementation
specific logic. |
OriginalFile |
register(java.lang.String repoUuid,
CheckedPath checked,
java.lang.String mimetype,
Ice.Current current)
Register an OriginalFile object
|
ome.model.core.OriginalFile |
register(java.lang.String repoUuid,
CheckedPath checked,
java.lang.String mimetype,
ome.system.ServiceFactory sf,
ome.util.SqlAction sql,
org.hibernate.Session session)
Returns original file object is "live" within the Hibernate session.
|
Fileset |
saveFileset(java.lang.String repoUuid,
Fileset _fs,
ChecksumAlgorithm checksumAlgorithm,
java.util.List<CheckedPath> paths,
Ice.Current current)
Fill the various fields of the
Fileset and then save the
entire instance into the database. |
Job |
saveJob(Job job,
Ice.Current current)
Create a job from an instance provided by either the client or the
server.
|
void |
saveObject(ome.model.IObject object,
Ice.Current current)
Save the given model object.
|
RMap |
treeList(java.lang.String repoUuid,
CheckedPath checked,
Ice.Current current) |
protected ome.services.RawFileBean |
unwrapRawFileBean(ome.api.RawFileStore proxy)
Loads
|
void |
updateJob(Job job,
java.lang.String message,
java.lang.String status,
Ice.Current current)
Set both the message and the status of the given job.
|
protected SecurityViolation |
wrapSecurityViolation(ome.conditions.SecurityViolation sv) |
protected final ome.system.Principal principal
protected final ome.system.Roles roles
protected final ome.services.util.Executor executor
protected final ome.services.util.Executor statefulExecutor
protected final ome.security.basic.OmeroInterceptor interceptor
protected final java.lang.String fileRepoSecretKey
public RepositoryDaoImpl(ome.system.Principal principal,
ome.system.Roles roles,
ome.services.util.Executor executor,
ome.services.util.Executor statefulExecutor,
ome.security.basic.OmeroInterceptor interceptor,
java.lang.String fileRepoSecretKey)
public RepositoryDaoImpl(ome.system.Principal principal,
ome.services.util.Executor executor)
protected ome.services.RawFileBean unwrapRawFileBean(ome.api.RawFileStore proxy)
protected SecurityViolation wrapSecurityViolation(ome.conditions.SecurityViolation sv) throws SecurityViolation
SecurityViolationpublic ome.api.RawFileStore getRawFileStore(long fileId,
CheckedPath checked,
java.lang.String mode,
Ice.Current current)
throws SecurityViolation
RepositoryDaoRawFileBean (i.e. an implementation of
RawFileStore which can be passed to
RepoRawFileStoreI for performing internal functions. The primary
difference to an instance created via the ServiceFactory is that
the RawFileBean.setFileIdWithBuffer(long, FileBuffer) method is
called pointing to a non-romio file path, e.g. /OMERO/Files/x.getRawFileStore in interface RepositoryDaofileId - ID of an OriginalFilechecked - Not null. Normalized path from the repository.mode - FileChannel mode, "r", "rw", etc.RawFileBean.setFileIdWithBuffer(long, FileBuffer) called.SecurityViolationpublic OriginalFile findRepoFile(java.lang.String uuid, CheckedPath checked, java.lang.String mimetype, Ice.Current current) throws ServerError
RepositoryDaoSqlAction.findRepoFile(String, String, String, String)
for looking up the id of the file, and then load it normally via
IQuery. This will enforce any read security checks.findRepoFile in interface RepositoryDaoServerErrorpublic ome.model.core.OriginalFile findRepoFile(ome.system.ServiceFactory sf,
ome.util.SqlAction sql,
java.lang.String uuid,
CheckedPath checked,
java.lang.String mimetype)
RepositoryDaoRepositoryDao.findRepoFile(String, CheckedPath, String, Current) but
can be called from within a transaction.findRepoFile in interface RepositoryDaopublic RMap treeList(java.lang.String repoUuid, CheckedPath checked, Ice.Current current) throws ServerError
treeList in interface RepositoryDaoServerErrorpublic void createOrFixUserDir(java.lang.String repoUuid,
java.util.List<CheckedPath> checkedPaths,
org.hibernate.Session s,
ome.system.ServiceFactory sf,
ome.util.SqlAction sql)
throws ServerError
RepositoryDaoCheckedPath objects exist (via
RepositoryDao.findRepoFile(String, CheckedPath, String, Ice.Current))
and are in the "user" group. If they don't exist, they are created; and
if they aren't in the "user" group, they are moved.createOrFixUserDir in interface RepositoryDaoServerErrorpublic boolean canUpdate(IObject obj, Ice.Current current)
RepositoryDaocanUpdate in interface RepositoryDaopublic java.util.List<java.lang.Long> filterFilesByRepository(java.lang.String repo,
java.util.List<java.lang.Long> ids,
Ice.Current current)
RepositoryDaofilterFilesByRepository in interface RepositoryDaorepo - a repository UUIDids - IDs of original filescurrent - Ice method invocation contextpublic OriginalFile getOriginalFile(long repoId, Ice.Current current) throws SecurityViolation
RepositoryDaogetOriginalFile in interface RepositoryDaorepoId - a file IDcurrent - applicable ICE contextSecurityViolation - if the query threw a security violationpublic java.util.List<OriginalFile> getOriginalFiles(java.lang.String repoUuid, CheckedPath checked, Ice.Current current) throws SecurityViolation
RepositoryDaoOriginalFile elements
which are accessible to the given user at the given path. If the
directory which they are associated with is not also readable by the
current user, then a SecurityViolation will be thrown.getOriginalFiles in interface RepositoryDaorepoUuid - for the repository in question.checked - normalized path which can be found as the value of
OriginalFile.getPath() in the database.SecurityViolationprotected java.util.List<ome.model.core.OriginalFile> getOriginalFiles(ome.system.ServiceFactory sf,
ome.util.SqlAction sql,
java.lang.String repoUuid,
CheckedPath checked)
public Fileset saveFileset(java.lang.String repoUuid, Fileset _fs, ChecksumAlgorithm checksumAlgorithm, java.util.List<CheckedPath> paths, Ice.Current current) throws ServerError
RepositoryDaoFileset and then save the
entire instance into the database.saveFileset in interface RepositoryDaorepoUuid - for the repository in question._fs - a user provided Fileset that must minimally have the
FilesetEntry objects present with their clientPath set. The rest
of the fields will be filled here.checksumAlgorithm - The algorithm to use.paths - a List of the same size as the number of entries in fs
one per FilesetEntry.current - Current contextServerErrorpublic java.util.List<Fileset> loadFilesets(java.util.List<java.lang.Long> ids, Ice.Current current) throws ServerError
RepositoryDaoloadFilesets in interface RepositoryDaoServerErrorpublic OriginalFile register(java.lang.String repoUuid, CheckedPath checked, java.lang.String mimetype, Ice.Current current) throws ServerError
RepositoryDaoregister in interface RepositoryDaorepoUuid - uuid of the repository that the given file argument should be
registered with. Cannot be null.checked - Normalized path provided by the repository. Not null.mimetype - Mimetype for use with the OriginalFile. May be null in which
case a default will be chosen.current - Not null.ServerErrorpublic ome.model.core.OriginalFile register(java.lang.String repoUuid,
CheckedPath checked,
java.lang.String mimetype,
ome.system.ServiceFactory sf,
ome.util.SqlAction sql,
org.hibernate.Session session)
throws ServerError
register in interface RepositoryDaorepoUuid - checked - mimetype - sf - sql - session - ServerErrorpublic Job saveJob(Job job, Ice.Current current) throws ServerError
RepositoryDaosaveJob in interface RepositoryDaojob - Not null.current - Not null.ServerErrorpublic void updateJob(Job job, java.lang.String message, java.lang.String status, Ice.Current current) throws ServerError
RepositoryDaoupdateJob in interface RepositoryDaojob - Not null.message - If null, no modification will be made for the messagestatus - If null, no modification will be made for the status.current - Not null.ServerErrorpublic void makeDirs(PublicRepositoryI repo, java.util.List<CheckedPath> dirs, boolean parents, Ice.Current __current) throws ServerError
RepositoryDaoPublicRepositoryI instance as a callback for implementation
specific logic. Applies the real user's event context when within a
PublicRepositoryI.sudo(Current, String).makeDirs in interface RepositoryDaoServerErrorpublic FsFile getFile(long id, Ice.Current current, java.lang.String repoUuid)
RepositoryDaoFsFile object based on its ID. Returns null if
the file does not exist or does not belong to this repository.getFile in interface RepositoryDaoid - database ID of the sought original filecurrent - current applicable ICE contextrepoUuid - the UUID of the repository containing the original filepublic java.util.List<ome.util.SqlAction.DeleteLog> findRepoDeleteLogs(ome.util.SqlAction.DeleteLog template,
Ice.Current current)
RepositoryDaoSqlAction.findRepoDeleteLogs(DeleteLog) with the current
context.findRepoDeleteLogs in interface RepositoryDaotemplate - not null.current - not null.public java.util.List<java.util.List<ome.util.SqlAction.DeleteLog>> findRepoDeleteLogs(java.util.List<ome.util.SqlAction.DeleteLog> templates,
Ice.Current current)
RepositoryDaofindRepoDeleteLogs(DeleteLog, Current) but for a collection
of templates.findRepoDeleteLogs in interface RepositoryDaotemplates - not null.current - not null.public int deleteRepoDeleteLogs(ome.util.SqlAction.DeleteLog template,
Ice.Current current)
RepositoryDaoSqlAction.deleteRepoDeleteLogs(DeleteLog) with the current
context.deleteRepoDeleteLogs in interface RepositoryDaotemplate - not null.current - not null.public java.util.List<java.lang.Integer> deleteRepoDeleteLogs(java.util.List<ome.util.SqlAction.DeleteLog> templates,
Ice.Current current)
RepositoryDaoSqlAction.deleteRepoDeleteLogs(DeleteLog) with the current
context for a number of templates.deleteRepoDeleteLogs in interface RepositoryDaotemplates - not null.current - not null.public EventContext getEventContext(Ice.Current curr)
RepositoryDaogetEventContext in interface RepositoryDaopublic java.lang.String getUserInstitution(long userId,
Ice.Current current)
RepositoryDaogetUserInstitution in interface RepositoryDaouserId - the ID of the user whose institution is to be fetchedcurrent - the current ICE method invocation contextnullpublic java.lang.String getUserInstitution(long userId,
ome.system.ServiceFactory sf)
RepositoryDaogetUserInstitution in interface RepositoryDaouserId - the ID of the user whose institution is to be fetchedsf - the service factory to use for the querynullprotected java.util.List<ome.model.core.OriginalFile> createOriginalFile(ome.system.ServiceFactory sf,
ome.util.SqlAction sql,
java.lang.String repoUuid,
java.util.List<CheckedPath> checked,
ChecksumAlgorithm checksumAlgorithm,
java.lang.String mimetype,
org.hibernate.Session session)
CheckedPath
instance. This will use access to the actual File
object in order to calculate size, timestamps, etc.sf - sql - repoUuid - checked - checksumAlgorithm - mimetype - session - protected void internalMkdir(CheckedPath file)
file - the path to ensure exists as a directoryome.conditions.ResourceErrorprotected void canWriteParentDirectory(ome.system.ServiceFactory sf,
ome.util.SqlAction sql,
java.lang.String repoUuid,
CheckedPath parent)
SecurityViolation if the current
context cannot write to the parent directory.sf - sql - repoUuid - parent - protected ome.system.Principal currentUser(Ice.Current __current)
protected java.util.Map<java.lang.String,java.lang.String> fileContext(long fileId,
Ice.Current current)
throws SecurityViolation
SecurityViolation - if the file can't be read.protected java.util.Map<java.lang.String,java.lang.String> groupContext(java.lang.Long groupId,
Ice.Current current)
Current.ctx map and if groupId is
not null, sets the "omero.group" key to be a string version of the
id.groupId - current - public ome.model.enums.ChecksumAlgorithm getChecksumAlgorithm(java.lang.String name,
Ice.Current current)
RepositoryDaogetChecksumAlgorithm in interface RepositoryDaoname - a checksum algorithm name, must existcurrent - Ice method invocation contextpublic ome.model.core.OriginalFile getOriginalFileWithHasher(long id,
Ice.Current current)
RepositoryDaogetOriginalFileWithHasher in interface RepositoryDaoid - the ID of an original file, must existcurrent - Ice method invocation contextpublic void saveObject(ome.model.IObject object,
Ice.Current current)
RepositoryDaosaveObject in interface RepositoryDaoobject - a model objectcurrent - Ice method invocation context