private Permission findPermissionByCode(
      Collection<Permission> allPermissions, String permissionCode) {

    if (allPermissions != null) {
      for (Permission permission : allPermissions) {
        if (permission.hasCode(permissionCode)) {
          return permission;
        }
      }
    }

    throw new PermissionNotFoundException(permissionCode);
  }
コード例 #2
0
  @Override
  public boolean isMakerCheckerEnabledForTask(final String taskPermissionCode) {
    if (StringUtils.isBlank(taskPermissionCode)) {
      throw new PermissionNotFoundException(taskPermissionCode);
    }

    final Permission thisTask = this.permissionRepository.findOneByCode(taskPermissionCode);
    if (thisTask == null) {
      throw new PermissionNotFoundException(taskPermissionCode);
    }

    final String makerCheckerConfigurationProperty = "maker-checker";
    final GlobalConfigurationProperty property =
        this.globalConfigurationRepository.findOneByNameWithNotFoundDetection(
            makerCheckerConfigurationProperty);

    return thisTask.hasMakerCheckerEnabled() && property.isEnabled();
  }