Package org.incenp.obofoundry.dicer
Class IDPolicyHelper
java.lang.Object
org.incenp.obofoundry.dicer.IDPolicyHelper
A class of helper methods to work with ID policies.
-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
IDPolicyHelper
public IDPolicyHelper()
-
-
Method Details
-
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 benull
, in which case the method will look for a range allocated to any of the user names specified indefaults
instead.defaults
- A list of default user names to use ifuser
isnull
.filename
- The name of the file containing the ID policy; may benull
, 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 notnull
, of the range allocated to any one of thedefaults
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.
-