001/* 002 * Copyright (c) 2006-2011 Nuxeo SA (http://nuxeo.com/) and others. 003 * 004 * All rights reserved. This program and the accompanying materials 005 * are made available under the terms of the Eclipse Public License v1.0 006 * which accompanies this distribution, and is available at 007 * http://www.eclipse.org/legal/epl-v10.html 008 * 009 * Contributors: 010 * Nuxeo 011 */ 012package org.nuxeo.ecm.automation.jaxrs.io.documents; 013 014import org.nuxeo.ecm.automation.core.util.PaginableDocumentModelList; 015import org.nuxeo.ecm.automation.core.util.PaginablePageProvider; 016import org.nuxeo.ecm.core.api.DocumentModel; 017import org.nuxeo.ecm.platform.query.api.PageProvider; 018 019/** 020 * Wraps a {@link PageProvider} as a {@link DocumentList} 021 * 022 * @author Tiry (tdelprat@nuxeo.com) 023 */ 024public class PaginableDocumentModelListImpl extends PaginablePageProvider<DocumentModel> implements 025 PaginableDocumentModelList { 026 027 private static final long serialVersionUID = 1L; 028 029 protected String documentLinkBuilder; 030 031 public PaginableDocumentModelListImpl(PageProvider<DocumentModel> provider) { 032 this(provider, null); 033 } 034 035 /** 036 * Creates a {@code PaginableDocumentModelListImpl} with more display information. 037 * 038 * @param documentLinkBuilder the name of what will be used to compute the document URLs, usually a codec name. 039 * @since 5.6 040 */ 041 public PaginableDocumentModelListImpl(PageProvider<DocumentModel> provider, String documentLinkBuilder) { 042 super(provider); 043 this.documentLinkBuilder = documentLinkBuilder; 044 } 045 046 public PageProvider<DocumentModel> getProvider() { 047 return pageProvider; 048 } 049 050 @Override 051 public String getDocumentLinkBuilder() { 052 return documentLinkBuilder; 053 } 054 055 @Override 056 public long totalSize() { 057 return pageProvider.getResultsCount(); 058 } 059}