1
|
package edu.ucsb.nceas.metacat.index;
|
2
|
|
3
|
import java.io.File;
|
4
|
import java.util.ArrayList;
|
5
|
import java.util.List;
|
6
|
|
7
|
import org.apache.commons.io.FileUtils;
|
8
|
import org.dataone.cn.indexer.solrhttp.SolrDoc;
|
9
|
import org.dataone.cn.indexer.solrhttp.SolrElementField;
|
10
|
import org.junit.Before;
|
11
|
import org.junit.Test;
|
12
|
|
13
|
import edu.ucsb.nceas.metacat.index.resourcemap.ResourceMapSubprocessor;
|
14
|
|
15
|
public class SolrMetacatIdsComparatorIT {
|
16
|
|
17
|
|
18
|
private static final String metacatIDFileName = "ids";
|
19
|
private static final String NOTINSOLR = "not_in_solr_but_in_metacat_ids";
|
20
|
//private static final String NOTINMETACAT = "in_solr_but_not_in_metacat_ids";
|
21
|
private File metacatIdsFile = null;
|
22
|
private File notInSolrFile = null;
|
23
|
private File notInMetacatFile = null;
|
24
|
|
25
|
|
26
|
@Before
|
27
|
public void setUp() throws Exception {
|
28
|
metacatIdsFile = new File( metacatIDFileName);
|
29
|
notInSolrFile = new File(NOTINSOLR);
|
30
|
if(notInSolrFile.exists()) {
|
31
|
notInSolrFile.delete();
|
32
|
}
|
33
|
notInSolrFile.createNewFile();
|
34
|
/*notInMetacatFile = new File(NOTINMETACAT);
|
35
|
if(notInMetacatFile.exists()) {
|
36
|
notInMetacatFile.delete();
|
37
|
}
|
38
|
notInMetacatFile.createNewFile();*/
|
39
|
}
|
40
|
|
41
|
|
42
|
/**
|
43
|
* Figure out ids which have been indexed.
|
44
|
*/
|
45
|
@Test
|
46
|
public void figureIdsNotIndexed() throws Exception {
|
47
|
List<String> metacatIds = FileUtils.readLines(metacatIdsFile, "UTF-8");
|
48
|
boolean appending = true;
|
49
|
if(metacatIds != null) {
|
50
|
for(String id : metacatIds) {
|
51
|
//String id = metacatIds.get(0);
|
52
|
if(id != null && !id.trim().equals("")) {
|
53
|
SolrDoc doc = ResourceMapSubprocessor.getSolrDoc(id);
|
54
|
if(doc == null) {
|
55
|
List<String> line = new ArrayList<String>();
|
56
|
line.add(id);
|
57
|
FileUtils.writeLines(notInSolrFile, line, appending);
|
58
|
}
|
59
|
}
|
60
|
}
|
61
|
}
|
62
|
}
|
63
|
}
|