@Test public void testInsert() { RESTInputGroup group = new RESTInputGroup(); group.setName("g1"); Response res = restUserGroupService.insert(group); long gid1 = (Long)res.getEntity(); RESTInputUser user = new RESTInputUser(); user.setName("user0"); user.setEnabled(Boolean.TRUE); user.setGroups(new ArrayList<IdName>()); user.getGroups().add(new IdName("g1")); Response userResp = restUserService.insert(user); Long id = (Long)userResp.getEntity(); { RESTOutputUser out = restUserService.get("user0"); assertNotNull(out); assertEquals("user0", out.getName()); } }
@Override public Response insert(RESTInputGroup userGroup) throws NotFoundRestEx, InternalErrorRestEx, ConflictRestEx { boolean exists; try { userGroupAdminService.get(userGroup.getName()); exists = true; } catch (NotFoundServiceEx ex) { exists = false; } catch (Exception ex) { LOGGER.error(ex.getMessage(), ex); throw new InternalErrorRestEx(ex.getMessage()); } if(exists) throw new ConflictRestEx("Role '"+userGroup.getName()+"' already exists"); try { ShortGroup insert = new ShortGroup(); insert.setEnabled(userGroup.isEnabled()); insert.setExtId(userGroup.getExtId()); insert.setName(userGroup.getName()); Long id = userGroupAdminService.insert(insert); return Response.status(Status.CREATED).tag(id.toString()).entity(id).build(); } catch (Exception ex) { LOGGER.error(ex.getMessage(), ex); throw new InternalErrorRestEx(ex.getMessage()); } }
RESTUserGroupServiceImpl extends BaseRESTServiceImpl implements RESTUserGroupService { @Override public Response insert(RESTInputGroup userGroup) throws NotFoundRestEx, InternalErrorRestEx, ConflictRestEx { boolean exists; try { userGroupAdminService.get(userGroup.getName()); exists = true; } catch (NotFoundServiceEx ex) { exists = false; } catch (Exception ex) { LOGGER.error(ex.getMessage(), ex); throw new InternalErrorRestEx(ex.getMessage()); } if(exists) throw new ConflictRestEx("Role '"+userGroup.getName()+"' already exists"); try { ShortGroup insert = new ShortGroup(); insert.setEnabled(userGroup.isEnabled()); insert.setExtId(userGroup.getExtId()); insert.setName(userGroup.getName()); Long id = userGroupAdminService.insert(insert); return Response.status(Status.CREATED).tag(id.toString()).entity(id).build(); } catch (Exception ex) { LOGGER.error(ex.getMessage(), ex); throw new InternalErrorRestEx(ex.getMessage()); } } }
RESTUserGroupServiceImpl extends BaseRESTServiceImpl implements RESTUserGroupService { @Override public Response insert(RESTInputGroup userGroup) throws NotFoundRestEx, InternalErrorRestEx, ConflictRestEx { boolean exists; try { userGroupAdminService.get(userGroup.getName()); exists = true; } catch (NotFoundServiceEx ex) { exists = false; } catch (Exception ex) { LOGGER.error(ex.getMessage(), ex); throw new InternalErrorRestEx(ex.getMessage()); } if(exists) throw new ConflictRestEx("Role '"+userGroup.getName()+"' already exists"); try { ShortGroup insert = new ShortGroup(); insert.setEnabled(userGroup.isEnabled()); insert.setExtId(userGroup.getExtId()); insert.setName(userGroup.getName()); Long id = userGroupAdminService.insert(insert); return Response.status(Status.CREATED).tag(id.toString()).entity(id).build(); } catch (Exception ex) { LOGGER.error(ex.getMessage(), ex); throw new InternalErrorRestEx(ex.getMessage()); } }  }
RESTUserGroupServiceImpl extends BaseRESTServiceImpl implements RESTUserGroupService { @Override public Response insert(RESTInputGroup userGroup) throws NotFoundRestEx, InternalErrorRestEx, ConflictRestEx { boolean exists; try { userGroupAdminService.get(userGroup.getName()); exists = true; } catch (NotFoundServiceEx ex) { exists = false; } catch (Exception ex) { LOGGER.error(ex.getMessage(), ex); throw new InternalErrorRestEx(ex.getMessage()); } if(exists) throw new ConflictRestEx("Role '"+userGroup.getName()+"' already exists"); try { ShortGroup insert = new ShortGroup(); insert.setEnabled(userGroup.isEnabled()); insert.setExtId(userGroup.getExtId()); insert.setName(userGroup.getName()); Long id = userGroupAdminService.insert(insert); return Response.status(Status.CREATED).tag(id.toString()).entity(id).build(); } catch (Exception ex) { LOGGER.error(ex.getMessage(), ex); throw new InternalErrorRestEx(ex.getMessage()); } }  @Override RESTFullUserGroupList getList(String nameLike, Integer page, Integer entries); @Override long count(String nameLike); @Override ShortGroup get(String name); @Override Response insert(RESTInputGroup userGroup); @Override void update(String name, RESTInputGroup group); @Override Response delete(String name, boolean cascade); }
RESTUserGroupServiceImpl extends BaseRESTServiceImpl implements RESTUserGroupService { @Override public Response insert(RESTInputGroup userGroup) throws NotFoundRestEx, InternalErrorRestEx, ConflictRestEx { boolean exists; try { userGroupAdminService.get(userGroup.getName()); exists = true; } catch (NotFoundServiceEx ex) { exists = false; } catch (Exception ex) { LOGGER.error(ex.getMessage(), ex); throw new InternalErrorRestEx(ex.getMessage()); } if(exists) throw new ConflictRestEx("Role '"+userGroup.getName()+"' already exists"); try { ShortGroup insert = new ShortGroup(); insert.setEnabled(userGroup.isEnabled()); insert.setExtId(userGroup.getExtId()); insert.setName(userGroup.getName()); Long id = userGroupAdminService.insert(insert); return Response.status(Status.CREATED).tag(id.toString()).entity(id).build(); } catch (Exception ex) { LOGGER.error(ex.getMessage(), ex); throw new InternalErrorRestEx(ex.getMessage()); } }  @Override RESTFullUserGroupList getList(String nameLike, Integer page, Integer entries); @Override long count(String nameLike); @Override ShortGroup get(String name); @Override Response insert(RESTInputGroup userGroup); @Override void update(String name, RESTInputGroup group); @Override Response delete(String name, boolean cascade);  }