REPO-3262 Remove CIFS (#249)

Removal of configuration and most of the classes. Some shared with FTP classes were left in place.
This commit is contained in:
Alex Mukha
2018-11-05 10:11:01 +00:00
committed by GitHub
parent cbbc135e35
commit 8e1e922b87
127 changed files with 351 additions and 24602 deletions

View File

@@ -1,28 +1,28 @@
/*
* #%L
* Alfresco Repository
* %%
* Copyright (C) 2005 - 2016 Alfresco Software Limited
* %%
* This file is part of the Alfresco software.
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
*
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alfresco 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 Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
* #L%
*/
/*
* #%L
* Alfresco Repository
* %%
* Copyright (C) 2005 - 2016 Alfresco Software Limited
* %%
* This file is part of the Alfresco software.
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
*
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alfresco 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 Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
* #L%
*/
package org.alfresco.filesys.repo;
import java.io.FileNotFoundException;
@@ -69,11 +69,6 @@ import org.alfresco.jlan.server.filesys.SearchContext;
import org.alfresco.jlan.server.filesys.SrvDiskInfo;
import org.alfresco.jlan.server.filesys.TreeConnection;
import org.alfresco.jlan.server.filesys.cache.FileState;
import org.alfresco.jlan.server.filesys.pseudo.MemoryNetworkFile;
import org.alfresco.jlan.server.filesys.pseudo.PseudoFile;
import org.alfresco.jlan.server.filesys.pseudo.PseudoFileInterface;
import org.alfresco.jlan.server.filesys.pseudo.PseudoFileList;
import org.alfresco.jlan.server.filesys.pseudo.PseudoNetworkFile;
import org.alfresco.jlan.server.filesys.quota.QuotaManager;
import org.alfresco.jlan.server.filesys.quota.QuotaManagerException;
import org.alfresco.jlan.server.locking.FileLockingInterface;
@@ -212,13 +207,13 @@ public class ContentDiskDriver extends AlfrescoTxDiskDriver implements DiskInter
private NodeMonitorFactory m_nodeMonitorFactory;
/**
* Class constructor
*
* @param cifsHelper to connect to the repository services
*/
public ContentDiskDriver(CifsHelper cifsHelper)
{
/**
* Class constructor
*
* @param cifsHelper to connect to the repository services
*/
public ContentDiskDriver(CifsHelper cifsHelper)
{
this.cifsHelper = cifsHelper;
}
@@ -320,12 +315,12 @@ public class ContentDiskDriver extends AlfrescoTxDiskDriver implements DiskInter
public final PermissionService getPermissionService() {
return this.permissionService;
}
/**
* Return the node archive service
*/
public final NodeArchiveService getNodeArchiveService() {
return nodeArchiveService;
/**
* Return the node archive service
*/
public final NodeArchiveService getNodeArchiveService() {
return nodeArchiveService;
}
/**
@@ -471,13 +466,13 @@ public class ContentDiskDriver extends AlfrescoTxDiskDriver implements DiskInter
m_nodeMonitorFactory = nodeMonitorFactory;
}
/**
* Set the node archive service
*
* @param nodeArchiveService nodeArchiveService
*/
public void setNodeArchiveService(NodeArchiveService nodeArchiveService) {
this.nodeArchiveService = nodeArchiveService;
/**
* Set the node archive service
*
* @param nodeArchiveService nodeArchiveService
*/
public void setNodeArchiveService(NodeArchiveService nodeArchiveService) {
this.nodeArchiveService = nodeArchiveService;
}
/**
@@ -650,12 +645,12 @@ public class ContentDiskDriver extends AlfrescoTxDiskDriver implements DiskInter
* of the shared device. The same DeviceInterface implementation may be used for multiple
* shares.
*
* WARNING: side effect, will commit or roll back current user transaction context.
*
* @param ctx the context
* @exception DeviceContextException
*/
// MER TODO - transaction handling in registerContext needs changing
* WARNING: side effect, will commit or roll back current user transaction context.
*
* @param ctx the context
* @exception DeviceContextException
*/
// MER TODO - transaction handling in registerContext needs changing
@Override
public void registerContext(DeviceContext ctx) throws DeviceContextException
{
@@ -828,28 +823,6 @@ public class ContentDiskDriver extends AlfrescoTxDiskDriver implements DiskInter
}
}
}
/**
* Check if pseudo file support is enabled
*
* @param context ContentContext
* @return boolean
*/
public final boolean hasPseudoFileInterface(ContentContext context)
{
return context.hasPseudoFileInterface();
}
/**
* Return the pseudo file support implementation
*
* @param context ContentContext
* @return PseudoFileInterface
*/
public final PseudoFileInterface getPseudoFileInterface(ContentContext context)
{
return context.getPseudoFileInterface();
}
/**
* Determine if the disk device is read-only.
@@ -864,15 +837,15 @@ public class ContentDiskDriver extends AlfrescoTxDiskDriver implements DiskInter
return isReadOnly;
}
/**
* Get the file information for the specified file.
*
* @param session Server session
* @param tree Tree connection
* @param path File name/path that information is required for.
* @return File information if valid, else null
* @exception java.io.IOException The exception description.
*/
/**
* Get the file information for the specified file.
*
* @param session Server session
* @param tree Tree connection
* @param path File name/path that information is required for.
* @return File information if valid, else null
* @exception java.io.IOException The exception description.
*/
public FileInfo getFileInformation(SrvSession session, TreeConnection tree, String path) throws IOException
{
if(logger.isDebugEnabled())
@@ -898,86 +871,7 @@ public class ContentDiskDriver extends AlfrescoTxDiskDriver implements DiskInter
// Check if the path is to a pseudo file
FileInfo finfo = null;
if ( hasPseudoFileInterface(ctx))
{
// Make sure the parent folder has a file state, and the path exists
String[] paths = FileName.splitPath( path);
FileState fstate = ctx.getStateCache().findFileState( paths[0]);
if ( fstate == null)
{
NodeRef nodeRef = getNodeForPath(tree, paths[0]);
if ( nodeRef != null)
{
// Get the file information for the node
finfo = cifsHelper.getFileInformation(nodeRef, isReadOnly, isLockedFilesAsOffline);
}
// Create the file state
fstate = ctx.getStateCache().findFileState( paths[0], true);
fstate.setFileStatus( DirectoryExists);
fstate.setFilesystemObject( nodeRef);
// Add pseudo files to the folder
getPseudoFileInterface( ctx).addPseudoFilesToFolder( session, tree, paths[0]);
// Debug
if ( logger.isDebugEnabled() && ctx.hasDebug(AlfrescoContext.DBG_INFO))
logger.debug( "Added file state for pseudo files folder (getinfo) - " + paths[0]);
}
else if ( fstate.hasPseudoFiles() == false)
{
// Make sure the file state has the node ref
if ( fstate.hasFilesystemObject() == false)
{
// Get the node for the folder path
fstate.setFilesystemObject( getNodeForPath( tree, paths[0]));
}
// Add pseudo files for the parent folder
getPseudoFileInterface( ctx).addPseudoFilesToFolder( session, tree, paths[0]);
// Debug
if ( logger.isDebugEnabled() && ctx.hasDebug(AlfrescoContext.DBG_INFO))
logger.debug( "Added pseudo files for folder (exists) - " + paths[0]);
}
// Get the pseudo file
PseudoFile pfile = getPseudoFileInterface(ctx).getPseudoFile( session, tree, path);
if ( pfile != null)
{
// DEBUG
if ( logger.isDebugEnabled() && ctx.hasDebug(AlfrescoContext.DBG_INFO))
logger.debug("getInfo using pseudo file info for " + path);
FileInfo pseudoFileInfo = pfile.getFileInfo();
if (isReadOnly)
{
int attr = pseudoFileInfo.getFileAttributes();
if (( attr & FileAttribute.ReadOnly) == 0)
{
attr += FileAttribute.ReadOnly;
pseudoFileInfo.setFileAttributes(attr);
}
}
return pfile.getFileInfo();
}
}
// Get the node ref for the path, chances are there is a file state in the cache
NodeRef nodeRef = getNodeForPath(tree, infoPath);
@@ -1110,13 +1004,13 @@ public class ContentDiskDriver extends AlfrescoTxDiskDriver implements DiskInter
* Start a new search on the filesystem using the specified searchPath that may contain
* wildcards.
*
* @param sess Server session
* @param tree Tree connection
* @param searchPath File(s) to search for, may include wildcards.
* @param attributes Attributes of the file(s) to search for, see class SMBFileAttribute.
* @return SearchContext
* @exception java.io.FileNotFoundException If the search could not be started.
*/
* @param sess Server session
* @param tree Tree connection
* @param searchPath File(s) to search for, may include wildcards.
* @param attributes Attributes of the file(s) to search for, see class SMBFileAttribute.
* @return SearchContext
* @exception java.io.FileNotFoundException If the search could not be started.
*/
public SearchContext startSearch(SrvSession sess, TreeConnection tree, String searchPath, int attributes) throws FileNotFoundException
{
// Access the device context
@@ -1170,11 +1064,6 @@ public class ContentDiskDriver extends AlfrescoTxDiskDriver implements DiskInter
searchFolderState.setFilesystemObject( nodeRef);
}
// Add pseudo files to the folder being searched
if ( hasPseudoFileInterface(ctx))
getPseudoFileInterface(ctx).addPseudoFilesToFolder( sess, tree, paths[0]);
// Set the search node and file spec
@@ -1214,70 +1103,7 @@ public class ContentDiskDriver extends AlfrescoTxDiskDriver implements DiskInter
logger.debug("Search for searchPath=" + searchPath + ", searchSpec=" + searchFileSpec + ", searchRootNode=" + searchRootNodeRef + " took "
+ ( endTime - startTime) + "ms results=" + results.size());
}
// Check if there are any pseudo files for the folder being searched, for CIFS only
PseudoFileList pseudoList = null;
if ( sess instanceof SMBSrvSession && searchFolderState != null && searchFolderState.hasPseudoFiles())
{
// If it is a wildcard search use all pseudo files
if ( WildCard.containsWildcards(searchFileSpec))
{
// Get the list of pseudo files for the search path
pseudoList = searchFolderState.getPseudoFileList();
// Check if the wildcard is for all files or a subset
if ( searchFileSpec.equals( "*") == false && pseudoList != null && pseudoList.numberOfFiles() > 0)
{
// Generate a subset of pseudo files that match the wildcard search pattern
WildCard wildCard = new WildCard( searchFileSpec, false);
PseudoFileList filterList = null;
for ( int i = 0; i < pseudoList.numberOfFiles(); i++)
{
PseudoFile pseudoFile = pseudoList.getFileAt( i);
if ( wildCard.matchesPattern( pseudoFile.getFileName()))
{
// Add the pseudo file to the filtered list
if ( filterList == null)
filterList = new PseudoFileList();
filterList.addFile( pseudoFile);
}
}
// Use the filtered pseudo file list, or null if there were no matches
pseudoList = filterList;
}
}
else if ( results == null || results.size() == 0)
{
// Check if the required file is in the pseudo file list
String fname = paths[1];
if ( fname != null)
{
// Search for a matching pseudo file
PseudoFile pfile = searchFolderState.getPseudoFileList().findFile( fname, true);
if ( pfile != null)
{
// Create a file list with the required file
pseudoList = new PseudoFileList();
pseudoList.addFile( pfile);
}
}
}
}
// Build the search context to store the results, use the cache lookup search for wildcard searches
SearchContext searchCtx = null;
@@ -1286,7 +1112,7 @@ public class ContentDiskDriver extends AlfrescoTxDiskDriver implements DiskInter
{
// Use a cache lookup search context
CacheLookupSearchContext cacheContext = new CacheLookupSearchContext(cifsHelper, results, searchFileSpec, pseudoList, paths[0], ctx.getStateCache(), isLockedFilesAsOffline);
CacheLookupSearchContext cacheContext = new CacheLookupSearchContext(cifsHelper, results, searchFileSpec, paths[0], ctx.getStateCache(), isLockedFilesAsOffline);
searchCtx = cacheContext;
// Set the '.' and '..' pseudo file entry details
@@ -1373,9 +1199,9 @@ public class ContentDiskDriver extends AlfrescoTxDiskDriver implements DiskInter
}
else {
if ( ctx.hasStateCache())
searchCtx = new CacheLookupSearchContext(cifsHelper, results, searchFileSpec, pseudoList, paths[0], ctx.getStateCache(), isLockedFilesAsOffline);
searchCtx = new CacheLookupSearchContext(cifsHelper, results, searchFileSpec, paths[0], ctx.getStateCache(), isLockedFilesAsOffline);
else
searchCtx = new ContentSearchContext(cifsHelper, results, searchFileSpec, pseudoList, paths[0], isLockedFilesAsOffline);
searchCtx = new ContentSearchContext(cifsHelper, results, searchFileSpec, paths[0], isLockedFilesAsOffline);
}
// Debug
@@ -1449,90 +1275,6 @@ public class ContentDiskDriver extends AlfrescoTxDiskDriver implements DiskInter
}
else
{
// Check if pseudo files are enabled
if ( hasPseudoFileInterface(ctx))
{
// Check if the file name is a pseudo file name
if ( getPseudoFileInterface( ctx).isPseudoFile(sess, tree, name)) {
// Make sure the parent folder has a file state, and the path exists
String[] paths = FileName.splitPath( name);
fstate = ctx.getStateCache().findFileState( paths[0]);
if ( fstate == null) {
// Check if the path exists
if ( fileExists( sess, tree, paths[0]) == FileStatus.DirectoryExists)
{
// Create the file state
fstate = ctx.getStateCache().findFileState( paths[0], true);
fstate.setFileStatus( DirectoryExists);
// Get the node for the folder path
beginReadTransaction( sess);
fstate.setFilesystemObject( getNodeForPath( tree, paths[0]));
// Add pseudo files to the folder
getPseudoFileInterface( ctx).addPseudoFilesToFolder( sess, tree, paths[0]);
// Debug
if ( logger.isDebugEnabled() && ctx.hasDebug(AlfrescoContext.DBG_PSEUDO))
logger.debug( "Added file state for pseudo files folder (exists) - " + paths[0]);
}
}
else if ( fstate.hasPseudoFiles() == false)
{
// Make sure the file state has the node ref
if ( fstate.hasFilesystemObject() == false)
{
// Create the transaction
beginReadTransaction( sess);
// Get the node for the folder path
fstate.setFilesystemObject( getNodeForPath( tree, paths[0]));
}
// Add pseudo files for the parent folder
getPseudoFileInterface( ctx).addPseudoFilesToFolder( sess, tree, paths[0]);
// Debug
if ( logger.isDebugEnabled() && ctx.hasDebug(AlfrescoContext.DBG_PSEUDO))
logger.debug( "Added pseudo files for folder (exists) - " + paths[0]);
}
// Check if the path is to a pseudo file
PseudoFile pfile = getPseudoFileInterface(ctx).getPseudoFile( sess, tree, name);
if ( pfile != null)
{
// Indicate that the file exists
status = FileStatus.FileExists;
}
else
{
// Failed to find pseudo file
if ( logger.isDebugEnabled() && ctx.hasDebug(AlfrescoContext.DBG_PSEUDO))
logger.debug( "Failed to find pseudo file (exists) - " + name);
}
}
}
// If the file is not a pseudo file then search for the file
if ( status == FileStatus.Unknown)
@@ -1614,71 +1356,6 @@ public class ContentDiskDriver extends AlfrescoTxDiskDriver implements DiskInter
try
{
// Check if pseudo files are enabled
if ( hasPseudoFileInterface(ctx))
{
// Check if the file name is a pseudo file name
String path = params.getPath();
if ( getPseudoFileInterface( ctx).isPseudoFile(sess, tree, path)) {
// Make sure the parent folder has a file state, and the path exists
String[] paths = FileName.splitPath( path);
FileState fstate = ctx.getStateCache().findFileState( paths[0]);
if ( fstate == null) {
// Check if the path exists
if ( fileExists( sess, tree, paths[0]) == FileStatus.DirectoryExists)
{
// Create the file state and add any pseudo files
fstate = ctx.getStateCache().findFileState( paths[0], true);
fstate.setFileStatus( DirectoryExists);
getPseudoFileInterface( ctx).addPseudoFilesToFolder( sess, tree, paths[0]);
// Debug
if ( logger.isDebugEnabled() && ctx.hasDebug(AlfrescoContext.DBG_PSEUDO))
logger.debug( "Added file state for pseudo files folder (open) - " + paths[0]);
}
}
else if ( fstate.hasPseudoFiles() == false)
{
// Add pseudo files for the parent folder
getPseudoFileInterface( ctx).addPseudoFilesToFolder( sess, tree, paths[0]);
// Debug
if ( logger.isDebugEnabled() && ctx.hasDebug(AlfrescoContext.DBG_PSEUDO))
logger.debug( "Added pseudo files for folder (open) - " + paths[0]);
}
// Check if the path is to a pseudo file
PseudoFile pfile = getPseudoFileInterface(ctx).getPseudoFile( sess, tree, params.getPath());
if ( pfile != null)
{
// Create a network file to access the pseudo file data
return pfile.getFile( params.getPath());
}
else
{
// Failed to find pseudo file
if ( logger.isDebugEnabled() && ctx.hasDebug(AlfrescoContext.DBG_PSEUDO))
logger.debug( "Failed to find pseudo file (open) - " + params.getPath());
}
}
}
// Not a pseudo file, try and open a normal file/folder node
NodeRef nodeRef = getNodeForPath(tree, params.getPath());
@@ -2511,13 +2188,13 @@ public class ContentDiskDriver extends AlfrescoTxDiskDriver implements DiskInter
/**
* Close the file.
*
* @param sess Server session
* @param tree Tree connection.
* @param file Network file context.
* @exception java.io.IOException If an error occurs.
*/
public void closeFile(SrvSession sess, TreeConnection tree, final NetworkFile file) throws IOException
*
* @param sess Server session
* @param tree Tree connection.
* @param file Network file context.
* @exception java.io.IOException If an error occurs.
*/
public void closeFile(SrvSession sess, TreeConnection tree, final NetworkFile file) throws IOException
{
if (logger.isDebugEnabled())
{
@@ -2820,14 +2497,6 @@ public class ContentDiskDriver extends AlfrescoTxDiskDriver implements DiskInter
}
}
}
else if (file.hasDeleteOnClose() && (file instanceof PseudoNetworkFile || file instanceof MemoryNetworkFile)
&& hasPseudoFileInterface(ctx))
{
// Delete the pseudo file
getPseudoFileInterface(ctx).deletePseudoFile(sess, tree, file.getFullName());
}
// DEBUG
@@ -2881,13 +2550,13 @@ public class ContentDiskDriver extends AlfrescoTxDiskDriver implements DiskInter
/**
* Delete the specified file.
*
* @param sess Server session
* @param tree Tree connection
* @param name NetworkFile
* @exception java.io.IOException The exception description.
*/
public void deleteFile(final SrvSession sess, final TreeConnection tree, final String name) throws IOException
*
* @param sess Server session
* @param tree Tree connection
* @param name NetworkFile
* @exception java.io.IOException The exception description.
*/
public void deleteFile(final SrvSession sess, final TreeConnection tree, final String name) throws IOException
{
// Get the device context
@@ -2900,35 +2569,6 @@ public class ContentDiskDriver extends AlfrescoTxDiskDriver implements DiskInter
try
{
// Check if pseudo files are enabled
if ( hasPseudoFileInterface(ctx))
{
// Check if the file name is a pseudo file name
if ( getPseudoFileInterface( ctx).isPseudoFile(sess, tree, name)) {
// Make sure the parent folder has a file state, and the path exists
String[] paths = FileName.splitPath( name);
FileState fstate = ctx.getStateCache().findFileState( paths[0]);
if ( fstate != null) {
// Check if the path is to a pseudo file
PseudoFile pfile = getPseudoFileInterface(ctx).getPseudoFile( sess, tree, name);
if ( pfile != null)
{
// Delete the pseudo file
getPseudoFileInterface( ctx).deletePseudoFile( sess, tree, name);
return;
}
}
}
}
// Check if there is a quota manager enabled, if so then we need to save the current file size
final QuotaManager quotaMgr = ctx.getQuotaManager();
@@ -3567,16 +3207,6 @@ public class ContentDiskDriver extends AlfrescoTxDiskDriver implements DiskInter
try
{
// Check if pseudo files are enabled
if ( hasPseudoFileInterface(ctx) &&
getPseudoFileInterface(ctx).isPseudoFile( sess, tree, name))
{
// Allow the file information to be changed
return;
}
final FileState fstate = getStateForPath(tree, name);
doInWriteTransaction(sess, new CallableIO<Pair<Boolean, Boolean>>(){
@@ -3824,16 +3454,16 @@ public class ContentDiskDriver extends AlfrescoTxDiskDriver implements DiskInter
/**
* Read a block of data from the specified file.
*
* @param sess Session details
* @param tree Tree connection
* @param file Network file
* @param buffer Buffer to return data to
* @param bufferPosition Starting position in the return buffer
* @param size Maximum size of data to return
* @param fileOffset File offset to read data
* @return Number of bytes read
* @exception java.io.IOException The exception description.
*/
* @param sess Session details
* @param tree Tree connection
* @param file Network file
* @param buffer Buffer to return data to
* @param bufferPosition Starting position in the return buffer
* @param size Maximum size of data to return
* @param fileOffset File offset to read data
* @return Number of bytes read
* @exception java.io.IOException The exception description.
*/
public int readFile(
SrvSession sess, TreeConnection tree, NetworkFile file,
byte[] buffer, int bufferPosition, int size, long fileOffset) throws IOException
@@ -3907,16 +3537,16 @@ public class ContentDiskDriver extends AlfrescoTxDiskDriver implements DiskInter
/**
* Write a block of data to the file.
*
* @param sess Server session
* @param tree Tree connection
* @param file Network file details
* @param buffer byte[] Data to be written
* @param bufferOffset Offset within the buffer that the data starts
* @param size int Data length
* @param fileOffset Position within the file that the data is to be written.
* @return Number of bytes actually written
* @exception java.io.IOException The exception description.
*/
* @param sess Server session
* @param tree Tree connection
* @param file Network file details
* @param buffer byte[] Data to be written
* @param bufferOffset Offset within the buffer that the data starts
* @param size int Data length
* @param fileOffset Position within the file that the data is to be written.
* @return Number of bytes actually written
* @exception java.io.IOException The exception description.
*/
public int writeFile(SrvSession sess, TreeConnection tree, NetworkFile file,
byte[] buffer, int bufferOffset, int size, long fileOffset) throws IOException
{