// Path: components/governance/org.wso2.carbon.governance.common/src/main/java/org/wso2/carbon/governance/common/GovernanceConfiguration.java
// public class GovernanceConfiguration {
// 
//     private Map<String, Map<String, String>> discoveryAgentConfigs = new HashMap();
//     private List<String> comparators = new ArrayList<>();
//     private boolean endpointStateManagementEnabled = false;
//     private boolean lifecycleChecklistItemsEnabled = false;
//     private long defaultEndpointActiveDuration = 90;
// 
//     private static GovernanceConfiguration instance = new GovernanceConfiguration();
// 
//     private GovernanceConfiguration() {
//     }
// 
//     public static GovernanceConfiguration getInstance() {
//         // Need permissions in order to instantiate ServerConfiguration
//         CarbonBaseUtils.checkSecurity();
//         return instance;
//     }
// 
//     public void addDiscoveryAgentConfig(String serverTypeId, Map<String, String> properties) {
//         discoveryAgentConfigs.put(serverTypeId, properties);
//     }
// 
//     public Map<String, Map<String, String>> getDiscoveryAgentConfigs() {
//         return discoveryAgentConfigs;
//     }
// 
//     public void addComparator(String comparatorClass) {
//         comparators.add(comparatorClass);
//     }
// 
//     public List<String> getComparators() {
//         return comparators;
//     }
// 
//     public void setComparators(List<String> comparators) {
//         this.comparators = comparators;
//     }
// 
// 
//     public boolean isEndpointStateManagementEnabled() {
//         return endpointStateManagementEnabled;
//     }
// 
//     public void setEndpointStateManagementEnabled(boolean endpointStateManagementEnabled) {
//         this.endpointStateManagementEnabled = endpointStateManagementEnabled;
//     }
// 
//     public long getDefaultEndpointActiveDuration() {
//         return defaultEndpointActiveDuration;
//     }
// 
//     public void setDefaultEndpointActiveDuration(long defaultEndpointActiveDuration) {
//         this.defaultEndpointActiveDuration = defaultEndpointActiveDuration;
//     }
// 
//     public boolean isLifecycleChecklistItemsEnabled() {
//         return lifecycleChecklistItemsEnabled;
//     }
// 
//     public void setLifecycleChecklistItemsEnabled(boolean lifecycleChecklistItemsEnabled) {
//         this.lifecycleChecklistItemsEnabled = lifecycleChecklistItemsEnabled;
//     }
// 
//     @Override
//     public String toString() {
//         return "GovernanceConfiguration{" +
//                "discoveryAgentConfigs=" + discoveryAgentConfigs +
//                ", comparators=" + comparators +
//                ", endpointStateManagementEnabled=" + endpointStateManagementEnabled +
//                ", defaultEndpointActiveDuration=" + defaultEndpointActiveDuration +
//                ", lifecycleChecklistItemsEnabled=" + lifecycleChecklistItemsEnabled +
//                '}';
//     }
// }


import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.xerces.util.SecurityManager;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
import org.wso2.carbon.governance.common.GovernanceConfiguration;
import org.wso2.carbon.governance.common.GovernanceConfigurationException;
import org.wso2.carbon.utils.CarbonUtils;
import org.wso2.carbon.utils.ServerConstants;
import org.xml.sax.SAXException;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.HashMap;
import java.util.Map;
            NodeList agents = agentsElement.getElementsByTagName(DISCOVERY_AGENT);
            for (int i = 0; i < agents.getLength(); i++) {
                Element agent = (Element) agents.item(i);
                String serverType = getFirstElementContent(agent, SERVER_TYPE_ID);
                String agentClass = getFirstElementContent(agent, AGENT_CLASS);
                Map<String, String> properties = getProperties(agent);
                properties.put(AGENT_CLASS, agentClass);
                govConfig.addDiscoveryAgentConfig(serverType, properties);
            }
        }

    }

    private static void readComparators(Element config,
                                        GovernanceConfiguration govConfig) {
        Element comparatorsEle = getFirstElement(config, COMPARATORS);
        if (comparatorsEle != null) {
            NodeList comparatorsElements = comparatorsEle.getElementsByTagName(COMPARATOR);
            for (int i = 0; i < comparatorsElements.getLength(); i++) {
                Element comparatorEle = (Element) comparatorsElements.item(i);
                String comparatorClass = comparatorEle.getAttribute(CLASS_ATTR);
                if (comparatorClass != null && !comparatorClass.isEmpty()) {
                    govConfig.addComparator(comparatorClass);
                }
            }
        }

    }


// Path: components/governance/org.wso2.carbon.governance.common/src/main/java/org/wso2/carbon/governance/common/GovernanceConfiguration.java
// public class GovernanceConfiguration {
// 
//     private Map<String, Map<String, String>> discoveryAgentConfigs = new HashMap();
//     private List<String> comparators = new ArrayList<>();
//     private boolean endpointStateManagementEnabled = false;
//     private boolean lifecycleChecklistItemsEnabled = false;
//     private long defaultEndpointActiveDuration = 90;
// 
//     private static GovernanceConfiguration instance = new GovernanceConfiguration();
// 
//     private GovernanceConfiguration() {
//     }
// 
//     public static GovernanceConfiguration getInstance() {
//         // Need permissions in order to instantiate ServerConfiguration
//         CarbonBaseUtils.checkSecurity();
//         return instance;
//     }
// 
//     public void addDiscoveryAgentConfig(String serverTypeId, Map<String, String> properties) {
//         discoveryAgentConfigs.put(serverTypeId, properties);
//     }
// 
//     public Map<String, Map<String, String>> getDiscoveryAgentConfigs() {
//         return discoveryAgentConfigs;
//     }
// 
//     public void addComparator(String comparatorClass) {
//         comparators.add(comparatorClass);
//     }
// 
//     public List<String> getComparators() {
//         return comparators;
//     }
// 
//     public void setComparators(List<String> comparators) {
//         this.comparators = comparators;
//     }
// 
// 
//     public boolean isEndpointStateManagementEnabled() {
//         return endpointStateManagementEnabled;
//     }
// 
//     public void setEndpointStateManagementEnabled(boolean endpointStateManagementEnabled) {
//         this.endpointStateManagementEnabled = endpointStateManagementEnabled;
//     }
// 
//     public long getDefaultEndpointActiveDuration() {
//         return defaultEndpointActiveDuration;
//     }
// 
//     public void setDefaultEndpointActiveDuration(long defaultEndpointActiveDuration) {
//         this.defaultEndpointActiveDuration = defaultEndpointActiveDuration;
//     }
// 
//     public boolean isLifecycleChecklistItemsEnabled() {
//         return lifecycleChecklistItemsEnabled;
//     }
// 
//     public void setLifecycleChecklistItemsEnabled(boolean lifecycleChecklistItemsEnabled) {
//         this.lifecycleChecklistItemsEnabled = lifecycleChecklistItemsEnabled;
//     }
// 
//     @Override
//     public String toString() {
//         return "GovernanceConfiguration{" +
//                "discoveryAgentConfigs=" + discoveryAgentConfigs +
//                ", comparators=" + comparators +
//                ", endpointStateManagementEnabled=" + endpointStateManagementEnabled +
//                ", defaultEndpointActiveDuration=" + defaultEndpointActiveDuration +
//                ", lifecycleChecklistItemsEnabled=" + lifecycleChecklistItemsEnabled +
//                '}';
//     }
// }


// Path: components/governance/org.wso2.carbon.governance.common/src/main/java/org/wso2/carbon/governance/common/utils/GovernanceUtils.java
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.xerces.util.SecurityManager;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
import org.wso2.carbon.governance.common.GovernanceConfiguration;
import org.wso2.carbon.governance.common.GovernanceConfigurationException;
import org.wso2.carbon.utils.CarbonUtils;
import org.wso2.carbon.utils.ServerConstants;
import org.xml.sax.SAXException;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.HashMap;
import java.util.Map;

            NodeList agents = agentsElement.getElementsByTagName(DISCOVERY_AGENT);
            for (int i = 0; i < agents.getLength(); i++) {
                Element agent = (Element) agents.item(i);
                String serverType = getFirstElementContent(agent, SERVER_TYPE_ID);
                String agentClass = getFirstElementContent(agent, AGENT_CLASS);
                Map<String, String> properties = getProperties(agent);
                properties.put(AGENT_CLASS, agentClass);
                govConfig.addDiscoveryAgentConfig(serverType, properties);
            }
        }

    }

    private static void readComparators(Element config,
                                        GovernanceConfiguration govConfig) {
        Element comparatorsEle = getFirstElement(config, COMPARATORS);
        if (comparatorsEle != null) {
            NodeList comparatorsElements = comparatorsEle.getElementsByTagName(COMPARATOR);
            for (int i = 0; i < comparatorsElements.getLength(); i++) {
                Element comparatorEle = (Element) comparatorsElements.item(i);
                String comparatorClass = comparatorEle.getAttribute(CLASS_ATTR);
                if (comparatorClass != null && !comparatorClass.isEmpty()) {
                    govConfig.addComparator(comparatorClass);
                }
            }
        }

    }


    private static void readEndpointStateManagement(Element config, GovernanceConfiguration govConfig) {