TranslationRuleConfigurationFile.java 48 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057
/*
 * Decompiled with CFR 0_118.
 * 
 * Could not load the following classes:
 *  com.adobe.aemds.guide.service.GuideLocalizationService
 *  com.adobe.aemds.guide.utils.GuideUtils
 *  com.adobe.cq.launches.api.LaunchManager
 *  com.adobe.cq.launches.api.LaunchManagerFactory
 *  com.adobe.granite.comments.CommentManager
 *  com.adobe.granite.translation.api.TranslationManager
 *  com.adobe.granite.translation.api.xliff.TranslationXLIFFService
 *  com.adobe.granite.translation.core.TranslationCloudConfigUtil
 *  com.adobe.granite.ui.clientlibs.HtmlLibraryManager
 *  com.day.cq.dam.api.Asset
 *  com.day.cq.dam.commons.util.DamLanguageUtil
 *  com.day.cq.dam.commons.util.DamUtil
 *  com.day.cq.tagging.TagManager
 *  com.day.cq.wcm.api.LanguageManager
 *  com.day.cq.wcm.api.PageManagerFactory
 *  com.day.cq.wcm.contentsync.PageExporter
 *  javax.jcr.Binary
 *  javax.jcr.Node
 *  javax.jcr.NodeIterator
 *  javax.jcr.Property
 *  javax.jcr.RepositoryException
 *  javax.jcr.Session
 *  javax.jcr.query.InvalidQueryException
 *  org.apache.commons.lang3.StringUtils
 *  org.apache.sling.api.resource.Resource
 *  org.apache.sling.api.resource.ResourceResolver
 *  org.apache.sling.commons.html.HtmlParser
 *  org.apache.sling.commons.json.JSONArray
 *  org.apache.sling.commons.json.JSONException
 *  org.apache.sling.commons.json.JSONObject
 *  org.slf4j.Logger
 *  org.slf4j.LoggerFactory
 */
package com.adobe.cq.wcm.translation.impl;

import com.adobe.aemds.guide.service.GuideLocalizationService;
import com.adobe.aemds.guide.utils.GuideUtils;
import com.adobe.cq.launches.api.LaunchManager;
import com.adobe.cq.launches.api.LaunchManagerFactory;
import com.adobe.cq.wcm.translation.impl.I18nDictionary;
import com.adobe.cq.wcm.translation.impl.TranslationUtils;
import com.adobe.granite.comments.CommentManager;
import com.adobe.granite.translation.api.TranslationManager;
import com.adobe.granite.translation.api.xliff.TranslationXLIFFService;
import com.adobe.granite.translation.core.TranslationCloudConfigUtil;
import com.adobe.granite.ui.clientlibs.HtmlLibraryManager;
import com.day.cq.dam.api.Asset;
import com.day.cq.dam.commons.util.DamLanguageUtil;
import com.day.cq.dam.commons.util.DamUtil;
import com.day.cq.tagging.TagManager;
import com.day.cq.wcm.api.LanguageManager;
import com.day.cq.wcm.api.PageManagerFactory;
import com.day.cq.wcm.contentsync.PageExporter;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Set;
import javax.jcr.Binary;
import javax.jcr.Node;
import javax.jcr.NodeIterator;
import javax.jcr.Property;
import javax.jcr.RepositoryException;
import javax.jcr.Session;
import javax.jcr.query.InvalidQueryException;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import org.apache.commons.lang3.StringUtils;
import org.apache.sling.api.resource.Resource;
import org.apache.sling.api.resource.ResourceResolver;
import org.apache.sling.commons.html.HtmlParser;
import org.apache.sling.commons.json.JSONArray;
import org.apache.sling.commons.json.JSONException;
import org.apache.sling.commons.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;

public class TranslationRuleConfigurationFile {
    private TranslationManager translationManager;
    private ResourceResolver resourceResolver;
    private TranslationCloudConfigUtil translationCloudConfigUtil;
    private String strFilePath;
    PageManagerFactory pageManagerFactory;
    HtmlLibraryManager htmlLibraryManager;
    GuideLocalizationService guideLocalizationService;
    private CommentManager commentManager = null;
    private LanguageManager languageManager = null;
    private LaunchManagerFactory launchesManagerFactory = null;
    private PageExporter pageExporter = null;
    private HtmlParser htmlParser = null;
    private String srcLang = "";
    private String dstLang = "";
    private boolean bInitialized = false;
    private boolean bAddAsset = true;
    private boolean bAddEmbeddedAssets = true;
    private ArrayList<NodeRule> rulesCompleteArray;
    private ArrayList<NodeRule> rulesWithContainsArray;
    private String exportFormat = "xml";
    private TranslationXLIFFService xliffService = null;
    private boolean bUpdateAssetsWorkflow = false;
    private String assetUpdateDestinationRoot = null;
    private String assetUpdateSourceRoot = null;
    private HashMap<String, AssetNodeRule> assetNodeHash;
    private static final Logger logger = LoggerFactory.getLogger(TranslationRuleConfigurationFile.class);

    public void setAssetUpdateDestinationRoot(String assetUpdateDestinationRoot) {
        this.assetUpdateDestinationRoot = assetUpdateDestinationRoot;
    }

    public void setAssetUpdateSourceRoot(String assetUpdateSourceRoot) {
        this.assetUpdateSourceRoot = assetUpdateSourceRoot;
    }

    public void setbUpdateAssetsWorkflow(boolean bUpdateAssetsWorkflow) {
        this.bUpdateAssetsWorkflow = bUpdateAssetsWorkflow;
    }

    public ResourceResolver getResourceResolver() {
        return this.resourceResolver;
    }

    public TranslationRuleConfigurationFile(ResourceResolver resourceResolver, String strFilePath, String sourceLang, String destLang, TranslationManager translationManager, TranslationCloudConfigUtil translationCloudConfigUtil, PageManagerFactory pageManagerFactory, HtmlLibraryManager htmlLibraryManager, GuideLocalizationService guideLocalizationService, LanguageManager languageManager, LaunchManagerFactory launchesManagerFactory, PageExporter exporter, HtmlParser htmlParser) {
        this.translationManager = translationManager;
        this.srcLang = sourceLang;
        this.dstLang = destLang;
        this.resourceResolver = resourceResolver;
        this.strFilePath = strFilePath;
        this.pageManagerFactory = pageManagerFactory;
        this.translationCloudConfigUtil = translationCloudConfigUtil;
        this.htmlLibraryManager = htmlLibraryManager;
        this.guideLocalizationService = guideLocalizationService;
        this.languageManager = languageManager;
        this.launchesManagerFactory = launchesManagerFactory;
        this.pageExporter = exporter;
        this.htmlParser = htmlParser;
        this.bInitialized = false;
    }

    public TranslationRuleConfigurationFile(ResourceResolver resourceResolver, String strFilePath, String sourceLang, String destLang, TranslationManager translationManager, TranslationCloudConfigUtil translationCloudConfigUtil, PageManagerFactory pageManagerFactory, HtmlLibraryManager htmlLibraryManager, GuideLocalizationService guideLocalizationService, boolean bAddAsset, boolean bAddEmbeddedAssets) {
        this.translationManager = translationManager;
        this.srcLang = sourceLang;
        this.dstLang = destLang;
        this.resourceResolver = resourceResolver;
        this.strFilePath = strFilePath;
        this.pageManagerFactory = pageManagerFactory;
        this.translationCloudConfigUtil = translationCloudConfigUtil;
        this.htmlLibraryManager = htmlLibraryManager;
        this.guideLocalizationService = guideLocalizationService;
        this.bAddAsset = bAddAsset;
        this.bAddEmbeddedAssets = bAddEmbeddedAssets;
        this.bInitialized = false;
    }

    public String getExportFormat() {
        return this.exportFormat;
    }

    public void setExportFormat(String exportFormat) {
        this.exportFormat = exportFormat;
    }

    public TranslationXLIFFService getXLIFFService() {
        return this.xliffService;
    }

    public void setXLIFFService(TranslationXLIFFService xliffService) {
        this.xliffService = xliffService;
    }

    public CommentManager getCommentManager() {
        return this.commentManager;
    }

    public void setCommentManager(CommentManager commentManager) {
        this.commentManager = commentManager;
    }

    public TranslatableNode getTranslatableNode(Node childNode, String strParentPath) {
        TranslatableNode retVal = new TranslatableNode();
        retVal.node = childNode;
        retVal.strReferencedNode = strParentPath;
        return retVal;
    }

    private void init() throws RepositoryException, IOException {
        if (!this.bInitialized) {
            this.rulesCompleteArray = new ArrayList();
            this.rulesWithContainsArray = new ArrayList();
            this.assetNodeHash = new HashMap();
            Resource resource = this.resourceResolver.getResource(this.strFilePath);
            Node node = (Node)resource.adaptTo(Node.class);
            Node jcrContent = node.getNode("jcr:content");
            InputStream contentStream = jcrContent.getProperty("jcr:data").getBinary().getStream();
            this.parse(contentStream);
            contentStream.close();
            this.bInitialized = true;
        }
    }

    public TranslationManager getTranslationManager() {
        return this.translationManager;
    }

    public TagManager getTagManager() {
        return (TagManager)this.resourceResolver.adaptTo(TagManager.class);
    }

    public TranslationCloudConfigUtil getTranslationCloudConfigUtil() {
        return this.translationCloudConfigUtil;
    }

    private void parse(InputStream contentStream) {
        try {
            DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
            DocumentBuilder db = dbf.newDocumentBuilder();
            Document doc = db.parse(contentStream);
            org.w3c.dom.Node rootNode = doc.getFirstChild();
            NodeList nodeList = rootNode.getChildNodes();
            for (int index = 0; index < nodeList.getLength(); ++index) {
                org.w3c.dom.Node childNode = nodeList.item(index);
                if (childNode.getNodeType() != 1) continue;
                if ("node".equals(childNode.getNodeName())) {
                    this.processNode(childNode, null);
                    continue;
                }
                if (!"assetNode".equals(childNode.getNodeName())) continue;
                this.processAssetNode(childNode);
            }
        }
        catch (Exception e) {
            e.printStackTrace();
        }
    }

    private boolean isNodeValidBasedOnFilterRules(Node node) throws RepositoryException, IOException {
        NodeRule nodeRule;
        this.init();
        boolean bRetVal = true;
        String strResourceType = TranslationUtils.getNodeResourceType(logger, node, "");
        ArrayList<String> resourceTypeList = new ArrayList<String>();
        if (!StringUtils.isEmpty((CharSequence)strResourceType)) {
            resourceTypeList.add(strResourceType);
        }
        if ((nodeRule = this.getMatchingNodeRule(node, node.getPath(), resourceTypeList)) != null && !nodeRule.isValidBasedonFilters(node)) {
            bRetVal = false;
        }
        return bRetVal;
    }

    public ArrayList<String> getTranslatablePropertyListForNode(Node inputNode) throws RepositoryException, IOException {
        ArrayList<String> strRetList = new ArrayList<String>();
        NodeRule nodeRule = this.getNodeRuleFromInputNode(inputNode);
        if (nodeRule != null) {
            strRetList = nodeRule.getTranslatablePropertyList();
        }
        return strRetList;
    }

    public ArrayList<String> getLanguagePatchPropertyListForNode(Node inputNode) throws RepositoryException, IOException {
        ArrayList<String> strRetList = new ArrayList<String>();
        NodeRule nodeRule = this.getNodeRuleFromInputNode(inputNode);
        if (nodeRule != null) {
            strRetList = nodeRule.getLanguagePatchPropertyList();
        }
        return strRetList;
    }

    private NodeRule getNodeRuleFromInputNode(Node inputNode) throws RepositoryException, IOException {
        NodeRule nodeRule;
        this.init();
        Node node = this.getSourceNodeFromInput(inputNode);
        String strResourceType = TranslationUtils.getNodeResourceType(logger, node, "");
        ArrayList<String> resourceTypeList = new ArrayList<String>();
        if (!StringUtils.isEmpty((CharSequence)strResourceType)) {
            resourceTypeList.add(strResourceType);
        }
        if ((nodeRule = this.getMatchingNodeRule(node, node.getPath(), resourceTypeList)) != null && nodeRule.isValidBasedonFilters(node)) {
            return nodeRule;
        }
        return null;
    }

    private Node getSourceNodeFromInput(Node inputNode) throws RepositoryException {
        Resource resource;
        String strNodePath;
        if (inputNode != null && (resource = this.resourceResolver.getResource(strNodePath = inputNode.getPath())) != null && (resource = TranslationUtils.getSourceResourceFromLaunch(resource)) != null) {
            return (Node)resource.adaptTo(Node.class);
        }
        return inputNode;
    }

    private void processAssetNode(org.w3c.dom.Node currentNode) {
        if (currentNode != null) {
            String strResourceType = this.getNodeResourceType(currentNode);
            String strFileReference = this.getElementAttribute((Element)currentNode, "assetReferenceAttribute", "");
            if (!StringUtils.isEmpty((CharSequence)strResourceType)) {
                this.addAssetNodeDetails(strResourceType, strFileReference);
            }
        }
    }

    private AssetNodeRule getAssetNodeFileRule(String strResourceType) {
        return this.assetNodeHash.get(strResourceType);
    }

    private void addAssetNodeDetails(String strResourceType, String strFileReference) {
        this.assetNodeHash.put(strResourceType, new AssetNodeRule(strResourceType, strFileReference));
    }

    private void processNode(org.w3c.dom.Node currentNode, NodeRule parentRule) {
        if (currentNode != null) {
            String strNodePath = this.getNodePath(currentNode);
            if (StringUtils.isEmpty((CharSequence)strNodePath) && parentRule != null) {
                strNodePath = parentRule.strNodePath;
            }
            String strNodePathContains = this.getNodePathContains(currentNode);
            String strResourceType = this.getNodeResourceType(currentNode);
            NodeRule nodeRule = this.createNodeRuleIfRequired(strNodePath, strResourceType, strNodePathContains);
            nodeRule.copyRules(parentRule);
            NodeList nodeList = currentNode.getChildNodes();
            for (int index = 0; index < nodeList.getLength(); ++index) {
                org.w3c.dom.Node childNode = nodeList.item(index);
                if (childNode.getNodeType() != 1) continue;
                String strChildNodeName = childNode.getNodeName();
                if ("node".equals(strChildNodeName)) {
                    this.processNode(childNode, nodeRule);
                    continue;
                }
                if ("property".equals(strChildNodeName)) {
                    this.processProperty(childNode, nodeRule);
                    continue;
                }
                if (!"filter".equals(strChildNodeName)) continue;
                this.processFilter(childNode, nodeRule);
            }
        }
    }

    private void processFilter(org.w3c.dom.Node currentNode, NodeRule nodeRule) {
        if (currentNode != null) {
            NodeList nodeList = currentNode.getChildNodes();
            for (int index = 0; index < nodeList.getLength(); ++index) {
                String strChildNodeName;
                org.w3c.dom.Node childNode = nodeList.item(index);
                if (childNode.getNodeType() != 1 || !"node".equals(strChildNodeName = childNode.getNodeName())) continue;
                this.processFilterNode(childNode, nodeRule);
            }
        }
    }

    private void processFilterNode(org.w3c.dom.Node currentNode, NodeRule currentNodeRule) {
        Element element = (Element)currentNode;
        String strPathContains = this.getElementAttribute(element, "pathContains", "");
        String strContainsProperty = this.getElementAttribute(element, "containsProperty", "");
        String strPropertyValue = this.getElementAttribute(element, "propertyValue", "");
        boolean bIsDeep = this.getElementAttribute(element, "isDeep", true);
        currentNodeRule.addFilterNode(strPathContains, strContainsProperty, strPropertyValue, bIsDeep);
    }

    private void processProperty(org.w3c.dom.Node currentNode, NodeRule currentNodeRule) {
        Element element = (Element)currentNode;
        String strPropertyName = this.getElementAttribute(element, "name", "");
        if (strPropertyName != null && !strPropertyName.isEmpty()) {
            boolean bInherit = this.getElementAttribute(element, "inherit", true);
            boolean bTranslate = this.getElementAttribute(element, "translate", true);
            boolean bPatchLanguage = this.getElementAttribute(element, "updateDestinationLanguage", false);
            currentNodeRule.processProperty(strPropertyName, bInherit, bTranslate, bPatchLanguage);
        }
    }

    private boolean getElementAttribute(Element element, String strAttributeName, boolean bDefault) {
        String strAttributeValue = this.getElementAttribute(element, strAttributeName, null);
        boolean bRetVal = bDefault;
        if (strAttributeValue != null) {
            if (strAttributeValue.equalsIgnoreCase("true")) {
                bRetVal = true;
            } else if (strAttributeValue.equalsIgnoreCase("false")) {
                bRetVal = false;
            }
        }
        return bRetVal;
    }

    private String removeEndBackslash(String strNodePath) {
        if (strNodePath.endsWith("/")) {
            strNodePath = strNodePath.substring(0, strNodePath.length() - 1);
        }
        return strNodePath;
    }

    private NodeRule createNodeRuleIfRequired(String strNodePath, String strResourceType, String strNodePathContains) {
        strNodePath = this.removeEndBackslash(strNodePath);
        strNodePath = strNodePath.toLowerCase();
        if (StringUtils.isEmpty((CharSequence)strResourceType)) {
            strResourceType = "";
        } else {
            strResourceType = this.removeEndBackslash(strResourceType);
            strResourceType = strResourceType.toLowerCase();
        }
        for (NodeRule rule : this.rulesCompleteArray) {
            if (!rule.strNodePath.equals(strNodePath) || !rule.strResourceType.equals(strResourceType) || !rule.strNodePathContains.equals(strNodePathContains)) continue;
            return rule;
        }
        NodeRule nodeRule = new NodeRule(strNodePath, strResourceType, strNodePathContains);
        this.rulesCompleteArray.add(nodeRule);
        if (!StringUtils.isEmpty((CharSequence)strNodePathContains)) {
            this.rulesWithContainsArray.add(nodeRule);
        }
        return nodeRule;
    }

    private NodeRule getNodeRule(String strNodePath, String strResourceType, String strActualNodePath) {
        strNodePath = this.removeEndBackslash(strNodePath);
        strNodePath = strNodePath.toLowerCase();
        if (StringUtils.isEmpty((CharSequence)strResourceType)) {
            strResourceType = "";
        } else {
            strResourceType = this.removeEndBackslash(strResourceType);
            strResourceType = strResourceType.toLowerCase();
        }
        NodeRule nodeRule = this.findRuleFromArray(this.rulesWithContainsArray, strNodePath, strResourceType, strActualNodePath);
        if (nodeRule == null) {
            nodeRule = this.findRuleFromArray(this.rulesCompleteArray, strNodePath, strResourceType, strActualNodePath);
        }
        return nodeRule;
    }

    private NodeRule findRuleFromArray(ArrayList<NodeRule> rulesArray, String strNodePath, String strResourceType, String strActualNodePath) {
        NodeRule retRule = null;
        for (NodeRule rule : rulesArray) {
            boolean bFound = false;
            if (!StringUtils.isEmpty((CharSequence)rule.strNodePath)) {
                if (rule.strNodePath.equals(strNodePath) && rule.strResourceType.equals(strResourceType)) {
                    bFound = true;
                    if (!StringUtils.isEmpty((CharSequence)rule.strNodePathContains) && strActualNodePath.indexOf(rule.strNodePathContains) == -1) {
                        bFound = false;
                    }
                }
            } else if (!StringUtils.isEmpty((CharSequence)rule.strNodePathContains) && strActualNodePath.indexOf(rule.strNodePathContains) != -1) {
                bFound = true;
            }
            if (!bFound) continue;
            retRule = rule;
            break;
        }
        return retRule;
    }

    private NodeRule getMatchingNodeRule(Node node, String strActualNodePath, ArrayList<String> resourceTypeList) throws RepositoryException {
        NodeRule nodeRule = null;
        if (node != null) {
            String strResourceType = TranslationUtils.getNodeResourceType(logger, node, "");
            if (!StringUtils.isEmpty((CharSequence)strResourceType) && !resourceTypeList.contains(strResourceType)) {
                resourceTypeList.add(strResourceType);
            }
            if ((nodeRule = this.getNodeRuleWithResourceType(node.getPath(), resourceTypeList, strActualNodePath)) == null) {
                nodeRule = this.getNodeRule(node.getPath(), "", strActualNodePath);
            }
            if (nodeRule == null) {
                Node parentNode = null;
                try {
                    parentNode = node.getParent();
                }
                catch (RepositoryException ex) {
                    // empty catch block
                }
                nodeRule = this.getMatchingNodeRule(parentNode, strActualNodePath, resourceTypeList);
            }
        }
        return nodeRule;
    }

    private NodeRule getNodeRuleWithResourceType(String path, ArrayList<String> resourceTypeList, String strActualNodePath) {
        NodeRule retVal = null;
        for (int index = 0; index < resourceTypeList.size() && retVal == null; ++index) {
            retVal = this.getNodeRule(path, resourceTypeList.get(index), strActualNodePath);
        }
        return retVal;
    }

    private String getNodePath(org.w3c.dom.Node node) {
        return this.getElementAttribute((Element)node, "path", "");
    }

    private String getNodePathContains(org.w3c.dom.Node node) {
        return this.getElementAttribute((Element)node, "pathContains", "");
    }

    private String getNodeResourceType(org.w3c.dom.Node node) {
        return this.getElementAttribute((Element)node, "resourceType", "");
    }

    private String getElementAttribute(Element element, String strAttributeName, String strDefaultValue) {
        return element.hasAttribute(strAttributeName) ? element.getAttribute(strAttributeName) : strDefaultValue;
    }

    public String getSourceLanguage() {
        return this.srcLang;
    }

    public String getDestinationLanguage() {
        return this.dstLang;
    }

    public ArrayList<TranslatableNode> getTranslatableNodeListFromResource(Resource pageResource, Session userSession, ArrayList<TranslatableNode> outputNodeList, boolean bCheckAssets, boolean bCheckForEmbeddedAssets) throws RepositoryException, IOException {
        this.init();
        ArrayList inputList = new ArrayList<TranslatableNode>();
        this.getCQPageListFromPath(inputList, pageResource);
        this.getTranslatableNodeList(inputList, outputNodeList, true);
        if (bCheckForEmbeddedAssets) {
            for (TranslatableNode pageNode : inputList) {
                ArrayList<Node> assetList;
                if (!this.isNodeValidBasedOnFilterRules(pageNode.node) || (assetList = this.getAssetListFromPage(pageNode.node, userSession, false)) == null || assetList.size() <= 0) continue;
                for (int index = 0; index < assetList.size(); ++index) {
                    Node newAssetNode = assetList.get(index);
                    if (this.isNodePresentInList(outputNodeList, newAssetNode)) continue;
                    TranslatableNode newAssetTranslationNode = new TranslatableNode();
                    newAssetTranslationNode.node = newAssetNode;
                    newAssetTranslationNode.strReferencedNode = pageNode.node.getPath();
                    outputNodeList.add(newAssetTranslationNode);
                }
            }
        }
        if (bCheckAssets) {
            inputList = new ArrayList();
            this.getCQAssetListFromPath(inputList, pageResource);
            this.getTranslatableNodeList(inputList, outputNodeList, false);
        }
        if (this.guideLocalizationService != null) {
            inputList = new ArrayList();
            try {
                this.getGuideContainerDictsFromPath(inputList, (Node)pageResource.adaptTo(Node.class));
                for (TranslatableNode translatableNode : outputNodeList) {
                    this.getGuideContainerDictsFromPath(inputList, translatableNode.node);
                }
            }
            catch (JSONException ignored) {
                // empty catch block
            }
            this.getTranslatableNodeList(inputList, outputNodeList, false);
        }
        inputList = new ArrayList();
        this.getI18nDictionaryFromPath(inputList, pageResource);
        this.getTranslatableNodeList(inputList, outputNodeList, false);
        inputList = new ArrayList();
        this.getCQTagsFromPath(inputList, pageResource);
        this.getTranslatableNodeList(inputList, outputNodeList, false);
        return outputNodeList;
    }

    private ArrayList<TranslatableNode> getTranslatableNodeList(ArrayList<TranslatableNode> inputNodeList, ArrayList<TranslatableNode> nodeList, boolean bCheckForTranslation) throws RepositoryException, IOException {
        if (inputNodeList != null) {
            for (TranslatableNode translatableNode : inputNodeList) {
                String strNodePrimaryType = this.getNodePrimaryType(translatableNode.node);
                if (translatableNode.node == null || this.isNodeLaunchOutOfScope(translatableNode.node) || bCheckForTranslation && !this.canTranslateNode(translatableNode.node, strNodePrimaryType) || this.isNodePresentInList(nodeList, translatableNode.node)) continue;
                nodeList.add(translatableNode);
            }
        }
        return nodeList;
    }

    private boolean isNodeLaunchOutOfScope(Node currentNode) {
        try {
            String strResourceType;
            Node contentNode = currentNode.getNode("jcr:content");
            if (contentNode != null && "launches/components/outofscope".equals(strResourceType = TranslationUtils.getNodeResourceType(logger, contentNode, ""))) {
                return true;
            }
        }
        catch (Exception ex) {
            // empty catch block
        }
        return false;
    }

    private boolean isNodePresentInList(ArrayList<TranslatableNode> nodeList, Node node) throws RepositoryException {
        boolean bPresent = false;
        for (TranslatableNode childNode : nodeList) {
            if (!childNode.node.getPath().equals(node.getPath())) continue;
            bPresent = true;
            break;
        }
        return bPresent;
    }

    private boolean canTranslateNode(Node node, String strNodePrimaryType) throws RepositoryException, IOException {
        boolean bRetVal = false;
        if (!this.isNodePropertyTranslatable(node)) {
            NodeIterator nodeIterator = node.getNodes();
            while (nodeIterator.hasNext() && !bRetVal) {
                Node childNode = (Node)nodeIterator.next();
                if (TranslationRuleConfigurationFile.isNodeOfPrimaryType(childNode, strNodePrimaryType)) continue;
                bRetVal = this.canTranslateNode(childNode, strNodePrimaryType);
            }
        } else {
            bRetVal = true;
        }
        return bRetVal;
    }

    private static boolean isNodeOfPrimaryType(Node node, String strNodePrimaryType) throws RepositoryException {
        String strVal;
        boolean bRetVal = false;
        if (node != null && (strVal = TranslationUtils.getStringAttribute(logger, node, "jcr:primaryType", null)) != null) {
            bRetVal = strNodePrimaryType.equals(strVal);
        }
        return bRetVal;
    }

    private static boolean isPageNode(Node node) throws RepositoryException {
        return TranslationRuleConfigurationFile.isNodeOfPrimaryType(node, "cq:Page");
    }

    public boolean isAddAssetAllowed() {
        return this.bAddAsset;
    }

    public boolean isbAddEmbeddedAssetsAllowed() {
        return this.bAddEmbeddedAssets;
    }

    private boolean isNodePropertyTranslatable(Node node) throws RepositoryException, IOException {
        ArrayList<String> propList;
        boolean bRetVal = false;
        if (node != null && (propList = this.getTranslatablePropertyListForNode(node)) != null && propList.size() > 0) {
            for (String propertyName : propList) {
                if (!node.hasProperty(propertyName)) continue;
                bRetVal = true;
                break;
            }
        }
        return bRetVal;
    }

    private void getCQPageListFromPath(ArrayList<TranslatableNode> nodeList, Resource pageResource) throws InvalidQueryException, RepositoryException {
        this.getCQObjectListFromPath(nodeList, (Node)pageResource.adaptTo(Node.class), "cq:Page");
    }

    private void getGuideContainerDictsFromPath(ArrayList<TranslatableNode> nodeList, Node currentNode) throws RepositoryException, JSONException {
        if (GuideUtils.isGuideContainerResource((Resource)this.resourceResolver.getResource(currentNode.getPath()))) {
            JSONObject jsonResult = this.guideLocalizationService.createDictionaryWithFragmentContent(this.resourceResolver.getResource(currentNode.getPath()), this.getDestinationLanguage());
            JSONArray languageArray = (JSONArray)jsonResult.get("languages");
            if (languageArray.length() == 1) {
                JSONObject languageEntry = (JSONObject)languageArray.get(0);
                JSONArray languageDicts = (JSONArray)languageEntry.get("dicts");
                for (int i = 0; i < languageDicts.length(); ++i) {
                    String dictPath = (String)languageDicts.get(i);
                    TranslatableNode newNode = new TranslatableNode();
                    newNode.node = (Node)this.resourceResolver.getResource(dictPath).adaptTo(Node.class);
                    nodeList.add(newNode);
                }
            } else {
                logger.error("Failed to get guideContainer dictionary)");
            }
        } else {
            NodeIterator nodeIterator = currentNode.getNodes();
            while (nodeIterator.hasNext()) {
                Node child = (Node)nodeIterator.next();
                if (TranslationRuleConfigurationFile.isPageNode(child)) continue;
                this.getGuideContainerDictsFromPath(nodeList, child);
            }
        }
    }

    String getNodePrimaryType(Node currentNode) throws RepositoryException {
        return TranslationUtils.getStringAttribute(logger, currentNode, "jcr:primaryType", null);
    }

    void getCQObjectListFromPath(ArrayList<TranslatableNode> nodeList, Node currentNode, String strResourceType) throws RepositoryException {
        String strPrimaryType = this.getNodePrimaryType(currentNode);
        if (strPrimaryType != null && strResourceType.equals(strPrimaryType) && (!this.bUpdateAssetsWorkflow || this.assetUpdateSourceExists(currentNode))) {
            TranslatableNode newNode = new TranslatableNode();
            newNode.node = currentNode;
            nodeList.add(newNode);
        }
        boolean childNodeTranslationRequired = true;
        if (TranslationUtils.isContentFragment(currentNode) || strPrimaryType.equals("dam:Asset")) {
            childNodeTranslationRequired = false;
        }
        if (childNodeTranslationRequired) {
            NodeIterator nodeIterator = currentNode.getNodes();
            while (nodeIterator.hasNext()) {
                Node childNode = (Node)nodeIterator.next();
                this.getCQObjectListFromPath(nodeList, childNode, strResourceType);
            }
        }
    }

    private boolean assetUpdateSourceExists(Node node) throws RepositoryException {
        String sourcePath;
        boolean retval = true;
        String nodePath = node.getPath();
        if (this.assetUpdateSourceRoot != null && this.assetUpdateDestinationRoot != null && !DamUtil.isAsset((Resource)this.resourceResolver.getResource(sourcePath = nodePath.replaceFirst(this.assetUpdateDestinationRoot, this.assetUpdateSourceRoot)))) {
            retval = false;
        }
        return retval;
    }

    private void getCQAssetListFromPath(ArrayList<TranslatableNode> nodeList, Resource pageResource) throws InvalidQueryException, RepositoryException {
        this.getCQObjectListFromPath(nodeList, (Node)pageResource.adaptTo(Node.class), "dam:Asset");
    }

    private void getI18nDictionaryFromPath(ArrayList<TranslatableNode> nodeList, Resource resource) throws InvalidQueryException, RepositoryException {
        Node currentNode = (Node)resource.adaptTo(Node.class);
        if (I18nDictionary.isI18nDictionary(resource)) {
            logger.trace("Found I18nDict {}", (Object)currentNode.getPath());
            TranslatableNode newNode = new TranslatableNode();
            newNode.node = currentNode;
            nodeList.add(newNode);
        }
    }

    private void getCQTagsFromPath(ArrayList<TranslatableNode> nodeList, Resource resource) throws RepositoryException {
        Node currentNode = (Node)resource.adaptTo(Node.class);
        if ("cq:Tag".equals(this.getNodePrimaryType(currentNode))) {
            logger.trace("Found cq:Tag {}", (Object)currentNode.getPath());
            TranslatableNode newNode = new TranslatableNode();
            newNode.node = currentNode;
            nodeList.add(newNode);
            Iterable children = resource.getChildren();
            for (Resource child : children) {
                this.getCQTagsFromPath(nodeList, child);
            }
        }
    }

    public ArrayList<Node> getAssetListFromPage(Node currentNode, Session userSesion, boolean bCheckTranslation) throws RepositoryException, IOException {
        this.init();
        ArrayList<Node> assetList = new ArrayList<Node>();
        NodeIterator nodeIterator = currentNode.getNodes();
        while (nodeIterator.hasNext()) {
            Node childNode = (Node)nodeIterator.next();
            this.getAssetListFromNode(childNode, assetList, userSesion, bCheckTranslation);
        }
        return assetList;
    }

    private void getAssetListFromNode(Node currentNode, ArrayList<Node> assetList, Session userSesion, boolean bCheckTranslation) throws RepositoryException, IOException {
        if (!TranslationRuleConfigurationFile.isPageNode(currentNode)) {
            AssetNodeRule assetRule;
            String strAssetPath = null;
            String strResourceType = TranslationUtils.getNodeResourceType(logger, currentNode, null);
            if (strResourceType != null && (assetRule = this.getAssetNodeFileRule(strResourceType)) != null) {
                String strFileAttributeName = assetRule.strFileReferenceAttribute;
                if (!StringUtils.isEmpty((CharSequence)strFileAttributeName)) {
                    strAssetPath = TranslationUtils.getStringAttribute(logger, currentNode, strFileAttributeName, null);
                }
                if (StringUtils.isEmpty((CharSequence)strAssetPath)) {
                    Node binaryNode = this.getBinaryNode(currentNode);
                    if (binaryNode != null) {
                        assetList.add(binaryNode);
                    }
                } else {
                    Node assetNode;
                    String strNodePrimaryType;
                    Resource assetResource = this.resourceResolver.getResource(strAssetPath);
                    if (assetResource != null && (assetNode = (Node)assetResource.adaptTo(Node.class)) != null && "dam:Asset".equals(strNodePrimaryType = this.getNodePrimaryType(assetNode)) && (!bCheckTranslation || this.canTranslateNode(assetNode, strNodePrimaryType))) {
                        Node newAssetNode = this.getOrCreateAssetLanguageCopy(strAssetPath);
                        if (newAssetNode != null) {
                            currentNode.setProperty(strFileAttributeName, newAssetNode.getPath());
                            assetNode = newAssetNode;
                            userSesion.save();
                        }
                        assetList.add(assetNode);
                    }
                }
            }
            NodeIterator nodeIterator = currentNode.getNodes();
            while (nodeIterator.hasNext()) {
                Node childNode = (Node)nodeIterator.next();
                this.getAssetListFromNode(childNode, assetList, userSesion, bCheckTranslation);
            }
        }
    }

    public Node getOrCreateAssetLanguageCopy(String strAssetPath) throws RepositoryException {
        Node retNode = null;
        Asset destinationAsset = DamLanguageUtil.getLanguageCopy((String)strAssetPath, (String)this.dstLang, (ResourceResolver)this.resourceResolver);
        if (destinationAsset == null) {
            String strPath;
            Resource resource;
            String[] targetLanguageCode = new String[]{this.dstLang};
            List retList = DamLanguageUtil.createLanguageCopy((ResourceResolver)this.resourceResolver, (PageManagerFactory)this.pageManagerFactory, (String)strAssetPath, (String[])targetLanguageCode);
            if (retList != null && retList.size() == 1 && (resource = this.resourceResolver.resolve(strPath = (String)retList.get(0))) != null) {
                retNode = (Node)resource.adaptTo(Node.class);
            }
        } else {
            Asset sourceAsset = (Asset)this.resourceResolver.getResource(strAssetPath).adaptTo(Asset.class);
            if (TranslationUtils.isSmartUpdateRequired(sourceAsset, destinationAsset)) {
                TranslationUtils.addSmartAssetUpdateSource(destinationAsset, sourceAsset.getPath());
            }
            retNode = (Node)destinationAsset.adaptTo(Node.class);
        }
        return retNode;
    }

    private Node getBinaryNode(Node currentNode) throws RepositoryException {
        Node retVal = null;
        if (currentNode != null) {
            if (!TranslationUtils.isBinaryNode(currentNode)) {
                Node childNode;
                NodeIterator nodeIterator = currentNode.getNodes();
                while (nodeIterator.hasNext() && (retVal = this.getBinaryNode(childNode = (Node)nodeIterator.next())) == null) {
                }
            } else {
                retVal = currentNode;
            }
        }
        return retVal;
    }

    public void setLanguageSet(String sourceLanguage, String destinationLanguage) {
        this.srcLang = sourceLanguage;
        this.dstLang = destinationLanguage;
    }

    public LanguageManager getLanguageManager() {
        return this.languageManager;
    }

    public LaunchManager getLaunchManager() {
        return this.launchesManagerFactory.getLaunchManager(this.resourceResolver);
    }

    public PageExporter getPageExporter() {
        return this.pageExporter;
    }

    public HtmlParser getHTMLParser() {
        return this.htmlParser;
    }

    private class NodeRule {
        boolean bCacheValid;
        String strNodePath;
        String strResourceType;
        String strNodePathContains;
        ArrayList<NodeFilterRule> filterRules;
        HashMap<String, PropertyRule> inheritablePropertyHash;
        HashMap<String, PropertyRule> privatePropertyHash;
        ArrayList<String> strCachedTranslatablePropertyList;

        NodeRule(String strNodePath, String strResourceType, String strNodePathContains) {
            this.bCacheValid = false;
            this.strNodePath = strNodePath;
            this.strResourceType = strResourceType;
            this.strNodePathContains = strNodePathContains;
            this.strCachedTranslatablePropertyList = null;
            this.filterRules = new ArrayList();
            this.inheritablePropertyHash = new HashMap();
            this.privatePropertyHash = new HashMap();
        }

        public void copyRules(NodeRule parentRule) {
            if (parentRule != null) {
                for (String key : parentRule.inheritablePropertyHash.keySet()) {
                    PropertyRule currentRule = parentRule.inheritablePropertyHash.get(key);
                    this.inheritablePropertyHash.put(key, currentRule.duplicate());
                }
                NodeFilterRule.copyFilters(this.filterRules, parentRule.filterRules);
            }
        }

        public ArrayList<String> getTranslatablePropertyList() {
            if (!this.bCacheValid || this.strCachedTranslatablePropertyList == null) {
                this.strCachedTranslatablePropertyList = new ArrayList();
                this.addPropertyToCacheList(this.inheritablePropertyHash, this.strCachedTranslatablePropertyList, true);
                this.addPropertyToCacheList(this.privatePropertyHash, this.strCachedTranslatablePropertyList, true);
                this.bCacheValid = true;
            }
            return this.strCachedTranslatablePropertyList;
        }

        private void addPropertyToCacheList(HashMap<String, PropertyRule> propertyHash, ArrayList<String> strPropertyList, boolean bCheckForTranslation) {
            for (String key : propertyHash.keySet()) {
                boolean bCheckValue;
                PropertyRule rule = propertyHash.get(key);
                boolean bl = bCheckValue = bCheckForTranslation ? rule.bTranslate : rule.bPatchLanguage;
                if (bCheckValue) {
                    if (strPropertyList.contains(rule.strPropertyName)) continue;
                    strPropertyList.add(rule.strPropertyName);
                    continue;
                }
                strPropertyList.remove(rule.strPropertyName);
            }
        }

        public void processProperty(String strPropertyName, boolean bInheritable, boolean bTranslate, boolean bPatchLanguage) {
            if (bPatchLanguage) {
                bTranslate = false;
            }
            this.bCacheValid = false;
            PropertyRule newRule = new PropertyRule(strPropertyName, bTranslate, bPatchLanguage);
            if (bInheritable) {
                this.inheritablePropertyHash.put(strPropertyName, newRule);
            } else {
                this.privatePropertyHash.put(strPropertyName, newRule);
            }
        }

        public void addFilterNode(String strPathContains, String strContainsProperty, String strPropertyValue, boolean bIsDeep) {
            NodeFilterRule newFilter = new NodeFilterRule(strPathContains, strContainsProperty, strPropertyValue, bIsDeep);
            this.filterRules.add(newFilter);
        }

        public boolean isValidBasedonFilters(Node node) throws RepositoryException {
            boolean bValid = true;
            for (NodeFilterRule filterRule : this.filterRules) {
                if (filterRule.isValidBasedonFilter(TranslationRuleConfigurationFile.this.resourceResolver, node)) continue;
                bValid = false;
                break;
            }
            return bValid;
        }

        public ArrayList<String> getLanguagePatchPropertyList() {
            ArrayList<String> strLanguagePatchPropertyList = new ArrayList<String>();
            this.addPropertyToCacheList(this.inheritablePropertyHash, strLanguagePatchPropertyList, false);
            this.addPropertyToCacheList(this.privatePropertyHash, strLanguagePatchPropertyList, false);
            return strLanguagePatchPropertyList;
        }
    }

    private class PropertyRule {
        public String strPropertyName;
        public boolean bTranslate;
        public boolean bPatchLanguage;

        public PropertyRule(String propertyName, boolean bTranslate, boolean bPatchLanguage) {
            this.strPropertyName = propertyName;
            this.bTranslate = bTranslate;
            this.bPatchLanguage = bPatchLanguage;
        }

        public PropertyRule duplicate() {
            return new PropertyRule(this.strPropertyName, this.bTranslate, this.bPatchLanguage);
        }
    }

    class TranslatableNode {
        String strReferencedNode;
        Node node;
    }

    class AssetNodeRule {
        String strResourceType;
        String strFileReferenceAttribute;

        public AssetNodeRule(String strType, String strFileReference) {
            this.strResourceType = strType;
            this.strFileReferenceAttribute = strFileReference;
        }
    }

    private static class NodeFilterRule {
        public String strPathContains;
        public String strContainsProperty;
        public String strPropertyValue;
        boolean bIsDeep;

        NodeFilterRule(String strPathContains, String strContainsProperty, String strPropertyValue, boolean bIsDeep) {
            this.strPathContains = strPathContains;
            this.strContainsProperty = strContainsProperty;
            this.strPropertyValue = strPropertyValue;
            this.bIsDeep = bIsDeep;
        }

        private boolean isNodeFilterPropertyValid(Node node, String strContainsProperty) throws RepositoryException {
            boolean bValid = true;
            if (node != null && node.hasProperty(strContainsProperty)) {
                Property prop = node.getProperty(strContainsProperty);
                if (!StringUtils.isEmpty((CharSequence)this.strPropertyValue)) {
                    int type = prop.getType();
                    String strValue = "";
                    switch (type) {
                        case 6: {
                            strValue = prop.getBoolean() ? "true" : "false";
                            break;
                        }
                        case 1: {
                            strValue = prop.getString();
                            break;
                        }
                        case 4: {
                            strValue = new Double(prop.getDouble()).toString();
                            break;
                        }
                        case 3: {
                            strValue = new Long(prop.getLong()).toString();
                        }
                    }
                    if (this.strPropertyValue.equals(strValue)) {
                        bValid = false;
                    }
                }
            }
            return bValid;
        }

        public boolean isValidBasedonFilter(ResourceResolver resourceResolver, Node currentNode) throws RepositoryException {
            boolean bValid;
            block8 : {
                bValid = true;
                boolean bContinue = true;
                String strActualNodePath = currentNode.getPath();
                try {
                    if (!StringUtils.isEmpty((CharSequence)this.strPathContains) && strActualNodePath.indexOf(this.strPathContains) != -1) {
                        bValid = false;
                    }
                    if (!bValid || StringUtils.isEmpty((CharSequence)this.strContainsProperty)) break block8;
                    Node node = currentNode;
                    do {
                        if ((bValid = this.isNodeFilterPropertyValid(node, this.strContainsProperty)) && TranslationRuleConfigurationFile.isPageNode(node)) {
                            bValid = this.isNodeFilterPropertyValid(node.getNode("jcr:content"), this.strContainsProperty);
                        }
                        if (this.bIsDeep && bValid) {
                            try {
                                node = node.getParent();
                            }
                            catch (Exception e) {
                                node = null;
                            }
                            if (node != null) continue;
                            bContinue = false;
                            continue;
                        }
                        bContinue = false;
                    } while (bContinue);
                }
                catch (Exception ex) {
                    logger.error("Error while processing the filter ", (Throwable)ex);
                    bValid = false;
                }
            }
            return bValid;
        }

        public static void copyFilters(ArrayList<NodeFilterRule> childRules, ArrayList<NodeFilterRule> parentRules) {
            if (childRules != null && parentRules != null && parentRules.size() > 0) {
                for (NodeFilterRule filterRule : parentRules) {
                    NodeFilterRule newFilter = new NodeFilterRule(filterRule.strPathContains, filterRule.strContainsProperty, filterRule.strPropertyValue, filterRule.bIsDeep);
                    childRules.add(newFilter);
                }
            }
        }
    }

}