-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[UC Editor] adding JSON/Leef custom parser Signed-off-by: Taees Eimouri <[email protected]>
- Loading branch information
1 parent
e2cd2b3
commit 83319b7
Showing
16 changed files
with
1,405 additions
and
71 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
13 changes: 8 additions & 5 deletions
13
...c/main/java/com/ibm/guardium/universalconnector/commons/custom_parsing/ParserFactory.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 |
---|---|---|
@@ -1,23 +1,26 @@ | ||
package com.ibm.guardium.universalconnector.commons.custom_parsing; | ||
|
||
import com.ibm.guardium.universalconnector.commons.custom_parsing.parsers.IParser; | ||
import com.ibm.guardium.universalconnector.commons.custom_parsing.parsers.JsonParser; | ||
import com.ibm.guardium.universalconnector.commons.custom_parsing.parsers.LeefParser; | ||
import com.ibm.guardium.universalconnector.commons.custom_parsing.parsers.RegexParser; | ||
|
||
public class ParserFactory { | ||
IParser parser; | ||
|
||
public ParserFactory() { | ||
} | ||
|
||
public IParser getParser(ParserType parserType) { | ||
//For now we only support Regex | ||
//if(parserType.equals(ParserType.regex)) | ||
if (parserType.equals(ParserType.json)) | ||
return new JsonParser(); | ||
else if (parserType.equals(ParserType.leef)) | ||
return new LeefParser(); | ||
|
||
return new RegexParser(); | ||
} | ||
|
||
public enum ParserType { | ||
regex, | ||
json, | ||
xml | ||
leef | ||
} | ||
} |
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
7 changes: 7 additions & 0 deletions
7
...ium/universalconnector/commons/custom_parsing/excepton/InvalidConfigurationException.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,7 @@ | ||
package com.ibm.guardium.universalconnector.commons.custom_parsing.excepton; | ||
|
||
public class InvalidConfigurationException extends Exception { | ||
public InvalidConfigurationException(String msg) { | ||
super(msg); | ||
} | ||
} |
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 |
---|---|---|
|
@@ -2,4 +2,6 @@ | |
|
||
public interface IParser { | ||
String parse(String payload, String key); | ||
|
||
boolean isPayloadValid(String payload); | ||
} |
27 changes: 27 additions & 0 deletions
27
...n/java/com/ibm/guardium/universalconnector/commons/custom_parsing/parsers/JsonParser.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,27 @@ | ||
package com.ibm.guardium.universalconnector.commons.custom_parsing.parsers; | ||
|
||
import com.ibm.guardium.universalconnector.commons.custom_parsing.parsers.json_parser.JsonUtil; | ||
|
||
import java.util.Map; | ||
|
||
public class JsonParser implements IParser { | ||
|
||
private final JsonUtil util = new JsonUtil(); | ||
Map<String, String> extractedProperties; | ||
|
||
@Override | ||
public String parse(String payload, String key) { | ||
if (key == null) | ||
return null; | ||
return extractedProperties.get(key); | ||
} | ||
|
||
@Override | ||
public boolean isPayloadValid(String payload) { | ||
if (payload == null) | ||
return false; | ||
|
||
extractedProperties = util.getMap(payload); | ||
return extractedProperties != null && !extractedProperties.isEmpty(); | ||
} | ||
} |
Oops, something went wrong.