Examples of QuotaRLBucket


Examples of com.alu.e3.data.model.sub.QuotaRLBucket

  public void addAuthsToBucket(String policyId, String bucketId, QuotaRLBucket bucket) throws IllegalArgumentException {

    Policy policy = getPolicyById(policyId);

    // Find the correct bucket in this policy
    QuotaRLBucket pAuthIds = getBucketWithIdForPolicy(policy, bucketId);
    if(pAuthIds == null) {
      throw new IllegalArgumentException("A Bucket with that ID [" + bucketId + "] doesn't exist for this Policy [" + policyId + "]");
    }

    checkIfAuthAlreadyInPolicy(policyId, bucket.getAuthIds(), bucketId);

    for(String authId : bucket.getAuthIds()) {

      String authToken = cachingTableAuthIdToAuthToken.get(authId);
      if (authToken == null)
        throw new IllegalArgumentException("Auth ID [" + authId + "] not found");

      Auth auth = cachingTableAuth.get(authToken);
      if (auth == null)
        throw new IllegalArgumentException("Auth token not found");

      // Add auth to the bucket
      if (pAuthIds.getAuthIds().indexOf(auth.getId()) < 0)
      {
        pAuthIds.getAuthIds().add(auth.getId());
        cachingTablePolicy.set(policy.getId(), policy);
      }

      // Add policy to auth
      boolean found = false;
      for (AuthIds authCtx : auth.getPolicyContexts()) {
        if (authCtx.getPolicyId().equals(policy.getId())) {
          //update Auth with good Policy context and bucket
          authCtx.setPolicyContextId(getPolicyContextId(auth, policy));
          authCtx.setPolicyBucketId(bucket.getBucketId());
          cachingTableAuth.set(authToken, auth);//updating auth
          found = true;
          break;
        }
      }

      if (!found) {
        auth.getPolicyContexts().add(new AuthIds(policyId, bucketId, getPolicyContextId(auth, policy), pAuthIds.getBucketId(), auth.getStatus().isActive()));
        cachingTableAuth.set(authToken, auth);
      }
    }
  }
View Full Code Here

Examples of com.alu.e3.data.model.sub.QuotaRLBucket

    Auth auth = cachingTableAuth.get(authToken);
    if (auth == null)
      throw new InvalidIDException("An Authorization with that token doesn't exist");

    QuotaRLBucket pAuthIds = getBucketWithIdForPolicy(policy, bucketId);
    if(pAuthIds == null) {
      throw new InvalidIDException("A Bucket with that ID [" + bucketId + "] doesn't exist for this Policy [" + policyId + "]");
    }

    // Remove auth from the bucket
    pAuthIds.getAuthIds().remove(auth.getId());
    cachingTablePolicy.set(policy.getId(), policy);

    // Remove policy from auth
    for (AuthIds authCtx : auth.getPolicyContexts()) {
      if (authCtx.getPolicyId().equals(policy.getId())) {
View Full Code Here

Examples of com.alu.e3.data.model.sub.QuotaRLBucket

  @Override
  public void removeBucket(String policyId, String bucketId) throws IllegalArgumentException {

    Policy policy = getPolicyById(policyId);

    QuotaRLBucket pAuthIds = getBucketWithIdForPolicy(policy, bucketId);
    if(pAuthIds == null) {
      throw new InvalidIDException("A Bucket with that ID [" + bucketId + "] doesn't exist for this Policy [" + policyId + "]");
    }

    // Iterating over Auth Ids in the bucket to remove policy from the auth
    for(String authId : pAuthIds.getAuthIds()) {

      String authToken = cachingTableAuthIdToAuthToken.get(authId);
      if (authToken == null)
        continue;
View Full Code Here

Examples of com.alu.e3.data.model.sub.QuotaRLBucket

   * @param policy Policy to iterate on
   * @param bucketId Id of the bucket to get
   * @return The corresponding bucket (AuthIds object)
   */
  private QuotaRLBucket getBucketWithIdForPolicy(Policy policy, String bucketId) {
    QuotaRLBucket pAuthIds = null;
    for(QuotaRLBucket cAuthIds : policy.getAuthIds()) {
      if(cAuthIds.getId().equalsIgnoreCase(bucketId)) {
        pAuthIds = cAuthIds;
        break;
      }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.