Issue #2541 Added exclude patterns to RequestPatterns.
Added an exclude pattern to grib.xml to exclude data delivery sbn files. Change-Id: Id92865e1b58bdcf3744328bd0362636093a03521 Former-commit-id:5a29ccf45a
[formerlyabafd2bc13
] [formerlydc7e255d43
] [formerly5a29ccf45a
[formerlyabafd2bc13
] [formerlydc7e255d43
] [formerly8acfa99e77
[formerlydc7e255d43
[formerly 396a9a99863ce9a616eecde6466f1c4d43b8d566]]]] Former-commit-id:8acfa99e77
Former-commit-id:2ac17d4f80
[formerlyf25d05d871
] [formerly ae02142a37272496582f2ecc88cfd8d603853aa7 [formerlydd8eb8c2b4
]] Former-commit-id: 92c939ad476a1068e1097bc9ebf073196e097603 [formerlyc596c6f672
] Former-commit-id:5bebc39d29
This commit is contained in:
parent
aaf5dfbd62
commit
5a58530d03
2 changed files with 34 additions and 3 deletions
|
@ -22,6 +22,8 @@
|
|||
<!-- Super Set of all possible WMO grib patterns -->
|
||||
<!-- Is specifically not restricting on CCCC since HPE isn't populating it -->
|
||||
<regex>^[EHLMOYZ][A-Z]{3}\d{2}</regex>
|
||||
<!-- Exclude Data Delivery specific patterns -->
|
||||
<regexExclude>^LZ[ABC][ABC]9[123] KWBC</regexExclude>
|
||||
|
||||
<!-- ECMWF decrypted -->
|
||||
<regex>ecmwf_decrypted</regex>
|
||||
|
|
|
@ -52,6 +52,7 @@ import com.raytheon.uf.common.serialization.ISerializableObject;
|
|||
* for PatternSyntaxException.
|
||||
* Mar 19, 2013 1794 djohnson Add toString() for debugging.
|
||||
* Sep 10, 2013 2327 rjpeter Sized ArrayList declarations.
|
||||
* Nov 21, 2013 2541 bgonzale Exclusion patterns.
|
||||
* </pre>
|
||||
*
|
||||
* @author brockwoo
|
||||
|
@ -68,8 +69,17 @@ public class RequestPatterns implements ISerializableObject {
|
|||
@XmlElements({ @XmlElement(name = "regex", type = String.class) })
|
||||
private List<String> patterns = new ArrayList<String>(0);
|
||||
|
||||
/**
|
||||
* List of patterns excluded by a plugin. Excludes takes precedence over
|
||||
* acceptance and is applied first.
|
||||
*/
|
||||
@XmlElements({ @XmlElement(name = "regexExclude", type = String.class) })
|
||||
private List<String> exclusionPatterns = new ArrayList<String>(0);
|
||||
|
||||
private List<Pattern> compiledPatterns = new ArrayList<Pattern>(0);
|
||||
|
||||
private List<Pattern> compiledExclusionPatterns = new ArrayList<Pattern>(0);
|
||||
|
||||
protected Log patternFailedLogger = LogFactory.getLog("PatternFailedLog");
|
||||
|
||||
/**
|
||||
|
@ -112,7 +122,13 @@ public class RequestPatterns implements ISerializableObject {
|
|||
*
|
||||
*/
|
||||
public void compilePatterns() {
|
||||
compiledPatterns = new ArrayList<Pattern>(patterns.size());
|
||||
compiledPatterns = compilePatterns(patterns);
|
||||
compiledExclusionPatterns = compilePatterns(exclusionPatterns);
|
||||
}
|
||||
|
||||
private List<Pattern> compilePatterns(List<String> patterns) {
|
||||
List<Pattern> compiledPatterns = new ArrayList<Pattern>(patterns.size());
|
||||
|
||||
for (String pattern : patterns) {
|
||||
try {
|
||||
compiledPatterns.add(Pattern.compile(pattern));
|
||||
|
@ -123,24 +139,37 @@ public class RequestPatterns implements ISerializableObject {
|
|||
patternFailedLogger.error(sb.toString(), e);
|
||||
}
|
||||
}
|
||||
return compiledPatterns;
|
||||
}
|
||||
|
||||
/**
|
||||
* Takes a string and compares against the patterns in this container. The
|
||||
* first one that matches breaks the search and returns true.
|
||||
*
|
||||
* Check for exclusion first. It takes precedence over acceptance.
|
||||
*
|
||||
* @param header
|
||||
* The string to search for
|
||||
* @return a boolean indicating success
|
||||
*/
|
||||
public boolean isDesiredHeader(String header) {
|
||||
boolean isFound = false;
|
||||
boolean isExcluded = false;
|
||||
|
||||
for (Pattern headerPattern : compiledExclusionPatterns) {
|
||||
if (headerPattern.matcher(header).find()) {
|
||||
isExcluded = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!isExcluded) {
|
||||
for (Pattern headerPattern : compiledPatterns) {
|
||||
if (headerPattern.matcher(header).find()) {
|
||||
isFound = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return isFound;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue