Search in sources :

Example 11 with NuxeoDriveManager

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();
}
Also used : StringBlob(org.nuxeo.ecm.core.api.impl.blob.StringBlob) Blob(org.nuxeo.ecm.core.api.Blob) StringBlob(org.nuxeo.ecm.core.api.impl.blob.StringBlob) NuxeoDriveManager(org.nuxeo.drive.service.NuxeoDriveManager)

Example 12 with NuxeoDriveManager

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);
}
Also used : NuxeoDriveManager(org.nuxeo.drive.service.NuxeoDriveManager) Principal(java.security.Principal)

Example 13 with NuxeoDriveManager

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();
    }
}
Also used : NuxeoDriveManager(org.nuxeo.drive.service.NuxeoDriveManager) Principal(java.security.Principal) DocumentModel(org.nuxeo.ecm.core.api.DocumentModel)

Example 14 with NuxeoDriveManager

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;
}
Also used : NuxeoDriveManager(org.nuxeo.drive.service.NuxeoDriveManager) OperationMethod(org.nuxeo.ecm.automation.core.annotations.OperationMethod)

Aggregations

NuxeoDriveManager (org.nuxeo.drive.service.NuxeoDriveManager)14 Principal (java.security.Principal)6 IdRef (org.nuxeo.ecm.core.api.IdRef)4 OperationMethod (org.nuxeo.ecm.automation.core.annotations.OperationMethod)3 DocumentModel (org.nuxeo.ecm.core.api.DocumentModel)3 DocumentModelList (org.nuxeo.ecm.core.api.DocumentModelList)3 SynchronizationRoots (org.nuxeo.drive.service.SynchronizationRoots)2 Blob (org.nuxeo.ecm.core.api.Blob)2 DocumentModelListImpl (org.nuxeo.ecm.core.api.impl.DocumentModelListImpl)2 ArrayList (java.util.ArrayList)1 Map (java.util.Map)1 Set (java.util.Set)1 FacesContext (javax.faces.context.FacesContext)1 HttpServletRequest (javax.servlet.http.HttpServletRequest)1 LogFactory (org.apache.commons.logging.LogFactory)1 Factory (org.jboss.seam.annotations.Factory)1 Context (org.jboss.seam.contexts.Context)1 FileSystemChangeSummary (org.nuxeo.drive.service.FileSystemChangeSummary)1 FileSystemItemChange (org.nuxeo.drive.service.FileSystemItemChange)1 TooManyChangesException (org.nuxeo.drive.service.TooManyChangesException)1