use of com.tomasio.projects.trainning.dto.NetworkUserDTO in project trainning by fernandotomasio.
the class UserServiceSimpleImpl method removeUser.
@Override
public void removeUser(String uid) {
NetworkUserDAO userDAO = factory.getNetworkUserDAO();
NetworkGroupDAO groupDAO = factory.getNetworkGroupDAO();
try {
NetworkUserDTO user = userDAO.find(uid);
userDAO.remove(uid);
NetworkGroupDTO organizationGroup = groupDAO.findOrganization(user.getOrganizacao());
if (organizationGroup != null) {
organizationGroup.getMembers().remove(user.getId());
if (organizationGroup.getMembers().size() > 0) {
groupDAO.update(organizationGroup);
} else {
groupDAO.removeOrganization(user.getOrganizacao());
}
}
} catch (DAOException ex) {
throw new CoreException("Erro de acesso ao serviço de diretórios: " + ex.getMessage());
}
}
use of com.tomasio.projects.trainning.dto.NetworkUserDTO in project trainning by fernandotomasio.
the class UserServiceSimpleImpl method updateUser.
@Override
@Transactional(readOnly = true)
public void updateUser(NetworkUserDTO user) {
NetworkUserDAO userDAO = factory.getNetworkUserDAO();
NetworkGroupDAO groupDAO = factory.getNetworkGroupDAO();
OrganizacaoDAO organizacaoDAO = factory.getOrganizacaoDAO();
try {
NetworkUserDTO oldUser = userDAO.find(user.getLogin());
userDAO.update(user);
if (!oldUser.getOrganizacao().equals(user.getOrganizacao())) {
// REMOVER DO GRUPO DA ORGANIZAÇÃO ANTIGA
NetworkGroupDTO oldOrganizationGroup = groupDAO.findOrganization(oldUser.getOrganizacao());
if (oldOrganizationGroup != null) {
oldOrganizationGroup.getMembers().remove(oldUser.getId());
if (oldOrganizationGroup.getMembers().size() > 0) {
groupDAO.update(oldOrganizationGroup);
} else {
groupDAO.removeOrganization(oldUser.getOrganizacao());
}
}
// ADICIONAR AO GRUPO DA ORGANIZAÇÃO NOVA
Organizacao organizacao = organizacaoDAO.findBySigla(user.getOrganizacao());
NetworkGroupDTO organizationGroup = groupDAO.findOrganization(organizacao.getSigla());
if (organizationGroup == null) {
organizationGroup = new NetworkGroupDTO();
organizationGroup.setNome(organizacao.getSigla());
organizationGroup.setDescricao(organizacao.getNome());
organizationGroup.getMembers().add(user.getId());
groupDAO.createOrganization(organizationGroup);
} else {
organizationGroup.getMembers().add(user.getId());
groupDAO.update(organizationGroup);
}
}
} catch (DAOException ex) {
throw new CoreException("Erro de acesso ao serviço de diretórios: " + ex.getMessage());
}
}
use of com.tomasio.projects.trainning.dto.NetworkUserDTO in project trainning by fernandotomasio.
the class UserServiceSimpleImpl method authenticate.
@Override
public NetworkUserDTO authenticate(String uid, String password) {
NetworkUserDAO dao = factory.getNetworkUserDAO();
NetworkUserDTO user = null;
try {
user = dao.authenticate(uid, password);
} catch (DAOException ex) {
ex.printStackTrace();
}
return user;
}
use of com.tomasio.projects.trainning.dto.NetworkUserDTO in project trainning by fernandotomasio.
the class UserServiceSimpleImpl method findAllUsers.
@Override
public NetworkUserDTO[] findAllUsers() {
NetworkUserDAO dao = factory.getNetworkUserDAO();
NetworkUserDTO[] usersArray = null;
try {
List<NetworkUserDTO> users = dao.findAll();
if (users != null) {
usersArray = new NetworkUserDTO[users.size()];
users.toArray(usersArray);
}
} catch (DAOException ex) {
throw new CoreException("Erro de acesso ao serviço de diretórios: " + ex.getMessage());
}
return usersArray;
}
use of com.tomasio.projects.trainning.dto.NetworkUserDTO in project trainning by fernandotomasio.
the class LDAPNetworkUserDAO method find.
@SuppressWarnings("unchecked")
@Override
public NetworkUserDTO find(String uid) throws DAOException {
NetworkUserDTO user = null;
try {
AndFilter filter = new AndFilter();
filter.and(new EqualsFilter("objectclass", "inetOrgPerson")).and(new EqualsFilter("uid", uid));
List<NetworkUserDTO> users = ldapTemplate.search(DistinguishedName.EMPTY_PATH, filter.encode(), new UserAttributesMapper());
if (!users.isEmpty()) {
user = users.get(0);
}
} catch (AuthenticationException e) {
Logger.getLogger(LDAPNetworkUserDAO.class.getName()).log(Level.INFO, null, e);
throw new DAOException(MessageHelper.getMessage("systemUsers.find.error"));
}
return user;
}
Aggregations