Exemplo n.º 1
0
  @Override
  public String getSuffix(String worldName) {
    // @TODO This method should be refactored
    if (!this.cachedSuffix.containsKey(worldName)) {
      String localSuffix = this.getOwnSuffix(worldName);

      if (worldName != null && (localSuffix == null || localSuffix.isEmpty())) {
        // World-inheritance
        for (String parentWorld : this.manager.getWorldInheritance(worldName)) {
          String suffix = this.getOwnSuffix(parentWorld);
          if (suffix != null && !suffix.isEmpty()) {
            localSuffix = suffix;
            break;
          }
        }

        // Common space
        if (localSuffix == null || localSuffix.isEmpty()) {
          localSuffix = this.getOwnSuffix(null);
        }
      }

      if (localSuffix == null || localSuffix.isEmpty()) {
        for (PermissionGroup group : this.getGroups(worldName)) {
          localSuffix = group.getSuffix(worldName);
          if (localSuffix != null && !localSuffix.isEmpty()) {
            break;
          }
        }
      }

      if (localSuffix == null) { // just for NPE safety
        localSuffix = "";
      }
      this.cachedSuffix.put(worldName, localSuffix);
    }

    return this.cachedSuffix.get(worldName);
  }