private void validateItem(Item item) { if (item.getCategory() == null || item.getCategory().getId() == null) { throw new ApplicationRuntimeException(bundle.getString("ADM_ITEM_VALIDATE_CATEGORY_NOK")); } if (item.getDescription() == null || item.getDescription().length() == 0) { throw new ApplicationRuntimeException(bundle.getString("ADM_ITEM_VALIDATE_DESCRIPTION_NOK")); } }
public List<Category> listAvailableCategories() { try { return categoryDAO.listAvailableCategories(); } catch (Exception e) { throw new ApplicationRuntimeException(bundle.getString("LIST_CATEGORY_NOK", e)); } }
public void delete(Item item) { try { item = itemDAO.load(item.getId()); if (item == null) { throw new ApplicationRuntimeException(bundle.getString("OBJECT_NOT_FOUND")); } List<Auction> listAuctions = auctionDAO.listAllAuctionsByItem(item); if (listAuctions != null) if (listAuctions.size() > 0) throw new ApplicationRuntimeException( bundle.getString("ADM_ITEM_DELETE_NOK_THERE_ARE_AUCTIONS")); itemDAO.delete(item.getId()); } catch (Exception e) { e.printStackTrace(); throw new ApplicationRuntimeException(bundle.getString("ADM_ITEM_DELETED_NOK" + e)); } }
public FacesContext getDelegate() { FacesContext facesContext = FacesContext.getCurrentInstance(); if (facesContext == null) { throw new ContextNotActiveException(bundle.getString("faces-context-not-available")); } return facesContext; }
public void send(Message message) { mailer .to(resourceBundle.getString("demoiselle-mail-to")) .from(message.getSender().getEmail()) .body() .text(message.getText()) .subject(message.getSubject()) .send(); }
/** @throws AuthenticationException */ @SuppressWarnings("unused") @Override public void authenticate() throws AuthenticationException { Usuario user; Map<Integer, Integer> recursosOperacoes = new HashMap<Integer, Integer>(); try { user = usuarioDAO.findById(Long.getLong(identity.getId())); if (user != null) { List<UsuarioRecurso> recursosUsuario = usuarioRecursoDAO.findByUsuario(user.getId()); if (recursosUsuario != null) { Iterator<UsuarioRecurso> it = recursosUsuario.iterator(); while (it.hasNext()) { UsuarioRecurso usuarioRecurso = it.next(); recursosOperacoes.put( usuarioRecurso.getUsuarioRecursosPK().getRecursos(), usuarioRecurso.getOperacao()); } } else { throw new AuthenticationException( rb.getString("login.usuario.nao.existe"), new Exception()); } } else { throw new AuthenticationException( rb.getString("login.usuario.nao.existe"), new Exception()); } } catch (Exception ex) { throw new AuthenticationException(rb.getString("login.usuario.nao.existe"), ex); } if (!user.getAminesia().isEmpty() && user.getSenha().equals(user.getAminesia().substring(21, 27))) { throw new AuthenticationException(rb.getString("login.alteracao.por.email")); } this.identity.setAttribute("Nome", user.getNome()); this.identity.setAttribute("Papel", Roles.getRole(user.getPapel()).get(0)); this.identity.setAttribute("Recurso", recursosOperacoes); }
public List<Item> filterByCategory(Item item) { if (item.getCategory() != null) { try { List<Item> list = itemDAO.listByCategory(item.getCategory()); return list; } catch (Exception e) { throw new ApplicationRuntimeException(bundle.getString("ADM_ITEM_LIST_LOAD_NOK", e)); } } return new ArrayList<Item>(); }
@Override @Transactional public String update() { UsuarioEntity usuario = this.getBean().getUsuario(); if (usuario.getSenha().equals(CriptografiaUtil.getCodigoMd5(getSenhaAtual()))) { usuario.setSenha(CriptografiaUtil.getCodigoMd5(getNovaSenha())); this.avaliadorBC.update(this.getBean()); } else { messageContext.add(bundle.getString("label.senha.invalida")); } return getPreviousView(); }
public Item save(Item item) { validateItem(item); try { if (item.getId() != null) { itemDAO.update(item); } else { itemDAO.insert(item); } } catch (Exception e) { throw new ApplicationRuntimeException(bundle.getString("ADM_ITEM_SAVE_NOK", e)); } return item; }