X-Git-Url: https://gerrit.onap.org/r/gitweb?p=policy%2Fengine.git;a=blobdiff_plain;f=POLICY-SDK-APP%2Fsrc%2Fmain%2Fjava%2Forg%2Fonap%2Fpolicy%2Fcomponents%2FHumanPolicyComponent.java;h=f2c3a5d7a54e93550afe3f493e76314a0e07c76e;hp=ea0dce2c06783c952c2108d0d22dcdf105c48f2f;hb=0950d79047d3404c15b4dd30cffeb81346565f64;hpb=79cd00fc32b9894672590418a5af9a64929db49d diff --git a/POLICY-SDK-APP/src/main/java/org/onap/policy/components/HumanPolicyComponent.java b/POLICY-SDK-APP/src/main/java/org/onap/policy/components/HumanPolicyComponent.java index ea0dce2c0..f2c3a5d7a 100644 --- a/POLICY-SDK-APP/src/main/java/org/onap/policy/components/HumanPolicyComponent.java +++ b/POLICY-SDK-APP/src/main/java/org/onap/policy/components/HumanPolicyComponent.java @@ -2,14 +2,15 @@ * ============LICENSE_START======================================================= * ONAP Policy Engine * ================================================================================ - * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2019 Bell Canada * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -38,7 +39,9 @@ import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map; + import javax.xml.bind.JAXBElement; + import oasis.names.tc.xacml._3_0.core.schema.wd_17.AdviceExpressionType; import oasis.names.tc.xacml._3_0.core.schema.wd_17.AdviceExpressionsType; import oasis.names.tc.xacml._3_0.core.schema.wd_17.AllOfType; @@ -56,6 +59,7 @@ import oasis.names.tc.xacml._3_0.core.schema.wd_17.PolicySetType; import oasis.names.tc.xacml._3_0.core.schema.wd_17.PolicyType; import oasis.names.tc.xacml._3_0.core.schema.wd_17.RuleType; import oasis.names.tc.xacml._3_0.core.schema.wd_17.VariableReferenceType; + import org.apache.commons.io.FilenameUtils; import org.json.JSONObject; import org.onap.policy.common.logging.flexlogger.FlexLogger; @@ -65,8 +69,6 @@ import org.onap.policy.rest.jpa.FunctionDefinition; import org.onap.policy.xacml.api.XACMLErrorConstants; import org.onap.policy.xacml.util.XACMLPolicyScanner; - - public class HumanPolicyComponent { private static final Logger LOGGER = FlexLogger.getLogger(HumanPolicyComponent.class); @@ -96,7 +98,6 @@ public class HumanPolicyComponent { public static final String EMPTY_STRING = ""; private static final String ENTER = "ENTER"; - private static HtmlProcessor htmlProcessor; private static File policyFile; @@ -105,9 +106,16 @@ public class HumanPolicyComponent { // Default Constructor } + /** + * DescribePolicy. + * + * @param policyFile File + * @return JSONObject + */ public static JSONObject DescribePolicy(final File policyFile) { - if (LOGGER.isTraceEnabled()) + if (LOGGER.isTraceEnabled()) { LOGGER.trace(ENTER); + } HumanPolicyComponent.policyFile = policyFile; return humanPolicyLayout(); @@ -115,8 +123,9 @@ public class HumanPolicyComponent { } private static JSONObject humanPolicyLayout() { - if (LOGGER.isTraceEnabled()) + if (LOGGER.isTraceEnabled()) { LOGGER.trace(ENTER); + } try { String html = processPolicy(); @@ -136,8 +145,9 @@ public class HumanPolicyComponent { } try (FileInputStream pIS = new FileInputStream(policyFile)) { Object policy = XACMLPolicyScanner.readPolicy(pIS); - if (policy == null) + if (policy == null) { throw new IllegalArgumentException("Policy File " + policyFile.getName() + " cannot be unmarshalled"); + } HumanPolicyComponent.htmlProcessor = new HtmlProcessor(HumanPolicyComponent.policyFile, policy); @@ -145,8 +155,9 @@ public class HumanPolicyComponent { XACMLPolicyScanner xacmlScanner = new XACMLPolicyScanner(policyPath, htmlProcessor); xacmlScanner.scan(); String html = htmlProcessor.html(); - if (LOGGER.isDebugEnabled()) + if (LOGGER.isDebugEnabled()) { LOGGER.debug(policyPath + System.lineSeparator() + html); + } return html; @@ -166,6 +177,7 @@ class HtmlProcessor extends SimpleCallback { private static final String ENTER = "ENTER"; private static Map function2human; + static { function2human = new HashMap<>(); function2human.put(HumanPolicyComponent.FUNCTION_STRING_EQUAL, "equal"); @@ -176,6 +188,7 @@ class HtmlProcessor extends SimpleCallback { } private static Map combiningAlgo2human; + static { combiningAlgo2human = new HashMap<>(); combiningAlgo2human.put("deny-overrides", "to deny if any $placeholder$ below evaluates to deny"); @@ -204,8 +217,9 @@ class HtmlProcessor extends SimpleCallback { private final Object rootPolicyObject; public HtmlProcessor(File policyFile, Object policyObject) { - if (LOGGER.isTraceEnabled()) + if (LOGGER.isTraceEnabled()) { LOGGER.trace(ENTER); + } if (policyFile == null) { LOGGER.error(XACMLErrorConstants.ERROR_DATA_ISSUE + "Null Policy File"); @@ -218,8 +232,7 @@ class HtmlProcessor extends SimpleCallback { throw new IllegalArgumentException(msg); } - if (policyObject == null - || (!(policyObject instanceof PolicySetType) && !(policyObject instanceof PolicyType))) { + if ((!(policyObject instanceof PolicySetType) && !(policyObject instanceof PolicyType))) { String msg = "Invalid unmarshalled object: " + policyObject; LOGGER.error(XACMLErrorConstants.ERROR_SCHEMA_INVALID + msg); throw new IllegalArgumentException(msg); @@ -261,6 +274,8 @@ class HtmlProcessor extends SimpleCallback { } /** + * getAttributeIdentifiersMap. + * * @return the attributeIdentifiersMap */ public Map getAttributeIdentifiersMap() { @@ -269,8 +284,9 @@ class HtmlProcessor extends SimpleCallback { @Override public void onFinishScan(Object root) { - if (LOGGER.isTraceEnabled()) + if (LOGGER.isTraceEnabled()) { LOGGER.trace(ENTER); + } if (rootPolicyObject instanceof PolicySetType) { htmlOut.println(""); @@ -308,43 +324,52 @@ class HtmlProcessor extends SimpleCallback { @Override public CallbackResult onPreVisitPolicySet(PolicySetType parent, PolicySetType policySet) { - if (LOGGER.isTraceEnabled()) + if (LOGGER.isTraceEnabled()) { LOGGER.trace("PolicySet: " + policySet.getPolicySetId() + " Version: " + policySet.getVersion()); + } - if (parent != null && LOGGER.isTraceEnabled()) + if (parent != null && LOGGER.isTraceEnabled()) { LOGGER.trace("PolicySet: " + policySet.getPolicySetId() + "Parent PolicySet: " + parent.getPolicySetId() + " Version: " + parent.getVersion()); + } String description = policySet.getDescription(); - if (description != null && LOGGER.isTraceEnabled()) + if (description != null && LOGGER.isTraceEnabled()) { LOGGER.trace("PolicySet: " + policySet.getPolicySetId() + " Description: " + policySet.getDescription()); + } - if (parent == null) // root + if (parent == null) { // root policySet(policySet, "dl"); - else + } else { policySet(policySet, "li"); + } - if (!policySet.getPolicySetOrPolicyOrPolicySetIdReference().isEmpty()) + if (!policySet.getPolicySetOrPolicyOrPolicySetIdReference().isEmpty()) { htmlOut.println("
    "); + } return super.onPreVisitPolicySet(parent, policySet); } @Override public CallbackResult onPostVisitPolicySet(PolicySetType parent, PolicySetType policySet) { - if (LOGGER.isTraceEnabled()) + if (LOGGER.isTraceEnabled()) { LOGGER.trace("PolicySet: " + policySet.getPolicySetId() + " Version: " + policySet.getVersion()); + } - if (parent != null && LOGGER.isTraceEnabled()) + if (parent != null && LOGGER.isTraceEnabled()) { LOGGER.trace("PolicySet: " + policySet.getPolicySetId() + "Parent PolicySet: " + parent.getPolicySetId() + " Version: " + parent.getVersion()); + } String description = policySet.getDescription(); - if (description != null && LOGGER.isTraceEnabled()) + if (description != null && LOGGER.isTraceEnabled()) { LOGGER.trace("PolicySet: " + policySet.getPolicySetId() + " Description: " + policySet.getDescription()); + } - if (!policySet.getPolicySetOrPolicyOrPolicySetIdReference().isEmpty()) + if (!policySet.getPolicySetOrPolicyOrPolicySetIdReference().isEmpty()) { htmlOut.println("
"); + } htmlOut.println("

"); @@ -352,23 +377,25 @@ class HtmlProcessor extends SimpleCallback { } public void policySet(PolicySetType policySet, String htmlListElement) { - if (LOGGER.isTraceEnabled()) + if (LOGGER.isTraceEnabled()) { LOGGER.trace("PolicySet: " + policySet.getPolicySetId()); + } String combiningAlgorithm = "-"; String id = "-"; String version = "-"; - - if (policySet.getPolicyCombiningAlgId() != null) + if (policySet.getPolicyCombiningAlgId() != null) { combiningAlgorithm = extractLastIdentifier(policySet.getPolicyCombiningAlgId(), ":"); + } - if (policySet.getPolicySetId() != null) + if (policySet.getPolicySetId() != null) { id = extractLastIdentifier(policySet.getPolicySetId(), ":"); + } - if (policySet.getVersion() != null) + if (policySet.getVersion() != null) { version = policySet.getVersion(); - + } htmlOut.println("<" + htmlListElement + ">Policy Set ID: " + id + " (v" + version + ") " + ""); @@ -380,8 +407,7 @@ class HtmlProcessor extends SimpleCallback { htmlOut.print("

"); htmlOut.print("This policy set applies to requests with attributes "); - List anyOf_s = policySet.getTarget().getAnyOf(); - target(anyOf_s); + target(policySet.getTarget().getAnyOf()); htmlOut.println(".

"); } @@ -400,58 +426,68 @@ class HtmlProcessor extends SimpleCallback { @Override public CallbackResult onPreVisitPolicy(PolicySetType parent, PolicyType policy) { - if (LOGGER.isTraceEnabled()) + if (LOGGER.isTraceEnabled()) { LOGGER.trace("PolicySet: " + policy.getPolicyId() + " Version: " + policy.getVersion()); + } - if (parent != null && LOGGER.isTraceEnabled()) + if (parent != null && LOGGER.isTraceEnabled()) { LOGGER.trace("PolicySet: " + policy.getPolicyId() + "Parent PolicySet: " + parent.getPolicySetId() + " Version: " + parent.getVersion()); + } String description = policy.getDescription(); - if (description != null && LOGGER.isTraceEnabled()) + if (description != null && LOGGER.isTraceEnabled()) { LOGGER.trace("PolicySet: " + policy.getPolicyId() + " Description: " + policy.getDescription()); + } policy(policy); - if (!policy.getCombinerParametersOrRuleCombinerParametersOrVariableDefinition().isEmpty()) + if (!policy.getCombinerParametersOrRuleCombinerParametersOrVariableDefinition().isEmpty()) { htmlOut.println("
    "); + } return super.onPreVisitPolicy(parent, policy); } @Override public CallbackResult onPostVisitPolicy(PolicySetType parent, PolicyType policy) { - if (LOGGER.isTraceEnabled()) + if (LOGGER.isTraceEnabled()) { LOGGER.trace("PolicySet: " + policy.getPolicyId() + " Version: " + policy.getVersion()); + } - if (parent != null && LOGGER.isTraceEnabled()) + if (parent != null && LOGGER.isTraceEnabled()) { LOGGER.trace("PolicySet: " + policy.getPolicyId() + "Parent PolicySet: " + parent.getPolicySetId() + " Version: " + parent.getVersion()); + } - if (!policy.getCombinerParametersOrRuleCombinerParametersOrVariableDefinition().isEmpty()) + if (!policy.getCombinerParametersOrRuleCombinerParametersOrVariableDefinition().isEmpty()) { htmlOut.println("
"); + } htmlOut.println("

"); return super.onPostVisitPolicy(parent, policy); } public void policy(PolicyType policy) { - if (LOGGER.isTraceEnabled()) + if (LOGGER.isTraceEnabled()) { LOGGER.trace("Policy: " + policy.getPolicyId()); + } String combiningAlgorithm = "-"; String id = "-"; String version = "-"; - - if (policy.getRuleCombiningAlgId() != null) + if (policy.getRuleCombiningAlgId() != null) { combiningAlgorithm = extractLastIdentifier(policy.getRuleCombiningAlgId(), ":"); + } - if (policy.getPolicyId() != null) + if (policy.getPolicyId() != null) { id = extractLastIdentifier(policy.getPolicyId(), ":"); + } - if (policy.getVersion() != null) + if (policy.getVersion() != null) { version = policy.getVersion(); + } htmlOut.println("
  • Policy ID: " + id + " (v" + version + ") " + "
  • "); @@ -462,8 +498,7 @@ class HtmlProcessor extends SimpleCallback { htmlOut.print("

    "); htmlOut.print("This policy applies to requests with attributes "); - List anyOf_s = policy.getTarget().getAnyOf(); - target(anyOf_s); + target(policy.getTarget().getAnyOf()); htmlOut.println(".

    "); } @@ -479,14 +514,15 @@ class HtmlProcessor extends SimpleCallback { } } - @Override public CallbackResult onPreVisitRule(PolicyType parent, RuleType rule) { - if (LOGGER.isTraceEnabled()) + if (LOGGER.isTraceEnabled()) { LOGGER.trace("Rule: " + rule.getRuleId()); + } - if (parent != null && LOGGER.isTraceEnabled()) + if (parent != null && LOGGER.isTraceEnabled()) { LOGGER.trace("Parent Policy: " + parent.getPolicyId() + " Version: " + parent.getVersion()); + } String description = rule.getDescription(); if (description != null && LOGGER.isTraceEnabled()) { @@ -500,23 +536,21 @@ class HtmlProcessor extends SimpleCallback { @Override public CallbackResult onPostVisitRule(PolicyType parent, RuleType rule) { - if (LOGGER.isTraceEnabled()) - LOGGER.trace("Rule: " + rule.getRuleId()); - if (parent != null && LOGGER.isTraceEnabled()) + if (parent != null && LOGGER.isTraceEnabled()) { LOGGER.trace("Parent Policy: " + parent.getPolicyId() + " Version: " + parent.getVersion()); + } return super.onPostVisitRule(parent, rule); } public void rule(RuleType rule) { - if (LOGGER.isTraceEnabled()) - LOGGER.trace("Rule: " + rule.getRuleId()); String id = "-"; - if (rule.getRuleId() != null) + if (rule.getRuleId() != null) { id = extractLastIdentifier(rule.getRuleId(), ":"); + } htmlOut.println("
  • Rule ID: " + id + "
  • "); @@ -528,9 +562,8 @@ class HtmlProcessor extends SimpleCallback { if (rule.getTarget() == null || rule.getTarget().getAnyOf() == null || rule.getTarget().getAnyOf().isEmpty()) { htmlOut.print(" for all requests"); } else { - List anyOf_s = rule.getTarget().getAnyOf(); htmlOut.print(" for requests with attributes "); - target(anyOf_s); + target(rule.getTarget().getAnyOf()); } if (rule.getCondition() != null) { @@ -542,8 +575,9 @@ class HtmlProcessor extends SimpleCallback { if (rule.getAdviceExpressions() != null) { advice(rule.getAdviceExpressions()); - if (rule.getObligationExpressions() != null) + if (rule.getObligationExpressions() != null) { htmlOut.println(" and "); + } } if (rule.getObligationExpressions() != null) { @@ -554,8 +588,9 @@ class HtmlProcessor extends SimpleCallback { } private void advice(AdviceExpressionsType adviceExpressions) { - if (LOGGER.isTraceEnabled()) + if (LOGGER.isTraceEnabled()) { LOGGER.trace(ENTER); + } List ae = adviceExpressions.getAdviceExpression(); for (AdviceExpressionType expression : ae) { @@ -571,8 +606,9 @@ class HtmlProcessor extends SimpleCallback { } private void obligation(ObligationExpressionsType obligationExpressions) { - if (LOGGER.isTraceEnabled()) + if (LOGGER.isTraceEnabled()) { LOGGER.trace(ENTER); + } List oe = obligationExpressions.getObligationExpression(); for (ObligationExpressionType expression : oe) { @@ -588,11 +624,14 @@ class HtmlProcessor extends SimpleCallback { } /** - * @param assignments + * processAttributeAssignments. + * + * @param assignments List of AttributeAssignmentExpressionType */ private void processAttributeAssignments(List assignments) { - if (LOGGER.isTraceEnabled()) + if (LOGGER.isTraceEnabled()) { LOGGER.trace(ENTER); + } for (AttributeAssignmentExpressionType assignment : assignments) { String succintIdentifier = extractLastIdentifier(assignment.getCategory(), ":") + ":" @@ -622,8 +661,9 @@ class HtmlProcessor extends SimpleCallback { for (Object c : avt.getContent()) { countContent++; htmlOut.print("" + c + ""); - if (countContent < numContent) + if (countContent < numContent) { htmlOut.print(" or "); + } } htmlOut.println(""); } else if (assignmentObject instanceof AttributeDesignatorType @@ -636,118 +676,118 @@ class HtmlProcessor extends SimpleCallback { } /** - * - * @param anyOfList + * target. + * + * @param anyOfList List of AnyOfType's */ public void target(List anyOfList) { - if (LOGGER.isTraceEnabled()) + if (LOGGER.isTraceEnabled()) { LOGGER.trace(ENTER); + } - if (anyOfList != null) { - Iterator iterAnyOf = anyOfList.iterator(); - StringBuilder targetInHuman = new StringBuilder(); - while (iterAnyOf.hasNext()) { - AnyOfType anyOf = iterAnyOf.next(); - List allOfList = anyOf.getAllOf(); - if (allOfList != null) { - Iterator iterAllOf = allOfList.iterator(); - while (iterAllOf.hasNext()) { - AllOfType allOf = iterAllOf.next(); - List matchList = allOf.getMatch(); - if (matchList != null) { - Iterator iterMatch = matchList.iterator(); - if (matchList.size() > 1) - targetInHuman.append("("); - while (iterMatch.hasNext()) { - MatchType match = iterMatch.next(); - // - // Finally down to the actual attribute - // - StdAttribute attribute = null; - AttributeValueType value = match.getAttributeValue(); - String attributeDataType; - if (match.getAttributeDesignator() != null && value != null) { - AttributeDesignatorType designator = match.getAttributeDesignator(); - attribute = new StdAttribute(new IdentifierImpl(designator.getCategory()), - new IdentifierImpl(designator.getAttributeId()), - new StdAttributeValue>(new IdentifierImpl(value.getDataType()), - value.getContent()), - designator.getIssuer(), false); - attributeDataType = designator.getDataType(); - } else if (match.getAttributeSelector() != null && value != null) { - AttributeSelectorType selector = match.getAttributeSelector(); - attribute = new StdAttribute(new IdentifierImpl(selector.getCategory()), - new IdentifierImpl(selector.getContextSelectorId()), - new StdAttributeValue>(new IdentifierImpl(value.getDataType()), - value.getContent()), - null, false); - attributeDataType = selector.getDataType(); - } else { - LOGGER.warn("NULL designator/selector or value for match."); - attributeDataType = "NA"; - } + if (anyOfList == null) { + return; + } + Iterator iterAnyOf = anyOfList.iterator(); + StringBuilder targetInHuman = new StringBuilder(); + while (iterAnyOf.hasNext()) { + AnyOfType anyOf = iterAnyOf.next(); + List allOfList = anyOf.getAllOf(); + Iterator iterAllOf = allOfList.iterator(); + while (iterAllOf.hasNext()) { + AllOfType allOf = iterAllOf.next(); + List matchList = allOf.getMatch(); + Iterator iterMatch = matchList.iterator(); + if (matchList.size() > 1) { + targetInHuman.append("("); + } + while (iterMatch.hasNext()) { + MatchType match = iterMatch.next(); + // + // Finally down to the actual attribute + // + StdAttribute attribute = null; + AttributeValueType value = match.getAttributeValue(); + String attributeDataType; + if (match.getAttributeDesignator() != null && value != null) { + AttributeDesignatorType designator = match.getAttributeDesignator(); + attribute = new StdAttribute(new IdentifierImpl(designator.getCategory()), + new IdentifierImpl(designator.getAttributeId()), + new StdAttributeValue>(new IdentifierImpl(value.getDataType()), + value.getContent()), + designator.getIssuer(), false); + attributeDataType = designator.getDataType(); + } else if (match.getAttributeSelector() != null && value != null) { + AttributeSelectorType selector = match.getAttributeSelector(); + attribute = new StdAttribute(new IdentifierImpl(selector.getCategory()), + new IdentifierImpl(selector.getContextSelectorId()), + new StdAttributeValue>(new IdentifierImpl(value.getDataType()), + value.getContent()), + null, false); + attributeDataType = selector.getDataType(); + } else { + LOGGER.warn("NULL designator/selector or value for match."); + attributeDataType = "NA"; + } - String functionName = getHumanFunction(match.getMatchId()); - if (attribute != null) { - String succintIdentifier = extractLastIdentifier( - attribute.getCategory().stringValue(), ":") + ":" - + extractLastIdentifier(attribute.getAttributeId().stringValue(), ":"); - AttributeIdentifiers ai = - new AttributeIdentifiers(attribute.getCategory().stringValue(), - attributeDataType, attribute.getAttributeId().stringValue()); - this.attributeIdentifiersMap.put(succintIdentifier, ai); - - targetInHuman.append("" - + succintIdentifier + " " + functionName + " "); - - int numAttributes = attribute.getValues().size(); - int count = 0; - for (AttributeValue v : attribute.getValues()) { - count++; - if (v.getValue() instanceof Collection) { - Collection value_s = (Collection) v.getValue(); - int numValues = value_s.size(); - int countValues = 0; - for (Object o : value_s) { - countValues++; - targetInHuman.append(" " + o + ""); - if (countValues < numValues) { - targetInHuman.append(", or"); - } - } - } else { - targetInHuman.append(" " + v.getValue() + ""); - if (count < numAttributes) { - targetInHuman.append(", or "); - } - } + String functionName = getHumanFunction(match.getMatchId()); + if (attribute != null) { + String succintIdentifier = extractLastIdentifier( + attribute.getCategory().stringValue(), ":") + ":" + + extractLastIdentifier(attribute.getAttributeId().stringValue(), ":"); + AttributeIdentifiers ai = + new AttributeIdentifiers(attribute.getCategory().stringValue(), + attributeDataType, attribute.getAttributeId().stringValue()); + this.attributeIdentifiersMap.put(succintIdentifier, ai); + + targetInHuman.append("" + + succintIdentifier + " " + functionName + " "); + + int numAttributes = attribute.getValues().size(); + int count = 0; + for (AttributeValue v : attribute.getValues()) { + count++; + if (v.getValue() instanceof Collection) { + Collection collectionValues = (Collection) v.getValue(); + int numValues = collectionValues.size(); + int countValues = 0; + for (Object o : collectionValues) { + countValues++; + targetInHuman.append(" " + o + ""); + if (countValues < numValues) { + targetInHuman.append(", or"); } } - - if (iterMatch.hasNext()) { - targetInHuman.append(" and "); + } else { + targetInHuman.append(" " + v.getValue() + ""); + if (count < numAttributes) { + targetInHuman.append(", or "); } - } // end iterMatch - if (matchList.size() > 1) { - targetInHuman.append(")"); } } - if (iterAllOf.hasNext()) { - targetInHuman.append(" or "); - } - } // end iterAllOf - } - if (iterAnyOf.hasNext()) { - targetInHuman = new StringBuilder(); - targetInHuman.append("(" + targetInHuman + ")" + " or "); - } else { - if (anyOfList.size() > 1) { - targetInHuman.append(")"); } + + if (iterMatch.hasNext()) { + targetInHuman.append(" and "); + } + } // end iterMatch + if (matchList.size() > 1) { + targetInHuman.append(")"); } - } // end iterAnyOf - htmlOut.println(targetInHuman); + } + if (iterAllOf.hasNext()) { + targetInHuman.append(" or "); + } + } // end iterAllOf + if (iterAnyOf.hasNext()) { + targetInHuman = new StringBuilder(); + targetInHuman.append("(" + targetInHuman + ")" + " or "); + } else { + if (anyOfList.size() > 1) { + targetInHuman.append(")"); + } } + htmlOut.println(targetInHuman); } private String getHumanFunction(String matchId) { @@ -817,12 +857,12 @@ class HtmlProcessor extends SimpleCallback { } else { StringBuilder forResult = new StringBuilder(); for (JAXBElement e : exps) { - Object v = e.getValue(); + Object theValue = e.getValue(); if (LOGGER.isDebugEnabled()) { - LOGGER.debug("one-and-only children: " + v); + LOGGER.debug("one-and-only children: " + theValue); } - if (v != null) { - forResult.append(stringifyExpression(v)); + if (theValue != null) { + forResult.append(stringifyExpression(theValue)); } } return forResult.toString(); @@ -842,8 +882,8 @@ class HtmlProcessor extends SimpleCallback { } StringBuilder applySubresult = new StringBuilder(); for (JAXBElement e : apply.getExpression()) { - Object v = e.getValue(); - if (v != null) { + Object theValue = e.getValue(); + if (theValue != null) { applySubresult.append(this.stringifyExpression(e.getValue())); } } @@ -908,11 +948,12 @@ class HtmlProcessor extends SimpleCallback { if (expression instanceof AttributeValueType) { AttributeValueType avt = (AttributeValueType) expression; List content = avt.getContent(); - StringBuilder value_s = new StringBuilder(); + StringBuilder stringValue = new StringBuilder(" "); for (Object o : content) { - value_s.append(" " + o.toString()); + stringValue.append(" "); + stringValue.append(o.toString()); } - return " " + value_s.toString(); + return stringValue.toString(); } if (expression instanceof VariableReferenceType) { //