/** * Get the reason phrase * @return the reason phrase */ public String getReasonPhrase() { return toString(); }
/** * Convert a numerical status code into the corresponding Status * @param statusCode the numerical status code * @return the matching Status or null is no matching Status is defined */ public static Status fromStatusCode(final int statusCode) { for (Status s : Status.values()) { if (s.code == statusCode) { return s; } } return null; } }
@ExceptionHandler(NotFoundServiceEx.class) public void ruleNotFound( NotFoundServiceEx exception, HttpServletRequest request, HttpServletResponse response) throws IOException { response.sendError(404, exception.getMessage()); }
@Override public AdminRule get(long id) throws NotFoundServiceEx { AdminRule rule = ruleDAO.find(id); if (rule == null) { throw new NotFoundServiceEx("AdminRule not found", id); } return rule; }
protected Search buildCriteria(Integer page, Integer entries, String nameLike) throws BadRequestServiceEx { if ( (page != null && entries == null) || (page == null && entries != null) ) { throw new BadRequestServiceEx("Page and entries params should be declared together."); } Search searchCriteria = new Search(UserGroup.class); if ( page != null ) { searchCriteria.setMaxResults(entries); searchCriteria.setPage(page); } searchCriteria.addSortAsc("name"); if ( nameLike != null ) { searchCriteria.addFilterILike("name", nameLike); } return searchCriteria; }
@ExceptionHandler(NotFoundServiceEx.class) public void ruleNotFound( NotFoundServiceEx exception, HttpServletRequest request, HttpServletResponse response) throws IOException { response.sendError(404, exception.getMessage()); }
@Override public GSInstance get(long id) throws NotFoundServiceEx { GSInstance instance = instanceDAO.find(id); if (instance == null) { throw new NotFoundServiceEx("GSInstance not found", id); } return instance; }
/** * Get the reason phrase * @return the reason phrase */ public String getReasonPhrase() { return toString(); }
/** * Convert a numerical status code into the corresponding Status * @param statusCode the numerical status code * @return the matching Status or null is no matching Status is defined */ public static Status fromStatusCode(final int statusCode) { for (Status s : Status.values()) { if (s.code == statusCode) { return s; } } return null; } }
@Override public GSUser get(long id) throws NotFoundServiceEx { GSUser user = userDAO.find(id); if (user == null) { throw new NotFoundServiceEx("User not found", id); } return user; }
@Override public GFUser get(long id) throws NotFoundServiceEx { GFUser user = gfUserDAO.find(id); if (user == null) { throw new NotFoundServiceEx("User not found", id); } return user; }
@Override public Rule get(long id) throws NotFoundServiceEx { Rule rule = ruleDAO.find(id); if (rule == null) { throw new NotFoundServiceEx("Rule not found", id); } return rule; }
@Override public UserGroup get(long id) throws NotFoundServiceEx { UserGroup group = userGroupDAO.find(id); if ( group == null ) { throw new NotFoundServiceEx("UserGroup not found", id); } return group; }
@Override public GSUser getFull(String name) throws NotFoundServiceEx { GSUser user = userDAO.getFull(name); if(user == null) throw new NotFoundServiceEx("User not found", name); return user; }
@Override public boolean delete(long id) throws NotFoundServiceEx { Rule rule = ruleDAO.find(id); if (rule == null) { throw new NotFoundServiceEx("Rule not found", id); } // data on ancillary tables should be deleted by cascading return ruleDAO.remove(rule); }
@Override public boolean delete(long id) throws NotFoundServiceEx { GSInstance instance = instanceDAO.find(id); if (instance == null) { throw new NotFoundServiceEx("GSInstance not found", id); } // data on ancillary tables should be deleted by cascading return instanceDAO.remove(instance); }
@Override public boolean delete(long id) throws NotFoundServiceEx { UserGroup group = userGroupDAO.find(id); if ( group == null ) { throw new NotFoundServiceEx("Group not found", id); } // data on ancillary tables should be deleted by cascading return userGroupDAO.remove(group); }
@Override public boolean delete(long id) throws NotFoundServiceEx { AdminRule rule = ruleDAO.find(id); if (rule == null) { throw new NotFoundServiceEx("AdminRule not found", id); } return ruleDAO.remove(rule); }
@Override public long update(AdminRule rule) throws NotFoundServiceEx { AdminRule orig = ruleDAO.find(rule.getId()); if (orig == null) { throw new NotFoundServiceEx("AdminRule not found", rule.getId()); } ruleDAO.merge(rule); return orig.getId(); }
@Override public long update(GFUser user) throws NotFoundServiceEx { GFUser orig = gfUserDAO.find(user.getId()); if (orig == null) { throw new NotFoundServiceEx("User not found", user.getId()); } gfUserDAO.merge(user); return orig.getId(); }