Class IDPolicyHelper

java.lang.Object
org.incenp.obofoundry.dicer.IDPolicyHelper

public class IDPolicyHelper extends Object
A class of helper methods to work with ID policies.
  • Constructor Details

    • IDPolicyHelper

      public IDPolicyHelper()
  • Method Details

    • findIDPolicyFile

      public static Optional<String> findIDPolicyFile()
      Finds an ID policy file in the current directory. This methods looks for a single file whose name ends with -idranges.owl in the current directory.
      Returns:
      An Optional of the ID policy file (empty if there is no such file).
    • getRange

      public static IDRange getRange(String user, String[] defaults, String filename) throws InvalidIDPolicyException, IOException, IDRangeNotFoundException
      Gets the ID range allocated to the given user according to the ID policy.
      Parameters:
      user - The user for which to retrieve the range. May be null, in which case the method will look for a range allocated to any of the user names specified in defaults instead.
      defaults - A list of default user names to use if user is null.
      filename - The name of the file containing the ID policy; may be null, in which case the method will search for a file ending with -idranges.owl in the current directory.
      Returns:
      The requested ID range (either the range allocated to user if not null, of the range allocated to any one of the defaults users).
      Throws:
      InvalidIDPolicyException - If the file is not a valid ID policy file.
      IOException - If the policy file cannot be read for any reason (including a missing file).
      IDRangeNotFoundException - If neither the requested range nor any of the default ranges can be found in the policy.