package com.baidu.disconf.web.web.app.validator;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.baidu.disconf.web.service.app.bo.App;
import com.baidu.disconf.web.service.app.form.AppNewForm;
import com.baidu.disconf.web.service.app.service.AppMgr;
import com.baidu.dsp.common.exception.FieldException;

/**
 * 权限验证
 *
 * @author liaoqiqi
 * @version 2014-7-2
 */
@Component
public class AppValidator {

    @Autowired
    private AppMgr appMgr;

    /**
     * 验证创建
     */
    public void validateCreate(AppNewForm appNewForm) {

        App app = appMgr.getByName(appNewForm.getApp());
        if (app != null) {
            throw new FieldException(AppNewForm.APP, "app.exist", null);
        }

    }

}

@@ -599,24 +599,268 @@
 NewForm) %7B%0A%0A
+        // trim%0A        if (appNewForm.getApp() != null) %7B%0A            appNewForm.setApp(appNewForm.getApp().trim());%0A        %7D%0A        if (appNewForm.getDesc() != null) %7B%0A            appNewForm.setDesc(appNewForm.getDesc().trim());%0A        %7D%0A%0A
         App 
@@ -900,24 +900,24 @@
 .getApp());%0A
-
         if (
@@ -1004,16 +1004,16 @@
  null);%0A
+
         
@@ -1010,22 +1010,21 @@
 ;%0A        %7D%0A
-%0A
     %7D%0A%0A%7D%0A

fix app name has blank bug