Search in sources :

Example 1 with Factory

use of org.jboss.seam.annotations.Factory 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)

Example 2 with Factory

use of org.jboss.seam.annotations.Factory in project nuxeo-drive-server by nuxeo.

the class NuxeoDriveActions method canNavigateToCurrentSynchronizationRoot.

@Factory(value = "canNavigateToCurrentSynchronizationRoot")
public boolean canNavigateToCurrentSynchronizationRoot() {
    @SuppressWarnings("hiding") DocumentModel currentDocument = navigationContext.getCurrentDocument();
    if (currentDocument == null) {
        return false;
    }
    if (currentDocument.isTrashed()) {
        return false;
    }
    DocumentRef currentDocRef = currentDocument.getRef();
    DocumentModel currentSyncRoot = getCurrentSynchronizationRoot();
    if (currentSyncRoot == null) {
        return false;
    }
    return !currentDocRef.equals(currentSyncRoot.getRef());
}
Also used : DocumentRef(org.nuxeo.ecm.core.api.DocumentRef) DocumentModel(org.nuxeo.ecm.core.api.DocumentModel) Factory(org.jboss.seam.annotations.Factory) LogFactory(org.apache.commons.logging.LogFactory)

Example 3 with Factory

use of org.jboss.seam.annotations.Factory in project nuxeo-drive-server by nuxeo.

the class NuxeoDriveActions method canUnSynchronizeCurrentDocument.

@Factory(value = "canUnSynchronizeCurrentDocument")
public boolean canUnSynchronizeCurrentDocument() {
    @SuppressWarnings("hiding") DocumentModel currentDocument = navigationContext.getCurrentDocument();
    if (currentDocument == null) {
        return false;
    }
    if (!isSyncRootCandidate(currentDocument)) {
        return false;
    }
    DocumentRef currentDocRef = currentDocument.getRef();
    DocumentModel currentSyncRoot = getCurrentSynchronizationRoot();
    if (currentSyncRoot == null) {
        return false;
    }
    return currentDocRef.equals(currentSyncRoot.getRef());
}
Also used : DocumentRef(org.nuxeo.ecm.core.api.DocumentRef) DocumentModel(org.nuxeo.ecm.core.api.DocumentModel) Factory(org.jboss.seam.annotations.Factory) LogFactory(org.apache.commons.logging.LogFactory)

Aggregations

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