Source:
<code>public Response create(@Context SecurityContext securityContext, @Required NewAccount newAccount) throws NotFoundException, ConflictException, ServerException { requiredNotNull(newAccount, "New account"); requiredNotNull(newAccount.getName(), "Account name"); if (newAccount.getAttributes() != null) { for (String attributeName : newAccount.getAttributes().keySet()) { validateAttributeName(attributeName); } } User current = null; if (securityContext.isUserInRole("user")) { current = userDao.getByAlias(securityContext.getUserPrincipal().getName()); if (accountDao.getByOwner(current.getId()).size() != 0) { throw new ConflictException(format("Account which owner is %s already exists", current.getId())); } } try { accountDao.getByName(newAccount.getName()); throw new ConflictException(format("Account with name %s already exists", newAccount.getName())); } catch (NotFoundException ignored) { } final String accountId = NameGenerator.generate(Account.class.getSimpleName().toLowerCase(), Constants.ID_LENGTH); <START> final Account account = new Account(accountId, newAccount.getName()); <END> accountDao.create(account); if (current != null) { final Member owner = new Member().withAccountId(accountId) .withUserId(current.getId()) .withRoles(Arrays.asList("account/owner")); accountDao.addMember(owner); LOG.info("EVENT#account-add-member# ACCOUNT-ID#{}# USER-ID#{}# ROLES#{}#", accountId, current.getId(), Arrays.asList("account/owner").toString()); } return Response.status(Response.Status.CREATED) .entity(toDescriptor(account)) .build(); }</code><technical_language>omit setting account attributes</technical_language>

Target:
public Response create(@Context SecurityContext securityContext, @Required NewAccount newAccount) throws NotFoundException, ConflictException, ServerException { requiredNotNull(newAccount, "New account"); requiredNotNull(newAccount.getName(), "Account name"); if (newAccount.getAttributes() != null) { for (String attributeName : newAccount.getAttributes().keySet()) { validateAttributeName(attributeName); } } User current = null; if (securityContext.isUserInRole("user")) { current = userDao.getByAlias(securityContext.getUserPrincipal().getName()); if (accountDao.getByOwner(current.getId()).size() != 0) { throw new ConflictException(format("Account which owner is %s already exists", current.getId())); } } try { accountDao.getByName(newAccount.getName()); throw new ConflictException(format("Account with name %s already exists", newAccount.getName())); } catch (NotFoundException ignored) { } final String accountId = NameGenerator.generate(Account.class.getSimpleName().toLowerCase(), Constants.ID_LENGTH); final Account account = new Account(accountId, newAccount.getName(), null, newAccount.getAttributes()); accountDao.create(account); if (current != null) { final Member owner = new Member().withAccountId(accountId) .withUserId(current.getId()) .withRoles(Arrays.asList("account/owner")); accountDao.addMember(owner); LOG.info("EVENT#account-add-member# ACCOUNT-ID#{}# USER-ID#{}# ROLES#{}#", accountId, current.getId(), Arrays.asList("account/owner").toString()); } return Response.status(Response.Status.CREATED) .entity(toDescriptor(account)) .build(); }