| | |
| | | import java.util.List; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.i18n.LocalizableMessageDescriptor.Arg2; |
| | | import org.forgerock.opendj.ldap.ByteSequence; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.forgerock.opendj.ldap.schema.ObjectClassType; |
| | |
| | | { |
| | | StringBuilder woidBuffer = new StringBuilder(); |
| | | pos = readWOID(lowerStr, woidBuffer, (pos)); |
| | | attrs.add(getAttributeType(schema, allowUnknownElements, oid, woidBuffer, |
| | | ERR_ATTR_SYNTAX_NAME_FORM_UNKNOWN_REQUIRED_ATTR)); |
| | | |
| | | AttributeType attr = schema.getAttributeType(woidBuffer.toString()); |
| | | if (attr == null) |
| | | { |
| | | // This isn't good because it means that the name form requires |
| | | // an attribute type that we don't know anything about. |
| | | if (allowUnknownElements) |
| | | { |
| | | attr = DirectoryServer.getDefaultAttributeType( |
| | | woidBuffer.toString()); |
| | | } |
| | | else |
| | | { |
| | | throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION, |
| | | ERR_ATTR_SYNTAX_NAME_FORM_UNKNOWN_REQUIRED_ATTR.get(oid, woidBuffer)); |
| | | } |
| | | } |
| | | |
| | | attrs.add(attr); |
| | | |
| | | |
| | | // The next character must be either a dollar sign or a closing |
| | | // parenthesis. |
| | | // The next character must be either a dollar sign or a closing parenthesis. |
| | | c = valueStr.charAt(pos++); |
| | | if (c == ')') |
| | | { |
| | |
| | | { |
| | | StringBuilder woidBuffer = new StringBuilder(); |
| | | pos = readWOID(lowerStr, woidBuffer, (pos-1)); |
| | | |
| | | AttributeType attr = schema.getAttributeType(woidBuffer.toString()); |
| | | if (attr == null) |
| | | { |
| | | // This isn't good because it means that the name form requires an |
| | | // attribute type that we don't know anything about. |
| | | if (allowUnknownElements) |
| | | { |
| | | attr = DirectoryServer.getDefaultAttributeType( |
| | | woidBuffer.toString()); |
| | | } |
| | | else |
| | | { |
| | | throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION, |
| | | ERR_ATTR_SYNTAX_NAME_FORM_UNKNOWN_REQUIRED_ATTR.get(oid, woidBuffer)); |
| | | } |
| | | } |
| | | |
| | | attrs.add(attr); |
| | | attrs.add(getAttributeType(schema, allowUnknownElements, oid, woidBuffer, |
| | | ERR_ATTR_SYNTAX_NAME_FORM_UNKNOWN_REQUIRED_ATTR)); |
| | | } |
| | | |
| | | requiredAttributes.addAll(attrs); |
| | |
| | | { |
| | | StringBuilder woidBuffer = new StringBuilder(); |
| | | pos = readWOID(lowerStr, woidBuffer, (pos)); |
| | | attrs.add(getAttributeType(schema, allowUnknownElements, oid, woidBuffer, |
| | | ERR_ATTR_SYNTAX_NAME_FORM_UNKNOWN_OPTIONAL_ATTR)); |
| | | |
| | | AttributeType attr = schema.getAttributeType(woidBuffer.toString()); |
| | | if (attr == null) |
| | | { |
| | | // This isn't good because it means that the name form allows an |
| | | // attribute type that we don't know anything about. |
| | | if (allowUnknownElements) |
| | | { |
| | | attr = DirectoryServer.getDefaultAttributeType( |
| | | woidBuffer.toString()); |
| | | } |
| | | else |
| | | { |
| | | throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION, |
| | | ERR_ATTR_SYNTAX_NAME_FORM_UNKNOWN_OPTIONAL_ATTR.get(oid, woidBuffer)); |
| | | } |
| | | } |
| | | |
| | | attrs.add(attr); |
| | | |
| | | |
| | | // The next character must be either a dollar sign or a closing |
| | | // parenthesis. |
| | | // The next character must be either a dollar sign or a closing parenthesis. |
| | | c = valueStr.charAt(pos++); |
| | | if (c == ')') |
| | | { |
| | |
| | | { |
| | | StringBuilder woidBuffer = new StringBuilder(); |
| | | pos = readWOID(lowerStr, woidBuffer, (pos-1)); |
| | | |
| | | AttributeType attr = schema.getAttributeType(woidBuffer.toString()); |
| | | if (attr == null) |
| | | { |
| | | // This isn't good because it means that the name form allows an |
| | | // attribute type that we don't know anything about. |
| | | if (allowUnknownElements) |
| | | { |
| | | attr = DirectoryServer.getDefaultAttributeType( |
| | | woidBuffer.toString()); |
| | | } |
| | | else |
| | | { |
| | | throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION, |
| | | ERR_ATTR_SYNTAX_NAME_FORM_UNKNOWN_OPTIONAL_ATTR.get(oid, woidBuffer)); |
| | | } |
| | | } |
| | | |
| | | attrs.add(attr); |
| | | attrs.add(getAttributeType(schema, allowUnknownElements, oid, woidBuffer, |
| | | ERR_ATTR_SYNTAX_NAME_FORM_UNKNOWN_OPTIONAL_ATTR)); |
| | | } |
| | | |
| | | optionalAttributes.addAll(attrs); |
| | |
| | | optionalAttributes, extraProperties); |
| | | } |
| | | |
| | | private static AttributeType getAttributeType(Schema schema, boolean allowUnknownElements, String oid, |
| | | StringBuilder woidBuffer, Arg2<Object, Object> msg) throws DirectoryException |
| | | { |
| | | String woidString = woidBuffer.toString(); |
| | | AttributeType attr = schema.getAttributeType(woidString); |
| | | if (attr == null) |
| | | { |
| | | // This isn't good because it means that the name form |
| | | // refers to an attribute type that we don't know anything about. |
| | | if (!allowUnknownElements) |
| | | { |
| | | throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION, |
| | | msg.get(oid, woidString)); |
| | | } |
| | | attr = DirectoryServer.getDefaultAttributeType(woidString); |
| | | } |
| | | return attr; |
| | | } |
| | | |
| | | /** |
| | | * Reads the next token name from the name form definition, skipping over any |
| | | * leading or trailing spaces, and appends it to the provided buffer. |