@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; }
@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; }
@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 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 void setAllowedStyles(Long ruleId, Set<String> styles) { Rule rule = ruleDAO.find(ruleId); if(rule == null) throw new NotFoundServiceEx("Rule not found"); if(rule.getLayerDetails() == null) { throw new NotFoundServiceEx("Rule has no details associated"); } detailsDAO.setAllowedStyles(ruleId, styles); }
@Override public Set<String> getAllowedStyles(Long ruleId) { Rule rule = ruleDAO.find(ruleId); if(rule == null) throw new NotFoundServiceEx("Rule not found"); if(rule.getLayerDetails() == null) { throw new NotFoundServiceEx("Rule has no details associated"); } return detailsDAO.getAllowedStyles(ruleId); }
@Override public GFUser get(String name) { Search search = new Search(GFUser.class); search.addFilterEqual("name", name); List<GFUser> users = gfUserDAO.search(search); if(users.isEmpty()) throw new NotFoundServiceEx("User not found '"+ name + "'"); else if(users.size() > 1) throw new IllegalStateException("Found more than one user with name '"+name+"'"); else return users.get(0); }
@Override public GSInstance get(String name) { Search search = new Search(GSInstance.class); search.addFilterEqual("name", name); List<GSInstance> groups = instanceDAO.search(search); if ( groups.isEmpty() ) { throw new NotFoundServiceEx("GSInstance not found '" + name + "'"); } else if ( groups.size() > 1 ) { throw new IllegalStateException("Found more than one GSInstance with name '" + name + "'"); } else { return groups.get(0); } }
@Override public GSUser get(String name) { Search search = new Search(GSUser.class); search.addFilterEqual("name", name); List<GSUser> users = userDAO.search(search); if(users.isEmpty()) throw new NotFoundServiceEx("User not found '"+ name + "'"); else if(users.size() > 1) throw new IllegalStateException("Found more than one user with name '"+name+"'"); else return users.get(0); }
@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 { AdminRule rule = ruleDAO.find(id); if (rule == null) { throw new NotFoundServiceEx("AdminRule not found", id); } 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 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(); }
@Override public long update(GSInstance instance) throws NotFoundServiceEx { GSInstance orig = instanceDAO.find(instance.getId()); if (orig == null) { throw new NotFoundServiceEx("GSInstance not found", instance.getId()); } instanceDAO.merge(instance); return orig.getId(); }
@Override public long update(GSUser user) throws NotFoundServiceEx { GSUser orig = userDAO.find(user.getId()); if (orig == null) { throw new NotFoundServiceEx("User not found", user.getId()); } userDAO.merge(user); return orig.getId(); }
@Override public long update(Rule rule) throws NotFoundServiceEx { Rule orig = ruleDAO.find(rule.getId()); if (orig == null) { throw new NotFoundServiceEx("Rule not found", rule.getId()); } sanitizeFields(rule); ruleDAO.merge(rule); return orig.getId(); }