mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-07 18:25:23 +00:00
12999: Fixed read-only bootstrap of SiteAVMBootstrap and removed incorrect use of 'assert' 13000: Added log4j to Eclipse classpath (unexported) 13001: Merged V2.1-A to V3.1 9127: Performance improvement to folder copy 9151: *RECORD-ONLY* Fix index back up failing with missing files 13002: Merged V2.1-A to V3.1 9174: Further fixes for ACT-2588 (Lucene backup read-write locks) 9279: Fix ADB-84. PHP module is not restricted by the upper version 10191: Fix for ADB-77: Need to have as the sender's email address the email address of the user triggering the rule 13006: Merged V2.1-A to V3.1 10893: Fixes for ADB-78 & ADB-98 - Fixed service getter/setter pattern as well 10903: Fix for ADB-115 ACT-4355 13010: Made AVMLockingBootstrap resilient to read-only mode 13011: Better message for InvalidStoreRefException 13013: Merged V2.1-A to V3.1 9189: Composite Conditions Support Part 1 of 2 (repo) 9190: Composite Conditions Support Part 1a of 2 ( missed file from repo) 13015: Port of Adobe CIFS/FTP configuration changes 13017: Convert avoids folders given by '--svn-status' option 13018: Merge V2.1A to V3.1 7746: (record-only) Added ability to specify a custom CIFS authenticator class 8533: (record-only) Added the <disableNativeCode/> configuration tag, disable use of JNI code on Windows 8700: (record-only) Update to prevent any native calls via configuration code 8705: (record-only) Filer out the '0.0.0.0' bind address 8864: (record-only) Added the getBean() method for custom authenticators to get access to beans 9054: (record-only) Added the 'AIX' platform type for use in the platforms="..." attribute 8863: (record-only) Fix passthru socket connection timeout, added 'protocolOrder' and 'offlineCheckInterval' config values 12144: (record-only) CIFS virtual circuit fixes 13020: Merged V2.1-A to V3.1 (Composite Actions) 9191: Composite Conditions Support Part 2 of 2 (client) 9243: Composite Conditions Support Part 1 of 2 (client) 9245: Composite Conditions Support Part 2 of 2 (repo) 13021: Merged V3.0 to V3.1 13008: Merged V2.2 to V3.0 12824: (record only) Change admin access to the web project staging store to be read-only in the virtualization view - ETWOTWO-933 13024: Ported CIFS configuration changes from Adobe V2.1A, missed checkin. ___________________________________________________________________ Modified: svn:mergeinfo Merged /alfresco/BRANCHES/V2.1-A:r9127,9151,9174,9189-9191,9243,9245,9279,10191,10893,10903 Merged /alfresco/BRANCHES/V3.1:r12999-13002,13006,13010-13011,13013,13015,13017-13018,13020-13021,13024 git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@13550 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
579 lines
15 KiB
Java
579 lines
15 KiB
Java
/*
|
|
* Copyright (C) 2005-2007 Alfresco Software Limited.
|
|
*
|
|
* This program is free software; you can redistribute it and/or
|
|
* modify it under the terms of the GNU General Public License
|
|
* as published by the Free Software Foundation; either version 2
|
|
* of the License, or (at your option) any later version.
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with this program; if not, write to the Free Software
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
* As a special exception to the terms and conditions of version 2.0 of
|
|
* the GPL, you may redistribute this Program in connection with Free/Libre
|
|
* and Open Source Software ("FLOSS") applications as described in Alfresco's
|
|
* FLOSS exception. You should have recieved a copy of the text describing
|
|
* the FLOSS exception, and it is also available here:
|
|
* http://www.alfresco.com/legal/licensing" */
|
|
|
|
package org.alfresco.filesys.avm;
|
|
|
|
import org.alfresco.filesys.alfresco.AlfrescoContext;
|
|
import org.alfresco.filesys.alfresco.IOControlHandler;
|
|
import org.alfresco.filesys.state.FileState;
|
|
import org.alfresco.filesys.state.FileStateTable;
|
|
import org.alfresco.jlan.server.filesys.DiskInterface;
|
|
import org.alfresco.jlan.server.filesys.FileName;
|
|
import org.alfresco.jlan.server.filesys.FileSystem;
|
|
import org.alfresco.jlan.server.filesys.NotifyChange;
|
|
import org.alfresco.jlan.util.StringList;
|
|
import org.alfresco.repo.avm.CreateStoreCallback;
|
|
import org.alfresco.repo.avm.CreateVersionCallback;
|
|
import org.alfresco.repo.avm.PurgeStoreCallback;
|
|
import org.alfresco.repo.avm.PurgeVersionCallback;
|
|
import org.apache.commons.logging.Log;
|
|
import org.apache.commons.logging.LogFactory;
|
|
|
|
/**
|
|
* AVM Filesystem Context Class
|
|
*
|
|
* <p>Contains per filesystem context.
|
|
*
|
|
* @author GKSpencer
|
|
*/
|
|
public class AVMContext extends AlfrescoContext
|
|
implements CreateStoreCallback, PurgeStoreCallback, CreateVersionCallback, PurgeVersionCallback {
|
|
|
|
// Logging
|
|
|
|
private static final Log logger = LogFactory.getLog(AVMContext.class);
|
|
|
|
// Constants
|
|
//
|
|
// Version id that indicates the head version
|
|
|
|
public static final int VERSION_HEAD = -1;
|
|
|
|
// Store types to show in the virtualization view
|
|
|
|
public static final int ShowNormalStores = 0x0001;
|
|
public static final int ShowSiteStores = 0x0002;
|
|
public static final int ShowStagingStores = 0x0004;
|
|
public static final int ShowAuthorStores = 0x0008;
|
|
public static final int ShowPreviewStores = 0x0010;
|
|
|
|
// Store, root path and version
|
|
|
|
private String m_storePath;
|
|
private int m_version = VERSION_HEAD;
|
|
|
|
// Flag to indicate if the virtualization view is enabled
|
|
//
|
|
// The first set of folders then map to the stores and the second layer map to the versions with
|
|
// paths below.
|
|
|
|
private boolean m_virtualView;
|
|
|
|
// Associated AVM filesystem driver
|
|
|
|
private AVMDiskDriver m_avmDriver;
|
|
|
|
// Virtualization view filtering options
|
|
|
|
private int m_showOptions;
|
|
|
|
// List of newly created store names that need adding into the virtualization view
|
|
|
|
private StringList m_newStores;
|
|
private Object m_newStoresLock;
|
|
|
|
// Allow admin user to write to web project staging stores
|
|
|
|
private boolean m_allowAdminStagingWrites;
|
|
|
|
/**
|
|
* Class constructor
|
|
*
|
|
* <p>Construct a context for a normal view onto a single store/version within AVM.
|
|
*
|
|
* @param filesysName String
|
|
* @param storePath String
|
|
* @param version int
|
|
*/
|
|
public AVMContext( String filesysName, String storePath, int version)
|
|
{
|
|
super( filesysName, storePath + "(" + version + ")");
|
|
|
|
// Set the store root path, remove any trailing slash as relative paths will be appended to this value
|
|
|
|
m_storePath = storePath;
|
|
if ( m_storePath.endsWith( "/"))
|
|
m_storePath = m_storePath.substring(0, m_storePath.length() - 1);
|
|
|
|
// Set the store version to use
|
|
|
|
m_version = version;
|
|
}
|
|
|
|
/**
|
|
* Class constructor
|
|
*
|
|
* <p>Construct a context for a virtualization view onto all stores/versions within AVM.
|
|
*
|
|
* @param filesysName String
|
|
* @param showOptions int
|
|
* @param avmDriver AVMDiskDriver
|
|
*/
|
|
public AVMContext( String filesysName, int showOptions, AVMDiskDriver avmDriver)
|
|
{
|
|
super( filesysName, "VirtualView");
|
|
|
|
// Enable the virtualization view
|
|
|
|
m_virtualView = true;
|
|
m_showOptions = showOptions;
|
|
|
|
m_newStoresLock = new Object();
|
|
m_newStores = new StringList();
|
|
|
|
// Save the associated filesystem driver
|
|
|
|
m_avmDriver = avmDriver;
|
|
}
|
|
|
|
/**
|
|
* Return the filesystem type, either FileSystem.TypeFAT or FileSystem.TypeNTFS.
|
|
*
|
|
* @return String
|
|
*/
|
|
public String getFilesystemType()
|
|
{
|
|
return FileSystem.TypeNTFS;
|
|
}
|
|
|
|
/**
|
|
* Return the store path
|
|
*
|
|
* @return String
|
|
*/
|
|
public final String getStorePath()
|
|
{
|
|
return m_storePath;
|
|
}
|
|
|
|
/**
|
|
* Return the version
|
|
*
|
|
* @return int
|
|
*/
|
|
public final int isVersion()
|
|
{
|
|
return m_version;
|
|
}
|
|
|
|
/**
|
|
* Check if the virtualization view is enabled
|
|
*
|
|
* @return boolean
|
|
*/
|
|
public final boolean isVirtualizationView()
|
|
{
|
|
return m_virtualView;
|
|
}
|
|
|
|
/**
|
|
* Check if the admin user is allowed to write to web project staging stores
|
|
*
|
|
* @return boolean
|
|
*/
|
|
public final boolean allowAdminStagingWrites() {
|
|
return m_allowAdminStagingWrites;
|
|
}
|
|
|
|
/**
|
|
* Set the admin web project staging store writeable status
|
|
*
|
|
* @param writeable boolean
|
|
*/
|
|
public final void setAllowAdminStaginWrites(boolean writeable) {
|
|
m_allowAdminStagingWrites = writeable;
|
|
}
|
|
|
|
/**
|
|
* Check if there are any new stores queued for adding to the virtualization view
|
|
*
|
|
* @return boolean
|
|
*/
|
|
protected final boolean hasNewStoresQueued() {
|
|
if ( m_newStores == null || m_newStores.numberOfStrings() == 0)
|
|
return false;
|
|
return true;
|
|
}
|
|
|
|
/**
|
|
* Return the new stores queue, and reset the current queue
|
|
*
|
|
* @return StringList
|
|
*/
|
|
protected StringList getNewStoresQueue() {
|
|
|
|
StringList storesQueue = null;
|
|
|
|
synchronized ( m_newStoresLock) {
|
|
storesQueue = m_newStores;
|
|
m_newStores = new StringList();
|
|
}
|
|
|
|
return storesQueue;
|
|
}
|
|
|
|
/**
|
|
* Check if normal stores should be shown in the virtualization view
|
|
*
|
|
* @return boolean
|
|
*/
|
|
public final boolean showNormalStores()
|
|
{
|
|
return (m_showOptions & ShowNormalStores) != 0 ? true : false;
|
|
}
|
|
|
|
/**
|
|
* Check if site data stores should be shown in the virtualization view
|
|
*
|
|
* @return boolean
|
|
*/
|
|
public final boolean showSiteStores()
|
|
{
|
|
return (m_showOptions & ShowSiteStores) != 0 ? true : false;
|
|
}
|
|
|
|
/**
|
|
* Check if author stores should be shown in the virtualization view
|
|
*
|
|
* @return boolean
|
|
*/
|
|
public final boolean showAuthorStores()
|
|
{
|
|
return (m_showOptions & ShowAuthorStores) != 0 ? true : false;
|
|
}
|
|
|
|
/**
|
|
* Check if preview stores should be shown in the virtualization view
|
|
*
|
|
* @return boolean
|
|
*/
|
|
public final boolean showPreviewStores()
|
|
{
|
|
return (m_showOptions & ShowPreviewStores) != 0 ? true : false;
|
|
}
|
|
|
|
/**
|
|
* Check if staging stores should be shown in the virtualization view
|
|
*
|
|
* @return boolean
|
|
*/
|
|
public final boolean showStagingStores()
|
|
{
|
|
return (m_showOptions & ShowStagingStores) != 0 ? true : false;
|
|
}
|
|
|
|
/**
|
|
* Check if the specified store type should be visible
|
|
*
|
|
* @param storeType int
|
|
* @return boolean
|
|
*/
|
|
public final boolean showStoreType(int storeType)
|
|
{
|
|
boolean showStore = false;
|
|
|
|
switch (storeType)
|
|
{
|
|
case StoreType.Normal:
|
|
showStore = showNormalStores();
|
|
break;
|
|
case StoreType.SiteStore:
|
|
showStore = showSiteStores();
|
|
break;
|
|
case StoreType.WebAuthorMain:
|
|
showStore = showAuthorStores();
|
|
break;
|
|
case StoreType.WebStagingMain:
|
|
showStore = showStagingStores();
|
|
break;
|
|
case StoreType.WebAuthorPreview:
|
|
case StoreType.WebStagingPreview:
|
|
showStore = showPreviewStores();
|
|
break;
|
|
}
|
|
|
|
return showStore;
|
|
}
|
|
|
|
/**
|
|
* Close the filesystem context
|
|
*/
|
|
public void CloseContext() {
|
|
|
|
// Call the base class
|
|
|
|
super.CloseContext();
|
|
}
|
|
|
|
/**
|
|
* Create the I/O control handler for this filesystem type
|
|
*
|
|
* @param filesysDriver DiskInterface
|
|
* @return IOControlHandler
|
|
*/
|
|
protected IOControlHandler createIOHandler( DiskInterface filesysDriver)
|
|
{
|
|
return null;
|
|
}
|
|
|
|
/**
|
|
* Create store call back handler
|
|
*
|
|
* @param storeName String
|
|
* @param versionID int
|
|
*/
|
|
public void storeCreated(String storeName)
|
|
{
|
|
// Not interested if the virtualization view is not enabled
|
|
|
|
if ( isVirtualizationView() == false)
|
|
return;
|
|
|
|
// Make sure the file state cache is enabled
|
|
|
|
FileStateTable fsTable = getStateTable();
|
|
if ( fsTable == null)
|
|
return;
|
|
|
|
// Find the file state for the root folder
|
|
|
|
FileState rootState = fsTable.findFileState( FileName.DOS_SEPERATOR_STR, true, true);
|
|
|
|
if ( rootState != null)
|
|
{
|
|
// DEBUG
|
|
|
|
if ( logger.isDebugEnabled())
|
|
logger.debug("Queueing new store " + storeName + " for addition to virtualization view");
|
|
|
|
// Add the new store name to the list to be picked up by the next file server access
|
|
// to the filesystem
|
|
|
|
synchronized ( m_newStoresLock) {
|
|
|
|
// Add the new store name
|
|
|
|
m_newStores.addString( storeName);
|
|
}
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Purge store call back handler
|
|
*
|
|
* @param storeName String
|
|
*/
|
|
public void storePurged(String storeName)
|
|
{
|
|
// Not interested if the virtualization view is not enabled
|
|
|
|
if ( isVirtualizationView() == false)
|
|
return;
|
|
|
|
// Make sure the file state cache is enabled
|
|
|
|
FileStateTable fsTable = getStateTable();
|
|
if ( fsTable == null)
|
|
return;
|
|
|
|
// Find the file state for the root folder
|
|
|
|
FileState rootState = fsTable.findFileState( FileName.DOS_SEPERATOR_STR);
|
|
|
|
if ( rootState != null && rootState.hasPseudoFiles())
|
|
{
|
|
// Remove the pseudo folder for the store
|
|
|
|
rootState.getPseudoFileList().removeFile( storeName, false);
|
|
|
|
// Build the filesystem relative path to the deleted store folder
|
|
|
|
StringBuilder pathStr = new StringBuilder();
|
|
|
|
pathStr.append( FileName.DOS_SEPERATOR);
|
|
pathStr.append( storeName);
|
|
|
|
// Remove the file state for the deleted store
|
|
|
|
String storePath = pathStr.toString();
|
|
fsTable.removeFileState( storePath);
|
|
|
|
// DEBUG
|
|
|
|
if ( logger.isDebugEnabled())
|
|
logger.debug( "Removed pseudo folder for purged store " + storeName);
|
|
|
|
// Update the file state modify time
|
|
|
|
rootState.updateModifyDateTime();
|
|
|
|
// Send a change notification for the deleted folder
|
|
|
|
if ( hasChangeHandler())
|
|
{
|
|
// Send the change notification
|
|
|
|
getChangeHandler().notifyDirectoryChanged(NotifyChange.ActionRemoved, storePath);
|
|
}
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Create version call back handler
|
|
*
|
|
* @param storeName String
|
|
* @param versionID int
|
|
*/
|
|
public void versionCreated(String storeName, int versionID)
|
|
{
|
|
// Not interested if the virtualization view is not enabled
|
|
|
|
if ( isVirtualizationView() == false)
|
|
return;
|
|
|
|
// Make sure the file state cache is enabled
|
|
|
|
FileStateTable fsTable = getStateTable();
|
|
if ( fsTable == null)
|
|
return;
|
|
|
|
// Build the path to the store version folder
|
|
|
|
StringBuilder pathStr = new StringBuilder();
|
|
|
|
pathStr.append( FileName.DOS_SEPERATOR);
|
|
pathStr.append( storeName);
|
|
pathStr.append( FileName.DOS_SEPERATOR);
|
|
pathStr.append( AVMPath.VersionsFolder);
|
|
|
|
// Find the file state for the store versions folder
|
|
|
|
FileState verState = fsTable.findFileState( pathStr.toString());
|
|
|
|
if ( verState != null)
|
|
{
|
|
// Create the version folder name
|
|
|
|
StringBuilder verStr = new StringBuilder();
|
|
|
|
verStr.append( AVMPath.VersionFolderPrefix);
|
|
verStr.append( versionID);
|
|
|
|
String verName = verStr.toString();
|
|
|
|
// Add a pseudo folder for the new version
|
|
|
|
pathStr.append( FileName.DOS_SEPERATOR);
|
|
pathStr.append( verName);
|
|
|
|
verState.addPseudoFile( new VersionPseudoFile( verName, pathStr.toString()));
|
|
|
|
// DEBUG
|
|
|
|
if ( logger.isDebugEnabled())
|
|
logger.debug( "Added pseudo folder for new version " + storeName + ":/" + verName);
|
|
|
|
// Send a change notification for the new folder
|
|
|
|
if ( hasChangeHandler())
|
|
{
|
|
// Build the filesystem relative path to the new version folder
|
|
|
|
pathStr.append( FileName.DOS_SEPERATOR);
|
|
pathStr.append( verName);
|
|
|
|
// Send the change notification
|
|
|
|
getChangeHandler().notifyDirectoryChanged(NotifyChange.ActionAdded, pathStr.toString());
|
|
}
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Purge version call back handler
|
|
*
|
|
* @param storeName String
|
|
*/
|
|
public void versionPurged(String storeName, int versionID)
|
|
{
|
|
// Not interested if the virtualization view is not enabled
|
|
|
|
if ( isVirtualizationView() == false)
|
|
return;
|
|
|
|
// Make sure the file state cache is enabled
|
|
|
|
FileStateTable fsTable = getStateTable();
|
|
if ( fsTable == null)
|
|
return;
|
|
|
|
// Build the path to the store version folder
|
|
|
|
StringBuilder pathStr = new StringBuilder();
|
|
|
|
pathStr.append( FileName.DOS_SEPERATOR);
|
|
pathStr.append( storeName);
|
|
pathStr.append( FileName.DOS_SEPERATOR);
|
|
pathStr.append( AVMPath.VersionsFolder);
|
|
|
|
// Find the file state for the store versions folder
|
|
|
|
FileState verState = fsTable.findFileState( pathStr.toString());
|
|
|
|
if ( verState != null && verState.hasPseudoFiles())
|
|
{
|
|
// Create the version folder name
|
|
|
|
StringBuilder verStr = new StringBuilder();
|
|
|
|
verStr.append( AVMPath.VersionFolderPrefix);
|
|
verStr.append( versionID);
|
|
|
|
String verName = verStr.toString();
|
|
|
|
// Remove the pseudo folder for the purged version
|
|
|
|
verState.getPseudoFileList().removeFile( verName, true);
|
|
|
|
// DEBUG
|
|
|
|
if ( logger.isDebugEnabled())
|
|
logger.debug( "Removed pseudo folder for purged version " + storeName + ":/" + verName);
|
|
|
|
// Send a change notification for the deleted folder
|
|
|
|
if ( hasChangeHandler())
|
|
{
|
|
// Build the filesystem relative path to the deleted version folder
|
|
|
|
pathStr.append( FileName.DOS_SEPERATOR);
|
|
pathStr.append( verName);
|
|
|
|
// Send the change notification
|
|
|
|
getChangeHandler().notifyDirectoryChanged(NotifyChange.ActionRemoved, pathStr.toString());
|
|
}
|
|
}
|
|
}
|
|
}
|