use of org.jboss.seam.contexts.Context in project nuxeo-drive-server by nuxeo.
the class NuxeoDriveActions method getCurrentSynchronizationRoot.
@Factory(value = CURRENT_SYNCHRONIZATION_ROOT, scope = ScopeType.EVENT)
public DocumentModel getCurrentSynchronizationRoot() {
// Use the event context as request cache
Context cache = Contexts.getEventContext();
Boolean isUnderSync = (Boolean) cache.get(IS_UNDER_SYNCHRONIZATION_ROOT);
if (isUnderSync == null) {
NuxeoDriveManager driveManager = Framework.getService(NuxeoDriveManager.class);
Set<IdRef> references = driveManager.getSynchronizationRootReferences(documentManager);
DocumentModelList path = navigationContext.getCurrentPath();
DocumentModel root = null;
// considered the current synchronization root
for (DocumentModel parent : path) {
if (references.contains(parent.getRef())) {
root = parent;
break;
}
}
cache.set(CURRENT_SYNCHRONIZATION_ROOT, root);
cache.set(IS_UNDER_SYNCHRONIZATION_ROOT, root != null);
}
return (DocumentModel) cache.get(CURRENT_SYNCHRONIZATION_ROOT);
}
Aggregations