if ("getOrgs".equals(action)) {
try {
JSONArray jsonArray = new JSONArray();
ApplicationContext ac = AppUtil.getApplicationContext();
ExtDirectoryManager directoryManager = (ExtDirectoryManager) ac.getBean("directoryManager");
Map<String, String> empty = new HashMap<String, String>();
empty.put("value", "");
empty.put("label", ResourceBundleUtil.getMessage("console.directory.user.empty.option.label"));
jsonArray.put(empty);
Collection<Organization> orgList = directoryManager.getOrganizationsByFilter(null, "name", false, null, null);
for (Organization o : orgList) {
Map<String, String> option = new HashMap<String, String>();
option.put("value", o.getId());
option.put("label", o.getName());
jsonArray.put(option);
}
jsonArray.write(response.getWriter());
} catch (Exception ex) {
LogUtil.error(this.getClass().getName(), ex, "Get Organization options Error!");
}
} else if ("getUsers".equals(action)) {
String orgId = request.getParameter("orgId");
if ("null".equals(orgId) || "".equals(orgId)) {
orgId = null;
}
try {
JSONArray jsonArray = new JSONArray();
ApplicationContext ac = AppUtil.getApplicationContext();
ExtDirectoryManager directoryManager = (ExtDirectoryManager) ac.getBean("directoryManager");
Collection<User> userList = directoryManager.getUsers(null, orgId, null, null, null, null, null, "firstName", false, null, null);
for (User u : userList) {
Map<String, String> option = new HashMap<String, String>();
option.put("value", u.getUsername());
option.put("label", u.getFirstName() + " " + u.getLastName() + "(" + u.getUsername() + ")");