use of com.tomasio.projects.trainning.dto.NetworkGroupDTO in project trainning by fernandotomasio.
the class LDAPNetworkGroupDAO method findOrganization.
@Override
public NetworkGroupDTO findOrganization(String uid) throws DAOException {
NetworkGroupDTO group = null;
try {
DistinguishedName dn = new DistinguishedName();
dn.add("ou", "groups");
dn.add("ou", APPLICATION_GROUP_BRANCH);
dn.add("ou", ORGANIZATIONS_GROUP_BRANCH);
dn.add("cn", uid);
group = (NetworkGroupDTO) ldapTemplate.lookup(dn, getGroupContextMapper());
} catch (AuthenticationException e) {
Logger.getLogger(this.getClass().getName()).log(Level.INFO, null, e);
throw new DAOException(MessageHelper.getMessage("systemUsers.find.error"));
} catch (org.springframework.ldap.NameNotFoundException e) {
Logger.getLogger(this.getClass().getName()).log(Level.INFO, null, e);
}
return group;
}
use of com.tomasio.projects.trainning.dto.NetworkGroupDTO in project trainning by fernandotomasio.
the class TestesDAO method main.
public static void main(String[] args) throws DAOException {
@SuppressWarnings("resource") ApplicationContext context = new ClassPathXmlApplicationContext("persist-context.xml");
DAOFactory factory = (DAOFactory) context.getBean("daoFactory");
NetworkGroupDAO dao = factory.getNetworkGroupDAO();
SessionFactory sessionFactory = (SessionFactory) context.getBean("sessionFactory");
HibernateTransactionManager transactionManager = new HibernateTransactionManager(sessionFactory);
Session session = transactionManager.getSessionFactory().openSession();
Transaction tx = session.beginTransaction();
NetworkGroupDTO group = dao.findRole("OperadorLocal");
group.getMembers().add("uid=tasdfasd,ou=people");
dao.update(group);
tx.commit();
session.close();
}
use of com.tomasio.projects.trainning.dto.NetworkGroupDTO in project trainning by fernandotomasio.
the class SettingsController method showIndex.
@RequestMapping({ "/", "/index", "" })
public String showIndex(Model model, WebRequest request) {
final InetOrgPerson user = (InetOrgPerson) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
String userLogin = user.getUid();
// buscar o usuário pelo ID
NetworkUserDTO usuario = userService.findUser(userLogin);
// buscar as roles do usuário
NetworkGroupDTO[] groups = userService.findAllRoleGroups();
List<String> rolesAssigned = new ArrayList<>();
for (NetworkGroupDTO group : groups) {
if (group.getMembers().contains(usuario.getId())) {
rolesAssigned.add(group.getNome());
}
}
// jogo no ArrayList para trabalhar
List<NetworkGroupDTO> roles = new ArrayList();
roles.addAll(Arrays.asList(groups));
// ordenar a lista de roles
Collections.sort(roles, new Comparator<NetworkGroupDTO>() {
@Override
public int compare(NetworkGroupDTO o1, NetworkGroupDTO o2) {
return o1.getDescricao().compareTo(o2.getDescricao());
}
});
model.addAttribute("roles", roles);
model.addAttribute("rolesAssigned", rolesAssigned);
model.addAttribute("usuario", usuario);
return "settings";
}
use of com.tomasio.projects.trainning.dto.NetworkGroupDTO in project trainning by fernandotomasio.
the class UsuariosController method editUsuario.
@RequestMapping("/edit")
public String editUsuario(Model model, @ModelAttribute("userOrganization") OrganizacaoDTO userOrganization, WebRequest request) {
String usuarioId = request.getParameter("usuarioId");
// buscar usuário pelo ID
NetworkUserDTO dto = userService.findUser(usuarioId);
// buscar as roles do usuário
NetworkGroupDTO[] groups = userService.findAllRoleGroups();
List<String> rolesAssigned = new ArrayList<>();
for (NetworkGroupDTO group : groups) {
if (group.getMembers().contains(dto.getId())) {
rolesAssigned.add(group.getNome());
}
}
// jogo no ArrayList para trabalhar
List<NetworkGroupDTO> roles = new ArrayList();
roles.addAll(Arrays.asList(groups));
// ordenar a lista de roles
Collections.sort(roles, new Comparator<NetworkGroupDTO>() {
@Override
public int compare(NetworkGroupDTO o1, NetworkGroupDTO o2) {
return o1.getDescricao().compareTo(o2.getDescricao());
}
});
UsuarioForm usuarioForm = new UsuarioForm();
usuarioForm.setOp("EDIT");
usuarioForm.setEmail(dto.getEmail());
usuarioForm.setLogin(dto.getLogin());
usuarioForm.setNome(dto.getNome());
usuarioForm.setNomeGuerra(dto.getNomeGuerra());
OrganizacaoDTO organizacao = organizationalService.findOrganizacaoBySigla(dto.getOrganizacao());
usuarioForm.setOrganizacaoId(organizacao.getId());
usuarioForm.setPosto(dto.getPosto());
usuarioForm.setTelefone(dto.getTelefone());
model.addAttribute(usuarioForm);
model.addAttribute("organizacoes", initializeSelectableOrganizacoes(request, userOrganization));
model.addAttribute("roles", roles);
model.addAttribute("rolesAssigned", rolesAssigned);
return "usuarios/form";
}
use of com.tomasio.projects.trainning.dto.NetworkGroupDTO in project trainning by fernandotomasio.
the class UsuariosController method showDetails.
@RequestMapping("/detail")
public String showDetails(Model model, WebRequest request) {
String usuarioId = request.getParameter("usuarioId");
// buscar o usuário pelo ID
NetworkUserDTO usuario = userService.findUser(usuarioId);
// buscar as roles do usuário
NetworkGroupDTO[] groups = userService.findAllRoleGroups();
List<String> rolesAssigned = new ArrayList<>();
for (NetworkGroupDTO group : groups) {
if (group.getMembers().contains(usuario.getId())) {
rolesAssigned.add(group.getNome());
}
}
// jogo no ArrayList para trabalhar
List<NetworkGroupDTO> roles = new ArrayList();
roles.addAll(Arrays.asList(groups));
// ordenar a lista de roles
Collections.sort(roles, new Comparator<NetworkGroupDTO>() {
@Override
public int compare(NetworkGroupDTO o1, NetworkGroupDTO o2) {
return o1.getDescricao().compareTo(o2.getDescricao());
}
});
model.addAttribute("roles", roles);
model.addAttribute("rolesAssigned", rolesAssigned);
model.addAttribute("usuario", usuario);
return "usuarios/detail";
}
Aggregations