use of com.tomasio.projects.trainning.exception.DAOException in project trainning by fernandotomasio.
the class UserServiceSimpleImpl method createUser.
@Override
@Transactional(readOnly = true)
public void createUser(NetworkUserDTO user) {
NetworkUserDAO userDAO = factory.getNetworkUserDAO();
NetworkGroupDAO groupDAO = factory.getNetworkGroupDAO();
OrganizacaoDAO organizacaoDAO = factory.getOrganizacaoDAO();
try {
userDAO.create(user);
user = userDAO.find(user.getLogin());
NetworkGroupDTO roleGroup = groupDAO.findRole("OperadorLocal");
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);
}
roleGroup.getMembers().add(user.getId());
groupDAO.update(roleGroup);
} catch (DAOException ex) {
throw new CoreException("Erro de acesso ao serviço de diretórios: " + ex.getMessage());
}
}
use of com.tomasio.projects.trainning.exception.DAOException in project trainning by fernandotomasio.
the class UserServiceSimpleImpl method createUser.
@Override
@Transactional(readOnly = true)
public void createUser(NetworkUserDTO user, String[] roles) {
NetworkUserDAO userDAO = factory.getNetworkUserDAO();
NetworkGroupDAO groupDAO = factory.getNetworkGroupDAO();
OrganizacaoDAO organizacaoDAO = factory.getOrganizacaoDAO();
try {
userDAO.create(user);
user = userDAO.find(user.getLogin());
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);
}
if (roles != null) {
for (String role : roles) {
NetworkGroupDTO roleGroup = groupDAO.findRole(role);
roleGroup.getMembers().add(user.getId());
groupDAO.update(roleGroup);
}
}
} catch (DAOException ex) {
throw new CoreException("Erro de acesso ao serviço de diretórios: " + ex.getMessage());
}
}
use of com.tomasio.projects.trainning.exception.DAOException in project trainning by fernandotomasio.
the class UserServiceSimpleImpl method findAllRoleGroups.
@Override
public NetworkGroupDTO[] findAllRoleGroups() {
NetworkGroupDAO dao = factory.getNetworkGroupDAO();
NetworkGroupDTO[] groupsArray = null;
try {
List<NetworkGroupDTO> groups = dao.findAllRoles();
if (groups != null) {
groupsArray = new NetworkGroupDTO[groups.size()];
groups.toArray(groupsArray);
}
} catch (DAOException ex) {
throw new CoreException("Erro de acesso ao serviço de diretórios: " + ex.getMessage());
}
return groupsArray;
}
use of com.tomasio.projects.trainning.exception.DAOException 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.exception.DAOException 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;
}
Aggregations