List of usage examples for org.springframework.dao DataAccessException getLocalizedMessage
public String getLocalizedMessage()
From source file:org.esco.portlets.news.services.EntityManagerImpl.java
/** * Delete a Filter of an Entity.// w w w . j a v a2 s . c om * @param filterId The filter id. * @param entityId The entity id. * @return <code>boolean</code> */ @Transactional(readOnly = false) public boolean deleteFilterOfEntity(final Long filterId, final Long entityId) { try { return this.filterDao.deleteFilterOfEntity(filterId, entityId); } catch (DataAccessException e) { LOG.error("Delete Filter of Entity error : " + e.getLocalizedMessage()); throw e; } }
From source file:org.esco.portlets.news.services.EntityManagerImpl.java
/** * Returns the filter from id.//from www . j av a2 s . c o m * @param filterId * @return <code>Filter</code> */ public Filter getFilter(final Long filterId) { try { return this.filterDao.getFilterById(filterId); } catch (DataAccessException e) { LOG.error("Get Filter error : " + e.getLocalizedMessage()); throw e; } }
From source file:org.esco.portlets.news.services.EntityManagerImpl.java
/** * Returns the list of filters associated to an Entity. * @param entityId The entity id./*from w w w. ja v a 2 s. com*/ * @return <code>List<Filter></code> */ public List<Filter> getFiltersOfEntity(final Long entityId) { try { return this.filterDao.getFiltersOfEntity(entityId); } catch (DataAccessException e) { LOG.error("Get Filters of Entity error : " + e.getLocalizedMessage()); throw e; } }
From source file:org.esco.portlets.news.services.EntityManagerImpl.java
/** * Returns the list of filters associated to an Entity and classed by type. * @param entityId The entity id./*from ww w . jav a2 s . co m*/ * @return <code>List<Filter></code> */ public Map<FilterType, List<Filter>> getFiltersByTypeOfEntity(final Long entityId) { try { Map<FilterType, List<Filter>> map = new HashMap<FilterType, List<Filter>>(); for (FilterType ft : FilterType.values()) { map.put(ft, this.filterDao.getFiltersOfTypeOfEntity(entityId, ft)); } return map; } catch (DataAccessException e) { LOG.error("Get Filters of Entity error : " + e.getLocalizedMessage()); throw e; } }
From source file:org.esco.portlets.news.services.TypeManagerImpl.java
/** * Sauvegarder un type./*w ww. jav a2 s.c o m*/ * @param type */ @Transactional(readOnly = false, propagation = Propagation.REQUIRES_NEW) public void saveType(final Type type) { if (type == null) { throw new IllegalArgumentException("Can't save a type when given a null type instance."); } try { this.typeDao.saveType(type); } catch (DataIntegrityViolationException dive) { LOG.error("Could not save entity, duplicate entity id or name ??", dive); throw dive; } catch (DataAccessException e) { LOG.error("Could not save entity " + e.getLocalizedMessage(), e); throw e; } }
From source file:org.esco.portlets.news.services.TypeManagerImpl.java
/** * Obtenir un type partir de son id./*from w w w .ja va 2s . c o m*/ * @param typeId * @return <code>Type</code> */ public Type getTypeById(final Long typeId) { try { return this.typeDao.getTypeById(typeId); } catch (DataAccessException e) { LOG.error("Get Type By Id error : " + e.getLocalizedMessage()); throw e; } }
From source file:org.esco.portlets.news.services.TypeManagerImpl.java
/** * Supprimer un type./*from w w w .j a v a 2 s. c om*/ * @param typeId * @return true si la suppression s'est bien passe, faux sinon. */ @Transactional(readOnly = false) public boolean deleteType(final Long typeId) { try { Type t = this.typeDao.getTypeById(typeId); if (t.equals(typeDao.getTypeByName(NewsConstants.DEFAULT_TYPE))) { throw new IllegalArgumentException("This isn't authorized to delete the default type."); } return this.typeDao.deleteTypeById(typeId); } catch (DataAccessException e) { LOG.error("Delete Type error : " + e.getLocalizedMessage()); throw e; } }
From source file:org.esco.portlets.news.services.TypeManagerImpl.java
/** * Lier des entits un type./* w w w. jav a 2 s .c o m*/ * @param typeId * @param entitiesIds * @see org.esco.portlets.news.services.TypeManager#addEntitiesToType(java.lang.Long, java.util.List) */ @Transactional(readOnly = false) public void addEntitiesToType(final Long typeId, final List<Long> entitiesIds) { try { this.typeDao.addEntitiesToType(typeId, entitiesIds); } catch (DataAccessException e) { LOG.error("Add Entities to Type Error msg : " + e.getLocalizedMessage()); throw e; } }
From source file:org.esco.portlets.news.services.TypeManagerImpl.java
/** * Supprime a des entits un type, mais en vrifiant * qu'aucune des catgories des entits n'aient encore le type de li. * @param typeId/*from w w w.j a va2 s . c o m*/ * @param entitiesIds * @see org.esco.portlets.news.services.TypeManager#deleteEntitiesToType(java.lang.Long, java.util.List) */ @Transactional(readOnly = false) public void deleteEntitiesToType(final Long typeId, final List<Long> entitiesIds) { try { List<Long> entities = new ArrayList<Long>(); boolean b = true; for (Long eId : entitiesIds) { List<Category> cats = this.catDao.getCategoryByTypeOfEntity(typeId, eId); if (cats == null || cats.isEmpty()) { entities.add(eId); } else { b = false; } } if (!entities.isEmpty()) { this.getTypeDao().deleteEntitiesToType(typeId, entities); } if (!b) { String msg = "Delete unauthorized, the type is always attached to some Categories of Entities."; LOG.error(msg); throw new UnauthorizedException(msg); } } catch (DataAccessException e) { LOG.error("Delete Entities to Type error : " + e.getLocalizedMessage()); throw e; } }
From source file:org.esco.portlets.news.services.UserManagerImpl.java
/** * @param searchBy//from w ww. j a v a2 s . c om * @return <code>User</code> * @see org.esco.portlets.news.services.UserManager#findUserByUid(java.lang.String) */ public IEscoUser findUserByUid(final String searchBy) { try { return userDao.getUserById(searchBy); } catch (DataAccessException e) { LOG.error("findUserById:: " + e.getLocalizedMessage()); } return null; }