List of usage examples for org.springframework.orm ObjectRetrievalFailureException ObjectRetrievalFailureException
public ObjectRetrievalFailureException(String persistentClassName, Object identifier)
From source file:org.uhp.portlets.news.dao.iBatis.SqlMapClientCategoryDaoImpl.java
public Category getCategoryById(final Long categoryId) throws DataAccessException { Category category = (Category) getSqlMapClientTemplate().queryForObject("getCategoryById", categoryId); if (category == null) { LOGGER.error("category [" + categoryId + "] not found"); throw new ObjectRetrievalFailureException(Category.class, categoryId); }/*from w w w.j a v a 2s.c o m*/ category.setTotalCount( (Integer) getSqlMapClientTemplate().queryForObject("getTotalItemsCountByCategory", categoryId)); category.setPendingCount( (Integer) getSqlMapClientTemplate().queryForObject("getPendingItemsCountByCategory", categoryId)); return category; }
From source file:org.uhp.portlets.news.dao.iBatis.SqlMapClientTopicDaoImpl.java
public Topic getTopicById(final Long topicId) throws DataAccessException { Topic topic = null;//ww w . j ava 2 s. c om try { topic = (Topic) getSqlMapClientTemplate().queryForObject("getTopicById", topicId); if (topic == null) { LOGGER.error("getTopic:: topic null"); throw new ObjectRetrievalFailureException(Topic.class, topicId); } } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } return topic; }
From source file:org.uhp.portlets.news.web.CategoryEditController.java
/** * @param request//from w ww. j a va 2 s . com * @return <code>CategoryForm</code> * @throws Exception * @see org.springframework.web.portlet.mvc.AbstractFormController# * formBackingObject(javax.portlet.PortletRequest) */ @Override protected Object formBackingObject(final PortletRequest request) throws Exception { Long categoryId = PortletRequestUtils.getLongParameter(request, Constants.ATT_CAT_ID); CategoryForm catF = new CategoryForm(); if (categoryId != null) { securityCheck(request.getRemoteUser(), NewsConstants.CTX_C, categoryId); catF.setCategory(this.cm.getCategoryById(categoryId)); List<String> tIds = new ArrayList<String>(); for (Type t : this.getCm().getTypesOfCategory(categoryId)) { tIds.add(String.valueOf(t.getTypeId())); } catF.setTypesIds(tIds.toArray(new String[0])); return catF; } throw new ObjectRetrievalFailureException(Category.class, null); }
From source file:org.uhp.portlets.news.web.CategoryViewController.java
public ModelAndView handleRenderRequestInternal(RenderRequest request, RenderResponse response) throws Exception { Long id = Long.valueOf(request.getParameter(Constants.ATT_CAT_ID)); if (LOGGER.isDebugEnabled()) { LOGGER.debug("CategoryViewController:: entering method handleRenderRequestInternal: catId=" + id); }// w w w . j ava 2 s . com Category category = this.cm.getCategoryById(id); if (category == null) { throw new ObjectRetrievalFailureException(Category.class, id); } List<String> usersUid = new ArrayList<String>(); usersUid.add(category.getCreatedBy()); ModelAndView mav = new ModelAndView(Constants.ACT_VIEW_CAT); mav.addObject(Constants.OBJ_CATEGORY, category); mav.addObject(Constants.ATT_TYPE_LIST, this.cm.getTypesOfCategory(id)); mav.addObject(Constants.OBJ_ENTITY, this.em.getEntityById(category.getEntityId())); mav.addObject(Constants.ATT_USER_LIST, this.um.getUsersByListUid(usersUid)); mav.addObject(Constants.ATT_T_LIST, this.tm.getTopicListForCategoryByUser(id, request.getRemoteUser())); mav.addObject(Constants.ATT_PM, RolePerm .valueOf(this.um.getUserRoleInCtx(id, NewsConstants.CTX_C, request.getRemoteUser())).getMask()); return mav; }