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 - initial API and implementation 011 * 012 * $Id: DocumentChildrenReader.java 29029 2008-01-14 18:38:14Z ldoguin $ 013 */ 014 015package org.nuxeo.ecm.core.io.impl.plugins; 016 017import java.io.IOException; 018 019import org.nuxeo.ecm.core.api.CoreSession; 020import org.nuxeo.ecm.core.api.DocumentModel; 021import org.nuxeo.ecm.core.api.DocumentModelIterator; 022import org.nuxeo.ecm.core.api.DocumentRef; 023import org.nuxeo.ecm.core.io.ExportedDocument; 024import org.nuxeo.ecm.core.io.impl.ExportedDocumentImpl; 025 026/** 027 * @deprecated unused since 5.6 028 */ 029@Deprecated 030public class DocumentChildrenReader extends DocumentModelReader { 031 032 private DocumentModelIterator iterator; 033 034 public DocumentChildrenReader(CoreSession session, DocumentModel root) { 035 super(session); 036 iterator = session.getChildrenIterator(root.getRef(), null, null, null); 037 } 038 039 public DocumentChildrenReader(CoreSession session, DocumentRef root) { 040 this(session, session.getDocument(root)); 041 } 042 043 @Override 044 public void close() { 045 super.close(); 046 iterator = null; 047 } 048 049 @Override 050 public ExportedDocument read() throws IOException { 051 if (iterator.hasNext()) { 052 DocumentModel docModel = iterator.next(); 053 return new ExportedDocumentImpl(docModel); 054 } 055 return null; 056 } 057 058}