use of org.nuxeo.drive.service.NuxeoDriveManager in project nuxeo-drive-server by nuxeo.
the class TestFileSystemItemAdapterService method registerRootAndCreateSomeDocs.
protected void registerRootAndCreateSomeDocs() throws Exception {
syncRootFolder = session.createDocumentModel("/", "syncRoot", "Folder");
syncRootFolder = session.createDocument(syncRootFolder);
// Register the root folder as sync root
NuxeoDriveManager driveManager = Framework.getService(NuxeoDriveManager.class);
driveManager.registerSynchronizationRoot(session.getPrincipal(), syncRootFolder, session);
syncRootItem = (FolderItem) fileSystemItemAdapterService.getFileSystemItem(syncRootFolder);
syncRootItemId = syncRootItem.getId();
file = session.createDocumentModel(syncRootFolder.getPathAsString(), "aFile", "File");
file.setPropertyValue("dc:creator", "Joe");
file.setPropertyValue("dc:lastContributor", "Joe");
Blob blob = new StringBlob("Content of Joe's file.");
blob.setFilename("Joe's file.txt");
file.setPropertyValue("file:content", (Serializable) blob);
file.putContextData(DocumentValidationService.CTX_MAP_KEY, Forcing.TURN_OFF);
file.putContextData(DublinCoreListener.DISABLE_DUBLINCORE_LISTENER, true);
file = session.createDocument(file);
folder = session.createDocumentModel(syncRootFolder.getPathAsString(), "aFolder", "Folder");
folder.setPropertyValue("dc:title", "Jack's folder");
folder.setPropertyValue("dc:creator", "Jack");
folder.setPropertyValue("dc:lastContributor", "Jack");
folder.putContextData(DocumentValidationService.CTX_MAP_KEY, Forcing.TURN_OFF);
folder.putContextData(DublinCoreListener.DISABLE_DUBLINCORE_LISTENER, true);
folder = session.createDocument(folder);
custom = session.createDocumentModel(syncRootFolder.getPathAsString(), "aCustom", "Custom");
custom.setPropertyValue("dc:creator", "Bonnie");
custom.setPropertyValue("dc:lastContributor", "Bonnie");
blob = new StringBlob("Content of the custom document's blob.");
blob.setFilename("Bonnie's file.txt");
custom.setPropertyValue("file:content", (Serializable) blob);
custom.putContextData(DocumentValidationService.CTX_MAP_KEY, Forcing.TURN_OFF);
custom.putContextData(DublinCoreListener.DISABLE_DUBLINCORE_LISTENER, true);
custom = session.createDocument(custom);
session.save();
}
use of org.nuxeo.drive.service.NuxeoDriveManager in project nuxeo-drive-server by nuxeo.
the class NuxeoDriveActions method unsynchronizeRoot.
public void unsynchronizeRoot(DocumentModel syncRoot) {
NuxeoDriveManager driveManager = Framework.getService(NuxeoDriveManager.class);
Principal principal = documentManager.getPrincipal();
driveManager.unregisterSynchronizationRoot(principal, syncRoot, documentManager);
}
use of org.nuxeo.drive.service.NuxeoDriveManager in project nuxeo-drive-server by nuxeo.
the class NuxeoDriveActions method synchronizeCurrentDocument.
public String synchronizeCurrentDocument() throws UnsupportedEncodingException {
NuxeoDriveManager driveManager = Framework.getService(NuxeoDriveManager.class);
Principal principal = documentManager.getPrincipal();
DocumentModel newSyncRoot = navigationContext.getCurrentDocument();
driveManager.registerSynchronizationRoot(principal, newSyncRoot, documentManager);
boolean hasOneNuxeoDriveToken = hasOneDriveToken(principal);
if (hasOneNuxeoDriveToken) {
return null;
} else {
// redirect to user center
return getUserCenterNuxeoDriveView();
}
}
use of org.nuxeo.drive.service.NuxeoDriveManager in project nuxeo-drive-server by nuxeo.
the class NuxeoDriveAddToLocallyEditedCollection method run.
@OperationMethod
public DocumentModel run(DocumentModel doc) {
NuxeoDriveManager nuxeoDriveManager = Framework.getService(NuxeoDriveManager.class);
nuxeoDriveManager.addToLocallyEditedCollection(session, doc);
return doc;
}
Aggregations