Source:
protected Response putAccount(final MultivaluedMap<String, String> data, final MediaType responseType) { final Subject subject = SecurityUtils.getSubject(); final Sid sid = new Sid((String) subject.getPrincipal()); Account account = null; try { account = createFrom(sid, data); } catch (final NullPointerException exception) { return status(BAD_REQUEST).entity(exception.getMessage()).build(); } if (dao.getAccount(account.getSid()) == null) { final Account parent = dao.getAccount(sid); if (parent.getStatus().equals(Account.Status.ACTIVE) && (subject.hasRole("Administrator") || (subject.isPermitted("RestComm:Create:Accounts")))) { if (!subject.hasRole("Administrator") || !data.containsKey("Role")) { account = account.setRole(parent.getRole()); } dao.addAccount(account); MultivaluedMap<String, String> clientData = new MultivaluedMapImpl(); clientData.add("Login", data.getFirst("EmailAddress")); clientData.add("Password", data.getFirst("Password")); clientData.add("FriendlyName", account.getFriendlyName()); clientData.add("AccountSid", account.getSid().toString()); Client client = clientDao.getClient(clientData.getFirst("Login")); if (client == null) { client = createClientFrom(account.getSid(), clientData); clientDao.addClient(client); } else if (!client.getAccountSid().toString().equals(account.getSid().toString())) { return status(CONFLICT) .entity("A client with the same name was already created by another account. Please, choose a different name and try again.") .build(); } } else { return status(UNAUTHORIZED).build(); } } else { return status(CONFLICT).entity("The sid generated to the new account is already in use.").build(); } if (APPLICATION_JSON_TYPE == responseType) { return ok(gson.toJson(account), APPLICATION_JSON).build(); } else if (APPLICATION_XML_TYPE == responseType) { final RestCommResponse response = new RestCommResponse(account); return ok(xstream.toXML(response), APPLICATION_XML).build(); } else { return null; } }

Target:
protected Response putAccount(final MultivaluedMap<String, String> data, final MediaType responseType) { final Subject subject = SecurityUtils.getSubject(); final Sid sid = new Sid((String) subject.getPrincipal()); Account account = null; try { account = createFrom(sid, data); } catch (final NullPointerException exception) { return status(BAD_REQUEST).entity(exception.getMessage()).build(); } if (dao.getAccount(account.getSid()) == null) { final Account parent = dao.getAccount(sid); if (parent.getStatus().equals(Account.Status.ACTIVE) && (subject.hasRole("Administrator") || (subject.isPermitted("RestComm:Create:Accounts")))) { if (!subject.hasRole("Administrator") || !data.containsKey("Role")) { account = account.setRole(parent.getRole()); } dao.addAccount(account); MultivaluedMap<String, String> clientData = new MultivaluedMapImpl(); String username = data.getFirst("EmailAddress").split("@")[0]; clientData.add("Login", username); clientData.add("Password", data.getFirst("Password")); clientData.add("FriendlyName", account.getFriendlyName()); clientData.add("AccountSid", account.getSid().toString()); Client client = clientDao.getClient(clientData.getFirst("Login")); if (client == null) { client = createClientFrom(account.getSid(), clientData); clientDao.addClient(client); } } else { return status(UNAUTHORIZED).build(); } } else { return status(CONFLICT).entity("The sid generated to the new account is already in use.").build(); } if (APPLICATION_JSON_TYPE == responseType) { return ok(gson.toJson(account), APPLICATION_JSON).build(); } else if (APPLICATION_XML_TYPE == responseType) { final RestCommResponse response = new RestCommResponse(account); return ok(xstream.toXML(response), APPLICATION_XML).build(); } else { return null; } }