Package ome.services.blitz.repo
Class ManagedRepositoryI
- java.lang.Object
-
- ome.services.blitz.repo.PublicRepositoryI
-
- ome.services.blitz.repo.ManagedRepositoryI
-
- All Implemented Interfaces:
_ManagedRepositoryOperations,_RepositoryOperations,org.springframework.beans.factory.Aware,org.springframework.context.ApplicationContextAware
public class ManagedRepositoryI extends PublicRepositoryI implements _ManagedRepositoryOperations
Extension of the PublicRepository API which only manages files under ${omero.data.dir}/ManagedRepository.- Since:
- 5.0
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class ome.services.blitz.repo.PublicRepositoryI
PublicRepositoryI.AMD_submit
-
-
Field Summary
Fields Modifier and Type Field Description protected FsFiletemplateRoot-
Fields inherited from class ome.services.blitz.repo.PublicRepositoryI
checksumAlgorithms, checksumProviderFactory, context, DIRECTORY_MIMETYPE, filePathRestrictions, IMPORT_LOG_MIMETYPE, repositoryDao, serverPaths
-
-
Constructor Summary
Constructors Constructor Description ManagedRepositoryI(java.lang.String template, RepositoryDao dao)Creates aProcessContainerinternally that will not be managed by background threads.ManagedRepositoryI(java.lang.String template, RepositoryDao dao, ProcessContainer processes, ome.security.SecuritySystem securitySystem, ome.util.checksum.ChecksumProviderFactory checksumProviderFactory, java.lang.String checksumAlgorithmSupported, java.lang.String pathRules, java.lang.String rootSessionUuid, ome.system.Roles roles, java.util.Set<java.lang.String> managedRepoUuids)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected CheckedPathcheckPath(java.lang.String path, ChecksumAlgorithm checksumAlgorithm)protected CheckedPathcheckPath(java.lang.String path, ChecksumAlgorithm checksumAlgorithm, Ice.Current curr)Create a newCheckedPathobject based on the given user input.voidclearFileCreationListener()Clear the file creation listener for this thread.protected FsFilecommonRoot(java.util.List<FsFile> paths)From a list of paths, calculate the common root path that all share.protected ImportProcessPrxcreateImportProcess(Fileset fs, ImportLocation location, ImportSettings settings, Ice.Current __current)Creating the process will register itself in an appropriate container (i.e.protected FsFilecreateTemplatePath(java.lang.Object consistentData, Ice.Current __current)Expand the template path and create its directories with the correct ownership.FsFilecreateTemplatePath(java.lang.Object consistentData, ome.system.EventContext ctx, ome.system.ServiceFactory sf, org.hibernate.Session session, ome.util.SqlAction sql)Expand the template path and create its directories with the correct ownership.protected ImportProcessPrxcreateUploadProcess(Fileset fs, ImportLocation location, ImportSettings settings, Ice.Current __current, boolean uploadOnly)Creating the process will register itself in an appropriate container (i.e.protected FsFileexpandTemplateRootOwnedPath(EventContext ctx, ome.system.ServiceFactory sf)Expand the root-owned segment of the template path.protected java.lang.Class<? extends loci.formats.FormatReader>getReaderClass(Fileset fs, Ice.Current __current)Get the suggested BioFormats Reader for the given Fileset.ImportProcessPrximportFileset(Fileset fs, ImportSettings settings, Ice.Current __current)Return a template based directory path.ImportProcessPrximportPaths(java.util.List<java.lang.String> paths, Ice.Current __current)For clients without access to Bio-Formats, the simplifiedimportPathsmethod allows passing solely the absolute path of the files to be uploaded (no directories) and all configuration happens server-side.voidinitialize(FileMaker fileMaker, java.lang.Long id, java.lang.String repoUuid)Called by the internal repository once initialization has taken place.java.util.List<ChecksumAlgorithm>listChecksumAlgorithms(Ice.Current __current)Return the list of checksum algorithms supported by this repository for verifying the integrity of uploaded files.java.util.List<ImportProcessPrx>listImports(Ice.Current __current)List imports that are currently running in this importer.protected voidmakeCheckedDirs(java.util.LinkedList<CheckedPath> paths, boolean parents, org.hibernate.Session s, ome.system.ServiceFactory sf, ome.util.SqlAction sql, ome.system.EventContext effectiveEventContext)Checks for the top-level user directory restriction before callingPublicRepositoryI.makeCheckedDirs(LinkedList, boolean, Session, ServiceFactory, SqlAction, EventContext)voidmakeDir(java.lang.String path, boolean parents, org.hibernate.Session session, ome.system.ServiceFactory sf, ome.util.SqlAction sql, ome.system.EventContext effectiveEventContext)java.util.List<java.lang.Long>setChecksumAlgorithm(ChecksumAlgorithm toHasherWrapped, java.util.List<java.lang.Long> ids, Ice.Current __current)Set the checksum algorithm for the original files identified by the given IDs and calculate their checksum accordingly.voidsetFileCreationListener(java.util.function.Consumer<CheckedPath> fileCreationListener)Set the file creation listener for this thread that is notified of new files being created.ChecksumAlgorithmsuggestChecksumAlgorithm(java.util.List<ChecksumAlgorithm> supported, Ice.Current __current)Suggest a checksum algorithm to use forImportSettings.checksumAlgorithmaccording to the preferences set by the server administrator.protected ImportLocationsuggestImportPaths(FsFile relPath, FsFile basePath, java.util.List<FsFile> paths, java.lang.Class<? extends loci.formats.FormatReader> reader, ChecksumAlgorithm checksumAlgorithm, Ice.Current __current)Take a relative path that the user would like to see in his or her upload area, and provide an import location instance whose paths correspond to existing directories corresponding to the sanitized file paths.Ice.Objecttie()Wrap the current instance with anTieBaseso that it can be turned into a proxy.protected ome.services.blitz.repo.ManagedRepositoryI.PathstrimPaths(FsFile basePath, java.util.List<FsFile> fullPaths, java.lang.Class<? extends loci.formats.FormatReader> readerClass)Trim off the start of long client-side paths.ImportProcessPrxuploadFileset(Fileset fs, ImportSettings settings, Ice.Current __current)Return a template based directory path.java.util.List<java.lang.Long>verifyChecksums(java.util.List<java.lang.Long> ids, Ice.Current __current)Verify the checksum for the original files identified by the given IDs.-
Methods inherited from class ome.services.blitz.repo.PublicRepositoryI
createRepoRFS, deletePaths, file, fileById, fileExists, findInDb, findOrCreateInDb, findOrCreateInDb, getFactory, getRepoUuid, list, listFiles, makeAdjustedCurrent, makeCheckedDirs, makeDir, makeDir, mimetype, persistLogFile, publishMessage, register, root, rootPath, setApplicationContext, stackTraceAsString, submitRequest, submitRequest, sudo, treeList
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface omero.grid._RepositoryOperations
deletePaths, file, fileById, fileExists, list, listFiles, makeDir, mimetype, register, root, treeList
-
-
-
-
Field Detail
-
templateRoot
protected FsFile templateRoot
-
-
Constructor Detail
-
ManagedRepositoryI
public ManagedRepositoryI(java.lang.String template, RepositoryDao dao) throws java.lang.ExceptionCreates aProcessContainerinternally that will not be managed by background threads. Used primarily during testing.- Parameters:
template-dao-- Throws:
java.lang.Exception
-
ManagedRepositoryI
public ManagedRepositoryI(java.lang.String template, RepositoryDao dao, ProcessContainer processes, ome.security.SecuritySystem securitySystem, ome.util.checksum.ChecksumProviderFactory checksumProviderFactory, java.lang.String checksumAlgorithmSupported, java.lang.String pathRules, java.lang.String rootSessionUuid, ome.system.Roles roles, java.util.Set<java.lang.String> managedRepoUuids) throws ServerError- Throws:
ServerError
-
-
Method Detail
-
tie
public Ice.Object tie()
Description copied from class:PublicRepositoryIWrap the current instance with anTieBaseso that it can be turned into a proxy. This is required due to the subclassing between public repo instances.- Overrides:
tiein classPublicRepositoryI
-
initialize
public void initialize(FileMaker fileMaker, java.lang.Long id, java.lang.String repoUuid) throws ValidationException
Description copied from class:PublicRepositoryICalled by the internal repository once initialization has taken place.- Overrides:
initializein classPublicRepositoryI- Throws:
ValidationException
-
setFileCreationListener
public void setFileCreationListener(java.util.function.Consumer<CheckedPath> fileCreationListener)
Set the file creation listener for this thread that is notified of new files being created. Maintains only a weak reference to the given listener. Applies only for uses ofmakeCheckedDirs(LinkedList, boolean, Session, ServiceFactory, SqlAction, EventContext)by this thread.- Parameters:
fileCreationListener- a file creation listener
-
clearFileCreationListener
public void clearFileCreationListener()
Clear the file creation listener for this thread.- See Also:
setFileCreationListener(Consumer)
-
uploadFileset
public ImportProcessPrx uploadFileset(Fileset fs, ImportSettings settings, Ice.Current __current) throws ServerError
Return a template based directory path. The path will be created by callingPublicRepositoryI.makeDir(String, boolean, Ice.Current).- Throws:
ServerError
-
importFileset
public ImportProcessPrx importFileset(Fileset fs, ImportSettings settings, Ice.Current __current) throws ServerError
Return a template based directory path. The path will be created by callingPublicRepositoryI.makeDir(String, boolean, Ice.Current).- Specified by:
importFilesetin interface_ManagedRepositoryOperations__current- The Current object for the invocation.- Throws:
ServerError
-
importPaths
public ImportProcessPrx importPaths(java.util.List<java.lang.String> paths, Ice.Current __current) throws ServerError
Description copied from interface:_ManagedRepositoryOperationsFor clients without access to Bio-Formats, the simplifiedimportPathsmethod allows passing solely the absolute path of the files to be uploaded (no directories) and all configuration happens server-side. Much of the functionality provided viaFilesetandImportSettingsis of course lost.- Specified by:
importPathsin interface_ManagedRepositoryOperations__current- The Current object for the invocation.- Throws:
ServerError
-
listImports
public java.util.List<ImportProcessPrx> listImports(Ice.Current __current) throws ServerError
Description copied from interface:_ManagedRepositoryOperationsList imports that are currently running in this importer. These will be limited based on user/group membership for theFilesetobject which is being created by the import. If the user has write permissions for the fileset, then the import will be included.- Specified by:
listImportsin interface_ManagedRepositoryOperations- Parameters:
__current- The Current object for the invocation.- Throws:
ServerError
-
listChecksumAlgorithms
public java.util.List<ChecksumAlgorithm> listChecksumAlgorithms(Ice.Current __current)
Description copied from interface:_ManagedRepositoryOperationsReturn the list of checksum algorithms supported by this repository for verifying the integrity of uploaded files. They are named as ""algorithm-integer"", integer being the bit width of the resulting hash code. It is possible for the same algorithm to be offered with different bit widths. They are listed in descending order of preference, as set by the server administrator, and any of them may be specified forImportSettings.checksumAlgorithm.- Specified by:
listChecksumAlgorithmsin interface_ManagedRepositoryOperations- Parameters:
__current- The Current object for the invocation.
-
suggestChecksumAlgorithm
public ChecksumAlgorithm suggestChecksumAlgorithm(java.util.List<ChecksumAlgorithm> supported, Ice.Current __current)
Description copied from interface:_ManagedRepositoryOperationsSuggest a checksum algorithm to use forImportSettings.checksumAlgorithmaccording to the preferences set by the server administrator. Provide a list of the algorithms supported by the client, and the server will report which of them is most preferred by the server, or return null if none of them are supported.- Specified by:
suggestChecksumAlgorithmin interface_ManagedRepositoryOperations__current- The Current object for the invocation.
-
verifyChecksums
public java.util.List<java.lang.Long> verifyChecksums(java.util.List<java.lang.Long> ids, Ice.Current __current) throws ServerErrorDescription copied from interface:_ManagedRepositoryOperationsVerify the checksum for the original files identified by the given IDs. The files must be in this repository. Returns the IDs of the original files whose checksums do not match the file on disk.- Specified by:
verifyChecksumsin interface_ManagedRepositoryOperations__current- The Current object for the invocation.- Throws:
ServerError
-
setChecksumAlgorithm
public java.util.List<java.lang.Long> setChecksumAlgorithm(ChecksumAlgorithm toHasherWrapped, java.util.List<java.lang.Long> ids, Ice.Current __current) throws ServerError
Description copied from interface:_ManagedRepositoryOperationsSet the checksum algorithm for the original files identified by the given IDs and calculate their checksum accordingly. The files must be in this repository. Existing checksums are checked before being changed. If a checksum does not match, ServerError will be thrown; in this case some other files may already have had their checksum algorithm set. Returns the IDs of the original files that did not already have a checksum set for the given algorithm.- Specified by:
setChecksumAlgorithmin interface_ManagedRepositoryOperations__current- The Current object for the invocation.- Throws:
ServerError
-
createImportProcess
protected ImportProcessPrx createImportProcess(Fileset fs, ImportLocation location, ImportSettings settings, Ice.Current __current) throws ServerError
Creating the process will register itself in an appropriate container (i.e. a SessionI or similar) for the current user and therefore this instance no longer needs to worry about the maintenance of the object.- Throws:
ServerError
-
createUploadProcess
protected ImportProcessPrx createUploadProcess(Fileset fs, ImportLocation location, ImportSettings settings, Ice.Current __current, boolean uploadOnly) throws ServerError
Creating the process will register itself in an appropriate container (i.e. a SessionI or similar) for the current user and therefore this instance no longer needs to worry about the maintenance of the object.- Throws:
ServerError
-
getReaderClass
protected java.lang.Class<? extends loci.formats.FormatReader> getReaderClass(Fileset fs, Ice.Current __current)
Get the suggested BioFormats Reader for the given Fileset.- Parameters:
fs- a fileset__current- the current ICE context- Returns:
- a reader class, or null if none could be found
-
commonRoot
protected FsFile commonRoot(java.util.List<FsFile> paths)
From a list of paths, calculate the common root path that all share. In the worst case, that may be "/". May not include the last element, the filename.- Parameters:
paths- some paths- Returns:
- the paths' common root
-
expandTemplateRootOwnedPath
protected FsFile expandTemplateRootOwnedPath(EventContext ctx, ome.system.ServiceFactory sf) throws ServerError
Expand the root-owned segment of the template path.- Parameters:
ctx- the event context to apply in expanding termssf- the service factory- Returns:
- the expanded template path
- Throws:
ServerError- if the path could not be expanded
-
createTemplatePath
protected FsFile createTemplatePath(java.lang.Object consistentData, Ice.Current __current) throws ServerError
Expand the template path and create its directories with the correct ownership.- Parameters:
consistentData- the object to hash in expanding%hash%__current- the method invocation context- Returns:
- the expanded template path
- Throws:
ServerError- if the new path could not be created
-
createTemplatePath
public FsFile createTemplatePath(java.lang.Object consistentData, ome.system.EventContext ctx, ome.system.ServiceFactory sf, org.hibernate.Session session, ome.util.SqlAction sql) throws ServerError
Expand the template path and create its directories with the correct ownership. Performs the work ofcreateTemplatePath(Object, Current)except from within an existing transaction.- Parameters:
consistentData- the object to hash in expanding%hash%ctx- the event context to apply in expanding termssf- the service factorysession- the Hibernate sessionsql- the JDBC convenience wrapper- Returns:
- the expanded template path
- Throws:
ServerError- if the new path could not be created
-
trimPaths
protected ome.services.blitz.repo.ManagedRepositoryI.Paths trimPaths(FsFile basePath, java.util.List<FsFile> fullPaths, java.lang.Class<? extends loci.formats.FormatReader> readerClass)
Trim off the start of long client-side paths.- Parameters:
basePath- the common rootfullPaths- the full paths from the common root down to the filenamereaderClass- BioFormats reader for data, may be null- Returns:
- possibly trimmed common root and full paths
-
suggestImportPaths
protected ImportLocation suggestImportPaths(FsFile relPath, FsFile basePath, java.util.List<FsFile> paths, java.lang.Class<? extends loci.formats.FormatReader> reader, ChecksumAlgorithm checksumAlgorithm, Ice.Current __current) throws ServerError
Take a relative path that the user would like to see in his or her upload area, and provide an import location instance whose paths correspond to existing directories corresponding to the sanitized file paths.- Parameters:
relPath- Path parsed from the templatebasePath- Common base of all the listed paths ("/my/path")reader- BioFormats reader for data, may be nullchecksumAlgorithm- the checksum algorithm to use in verifying the integrity of uploaded files- Returns:
ImportLocationinstance- 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
Checks for the top-level user directory restriction before callingPublicRepositoryI.makeCheckedDirs(LinkedList, boolean, Session, ServiceFactory, SqlAction, EventContext)- Overrides:
makeCheckedDirsin classPublicRepositoryI- 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
-
checkPath
protected final CheckedPath checkPath(java.lang.String path, ChecksumAlgorithm checksumAlgorithm, Ice.Current curr) throws ValidationException
Description copied from class:PublicRepositoryICreate a newCheckedPathobject based on the given user input. This method is included to allow subclasses a chance to introduce their ownCheckedPathimplementations.- Overrides:
checkPathin classPublicRepositoryI- Parameters:
path- A path on a repository.- Throws:
ValidationException
-
checkPath
protected final CheckedPath checkPath(java.lang.String path, ChecksumAlgorithm checksumAlgorithm) throws ValidationException
-
makeDir
public void makeDir(java.lang.String path, boolean parents, org.hibernate.Session session, ome.system.ServiceFactory sf, ome.util.SqlAction sql, ome.system.EventContext effectiveEventContext) throws ServerError
-
-