001/* 002 * (C) Copyright 2013 Nuxeo SA (http://nuxeo.com/) and contributors. 003 * 004 * All rights reserved. This program and the accompanying materials 005 * are made available under the terms of the GNU Lesser General Public License 006 * (LGPL) version 2.1 which accompanies this distribution, and is available at 007 * http://www.gnu.org/licenses/lgpl-2.1.html 008 * 009 * This library is distributed in the hope that it will be useful, 010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 012 * Lesser General Public License for more details. 013 * 014 * Contributors: 015 * Benjamin JALON<bjalon@nuxeo.com> 016 */ 017package org.nuxeo.ecm.platform.importer.xml.parser; 018 019import java.io.File; 020import java.util.ArrayList; 021import java.util.List; 022 023import org.apache.commons.logging.Log; 024import org.apache.commons.logging.LogFactory; 025import org.nuxeo.ecm.platform.importer.source.FileSourceNode; 026import org.nuxeo.ecm.platform.importer.source.SourceNode; 027 028/** 029 * Source Node filtering only Folder, XML and ZIP files. 030 * 031 * @since 5.7.3 032 */ 033public class XMLFileSourceNode extends FileSourceNode { 034 035 public static final Log log = LogFactory.getLog(XMLFileSourceNode.class); 036 037 public XMLFileSourceNode(File file) { 038 super(file); 039 } 040 041 @Override 042 public List<SourceNode> getChildren() { 043 List<SourceNode> children = new ArrayList<SourceNode>(); 044 045 File[] childrenFile = file.listFiles(); 046 for (File child : childrenFile) { 047 if (child.getName().endsWith(".xml") || child.getName().endsWith(".zip") || child.isDirectory()) { 048 children.add(new XMLFileSourceNode(child)); 049 } else { 050 log.info("File ignored as not xml or zip or directory file " + child.getAbsolutePath()); 051 } 052 } 053 return children; 054 } 055 056}