// Path: disconf-core/src/main/java/com/baidu/disconf/core/common/constants/DisConfigTypeEnum.java
// public enum DisConfigTypeEnum {
// 
//     FILE(0, "配置文件"), ITEM(1, "配置项");
// 
//     private int type = 0;
//     private String modelName = null;
// 
//     private DisConfigTypeEnum(int type, String modelName) {
//         this.type = type;
//         this.modelName = modelName;
//     }
// 
//     public static DisConfigTypeEnum getByType(int type) {
// 
//         int index = 0;
//         for (DisConfigTypeEnum disConfigTypeEnum : DisConfigTypeEnum.values()) {
// 
//             if (type == index) {
//                 return disConfigTypeEnum;
//             }
// 
//             index++;
//         }
// 
//         return null;
//     }
// 
//     public int getType() {
//         return type;
//     }
// 
//     public void setType(int type) {
//         this.type = type;
//     }
// 
//     public String getModelName() {
//         return modelName;
//     }
// 
//     public void setModelName(String modelName) {
//         this.modelName = modelName;
//     }
// 
// }
// 
// Path: disconf-web/src/main/java/com/baidu/dsp/common/exception/DocumentNotFoundException.java
// public class DocumentNotFoundException extends RuntimeException {
// 
//     private static final long serialVersionUID = 545280194497047918L;
// 
//     public DocumentNotFoundException(String fileName) {
//         super(fileName + " file does not exist!");
//     }
// 
// }


import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import com.baidu.disconf.core.common.constants.DisConfigTypeEnum;
import com.baidu.disconf.core.common.json.ValueVo;
import com.baidu.disconf.web.service.config.bo.Config;
import com.baidu.disconf.web.service.config.form.ConfForm;
import com.baidu.disconf.web.service.config.service.ConfigFetchMgr;
import com.baidu.disconf.web.service.config.utils.ConfigUtils;
import com.baidu.disconf.web.web.config.dto.ConfigFullModel;
import com.baidu.disconf.web.web.config.validator.ConfigValidator;
import com.baidu.disconf.web.web.config.validator.ConfigValidator4Fetch;
import com.baidu.dsp.common.annotation.NoAuth;
import com.baidu.dsp.common.constant.WebConstants;
import com.baidu.dsp.common.controller.BaseController;
import com.baidu.dsp.common.exception.DocumentNotFoundException;
import com.baidu.dsp.common.vo.JsonObjectBase;
     *
     * @return
     */
    @NoAuth
    @RequestMapping(value = "/file", method = RequestMethod.GET)
    @ResponseBody
    public HttpEntity<byte[]> getFile(ConfForm confForm) {

        boolean hasError = false;

        //
        // 校验
        //
        ConfigFullModel configModel = null;
        try {
            configModel = configValidator4Fetch.verifyConfForm(confForm, false);
        } catch (Exception e) {
            LOG.error(e.toString());
            hasError = true;
        }

        if (hasError == false) {
            try {
                //
                Config config = configFetchMgr
                        .getConfByParameter(configModel.getApp().getId(), configModel.getEnv().getId(),
                                configModel.getVersion(), configModel.getKey(),
                                DisConfigTypeEnum.FILE);
                if (config == null) {
                    hasError = true;
// Path: disconf-core/src/main/java/com/baidu/disconf/core/common/constants/DisConfigTypeEnum.java
// public enum DisConfigTypeEnum {
// 
//     FILE(0, "配置文件"), ITEM(1, "配置项");
// 
//     private int type = 0;
//     private String modelName = null;
// 
//     private DisConfigTypeEnum(int type, String modelName) {
//         this.type = type;
//         this.modelName = modelName;
//     }
// 
//     public static DisConfigTypeEnum getByType(int type) {
// 
//         int index = 0;
//         for (DisConfigTypeEnum disConfigTypeEnum : DisConfigTypeEnum.values()) {
// 
//             if (type == index) {
//                 return disConfigTypeEnum;
//             }
// 
//             index++;
//         }
// 
//         return null;
//     }
// 
//     public int getType() {
//         return type;
//     }
// 
//     public void setType(int type) {
//         this.type = type;
//     }
// 
//     public String getModelName() {
//         return modelName;
//     }
// 
//     public void setModelName(String modelName) {
//         this.modelName = modelName;
//     }
// 
// }
// 
// Path: disconf-web/src/main/java/com/baidu/dsp/common/exception/DocumentNotFoundException.java
// public class DocumentNotFoundException extends RuntimeException {
// 
//     private static final long serialVersionUID = 545280194497047918L;
// 
//     public DocumentNotFoundException(String fileName) {
//         super(fileName + " file does not exist!");
//     }
// 
// }


// Path: disconf-web/src/main/java/com/baidu/disconf/web/web/config/controller/ConfigFetcherController.java
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import com.baidu.disconf.core.common.constants.DisConfigTypeEnum;
import com.baidu.disconf.core.common.json.ValueVo;
import com.baidu.disconf.web.service.config.bo.Config;
import com.baidu.disconf.web.service.config.form.ConfForm;
import com.baidu.disconf.web.service.config.service.ConfigFetchMgr;
import com.baidu.disconf.web.service.config.utils.ConfigUtils;
import com.baidu.disconf.web.web.config.dto.ConfigFullModel;
import com.baidu.disconf.web.web.config.validator.ConfigValidator;
import com.baidu.disconf.web.web.config.validator.ConfigValidator4Fetch;
import com.baidu.dsp.common.annotation.NoAuth;
import com.baidu.dsp.common.constant.WebConstants;
import com.baidu.dsp.common.controller.BaseController;
import com.baidu.dsp.common.exception.DocumentNotFoundException;
import com.baidu.dsp.common.vo.JsonObjectBase;

     *
     * @return
     */
    @NoAuth
    @RequestMapping(value = "/file", method = RequestMethod.GET)
    @ResponseBody
    public HttpEntity<byte[]> getFile(ConfForm confForm) {

        boolean hasError = false;

        //
        // 校验
        //
        ConfigFullModel configModel = null;
        try {
            configModel = configValidator4Fetch.verifyConfForm(confForm, false);
        } catch (Exception e) {
            LOG.error(e.toString());
            hasError = true;
        }

        if (hasError == false) {
            try {
                //
                Config config = configFetchMgr
                        .getConfByParameter(configModel.getApp().getId(), configModel.getEnv().getId(),
                                configModel.getVersion(), configModel.getKey(),
                                DisConfigTypeEnum.FILE);
                if (config == null) {
                    hasError = true;
                    throw new DocumentNotFoundException(configModel.getKey());