Package netflix.adminresources.resources

Source Code of netflix.adminresources.resources.PropertiesHelper

package netflix.adminresources.resources;

import com.netflix.config.ConfigurationManager;
import netflix.adminresources.resources.model.Property;
import org.apache.commons.configuration.AbstractConfiguration;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Set;

public class PropertiesHelper {
    private static final Logger LOG = LoggerFactory.getLogger(PropertiesHelper.class);

    public static List<Property> getAllProperties() {
        final AbstractConfiguration configInstance = ConfigurationManager.getConfigInstance();
        List<Property> properties = new ArrayList<Property>();
        Iterator keys = null;
        try {
            keys = configInstance.getKeys();
        } catch (Exception e) {
            LOG.error("Exception fetching all property keys ", e);
        }

        Set<String> maskedResources = MaskedResourceHelper.getMaskedPropertiesSet();

        while (keys.hasNext()) {
            final String key = (String) keys.next();
            try {
                Object value = null;
                // mask the specified properties
                if (maskedResources.contains(key)) {
                    value = MaskedResourceHelper.MASKED_PROPERTY_VALUE;
                } else {
                    value = configInstance.getProperty(key);
                }
                Property property = new Property(key, value.toString(), null);
                properties.add(property);
            } catch (Exception e) {
                LOG.info("Exception fetching property value for key " + key, e);
            }

        }
        return properties;
    }
}
TOP

Related Classes of netflix.adminresources.resources.PropertiesHelper

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.