use of org.nuxeo.drive.service.NuxeoDriveManager 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.nuxeo.drive.service.NuxeoDriveManager in project nuxeo-drive-server by nuxeo.
the class NuxeoDriveActions method getSynchronizationRoots.
public DocumentModelList getSynchronizationRoots() {
DocumentModelList syncRoots = new DocumentModelListImpl();
NuxeoDriveManager driveManager = Framework.getService(NuxeoDriveManager.class);
Set<IdRef> syncRootRefs = driveManager.getSynchronizationRootReferences(documentManager);
for (IdRef syncRootRef : syncRootRefs) {
syncRoots.add(documentManager.getDocument(syncRootRef));
}
return syncRoots;
}
use of org.nuxeo.drive.service.NuxeoDriveManager in project nuxeo-drive-server by nuxeo.
the class NuxeoDriveActions method unsynchronizeCurrentDocument.
public void unsynchronizeCurrentDocument() {
NuxeoDriveManager driveManager = Framework.getService(NuxeoDriveManager.class);
Principal principal = documentManager.getPrincipal();
DocumentModel syncRoot = navigationContext.getCurrentDocument();
driveManager.unregisterSynchronizationRoot(principal, syncRoot, documentManager);
}
use of org.nuxeo.drive.service.NuxeoDriveManager in project nuxeo-drive-server by nuxeo.
the class NuxeoDriveGetRootsOperation method run.
@OperationMethod
public DocumentModelList run() {
// By default get synchronization roots from all repositories, except if
// a specific repository name is passed as a request header
boolean allRepositories = true;
HttpServletRequest request = (HttpServletRequest) ctx.get("request");
if (request != null) {
String respositoryName = request.getHeader(RenderingContext.REPOSITORY_NAME_REQUEST_HEADER);
if (!StringUtils.isEmpty(respositoryName)) {
allRepositories = false;
}
}
NuxeoDriveManager driveManager = Framework.getService(NuxeoDriveManager.class);
Map<String, SynchronizationRoots> roots = driveManager.getSynchronizationRoots(ctx.getPrincipal());
DocumentModelList rootDocumentModels = new DocumentModelListImpl();
for (Map.Entry<String, SynchronizationRoots> rootsEntry : roots.entrySet()) {
if (session.getRepositoryName().equals(rootsEntry.getKey())) {
Set<IdRef> references = rootsEntry.getValue().getRefs();
rootDocumentModels.addAll(session.getDocuments(references.toArray(new DocumentRef[references.size()])));
} else {
if (allRepositories) {
// XXX: do we really need to implement this now?
throw new RuntimeException("Multi repo roots not yet implemented");
}
}
}
return rootDocumentModels;
}
use of org.nuxeo.drive.service.NuxeoDriveManager in project nuxeo-drive-server by nuxeo.
the class NuxeoDriveGetChangeSummary method run.
@OperationMethod
public Blob run() throws IOException {
NuxeoDriveManager driveManager = Framework.getService(NuxeoDriveManager.class);
Map<String, Set<IdRef>> lastActiveRootRefs = RootDefinitionsHelper.parseRootDefinitions(lastSyncActiveRootDefinitions);
FileSystemChangeSummary docChangeSummary;
if (lastSyncDate >= 0) {
docChangeSummary = driveManager.getChangeSummary(ctx.getPrincipal(), lastActiveRootRefs, lastSyncDate);
} else {
docChangeSummary = driveManager.getChangeSummaryIntegerBounds(ctx.getPrincipal(), lastActiveRootRefs, lowerBound);
}
return Blobs.createJSONBlobFromValue(docChangeSummary);
}
Aggregations