public class CheckedPath extends Object
CheckedPath
objects store various interpretations of paths that
are passed in by users. One of these objects should be created at the
very beginning of any PublicRepositoryI
remote method (i.e. those
public methods which take Current
instance arguments. Methods
are then available to check various capabilities by the current user. When
a null CheckedPath
object is passed into the constructor the caller
indicates that the path is the root path, hence isRoot
will not be called.Modifier and Type | Field and Description |
---|---|
FsFile |
fsFile |
protected String |
hash |
protected Long |
id |
boolean |
isRoot |
protected String |
mime |
Constructor and Description |
---|
CheckedPath(ServerFilePathTransformer serverPaths,
String path,
ChecksumProviderFactory checksumProviderFactory,
omero.model.ChecksumAlgorithm checksumAlgorithm)
Construct a CheckedPath from a relative "/"-delimited path rooted at the repository.
|
Modifier and Type | Method and Description |
---|---|
OriginalFile |
asOriginalFile(String mimetype)
Creates an
OriginalFile instance for the given
CheckedPath even if it doesn't exist. |
void |
bfSetId(ReaderWrapper reader)
Perform BioFormats
ReaderWrapper.setId(String) for this file. |
boolean |
canEdit() |
boolean |
canRead()
Check if this file is actually readable on the underlying filesystem.
|
CheckedPath |
child(String name)
Returns a new
CheckedPath that has the given path appended
to the end of this instances path. |
boolean |
equals(Object object)
Instances are equal if their string representations match.
|
boolean |
exists()
Check if this file actually exists on the underlying filesystem.
|
protected String |
getDirname()
Assuming this is a directory, return relative path plus name with a final
slash.
|
FileBuffer |
getFileBuffer(String mode)
Get a
FileBuffer corresponding to this instance. |
protected String |
getFullFsPath()
The full path of the entity to which this path corresponds.
|
Long |
getId() |
String |
getMimetype()
Get the mimetype for a file.
|
protected String |
getName()
Get the last component of this path, the entity to which the path corresponds.
|
protected String |
getRelativePath()
Get the parent path of the entity to which this path corresponds.
|
String |
hash() |
int |
hashCode()
On Windows systems the calculation is not case-sensitive.
|
boolean |
isDirectory() |
boolean |
markModified()
Mark this existing file as having been modified at the present moment.
|
boolean |
mkdir()
Create this directory on the underlying filesystem.
|
boolean |
mkdirs()
Create this directory, and parents if necessary, on the underlying filesystem.
|
CheckedPath |
mustEdit() |
CheckedPath |
mustExist()
Checks for existence of the original path, throwing an exception if
not present.
|
CheckedPath |
parent()
Returns a new
CheckedPath using File.getParent() and
passing in all other values. |
void |
setId(Long id) |
long |
size()
Return the size of this file on the underlying filesystem.
|
String |
toString() |
public final FsFile fsFile
public boolean isRoot
protected Long id
protected String hash
protected String mime
public CheckedPath(ServerFilePathTransformer serverPaths, String path, ChecksumProviderFactory checksumProviderFactory, omero.model.ChecksumAlgorithm checksumAlgorithm) throws omero.ValidationException
.and
..are understood to have their usual meaning. An empty path is the repository root.
serverPaths
- the server path handling servicepath
- a repository pathchecksumProviderFactory
- a source of checksum providers,
may be null
if checksumAlgorithm
is also null
checksumAlgorithm
- the algorithm to use in hash()
's calculationsomero.ValidationException
- if the path is empty or contains illegal componentspublic Long getId()
public void setId(Long id)
public String hash()
public String getMimetype()
public CheckedPath parent() throws omero.ValidationException
CheckedPath
using File.getParent()
and
passing in all other values. Just as if calling the constructor,
bad paths will cause a ValidationException
to be thrown.
CheckedPath
s generated with this method always return a
null
hash.omero.ValidationException
public CheckedPath child(String name) throws omero.ValidationException
CheckedPath
that has the given path appended
to the end of this instances path. A check is made that the name does
not contain "/" (i.e. subpaths) nor that it is ".." or ".".
CheckedPath
s generated with this method always return a
null
hash.name
- omero.ValidationException
public boolean exists()
File.exists()
.true
if the file exists, false
otherwisepublic CheckedPath mustExist() throws omero.ValidationException
omero.ValidationException
public CheckedPath mustEdit() throws omero.SecurityViolation
omero.SecurityViolation
public boolean canRead()
File.canRead()
.true
if the file is readable, false
otherwisepublic boolean canEdit()
public boolean isDirectory()
protected String getDirname()
protected String getName()
isRoot
then this is the empty string.protected String getRelativePath()
FsFile.separatorChar
.FsFile.separatorChar
.protected String getFullFsPath()
FsFile.separatorChar
.public FileBuffer getFileBuffer(String mode)
FileBuffer
corresponding to this instance.
It is the caller's responsibility to FileBuffer.close()
it.mode
- as for RandomAccessFile.RandomAccessFile(File, String)
,
"r"
and "rw"
being common choicesFileBuffer
public long size()
File.length()
.public boolean mkdir()
File.mkdir()
.true
if the directory was created, false
otherwisepublic boolean mkdirs()
File.mkdirs()
.true
if the directory was created, false
otherwisepublic boolean markModified()
true
if the file's modification time was updated, false
otherwisepublic void bfSetId(ReaderWrapper reader) throws FormatException, IOException
ReaderWrapper.setId(String)
for this file.reader
- the BioFormats reader upon which to operateFormatException
- passed up from ReaderWrapper.setId(String)
IOException
- passed up from ReaderWrapper.setId(String)
public OriginalFile asOriginalFile(String mimetype)
OriginalFile
instance for the given
CheckedPath
even if it doesn't exist. If it does exist, then
the size and hash will be properly set. Further, if it's a directory,
the mimetype passed in by the user must either be null, in which case
"Directory" will be used, or must be that correct value.mimetype
- The mimetype to handle.public boolean equals(Object object)
Version: 5.2.8-ice35-b57
Copyright © 2017 The University of Dundee & Open Microscopy Environment. All Rights Reserved.