001/* 002 * (C) Copyright 2013 Nuxeo SA (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 * Benjamin JALON<[email protected]> 018 */ 019package org.nuxeo.ecm.platform.importer.xml.parser; 020 021import java.io.File; 022import java.util.ArrayList; 023import java.util.List; 024 025import org.apache.commons.logging.Log; 026import org.apache.commons.logging.LogFactory; 027import org.nuxeo.ecm.platform.importer.source.FileSourceNode; 028import org.nuxeo.ecm.platform.importer.source.SourceNode; 029 030/** 031 * Source Node filtering only Folder, XML and ZIP files. 032 * 033 * @since 5.7.3 034 */ 035public class XMLFileSourceNode extends FileSourceNode { 036 037 public static final Log log = LogFactory.getLog(XMLFileSourceNode.class); 038 039 public XMLFileSourceNode(File file) { 040 super(file); 041 } 042 043 @Override 044 public List<SourceNode> getChildren() { 045 List<SourceNode> children = new ArrayList<SourceNode>(); 046 047 File[] childrenFile = file.listFiles(); 048 for (File child : childrenFile) { 049 if (child.getName().endsWith(".xml") || child.getName().endsWith(".zip") || child.isDirectory()) { 050 children.add(new XMLFileSourceNode(child)); 051 } else { 052 log.info("File ignored as not xml or zip or directory file " + child.getAbsolutePath()); 053 } 054 } 055 return children; 056 } 057 058}