Revision 3696
Added by Jing Tao almost 17 years ago
test/edu/ucsb/nceas/metacattest/UploadIPCCDataTest.java | ||
---|---|---|
91 | 91 |
} |
92 | 92 |
|
93 | 93 |
/**Constants*/ |
94 |
private static String SRBDATAFILEDIR = "/home/tao/data-file"; // Dir for storing srb data file |
|
94 |
private static String SRBDATAFILEDIR = "/home/tao/data-file/IPCC"; // Dir for storing srb data file
|
|
95 | 95 |
private static String DOCLISTFILE = "docidList"; // File name which stores IPCC document id |
96 | 96 |
private static String METACATURL = "http://chico.dyndns.org/knb/metacat"; |
97 |
private static String USERNAME = "uid=tao,o=NCEAS,dc=ecoinformatics,dc=org";
|
|
97 |
private static String USERNAME = "uid=dpennington,o=LTER,dc=ecoinformatics,dc=org";
|
|
98 | 98 |
private static String PASSWORD = "password"; |
99 | 99 |
private static String TABLEONLINEURL= "/eml:eml/dataset/dataTable/physical/distribution/online/url"; |
100 | 100 |
private static String SPATIALONLINEURL = "/eml:eml/dataset/spatialRaster/physical/distribution/online/url"; |
... | ... | |
128 | 128 |
public static Test suite() |
129 | 129 |
{ |
130 | 130 |
TestSuite suite = new TestSuite(); |
131 |
//suite.addTest(new UploadIPCCDataTest("upload"));
|
|
132 |
//suite.addTest(new UploadIPCCDataTest("getCurrent_CorrectFileNamesPair"));
|
|
131 |
//suite.addTest(new UploadIPCCDataTest("modifyEMLDocsWithCorrectDataFileName"));
|
|
132 |
//suite.addTest(new UploadIPCCDataTest("modifyEMLDocsWithIncorrectDataFileName"));
|
|
133 | 133 |
return suite; |
134 | 134 |
} |
135 | 135 |
|
136 | 136 |
/** |
137 |
* Modify EML Docs' data url online from SRB to ecogrid. |
|
138 |
*Those eml docs pointe valide srb file names. |
|
139 |
*/ |
|
140 |
public void modifyEMLDocsWithCorrectDataFileName() |
|
141 |
{ |
|
142 |
boolean originalDataFileIncorrect = false; |
|
143 |
updateEML(originalDataFileIncorrect); |
|
144 |
} |
|
145 |
/** |
|
146 |
* Modify EML Docs' data url online from SRB to ecogrid. |
|
147 |
*Those eml docs pointe invalide srb file names. |
|
148 |
*/ |
|
149 |
public void modifyEMLDocsWithIncorrectDataFileName() |
|
150 |
{ |
|
151 |
boolean originalDataFileIncorrect = true; |
|
152 |
updateEML(originalDataFileIncorrect); |
|
153 |
} |
|
154 |
/* |
|
137 | 155 |
* Upload the data file to Metacat and modify the eml documents |
138 | 156 |
* @return |
139 | 157 |
* @throws Exception |
140 | 158 |
*/ |
141 |
public void upload()
|
|
159 |
private void updateEML(boolean originalDataFileIncorrect)
|
|
142 | 160 |
{ |
143 | 161 |
|
144 | 162 |
// Get eml document first |
... | ... | |
163 | 181 |
try |
164 | 182 |
{ |
165 | 183 |
docid = (String)list.elementAt(i); |
166 |
String dataId = handleSingleEML(docid); |
|
184 |
String dataId = handleSingleEML(docid, originalDataFileIncorrect);
|
|
167 | 185 |
String message = "Successfully update eml "+docid + " with data id "+dataId; |
168 | 186 |
writeLog(log, message); |
169 | 187 |
} |
... | ... | |
197 | 215 |
* 7. Update it to a new version in Metacat. |
198 | 216 |
* |
199 | 217 |
*/ |
200 |
private String handleSingleEML(String docid) throws Exception |
|
218 |
private String handleSingleEML(String docid,boolean originalDataFileIncorrect) throws Exception
|
|
201 | 219 |
{ |
202 | 220 |
Metacat metacat = MetacatFactory.createMetacatConnection(METACATURL); |
203 | 221 |
// login metacat |
... | ... | |
217 | 235 |
|
218 | 236 |
//3. Find the srb data file |
219 | 237 |
String dataFileName = getDataFileNameFromURL(onlineUrl); |
238 |
//System.out.println("the data fileName in eml "+dataFileName); |
|
239 |
//If the dataFileName in original eml is wrong, we need to look up the |
|
240 |
// the correct name first |
|
241 |
if (originalDataFileIncorrect) |
|
242 |
{ |
|
243 |
Hashtable correctName = getCurrent_CorrectFileNamesPair(); |
|
244 |
dataFileName =(String) correctName.get(dataFileName); |
|
245 |
} |
|
220 | 246 |
//System.out.println("=================The data file is "+dataFileName); |
221 | 247 |
File dataFile = null; |
222 | 248 |
dataFile = new File(SRBDATAFILEDIR,dataFileName); |
Also available in: Unified diff
Add method to handle origianl data file error in IPCC eml document