use of org.nuxeo.ecm.core.api.impl.DocumentModelListImpl 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.ecm.core.api.impl.DocumentModelListImpl 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;
}
Aggregations