Revision 3366
Added by barteau over 17 years ago
src/edu/ucsb/nceas/metacat/clientview/ClientFgdcHelper.java | ||
---|---|---|
134 | 134 |
return(revision); |
135 | 135 |
} |
136 | 136 |
|
137 |
public static boolean handlePackageUpload(String metaDocId, HashMap dataDocIDs, String contactName, Document metadataDoc) throws IOException { |
|
137 |
public static boolean handlePackageUpload(String metaDocId, |
|
138 |
HashMap dataDocIDs, |
|
139 |
String contactName, |
|
140 |
String metaFNm, |
|
141 |
Document metadataDoc) throws IOException { |
|
138 | 142 |
boolean result = true; |
139 | 143 |
Node newBranch, metaRootNode; |
140 | 144 |
|
141 | 145 |
//*** Store the User Name and Doc Id in the FGDC document. |
142 |
newBranch = getFGDCdisinfo(contactName, metaDocId, dataDocIDs); |
|
143 |
System.out.println("ClientFgdcHelper.handlePackageUpload: " + XMLUtilities.getDOMTreeAsString(newBranch)); |
|
146 |
newBranch = getFGDCdisinfo(contactName, metaDocId, metaFNm, dataDocIDs);
|
|
147 |
//System.out.println("ClientFgdcHelper.handlePackageUpload: " + XMLUtilities.getDOMTreeAsString(newBranch));
|
|
144 | 148 |
metaRootNode = addDistInfoToFGDC(newBranch, metadataDoc); |
145 | 149 |
return(result); |
146 | 150 |
} |
... | ... | |
174 | 178 |
return(result); |
175 | 179 |
} |
176 | 180 |
|
177 |
private static Node getFGDCdisinfo(String contactName, String resourceDescription, HashMap dataDocIDs) throws IOException { |
|
178 |
Node result = null, node, digformBranch, formname, stdorder; |
|
181 |
public static boolean hasMetacatInfo(String docId, Document metadataDoc) { |
|
182 |
boolean result = false; |
|
183 |
String queryResult, xPathQuery; |
|
184 |
|
|
185 |
xPathQuery = String.format(XPATH_QUERY_TEMPLATE, docId); |
|
186 |
try { |
|
187 |
queryResult = xpath.evaluate(xPathQuery, metadataDoc); |
|
188 |
result = (queryResult != null && !queryResult.equals("")); |
|
189 |
} catch (XPathExpressionException ex) { |
|
190 |
ex.printStackTrace(); |
|
191 |
} |
|
192 |
return(result); |
|
193 |
} |
|
194 |
|
|
195 |
private static Node getFGDCdisinfo(String contactName, String resourceDescription, String metaFNm, HashMap dataDocIDs) throws IOException { |
|
196 |
Node result = null, node, digformBranch, formname, stdorder, formcont; |
|
179 | 197 |
Document doc; |
180 | 198 |
Iterator iterIt; |
181 |
String key, value; |
|
199 |
String key, value, fileInfo[];
|
|
182 | 200 |
|
183 | 201 |
//*** This is a valid/minimal FGDC "distinfo" branch. |
184 | 202 |
final String XML = "<distinfo>" |
... | ... | |
204 | 222 |
+ " <digform>" |
205 | 223 |
+ " <digtinfo>" |
206 | 224 |
+ " <formname></formname>" |
225 |
+ " <formcont></formcont>" |
|
207 | 226 |
+ " </digtinfo>" |
208 | 227 |
+ " <digtopt>" |
209 | 228 |
+ " <onlinopt>" |
... | ... | |
217 | 236 |
+ " </digform>" |
218 | 237 |
+ " <fees></fees>" |
219 | 238 |
+ " </stdorder>" |
239 |
+ " <custom></custom>" |
|
220 | 240 |
+ "</distinfo>"; |
221 | 241 |
|
222 | 242 |
doc = XMLUtilities.getXMLReaderAsDOMDocument(new StringReader(XML)); |
... | ... | |
228 | 248 |
//*** Set the metadata Doc Id. |
229 | 249 |
node = (Node) xpath.evaluate("/distinfo/resdesc", result, XPathConstants.NODE); |
230 | 250 |
node.setTextContent(resourceDescription); |
251 |
//*** Set the metadata filename. |
|
252 |
node = (Node) xpath.evaluate("/distinfo/custom", result, XPathConstants.NODE); |
|
253 |
node.setTextContent(metaFNm); |
|
231 | 254 |
|
232 | 255 |
//*** Loop thru the files, setting their format and Doc Id. |
233 | 256 |
stdorder = (Node) xpath.evaluate("/distinfo/stdorder", result, XPathConstants.NODE); |
... | ... | |
238 | 261 |
key = (String) iterIt.next(); |
239 | 262 |
node = (Node) xpath.evaluate("digtopt/onlinopt/computer/networka/networkr", digformBranch, XPathConstants.NODE); |
240 | 263 |
node.setTextContent(key); |
241 |
//*** Save the data file format (optional). |
|
242 |
formname = (Node) xpath.evaluate("digtinfo/formname", digformBranch, XPathConstants.NODE); |
|
243 |
if ((value = (String) dataDocIDs.get(key)) != null && !value.equals("")) { |
|
244 |
formname.setTextContent(value); |
|
245 |
} else { |
|
246 |
//*** We did a deep clone of the branch, so clear prior contents. |
|
247 |
formname.setTextContent(""); |
|
264 |
|
|
265 |
fileInfo = (String[]) dataDocIDs.get(key); |
|
266 |
if (fileInfo != null) { |
|
267 |
//*** Save the data file format (optional). |
|
268 |
formname = (Node) xpath.evaluate("digtinfo/formname", digformBranch, XPathConstants.NODE); |
|
269 |
if ((value = fileInfo[ClientView.FORMAT_TYPE]) != null && !value.equals("")) { |
|
270 |
formname.setTextContent(value); |
|
271 |
} else { |
|
272 |
//*** We did a deep clone of the branch, so clear prior contents. |
|
273 |
formname.setTextContent(""); |
|
274 |
} |
|
275 |
//*** Save the data file name. |
|
276 |
formcont = (Node) xpath.evaluate("digtinfo/formcont", digformBranch, XPathConstants.NODE); |
|
277 |
if ((value = fileInfo[ClientView.FILE_NAME]) != null && !value.equals("")) { |
|
278 |
formcont.setTextContent(value); |
|
279 |
} else { |
|
280 |
//*** We did a deep clone of the branch, so clear prior contents. |
|
281 |
formcont.setTextContent(""); |
|
282 |
} |
|
248 | 283 |
} |
249 |
|
|
250 | 284 |
//*** Clone branch for next file. |
251 | 285 |
if (iterIt.hasNext()) { |
252 | 286 |
digformBranch = digformBranch.cloneNode(true); |
Also available in: Unified diff
Updated handlePackageUpload (in development).