Class EntityUtil

java.lang.Object
ch.tocco.nice2.persist.security.api.EntityUtil

public class EntityUtil extends Object
Static methods for common entity operations to avoid copy/paste coding.
  • Method Details

    • principalExists

      public static boolean principalExists(Context context, String userName, boolean caseless) throws PersistException
      Parameters:
      caseless - If true then an existing user in any spelling (upper/lower case) will return true. This may be desired to not accidently create multiple users with the same username in different case.
      Throws:
      PersistException
    • getCorrespondenceLanguages

      public static Map<String,String> getCorrespondenceLanguages(Context context) throws PersistException
      Returns a map containing all correspondence languages.
      Returns:
      a map containing all correspondence languages.
      Throws:
      PersistException - if an error occurs.
    • hasRoles

      public static boolean hasRoles(Principal principal, Iterable<String> roles, boolean matchAll)
      Checks if the principal has all (matchAll: true) or just one of the given roles (matchAll: false)
      Parameters:
      roles - pass a Set if you do not get data from another point (i.e. you are creating it).
    • hasRole

      public static boolean hasRole(Principal principal, String role)
    • map

      public static <V> List<V> map(EntityList entities, Function<Entity,V> fun) throws PersistException
      Throws:
      PersistException