// 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;
/*
 * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
 *
 *   WSO2 Inc. licenses this file to you 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.  See the License for the
 *  specific language governing permissions and limitations
 *  under the License.
 */

package org.wso2.carbon.governance.common.utils;



public class GovernanceUtils {

    public static final String DISCOVERY_AGENTS = "DiscoveryAgents";
    public static final String DISCOVERY_AGENT = "DiscoveryAgent";
    public static final String SERVER_TYPE_ID = "ServerTypeId";
    public static final String AGENT_CLASS = "AgentClass";
    public static final String PROPERTY = "property";
    public static final String NAME = "name";
    public static final String VALUE = "value";
    public static final String GOVERNANCE_CONFIG_FILE = "governance.xml";
    public static final String COMPARATORS = "Comparators";
    public static final String COMPARATOR = "Comparator";
    public static final String CLASS_ATTR = "class";
    public static final String ENDPOINT_STATE_MANAGEMENT = "EndpointStateManagement";
    public static final String ENDPOINT_STATE_MANAGEMENT_ENABLED = "enabled";
    public static final String DEFAULT_ENDPOINT_ACTIVE_DURATION = "DefaultEndpointActiveDuration";
    public static final String ENABLE_LIFECYCLE_CHECKLIST_ITEMS = "enableLifecycleChecklistItems";
    public static final String LIFECYCLE_CHECKLIST_ITEMS_ENABLED = "true";
    private static final int ENTITY_EXPANSION_LIMIT = 0;
    private static Log log = LogFactory.getLog(GovernanceUtils.class);


    private static boolean isConfigInitialized = false;

// 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;

/*
 * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
 *
 *   WSO2 Inc. licenses this file to you 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.  See the License for the
 *  specific language governing permissions and limitations
 *  under the License.
 */

package org.wso2.carbon.governance.common.utils;



public class GovernanceUtils {

    public static final String DISCOVERY_AGENTS = "DiscoveryAgents";
    public static final String DISCOVERY_AGENT = "DiscoveryAgent";
    public static final String SERVER_TYPE_ID = "ServerTypeId";
    public static final String AGENT_CLASS = "AgentClass";
    public static final String PROPERTY = "property";
    public static final String NAME = "name";
    public static final String VALUE = "value";
    public static final String GOVERNANCE_CONFIG_FILE = "governance.xml";
    public static final String COMPARATORS = "Comparators";
    public static final String COMPARATOR = "Comparator";
    public static final String CLASS_ATTR = "class";
    public static final String ENDPOINT_STATE_MANAGEMENT = "EndpointStateManagement";
    public static final String ENDPOINT_STATE_MANAGEMENT_ENABLED = "enabled";
    public static final String DEFAULT_ENDPOINT_ACTIVE_DURATION = "DefaultEndpointActiveDuration";
    public static final String ENABLE_LIFECYCLE_CHECKLIST_ITEMS = "enableLifecycleChecklistItems";
    public static final String LIFECYCLE_CHECKLIST_ITEMS_ENABLED = "true";
    private static final int ENTITY_EXPANSION_LIMIT = 0;
    private static Log log = LogFactory.getLog(GovernanceUtils.class);


    private static boolean isConfigInitialized = false;

    public static GovernanceConfiguration getGovernanceConfiguration() throws GovernanceConfigurationException {