mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-24 17:32:48 +00:00
Added delete file and mark for delete support for pseudo files.
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@2321 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -51,9 +51,11 @@ import org.alfresco.filesys.smb.server.SMBSrvSession;
|
||||
import org.alfresco.filesys.smb.server.repo.FileState.FileStateStatus;
|
||||
import org.alfresco.filesys.smb.server.repo.pseudo.ContentPseudoFileImpl;
|
||||
import org.alfresco.filesys.smb.server.repo.pseudo.LocalPseudoFile;
|
||||
import org.alfresco.filesys.smb.server.repo.pseudo.MemoryNetworkFile;
|
||||
import org.alfresco.filesys.smb.server.repo.pseudo.PseudoFile;
|
||||
import org.alfresco.filesys.smb.server.repo.pseudo.PseudoFileInterface;
|
||||
import org.alfresco.filesys.smb.server.repo.pseudo.PseudoFileList;
|
||||
import org.alfresco.filesys.smb.server.repo.pseudo.PseudoNetworkFile;
|
||||
import org.alfresco.filesys.util.DataBuffer;
|
||||
import org.alfresco.filesys.util.WildCard;
|
||||
import org.alfresco.model.ContentModel;
|
||||
@@ -1333,40 +1335,59 @@ public class ContentDiskDriver implements DiskInterface, IOCtlInterface
|
||||
|
||||
// Remove the node if marked for delete
|
||||
|
||||
if (file.hasDeleteOnClose() && file instanceof ContentNetworkFile)
|
||||
if (file.hasDeleteOnClose())
|
||||
{
|
||||
ContentNetworkFile contentNetFile = (ContentNetworkFile) file;
|
||||
NodeRef nodeRef = contentNetFile.getNodeRef();
|
||||
// Check if the file is a content file
|
||||
|
||||
// We don't know how long the network file has had the reference, so check for existence
|
||||
|
||||
if (nodeService.exists(nodeRef))
|
||||
if ( file instanceof ContentNetworkFile)
|
||||
{
|
||||
try
|
||||
ContentNetworkFile contentNetFile = (ContentNetworkFile) file;
|
||||
NodeRef nodeRef = contentNetFile.getNodeRef();
|
||||
|
||||
// We don't know how long the network file has had the reference, so check for existence
|
||||
|
||||
if (nodeService.exists(nodeRef))
|
||||
{
|
||||
// Delete the file
|
||||
try
|
||||
{
|
||||
// Delete the file
|
||||
|
||||
nodeService.deleteNode(nodeRef);
|
||||
nodeService.deleteNode(nodeRef);
|
||||
|
||||
// Remove the file state
|
||||
// Remove the file state
|
||||
|
||||
if ( ctx.hasStateTable())
|
||||
ctx.getStateTable().removeFileState(file.getFullName());
|
||||
if ( ctx.hasStateTable())
|
||||
ctx.getStateTable().removeFileState(file.getFullName());
|
||||
}
|
||||
catch (org.alfresco.repo.security.permissions.AccessDeniedException ex)
|
||||
{
|
||||
// Debug
|
||||
|
||||
if ( logger.isDebugEnabled())
|
||||
logger.debug("Delete on close - access denied, " + file.getFullName());
|
||||
|
||||
// Convert to a filesystem access denied exception
|
||||
|
||||
throw new AccessDeniedException("Delete on close " + file.getFullName());
|
||||
}
|
||||
}
|
||||
catch (org.alfresco.repo.security.permissions.AccessDeniedException ex)
|
||||
}
|
||||
else if ( file instanceof PseudoNetworkFile ||
|
||||
file instanceof MemoryNetworkFile)
|
||||
{
|
||||
// Delete the pseudo file
|
||||
|
||||
if ( hasPseudoFileInterface())
|
||||
{
|
||||
// Debug
|
||||
// Delete the pseudo file
|
||||
|
||||
if ( logger.isDebugEnabled())
|
||||
logger.debug("Delete on close - access denied, " + file.getFullName());
|
||||
|
||||
// Convert to a filesystem access denied exception
|
||||
|
||||
throw new AccessDeniedException("Delete on close " + file.getFullName());
|
||||
getPseudoFileInterface().deletePseudoFile( sess, tree, file.getFullName());
|
||||
}
|
||||
}
|
||||
}
|
||||
// done
|
||||
|
||||
// DEBUG
|
||||
|
||||
if (logger.isDebugEnabled())
|
||||
{
|
||||
logger.debug("Closed file: \n" +
|
||||
@@ -1634,6 +1655,16 @@ public class ContentDiskDriver implements DiskInterface, IOCtlInterface
|
||||
{
|
||||
try
|
||||
{
|
||||
// Check if pseudo files are enabled
|
||||
|
||||
if ( hasPseudoFileInterface() &&
|
||||
getPseudoFileInterface().isPseudoFile( sess, tree, name))
|
||||
{
|
||||
// Allow the file information to be changed
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// Get the file/folder node
|
||||
|
||||
NodeRef nodeRef = getNodeForPath(tree, name);
|
||||
|
@@ -45,7 +45,7 @@ public class FileState
|
||||
// File state constants
|
||||
|
||||
public final static long NoTimeout = -1L;
|
||||
public final static long DefTimeout = 5 * 60000L; // 5 minutes
|
||||
public final static long DefTimeout = 2 * 60000L; // 2 minutes
|
||||
public final static long RenameTimeout = 1 * 60000L; // 1 minute
|
||||
|
||||
// File status
|
||||
@@ -324,7 +324,9 @@ public class FileState
|
||||
*/
|
||||
public final boolean hasPseudoFiles()
|
||||
{
|
||||
return m_pseudoFiles != null ? true : false;
|
||||
if ( m_pseudoFiles != null)
|
||||
return m_pseudoFiles.numberOfFiles() > 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -196,6 +196,34 @@ public class ContentPseudoFileImpl implements PseudoFileInterface
|
||||
return pseudoCnt;
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a pseudo file
|
||||
*
|
||||
* @param sess SrvSession
|
||||
* @param tree TreeConnection
|
||||
* @param path String
|
||||
*/
|
||||
public void deletePseudoFile(SrvSession sess, TreeConnection tree, String path)
|
||||
{
|
||||
// Access the device context
|
||||
|
||||
ContentContext ctx = (ContentContext) tree.getContext();
|
||||
|
||||
// Get the file state for the parent folder
|
||||
|
||||
String[] paths = FileName.splitPath( path);
|
||||
FileState fstate = getStateForPath( ctx, paths[0]);
|
||||
|
||||
// Check if the folder has any pseudo files
|
||||
|
||||
if ( fstate == null || fstate.hasPseudoFiles() == false)
|
||||
return;
|
||||
|
||||
// Remove the pseudo file from the list
|
||||
|
||||
fstate.getPseudoFileList().removeFile( paths[1], false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the file state for the specified path
|
||||
*
|
||||
|
@@ -17,9 +17,7 @@
|
||||
|
||||
package org.alfresco.filesys.smb.server.repo.pseudo;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.RandomAccessFile;
|
||||
|
||||
import org.alfresco.filesys.server.filesys.AccessDeniedException;
|
||||
import org.alfresco.filesys.server.filesys.FileInfo;
|
||||
|
@@ -18,8 +18,6 @@
|
||||
package org.alfresco.filesys.smb.server.repo.pseudo;
|
||||
|
||||
import org.alfresco.filesys.server.SrvSession;
|
||||
import org.alfresco.filesys.server.filesys.DiskDeviceContext;
|
||||
import org.alfresco.filesys.server.filesys.DiskInterface;
|
||||
import org.alfresco.filesys.server.filesys.TreeConnection;
|
||||
|
||||
/**
|
||||
@@ -60,4 +58,13 @@ public interface PseudoFileInterface
|
||||
* @return int
|
||||
*/
|
||||
public int addPseudoFilesToFolder(SrvSession sess, TreeConnection tree, String path);
|
||||
|
||||
/**
|
||||
* Delete a pseudo file
|
||||
*
|
||||
* @param sess SrvSession
|
||||
* @param tree TreeConnection
|
||||
* @param path String
|
||||
*/
|
||||
public void deletePseudoFile(SrvSession sess, TreeConnection tree, String path);
|
||||
}
|
||||
|
@@ -102,4 +102,46 @@ public class PseudoFileList
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified pseudo file from the list
|
||||
*
|
||||
* @param fname String
|
||||
* @param caseSensitive boolean
|
||||
* @return PseudoFile
|
||||
*/
|
||||
public final PseudoFile removeFile( String fname, boolean caseSensitive)
|
||||
{
|
||||
// Check if there are any entries in the list
|
||||
|
||||
if ( m_list == null || m_list.size() == 0)
|
||||
return null;
|
||||
|
||||
// Search for the name match
|
||||
|
||||
for ( int idx = 0; idx < m_list.size(); idx++)
|
||||
{
|
||||
// Get the current pseudo file
|
||||
|
||||
PseudoFile pfile = m_list.get( idx);
|
||||
boolean match = false;
|
||||
|
||||
if ( caseSensitive && pfile.getFileName().equals( fname))
|
||||
match = true;
|
||||
else if ( pfile.getFileName().equalsIgnoreCase( fname))
|
||||
match = true;
|
||||
|
||||
// If we found the matching pseudo file remove it from the list
|
||||
|
||||
if ( match)
|
||||
{
|
||||
m_list.remove( idx);
|
||||
return pfile;
|
||||
}
|
||||
}
|
||||
|
||||
// File not found
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user