Search in sources :

Example 6 with OperationMethod

use of org.nuxeo.ecm.automation.core.annotations.OperationMethod in project nuxeo-drive-server by nuxeo.

the class NuxeoDriveGetChildren method run.

@OperationMethod
public Blob run() throws IOException {
    FileSystemItemManager fileSystemItemManager = Framework.getService(FileSystemItemManager.class);
    List<FileSystemItem> children = fileSystemItemManager.getChildren(id, ctx.getPrincipal());
    return Blobs.createJSONBlobFromValue(children);
}
Also used : FileSystemItemManager(org.nuxeo.drive.service.FileSystemItemManager) FileSystemItem(org.nuxeo.drive.adapter.FileSystemItem) OperationMethod(org.nuxeo.ecm.automation.core.annotations.OperationMethod)

Example 7 with OperationMethod

use of org.nuxeo.ecm.automation.core.annotations.OperationMethod in project nuxeo-drive-server by nuxeo.

the class NuxeoDriveFileSystemItemExists method run.

@OperationMethod
public Blob run() throws IOException {
    FileSystemItemManager fileSystemItemManager = Framework.getService(FileSystemItemManager.class);
    boolean exists = fileSystemItemManager.exists(id, ctx.getPrincipal());
    return Blobs.createJSONBlobFromValue(exists);
}
Also used : FileSystemItemManager(org.nuxeo.drive.service.FileSystemItemManager) OperationMethod(org.nuxeo.ecm.automation.core.annotations.OperationMethod)

Example 8 with OperationMethod

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

Example 9 with OperationMethod

use of org.nuxeo.ecm.automation.core.annotations.OperationMethod in project nuxeo-drive-server by nuxeo.

the class NuxeoDriveMove method run.

@OperationMethod
public Blob run() throws InvalidOperationException, IOException {
    FileSystemItemManager fileSystemItemManager = Framework.getService(FileSystemItemManager.class);
    FileSystemItem fsItem;
    try {
        fsItem = fileSystemItemManager.move(srcId, destId, ctx.getPrincipal());
    } catch (UnsupportedOperationException e) {
        throw new InvalidOperationException(e);
    }
    return Blobs.createJSONBlobFromValue(fsItem);
}
Also used : FileSystemItemManager(org.nuxeo.drive.service.FileSystemItemManager) FileSystemItem(org.nuxeo.drive.adapter.FileSystemItem) InvalidOperationException(org.nuxeo.ecm.automation.InvalidOperationException) OperationMethod(org.nuxeo.ecm.automation.core.annotations.OperationMethod)

Example 10 with OperationMethod

use of org.nuxeo.ecm.automation.core.annotations.OperationMethod in project nuxeo-drive-server by nuxeo.

the class NuxeoDriveCreateTestDocuments method run.

@OperationMethod
public Blob run(DocumentModel parent) throws Exception {
    NuxeoDriveIntegrationTestsHelper.checkOperationAllowed();
    FileManager fileManager = Framework.getService(FileManager.class);
    for (int i = 0; i < number; i++) {
        String name = String.format(namePattern, i);
        Blob content = new StringBlob(String.format(contentPattern, i));
        content.setFilename(name);
        fileManager.createDocumentFromBlob(session, content, parent.getPathAsString(), false, name);
        if (delay > 0) {
            Thread.sleep(delay);
        }
    }
    return new StringBlob(number.toString(), "text/plain");
}
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) FileManager(org.nuxeo.ecm.platform.filemanager.api.FileManager) OperationMethod(org.nuxeo.ecm.automation.core.annotations.OperationMethod)

Aggregations

OperationMethod (org.nuxeo.ecm.automation.core.annotations.OperationMethod)20 FileSystemItemManager (org.nuxeo.drive.service.FileSystemItemManager)12 FileSystemItem (org.nuxeo.drive.adapter.FileSystemItem)5 NuxeoDriveManager (org.nuxeo.drive.service.NuxeoDriveManager)3 FileItem (org.nuxeo.drive.adapter.FileItem)2 FolderItem (org.nuxeo.drive.adapter.FolderItem)2 FileSystemItemAdapterService (org.nuxeo.drive.service.FileSystemItemAdapterService)2 InvalidOperationException (org.nuxeo.ecm.automation.InvalidOperationException)2 URL (java.net.URL)1 SimpleDateFormat (java.text.SimpleDateFormat)1 Calendar (java.util.Calendar)1 Map (java.util.Map)1 Set (java.util.Set)1 HttpServletRequest (javax.servlet.http.HttpServletRequest)1 RootlessItemException (org.nuxeo.drive.adapter.RootlessItemException)1 ScrollFileSystemItemList (org.nuxeo.drive.adapter.ScrollFileSystemItemList)1 FileSystemChangeSummary (org.nuxeo.drive.service.FileSystemChangeSummary)1 SynchronizationRoots (org.nuxeo.drive.service.SynchronizationRoots)1 VersioningFileSystemItemFactory (org.nuxeo.drive.service.VersioningFileSystemItemFactory)1 FileSystemItemAdapterServiceImpl (org.nuxeo.drive.service.impl.FileSystemItemAdapterServiceImpl)1