Search in sources :

Example 1 with Context

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);
}
Also used : FacesContext(javax.faces.context.FacesContext) Context(org.jboss.seam.contexts.Context) DocumentModelList(org.nuxeo.ecm.core.api.DocumentModelList) IdRef(org.nuxeo.ecm.core.api.IdRef) NuxeoDriveManager(org.nuxeo.drive.service.NuxeoDriveManager) DocumentModel(org.nuxeo.ecm.core.api.DocumentModel) Factory(org.jboss.seam.annotations.Factory) LogFactory(org.apache.commons.logging.LogFactory)

Aggregations

FacesContext (javax.faces.context.FacesContext)1 LogFactory (org.apache.commons.logging.LogFactory)1 Factory (org.jboss.seam.annotations.Factory)1 Context (org.jboss.seam.contexts.Context)1 NuxeoDriveManager (org.nuxeo.drive.service.NuxeoDriveManager)1 DocumentModel (org.nuxeo.ecm.core.api.DocumentModel)1 DocumentModelList (org.nuxeo.ecm.core.api.DocumentModelList)1 IdRef (org.nuxeo.ecm.core.api.IdRef)1