1
1
package org .kramerius .importmets ;
2
2
3
3
import com .qbizm .kramerius .imp .jaxb .DigitalObject ;
4
+
4
5
import cz .incad .kramerius .utils .IOUtils ;
5
6
import cz .incad .kramerius .utils .XMLUtils ;
6
7
import cz .incad .kramerius .utils .conf .KConfiguration ;
8
+
7
9
import org .apache .commons .io .input .BOMInputStream ;
8
10
import org .apache .log4j .Logger ;
9
11
import org .kramerius .Import ;
21
23
22
24
import javax .xml .bind .*;
23
25
import javax .xml .transform .sax .SAXSource ;
26
+
24
27
import java .io .*;
25
28
26
29
@@ -99,7 +102,7 @@ private static void checkAndConvertDirectory(String importRoot, String exportRoo
99
102
}
100
103
File exportFolderFile = IOUtils .checkDirectory (exportRoot );
101
104
102
- File infoFile = new File (importFolder , "info.xml" );
105
+ File infoFile = findInfoFile (importFolder );
103
106
if (!infoFile .exists ()) {
104
107
for (File child : importFolder .listFiles ()){
105
108
if (child .isDirectory ()){
@@ -116,6 +119,22 @@ private static void checkAndConvertDirectory(String importRoot, String exportRoo
116
119
117
120
}
118
121
122
+ private static File findInfoFile (File importFolder ) {
123
+ File infoFile = null ;
124
+ File [] lfiles = importFolder .listFiles (new FileFilter () {
125
+
126
+ @ Override
127
+ public boolean accept (File p ) {
128
+ String fname = p .getName ().toLowerCase ();
129
+ if (fname .startsWith ("info" ) && fname .endsWith (".xml" )) {
130
+ return true ;
131
+ } else return false ;
132
+ }
133
+ });
134
+ infoFile = (lfiles !=null && lfiles .length >0 ) ? lfiles [0 ] : new File (importFolder , "info.xml" );
135
+ return infoFile ;
136
+ }
137
+
119
138
120
139
private static String convert (String importRoot , String exportRoot , boolean defaultVisibility ) throws InterruptedException , JAXBException , FileNotFoundException , SAXException , ServiceException {
121
140
System .setProperty ("java.awt.headless" , "true" );
@@ -125,9 +144,7 @@ private static String convert(String importRoot, String exportRoot, boolean defa
125
144
126
145
File importFolder = new File (importRoot );
127
146
128
- File infoFile = new File (importFolder , "info.xml" );
129
-
130
-
147
+ File infoFile = findInfoFile (importFolder );
131
148
132
149
String packageid = getPackageid (infoFile );
133
150
@@ -177,8 +194,7 @@ private static File findMetsFile(File importFolder){
177
194
File [] fileList = importFolder .listFiles (new FileFilter () {
178
195
@ Override
179
196
public boolean accept (File pathname ) {
180
- return pathname .isFile () && pathname .getName ().toLowerCase ().endsWith (".xml" ) && !(pathname .getName ().equalsIgnoreCase ("info.xml" ));
181
-
197
+ return pathname .isFile () && pathname .getName ().toLowerCase ().endsWith (".xml" ) && pathname .getName ().toLowerCase ().startsWith ("mets" );
182
198
}
183
199
});
184
200
if (fileList .length !=1 ){
0 commit comments