private void updateDefaultOrganizationId(User user, String portalOrganizationId)
      throws Exception {
    BasicHttpContext ctx = new BasicHttpContext();
    ctx.setAttribute(ClientContext.AUTH_CACHE, authCache);

    HttpPost post = new HttpPost("/user/update-organizations");
    List<NameValuePair> params = new ArrayList<NameValuePair>();

    JSONSerializer serializer = new JSONSerializer();
    String orgIds = serializer.serialize(new String[] {portalOrganizationId});

    params.add(new BasicNameValuePair("userId", Long.toString(user.getUserId())));
    params.add(new BasicNameValuePair("organizationIds", orgIds));
    params.add(new BasicNameValuePair("serviceContext", null));

    UrlEncodedFormEntity entity = new UrlEncodedFormEntity(params, "UTF-8");
    post.setEntity(entity);

    HttpResponse resp = httpclient.execute(targetHost, post, ctx);
    System.out.println("updateDefaultOrganizationId Status:[" + resp.getStatusLine() + "]");

    String response = null;
    if (resp.getEntity() != null) {
      response = EntityUtils.toString(resp.getEntity());
    }
    System.out.println("getOrganizationByName Resp:[" + response + "]");

    EntityUtils.consume(resp.getEntity());
  }
 @Override
 public boolean userHasRoleByEmailAddress(String emailAddress, String roleName) throws Exception {
   User user = provideUserByEmailAddress(emailAddress, null, null);
   Boolean hasRole = userHasRole(Long.toString(user.getUserId()), roleName);
   return hasRole;
 }