List of usage examples for org.springframework.orm ObjectRetrievalFailureException ObjectRetrievalFailureException
public ObjectRetrievalFailureException(String persistentClassName, Object identifier)
From source file:org.esco.portlets.news.web.EntityViewController.java
/** * @param request//from w w w . j av a 2 s . c o m * @param response * @return <code>ModelAndView</code> * @throws Exception * @see org.springframework.web.portlet.mvc.AbstractController * #handleRenderRequest(javax.portlet.RenderRequest, javax.portlet.RenderResponse) */ @Override public ModelAndView handleRenderRequest(final RenderRequest request, final RenderResponse response) throws Exception { final Long id = Long.valueOf(request.getParameter(Constants.ATT_ENTITY_ID)); final String uid = request.getRemoteUser(); if (LOG.isDebugEnabled()) { LOG.debug("EntityViewController:: entering method handleRenderRequest EntityId = " + id); } final Entity entity = this.em.getEntityById(id); if (entity == null) { throw new ObjectRetrievalFailureException(Entity.class, id); } ModelAndView mav = new ModelAndView(Constants.ACT_VIEW_ENTITY); mav.addObject(Constants.OBJ_ENTITY, entity); // Get all category for the user. mav.addObject(Constants.ATT_C_LIST, this.getCm().getListCategoryOfEntityByUser(uid, id)); // Get rigths of the user in the context mav.addObject(Constants.ATT_PM, RolePerm .valueOf(this.um.getUserRoleInCtx(entity.getEntityId(), NewsConstants.CTX_E, uid)).getMask()); // Usefull for xml and opm links mav.addObject(Constants.ATT_PORTAL_URL, HostUtils.getHostUrl(request)); return mav; }
From source file:org.esco.portlets.news.web.FilterDeleteController.java
/** * @param request// w w w .j a v a2 s . c o m * @param response * @return <code>ModelAndView</code> * @throws Exception * @see org.springframework.web.portlet.mvc.AbstractController# * handleRenderRequest(javax.portlet.RenderRequest, javax.portlet.RenderResponse) */ @Override public ModelAndView handleRenderRequest(final RenderRequest request, final RenderResponse response) throws Exception { if (this.deleted) { if (LOG.isDebugEnabled()) { LOG.debug("FilterViewController:: entering method handleRenderRequestInternal - entityId=" + entityId); } final Map<FilterType, List<Filter>> filters = this.getEm().getFiltersByTypeOfEntity(entityId); if (filters != null && !filters.isEmpty()) { ModelAndView mav = new ModelAndView(Constants.ACT_VIEW_FILTERS); mav.addObject(Constants.ATT_FILTER_MAP, filters); mav.addObject(Constants.OBJ_ENTITY, this.em.getEntityById(entityId)); mav.addObject(Constants.ATT_PM, RolePerm.valueOf( this.um.getUserRoleInCtx(entityId, NewsConstants.CTX_E, request.getRemoteUser())) .getMask()); return mav; } throw new ObjectRetrievalFailureException(Filter.class, "entityId=" + entityId); } return new ModelAndView("Errors", "message", getMessageSourceAccessor().getMessage(msgKey)); }
From source file:org.esco.portlets.news.web.FilterViewController.java
/** * @param request// w ww . j a va 2 s .c om * @param response * @return <code>ModelAndView</code> * @throws Exception * @see org.springframework.web.portlet.mvc.AbstractController# * handleRenderRequest(javax.portlet.RenderRequest, javax.portlet.RenderResponse) */ @Override public ModelAndView handleRenderRequest(final RenderRequest request, final RenderResponse response) throws Exception { Long entityId = Long.valueOf(request.getParameter(Constants.ATT_ENTITY_ID)); if (LOG.isDebugEnabled()) { LOG.debug("FilterViewController:: entering method handleRenderRequestInternal - entityId=" + entityId); } final Map<FilterType, List<Filter>> filters = this.getEm().getFiltersByTypeOfEntity(entityId); if (filters != null && !filters.isEmpty()) { ModelAndView mav = new ModelAndView(Constants.ACT_VIEW_FILTERS); mav.addObject(Constants.ATT_FILTER_MAP, filters); mav.addObject(Constants.OBJ_ENTITY, this.em.getEntityById(entityId)); mav.addObject(Constants.ATT_PM, RolePerm.valueOf( this.um.getUserRoleInCtx(entityId, NewsConstants.CTX_E, request.getRemoteUser())) .getMask()); return mav; } throw new ObjectRetrievalFailureException(Filter.class, entityId); }
From source file:org.esco.portlets.news.web.TypeDeleteController.java
/** * @param request/* w w w. ja v a 2 s . co m*/ * @param response * @return <code>ModelAndView</code> * @throws Exception * @see org.springframework.web.portlet.mvc.AbstractController# * handleRenderRequest(javax.portlet.RenderRequest, javax.portlet.RenderResponse) */ @Override public ModelAndView handleRenderRequest(final RenderRequest request, final RenderResponse response) throws Exception { if (this.deleted) { final List<Type> types = this.getTm().getAllTypes(); if (types != null && !types.isEmpty()) { ModelAndView mav = new ModelAndView(Constants.ACT_VIEW_TYPE); mav.addObject(Constants.ATT_TYPE_LIST, types); return mav; } throw new ObjectRetrievalFailureException(Type.class, "No object found."); } return new ModelAndView("Errors", "message", getMessageSourceAccessor().getMessage(msgKey)); }
From source file:org.esco.portlets.news.web.TypeSettingViewController.java
/** * @param request// w w w.j a v a 2 s. c o m * @param response * @return <code>ModelAndView</code> * @throws Exception * @see org.springframework.web.portlet.mvc.AbstractController# * handleRenderRequest(javax.portlet.RenderRequest, javax.portlet.RenderResponse) */ @Override public ModelAndView handleRenderRequest(final RenderRequest request, final RenderResponse response) throws Exception { Long id = Long.valueOf(request.getParameter(Constants.ATT_TYPE_ID)); if (LOG.isDebugEnabled()) { LOG.debug("TypeSettingViewController:: entering method handleRenderRequestInternal: type Id=" + id); } final Type type = this.getTm().getTypeById(id); if (type != null) { TypeForm typeF = new TypeForm(); typeF.setType(type); List<Entity> entities = this.getEm().getEntitiesByType(id); List<String> entitiesIds = new ArrayList<String>(); Map<Long, List<Category>> categoriesOfTypeInEntity = new HashMap<Long, List<Category>>(); if (entities != null && !entities.isEmpty()) { for (Entity e : entities) { entitiesIds.add(String.valueOf(e.getEntityId())); List<Category> catList = this.cm.getCategoryByTypeOfEntity(type.getTypeId(), e.getEntityId()); categoriesOfTypeInEntity.put(e.getEntityId(), catList); } typeF.setEntitiesIds(entitiesIds.toArray(new String[0])); } ModelAndView mav = new ModelAndView(Constants.ACT_VIEW_TYPE_SETTING); mav.addObject(Constants.CMD_TYPE, typeF); mav.addObject(Constants.ATT_E_LIST, entities); mav.addObject(Constants.ATT_MAP_C_E, categoriesOfTypeInEntity); return mav; } throw new ObjectRetrievalFailureException(Type.class, id); }
From source file:org.esco.portlets.news.web.TypeViewController.java
/** * @param request/*from w w w .j a v a 2 s . co m*/ * @param response * @return <code>ModelAndView</code> * @throws Exception * @see org.springframework.web.portlet.mvc.AbstractController# * handleRenderRequest(javax.portlet.RenderRequest, javax.portlet.RenderResponse) */ @Override public ModelAndView handleRenderRequest(final RenderRequest request, final RenderResponse response) throws Exception { if (LOG.isDebugEnabled()) { LOG.debug("TypeViewController:: entering method handleRenderRequestInternal."); } final List<Type> types = this.getTm().getAllTypes(); if (types != null && !types.isEmpty()) { ModelAndView mav = new ModelAndView(Constants.ACT_VIEW_TYPE); mav.addObject(Constants.ATT_TYPE_LIST, types); mav.addObject(Constants.ATT_PORTAL_URL, HostUtils.getHostUrl(request)); return mav; } throw new ObjectRetrievalFailureException(Type.class, "No object found."); }
From source file:org.openmrs.scheduler.db.hibernate.HibernateSchedulerDAO.java
/** * Get task by internal identifier// w w w . ja va 2s . c o m * * @param taskId internal task identifier * @return task with given internal identifier * @throws DAOException */ public TaskDefinition getTask(Integer taskId) throws DAOException { TaskDefinition task = (TaskDefinition) sessionFactory.getCurrentSession().get(TaskDefinition.class, taskId); if (task == null) { log.warn("Task '" + taskId + "' not found"); throw new ObjectRetrievalFailureException(TaskDefinition.class, taskId); } return task; }
From source file:org.openmrs.scheduler.db.hibernate.HibernateSchedulerDAO.java
/** * Get task by public name./*from www.j a va2 s .com*/ * * @param name public task name * @return task with given public name * @throws DAOException */ public TaskDefinition getTaskByName(String name) throws DAOException { Criteria crit = sessionFactory.getCurrentSession().createCriteria(TaskDefinition.class) .add(Restrictions.eq("name", name)); TaskDefinition task = (TaskDefinition) crit.uniqueResult(); if (task == null) { log.warn("Task '" + name + "' not found"); throw new ObjectRetrievalFailureException(TaskDefinition.class, name); } return task; }
From source file:org.openmrs.scheduler.db.hibernate.HibernateSchedulerDAO.java
/** * Get schedule by internal identifier/*from ww w. j a va2 s . com*/ * * @param scheduleId internal schedule identifier * @return schedule with given internal identifier * @throws DAOException */ public Schedule getSchedule(Integer scheduleId) throws DAOException { Schedule schedule = (Schedule) sessionFactory.getCurrentSession().get(Schedule.class, scheduleId); if (schedule == null) { log.error("Schedule '" + scheduleId + "' not found"); throw new ObjectRetrievalFailureException(Schedule.class, scheduleId); } return schedule; }
From source file:org.pssframework.dao.BaseHibernateDao.java
public void deleteById(PK id) { Object entity = getById(id);//from ww w.j a v a 2s.com if (entity == null) { throw new ObjectRetrievalFailureException(getEntityClass(), id); } getHibernateTemplate().delete(entity); }