Search in sources :

Example 1 with NoAuth

use of com.baidu.dsp.common.annotation.NoAuth in project disconf by knightliao.

the class ConfigFetcherController method getFile.

/**
 * 获取配置文件
 *
 * @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());
            }
            // API获取节点内容也需要同样做格式转换
            return downloadDspBill(configModel.getKey(), config.getValue());
        } catch (Exception e) {
            LOG.error(e.toString());
        }
    }
    if (confForm.getKey() != null) {
        throw new DocumentNotFoundException(confForm.getKey());
    } else {
        throw new DocumentNotFoundException("");
    }
}
Also used : DocumentNotFoundException(com.baidu.dsp.common.exception.DocumentNotFoundException) Config(com.baidu.disconf.web.service.config.bo.Config) ConfigFullModel(com.baidu.disconf.web.web.config.dto.ConfigFullModel) DocumentNotFoundException(com.baidu.dsp.common.exception.DocumentNotFoundException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) NoAuth(com.baidu.dsp.common.annotation.NoAuth) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 2 with NoAuth

use of com.baidu.dsp.common.annotation.NoAuth in project disconf by knightliao.

the class ZooController method getHosts.

/**
 * 获取Zookeeper地址
 *
 * @return
 */
@NoAuth
@RequestMapping(value = "/hosts", method = RequestMethod.GET)
@ResponseBody
public ValueVo getHosts() {
    ValueVo confItemVo = new ValueVo();
    confItemVo.setStatus(Constants.OK);
    confItemVo.setValue(zooConfig.getZooHosts());
    return confItemVo;
}
Also used : ValueVo(com.baidu.disconf.core.common.json.ValueVo) NoAuth(com.baidu.dsp.common.annotation.NoAuth) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 3 with NoAuth

use of com.baidu.dsp.common.annotation.NoAuth in project disconf by knightliao.

the class ZooController method getPrefixUrl.

/**
 * 获取ZK prefix
 *
 * @return
 */
@NoAuth
@RequestMapping(value = "/prefix", method = RequestMethod.GET)
@ResponseBody
public ValueVo getPrefixUrl() {
    ValueVo confItemVo = new ValueVo();
    confItemVo.setStatus(Constants.OK);
    confItemVo.setValue(zooConfig.getZookeeperUrlPrefix());
    return confItemVo;
}
Also used : ValueVo(com.baidu.disconf.core.common.json.ValueVo) NoAuth(com.baidu.dsp.common.annotation.NoAuth) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 4 with NoAuth

use of com.baidu.dsp.common.annotation.NoAuth in project disconf by knightliao.

the class ConfigFetcherController method getItem.

/**
 * 获取配置项 Item
 *
 * @param confForm
 *
 * @return
 */
@NoAuth
@RequestMapping(value = "/item", method = RequestMethod.GET)
@ResponseBody
public ValueVo getItem(ConfForm confForm) {
    LOG.info(confForm.toString());
    // 
    // 校验
    // 
    ConfigFullModel configModel = null;
    try {
        configModel = configValidator4Fetch.verifyConfForm(confForm, false);
    } catch (Exception e) {
        LOG.warn(e.toString());
        return ConfigUtils.getErrorVo(e.getMessage());
    }
    return configFetchMgr.getConfItemByParameter(configModel.getApp().getId(), configModel.getEnv().getId(), configModel.getVersion(), configModel.getKey());
}
Also used : ConfigFullModel(com.baidu.disconf.web.web.config.dto.ConfigFullModel) DocumentNotFoundException(com.baidu.dsp.common.exception.DocumentNotFoundException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) NoAuth(com.baidu.dsp.common.annotation.NoAuth) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 5 with NoAuth

use of com.baidu.dsp.common.annotation.NoAuth in project disconf by knightliao.

the class UserController method signin.

/**
 * 登录
 *
 * @param signin
 * @param request
 *
 * @return
 */
@NoAuth
@RequestMapping(value = "/signin", method = RequestMethod.POST)
@ResponseBody
public JsonObjectBase signin(@Valid SigninForm signin, HttpServletRequest request) {
    LOG.info(signin.toString());
    // 验证
    authValidator.validateLogin(signin);
    // 数据库登录
    User user = signMgr.signin(signin.getName());
    // 过期时间
    int expireTime = LoginConstant.SESSION_EXPIRE_TIME;
    if (signin.getRemember().equals(1)) {
        expireTime = LoginConstant.SESSION_EXPIRE_TIME2;
    }
    // redis login
    redisLogin.login(request, user, expireTime);
    VisitorVo visitorVo = userMgr.getCurVisitor();
    return buildSuccess("visitor", visitorVo);
}
Also used : User(com.baidu.disconf.web.service.user.bo.User) VisitorVo(com.baidu.disconf.web.service.user.vo.VisitorVo) NoAuth(com.baidu.dsp.common.annotation.NoAuth) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Aggregations

NoAuth (com.baidu.dsp.common.annotation.NoAuth)5 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)5 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)5 ValueVo (com.baidu.disconf.core.common.json.ValueVo)2 ConfigFullModel (com.baidu.disconf.web.web.config.dto.ConfigFullModel)2 DocumentNotFoundException (com.baidu.dsp.common.exception.DocumentNotFoundException)2 UnsupportedEncodingException (java.io.UnsupportedEncodingException)2 Config (com.baidu.disconf.web.service.config.bo.Config)1 User (com.baidu.disconf.web.service.user.bo.User)1 VisitorVo (com.baidu.disconf.web.service.user.vo.VisitorVo)1