public class RepositoryDaoImpl extends Object implements RepositoryDao
Modifier and Type | Field and Description |
---|---|
protected Executor |
executor |
protected Principal |
principal |
protected Roles |
roles |
protected Executor |
statefulExecutor |
Constructor and Description |
---|
RepositoryDaoImpl(Principal principal,
Executor executor)
Previous constructor which should no longer be used.
|
RepositoryDaoImpl(Principal principal,
Roles roles,
Executor executor,
Executor statefulExecutor)
Primary constructor which takes all final fields.
|
Modifier and Type | Method and Description |
---|---|
boolean |
canUpdate(omero.model.IObject obj,
Ice.Current current)
Delegates to IAdmin#canUpdate
|
protected void |
canWriteParentDirectory(ServiceFactory sf,
SqlAction sql,
String repoUuid,
CheckedPath parent)
Throw a
SecurityViolation if the current
context cannot write to the parent directory. |
void |
createOrFixUserDir(String repoUuid,
List<CheckedPath> checkedPaths,
org.hibernate.Session s,
ServiceFactory sf,
SqlAction sql)
Checks that the given
CheckedPath objects exist (via
RepositoryDao.findRepoFile(String, CheckedPath, String, Ice.Current) )
and are in the "user" group. |
protected List<OriginalFile> |
createOriginalFile(ServiceFactory sf,
SqlAction sql,
String repoUuid,
List<CheckedPath> checked,
omero.model.ChecksumAlgorithm checksumAlgorithm,
String mimetype)
Primary location for creating original files from a
CheckedPath
instance. |
protected EventContext |
currentContext(Principal currentUser) |
protected Principal |
currentUser(Ice.Current __current) |
List<Integer> |
deleteRepoDeleteLogs(List<SqlAction.DeleteLog> templates,
Ice.Current current)
Call
SqlAction.deleteRepoDeleteLogs(DeleteLog) with the current
context for a number of templates. |
int |
deleteRepoDeleteLogs(SqlAction.DeleteLog template,
Ice.Current current)
Call
SqlAction.deleteRepoDeleteLogs(DeleteLog) with the current
context. |
protected Map<String,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.
|
List<Long> |
filterFilesByRepository(String repo,
List<Long> ids,
Ice.Current current)
Find the original file IDs among those given that are in the given repository.
|
List<List<SqlAction.DeleteLog>> |
findRepoDeleteLogs(List<SqlAction.DeleteLog> templates,
Ice.Current current)
As
findRepoDeleteLogs(DeleteLog, Current) but for a collection
of templates. |
List<SqlAction.DeleteLog> |
findRepoDeleteLogs(SqlAction.DeleteLog template,
Ice.Current current)
Call
SqlAction.findRepoDeleteLogs(DeleteLog) with the current
context. |
OriginalFile |
findRepoFile(ServiceFactory sf,
SqlAction sql,
String uuid,
CheckedPath checked,
String mimetype)
As
RepositoryDao.findRepoFile(String, CheckedPath, String, Current) but
can be called from within a transaction. |
omero.model.OriginalFile |
findRepoFile(String uuid,
CheckedPath checked,
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. |
ChecksumAlgorithm |
getChecksumAlgorithm(String name,
Ice.Current current)
Retrieve the checksum algorithm of the given name.
|
omero.sys.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,
String repoUuid)
Get an
FsFile object based on its ID. |
omero.model.OriginalFile |
getOriginalFile(long repoId,
Ice.Current current)
Gets the original file instance for a given file ID.
|
protected List<OriginalFile> |
getOriginalFiles(ServiceFactory sf,
SqlAction sql,
String repoUuid,
CheckedPath checked) |
List<omero.model.OriginalFile> |
getOriginalFiles(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. |
OriginalFile |
getOriginalFileWithHasher(long id,
Ice.Current current)
Retrieve the original file of the given ID.
|
RawFileStore |
getRawFileStore(long fileId,
CheckedPath checked,
String mode,
Ice.Current current)
Create a
RawFileBean (i.e. an implementation of
RawFileStore which can be passed to
RepoRawFileStoreI for performing internal functions. |
String |
getUserInstitution(long userId,
Ice.Current current)
Get the current user's institution.
|
String |
getUserInstitution(long userId,
ServiceFactory sf)
Get the current user's institution.
|
protected Map<String,String> |
groupContext(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.
|
List<omero.model.Fileset> |
loadFilesets(List<Long> ids,
Ice.Current current)
Load filesets by id.
|
void |
makeDirs(PublicRepositoryI repo,
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. |
omero.model.OriginalFile |
register(String repoUuid,
CheckedPath checked,
String mimetype,
Ice.Current current)
Register an OriginalFile object
|
OriginalFile |
register(String repoUuid,
CheckedPath checked,
String mimetype,
ServiceFactory sf,
SqlAction sql)
Returns original file object is "live" within the Hibernate session.
|
omero.model.Fileset |
saveFileset(String repoUuid,
omero.model.Fileset _fs,
omero.model.ChecksumAlgorithm checksumAlgorithm,
List<CheckedPath> paths,
Ice.Current current)
Fill the various fields of the
Fileset and then save the
entire instance into the database. |
omero.model.Job |
saveJob(omero.model.Job job,
Ice.Current current)
Create a job from an instance provided by either the client or the
server.
|
void |
saveObject(IObject object,
Ice.Current current)
Save the given model object.
|
omero.RMap |
treeList(String repoUuid,
CheckedPath checked,
Ice.Current current) |
protected RawFileBean |
unwrapRawFileBean(RawFileStore proxy)
Loads
|
void |
updateJob(omero.model.Job job,
String message,
String status,
Ice.Current current)
Set both the message and the status of the given job.
|
protected omero.SecurityViolation |
wrapSecurityViolation(SecurityViolation sv) |
protected final Principal principal
protected final Roles roles
protected final Executor executor
protected final Executor statefulExecutor
public RepositoryDaoImpl(Principal principal, Roles roles, Executor executor, Executor statefulExecutor)
principal
- roles
- executor
- statefulExecutor
- protected RawFileBean unwrapRawFileBean(RawFileStore proxy)
protected omero.SecurityViolation wrapSecurityViolation(SecurityViolation sv) throws omero.SecurityViolation
omero.SecurityViolation
public RawFileStore getRawFileStore(long fileId, CheckedPath checked, String mode, Ice.Current current) throws omero.SecurityViolation
RepositoryDao
RawFileBean
(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 RepositoryDao
fileId
- ID of an OriginalFile
checked
- Not null. Normalized path from the repository.mode
- FileChannel mode, "r", "rw", etc.RawFileBean.setFileIdWithBuffer(long, FileBuffer)
called.omero.SecurityViolation
public omero.model.OriginalFile findRepoFile(String uuid, CheckedPath checked, String mimetype, Ice.Current current) throws omero.ServerError
RepositoryDao
SqlAction.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 RepositoryDao
omero.ServerError
public OriginalFile findRepoFile(ServiceFactory sf, SqlAction sql, String uuid, CheckedPath checked, String mimetype)
RepositoryDao
RepositoryDao.findRepoFile(String, CheckedPath, String, Current)
but
can be called from within a transaction.findRepoFile
in interface RepositoryDao
public omero.RMap treeList(String repoUuid, CheckedPath checked, Ice.Current current) throws omero.ServerError
treeList
in interface RepositoryDao
omero.ServerError
public void createOrFixUserDir(String repoUuid, List<CheckedPath> checkedPaths, org.hibernate.Session s, ServiceFactory sf, SqlAction sql) throws omero.ServerError
RepositoryDao
CheckedPath
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 RepositoryDao
omero.ServerError
public boolean canUpdate(omero.model.IObject obj, Ice.Current current)
RepositoryDao
canUpdate
in interface RepositoryDao
public List<Long> filterFilesByRepository(String repo, List<Long> ids, Ice.Current current)
RepositoryDao
filterFilesByRepository
in interface RepositoryDao
repo
- a repository UUIDids
- IDs of original filescurrent
- Ice method invocation contextpublic omero.model.OriginalFile getOriginalFile(long repoId, Ice.Current current) throws omero.SecurityViolation
RepositoryDao
getOriginalFile
in interface RepositoryDao
repoId
- a file IDcurrent
- applicable ICE contextomero.SecurityViolation
- if the query threw a security violationpublic List<omero.model.OriginalFile> getOriginalFiles(String repoUuid, CheckedPath checked, Ice.Current current) throws omero.SecurityViolation
RepositoryDao
OriginalFile
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 RepositoryDao
repoUuid
- for the repository in question.checked
- normalized path which can be found as the value of
OriginalFile.getPath()
in the database.omero.SecurityViolation
protected List<OriginalFile> getOriginalFiles(ServiceFactory sf, SqlAction sql, String repoUuid, CheckedPath checked)
public omero.model.Fileset saveFileset(String repoUuid, omero.model.Fileset _fs, omero.model.ChecksumAlgorithm checksumAlgorithm, List<CheckedPath> paths, Ice.Current current) throws omero.ServerError
RepositoryDao
Fileset
and then save the
entire instance into the database.saveFileset
in interface RepositoryDao
repoUuid
- 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 contextomero.ServerError
public List<omero.model.Fileset> loadFilesets(List<Long> ids, Ice.Current current) throws omero.ServerError
RepositoryDao
loadFilesets
in interface RepositoryDao
omero.ServerError
public omero.model.OriginalFile register(String repoUuid, CheckedPath checked, String mimetype, Ice.Current current) throws omero.ServerError
RepositoryDao
register
in interface RepositoryDao
repoUuid
- 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.omero.ServerError
public OriginalFile register(String repoUuid, CheckedPath checked, String mimetype, ServiceFactory sf, SqlAction sql) throws omero.ServerError
register
in interface RepositoryDao
repoUuid
- checked
- mimetype
- sf
- sql
- omero.ServerError
public omero.model.Job saveJob(omero.model.Job job, Ice.Current current) throws omero.ServerError
RepositoryDao
saveJob
in interface RepositoryDao
job
- Not null.current
- Not null.omero.ServerError
public void updateJob(omero.model.Job job, String message, String status, Ice.Current current) throws omero.ServerError
RepositoryDao
updateJob
in interface RepositoryDao
job
- 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.omero.ServerError
public void makeDirs(PublicRepositoryI repo, List<CheckedPath> dirs, boolean parents, Ice.Current __current) throws omero.ServerError
RepositoryDao
PublicRepositoryI
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 RepositoryDao
omero.ServerError
public FsFile getFile(long id, Ice.Current current, String repoUuid)
RepositoryDao
FsFile
object based on its ID. Returns null if
the file does not exist or does not belong to this repository.getFile
in interface RepositoryDao
id
- database ID of the sought original filecurrent
- current applicable ICE contextrepoUuid
- the UUID of the repository containing the original filepublic List<SqlAction.DeleteLog> findRepoDeleteLogs(SqlAction.DeleteLog template, Ice.Current current)
RepositoryDao
SqlAction.findRepoDeleteLogs(DeleteLog)
with the current
context.findRepoDeleteLogs
in interface RepositoryDao
template
- not null.current
- not null.public List<List<SqlAction.DeleteLog>> findRepoDeleteLogs(List<SqlAction.DeleteLog> templates, Ice.Current current)
RepositoryDao
findRepoDeleteLogs(DeleteLog, Current)
but for a collection
of templates.findRepoDeleteLogs
in interface RepositoryDao
templates
- not null.current
- not null.public int deleteRepoDeleteLogs(SqlAction.DeleteLog template, Ice.Current current)
RepositoryDao
SqlAction.deleteRepoDeleteLogs(DeleteLog)
with the current
context.deleteRepoDeleteLogs
in interface RepositoryDao
template
- not null.current
- not null.public List<Integer> deleteRepoDeleteLogs(List<SqlAction.DeleteLog> templates, Ice.Current current)
RepositoryDao
SqlAction.deleteRepoDeleteLogs(DeleteLog)
with the current
context for a number of templates.deleteRepoDeleteLogs
in interface RepositoryDao
templates
- not null.current
- not null.public omero.sys.EventContext getEventContext(Ice.Current curr)
RepositoryDao
getEventContext
in interface RepositoryDao
protected EventContext currentContext(Principal currentUser)
public String getUserInstitution(long userId, Ice.Current current)
RepositoryDao
getUserInstitution
in interface RepositoryDao
userId
- the ID of the user whose institution is to be fetchedcurrent
- the current ICE method invocation contextnull
public String getUserInstitution(long userId, ServiceFactory sf)
RepositoryDao
getUserInstitution
in interface RepositoryDao
userId
- the ID of the user whose institution is to be fetchedsf
- the service factory to use for the querynull
protected List<OriginalFile> createOriginalFile(ServiceFactory sf, SqlAction sql, String repoUuid, List<CheckedPath> checked, omero.model.ChecksumAlgorithm checksumAlgorithm, String mimetype)
CheckedPath
instance. This will use access to the actual File
object in order to calculate size, timestamps, etc.sf
- sql
- repoUuid
- checked
- checksumAlgorithm
- mimetype
- protected void internalMkdir(CheckedPath file)
file
- the path to ensure exists as a directoryResourceError
protected void canWriteParentDirectory(ServiceFactory sf, SqlAction sql, String repoUuid, CheckedPath parent)
SecurityViolation
if the current
context cannot write to the parent directory.sf
- sql
- repoUuid
- parent
- protected Principal currentUser(Ice.Current __current)
protected Map<String,String> fileContext(long fileId, Ice.Current current) throws omero.SecurityViolation
omero.SecurityViolation
- if the file can't be read.protected Map<String,String> groupContext(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 ChecksumAlgorithm getChecksumAlgorithm(String name, Ice.Current current)
RepositoryDao
getChecksumAlgorithm
in interface RepositoryDao
name
- a checksum algorithm name, must existcurrent
- Ice method invocation contextpublic OriginalFile getOriginalFileWithHasher(long id, Ice.Current current)
RepositoryDao
getOriginalFileWithHasher
in interface RepositoryDao
id
- the ID of an original file, must existcurrent
- Ice method invocation contextpublic void saveObject(IObject object, Ice.Current current)
RepositoryDao
saveObject
in interface RepositoryDao
object
- a model objectcurrent
- Ice method invocation context
Version: 5.2.0-ice35-b12
Copyright © 2015 The University of Dundee & Open Microscopy Environment. All Rights Reserved.