public interface WorkspaceDocumentManager
Modifier and Type | Method and Description |
---|---|
void |
clearAllFilePaths()
Clear all file paths.
|
void |
closeFile(Path filePath)
Close the given file in document manager.
|
Set<Path> |
getAllFilePaths()
Returns a list of all file paths.
|
String |
getFileContent(Path filePath)
Returns the content of the file.
|
boolean |
isFileOpen(Path filePath)
Checks whether the given file is open in workspace.
|
Optional<Lock> |
lockFile(Path filePath)
Acquire a file lock.
|
Optional<Lock> |
openFile(Path filePath,
String content)
Opens the given file in document manager.
|
Optional<Lock> |
updateFile(Path filePath,
String updatedContent)
Updates given file in document manager with new content.
|
boolean isFileOpen(Path filePath)
filePath
- Path of the fileOptional<Lock> openFile(Path filePath, String content) throws WorkspaceDocumentException
filePath
- Path of the filecontent
- Content of the fileLock
retrieving a lock for the file. You must call Lock.unlock() once you are done with the work.WorkspaceDocumentException
- when file cannot be opened.Optional<Lock> updateFile(Path filePath, String updatedContent) throws WorkspaceDocumentException
Optional<Lock> lock = Optional.empty(); try { lock = documentManager.updateFile(filePath, ""); } finally { lock.ifPresent(Lock:unlock); }
filePath
- Path of the fileupdatedContent
- New content of the fileLock
retrieving a lock for the file. You must call Lock.unlock() once you are done with the work.WorkspaceDocumentException
- when file cannot be updated.void closeFile(Path filePath) throws WorkspaceDocumentException
filePath
- Path of the fileWorkspaceDocumentException
- when file cannot be closed.String getFileContent(Path filePath) throws WorkspaceDocumentException
filePath
- Path of the fileWorkspaceDocumentException
- when file cannot be read.Optional<Lock> lockFile(Path filePath)
Optional<Lock> lock = documentManager.lockFile(filePath); try { //your code } finally { lock.ifPresent(Lock:unlock); }
filePath
- Path of the fileLock
retrieving a lock for the file. You must call Lock.unlock() once you are done with the work.void clearAllFilePaths()
Copyright © 2019 WSO2. All rights reserved.