Package org.ametys.core.util.path
Class PathSource
java.lang.Object
org.ametys.core.util.path.PathSource
- All Implemented Interfaces:
ModifiableSource
,ModifiableTraversableSource
,MoveableSource
,Source
,TraversableSource
- Direct Known Subclasses:
SkinSource
A
ModifiableTraversableSource
for path objects.-
Field Summary
-
Constructor Summary
ModifierConstructorDescriptionprotected
Empty constructorPathSource
(String uri) Builds a PathSource given an URI, which doesn't necessarily have to start with "file:"PathSource
(String scheme, String uri, Path path) Builds a PathSource, given an URI scheme, URI and a Path.PathSource
(String scheme, Path path) Builds a PathSource, given an URI scheme and a Path. -
Method Summary
Modifier and TypeMethodDescriptionboolean
canCancel
(OutputStream stream) Can the data sent to anOutputStream
returned bygetOutputStream()
be cancelled ?void
cancel
(OutputStream stream) Cancel the data sent to anOutputStream
returned bygetOutputStream()
.void
void
delete()
Delete the source.boolean
exists()
long
getFile()
Get the associated filelong
getName()
Get anInputStream
where raw bytes can be written to.getURI()
boolean
void
void
void
refresh()
-
Field Details
-
_path
The file -
_scheme
The scheme -
_uri
The URI of this source -
_externalUri
The uri taking in account the final file
-
-
Constructor Details
-
PathSource
protected PathSource()Empty constructor -
PathSource
Builds a PathSource given an URI, which doesn't necessarily have to start with "file:"- Parameters:
uri
- The filURI- Throws:
SourceException
- If URL cannot be createdMalformedURLException
- If URL is malformed
-
PathSource
Builds a PathSource, given an URI scheme and a Path.- Parameters:
scheme
- The schemepath
- The file- Throws:
SourceException
- If url cannot be created
-
PathSource
Builds a PathSource, given an URI scheme, URI and a Path.- Parameters:
scheme
- The schemeuri
- the URIpath
- The file
-
-
Method Details
-
getFile
Get the associated file- Returns:
- The underlying path
-
getContentLength
- Specified by:
getContentLength
in interfaceSource
-
getInputStream
- Specified by:
getInputStream
in interfaceSource
- Throws:
IOException
SourceNotFoundException
-
getLastModified
- Specified by:
getLastModified
in interfaceSource
-
getMimeType
- Specified by:
getMimeType
in interfaceSource
-
getScheme
-
getURI
-
getValidity
- Specified by:
getValidity
in interfaceSource
-
refresh
-
exists
-
getChild
- Specified by:
getChild
in interfaceTraversableSource
- Throws:
SourceException
-
getChildren
- Specified by:
getChildren
in interfaceTraversableSource
- Throws:
SourceException
-
getName
- Specified by:
getName
in interfaceTraversableSource
-
getParent
- Specified by:
getParent
in interfaceTraversableSource
- Throws:
SourceException
-
isCollection
- Specified by:
isCollection
in interfaceTraversableSource
-
getOutputStream
Get anInputStream
where raw bytes can be written to. The signification of these bytes is implementation-dependent and is not restricted to a serialized XML document. The output stream returned actually writes to a temp file that replaces the real one on close. This temp file is used as lock to forbid multiple simultaneous writes. The real file is updated atomically when the output stream is closed. The returned stream must be closed or cancelled by the calling code.- Specified by:
getOutputStream
in interfaceModifiableSource
- Returns:
- a stream to write to
- Throws:
ConcurrentModificationException
- if another thread is currently writing to this file.IOException
-
canCancel
Can the data sent to anOutputStream
returned bygetOutputStream()
be cancelled ?- Specified by:
canCancel
in interfaceModifiableSource
- Returns:
- true if the stream can be cancelled
-
cancel
Cancel the data sent to anOutputStream
returned bygetOutputStream()
.After cancel, the stream should no more be used.
- Specified by:
cancel
in interfaceModifiableSource
- Throws:
SourceException
-
delete
Delete the source.- Specified by:
delete
in interfaceModifiableSource
- Throws:
SourceException
-
makeCollection
- Specified by:
makeCollection
in interfaceModifiableTraversableSource
- Throws:
SourceException
-
copyTo
- Specified by:
copyTo
in interfaceMoveableSource
- Throws:
SourceException
-
moveTo
- Specified by:
moveTo
in interfaceMoveableSource
- Throws:
SourceException
-