mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Merge 3.1 to HEAD:
14099 Repository filesystem handles file sharing mode options on file create/open calls. ETHREEOH-1954 git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@14108 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -1360,12 +1360,45 @@ public class ContentDiskDriver extends AlfrescoDiskDriver implements DiskInterfa
|
||||
if ( fstate.exists() == false)
|
||||
throw new FileNotFoundException();
|
||||
|
||||
// Check if the open request shared access indicates exclusive file access
|
||||
// Check the file sharing mode
|
||||
|
||||
if ( fstate != null && params.getSharedAccess() == SharingMode.NOSHARING &&
|
||||
fstate.getOpenCount() > 0)
|
||||
if ( fstate != null) {
|
||||
|
||||
// Check if the current file open allows the required shared access
|
||||
|
||||
boolean nosharing = false;
|
||||
|
||||
if ( fstate.getOpenCount() > 0) {
|
||||
|
||||
// Check if the file has been opened for exclusive access
|
||||
|
||||
if ( fstate.getSharedAccess() == SharingMode.NOSHARING)
|
||||
nosharing = true;
|
||||
|
||||
// Check if the required sharing mode is allowed by the current file open
|
||||
|
||||
else if ( ( fstate.getSharedAccess() & params.getSharedAccess()) != params.getSharedAccess())
|
||||
nosharing = true;
|
||||
|
||||
// Check if the caller wants exclusive access to the file
|
||||
|
||||
else if ( params.getSharedAccess() == SharingMode.NOSHARING)
|
||||
nosharing = true;
|
||||
}
|
||||
|
||||
// Check if the file allows shared access
|
||||
|
||||
if ( nosharing == true)
|
||||
{
|
||||
if ( params.getPath().equals( "\\") == false)
|
||||
throw new FileSharingException("File already open, " + params.getPath());
|
||||
}
|
||||
|
||||
// Update the file sharing mode, if this is the first file open
|
||||
|
||||
fstate.setSharedAccess( params.getSharedAccess());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Check if the node is a link node
|
||||
@@ -1588,6 +1621,10 @@ public class ContentDiskDriver extends AlfrescoDiskDriver implements DiskInterfa
|
||||
FileState fstate = ctx.getStateTable().findFileState(params.getPath(), false, true);
|
||||
if ( fstate != null)
|
||||
{
|
||||
// Save the file sharing mode, needs to be done before the open count is incremented
|
||||
|
||||
fstate.setSharedAccess( params.getSharedAccess());
|
||||
|
||||
// Indicate that the file is open
|
||||
|
||||
fstate.setFileStatus(FileStateStatus.FileExists);
|
||||
@@ -1869,8 +1906,13 @@ public class ContentDiskDriver extends AlfrescoDiskDriver implements DiskInterfa
|
||||
if ( ctx.hasStateTable())
|
||||
{
|
||||
FileState fstate = ctx.getStateTable().findFileState(file.getFullName());
|
||||
if ( fstate != null)
|
||||
fstate.decrementOpenCount();
|
||||
if ( fstate != null) {
|
||||
|
||||
// If the file open count is now zero then reset the stored sharing mode
|
||||
|
||||
if ( fstate.decrementOpenCount() == 0)
|
||||
fstate.setSharedAccess( SharingMode.READWRITE + SharingMode.DELETE);
|
||||
}
|
||||
}
|
||||
|
||||
// Defer to the network file to close the stream and remove the content
|
||||
@@ -2087,6 +2129,10 @@ public class ContentDiskDriver extends AlfrescoDiskDriver implements DiskInterfa
|
||||
// Check if there is a renamed state for the new file
|
||||
|
||||
if ( renState.getFileStatus() == FileStateStatus.Renamed)
|
||||
{
|
||||
// Check if the renamed node still exists
|
||||
|
||||
if ( nodeService.exists( renState.getNodeRef()))
|
||||
{
|
||||
// DEBUG
|
||||
|
||||
@@ -2104,10 +2150,6 @@ public class ContentDiskDriver extends AlfrescoDiskDriver implements DiskInterfa
|
||||
if ( renState.hasRenameState())
|
||||
renState.getRenameState().setNodeRef(nodeToMoveRef);
|
||||
|
||||
// Remove the file state for the old file name
|
||||
|
||||
ctx.getStateTable().removeFileState(oldName);
|
||||
|
||||
// Get, or create, a file state for the new file path
|
||||
|
||||
FileState fstate = ctx.getStateTable().findFileState(newName, false, true);
|
||||
@@ -2115,6 +2157,11 @@ public class ContentDiskDriver extends AlfrescoDiskDriver implements DiskInterfa
|
||||
fstate.setNodeRef(renState.getNodeRef());
|
||||
fstate.setFileStatus(FileStateStatus.FileExists);
|
||||
}
|
||||
|
||||
// Remove the file state for the old file name
|
||||
|
||||
ctx.getStateTable().removeFileState(oldName);
|
||||
}
|
||||
else if ( renState.getFileStatus() == FileStateStatus.DeleteOnClose)
|
||||
{
|
||||
// DEBUG
|
||||
@@ -2410,6 +2457,18 @@ public class ContentDiskDriver extends AlfrescoDiskDriver implements DiskInterfa
|
||||
throw new AccessDeniedException("Node locked, cannot mark for delete");
|
||||
}
|
||||
|
||||
// Check if a folder is being marked for delete
|
||||
|
||||
// Get the node for the folder
|
||||
|
||||
if (fileFolderService.exists(nodeRef))
|
||||
{
|
||||
// Check if the folder is empty
|
||||
|
||||
if ( cifsHelper.isFolderEmpty( nodeRef) == false)
|
||||
throw new DirectoryNotEmptyException( name);
|
||||
}
|
||||
|
||||
// Update the change date/time
|
||||
|
||||
if ( fstate != null)
|
||||
|
@@ -77,7 +77,7 @@ public class FileState
|
||||
|
||||
// Sharing mode
|
||||
|
||||
private int m_sharedAccess = SharingMode.READWRITE;
|
||||
private int m_sharedAccess = SharingMode.READWRITE + SharingMode.DELETE;
|
||||
|
||||
// File lock list, allocated once there are active locks on this file
|
||||
|
||||
@@ -716,6 +716,9 @@ public class FileState
|
||||
else
|
||||
str.append("Null");
|
||||
|
||||
str.append(",Shr=0x");
|
||||
str.append(Integer.toHexString(getSharedAccess()));
|
||||
|
||||
if ( isDirectory())
|
||||
{
|
||||
str.append(",Pseudo=");
|
||||
|
Reference in New Issue
Block a user