Search in sources :

Example 1 with FileSystemItemChangeImpl

use of org.nuxeo.drive.service.impl.FileSystemItemChangeImpl in project nuxeo-drive-server by nuxeo.

the class MockChangeFinder method getDocumentChanges.

protected List<FileSystemItemChange> getDocumentChanges(CoreSession session, String query, int limit) throws TooManyChangesException {
    List<FileSystemItemChange> docChanges = new ArrayList<FileSystemItemChange>();
    DocumentModelList queryResult = session.query(query, limit);
    if (queryResult.size() >= limit) {
        throw new TooManyChangesException("Too many document changes found in the repository.");
    }
    for (DocumentModel doc : queryResult) {
        String repositoryId = session.getRepositoryName();
        String eventId = "documentChanged";
        long eventDate = ((Calendar) doc.getPropertyValue("dc:modified")).getTimeInMillis();
        String docUuid = doc.getId();
        FileSystemItem fsItem = doc.getAdapter(FileSystemItem.class);
        if (fsItem != null) {
            docChanges.add(new FileSystemItemChangeImpl(eventId, eventDate, repositoryId, docUuid, fsItem));
        }
    }
    return docChanges;
}
Also used : FileSystemItem(org.nuxeo.drive.adapter.FileSystemItem) DocumentModelList(org.nuxeo.ecm.core.api.DocumentModelList) Calendar(java.util.Calendar) ArrayList(java.util.ArrayList) DocumentModel(org.nuxeo.ecm.core.api.DocumentModel) FileSystemItemChangeImpl(org.nuxeo.drive.service.impl.FileSystemItemChangeImpl)

Aggregations

ArrayList (java.util.ArrayList)1 Calendar (java.util.Calendar)1 FileSystemItem (org.nuxeo.drive.adapter.FileSystemItem)1 FileSystemItemChangeImpl (org.nuxeo.drive.service.impl.FileSystemItemChangeImpl)1 DocumentModel (org.nuxeo.ecm.core.api.DocumentModel)1 DocumentModelList (org.nuxeo.ecm.core.api.DocumentModelList)1