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);
}
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());
}
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());
}
Aggregations