mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-24 17:32:48 +00:00
Fix for AR-565. Checked out files can be edited and saved via CIFS without any warnings being given that the save failed.
Locked files are now marked as read-only, and may also be marked as offline if the <offlineFiles/> config is enabled. An attempt to open a locked file for write returns an access denied status to the CIFS client. There is also a minor fix to the file state caching of folders that are not opened/referenced by the client directly, this caused them to be expire from the cache causing path lookups to require a database hit. The expiry time is now bumped when a folders cached file state is used to find the NodeRef for a path. git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@2948 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -214,16 +214,21 @@ public class CifsHelper
|
|||||||
|
|
||||||
// Check the lock status of the file
|
// Check the lock status of the file
|
||||||
|
|
||||||
if ( hasLockedFilesAsOffline())
|
String lockTypeStr = (String) nodeProperties.get(ContentModel.PROP_LOCK_TYPE);
|
||||||
|
|
||||||
|
if ( lockTypeStr != null)
|
||||||
{
|
{
|
||||||
String lockTypeStr = (String) nodeProperties.get(ContentModel.PROP_LOCK_TYPE);
|
// File is locked so mark it as read-only and offline
|
||||||
|
|
||||||
if ( lockTypeStr != null)
|
int attr = fileInfo.getFileAttributes();
|
||||||
{
|
|
||||||
// File is locked so mark it as offline
|
|
||||||
|
|
||||||
fileInfo.setFileAttributes(fileInfo.getFileAttributes() + FileAttribute.NTOffline);
|
if (( attr & FileAttribute.ReadOnly) == 0)
|
||||||
}
|
attr += FileAttribute.ReadOnly;
|
||||||
|
|
||||||
|
if ( hasLockedFilesAsOffline())
|
||||||
|
attr += FileAttribute.NTOffline;
|
||||||
|
|
||||||
|
fileInfo.setFileAttributes( attr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -519,20 +519,24 @@ public class ContentDiskDriver implements DiskInterface, IOCtlInterface
|
|||||||
{
|
{
|
||||||
// Get the file information for the node
|
// Get the file information for the node
|
||||||
|
|
||||||
|
session.beginTransaction(transactionService, true);
|
||||||
finfo = cifsHelper.getFileInformation(nodeRef);
|
finfo = cifsHelper.getFileInformation(nodeRef);
|
||||||
|
|
||||||
// DEBUG
|
// DEBUG
|
||||||
|
|
||||||
if ( logger.isDebugEnabled())
|
if ( logger.isInfoEnabled())
|
||||||
logger.debug("getInfo using cached noderef for path " + path);
|
logger.debug("getInfo using cached noderef for path " + path);
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the required node was not in the state cache, the parent folder node might be
|
// If the required node was not in the state cache, the parent folder node might be
|
||||||
|
|
||||||
session.beginTransaction(transactionService, true);
|
|
||||||
|
|
||||||
if ( finfo == null)
|
if ( finfo == null)
|
||||||
{
|
{
|
||||||
|
// Start a transaction
|
||||||
|
|
||||||
|
session.beginTransaction(transactionService, true);
|
||||||
|
|
||||||
String[] paths = FileName.splitPath( path);
|
String[] paths = FileName.splitPath( path);
|
||||||
|
|
||||||
if ( paths[0] != null && paths[0].length() > 1)
|
if ( paths[0] != null && paths[0].length() > 1)
|
||||||
@@ -548,7 +552,7 @@ public class ContentDiskDriver implements DiskInterface, IOCtlInterface
|
|||||||
|
|
||||||
// DEBUG
|
// DEBUG
|
||||||
|
|
||||||
if ( logger.isDebugEnabled())
|
if ( logger.isInfoEnabled())
|
||||||
logger.debug("getInfo using cached noderef for parent " + path);
|
logger.debug("getInfo using cached noderef for parent " + path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -907,6 +911,13 @@ public class ContentDiskDriver implements DiskInterface, IOCtlInterface
|
|||||||
permissionService.hasPermission(nodeRef, PermissionService.DELETE) == AccessStatus.DENIED)
|
permissionService.hasPermission(nodeRef, PermissionService.DELETE) == AccessStatus.DENIED)
|
||||||
throw new AccessDeniedException("No delete access to " + params.getFullPath());
|
throw new AccessDeniedException("No delete access to " + params.getFullPath());
|
||||||
|
|
||||||
|
// Check if the file has a lock
|
||||||
|
|
||||||
|
String lockTypeStr = (String) nodeService.getProperty( nodeRef, ContentModel.PROP_LOCK_TYPE);
|
||||||
|
|
||||||
|
if ( params.hasAccessMode(AccessMode.NTWrite) && lockTypeStr != null)
|
||||||
|
throw new AccessDeniedException("File is locked, no write access to " + params.getFullPath());
|
||||||
|
|
||||||
// Check if there is a file state for the file
|
// Check if there is a file state for the file
|
||||||
|
|
||||||
FileState fstate = null;
|
FileState fstate = null;
|
||||||
@@ -1042,7 +1053,7 @@ public class ContentDiskDriver implements DiskInterface, IOCtlInterface
|
|||||||
|
|
||||||
// DEBUG
|
// DEBUG
|
||||||
|
|
||||||
if ( logger.isDebugEnabled())
|
if ( logger.isInfoEnabled())
|
||||||
logger.debug("Create file using cached noderef for path " + paths[0]);
|
logger.debug("Create file using cached noderef for path " + paths[0]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1084,6 +1095,7 @@ public class ContentDiskDriver implements DiskInterface, IOCtlInterface
|
|||||||
" node: " + nodeRef + "\n" +
|
" node: " + nodeRef + "\n" +
|
||||||
" network file: " + netFile);
|
" network file: " + netFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
return netFile;
|
return netFile;
|
||||||
}
|
}
|
||||||
catch (org.alfresco.repo.security.permissions.AccessDeniedException ex)
|
catch (org.alfresco.repo.security.permissions.AccessDeniedException ex)
|
||||||
@@ -1860,6 +1872,12 @@ public class ContentDiskDriver implements DiskInterface, IOCtlInterface
|
|||||||
// check that the node exists
|
// check that the node exists
|
||||||
if (nodeService.exists(fstate.getNodeRef()))
|
if (nodeService.exists(fstate.getNodeRef()))
|
||||||
{
|
{
|
||||||
|
// Bump the file states expiry time
|
||||||
|
|
||||||
|
fstate.setExpiryTime(System.currentTimeMillis() + FileState.DefTimeout);
|
||||||
|
|
||||||
|
// Return the cached noderef
|
||||||
|
|
||||||
return fstate.getNodeRef();
|
return fstate.getNodeRef();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
Reference in New Issue
Block a user