001/* 002 * (C) Copyright 2006-2019 Nuxeo (http://nuxeo.com/) and others. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 * 016 * Contributors: 017 * Nuxeo 018 */ 019package org.nuxeo.ecm.automation.jaxrs.io.documents; 020 021import org.nuxeo.ecm.automation.core.util.PaginableDocumentModelList; 022import org.nuxeo.ecm.automation.core.util.PaginablePageProvider; 023import org.nuxeo.ecm.core.api.DocumentModel; 024import org.nuxeo.ecm.core.api.DocumentModelList; 025import org.nuxeo.ecm.platform.query.api.PageProvider; 026 027/** 028 * Wraps a {@link PageProvider} as a {@link DocumentModelList} 029 * 030 * @author Tiry (tdelprat@nuxeo.com) 031 */ 032public class PaginableDocumentModelListImpl extends PaginablePageProvider<DocumentModel> implements 033 PaginableDocumentModelList { 034 035 private static final long serialVersionUID = 1L; 036 037 protected String documentLinkBuilder; 038 039 public PaginableDocumentModelListImpl(PageProvider<DocumentModel> provider) { 040 this(provider, null); 041 } 042 043 /** 044 * Creates a {@code PaginableDocumentModelListImpl} with more display information. 045 * 046 * @param documentLinkBuilder the name of what will be used to compute the document URLs, usually a codec name. 047 * @since 5.6 048 */ 049 public PaginableDocumentModelListImpl(PageProvider<DocumentModel> provider, String documentLinkBuilder) { 050 super(provider); 051 this.documentLinkBuilder = documentLinkBuilder; 052 } 053 054 public PageProvider<DocumentModel> getProvider() { 055 return pageProvider; 056 } 057 058 @Override 059 public String getDocumentLinkBuilder() { 060 return documentLinkBuilder; 061 } 062 063 @Override 064 public long totalSize() { 065 return pageProvider.getResultsCount(); 066 } 067}