Package org.eurekaj.api.datatypes

Examples of org.eurekaj.api.datatypes.Account


       
        if ((isPost(e) || isPut(e)) && isAdmin(loggedInUser)) {
          AccessTokenModel accessTokenModel = new Gson().fromJson(getHttpMessageContent(e), AccessTokenModel.class);
          BasicAccessToken newAccessToken = accessTokenModel.getAccessToken();
         
          Account account = getAccountService().getAccount(loggedInUser.getAccountName());
         
          if (account != null && newAccessToken != null && newAccessToken.getId() != null && newAccessToken.getId().length() >= 16) {
            newAccessToken.setAccountName(account.getId());
            logger.info("Persisting AccessToken: " + new Gson().toJson(newAccessToken));
            getAccountService().persistAccessToken(newAccessToken);
            if (account.getAccessTokens() == null) {
              BasicAccount newAccount = new BasicAccount(account);
              newAccount.setAccessTokens(new ArrayList<String>());
              account = newAccount;
            }
            account.getAccessTokens().add(newAccessToken.getId());
            getAccountService().persistAccount(account);
          }
         
          jsonResponse = new Gson().toJson(accessTokenModel);
        } else if (isGet(e) && isAdmin(loggedInUser)) {
          logger.info("Account Name: " + loggedInUser.getAccountName());
          Account account = getAccountService().getAccount(loggedInUser.getAccountName());
          logger.info("Account: " + account);
          List<String> accessTokens = account.getAccessTokens();
          if (accessTokens == null) {
            accessTokens = new ArrayList<>();
          }
         
          JsonArray accessTokenArray = new JsonArray();
          for (String accessToken : accessTokens) {
            AccessToken accessTokenObject = getAccountService().getAccessToken(accessToken);
            if (accessTokenObject != null && accessTokenObject.getAccountName().equals(account.getId())) {
              accessTokenArray.add(new Gson().toJsonTree(accessTokenObject));
            }
          }
         
          JsonObject accessTokensJson = new JsonObject();
View Full Code Here


            getAccountService().persistAccount(account);
        } else if (isPost(e) && session != null) { //Register new account
          //TODO: Verify that account name is unique!!
          JSONObject jsonObject = BuildJsonObjectsUtil.extractJsonContents(getHttpMessageContent(e));

            Account account = ParseJsonObjects.parseAccount(jsonObject);
            logger.info("Account Name: " + account.getId());
            BasicAccount basicAccount = new BasicAccount(account);
            basicAccount.setAccountType("new");

            getAccountService().persistAccount(account);
        } else if(isGet(e) && id != null && session != null) { //Get account for current user
          logger.info("Getting account for: " + session.getAccountName());
          Account account = getAccountService().getAccount(session.getAccountName());
          JsonObject accountObject = new JsonObject();
          accountObject.add("account", new Gson().toJsonTree(account));
         
          jsonResponse = accountObject.toString();
        } else if (isGet(e) && isRoot(session)) {
View Full Code Here

        return accountList;
  }

  @Override
  public Account getAccount(String id) {
    Account account = null;
   
    Bucket myBucket = null;
        try {
            myBucket = riakClient.fetchBucket("Account").execute();
          account = myBucket.fetch(this.encodeUri(id), BasicAccount.class).execute();
View Full Code Here

TOP

Related Classes of org.eurekaj.api.datatypes.Account

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.