Package ome.services.blitz.repo
Class PublicRepositoryI
- java.lang.Object
-
- ome.services.blitz.repo.PublicRepositoryI
-
- All Implemented Interfaces:
_RepositoryOperations
,org.springframework.beans.factory.Aware
,org.springframework.context.ApplicationContextAware
- Direct Known Subclasses:
ManagedRepositoryI
public class PublicRepositoryI extends java.lang.Object implements _RepositoryOperations, org.springframework.context.ApplicationContextAware
An implementation of the PublicRepository interface.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
PublicRepositoryI.AMD_submit
-
Field Summary
Fields Modifier and Type Field Description protected com.google.common.collect.ImmutableList<ChecksumAlgorithm>
checksumAlgorithms
protected ome.util.checksum.ChecksumProviderFactory
checksumProviderFactory
protected ome.system.OmeroContext
context
static java.lang.String
DIRECTORY_MIMETYPE
Mimetype used to connote a directoryOriginalFile
object.protected FilePathRestrictions
filePathRestrictions
static java.lang.String
IMPORT_LOG_MIMETYPE
media type for import logsprotected RepositoryDao
repositoryDao
protected ServerFilePathTransformer
serverPaths
-
Constructor Summary
Constructors Constructor Description PublicRepositoryI(RepositoryDao repositoryDao, ome.util.checksum.ChecksumProviderFactory checksumProviderFactory, java.lang.String checksumAlgorithmSupported, java.lang.String pathRules)
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description protected CheckedPath
checkPath(java.lang.String path, ChecksumAlgorithm checksumAlgorithm, Ice.Current curr)
Create a newCheckedPath
object based on the given user input.protected RawFileStorePrx
createRepoRFS(CheckedPath checked, java.lang.String mode, Ice.Current __current)
Create, initialize, and register anRepoRawFileStoreI
with the proper setting (read or write).HandlePrx
deletePaths(java.lang.String[] files, boolean recursive, boolean force, Ice.Current __current)
Delete paths recursively as described in Repositories.ice.RawFileStorePrx
file(java.lang.String path, java.lang.String mode, Ice.Current __current)
Returns a special RawFileStore which permits only the operations set out in the options string ""wb"", ""a+"", etc.RawFileStorePrx
fileById(long fileId, Ice.Current __current)
boolean
fileExists(java.lang.String path, Ice.Current __current)
Returns true if the file or path exists within the repository.protected OriginalFile
findInDb(CheckedPath checked, java.lang.String mode, Ice.Current current)
Find the given path in the DB or create.protected OriginalFile
findOrCreateInDb(CheckedPath checked, java.lang.String mode, Ice.Current curr)
protected OriginalFile
findOrCreateInDb(CheckedPath checked, java.lang.String mode, java.lang.String mimetype, Ice.Current curr)
protected Ice.ObjectFactory
getFactory(java.lang.String id, Ice.Current current)
java.lang.String
getRepoUuid()
void
initialize(FileMaker fileMaker, java.lang.Long id, java.lang.String repoUuid)
Called by the internal repository once initialization has taken place.java.util.List<java.lang.String>
list(java.lang.String path, Ice.Current __current)
Returns a set of strings naming the files and directories in the directory denoted by an abstract pathname.java.util.List<OriginalFile>
listFiles(java.lang.String path, Ice.Current __current)
Returns an array of abstract pathname objects denoting the files in the directory denoted by an abstract pathname.protected Ice.Current
makeAdjustedCurrent(Ice.Current __current)
protected void
makeCheckedDirs(java.util.LinkedList<CheckedPath> paths, boolean parents, org.hibernate.Session s, ome.system.ServiceFactory sf, ome.util.SqlAction sql, ome.system.EventContext effectiveEventContext)
Internal method to be used by subclasses to perform any extra checks on the listed ofCheckedPath
instances before allowing the creation of directories.protected void
makeCheckedDirs(java.util.LinkedList<CheckedPath> paths, boolean parents, org.hibernate.Session s, ome.system.ServiceFactory sf, ome.util.SqlAction sql, ome.system.EventContext effectiveEventContext, java.util.function.Consumer<CheckedPath> fileCreationListener)
Internal method to be used by subclasses to perform any extra checks on the listed ofCheckedPath
instances before allowing the creation of directories.void
makeDir(java.lang.String path, boolean parents, Ice.Current current)
Create a nested path in the repository.void
makeDir(CheckedPath checked, boolean parents, org.hibernate.Session s, ome.system.ServiceFactory sf, ome.util.SqlAction sql, ome.system.EventContext effectiveEventContext)
java.lang.String
mimetype(java.lang.String path, Ice.Current __current)
Get the mimetype for a file.protected ome.model.core.OriginalFile
persistLogFile(ome.model.core.OriginalFile originalFile, Ice.Current current)
Deprecated.protected void
publishMessage(ome.util.messages.InternalMessage msg)
OriginalFile
register(java.lang.String path, RString mimetype, Ice.Current __current)
Register an OriginalFile using its pathOriginalFile
root(Ice.Current __current)
Return the OriginalFile descriptor for this Repository.java.lang.String
rootPath(org.hibernate.Session session, ome.system.ServiceFactory serviceFactory)
void
setApplicationContext(org.springframework.context.ApplicationContext applicationContext)
protected java.lang.String
stackTraceAsString(java.lang.Throwable t)
protected PublicRepositoryI.AMD_submit
submitRequest(ServiceFactoryI sf, Request req, Ice.Current current)
protected PublicRepositoryI.AMD_submit
submitRequest(ServiceFactoryI sf, Request req, Ice.Current current, ome.services.util.Executor.Priority priority)
protected Ice.Current
sudo(Ice.Current current, java.lang.String sessionUuid)
Provide aCurrent
like the given one, except with the request context session UUID replaced.Ice.Object
tie()
Wrap the current instance with anTieBase
so that it can be turned into a proxy.RMap
treeList(java.lang.String path, Ice.Current __current)
Similar tolist
but recursive and returns only primitive values for the file at each location.
-
-
-
Field Detail
-
DIRECTORY_MIMETYPE
public static final java.lang.String DIRECTORY_MIMETYPE
Mimetype used to connote a directoryOriginalFile
object.- See Also:
- Constant Field Values
-
IMPORT_LOG_MIMETYPE
public static final java.lang.String IMPORT_LOG_MIMETYPE
media type for import logs- See Also:
- Constant Field Values
-
serverPaths
protected ServerFilePathTransformer serverPaths
-
repositoryDao
protected final RepositoryDao repositoryDao
-
checksumProviderFactory
protected final ome.util.checksum.ChecksumProviderFactory checksumProviderFactory
-
checksumAlgorithms
protected final com.google.common.collect.ImmutableList<ChecksumAlgorithm> checksumAlgorithms
-
filePathRestrictions
protected FilePathRestrictions filePathRestrictions
-
context
protected ome.system.OmeroContext context
-
-
Constructor Detail
-
PublicRepositoryI
public PublicRepositoryI(RepositoryDao repositoryDao, ome.util.checksum.ChecksumProviderFactory checksumProviderFactory, java.lang.String checksumAlgorithmSupported, java.lang.String pathRules) throws ServerError
- Throws:
ServerError
-
-
Method Detail
-
initialize
public void initialize(FileMaker fileMaker, java.lang.Long id, java.lang.String repoUuid) throws ValidationException
Called by the internal repository once initialization has taken place.- Parameters:
fileMaker
-id
-- Throws:
ValidationException
-
tie
public Ice.Object tie()
Wrap the current instance with anTieBase
so that it can be turned into a proxy. This is required due to the subclassing between public repo instances.
-
getRepoUuid
public java.lang.String getRepoUuid()
-
root
public OriginalFile root(Ice.Current __current) throws ServerError
Description copied from interface:_RepositoryOperations
Return the OriginalFile descriptor for this Repository. It will have the path of the repository's root on the underlying filesystem.- Specified by:
root
in interface_RepositoryOperations
- Parameters:
__current
- The Current object for the invocation.- Throws:
ServerError
-
fileExists
public boolean fileExists(java.lang.String path, Ice.Current __current) throws ServerError
Description copied from interface:_RepositoryOperations
Returns true if the file or path exists within the repository. In other words, if a call on `dirname path` tolistFiles
would return an object for this path.- Specified by:
fileExists
in interface_RepositoryOperations
__current
- The Current object for the invocation.- Throws:
ServerError
-
list
public java.util.List<java.lang.String> list(java.lang.String path, Ice.Current __current) throws ServerError
Description copied from interface:_RepositoryOperations
Returns a set of strings naming the files and directories in the directory denoted by an abstract pathname.- Specified by:
list
in interface_RepositoryOperations
__current
- The Current object for the invocation.- Throws:
ServerError
-
listFiles
public java.util.List<OriginalFile> listFiles(java.lang.String path, Ice.Current __current) throws ServerError
Description copied from interface:_RepositoryOperations
Returns an array of abstract pathname objects denoting the files in the directory denoted by an abstract pathname. It is expected that at a minimum the ""name"", ""path"", ""size"" and ""mtime"" attributes will be present for eachOriginalFile
instance.- Specified by:
listFiles
in interface_RepositoryOperations
__current
- The Current object for the invocation.- Throws:
ServerError
-
treeList
public RMap treeList(java.lang.String path, Ice.Current __current) throws ServerError
Description copied from interface:_RepositoryOperations
Similar tolist
but recursive and returns only primitive values for the file at each location. Guaranteed for each path is only the values id and mimetype. After a call to unwrap, the returnedRMap
for a call to treeList("/user_1/dir0") might look something like:{ "/user_1/dir0/file1.txt" : { "id":10, "mimetype": "binary", "size": 10000L }, "/user_1/dir0/dir1" : { "id": 100, "mimetype": "Directory", "size": 0L, "files": { "/user_1/dir0/dir1/file1indir.txt" : { "id": 1, "mimetype": "png", "size": 500 } } } }
- Specified by:
treeList
in interface_RepositoryOperations
__current
- The Current object for the invocation.- Throws:
ServerError
-
rootPath
public java.lang.String rootPath(org.hibernate.Session session, ome.system.ServiceFactory serviceFactory) throws ServerError
- Parameters:
session
- the Hibernate sessionserviceFactory
- the service factory- Returns:
- the filesystem path set for this repository's root directory
- Throws:
ServerError
- if the root path could not be retrieved
-
register
public OriginalFile register(java.lang.String path, RString mimetype, Ice.Current __current) throws ServerError
Register an OriginalFile using its path- Specified by:
register
in interface_RepositoryOperations
- Parameters:
path
- Absolute path of the file to be registered.mimetype
- Mimetype as an RString__current
- ice context.- Returns:
- The OriginalFile with id set (unloaded)
- Throws:
ServerError
-
deletePaths
public HandlePrx deletePaths(java.lang.String[] files, boolean recursive, boolean force, Ice.Current __current) throws ServerError
Delete paths recursively as described in Repositories.ice. Internally usestreeList(String, Ice.Current)
to build the recursive list of files.- Specified by:
deletePaths
in interface_RepositoryOperations
- Parameters:
files
- non-null, preferably non-empty list of files to check.recursive
- See Repositories.ice for an explanationforce
- See Repositories.ice for an explanation__current
- Non-null ice context.- Throws:
ServerError
-
mimetype
public java.lang.String mimetype(java.lang.String path, Ice.Current __current) throws ServerError
Get the mimetype for a file.- Specified by:
mimetype
in interface_RepositoryOperations
- Parameters:
path
- A path on a repository.__current
- ice context.- Returns:
- mimetype
- Throws:
ServerError
-
file
public RawFileStorePrx file(java.lang.String path, java.lang.String mode, Ice.Current __current) throws ServerError
Description copied from interface:_RepositoryOperations
Returns a special RawFileStore which permits only the operations set out in the options string ""wb"", ""a+"", etc. FIXME: Initially only ""r"" and ""rw"" are supported as these are handled directly by RandomAccessFile and so don't break the current implementation. Any call to that tries to break the options will throw an ApiUsageException. If a file exists at the given path, a ValidationException will be thrown.- Specified by:
file
in interface_RepositoryOperations
__current
- The Current object for the invocation.- Throws:
ServerError
-
fileById
public RawFileStorePrx fileById(long fileId, Ice.Current __current) throws ServerError
- Specified by:
fileById
in interface_RepositoryOperations
- Throws:
ServerError
-
findInDb
protected OriginalFile findInDb(CheckedPath checked, java.lang.String mode, Ice.Current current) throws ServerError
Find the given path in the DB or create. "requiresWrite" is set to true unless the mode is "r". If requiresWrite is true, then the caller needs the file to be modifiable (both on disk and the DB). If this doesn't hold, then a SecurityViolation will be thrown.- Throws:
ServerError
-
persistLogFile
@Deprecated protected ome.model.core.OriginalFile persistLogFile(ome.model.core.OriginalFile originalFile, Ice.Current current) throws ServerError
Deprecated.Set the repository of the given original file to be this one.- Parameters:
originalFile
- the ID of the log filecurrent
- the Ice method invocation context- Throws:
ServerError
-
findOrCreateInDb
protected OriginalFile findOrCreateInDb(CheckedPath checked, java.lang.String mode, Ice.Current curr) throws ServerError
- Throws:
ServerError
-
findOrCreateInDb
protected OriginalFile findOrCreateInDb(CheckedPath checked, java.lang.String mode, java.lang.String mimetype, Ice.Current curr) throws ServerError
- Throws:
ServerError
-
makeAdjustedCurrent
protected Ice.Current makeAdjustedCurrent(Ice.Current __current)
-
sudo
protected Ice.Current sudo(Ice.Current current, java.lang.String sessionUuid)
Provide aCurrent
like the given one, except with the request context session UUID replaced.- Parameters:
current
- anCurrent
instancesessionUuid
- a new session UUID for the instance- Returns:
- a new
Current
instance like the given one but with the new session UUID
-
createRepoRFS
protected RawFileStorePrx createRepoRFS(CheckedPath checked, java.lang.String mode, Ice.Current __current) throws ServerError, InternalException
Create, initialize, and register anRepoRawFileStoreI
with the proper setting (read or write).- Parameters:
checked
- The file that will be read. Can't be null, and must have ID set.mode
- The mode for writing. If null, read-only.__current
- The current user's session information.- Returns:
- A proxy ready to be returned to the user.
- Throws:
ServerError
InternalException
-
publishMessage
protected void publishMessage(ome.util.messages.InternalMessage msg) throws ServerError, InternalException
- Throws:
ServerError
InternalException
-
submitRequest
protected PublicRepositoryI.AMD_submit submitRequest(ServiceFactoryI sf, Request req, Ice.Current current) throws ServerError, InternalException
- Throws:
ServerError
InternalException
-
submitRequest
protected PublicRepositoryI.AMD_submit submitRequest(ServiceFactoryI sf, Request req, Ice.Current current, ome.services.util.Executor.Priority priority) throws ServerError, InternalException
- Throws:
ServerError
InternalException
-
getFactory
protected Ice.ObjectFactory getFactory(java.lang.String id, Ice.Current current)
-
makeDir
public void makeDir(java.lang.String path, boolean parents, Ice.Current current) throws ServerError
Create a nested path in the repository. Creates each directory in the path is it doen't already exist. Silently returns if the directory already exists.- Specified by:
makeDir
in interface_RepositoryOperations
- Parameters:
path
- A path on a repository.parents
- Boolean switch like the "mkdir -p" flag in unix.current
- ice context.- Throws:
ServerError
-
makeDir
public void makeDir(CheckedPath checked, boolean parents, org.hibernate.Session s, ome.system.ServiceFactory sf, ome.util.SqlAction sql, ome.system.EventContext effectiveEventContext) throws ServerError
- Throws:
ServerError
-
makeCheckedDirs
protected void makeCheckedDirs(java.util.LinkedList<CheckedPath> paths, boolean parents, org.hibernate.Session s, ome.system.ServiceFactory sf, ome.util.SqlAction sql, ome.system.EventContext effectiveEventContext) throws ServerError
Internal method to be used by subclasses to perform any extra checks on the listed ofCheckedPath
instances before allowing the creation of directories.- Parameters:
paths
- Not null, not empty. (Will be emptied by this method.)parents
- "mkdir -p" like flag.s
- the Hibernate sessionsf
- the service factorysql
- the JDBC convenience wrappereffectiveEventContext
- the event context to apply- Throws:
ServerError
-
makeCheckedDirs
protected void makeCheckedDirs(java.util.LinkedList<CheckedPath> paths, boolean parents, org.hibernate.Session s, ome.system.ServiceFactory sf, ome.util.SqlAction sql, ome.system.EventContext effectiveEventContext, java.util.function.Consumer<CheckedPath> fileCreationListener) throws ServerError
Internal method to be used by subclasses to perform any extra checks on the listed ofCheckedPath
instances before allowing the creation of directories.- Parameters:
paths
- Not null, not empty. (Will be emptied by this method.)parents
- "mkdir -p" like flag.s
- the Hibernate sessionsf
- the service factorysql
- the JDBC convenience wrappereffectiveEventContext
- the event context to applyfileCreationListener
- the file creation listener to notify of new directories being created- Throws:
ServerError
-
setApplicationContext
public void setApplicationContext(org.springframework.context.ApplicationContext applicationContext) throws org.springframework.beans.BeansException
- Specified by:
setApplicationContext
in interfaceorg.springframework.context.ApplicationContextAware
- Throws:
org.springframework.beans.BeansException
-
checkPath
protected CheckedPath checkPath(java.lang.String path, ChecksumAlgorithm checksumAlgorithm, Ice.Current curr) throws ValidationException
Create a newCheckedPath
object based on the given user input. This method is included to allow subclasses a chance to introduce their ownCheckedPath
implementations.- Parameters:
path
- A path on a repository.- Throws:
ValidationException
-
stackTraceAsString
protected java.lang.String stackTraceAsString(java.lang.Throwable t)
-
-