Skip to content

Commit

Permalink
Merge branch 'feature/PODAAC-5770' into feature/PODAAC-5770-DividedOv…
Browse files Browse the repository at this point in the history
…erIDL
  • Loading branch information
Yen, David (398B-Affiliate) committed Sep 13, 2023
2 parents 34d2c83 + 872811e commit 0679672
Show file tree
Hide file tree
Showing 8 changed files with 1,568 additions and 179 deletions.
6 changes: 2 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added
- **PODAAC-5594**
- Support BasinID
- **PODAAC-5708**
- Add capability in order to extract swot nc.iso.xml footprint and divide over IDL
- **PODAAC-5770**
- use meta.isoXMLSpatialType to configure the collection should process the combination of footprint, orbit and bbox
- **PODAAC-5717**
- Upgrade to UMMG 1.6.5
- support empty Pass in Cycle/Pass/Tile string
### Deprecated
### Removed
### Fixed
- **PODAAC-5770**
- selectively extract orbit, bbox, or footprint from iso.xml
### Security

-
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
import java.util.Hashtable;
import java.util.List;

import gov.nasa.cumulus.metadata.aggregator.constant.MENDsIsoXMLSpatialTypeConstant;
import gov.nasa.cumulus.metadata.aggregator.processor.DMRPPProcessor;
import gov.nasa.cumulus.metadata.aggregator.processor.FootprintProcessor;
import gov.nasa.cumulus.metadata.aggregator.processor.ImageProcessor;
Expand Down Expand Up @@ -258,7 +257,7 @@ public String getIsoXMLSpatialTypeStr(String token) {
final String trimmedToken = StringUtils.trim(token);
String s;
try {
s = MENDsIsoXMLSpatialTypeConstant.isoXMLSpatialTypeList.stream()
s = MENDsIsoXMLSpatialTypeEnum.getEnumValuList().stream()
.filter(e -> StringUtils.equals(trimmedToken, e)).findFirst().get();
} catch (java.util.NoSuchElementException e) {
s = "";
Expand Down

Large diffs are not rendered by default.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
package gov.nasa.cumulus.metadata.state;

import gov.nasa.cumulus.metadata.aggregator.constant.MENDsIsoXMLSpatialTypeConstant;
import org.apache.commons.lang3.StringUtils;

import java.util.Arrays;
import java.util.List;

public enum MENDsIsoXMLSpatialTypeEnum {

FOOTPRINT("footprint"), ORBIT("orbit"), BBOX("bbox"), NONE("none");
private String Status;
private static String FOOTPRINT_STR="footprint";
private static String ORBIT_STR="orbit";
private static String BBOX_STR="bbox";
private MENDsIsoXMLSpatialTypeEnum(String type) {
this.Status = type;
}
Expand All @@ -15,14 +21,19 @@ public String toString()
return this.Status;
}

public static List<String> getEnumValuList() {
final List<String> isoXMLSpatialTypeList = Arrays.asList(FOOTPRINT_STR, BBOX_STR, ORBIT_STR);
return isoXMLSpatialTypeList;
}

public static MENDsIsoXMLSpatialTypeEnum getEnum(String val)
{
val= StringUtils.trim(val);
if(StringUtils.equals(val, MENDsIsoXMLSpatialTypeConstant.FOOTPRINT))
if(StringUtils.equals(val, FOOTPRINT_STR))
return FOOTPRINT;
else if (StringUtils.equals(val, MENDsIsoXMLSpatialTypeConstant.ORBIT))
else if (StringUtils.equals(val, ORBIT_STR))
return ORBIT;
else if (StringUtils.equals(val, MENDsIsoXMLSpatialTypeConstant.BBOX))
else if (StringUtils.equals(val, BBOX_STR))
return BBOX;
else
return NONE;
Expand Down
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;
}

}
Loading

0 comments on commit 0679672

Please sign in to comment.