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,11 +1360,44 @@ public class ContentDiskDriver extends AlfrescoDiskDriver implements DiskInterfa
|
|||||||
if ( fstate.exists() == false)
|
if ( fstate.exists() == false)
|
||||||
throw new FileNotFoundException();
|
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 &&
|
if ( fstate != null) {
|
||||||
fstate.getOpenCount() > 0)
|
|
||||||
throw new FileSharingException("File already open, " + params.getPath());
|
// 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());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1588,6 +1621,10 @@ public class ContentDiskDriver extends AlfrescoDiskDriver implements DiskInterfa
|
|||||||
FileState fstate = ctx.getStateTable().findFileState(params.getPath(), false, true);
|
FileState fstate = ctx.getStateTable().findFileState(params.getPath(), false, true);
|
||||||
if ( fstate != null)
|
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
|
// Indicate that the file is open
|
||||||
|
|
||||||
fstate.setFileStatus(FileStateStatus.FileExists);
|
fstate.setFileStatus(FileStateStatus.FileExists);
|
||||||
@@ -1869,8 +1906,13 @@ public class ContentDiskDriver extends AlfrescoDiskDriver implements DiskInterfa
|
|||||||
if ( ctx.hasStateTable())
|
if ( ctx.hasStateTable())
|
||||||
{
|
{
|
||||||
FileState fstate = ctx.getStateTable().findFileState(file.getFullName());
|
FileState fstate = ctx.getStateTable().findFileState(file.getFullName());
|
||||||
if ( fstate != null)
|
if ( fstate != null) {
|
||||||
fstate.decrementOpenCount();
|
|
||||||
|
// 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
|
// Defer to the network file to close the stream and remove the content
|
||||||
@@ -2088,32 +2130,37 @@ public class ContentDiskDriver extends AlfrescoDiskDriver implements DiskInterfa
|
|||||||
|
|
||||||
if ( renState.getFileStatus() == FileStateStatus.Renamed)
|
if ( renState.getFileStatus() == FileStateStatus.Renamed)
|
||||||
{
|
{
|
||||||
// DEBUG
|
// Check if the renamed node still exists
|
||||||
|
|
||||||
if ( logger.isDebugEnabled())
|
if ( nodeService.exists( renState.getNodeRef()))
|
||||||
logger.debug(" Found rename state, relinking, " + renState);
|
{
|
||||||
|
// DEBUG
|
||||||
// Relink the new version of the file data to the previously renamed node so that it
|
|
||||||
// picks up version history and other settings.
|
if ( logger.isDebugEnabled())
|
||||||
|
logger.debug(" Found rename state, relinking, " + renState);
|
||||||
cifsHelper.relinkNode( renState.getNodeRef(), nodeToMoveRef, targetFolderRef, name);
|
|
||||||
relinked = true;
|
// Relink the new version of the file data to the previously renamed node so that it
|
||||||
|
// picks up version history and other settings.
|
||||||
// Link the node ref for the associated rename state
|
|
||||||
|
cifsHelper.relinkNode( renState.getNodeRef(), nodeToMoveRef, targetFolderRef, name);
|
||||||
if ( renState.hasRenameState())
|
relinked = true;
|
||||||
renState.getRenameState().setNodeRef(nodeToMoveRef);
|
|
||||||
|
// Link the node ref for the associated rename state
|
||||||
// Remove the file state for the old file name
|
|
||||||
|
if ( renState.hasRenameState())
|
||||||
|
renState.getRenameState().setNodeRef(nodeToMoveRef);
|
||||||
|
|
||||||
|
// Get, or create, a file state for the new file path
|
||||||
|
|
||||||
|
FileState fstate = ctx.getStateTable().findFileState(newName, false, true);
|
||||||
|
|
||||||
|
fstate.setNodeRef(renState.getNodeRef());
|
||||||
|
fstate.setFileStatus(FileStateStatus.FileExists);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Remove the file state for the old file name
|
||||||
|
|
||||||
ctx.getStateTable().removeFileState(oldName);
|
ctx.getStateTable().removeFileState(oldName);
|
||||||
|
|
||||||
// Get, or create, a file state for the new file path
|
|
||||||
|
|
||||||
FileState fstate = ctx.getStateTable().findFileState(newName, false, true);
|
|
||||||
|
|
||||||
fstate.setNodeRef(renState.getNodeRef());
|
|
||||||
fstate.setFileStatus(FileStateStatus.FileExists);
|
|
||||||
}
|
}
|
||||||
else if ( renState.getFileStatus() == FileStateStatus.DeleteOnClose)
|
else if ( renState.getFileStatus() == FileStateStatus.DeleteOnClose)
|
||||||
{
|
{
|
||||||
@@ -2410,6 +2457,18 @@ public class ContentDiskDriver extends AlfrescoDiskDriver implements DiskInterfa
|
|||||||
throw new AccessDeniedException("Node locked, cannot mark for delete");
|
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
|
// Update the change date/time
|
||||||
|
|
||||||
if ( fstate != null)
|
if ( fstate != null)
|
||||||
|
@@ -77,7 +77,7 @@ public class FileState
|
|||||||
|
|
||||||
// Sharing mode
|
// 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
|
// File lock list, allocated once there are active locks on this file
|
||||||
|
|
||||||
@@ -716,6 +716,9 @@ public class FileState
|
|||||||
else
|
else
|
||||||
str.append("Null");
|
str.append("Null");
|
||||||
|
|
||||||
|
str.append(",Shr=0x");
|
||||||
|
str.append(Integer.toHexString(getSharedAccess()));
|
||||||
|
|
||||||
if ( isDirectory())
|
if ( isDirectory())
|
||||||
{
|
{
|
||||||
str.append(",Pseudo=");
|
str.append(",Pseudo=");
|
||||||
|
Reference in New Issue
Block a user