Search in sources :

Example 6 with FieldException

use of com.baidu.dsp.common.exception.FieldException in project disconf by knightliao.

the class AuthValidator method validatePasswordModify.

/**
     * 验证密码更新
     */
public void validatePasswordModify(PasswordModifyForm passwordModifyForm) {
    Visitor visitor = ThreadContext.getSessionVisitor();
    User user = userMgr.getUser(visitor.getLoginUserId());
    // 校验密码
    if (!signMgr.validate(user.getPassword(), passwordModifyForm.getOld_password())) {
        throw new FieldException(PasswordModifyForm.OLD_PASSWORD, "password.not.right", null);
    }
    if (!passwordModifyForm.getNew_password().equals(passwordModifyForm.getNew_password_2())) {
        throw new FieldException(PasswordModifyForm.NEW_PASSWORD, "two.password.not.equal", null);
    }
}
Also used : User(com.baidu.disconf.web.service.user.bo.User) FieldException(com.baidu.dsp.common.exception.FieldException) Visitor(com.baidu.disconf.web.service.user.dto.Visitor)

Example 7 with FieldException

use of com.baidu.dsp.common.exception.FieldException in project disconf by knightliao.

the class ZkDeployValidator method verify.

/**
     * @param zkDeployForm
     *
     * @return
     */
public ConfigFullModel verify(ZkDeployForm zkDeployForm) {
    //
    if (zkDeployForm.getAppId() == null) {
        throw new FieldException("app is empty", null);
    }
    App app = appMgr.getById(zkDeployForm.getAppId());
    if (app == null) {
        throw new FieldException("app " + zkDeployForm.getAppId() + " doesn't exist in db.", null);
    }
    //
    if (zkDeployForm.getEnvId() == null) {
        throw new FieldException("app is empty", null);
    }
    Env env = envMgr.getById(zkDeployForm.getEnvId());
    if (env == null) {
        throw new FieldException("env " + zkDeployForm.getEnvId() + " doesn't exist in db.", null);
    }
    //
    if (StringUtils.isEmpty(zkDeployForm.getVersion())) {
        throw new FieldException("version is empty", null);
    }
    return new ConfigFullModel(app, env, zkDeployForm.getVersion(), "");
}
Also used : App(com.baidu.disconf.web.service.app.bo.App) FieldException(com.baidu.dsp.common.exception.FieldException) ConfigFullModel(com.baidu.disconf.web.web.config.dto.ConfigFullModel) Env(com.baidu.disconf.web.service.env.bo.Env)

Aggregations

FieldException (com.baidu.dsp.common.exception.FieldException)7 App (com.baidu.disconf.web.service.app.bo.App)3 Config (com.baidu.disconf.web.service.config.bo.Config)3 Env (com.baidu.disconf.web.service.env.bo.Env)3 ConfigFullModel (com.baidu.disconf.web.web.config.dto.ConfigFullModel)2 User (com.baidu.disconf.web.service.user.bo.User)1 Visitor (com.baidu.disconf.web.service.user.dto.Visitor)1 AccessDeniedException (com.baidu.dsp.common.exception.AccessDeniedException)1 DocumentNotFoundException (com.baidu.dsp.common.exception.DocumentNotFoundException)1 GlobalExceptionAware (com.baidu.dsp.common.exception.base.GlobalExceptionAware)1 IOException (java.io.IOException)1 InvalidPropertyException (org.springframework.beans.InvalidPropertyException)1 TypeMismatchException (org.springframework.beans.TypeMismatchException)1 BindException (org.springframework.validation.BindException)1 HttpRequestMethodNotSupportedException (org.springframework.web.HttpRequestMethodNotSupportedException)1 MissingServletRequestParameterException (org.springframework.web.bind.MissingServletRequestParameterException)1