Package org.opends.server.util
Class SchemaUtils
java.lang.Object
org.opends.server.util.SchemaUtils
Utility methods related to schema.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic enum
Represents a password type, including a "not a password" value. -
Method Summary
Modifier and TypeMethodDescriptionstatic String
addSchemaFileToElementDefinitionIfAbsent
(String definition, String schemaFile) Adds the provided schema file to the provided schema element definition.static boolean
canBeRelaxed
(boolean relaxRules, AttributeType at) Indicates if the provided attribute No-User-Modification constraint can be relaxed.static SchemaUtils.PasswordType
checkPasswordType
(AttributeType attrType) Checks if the provided attribute type contains a password.static String
Retrieves the definition string used to create the provided schema element and including the X-SCHEMA-FILE extension.static String
getElementSchemaFile
(SchemaElement element) Returns the schema file of the provided schema element.getSchemaFiles
(Path schemaDirectory) Returns the list of schema files contained in the provided schema directory.static boolean
is02ConfigLdif
(String schemaFile) Indicates if the provided schema file corresponds to the configuration schema.static String
parseAttributeTypeOID
(String definition) Returns the OID from the provided attribute type definition, assuming the definition is valid.static String
parseDITContentRuleOID
(String definition) Returns the OID from the provided DIT content rule definition, assuming the definition is valid.static String
parseMatchingRuleUseOID
(String definition) Returns the OID from the provided matching rule use definition, assuming the definition is valid.static String
parseNameFormOID
(String definition) Returns the OID from the provided name form definition, assuming the definition is valid.static String
parseObjectClassOID
(String definition) Returns the OID from the provided object class definition, assuming the definition is valid.static int
parseRuleID
(String definition) Returns the ruleID from the provided DIT structure rule definition, assuming the definition is valid.static String
parseSchemaFileFromElementDefinition
(String definition) Parses the schema file (value of X-SCHEMA-FILE extension) from the provided schema element definition.static String
parseSyntaxOID
(String definition) Returns the OID from the provided syntax definition, assuming the definition is valid.
-
Method Details
-
checkPasswordType
Checks if the provided attribute type contains a password.- Parameters:
attrType
- The attribute type to check.- Returns:
- a PasswordTypeCheck result
-
getElementDefinitionWithFileName
Retrieves the definition string used to create the provided schema element and including the X-SCHEMA-FILE extension.- Parameters:
element
- The schema element.- Returns:
- The definition string used to create the schema element including the X-SCHEMA-FILE extension.
-
getElementSchemaFile
Returns the schema file of the provided schema element.- Parameters:
element
- The schema element.- Returns:
- the schema file of schema element.
-
getSchemaFiles
Returns the list of schema files contained in the provided schema directory.- Parameters:
schemaDirectory
- The directory containing schema files- Returns:
- the schema files
- Throws:
IOException
- If the files can't be retrieved
-
addSchemaFileToElementDefinitionIfAbsent
Adds the provided schema file to the provided schema element definition.- Parameters:
definition
- The schema element definitionschemaFile
- The name of the schema file to include in the definition- Returns:
- The definition string of the element including the X-SCHEMA-FILE extension.
-
parseSchemaFileFromElementDefinition
Parses the schema file (value of X-SCHEMA-FILE extension) from the provided schema element definition.It expects a single value for the X-SCHEMA-FILE extension, e.g.: "X-SCHEMA-FILE '99-user.ldif'", as there is no sensible meaning for multiple values.
- Parameters:
definition
- The definition of a schema element- Returns:
- the value of the schema file or
null
if the X-SCHEMA-FILE extension is not present in the definition - Throws:
LdapException
- If an error occurs while parsing the schema element definition
-
parseAttributeTypeOID
Returns the OID from the provided attribute type definition, assuming the definition is valid.This method does not perform any check.
- Parameters:
definition
- The definition of an attribute type, assumed to be valid- Returns:
- the OID, which is never
null
- Throws:
LdapException
- If a problem occurs while parsing the definition
-
parseObjectClassOID
Returns the OID from the provided object class definition, assuming the definition is valid.This method does not perform any check.
- Parameters:
definition
- The definition of a object class, assumed to be valid- Returns:
- the OID, which is never
null
- Throws:
LdapException
- If a problem occurs while parsing the definition
-
parseNameFormOID
Returns the OID from the provided name form definition, assuming the definition is valid.This method does not perform any check.
- Parameters:
definition
- The definition of a name form, assumed to be valid- Returns:
- the OID, which is never
null
- Throws:
LdapException
- If a problem occurs while parsing the definition
-
parseDITContentRuleOID
Returns the OID from the provided DIT content rule definition, assuming the definition is valid.This method does not perform any check.
- Parameters:
definition
- The definition of a DIT content rule, assumed to be valid- Returns:
- the OID, which is never
null
- Throws:
LdapException
- If a problem occurs while parsing the definition
-
parseRuleID
Returns the ruleID from the provided DIT structure rule definition, assuming the definition is valid.This method does not perform any check.
- Parameters:
definition
- The definition of a DIT structure rule, assumed to be valid- Returns:
- the OID, which is never
null
- Throws:
LdapException
- If a problem occurs while parsing the definition
-
parseMatchingRuleUseOID
Returns the OID from the provided matching rule use definition, assuming the definition is valid.This method does not perform any check.
- Parameters:
definition
- The definition of a matching rule use, assumed to be valid- Returns:
- the OID, which is never
null
- Throws:
LdapException
- If a problem occurs while parsing the definition
-
parseSyntaxOID
Returns the OID from the provided syntax definition, assuming the definition is valid.This method does not perform any check.
- Parameters:
definition
- The definition of a syntax, assumed to be valid- Returns:
- the OID, which is never
null
- Throws:
LdapException
- If a problem occurs while parsing the definition
-
is02ConfigLdif
Indicates if the provided schema file corresponds to the configuration schema.The file containing the definitions of the schema elements used for configuration must not be imported nor propagated to other servers because these definitions may vary between versions of OpenDJ.
- Parameters:
schemaFile
- The name of a file defining schema elements- Returns:
true
if the file defines configuration elements,false
otherwise
-
canBeRelaxed
Indicates if the provided attribute No-User-Modification constraint can be relaxed.- Parameters:
relaxRules
- Indicates if the Relax Rules Control was usedat
- The attribute type to check- Returns:
true
if the "No-User-Modification" constraint can be relaxed for this attribute,false
otherwise
-