| 6 | public class MetadataManager { |
| 7 | |
| 8 | |
| 9 | MetadataFile[] metadataFiles = null; |
| 10 | |
| 11 | public MetadataManager(String metadataDirStr) throws Exception { |
| 12 | init(metadataDirStr); |
| 13 | } |
| 14 | |
| 15 | |
| 16 | public void init(String metadataDirStr) throws Exception{ |
| 17 | File metadataDir = new File(metadataDirStr); |
| 18 | File[] files = null; |
| 19 | if( metadataDir.exists() ){ |
| 20 | if( metadataDir.isFile()){ |
| 21 | files = new File[]{metadataDir}; |
| 22 | }else{ |
| 23 | if( metadataDir.isDirectory()){ |
| 24 | files = metadataDir.listFiles(); |
| 25 | }else{ |
| 26 | throw new Exception("Inernal File/Directory error: " + metadataDirStr); |
| 27 | } |
| 28 | } |
| 29 | }else{ |
| 30 | throw new Exception("File/Directory not found: " + metadataDirStr); |
| 31 | } |
| 32 | ArrayList<MetadataFile> aList = new ArrayList<MetadataFile>(); |
| 33 | for(File file: files){ |
| 34 | MetadataFile metadataFile = null; |
| 35 | try{ |
| 36 | metadataFile = new MetadataFile(file); |
| 37 | aList.add(metadataFile); |
| 38 | }catch(Exception ex){ |
| 39 | // WARNING |
| 40 | System.out.println("Invalid metadata file: " + file.getAbsolutePath()); |
| 41 | } |
| 42 | } |
| 43 | metadataFiles = aList.toArray(new MetadataFile[0]); |
| 44 | } |
| 45 | |
| 46 | |
| 47 | |