-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'feature/PODAAC-5770' into feature/PODAAC-5770-DividedOv…
…erIDL
- Loading branch information
Showing
8 changed files
with
1,568 additions
and
179 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
254 changes: 98 additions & 156 deletions
254
src/main/java/gov/nasa/cumulus/metadata/aggregator/MetadataFilesToEcho.java
Large diffs are not rendered by default.
Oops, something went wrong.
13 changes: 0 additions & 13 deletions
13
...in/java/gov/nasa/cumulus/metadata/aggregator/constant/MENDsIsoXMLSpatialTypeConstant.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
72 changes: 72 additions & 0 deletions
72
src/main/java/gov/nasa/cumulus/metadata/util/MENDsISOXmlUtiils.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
package gov.nasa.cumulus.metadata.util; | ||
|
||
import cumulus_message_adapter.message_parser.AdapterLogger; | ||
import org.w3c.dom.Document; | ||
|
||
import javax.xml.xpath.XPath; | ||
import javax.xml.xpath.XPathExpressionException; | ||
|
||
public class MENDsISOXmlUtiils { | ||
/** | ||
* extract a string from xml document. swallow exception if there is any. | ||
* If exception is swallowed, return empty string. | ||
* Another extractXPathValueThrowsException shall be implemented whenever needed, which | ||
* in another case should throw exception instead of swallow. | ||
* @return | ||
*/ | ||
/** | ||
* | ||
* @param doc | ||
* @param xpath | ||
* @param pathStr : the xml path in string format | ||
* @param pathTagStr :the tag form of the xml path string. Ex IsoMendsXPath.ADDITIONAL_ATTRIBUTES_BLOCK. | ||
* This is for logging and support purpose so the developer can quickly identify what field(s) | ||
* is causing problem | ||
* @return : extracted string. Or the extractedString default is "" which is empty string. Hence, | ||
* any exception would cause this function to return an empty string | ||
*/ | ||
public static String extractXPathValueSwallowException(Document doc, XPath xpath, String pathStr, String pathTagStr) { | ||
String extractedStr = ""; //default to empty string. | ||
try { | ||
extractedStr = xpath.evaluate(pathStr, doc); | ||
} catch (XPathExpressionException xPathExpressionException) { | ||
AdapterLogger.LogError("extractXPathValueSwallowException error while extracting: " + pathTagStr | ||
+ " path string value:"+ pathStr | ||
+ " Exception:" +xPathExpressionException); | ||
} catch (Exception genericException) { | ||
AdapterLogger.LogError("extractXPathValueSwallowException error while extracting: "+ pathTagStr | ||
+ " path string value:"+ pathStr | ||
+ " Exception:" +genericException); | ||
} | ||
return extractedStr; | ||
} | ||
|
||
/** | ||
* extract a string from xml document. throws exception if there is any. | ||
* @param doc | ||
* @param xpath | ||
* @param pathStr | ||
* @param pathTagStr | ||
* @return | ||
* @throws Exception | ||
*/ | ||
public static String extractXPathValueThrowsException(Document doc, XPath xpath, String pathStr, String pathTagStr) | ||
throws Exception{ | ||
String extractedStr = ""; | ||
try { | ||
extractedStr = xpath.evaluate(pathStr, doc); | ||
} catch (XPathExpressionException xPathExpressionException) { | ||
AdapterLogger.LogError("extractXPathValueSwallowException error while extracting: " + pathTagStr | ||
+ " path string value:"+ pathStr | ||
+ " Exception:" +xPathExpressionException); | ||
throw xPathExpressionException; | ||
} catch (Exception genericException) { | ||
AdapterLogger.LogError("extractXPathValueSwallowException error while extracting: "+ pathTagStr | ||
+ " path string value:"+ pathStr | ||
+ " Exception:" +genericException); | ||
throw genericException; | ||
} | ||
return extractedStr; | ||
} | ||
|
||
} |
Oops, something went wrong.