Skip to content

Commit

Permalink
Update policy generator
Browse files Browse the repository at this point in the history
  • Loading branch information
MaximPlusov committed Oct 24, 2024
1 parent 7b18862 commit 7e0b5ce
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,9 @@ private void generateFailPolicy(boolean isTagged, String profileName) {
.replace("{fileNameToBeReplaced}", shortFileName)
.replace("ISSUE_NUMBER_PART", getIssueNumberPart())
.replace("{failedRulesToBeReplaced}", failedRulesToBeReplaced));
if (isTagged) {
content.append(PolicyHelper.PATTERN_END);
}
nodeList = document.getElementsByTagName("rule");
int size = nodeList.getLength();
StringBuilder messageToBeReplaced = new StringBuilder();
Expand All @@ -238,8 +241,15 @@ private void generateFailPolicy(boolean isTagged, String profileName) {
Integer.parseInt(node.getNamedItem("testNumber").getNodeValue()),
Integer.parseInt(node.getNamedItem("failedChecks").getNodeValue())));
}
if (isTagged) {
content.append('\n');
}
for (Map.Entry<String, SortedSet<RuleInfo>> map : ruleInfoMap.entrySet()) {
Iterator<RuleInfo> iterator = map.getValue().iterator();
if (isTagged) {
content.append(PolicyHelper.PATTERN_START);
content.append('\n');
}
content.append(PolicyHelper.FAIL_RULE);
if (isTagged) {
content.append("object != '").append(map.getKey()).append("' or\n ");
Expand All @@ -265,9 +275,15 @@ private void generateFailPolicy(boolean isTagged, String profileName) {
}
content.append(PolicyHelper.RULE_END
.replace("{messageToBeReplaced}", messageToBeReplaced));
if (isTagged) {
content.append(PolicyHelper.PATTERN_END);
content.append('\n');
}
messageToBeReplaced = new StringBuilder();
}
content.append(PolicyHelper.PATTERN_END);
if (!isTagged) {
content.append(PolicyHelper.PATTERN_END);
}

System.out.println("Policy was created. PDF file is not compliant with " + profileName + " requirements");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ public class PolicyHelper {
" {messageToBeReplaced}</sch:assert>\n" +
" </sch:rule>\n" +
"\n";

public static final String PATTERN_START = " <sch:pattern>\n";
public static final String PATTERN_END = " </sch:pattern>\n";
public static final String LOGS_REPORT = "\n" +
" <sch:pattern name = \"Checking the logs\">\n" +
Expand Down

0 comments on commit 7e0b5ce

Please sign in to comment.