net.sf.vcaperture.services
Class YamlFilesystemStorageService
java.lang.Object
net.sf.vcaperture.services.YamlFilesystemStorageService
- All Implemented Interfaces:
- ILocalStorageService
public class YamlFilesystemStorageService
- extends java.lang.Object
- implements ILocalStorageService
Version of ILocalStorageService that uses a local filesystem directory structure and
YAML files to store information about the repositories.
INTERNAL IMPLEMENTATION DETAIL (SHOULD NOT BE USED BY OUTSIDE DEVELOPERS / SUBJECT TO CHANGE)
Directory Structure:
repoName
revisions (DIRECTORY)
latest-version.txt
{REVISION-GROUP-FOLDER} - Break revisions into chunks so that there are not millions of subfolders
{REVISION}
revision.yml
file/dir/structure/{FILENAME} - contents
files
file/dir/structure/${FILENAME}.yml
TODO: This is probably not the most highly efficient implementation possible. I guess that in
practice, especially in use from the web app, it will be fairly slow due to the large number of
file operations it must do. But it was quick and easy to put together. I am thinking that a
better implementation might be entirely based on Lucene.
- Author:
- Jeremy Thomerson (jthomerson@users.sourceforge.net)
Method Summary |
java.util.List<RepoFile> |
getChildren(AbstractRepository repo,
RepoFile repoFile,
boolean showAll)
|
protected java.lang.String |
getContents(AbstractRepository repo,
RepoFileRevision rfr)
|
RepoFile |
getFile(AbstractRepository repo,
java.lang.String relativePath)
|
private java.io.File |
getFilesStorageDirectory(AbstractRepository repo)
|
private static java.lang.String |
getFolderString(int rev)
|
java.lang.String |
getLatestStoredRevision(AbstractRepository repo)
|
private java.io.File |
getRepoStorageDirectory(AbstractRepository repo)
|
private java.io.File |
getRevisionFolder(AbstractRepository repo,
java.lang.String rev)
|
private int |
getRevisionNumber(java.lang.String rev)
|
java.util.Collection<Revision> |
getRevisions(AbstractRepository repo,
java.lang.String startingRevision,
int maxRevisions)
|
java.io.File |
getStorageDirectory()
|
void |
saveFileRevision(AbstractRepository repo,
RepoFileRevision rfr)
Saves an actual file that was part of the revision. |
void |
saveRevision(AbstractRepository repo,
Revision rev)
Saves the revision information for this repo / revision combo. |
void |
setStorageDirectory(java.io.File storageDirectory)
|
void |
updateLatestStoredRevision(AbstractRepository repo,
Revision rev)
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
LATEST_VERSION_FILE
private static final java.lang.String LATEST_VERSION_FILE
- See Also:
- Constant Field Values
REVISION_DATA_FILE
private static final java.lang.String REVISION_DATA_FILE
- See Also:
- Constant Field Values
mStorageDirectory
private java.io.File mStorageDirectory
YamlFilesystemStorageService
public YamlFilesystemStorageService()
getRevisions
public java.util.Collection<Revision> getRevisions(AbstractRepository repo,
java.lang.String startingRevision,
int maxRevisions)
- Specified by:
getRevisions
in interface ILocalStorageService
getContents
protected java.lang.String getContents(AbstractRepository repo,
RepoFileRevision rfr)
getLatestStoredRevision
public java.lang.String getLatestStoredRevision(AbstractRepository repo)
- Specified by:
getLatestStoredRevision
in interface ILocalStorageService
- Parameters:
repo
- The repo you need the revision for
- Returns:
- the latest revision that has been locally stored, or
AbstractRepository.getNullRevisionDefault() if none has been stored.
- See Also:
AbstractRepository.getNullRevisionDefault()
updateLatestStoredRevision
public void updateLatestStoredRevision(AbstractRepository repo,
Revision rev)
getFile
public RepoFile getFile(AbstractRepository repo,
java.lang.String relativePath)
- Specified by:
getFile
in interface ILocalStorageService
- Parameters:
repo
- The repo you need the revision forrelativePath
- The relative path of the file you need
- Returns:
- the RepoFile at that path
getChildren
public java.util.List<RepoFile> getChildren(AbstractRepository repo,
RepoFile repoFile,
boolean showAll)
saveRevision
public void saveRevision(AbstractRepository repo,
Revision rev)
- Description copied from interface:
ILocalStorageService
- Saves the revision information for this repo / revision combo.
IMPORTANT: This does NOT save the individual files that were part of this revision.
You must do that separately.
- Specified by:
saveRevision
in interface ILocalStorageService
- Parameters:
repo
- The repo that the revision applies torev
- The revision to save
saveFileRevision
public void saveFileRevision(AbstractRepository repo,
RepoFileRevision rfr)
- Description copied from interface:
ILocalStorageService
- Saves an actual file that was part of the revision. The RepoFileRevision passed in
should already have it's revisions field updated to reflect that it was part of this
revision. This method saves both the RepoFile and the contents of the
RepoFileRevision.
- Specified by:
saveFileRevision
in interface ILocalStorageService
- Parameters:
repo
- The repo that the revision applies torfr
- The revision to save
getStorageDirectory
public java.io.File getStorageDirectory()
setStorageDirectory
public void setStorageDirectory(java.io.File storageDirectory)
getRepoStorageDirectory
private java.io.File getRepoStorageDirectory(AbstractRepository repo)
getFilesStorageDirectory
private java.io.File getFilesStorageDirectory(AbstractRepository repo)
getRevisionFolder
private java.io.File getRevisionFolder(AbstractRepository repo,
java.lang.String rev)
getRevisionNumber
private int getRevisionNumber(java.lang.String rev)
getFolderString
private static java.lang.String getFolderString(int rev)
Copyright © 2008. All Rights Reserved.