-
Type: Bug
-
Status: Resolved
-
Priority: Major
-
Resolution: Fixed
-
Affects Version/s: 5.7.2
-
Fix Version/s: 5.6.0-HF27, 5.8.0-HF01, 5.9.1
-
Component/s: Nuxeo Drive
-
Tags:
-
Backlog priority:600
Using the service method:
driveManager.unregisterSynchronizationRoot( new NuxeoPrincipalImpl( (String) subscription.get("username")), doc, session);
It works if the principal of the coreSession is the same principal passed as the method argument.
A usecase could be a scheduler that needs to unregister all root folders that hasn't been changed since 2 months.
The scheduler would use an unrestricted session to make the query and would get the principal username through drive:subscriptions schema.
The unregistration is just working fine but AbstractSyncRootFolderItemFactory [line: 120] - isFileSystemItem(DocumentModel, boolean)
Principal principal = doc.getCoreSession().getPrincipal();
boolean isSyncRoot = nuxeoDriveManager.isSynchronizationRoot(principal,
doc);
is not using the principal passed as argument of the unregister method. In our usecase, system user is used instead and this user doesn't have any synchronizationRoot indeed.
The result is that the audit logging is never done and the Drive client is not updated. A RootlessItemException is thrown (see NuxeoDriveFileSystemDeletionListener [line: 98] - logDeletionEvent(DocumentModel, Principal, String))
FileSystemItem fsItem = null; try { fsItem = Framework.getLocalService( FileSystemItemAdapterService.class).getFileSystemItem(doc, true); } catch (RootlessItemException e) { // can happen when deleting a folder under and unregistered root: // nothing to do return; } if (fsItem == null) { return; } LogEntry entry = logger.newLogEntry(); entry.setEventId(NuxeoDriveEvents.DELETED_EVENT); ...
A good fix would be to add a Principal arguments to org.nuxeo.drive.service.FileSystemItemFactory.getFileSystemItem(DocumentModel)
We can also keep the current method and if no Principal is provided, use the coresession ones so we don't break to much things.