Package org.faceless.publisher.web
Class FileStore
java.lang.Object
org.faceless.publisher.web.FileStore
- All Implemented Interfaces:
Store
An implementation of
Store
that writes to the file system-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
clear()
Clear the store of all datavoid
configure
(Json json) boolean
del
(String path, Authorization auth) Delete from the store.get
(String path, Json props, Authorization auth) Retrieve a file from the store.put
(String path, Json props, Authorization auth) Save a file to the store.void
rename
(String oldpath, String newpath, Authorization auth) Rename a file in the store.void
setServiceEngine
(ServiceEngine engine) Set the ServiceEngine on this store.void
shutdown()
Prepare the Store for the ServiceEngine being shutdowntoString()
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.faceless.publisher.web.Store
copyStream, newFolderName
-
Constructor Details
-
FileStore
public FileStore()
-
-
Method Details
-
setServiceEngine
Description copied from interface:Store
Set the ServiceEngine on this store. Called immediately after the constructor- Specified by:
setServiceEngine
in interfaceStore
-
configure
public void configure(Json json) -
toString
-
clear
public void clear()Description copied from interface:Store
Clear the store of all data -
shutdown
public void shutdown()Description copied from interface:Store
Prepare the Store for the ServiceEngine being shutdown -
put
Description copied from interface:Store
Save a file to the store. Return an OutputStream to write to. Props may contain: - content_type - expiry - if not null, the number of ms after the last access to delete the file. - panding - if false, the file is flushed on each write and any get should return an InputStream for what we have. Otherwise the returned stream is opened on the first write, and until that any "get" call returns PENDING. Props is live, and can be modified up until the point the returned OutputStream is closed. Any modifications to props before closing will be reflected in any subsequent "get" operations for object, and will be written to the store when the stream is finally closed. Props should be updated synchronized. Props should be set with "ok" to boolean indicating ok or not before error- Specified by:
put
in interfaceStore
- Parameters:
path
- the path (required)props
- the properties (may be null)auth
- the Authorization used to approved this access- Returns:
- an OutputStream which is opened on the first write.
- Throws:
IOException
- if the path already exists
-
get
Description copied from interface:Store
Retrieve a file from the store. Return an InputStream to read from, or null if it doesn't exist. Props may contain anything: and will be updated (ie set or the fields removed) with - name - the name of the path - ok - whether completion was ok - content_type - last_modified - length If no files in that folder can be read, an IOException("Unauthorized") will be thrown. It's a list containing items with at least name, and possibly contentType and length.- Specified by:
get
in interfaceStore
- Parameters:
path
- the path (may be null)props
- the properties (may be null)auth
- the Authorization used to approved this access- Throws:
IOException
-
del
Description copied from interface:Store
Delete from the store. Props may contain anything The path may be a folder, if it is any files in that folder will be deleted (assuming permissions allow). If an OutputStreaam is currently open for that writer, any further writes to it will fail. If any files cannot be deleted, an IOException("Unauthorized") will be thrown.- Specified by:
del
in interfaceStore
- Parameters:
path
- the pathauth
- the Authorization used to approved this access- Returns:
- true if a file was deleted, false otherwise
- Throws:
IOException
- if something went wrong
-
rename
Description copied from interface:Store
Rename a file in the store. This is only used when a file has to be created before its final name is known; it's a technical requirement resulting from the way streamed content is stored. Authorization is the same for creating "newpath" and should be checked first. This operation will only be performed immediately after the file was created. The metadata is not updated. The files may be in different folders- Specified by:
rename
in interfaceStore
- Parameters:
oldpath
- the old pathnewpath
- the new path- Throws:
IOException
- if something went wrong
-