List of usage examples for org.apache.commons.beanutils.converters IntegerConverter convert
public Object convert(Class type, Object value)
From source file:com.sunchenbin.store.feilong.core.bean.ConvertUtil.java
/** * object?integer.// w ww .java 2s.c o m * * <p> * converted is missing or an error occurs converting the value,<span style="color:red">return null</span> * </p> * * @param toBeConvertedValue * * @return the integer * @see org.apache.commons.beanutils.converters.IntegerConverter */ public static Integer toInteger(Object toBeConvertedValue) { IntegerConverter integerConverter = new IntegerConverter(null); return integerConverter.convert(Integer.class, toBeConvertedValue); }
From source file:jp.co.acroquest.endosnipe.report.converter.util.calc.IntegerCalculator.java
public Object immediate(String str) { IntegerConverter converter = new IntegerConverter(); return converter.convert(Integer.class, str); }
From source file:org.itracker.web.actions.project.AssignIssueAction.java
public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { ActionMessages errors = new ActionMessages(); try {/*from www .j ava2 s. c om*/ IssueService issueService = ServletContextUtils.getItrackerServices().getIssueService(); ProjectService projectService = ServletContextUtils.getItrackerServices().getProjectService(); Integer defaultValue = -1; IntegerConverter converter = new IntegerConverter(defaultValue); Integer issueId = (Integer) converter.convert(Integer.class, (String) PropertyUtils.getSimpleProperty(form, "issueId")); Integer projectId = (Integer) converter.convert(Integer.class, (String) PropertyUtils.getSimpleProperty(form, "projectId")); Integer userId = (Integer) converter.convert(Integer.class, (String) PropertyUtils.getSimpleProperty(form, "userId")); HttpSession session = request.getSession(true); User currUser = (User) session.getAttribute(Constants.USER_KEY); Map<Integer, Set<PermissionType>> userPermissions = RequestHelper.getUserPermissions(session); Integer currUserId = currUser.getId(); Project project = projectService.getProject(projectId); if (project == null) { return mapping.findForward("unauthorized"); } if (!userId.equals(currUserId) && !UserUtilities.hasPermission(userPermissions, projectId, UserUtilities.PERMISSION_ASSIGN_OTHERS)) { return mapping.findForward("unauthorized"); } else if (!UserUtilities.hasPermission(userPermissions, projectId, UserUtilities.PERMISSION_ASSIGN_SELF)) { return mapping.findForward("unauthorized"); } if (project.getStatus() != Status.ACTIVE) { errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("itracker.web.error.projectlocked")); } else { issueService.assignIssue(issueId, userId, currUserId); } } catch (RuntimeException e) { log.warn("execute: caught exception", e); errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("itracker.web.error.system")); } catch (IllegalAccessException e) { log.warn("execute: caught exception", e); errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("itracker.web.error.system")); } catch (InvocationTargetException e) { log.warn("execute: caught exception", e); errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("itracker.web.error.system")); } catch (NoSuchMethodException e) { log.warn("execute: caught exception", e); errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("itracker.web.error.system")); } if (!errors.isEmpty()) { saveErrors(request, errors); saveToken(request); } return mapping.findForward("index"); }