mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-24 17:32:48 +00:00
Updates to AVM virtualization view for the latest layout with DATA and METADATA folders.
Fixes to AVM filesystem transaction handling. Made SrvSession.beginTransaction() private and added beginReadTransaction() and beginWriteTransaction(). git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@4580 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -523,10 +523,6 @@ public class AVMDiskDriver extends AlfrescoDiskDriver implements DiskInterface {
|
||||
// Create a path for the virtualization view
|
||||
|
||||
avmPath = new AVMPath( path);
|
||||
|
||||
// Validate that the store and version, if specified
|
||||
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -605,14 +601,14 @@ public class AVMDiskDriver extends AlfrescoDiskDriver implements DiskInterface {
|
||||
|
||||
// Check if the filesystem is the virtualization view
|
||||
|
||||
if ( ctx.isVirtualizationView() && storePath.isPseudoPath())
|
||||
if ( ctx.isVirtualizationView() && storePath.isReadOnlyPseudoPath())
|
||||
{
|
||||
throw new AccessDeniedException( "Cannot create folder in store/version layer, " + params.getPath());
|
||||
}
|
||||
|
||||
// Create a new file
|
||||
|
||||
sess.beginTransaction( m_transactionService, false);
|
||||
sess.beginWriteTransaction( m_transactionService);
|
||||
|
||||
try
|
||||
{
|
||||
@@ -649,8 +645,6 @@ public class AVMDiskDriver extends AlfrescoDiskDriver implements DiskInterface {
|
||||
// Check if the filesystem is writable
|
||||
|
||||
AVMContext ctx = (AVMContext) tree.getContext();
|
||||
if ( ctx.isVersion() != AVMContext.VERSION_HEAD)
|
||||
throw new AccessDeniedException("Cannot create " + params.getPath() + ", filesys not writable");
|
||||
|
||||
// Split the path to get the file name and relative path
|
||||
|
||||
@@ -667,14 +661,18 @@ public class AVMDiskDriver extends AlfrescoDiskDriver implements DiskInterface {
|
||||
|
||||
// Check if the filesystem is the virtualization view
|
||||
|
||||
if ( ctx.isVirtualizationView() && storePath.isPseudoPath())
|
||||
if ( ctx.isVirtualizationView() && storePath.isReadOnlyPseudoPath())
|
||||
{
|
||||
throw new AccessDeniedException( "Cannot create file in store/version layer, " + params.getPath());
|
||||
}
|
||||
else if ( storePath.getVersion() != AVMContext.VERSION_HEAD)
|
||||
{
|
||||
throw new AccessDeniedException("Cannot create " + params.getPath() + ", filesys not writable");
|
||||
}
|
||||
|
||||
// Create a new file
|
||||
|
||||
sess.beginTransaction( m_transactionService, false);
|
||||
sess.beginWriteTransaction( m_transactionService);
|
||||
|
||||
AVMNetworkFile netFile = null;
|
||||
|
||||
@@ -687,13 +685,13 @@ public class AVMDiskDriver extends AlfrescoDiskDriver implements DiskInterface {
|
||||
// Get the new file details
|
||||
|
||||
AVMPath fileStorePath = buildStorePath( ctx, params.getPath());
|
||||
AVMNodeDescriptor nodeDesc = m_avmService.lookup( ctx.isVersion(), fileStorePath.getAVMPath());
|
||||
AVMNodeDescriptor nodeDesc = m_avmService.lookup( fileStorePath.getVersion(), fileStorePath.getAVMPath());
|
||||
|
||||
if ( nodeDesc != null)
|
||||
{
|
||||
// Create the network file object for the new file
|
||||
|
||||
netFile = new AVMNetworkFile( nodeDesc, fileStorePath.getAVMPath(), ctx.isVersion(), m_avmService);
|
||||
netFile = new AVMNetworkFile( nodeDesc, fileStorePath.getAVMPath(), fileStorePath.getVersion(), m_avmService);
|
||||
netFile.setGrantedAccess(NetworkFile.READWRITE);
|
||||
netFile.setFullName(params.getPath());
|
||||
|
||||
@@ -750,11 +748,11 @@ public class AVMDiskDriver extends AlfrescoDiskDriver implements DiskInterface {
|
||||
|
||||
// Make sure the path is to a folder before deleting it
|
||||
|
||||
sess.beginTransaction( m_transactionService, false);
|
||||
sess.beginWriteTransaction( m_transactionService);
|
||||
|
||||
try
|
||||
{
|
||||
AVMNodeDescriptor nodeDesc = m_avmService.lookup( ctx.isVersion(), storePath.getAVMPath());
|
||||
AVMNodeDescriptor nodeDesc = m_avmService.lookup( storePath.getVersion(), storePath.getAVMPath());
|
||||
if ( nodeDesc != null)
|
||||
{
|
||||
// Check that we are deleting a folder
|
||||
@@ -815,11 +813,11 @@ public class AVMDiskDriver extends AlfrescoDiskDriver implements DiskInterface {
|
||||
|
||||
// Make sure the path is to a file before deleting it
|
||||
|
||||
sess.beginTransaction( m_transactionService, false);
|
||||
sess.beginWriteTransaction( m_transactionService);
|
||||
|
||||
try
|
||||
{
|
||||
AVMNodeDescriptor nodeDesc = m_avmService.lookup( ctx.isVersion(), storePath.getAVMPath());
|
||||
AVMNodeDescriptor nodeDesc = m_avmService.lookup( storePath.getVersion(), storePath.getAVMPath());
|
||||
if ( nodeDesc != null)
|
||||
{
|
||||
// Check that we are deleting a file
|
||||
@@ -865,42 +863,52 @@ public class AVMDiskDriver extends AlfrescoDiskDriver implements DiskInterface {
|
||||
if ( logger.isDebugEnabled())
|
||||
logger.debug("File exists check, path=" + name + ", storePath=" + storePath);
|
||||
|
||||
// Check if the filesystem is the virtualization view
|
||||
// Check if the path is valid
|
||||
|
||||
int status = FileStatus.NotExist;
|
||||
|
||||
if ( ctx.isVirtualizationView() && storePath.isPseudoPath())
|
||||
if ( storePath.isValid() == false)
|
||||
return status;
|
||||
|
||||
// Check if the filesystem is the virtualization view
|
||||
|
||||
if ( ctx.isVirtualizationView() && storePath.isReadOnlyPseudoPath())
|
||||
{
|
||||
// Check if the search path is for the root or a store folder
|
||||
// Find the file state for the pseudo folder
|
||||
|
||||
if ( storePath.isRootPath())
|
||||
FileState fstate = findPseudoState( storePath, ctx);
|
||||
|
||||
if ( fstate != null)
|
||||
{
|
||||
return FileStatus.DirectoryExists;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Get the pseudo file for the store/version folder
|
||||
// DEBUG
|
||||
|
||||
if ( logger.isDebugEnabled())
|
||||
logger.debug( " Found pseudo file " + fstate);
|
||||
|
||||
// Check if the pseudo file is a file or folder
|
||||
|
||||
PseudoFile psFile = findPseudoFolder( storePath, ctx);
|
||||
if ( psFile != null)
|
||||
{
|
||||
// DEBUG
|
||||
|
||||
if ( logger.isDebugEnabled())
|
||||
logger.debug( " Found pseudo file " + psFile);
|
||||
|
||||
return FileStatus.DirectoryExists;
|
||||
}
|
||||
if ( fstate.isDirectory())
|
||||
status = FileStatus.DirectoryExists;
|
||||
else
|
||||
return FileStatus.NotExist;
|
||||
status = FileStatus.FileExists;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Invalid pseudo file path
|
||||
|
||||
status = FileStatus.NotExist;
|
||||
}
|
||||
|
||||
// Return the file status
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
// Search for the file/folder
|
||||
|
||||
sess.beginTransaction( m_transactionService, true);
|
||||
sess.beginReadTransaction( m_transactionService);
|
||||
|
||||
AVMNodeDescriptor nodeDesc = m_avmService.lookup( ctx.isVersion(), storePath.getAVMPath());
|
||||
AVMNodeDescriptor nodeDesc = m_avmService.lookup( storePath.getVersion(), storePath.getAVMPath());
|
||||
|
||||
if ( nodeDesc != null)
|
||||
{
|
||||
@@ -955,9 +963,14 @@ public class AVMDiskDriver extends AlfrescoDiskDriver implements DiskInterface {
|
||||
if ( logger.isDebugEnabled())
|
||||
logger.debug("Get file information, path=" + name + ", storePath=" + storePath);
|
||||
|
||||
// Check if hte path is valid
|
||||
|
||||
if ( storePath.isValid() == false)
|
||||
throw new FileNotFoundException( name);
|
||||
|
||||
// Check if the filesystem is the virtualization view
|
||||
|
||||
if ( ctx.isVirtualizationView() && storePath.isPseudoPath())
|
||||
if ( ctx.isVirtualizationView() && storePath.isReadOnlyPseudoPath())
|
||||
{
|
||||
// Check if the search path is for the root, a store or version folder
|
||||
|
||||
@@ -965,7 +978,7 @@ public class AVMDiskDriver extends AlfrescoDiskDriver implements DiskInterface {
|
||||
{
|
||||
// Return dummy file informatiom for the root folder
|
||||
|
||||
return new FileInfo( name,0L, FileAttribute.Directory);
|
||||
return new FileInfo( name, 0L, FileAttribute.Directory);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -981,13 +994,13 @@ public class AVMDiskDriver extends AlfrescoDiskDriver implements DiskInterface {
|
||||
return psFile.getFileInfo();
|
||||
}
|
||||
else
|
||||
return null;
|
||||
throw new FileNotFoundException( name);
|
||||
}
|
||||
}
|
||||
|
||||
// Search for the file/folder
|
||||
|
||||
sess.beginTransaction( m_transactionService, true);
|
||||
sess.beginReadTransaction( m_transactionService);
|
||||
|
||||
FileInfo info = null;
|
||||
|
||||
@@ -1095,7 +1108,7 @@ public class AVMDiskDriver extends AlfrescoDiskDriver implements DiskInterface {
|
||||
|
||||
// Check if the filesystem is the virtualization view
|
||||
|
||||
if ( ctx.isVirtualizationView() && storePath.isPseudoPath())
|
||||
if ( ctx.isVirtualizationView() && storePath.isReadOnlyPseudoPath())
|
||||
{
|
||||
// Check if the path is for the root, a store or version folder
|
||||
|
||||
@@ -1125,7 +1138,7 @@ public class AVMDiskDriver extends AlfrescoDiskDriver implements DiskInterface {
|
||||
|
||||
// Search for the file/folder
|
||||
|
||||
sess.beginTransaction( m_transactionService, true);
|
||||
sess.beginReadTransaction( m_transactionService);
|
||||
|
||||
AVMNetworkFile netFile = null;
|
||||
|
||||
@@ -1133,20 +1146,20 @@ public class AVMDiskDriver extends AlfrescoDiskDriver implements DiskInterface {
|
||||
{
|
||||
// Get the details of the file/folder
|
||||
|
||||
AVMNodeDescriptor nodeDesc = m_avmService.lookup( ctx.isVersion(), storePath.getAVMPath());
|
||||
AVMNodeDescriptor nodeDesc = m_avmService.lookup( storePath.getVersion(), storePath.getAVMPath());
|
||||
|
||||
if ( nodeDesc != null)
|
||||
{
|
||||
// Check if the filesystem is read-only and write access has been requested
|
||||
|
||||
if ( ctx.isVersion() != AVMContext.VERSION_HEAD && ( params.isReadWriteAccess() || params.isWriteOnlyAccess()))
|
||||
if ( storePath.getVersion() != AVMContext.VERSION_HEAD && ( params.isReadWriteAccess() || params.isWriteOnlyAccess()))
|
||||
throw new AccessDeniedException("File " + params.getPath() + " is read-only");
|
||||
|
||||
// Create the network file object for the opened file/folder
|
||||
|
||||
netFile = new AVMNetworkFile( nodeDesc, storePath.getAVMPath(), ctx.isVersion(), m_avmService);
|
||||
netFile = new AVMNetworkFile( nodeDesc, storePath.getAVMPath(), storePath.getVersion(), m_avmService);
|
||||
|
||||
if ( params.isReadOnlyAccess() || ctx.isVersion() != AVMContext.VERSION_HEAD)
|
||||
if ( params.isReadOnlyAccess() || storePath.getVersion() != AVMContext.VERSION_HEAD)
|
||||
netFile.setGrantedAccess(NetworkFile.READONLY);
|
||||
else
|
||||
netFile.setGrantedAccess(NetworkFile.READWRITE);
|
||||
@@ -1202,7 +1215,7 @@ public class AVMDiskDriver extends AlfrescoDiskDriver implements DiskInterface {
|
||||
AVMNetworkFile avmFile = (AVMNetworkFile) file;
|
||||
|
||||
if ( avmFile.hasContentChannel() == false)
|
||||
sess.beginTransaction( m_transactionService, true);
|
||||
sess.beginReadTransaction( m_transactionService);
|
||||
|
||||
// Read the file
|
||||
|
||||
@@ -1252,14 +1265,14 @@ public class AVMDiskDriver extends AlfrescoDiskDriver implements DiskInterface {
|
||||
|
||||
// Check if the filesystem is the virtualization view
|
||||
|
||||
if ( ctx.isVirtualizationView() && oldAVMPath.isPseudoPath())
|
||||
if ( ctx.isVirtualizationView() && oldAVMPath.isReadOnlyPseudoPath())
|
||||
{
|
||||
throw new AccessDeniedException( "Cannot rename folder in store/version layer, " + oldName);
|
||||
}
|
||||
|
||||
// Start a transaction for the rename
|
||||
|
||||
sess.beginTransaction( m_transactionService, false);
|
||||
sess.beginWriteTransaction( m_transactionService);
|
||||
|
||||
try
|
||||
{
|
||||
@@ -1304,7 +1317,7 @@ public class AVMDiskDriver extends AlfrescoDiskDriver implements DiskInterface {
|
||||
AVMNetworkFile avmFile = (AVMNetworkFile) file;
|
||||
|
||||
if ( avmFile.hasContentChannel() == false)
|
||||
sess.beginTransaction( m_transactionService, true);
|
||||
sess.beginReadTransaction( m_transactionService);
|
||||
|
||||
// Set the file position
|
||||
|
||||
@@ -1368,60 +1381,73 @@ public class AVMDiskDriver extends AlfrescoDiskDriver implements DiskInterface {
|
||||
|
||||
// Check if the filesystem is the virtualization view
|
||||
|
||||
if ( avmCtx.isVirtualizationView() && storePath.isPseudoPath())
|
||||
if ( avmCtx.isVirtualizationView())
|
||||
{
|
||||
// Check if the search path is for the root or a store folder
|
||||
// Check for a search of a pseudo folder
|
||||
|
||||
FileState fstate = findPseudoState( storePath, avmCtx);
|
||||
|
||||
if ( fstate != null)
|
||||
{
|
||||
// Get the pseudo file list for the parent directory
|
||||
|
||||
PseudoFileList searchList = fstate.getPseudoFileList();
|
||||
|
||||
// Check if this is a single file or wildcard search
|
||||
if (storePath.isReadOnlyPseudoPath())
|
||||
{
|
||||
// Get the file state for the folder being searched
|
||||
|
||||
FileState fstate = findPseudoState( storePath, avmCtx);
|
||||
|
||||
if ( fstate != null)
|
||||
{
|
||||
// Get the pseudo file list for the parent directory
|
||||
|
||||
if ( WildCard.containsWildcards( searchPath))
|
||||
{
|
||||
// Create the search context, wildcard filter will take care of secondary filtering of the
|
||||
// folder listing
|
||||
|
||||
WildCard wildCardFilter = new WildCard( paths[1], false);
|
||||
return new PseudoFileListSearchContext( searchList, attrib, wildCardFilter);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Search the pseudo file list for the required file
|
||||
|
||||
PseudoFile pseudoFile = searchList.findFile( paths[1], false);
|
||||
if ( pseudoFile != null)
|
||||
{
|
||||
// Create a search context using the single file details
|
||||
|
||||
PseudoFileList singleList = new PseudoFileList();
|
||||
singleList.addFile( pseudoFile);
|
||||
|
||||
return new PseudoFileListSearchContext( singleList, attrib, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// File not found
|
||||
|
||||
throw new FileNotFoundException( searchPath);
|
||||
PseudoFileList searchList = fstate.getPseudoFileList();
|
||||
|
||||
// Check if this is a single file or wildcard search
|
||||
|
||||
if ( WildCard.containsWildcards( searchPath))
|
||||
{
|
||||
// Create the search context, wildcard filter will take care of secondary filtering of the
|
||||
// folder listing
|
||||
|
||||
WildCard wildCardFilter = new WildCard( paths[1], false);
|
||||
return new PseudoFileListSearchContext( searchList, attrib, wildCardFilter);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Search the pseudo file list for the required file
|
||||
|
||||
PseudoFile pseudoFile = searchList.findFile( paths[1], false);
|
||||
if ( pseudoFile != null)
|
||||
{
|
||||
// Create a search context using the single file details
|
||||
|
||||
PseudoFileList singleList = new PseudoFileList();
|
||||
singleList.addFile( pseudoFile);
|
||||
|
||||
return new PseudoFileListSearchContext( singleList, attrib, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// File not found
|
||||
|
||||
throw new FileNotFoundException( searchPath);
|
||||
}
|
||||
else if ( storePath.isLevel() == AVMPath.LevelId.HeadMetaData || storePath.isLevel() == AVMPath.LevelId.VersionMetaData)
|
||||
{
|
||||
// Return an empty file list for now
|
||||
|
||||
PseudoFileList metaFiles = new PseudoFileList();
|
||||
|
||||
return new PseudoFileListSearchContext( metaFiles, attrib, null);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Check if the path is a wildcard search
|
||||
|
||||
sess.beginTransaction( m_transactionService, true);
|
||||
sess.beginReadTransaction( m_transactionService);
|
||||
SearchContext context = null;
|
||||
|
||||
if ( WildCard.containsWildcards( searchPath))
|
||||
{
|
||||
// Get the file listing for the folder
|
||||
|
||||
AVMNodeDescriptor[] fileList = m_avmService.getDirectoryListingArray( avmCtx.isVersion(), storePath.getAVMPath(), false);
|
||||
AVMNodeDescriptor[] fileList = m_avmService.getDirectoryListingArray( storePath.getVersion(), storePath.getAVMPath(), false);
|
||||
|
||||
// Create the search context
|
||||
|
||||
@@ -1447,7 +1473,7 @@ public class AVMDiskDriver extends AlfrescoDiskDriver implements DiskInterface {
|
||||
|
||||
// Get the single file/folder details
|
||||
|
||||
AVMNodeDescriptor nodeDesc = m_avmService.lookup( avmCtx.isVersion(), storePath.getAVMPath());
|
||||
AVMNodeDescriptor nodeDesc = m_avmService.lookup( storePath.getVersion(), storePath.getAVMPath());
|
||||
|
||||
if ( nodeDesc != null)
|
||||
{
|
||||
@@ -1475,12 +1501,17 @@ public class AVMDiskDriver extends AlfrescoDiskDriver implements DiskInterface {
|
||||
public void truncateFile(SrvSession sess, TreeConnection tree, NetworkFile file, long siz)
|
||||
throws java.io.IOException
|
||||
{
|
||||
// Check if the file is a directory, or only has read access
|
||||
|
||||
if ( file.getGrantedAccess() == NetworkFile.READONLY)
|
||||
throw new AccessDeniedException();
|
||||
|
||||
// If the content channel is not open for the file then start a transaction
|
||||
|
||||
AVMNetworkFile avmFile = (AVMNetworkFile) file;
|
||||
|
||||
if ( avmFile.hasContentChannel() == false)
|
||||
sess.beginTransaction( m_transactionService, true);
|
||||
if ( avmFile.hasContentChannel() == false || avmFile.isWritable() == false)
|
||||
sess.beginWriteTransaction( m_transactionService);
|
||||
|
||||
// Truncate or extend the file
|
||||
|
||||
@@ -1505,9 +1536,9 @@ public class AVMDiskDriver extends AlfrescoDiskDriver implements DiskInterface {
|
||||
long fileoff)
|
||||
throws java.io.IOException
|
||||
{
|
||||
// Check if the file is a directory
|
||||
// Check if the file is a directory, or only has read access
|
||||
|
||||
if ( file.isDirectory())
|
||||
if ( file.isDirectory() || file.getGrantedAccess() == NetworkFile.READONLY)
|
||||
throw new AccessDeniedException();
|
||||
|
||||
// If the content channel is not open for the file, or the channel is not writable, then start a transaction
|
||||
@@ -1515,7 +1546,7 @@ public class AVMDiskDriver extends AlfrescoDiskDriver implements DiskInterface {
|
||||
AVMNetworkFile avmFile = (AVMNetworkFile) file;
|
||||
|
||||
if ( avmFile.hasContentChannel() == false || avmFile.isWritable() == false)
|
||||
sess.beginTransaction( m_transactionService, true);
|
||||
sess.beginWriteTransaction( m_transactionService);
|
||||
|
||||
// Write the data to the file
|
||||
|
||||
@@ -1558,69 +1589,165 @@ public class AVMDiskDriver extends AlfrescoDiskDriver implements DiskInterface {
|
||||
private final PseudoFile findPseudoFolder( AVMPath avmPath, AVMContext avmCtx)
|
||||
{
|
||||
// Check if the path is to a store pseudo folder
|
||||
|
||||
if ( avmPath.isRootPath())
|
||||
return null;
|
||||
|
||||
// Get the file state for the parent of the required folder
|
||||
|
||||
FileState fstate = null;
|
||||
StringBuilder str = null;
|
||||
PseudoFile psFile = null;
|
||||
|
||||
if ( avmPath.hasVersion() == false)
|
||||
{
|
||||
// Check for the path within the store layer
|
||||
|
||||
FileState fstate = avmCtx.getStateTable().findFileState( FileName.DOS_SEPERATOR_STR);
|
||||
PseudoFileList pseudoList = fstate.getPseudoFileList();
|
||||
|
||||
psFile = pseudoList.findFile( avmPath.getStoreName(), false);
|
||||
}
|
||||
else if ( avmPath.hasRelativePath() == false)
|
||||
{
|
||||
// Build the path to the parent store folder
|
||||
|
||||
StringBuilder storeStr = new StringBuilder();
|
||||
|
||||
storeStr.append( FileName.DOS_SEPERATOR);
|
||||
storeStr.append( avmPath.getStoreName());
|
||||
|
||||
// Search for the file state for the store pseudo folder
|
||||
|
||||
FileState storeState = avmCtx.getStateTable().findFileState( storeStr.toString());
|
||||
if ( storeState != null)
|
||||
{
|
||||
// Search the store pseudo folder file list for the required version
|
||||
|
||||
psFile = storeState.getPseudoFileList().findFile( avmPath.getVersionString(), false);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Get the list of AVM store versions
|
||||
switch ( avmPath.isLevel())
|
||||
{
|
||||
// Store root folder
|
||||
|
||||
case StoreRoot:
|
||||
|
||||
// Get the root folder file state
|
||||
|
||||
fstate = avmCtx.getStateTable().findFileState( FileName.DOS_SEPERATOR_STR);
|
||||
if ( fstate != null)
|
||||
psFile = fstate.getPseudoFileList().findFile( avmPath.getStoreName(), false);
|
||||
break;
|
||||
|
||||
// Versions root or Head folder
|
||||
|
||||
case VersionRoot:
|
||||
case Head:
|
||||
|
||||
// Create a path to the parent store
|
||||
|
||||
str = new StringBuilder();
|
||||
|
||||
str.append( FileName.DOS_SEPERATOR);
|
||||
str.append( avmPath.getStoreName());
|
||||
|
||||
// Find/create the file state for the store
|
||||
|
||||
AVMPath storePath = new AVMPath( str.toString());
|
||||
fstate = findPseudoState( storePath, avmCtx);
|
||||
|
||||
// Find the version root or head pseudo folder
|
||||
|
||||
if ( fstate != null)
|
||||
{
|
||||
if ( avmPath.isLevel() == AVMPath.LevelId.Head)
|
||||
psFile = fstate.getPseudoFileList().findFile( AVMPath.VersionNameHead, true);
|
||||
else
|
||||
psFile = fstate.getPseudoFileList().findFile( AVMPath.VersionsFolder, true);
|
||||
}
|
||||
break;
|
||||
|
||||
// Version folder
|
||||
|
||||
case Version:
|
||||
|
||||
try
|
||||
{
|
||||
// Get the list of versions for the store
|
||||
|
||||
List<VersionDescriptor> verList = m_avmService.getAVMStoreVersions( avmPath.getStoreName());
|
||||
|
||||
// Create a file state for the store path
|
||||
|
||||
storeState = avmCtx.getStateTable().findFileState( storeStr.toString(), true, true);
|
||||
|
||||
// Add pseudo files for the versions to the store state
|
||||
|
||||
for ( VersionDescriptor verDesc : verList)
|
||||
{
|
||||
// Add the version pseudo folder
|
||||
|
||||
storeState.addPseudoFile( new VersionPseudoFile ( avmPath.getVersionString(), verDesc));
|
||||
}
|
||||
|
||||
// Search for the required version pseudo folder
|
||||
|
||||
psFile = storeState.getPseudoFileList().findFile( avmPath.getVersionString(), false);
|
||||
}
|
||||
catch ( AVMNotFoundException ex)
|
||||
{
|
||||
// Invalid store name
|
||||
}
|
||||
}
|
||||
}
|
||||
// Create a path to the versions folder
|
||||
|
||||
str = new StringBuilder();
|
||||
|
||||
str.append( FileName.DOS_SEPERATOR);
|
||||
str.append( avmPath.getStoreName());
|
||||
str.append( FileName.DOS_SEPERATOR);
|
||||
str.append( AVMPath.VersionsFolder);
|
||||
|
||||
// Find/create the file state for the store
|
||||
|
||||
AVMPath verrootPath = new AVMPath( str.toString());
|
||||
fstate = findPseudoState( verrootPath, avmCtx);
|
||||
|
||||
// Find the version pseudo file
|
||||
|
||||
if ( fstate != null)
|
||||
{
|
||||
// Build the version folder name string
|
||||
|
||||
str.setLength( 0);
|
||||
|
||||
str.append( AVMPath.VersionFolderPrefix);
|
||||
str.append( avmPath.getVersion());
|
||||
|
||||
// find the version folder pseduo file
|
||||
|
||||
psFile = fstate.getPseudoFileList().findFile( str.toString(), true);
|
||||
}
|
||||
break;
|
||||
|
||||
// Head data or metadata folder
|
||||
|
||||
case HeadData:
|
||||
case HeadMetaData:
|
||||
|
||||
// Create a path to the head folder
|
||||
|
||||
str = new StringBuilder();
|
||||
|
||||
str.append( FileName.DOS_SEPERATOR);
|
||||
str.append( avmPath.getStoreName());
|
||||
str.append( FileName.DOS_SEPERATOR);
|
||||
str.append( AVMPath.VersionNameHead);
|
||||
|
||||
// Find/create the file state for the store
|
||||
|
||||
AVMPath headPath = new AVMPath( str.toString());
|
||||
fstate = findPseudoState( headPath, avmCtx);
|
||||
|
||||
// Find the data or metadata pseudo folder
|
||||
|
||||
if ( fstate != null)
|
||||
{
|
||||
// Find the pseudo folder
|
||||
|
||||
if ( avmPath.isLevel() == AVMPath.LevelId.HeadData)
|
||||
{
|
||||
psFile = fstate.getPseudoFileList().findFile( AVMPath.DataFolder, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
psFile = fstate.getPseudoFileList().findFile( AVMPath.MetaDataFolder, true);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
// Version data or metadata folder
|
||||
|
||||
case VersionData:
|
||||
case VersionMetaData:
|
||||
|
||||
// Create a path to the version folder
|
||||
|
||||
str = new StringBuilder();
|
||||
|
||||
str.append( FileName.DOS_SEPERATOR);
|
||||
str.append( avmPath.getStoreName());
|
||||
str.append( FileName.DOS_SEPERATOR);
|
||||
str.append( AVMPath.VersionFolderPrefix);
|
||||
str.append( avmPath.getVersion());
|
||||
|
||||
// Find/create the file state for the store
|
||||
|
||||
AVMPath verPath = new AVMPath( str.toString());
|
||||
fstate = findPseudoState( verPath, avmCtx);
|
||||
|
||||
// Find the data or metadata pseudo folder
|
||||
|
||||
if ( fstate != null)
|
||||
{
|
||||
// Find the pseudo folder
|
||||
|
||||
if ( avmPath.isLevel() == AVMPath.LevelId.VersionData)
|
||||
{
|
||||
psFile = fstate.getPseudoFileList().findFile( AVMPath.DataFolder, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
psFile = fstate.getPseudoFileList().findFile( AVMPath.MetaDataFolder, true);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
// Return the pseudo file, or null if not found
|
||||
|
||||
@@ -1636,72 +1763,148 @@ public class AVMDiskDriver extends AlfrescoDiskDriver implements DiskInterface {
|
||||
*/
|
||||
private final FileState findPseudoState( AVMPath avmPath, AVMContext avmCtx)
|
||||
{
|
||||
// Make sure the is to a pseudo file/folder
|
||||
|
||||
if ( avmPath.isPseudoPath() == false)
|
||||
return null;
|
||||
|
||||
// Check if the path is to a store pseudo folder
|
||||
|
||||
FileState fstate = null;
|
||||
|
||||
if ( avmPath.isRootPath())
|
||||
{
|
||||
// Get the root path file state
|
||||
|
||||
fstate = avmCtx.getStateTable().findFileState( FileName.DOS_SEPERATOR_STR);
|
||||
}
|
||||
else if ( avmPath.hasVersion() == false)
|
||||
{
|
||||
// Build the path to the parent store folder
|
||||
|
||||
StringBuilder storeStr = new StringBuilder();
|
||||
|
||||
storeStr.append( FileName.DOS_SEPERATOR);
|
||||
storeStr.append( avmPath.getStoreName());
|
||||
|
||||
// Search for the file state for the store pseudo folder
|
||||
|
||||
fstate = avmCtx.getStateTable().findFileState( storeStr.toString());
|
||||
|
||||
if ( fstate == null)
|
||||
{
|
||||
// Get the list of AVM store versions
|
||||
StringBuilder str = null;
|
||||
|
||||
try
|
||||
switch ( avmPath.isLevel())
|
||||
{
|
||||
// Root of the hieararchy
|
||||
|
||||
case Root:
|
||||
|
||||
// Get the root path file state
|
||||
|
||||
fstate = avmCtx.getStateTable().findFileState( FileName.DOS_SEPERATOR_STR);
|
||||
break;
|
||||
|
||||
// Store folder
|
||||
|
||||
case StoreRoot:
|
||||
|
||||
// Build the path to the parent store folder
|
||||
|
||||
str = new StringBuilder();
|
||||
|
||||
str.append( FileName.DOS_SEPERATOR);
|
||||
str.append( avmPath.getStoreName());
|
||||
|
||||
// Search for the file state for the store pseudo folder
|
||||
|
||||
fstate = avmCtx.getStateTable().findFileState( str.toString());
|
||||
|
||||
if ( fstate == null)
|
||||
{
|
||||
// Get the list of versions for the store
|
||||
|
||||
List<VersionDescriptor> verList = m_avmService.getAVMStoreVersions( avmPath.getStoreName());
|
||||
|
||||
// Create a file state for the store path
|
||||
|
||||
fstate = avmCtx.getStateTable().findFileState( storeStr.toString(), true, true);
|
||||
fstate = avmCtx.getStateTable().findFileState( str.toString(), true, true);
|
||||
|
||||
// Add a pseudo file for the head version
|
||||
|
||||
fstate.addPseudoFile( new VersionPseudoFile( AVMPath.VersionNameHead));
|
||||
|
||||
// Add pseudo files for the versions to the store state
|
||||
// Add a pseudo file for the version root folder
|
||||
|
||||
fstate.addPseudoFile( new DummyFolderPseudoFile( AVMPath.VersionsFolder));
|
||||
}
|
||||
break;
|
||||
|
||||
if ( verList.size() > 0)
|
||||
// Head folder
|
||||
|
||||
case Head:
|
||||
|
||||
// Build the path to the store head version folder
|
||||
|
||||
str = new StringBuilder();
|
||||
|
||||
str.append( FileName.DOS_SEPERATOR);
|
||||
str.append( avmPath.getStoreName());
|
||||
str.append( FileName.DOS_SEPERATOR);
|
||||
str.append( AVMPath.VersionNameHead);
|
||||
|
||||
// Search for the file state for the store head version pseudo folder
|
||||
|
||||
fstate = avmCtx.getStateTable().findFileState( str.toString());
|
||||
|
||||
if ( fstate == null)
|
||||
{
|
||||
// Create a file state for the store head folder path
|
||||
|
||||
fstate = avmCtx.getStateTable().findFileState( str.toString(), true, true);
|
||||
|
||||
// Add a pseudo file for the data pseudo folder
|
||||
|
||||
fstate.addPseudoFile( new DummyFolderPseudoFile( AVMPath.DataFolder));
|
||||
|
||||
// Add a pseudo file for the metadata pseudo folder
|
||||
|
||||
fstate.addPseudoFile( new DummyFolderPseudoFile( AVMPath.MetaDataFolder));
|
||||
}
|
||||
break;
|
||||
|
||||
// Version root folder
|
||||
|
||||
case VersionRoot:
|
||||
|
||||
// Get the list of AVM store versions
|
||||
|
||||
try
|
||||
{
|
||||
// Build the path to the parent store folder
|
||||
|
||||
str = new StringBuilder();
|
||||
|
||||
str.append( FileName.DOS_SEPERATOR);
|
||||
str.append( avmPath.getStoreName());
|
||||
str.append( FileName.DOS_SEPERATOR);
|
||||
str.append( AVMPath.VersionsFolder);
|
||||
|
||||
// Create a file state for the store path
|
||||
|
||||
fstate = avmCtx.getStateTable().findFileState( str.toString(), true, true);
|
||||
|
||||
// Add pseudo folders if the list is empty
|
||||
|
||||
if ( fstate.hasPseudoFiles() == false)
|
||||
{
|
||||
StringBuilder verStr = new StringBuilder();
|
||||
// Build the version folder name for the head version
|
||||
|
||||
for ( VersionDescriptor verDesc : verList)
|
||||
StringBuilder verStr = new StringBuilder( AVMPath.VersionFolderPrefix);
|
||||
verStr.append( "-1");
|
||||
|
||||
// Add a pseudo file for the head version
|
||||
|
||||
fstate.addPseudoFile( new VersionPseudoFile( verStr.toString()));
|
||||
|
||||
// Get the list of versions for the store
|
||||
|
||||
List<VersionDescriptor> verList = m_avmService.getAVMStoreVersions( avmPath.getStoreName());
|
||||
|
||||
// Add pseudo files for the versions to the store state
|
||||
|
||||
if ( verList.size() > 0)
|
||||
{
|
||||
// Generate the version string
|
||||
|
||||
String verName = null;
|
||||
|
||||
if ( verDesc.getVersionID() == -1)
|
||||
verName = AVMPath.VersionNameHead;
|
||||
else
|
||||
for ( VersionDescriptor verDesc : verList)
|
||||
{
|
||||
verStr.setLength( 0);
|
||||
// Generate the version string
|
||||
|
||||
String verName = null;
|
||||
|
||||
verStr.setLength( AVMPath.VersionFolderPrefix.length());
|
||||
verStr.append( verDesc.getVersionID());
|
||||
|
||||
verName = verStr.toString();
|
||||
|
||||
// Add the version pseudo folder
|
||||
|
||||
fstate.addPseudoFile( new VersionPseudoFile ( verName, verDesc));
|
||||
}
|
||||
|
||||
// Add the version pseudo folder
|
||||
|
||||
fstate.addPseudoFile( new VersionPseudoFile ( verName, verDesc));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1709,11 +1912,44 @@ public class AVMDiskDriver extends AlfrescoDiskDriver implements DiskInterface {
|
||||
{
|
||||
// Invalid store name
|
||||
}
|
||||
break;
|
||||
|
||||
// Version folder
|
||||
|
||||
}
|
||||
case Version:
|
||||
|
||||
// Build the path to the store version folder
|
||||
|
||||
str = new StringBuilder();
|
||||
|
||||
str.append( FileName.DOS_SEPERATOR);
|
||||
str.append( avmPath.getStoreName());
|
||||
str.append( FileName.DOS_SEPERATOR);
|
||||
str.append( AVMPath.VersionFolderPrefix);
|
||||
str.append( avmPath.getVersion());
|
||||
|
||||
// Search for the file state for the version pseudo folder
|
||||
|
||||
fstate = avmCtx.getStateTable().findFileState( str.toString());
|
||||
|
||||
if ( fstate == null)
|
||||
{
|
||||
// Create a file state for the version folder path
|
||||
|
||||
fstate = avmCtx.getStateTable().findFileState( str.toString(), true, true);
|
||||
|
||||
// Add a pseudo file for the data pseudo folder
|
||||
|
||||
fstate.addPseudoFile( new DummyFolderPseudoFile( AVMPath.DataFolder));
|
||||
|
||||
// Add a pseudo file for the metadata pseudo folder
|
||||
|
||||
fstate.addPseudoFile( new DummyFolderPseudoFile( AVMPath.MetaDataFolder));
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
// Return the file state
|
||||
|
||||
// Return the file state
|
||||
|
||||
return fstate;
|
||||
}
|
||||
|
@@ -36,13 +36,34 @@ public class AVMPath {
|
||||
|
||||
// Version id string for the head version
|
||||
|
||||
public static final String VersionNameHead = "Head";
|
||||
public static final String VersionNameHead = "HEAD";
|
||||
|
||||
// Folder name for the versions folder
|
||||
|
||||
public static final String VersionsFolder = "VERSION";
|
||||
|
||||
// Head and version sub-folders
|
||||
|
||||
public static final String DataFolder = "DATA";
|
||||
public static final String MetaDataFolder = "METADATA";
|
||||
|
||||
// Version folder prefix
|
||||
|
||||
public static final String VersionFolderPrefix = "v";
|
||||
|
||||
// AVM path seperator
|
||||
|
||||
public static final char AVM_SEPERATOR = '/';
|
||||
public static final String AVM_SEPERATOR_STR = "/";
|
||||
|
||||
// Level identifiers
|
||||
|
||||
public enum LevelId { Invalid, Root, StoreRoot, Head, HeadData, HeadMetaData, VersionRoot, Version, VersionData, VersionMetaData, StorePath };
|
||||
|
||||
// Level identifier for this path
|
||||
|
||||
private LevelId m_levelId = LevelId.Invalid;
|
||||
|
||||
// Store name
|
||||
|
||||
private String m_storeName;
|
||||
@@ -95,6 +116,16 @@ public class AVMPath {
|
||||
|
||||
parsePath( storeName, version, path);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the level id for the path
|
||||
*
|
||||
* @return LevelId
|
||||
*/
|
||||
public LevelId isLevel()
|
||||
{
|
||||
return m_levelId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the store name
|
||||
@@ -175,7 +206,7 @@ public class AVMPath {
|
||||
*/
|
||||
public final boolean isValid()
|
||||
{
|
||||
return m_storeName == null && m_path == null ? false : true;
|
||||
return m_levelId == LevelId.Invalid ? false : true;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -185,7 +216,20 @@ public class AVMPath {
|
||||
*/
|
||||
public final boolean isPseudoPath()
|
||||
{
|
||||
return m_version == InvalidVersionId || m_path == null ? true : false;
|
||||
return m_levelId == LevelId.Invalid || m_levelId == LevelId.StorePath ? false : true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if hte path is a read-only part of the pseudo folder tree
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public final boolean isReadOnlyPseudoPath()
|
||||
{
|
||||
if ( isLevel() == LevelId.Root || isLevel() == LevelId.StoreRoot || isLevel() == LevelId.VersionRoot ||
|
||||
isLevel() == LevelId.Head || isLevel() == LevelId.Version)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -195,9 +239,7 @@ public class AVMPath {
|
||||
*/
|
||||
public final boolean isRootPath()
|
||||
{
|
||||
if ( m_path != null && m_path.equals( FileName.DOS_SEPERATOR_STR))
|
||||
return true;
|
||||
return false;
|
||||
return m_levelId == LevelId.Root ? true : false;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -221,85 +263,179 @@ public class AVMPath {
|
||||
if ( paths == null || paths.length == 0)
|
||||
{
|
||||
m_path = FileName.DOS_SEPERATOR_STR;
|
||||
m_levelId = LevelId.Root;
|
||||
return;
|
||||
}
|
||||
|
||||
// Set the store name
|
||||
|
||||
m_storeName = paths[0];
|
||||
m_levelId = LevelId.StoreRoot;
|
||||
|
||||
if ( paths.length > 1)
|
||||
{
|
||||
// Validate the version id
|
||||
// Validate the next element, should be either the HEAD or VERSIONS folder
|
||||
|
||||
String verStr = paths[1];
|
||||
if ( verStr.equalsIgnoreCase( VersionNameHead))
|
||||
String levelStr = paths[1];
|
||||
|
||||
if ( levelStr.equalsIgnoreCase( VersionNameHead))
|
||||
{
|
||||
m_version = -1;
|
||||
m_levelId = LevelId.Head;
|
||||
}
|
||||
else if ( levelStr.equalsIgnoreCase( VersionsFolder))
|
||||
{
|
||||
m_levelId = LevelId.VersionRoot;
|
||||
}
|
||||
else
|
||||
{
|
||||
try
|
||||
{
|
||||
// Parse the version id
|
||||
|
||||
m_version = Integer.parseInt( verStr);
|
||||
|
||||
// Validate the version id
|
||||
|
||||
if ( m_version < 0)
|
||||
{
|
||||
// Invalid version id
|
||||
|
||||
m_storeName = null;
|
||||
return;
|
||||
}
|
||||
}
|
||||
catch ( NumberFormatException ex)
|
||||
{
|
||||
m_storeName = null;
|
||||
return;
|
||||
}
|
||||
// Invalid folder at the current level
|
||||
|
||||
m_levelId = LevelId.Invalid;
|
||||
return;
|
||||
}
|
||||
|
||||
// If there additional path elements build the share and AVM relative paths
|
||||
// Check the next level, if available
|
||||
|
||||
if ( paths.length > 2)
|
||||
{
|
||||
// Build the share relative path
|
||||
// If the previous level is the versions root then the next level should be a
|
||||
// version id folder
|
||||
|
||||
String folderName = paths[2];
|
||||
int pathIdx = 3;
|
||||
|
||||
StringBuilder pathStr = new StringBuilder();
|
||||
|
||||
for ( int i = 2; i < paths.length; i++)
|
||||
if ( isLevel() == LevelId.VersionRoot)
|
||||
{
|
||||
pathStr.append( FileName.DOS_SEPERATOR);
|
||||
pathStr.append( paths[i]);
|
||||
// Check that the folder name starts with the version folder prefix
|
||||
|
||||
if ( folderName != null && folderName.startsWith( VersionFolderPrefix) &&
|
||||
folderName.length() > VersionFolderPrefix.length())
|
||||
{
|
||||
try
|
||||
{
|
||||
// Parse the version id
|
||||
|
||||
m_version = Integer.parseInt( folderName.substring( VersionFolderPrefix.length()));
|
||||
m_levelId = LevelId.Version;
|
||||
|
||||
// Validate the version id
|
||||
|
||||
if ( m_version < -1)
|
||||
{
|
||||
// Invalid version id
|
||||
|
||||
m_levelId = LevelId.Invalid;
|
||||
return;
|
||||
}
|
||||
}
|
||||
catch ( NumberFormatException ex)
|
||||
{
|
||||
m_levelId = LevelId.Invalid;
|
||||
return;
|
||||
}
|
||||
|
||||
// Check for the next level
|
||||
|
||||
if ( paths.length > 3)
|
||||
{
|
||||
// Get the next level name
|
||||
|
||||
folderName = paths[3];
|
||||
pathIdx++;
|
||||
|
||||
// Check for the data folder
|
||||
|
||||
if ( folderName.equalsIgnoreCase( DataFolder))
|
||||
{
|
||||
m_levelId = LevelId.VersionData;
|
||||
|
||||
// Set the path to the root of the store
|
||||
|
||||
m_path = FileName.DOS_SEPERATOR_STR;
|
||||
}
|
||||
else if ( folderName.equalsIgnoreCase( MetaDataFolder))
|
||||
{
|
||||
m_levelId = LevelId.VersionMetaData;
|
||||
|
||||
// Set the path to the root of the metadata
|
||||
|
||||
m_path = FileName.DOS_SEPERATOR_STR;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_levelId = LevelId.Invalid;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_levelId = LevelId.Invalid;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
m_path = pathStr.toString();
|
||||
// If the previous level is head the next level should be the data or metadata folder
|
||||
|
||||
else if ( isLevel() == LevelId.Head)
|
||||
{
|
||||
// Check for the data folder
|
||||
|
||||
if ( folderName.equalsIgnoreCase( DataFolder))
|
||||
{
|
||||
m_levelId = LevelId.HeadData;
|
||||
|
||||
// Set the path to the root of the store
|
||||
|
||||
m_path = FileName.DOS_SEPERATOR_STR;
|
||||
}
|
||||
else if ( folderName.equalsIgnoreCase( MetaDataFolder))
|
||||
{
|
||||
m_levelId = LevelId.HeadMetaData;
|
||||
|
||||
// Set the path to the root of the metadata
|
||||
|
||||
m_path = FileName.DOS_SEPERATOR_STR;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_levelId = LevelId.Invalid;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// If there are remaining paths then build a relative path
|
||||
|
||||
if ( paths.length > pathIdx)
|
||||
{
|
||||
StringBuilder pathStr = new StringBuilder();
|
||||
|
||||
for ( int i = pathIdx; i < paths.length; i++)
|
||||
{
|
||||
pathStr.append( FileName.DOS_SEPERATOR);
|
||||
pathStr.append( paths[i]);
|
||||
}
|
||||
|
||||
m_path = pathStr.toString();
|
||||
|
||||
// Set the level to indicate a store relative path
|
||||
|
||||
m_levelId = LevelId.StorePath;
|
||||
}
|
||||
|
||||
// Build the AVM path, in <store>:/<path> format
|
||||
|
||||
pathStr.setLength( 0);
|
||||
if ( m_path != null)
|
||||
{
|
||||
StringBuilder pathStr = new StringBuilder();
|
||||
|
||||
pathStr.append( m_storeName);
|
||||
pathStr.append( ":");
|
||||
pathStr.append( m_path.replace( FileName.DOS_SEPERATOR, AVM_SEPERATOR));
|
||||
|
||||
m_avmPath = pathStr.toString();
|
||||
}
|
||||
else
|
||||
{
|
||||
// Share relative path is the root of the share
|
||||
|
||||
m_path = FileName.DOS_SEPERATOR_STR;
|
||||
|
||||
// Build the AVM path
|
||||
|
||||
StringBuilder pathStr = new StringBuilder();
|
||||
|
||||
pathStr.append( m_storeName);
|
||||
pathStr.append( ":/");
|
||||
|
||||
m_avmPath = pathStr.toString();
|
||||
pathStr.append( m_storeName);
|
||||
pathStr.append( ":");
|
||||
pathStr.append( m_path.replace( FileName.DOS_SEPERATOR, AVM_SEPERATOR));
|
||||
|
||||
m_avmPath = pathStr.toString();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -314,6 +450,8 @@ public class AVMPath {
|
||||
public final void parsePath( String storeName, int version, String path)
|
||||
{
|
||||
// Clear current settings
|
||||
|
||||
m_levelId = LevelId.Invalid;
|
||||
|
||||
m_storeName = null;
|
||||
m_version = InvalidVersionId;
|
||||
@@ -354,6 +492,10 @@ public class AVMPath {
|
||||
}
|
||||
|
||||
m_avmPath = avmPath.toString();
|
||||
|
||||
// Indicate that the path is to a store relative path
|
||||
|
||||
m_levelId = LevelId.StorePath;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -364,20 +506,77 @@ public class AVMPath {
|
||||
public String toString()
|
||||
{
|
||||
StringBuilder str = new StringBuilder();
|
||||
|
||||
str.append("[");
|
||||
str.append(getStoreName());
|
||||
str.append(",");
|
||||
|
||||
if ( hasVersion())
|
||||
str.append(getVersion());
|
||||
else
|
||||
str.append("NoVersion");
|
||||
|
||||
str.append(",");
|
||||
str.append(getRelativePath());
|
||||
str.append(":");
|
||||
str.append(getAVMPath());
|
||||
|
||||
switch ( m_levelId)
|
||||
{
|
||||
case Invalid:
|
||||
str.append("[Invalid");
|
||||
break;
|
||||
case Root:
|
||||
str.append("[Root");
|
||||
break;
|
||||
case StoreRoot:
|
||||
str.append("[StoresRoot");
|
||||
break;
|
||||
case Head:
|
||||
str.append("[");
|
||||
str.append(getStoreName());
|
||||
str.append(":HEAD");
|
||||
break;
|
||||
case HeadData:
|
||||
str.append("[");
|
||||
str.append(getStoreName());
|
||||
str.append(":HEAD\\");
|
||||
str.append( DataFolder);
|
||||
break;
|
||||
case HeadMetaData:
|
||||
str.append("[");
|
||||
str.append(getStoreName());
|
||||
str.append(":HEAD\\");
|
||||
str.append( MetaDataFolder);
|
||||
break;
|
||||
case VersionRoot:
|
||||
str.append("[");
|
||||
str.append(getStoreName());
|
||||
str.append(":Versions");
|
||||
break;
|
||||
case Version:
|
||||
str.append("[");
|
||||
str.append(getStoreName());
|
||||
str.append(":");
|
||||
str.append(VersionFolderPrefix);
|
||||
str.append(getVersion());
|
||||
break;
|
||||
case VersionData:
|
||||
str.append("[");
|
||||
str.append(getStoreName());
|
||||
str.append(":");
|
||||
str.append(VersionFolderPrefix);
|
||||
str.append(getVersion());
|
||||
str.append("\\");
|
||||
str.append( DataFolder);
|
||||
break;
|
||||
case VersionMetaData:
|
||||
str.append("[");
|
||||
str.append(getStoreName());
|
||||
str.append(":");
|
||||
str.append(VersionFolderPrefix);
|
||||
str.append(getVersion());
|
||||
str.append("\\");
|
||||
str.append( MetaDataFolder);
|
||||
break;
|
||||
case StorePath:
|
||||
str.append("[");
|
||||
str.append(getStoreName());
|
||||
str.append(":");
|
||||
str.append(VersionFolderPrefix);
|
||||
str.append(getVersion());
|
||||
str.append(",");
|
||||
str.append(getRelativePath());
|
||||
str.append(":");
|
||||
str.append(getAVMPath());
|
||||
break;
|
||||
}
|
||||
str.append("]");
|
||||
|
||||
return str.toString();
|
||||
|
@@ -237,7 +237,7 @@ public class AVMShareMapper implements ShareMapper {
|
||||
AVMDiskDriver avmDrv = (AVMDiskDriver) m_config.getAvmDiskInterface();
|
||||
AVMService avmService = avmDrv.getAvmService();
|
||||
|
||||
sess.beginTransaction( avmDrv.getTransactionService(), true);
|
||||
sess.beginReadTransaction( avmDrv.getTransactionService());
|
||||
|
||||
try
|
||||
{
|
||||
|
@@ -0,0 +1,79 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2006 Alfresco, Inc.
|
||||
*
|
||||
* Licensed under the Mozilla Public License version 1.1
|
||||
* with a permitted attribution clause. You may obtain a
|
||||
* copy of the License at
|
||||
*
|
||||
* http://www.alfresco.org/legal/license.txt
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
|
||||
* either express or implied. See the License for the specific
|
||||
* language governing permissions and limitations under the
|
||||
* License.
|
||||
*/
|
||||
package org.alfresco.filesys.avm;
|
||||
|
||||
import org.alfresco.filesys.server.filesys.FileAttribute;
|
||||
import org.alfresco.filesys.server.filesys.FileInfo;
|
||||
import org.alfresco.filesys.server.filesys.FileName;
|
||||
import org.alfresco.filesys.server.filesys.NetworkFile;
|
||||
import org.alfresco.filesys.server.pseudo.PseudoFile;
|
||||
import org.alfresco.filesys.server.pseudo.PseudoFolderNetworkFile;
|
||||
|
||||
/**
|
||||
* Dummy Folder Pseudo File Class
|
||||
*
|
||||
* <p>Represents a dummy folder within the virtualization filesystem view.
|
||||
*
|
||||
* @author gkspencer
|
||||
*/
|
||||
public class DummyFolderPseudoFile extends PseudoFile {
|
||||
|
||||
/**
|
||||
* Class constructor
|
||||
*
|
||||
* @param fname String
|
||||
*/
|
||||
public DummyFolderPseudoFile( String fname)
|
||||
{
|
||||
super( fname, FileAttribute.Directory + FileAttribute.ReadOnly);
|
||||
|
||||
// Create static file information from the folder details
|
||||
|
||||
FileInfo fInfo = new FileInfo( fname, 0L, FileAttribute.Directory + FileAttribute.ReadOnly);
|
||||
fInfo.setCreationDateTime( System.currentTimeMillis());
|
||||
|
||||
setFileInfo( fInfo);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a network file for reading/writing the pseudo file
|
||||
*
|
||||
* @param netPath String
|
||||
* @return NetworkFile
|
||||
*/
|
||||
@Override
|
||||
public NetworkFile getFile(String netPath) {
|
||||
|
||||
// Split the path to get the name
|
||||
|
||||
String[] paths = FileName.splitPath( netPath);
|
||||
|
||||
// Create a network file for the folder
|
||||
|
||||
return new PseudoFolderNetworkFile( paths[1], netPath);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the file information for the pseudo file
|
||||
*
|
||||
* @return FileInfo
|
||||
*/
|
||||
@Override
|
||||
public FileInfo getFileInfo() {
|
||||
return getInfo();
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user