class ConfigResourceImpl implements ConfigResource {
    private static final Logger LOG = LoggerFactory.getLogger(ConfigResourceImpl.class);

    @Autowired(required = false)
    private ConfigAdapter configAdapter;

    @Autowired
    private ServiceResource serviceResource;

    @Autowired
    private RestTemplate consoleRestTemplate;

    @Autowired
    private PluginConfigParser pluginConfigParser;

    @Autowired
    private PluginConfigDeparser pluginConfigDeparser;

    @Autowired
    private Environment environment;

    @Override
    public ConfigType getConfigType() {
        if (configAdapter == null) {
            LOG.error("Remote config adapter isn't provided");

            throw new DiscoveryException("Remote config adapter isn't provided");
        }

        return configAdapter.getConfigType();
    }

    @Override
    public boolean updateRemoteConfig(String group, String serviceId, String config) throws Exception {<FILL_FUNCTION_BODY>}

    @Override
    public boolean updateRemoteConfig(String group, String serviceId, String config, FormatType formatType) throws Exception {
        if (configAdapter == null) {
            LOG.error("Remote config adapter isn't provided");

            throw new DiscoveryException("Remote config adapter isn't provided");
        }

        return configAdapter.updateConfig(group, serviceId, config, formatType);
    }

    @Override
    public boolean updateRemoteRuleEntity(String group, String serviceId, RuleEntity ruleEntity) throws Exception {
        String config = fromRuleEntity(ruleEntity);
        String configFormat = environment.getProperty(DiscoveryConstant.SPRING_APPLICATION_CONFIG_FORMAT, String.class, DiscoveryConstant.XML_FORMAT);
        FormatType formatType = FormatType.fromString(configFormat);

        return updateRemoteConfig(group, serviceId, config, formatType);
    }

    @Override
    public boolean clearRemoteConfig(String group, String serviceId) throws Exception {
        if (configAdapter == null) {
            LOG.error("Remote config adapter isn't provided");

            throw new DiscoveryException("Remote config adapter isn't provided");
        }

        return configAdapter.clearConfig(group, serviceId);
    }

    @Override
    public String getRemoteConfig(String group, String serviceId) throws Exception {
        if (configAdapter == null) {
            LOG.error("Remote config adapter isn't provided");

            throw new DiscoveryException("Remote config adapter isn't provided");
        }

        return configAdapter.getConfig(group, serviceId);
    }

    @Override
    public RuleEntity getRemoteRuleEntity(String group, String serviceId) throws Exception {
        String config = getRemoteConfig(group, serviceId);

        return toRuleEntity(config);
    }

    @Override
    public List<ResultEntity> updateConfig(String serviceId, String config, boolean async) {
        ConfigUpdateRestInvoker configUpdateRestInvoker = new ConfigUpdateRestInvoker(serviceResource, serviceId, consoleRestTemplate, async, config);

        return configUpdateRestInvoker.invoke();
    }

    @Override
    public List<ResultEntity> updateRuleEntity(String serviceId, RuleEntity ruleEntity, boolean async) {
        String config = fromRuleEntity(ruleEntity);

        return updateConfig(serviceId, config, async);
    }

    @Override
    public List<ResultEntity> clearConfig(String serviceId, boolean async) {
        ConfigClearRestInvoker configClearRestInvoker = new ConfigClearRestInvoker(serviceResource, serviceId, consoleRestTemplate, async);

        return configClearRestInvoker.invoke();
    }

    @Override
    public List<ResultEntity> viewConfig(String serviceId) {
        ConfigViewRestInvoker configViewRestInvoker = new ConfigViewRestInvoker(serviceResource, serviceId, consoleRestTemplate);

        return configViewRestInvoker.invoke();
    }

    @Override
    public RuleEntity toRuleEntity(String config) {
        return StringUtils.isNotEmpty(config) ? parse(config) : new RuleEntity();
    }

    @Override
    public String fromRuleEntity(RuleEntity ruleEntity) {
        if (ruleEntity != null) {
            return deparse(ruleEntity);
        }

        String configFormat = environment.getProperty(DiscoveryConstant.SPRING_APPLICATION_CONFIG_FORMAT, String.class, DiscoveryConstant.XML_FORMAT);
        ConfigFormatType configFormatType = ConfigFormatType.fromString(configFormat);
        switch (configFormatType) {
            case XML_FORMAT:
                return DiscoveryConstant.EMPTY_XML_RULE;
            case JSON_FORMAT:
                return DiscoveryConstant.EMPTY_JSON_RULE_SINGLE;
        }

        return StringUtils.EMPTY;
    }

    @Override
    public RuleEntity parse(String config) {
        return pluginConfigParser.parse(config);
    }

    @Override
    public String deparse(RuleEntity ruleEntity) {
        return pluginConfigDeparser.deparse(ruleEntity);
    }
}

        if (configAdapter == null) {
            LOG.error("Remote config adapter isn't provided");

            throw new DiscoveryException("Remote config adapter isn't provided");
        }

        return configAdapter.updateConfig(group, serviceId, config);
    
<no_super_class>