@Test public void testUser() { UserDO userDO = new UserDO(); userDO.setUsername("liangjian"); ServerGroupDO serverGroupDO= new ServerGroupDO(); serverGroupDO.setName("group_ci"); System.err.println(zabbixServiceImpl.checkUserInUsergroup(userDO,serverGroupDO)); }
public int checkUserInUsergroup(UserDO userDO, ServerGroupDO serverGroupDO) { int userid = this.userGet(userDO); if (userid == 0) return 2; String usergrpName = serverGroupDO.getName().replace("group_", "users_"); int usrgrpid = usergroupGet(usergrpName); if (usrgrpid == 0) return 3; ZabbixRequest request = ZabbixRequestBuilder.newBuilder() .method("user.get").paramEntry("userids", new int[]{ userid }).paramEntry("usrgrpids", new int[]{ usrgrpid }) .build(); JSONObject getResponse = call(request); int resultUserid = getResultId(getResponse, "userid"); if (resultUserid == 0) return 0; return 1; }
ZabbixServiceImpl implements ZabbixService, InitializingBean { public int checkUserInUsergroup(UserDO userDO, ServerGroupDO serverGroupDO) { int userid = this.userGet(userDO); if (userid == 0) return 2; String usergrpName = serverGroupDO.getName().replace("group_", "users_"); int usrgrpid = usergroupGet(usergrpName); if (usrgrpid == 0) return 3; ZabbixRequest request = ZabbixRequestBuilder.newBuilder() .method("user.get").paramEntry("userids", new int[]{ userid }).paramEntry("usrgrpids", new int[]{ usrgrpid }) .build(); JSONObject getResponse = call(request); int resultUserid = getResultId(getResponse, "userid"); if (resultUserid == 0) return 0; return 1; } }
ZabbixServiceImpl implements ZabbixService, InitializingBean { public int checkUserInUsergroup(UserDO userDO, ServerGroupDO serverGroupDO) { int userid = this.userGet(userDO); if (userid == 0) return 2; String usergrpName = serverGroupDO.getName().replace("group_", "users_"); int usrgrpid = usergroupGet(usergrpName); if (usrgrpid == 0) return 3; ZabbixRequest request = ZabbixRequestBuilder.newBuilder() .method("user.get").paramEntry("userids", new int[]{ userid }).paramEntry("usrgrpids", new int[]{ usrgrpid }) .build(); JSONObject getResponse = call(request); int resultUserid = getResultId(getResponse, "userid"); if (resultUserid == 0) return 0; return 1; }  }
ZabbixServiceImpl implements ZabbixService, InitializingBean { public int checkUserInUsergroup(UserDO userDO, ServerGroupDO serverGroupDO) { int userid = this.userGet(userDO); if (userid == 0) return 2; String usergrpName = serverGroupDO.getName().replace("group_", "users_"); int usrgrpid = usergroupGet(usergrpName); if (usrgrpid == 0) return 3; ZabbixRequest request = ZabbixRequestBuilder.newBuilder() .method("user.get").paramEntry("userids", new int[]{ userid }).paramEntry("usrgrpids", new int[]{ usrgrpid }) .build(); JSONObject getResponse = call(request); int resultUserid = getResultId(getResponse, "userid"); if (resultUserid == 0) return 0; return 1; }  @Override String getApiVersion(); @Override boolean hostExists(ServerDO serverDO); @Override int hostGetStatus(ServerDO serverDO); @Deprecated int hostGetByIP(String ip); @Deprecated int hostGetByName(String name); int proxyGet(String hostname); boolean hostgroupCreate(String name); int templateGet(String name); int usergroupGet(String usergroup); @Override BusinessWrapper<Boolean> userCreate(UserDO userDO); @Override int usergroupCreate(ServerGroupDO serverGroupDO); @Override int userGet(UserDO userDO); @Override BusinessWrapper<Boolean> userDelete(UserDO userDO); @Override BusinessWrapper<Boolean> syncUser(); void cleanZabbixUser(); @Override BusinessWrapper<Boolean> checkUser(); @Override BusinessWrapper<Boolean> userUpdate(UserDO userDO); @Deprecated JSONObject itemGetAll(ServerDO serverDO); int itemGet(ServerDO serverDO, String itemName, String itemKey); @Override int actionCreate(ServerGroupDO serverGroupDO); @Override JSONObject historyGet(ServerDO serverDO, String itemName, String itemKey, int historyType, int limit); @Override JSONObject historyGet(ServerDO serverDO, String itemName, String itemKey, int historyType, String timestampFrom, String timestampTill); void api(int statusType, String key, String project, String group, String env); @Override BusinessWrapper<Boolean> refresh(); @Override BusinessWrapper<Boolean> addMonitor(long serverId); @Override BusinessWrapper<Boolean> delMonitor(long serverId); @Override BusinessWrapper<Boolean> disableMonitor(long serverId); @Override BusinessWrapper<Boolean> enableMonitor(long serverId); @Override BusinessWrapper<Boolean> ci(String key, int type, String project, String group, String env, Long deployId, String bambooDeployVersion,
                                       int bambooBuildNumber, String bambooDeployProject, boolean bambooDeployRollback,
                                       String bambooManualBuildTriggerReasonUserName, int errorCode, String branchName, int deployType); int checkUserInUsergroup(UserDO userDO, ServerGroupDO serverGroupDO); @Override void afterPropertiesSet(); }
ZabbixServiceImpl implements ZabbixService, InitializingBean { public int checkUserInUsergroup(UserDO userDO, ServerGroupDO serverGroupDO) { int userid = this.userGet(userDO); if (userid == 0) return 2; String usergrpName = serverGroupDO.getName().replace("group_", "users_"); int usrgrpid = usergroupGet(usergrpName); if (usrgrpid == 0) return 3; ZabbixRequest request = ZabbixRequestBuilder.newBuilder() .method("user.get").paramEntry("userids", new int[]{ userid }).paramEntry("usrgrpids", new int[]{ usrgrpid }) .build(); JSONObject getResponse = call(request); int resultUserid = getResultId(getResponse, "userid"); if (resultUserid == 0) return 0; return 1; }  @Override String getApiVersion(); @Override boolean hostExists(ServerDO serverDO); @Override int hostGetStatus(ServerDO serverDO); @Deprecated int hostGetByIP(String ip); @Deprecated int hostGetByName(String name); int proxyGet(String hostname); boolean hostgroupCreate(String name); int templateGet(String name); int usergroupGet(String usergroup); @Override BusinessWrapper<Boolean> userCreate(UserDO userDO); @Override int usergroupCreate(ServerGroupDO serverGroupDO); @Override int userGet(UserDO userDO); @Override BusinessWrapper<Boolean> userDelete(UserDO userDO); @Override BusinessWrapper<Boolean> syncUser(); void cleanZabbixUser(); @Override BusinessWrapper<Boolean> checkUser(); @Override BusinessWrapper<Boolean> userUpdate(UserDO userDO); @Deprecated JSONObject itemGetAll(ServerDO serverDO); int itemGet(ServerDO serverDO, String itemName, String itemKey); @Override int actionCreate(ServerGroupDO serverGroupDO); @Override JSONObject historyGet(ServerDO serverDO, String itemName, String itemKey, int historyType, int limit); @Override JSONObject historyGet(ServerDO serverDO, String itemName, String itemKey, int historyType, String timestampFrom, String timestampTill); void api(int statusType, String key, String project, String group, String env); @Override BusinessWrapper<Boolean> refresh(); @Override BusinessWrapper<Boolean> addMonitor(long serverId); @Override BusinessWrapper<Boolean> delMonitor(long serverId); @Override BusinessWrapper<Boolean> disableMonitor(long serverId); @Override BusinessWrapper<Boolean> enableMonitor(long serverId); @Override BusinessWrapper<Boolean> ci(String key, int type, String project, String group, String env, Long deployId, String bambooDeployVersion,
                                       int bambooBuildNumber, String bambooDeployProject, boolean bambooDeployRollback,
                                       String bambooManualBuildTriggerReasonUserName, int errorCode, String branchName, int deployType); int checkUserInUsergroup(UserDO userDO, ServerGroupDO serverGroupDO); @Override void afterPropertiesSet(); static final String zabbix_host_monitor_public_ip; static final String zabbix_proxy_id; static final String zabbix_proxy_name; static final int hostStatusDisable; static final int hostStatusEnable; static final int isMonitor; static final int noMonitor; }