Example #1
0
 public void checkUserBucketsCount(User user) {
   if (user.getBucketNames().size() > maxBucketsPerUser) {
     throw new IllegalStateException(
         String.format(
             "Unable to create bucket as user %s currently has %s buckets when the maximum is %s.",
             user.getUsername(), user.getBucketNames().size(), maxBucketsPerUser));
   }
 }
Example #2
0
  public boolean userOwnsBucket(final String bucketName, final User user) {
    LOG.debug(String.format("userOwnsBucket(%s, %s)", bucketName, user.getUsername()));

    StringBuilder sb =
        new StringBuilder("Trying to find user bucket ")
            .append(bucketName)
            .append(" for user ")
            .append(user.getUsername())
            .append(". Found: [");
    for (String userBucket : user.getBucketNames()) {
      sb.append(userBucket).append(", ");
      if (userBucket.equalsIgnoreCase(bucketName)) return true;
    }
    LOG.debug(sb.append("]").toString());

    return false;
  }