mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-24 17:32:48 +00:00
Added code to regenerate root folder file state if it expires. Fix for AR-1140.
Some fixes after merge. git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@4651 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -279,28 +279,6 @@ public class AVMDiskDriver extends AlfrescoDiskDriver implements DiskInterface {
|
||||
|
||||
context.enableStateTable( true, getStateReaper());
|
||||
|
||||
// Get a list of the available AVM stores
|
||||
|
||||
List<AVMStoreDescriptor> storeList = m_avmService.getStores();
|
||||
|
||||
if ( storeList != null && storeList.size() > 0)
|
||||
{
|
||||
// Create a file state for the root folder that does not expire, and add pseudo files
|
||||
// for the stores
|
||||
|
||||
FileState rootState = context.getStateTable().findFileState( FileName.DOS_SEPERATOR_STR, true, true);
|
||||
rootState.setExpiryTime( FileState.NoTimeout);
|
||||
|
||||
// Add pseudo files for the stores
|
||||
|
||||
for ( AVMStoreDescriptor storeDesc : storeList)
|
||||
{
|
||||
// Add a pseudo file for the current store
|
||||
|
||||
rootState.addPseudoFile( new StorePseudoFile( storeDesc));
|
||||
}
|
||||
}
|
||||
|
||||
// Plug the virtualization view context into the various store/version call back listeners
|
||||
// so that store/version pseudo folders can be kept in sync with AVM
|
||||
|
||||
@@ -756,6 +734,8 @@ public class AVMDiskDriver extends AlfrescoDiskDriver implements DiskInterface {
|
||||
netFile.setGrantedAccess(NetworkFile.READWRITE);
|
||||
netFile.setFullName(params.getPath());
|
||||
|
||||
netFile.setFileId( fileStorePath.generateFileId());
|
||||
|
||||
// Set the mime-type for the new file
|
||||
|
||||
netFile.setMimeType( m_mimetypeService.guessMimetype( paths[1]));
|
||||
@@ -1067,7 +1047,7 @@ public class AVMDiskDriver extends AlfrescoDiskDriver implements DiskInterface {
|
||||
|
||||
try
|
||||
{
|
||||
AVMNodeDescriptor nodeDesc = m_avmService.lookup( ctx.isVersion(), storePath.getAVMPath());
|
||||
AVMNodeDescriptor nodeDesc = m_avmService.lookup( storePath.getVersion(), storePath.getAVMPath());
|
||||
|
||||
if ( nodeDesc != null)
|
||||
{
|
||||
@@ -1107,7 +1087,11 @@ public class AVMDiskDriver extends AlfrescoDiskDriver implements DiskInterface {
|
||||
attr += FileAttribute.ReadOnly;
|
||||
|
||||
info.setFileAttributes( attr);
|
||||
|
||||
|
||||
// Set the file id
|
||||
|
||||
info.setFileId( storePath.generateFileId());
|
||||
|
||||
// DEBUG
|
||||
|
||||
if ( logger.isDebugEnabled())
|
||||
@@ -1226,6 +1210,7 @@ public class AVMDiskDriver extends AlfrescoDiskDriver implements DiskInterface {
|
||||
netFile.setGrantedAccess(NetworkFile.READWRITE);
|
||||
|
||||
netFile.setFullName(params.getPath());
|
||||
netFile.setFileId( storePath.generateFileId());
|
||||
|
||||
|
||||
// Set the mime-type for the new file
|
||||
@@ -1462,6 +1447,11 @@ public class AVMDiskDriver extends AlfrescoDiskDriver implements DiskInterface {
|
||||
|
||||
if ( WildCard.containsWildcards( searchPath))
|
||||
{
|
||||
// Check if the pseudo file list is valid
|
||||
|
||||
if ( searchList == null)
|
||||
searchList = new PseudoFileList();
|
||||
|
||||
// Create the search context, wildcard filter will take care of secondary filtering of the
|
||||
// folder listing
|
||||
|
||||
@@ -1523,7 +1513,7 @@ public class AVMDiskDriver extends AlfrescoDiskDriver implements DiskInterface {
|
||||
// folder listing
|
||||
|
||||
WildCard wildCardFilter = new WildCard( paths[1], false);
|
||||
context = new AVMSearchContext( fileList, attrib, wildCardFilter);
|
||||
context = new AVMSearchContext( fileList, attrib, wildCardFilter, storePath.getRelativePath());
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -1540,7 +1530,7 @@ public class AVMDiskDriver extends AlfrescoDiskDriver implements DiskInterface {
|
||||
{
|
||||
// Create the search context for the single file/folder
|
||||
|
||||
context = new AVMSingleFileSearchContext( nodeDesc);
|
||||
context = new AVMSingleFileSearchContext( nodeDesc, storePath.getRelativePath());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1669,7 +1659,7 @@ public class AVMDiskDriver extends AlfrescoDiskDriver implements DiskInterface {
|
||||
// Get the root folder file state
|
||||
|
||||
fstate = avmCtx.getStateTable().findFileState( FileName.DOS_SEPERATOR_STR);
|
||||
if ( fstate != null)
|
||||
if ( fstate != null && fstate.hasPseudoFiles())
|
||||
psFile = fstate.getPseudoFileList().findFile( avmPath.getStoreName(), false);
|
||||
break;
|
||||
|
||||
@@ -1843,6 +1833,32 @@ public class AVMDiskDriver extends AlfrescoDiskDriver implements DiskInterface {
|
||||
// Get the root path file state
|
||||
|
||||
fstate = avmCtx.getStateTable().findFileState( FileName.DOS_SEPERATOR_STR);
|
||||
|
||||
// Check if the root file state is valid
|
||||
|
||||
if ( fstate == null)
|
||||
{
|
||||
// Create a file state for the root folder
|
||||
|
||||
fstate = avmCtx.getStateTable().findFileState( FileName.DOS_SEPERATOR_STR, true, true);
|
||||
fstate.setExpiryTime( FileState.NoTimeout);
|
||||
|
||||
// Get a list of the available AVM stores
|
||||
|
||||
List<AVMStoreDescriptor> storeList = m_avmService.getStores();
|
||||
|
||||
if ( storeList != null && storeList.size() > 0)
|
||||
{
|
||||
// Add pseudo files for the stores
|
||||
|
||||
for ( AVMStoreDescriptor storeDesc : storeList)
|
||||
{
|
||||
// Add a pseudo file for the current store
|
||||
|
||||
fstate.addPseudoFile( new StorePseudoFile( storeDesc));
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
// Store folder
|
||||
|
@@ -498,6 +498,99 @@ public class AVMPath {
|
||||
m_levelId = LevelId.StorePath;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate a file id for the path
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public final int generateFileId()
|
||||
{
|
||||
// Check if the path is a store path or pseudo path
|
||||
|
||||
int fid = -1;
|
||||
|
||||
if ( isLevel() == LevelId.StorePath)
|
||||
{
|
||||
// Use the share relative path to generate the file id
|
||||
|
||||
fid = getRelativePath().hashCode();
|
||||
}
|
||||
else if ( isPseudoPath())
|
||||
{
|
||||
// Create a relative path to the pseudo folder
|
||||
|
||||
StringBuilder relStr = new StringBuilder();
|
||||
relStr.append( FileName.DOS_SEPERATOR);
|
||||
|
||||
switch( isLevel())
|
||||
{
|
||||
case StoreRoot:
|
||||
relStr.append( getStoreName());
|
||||
break;
|
||||
case Head:
|
||||
relStr.append( getStoreName());
|
||||
relStr.append( FileName.DOS_SEPERATOR);
|
||||
relStr.append( AVMPath.VersionNameHead);
|
||||
break;
|
||||
case HeadData:
|
||||
relStr.append( getStoreName());
|
||||
relStr.append( FileName.DOS_SEPERATOR);
|
||||
relStr.append( AVMPath.VersionNameHead);
|
||||
relStr.append( FileName.DOS_SEPERATOR);
|
||||
relStr.append( AVMPath.DataFolder);
|
||||
break;
|
||||
case HeadMetaData:
|
||||
relStr.append( getStoreName());
|
||||
relStr.append( FileName.DOS_SEPERATOR);
|
||||
relStr.append( AVMPath.VersionNameHead);
|
||||
relStr.append( FileName.DOS_SEPERATOR);
|
||||
relStr.append( AVMPath.MetaDataFolder);
|
||||
break;
|
||||
case VersionRoot:
|
||||
relStr.append( getStoreName());
|
||||
relStr.append( FileName.DOS_SEPERATOR);
|
||||
relStr.append( AVMPath.VersionsFolder);
|
||||
break;
|
||||
case Version:
|
||||
relStr.append( getStoreName());
|
||||
relStr.append( FileName.DOS_SEPERATOR);
|
||||
relStr.append( AVMPath.VersionsFolder);
|
||||
relStr.append( FileName.DOS_SEPERATOR);
|
||||
relStr.append( AVMPath.VersionFolderPrefix);
|
||||
relStr.append( getVersion());
|
||||
break;
|
||||
case VersionData:
|
||||
relStr.append( getStoreName());
|
||||
relStr.append( FileName.DOS_SEPERATOR);
|
||||
relStr.append( AVMPath.VersionsFolder);
|
||||
relStr.append( FileName.DOS_SEPERATOR);
|
||||
relStr.append( AVMPath.VersionFolderPrefix);
|
||||
relStr.append( getVersion());
|
||||
relStr.append( FileName.DOS_SEPERATOR);
|
||||
relStr.append( AVMPath.DataFolder);
|
||||
break;
|
||||
case VersionMetaData:
|
||||
relStr.append( getStoreName());
|
||||
relStr.append( FileName.DOS_SEPERATOR);
|
||||
relStr.append( AVMPath.VersionsFolder);
|
||||
relStr.append( FileName.DOS_SEPERATOR);
|
||||
relStr.append( AVMPath.VersionFolderPrefix);
|
||||
relStr.append( getVersion());
|
||||
relStr.append( FileName.DOS_SEPERATOR);
|
||||
relStr.append( AVMPath.MetaDataFolder);
|
||||
break;
|
||||
}
|
||||
|
||||
// Generate the file id using the pseudo folder relative path
|
||||
|
||||
fid = relStr.toString().hashCode();
|
||||
}
|
||||
|
||||
// Return the file id
|
||||
|
||||
return fid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the AVM path details as a string
|
||||
*
|
||||
|
@@ -19,6 +19,7 @@ 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.SearchContext;
|
||||
import org.alfresco.filesys.util.WildCard;
|
||||
import org.alfresco.service.cmr.avm.AVMNodeDescriptor;
|
||||
@@ -45,18 +46,27 @@ public class AVMSearchContext extends SearchContext {
|
||||
|
||||
private WildCard m_filter;
|
||||
|
||||
// Relative path to the parent folder being searched
|
||||
|
||||
private String m_parentPath;
|
||||
|
||||
/**
|
||||
* Class constructor
|
||||
*
|
||||
* @param fileList SortedMap<String, AVMNodeDescriptor>
|
||||
* @param attrib int
|
||||
* @param filter WildCard
|
||||
* @param parentPath String
|
||||
*/
|
||||
public AVMSearchContext( AVMNodeDescriptor[] fileList, int attrib, WildCard filter)
|
||||
public AVMSearchContext( AVMNodeDescriptor[] fileList, int attrib, WildCard filter, String parentPath)
|
||||
{
|
||||
m_attrib = attrib;
|
||||
m_filter = filter;
|
||||
m_fileList = fileList;
|
||||
|
||||
m_parentPath = parentPath;
|
||||
if ( m_parentPath != null && m_parentPath.endsWith( FileName.DOS_SEPERATOR_STR) == false)
|
||||
m_parentPath = m_parentPath + FileName.DOS_SEPERATOR_STR;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -163,6 +173,13 @@ public class AVMSearchContext extends SearchContext {
|
||||
attr += FileAttribute.Hidden;
|
||||
|
||||
info.setFileAttributes( attr);
|
||||
|
||||
// Generate a file id for the current file
|
||||
|
||||
StringBuilder pathStr = new StringBuilder( m_parentPath);
|
||||
pathStr.append ( curFile.getName());
|
||||
|
||||
info.setFileId( pathStr.toString().hashCode());
|
||||
}
|
||||
|
||||
// Indicate if the file information is valid
|
||||
|
@@ -39,14 +39,20 @@ public class AVMSingleFileSearchContext extends SearchContext {
|
||||
|
||||
private boolean m_endOfSearch;
|
||||
|
||||
// Relative path to the file/folder
|
||||
|
||||
private String m_relativePath;
|
||||
|
||||
/**
|
||||
* Class constructor
|
||||
*
|
||||
* @param fileDetails AVMNodeDescriptor
|
||||
* @param relPath String
|
||||
*/
|
||||
public AVMSingleFileSearchContext( AVMNodeDescriptor fileDetails)
|
||||
public AVMSingleFileSearchContext( AVMNodeDescriptor fileDetails, String relPath)
|
||||
{
|
||||
m_fileDetails = fileDetails;
|
||||
m_fileDetails = fileDetails;
|
||||
m_relativePath = relPath;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -102,6 +108,7 @@ public class AVMSingleFileSearchContext extends SearchContext {
|
||||
attr += FileAttribute.Hidden;
|
||||
|
||||
info.setFileAttributes( attr);
|
||||
info.setFileId( m_relativePath.hashCode());
|
||||
|
||||
// Set the end of search flag, indicate that the file informatin is valid
|
||||
|
||||
|
@@ -502,7 +502,7 @@ public abstract class SrvSession
|
||||
* @return boolean
|
||||
* @exception AlfrescoRuntimeException
|
||||
*/
|
||||
public final boolean beginTransaction(TransactionService transService, boolean readOnly)
|
||||
private final boolean beginTransaction(TransactionService transService, boolean readOnly)
|
||||
throws AlfrescoRuntimeException
|
||||
{
|
||||
boolean created = false;
|
||||
|
@@ -554,7 +554,7 @@ public class ContentDiskDriver extends AlfrescoDiskDriver implements DiskInterfa
|
||||
{
|
||||
// Get the file information for the node
|
||||
|
||||
session.beginTransaction(transactionService, true);
|
||||
session.beginReadTransaction(transactionService);
|
||||
finfo = cifsHelper.getFileInformation(nodeRef);
|
||||
}
|
||||
|
||||
@@ -582,7 +582,7 @@ public class ContentDiskDriver extends AlfrescoDiskDriver implements DiskInterfa
|
||||
{
|
||||
// Create the transaction
|
||||
|
||||
session.beginTransaction(transactionService, true);
|
||||
session.beginReadTransaction(transactionService);
|
||||
|
||||
// Get the node for the folder path
|
||||
|
||||
|
Reference in New Issue
Block a user