Fix a bug in the schema backend that could cause problems when deleting one
instance of an element and adding a different instance of the same element in
the same modification that also depends on a third schema element which was
added between the two. For example, if you tried to have a single modify
operation that deleted an existing object class, added a new attribute type,
and added a new object class that depended on the new attribute type, the
operation would fail because when processing the removal of the object class
the server would attempt to determine whether it was going to be re-added later
in the operation and therefore attempted to decode any object class additions
later in the operation. An error occurred when trying to decode the new object
class because it depended on an attribute type that was not yet defined and the
decode operation wasn't told to ignore unknown schema elements.
OpenDS Issue Number: 1318
| | |
| | | try |
| | | { |
| | | at = AttributeTypeSyntax.decodeAttributeType(v.getValue(), schema, |
| | | false); |
| | | true); |
| | | } |
| | | catch (DirectoryException de) |
| | | { |
| | |
| | | ObjectClass oc; |
| | | try |
| | | { |
| | | oc = ObjectClassSyntax.decodeObjectClass(v.getValue(), schema, false); |
| | | oc = ObjectClassSyntax.decodeObjectClass(v.getValue(), schema, true); |
| | | } |
| | | catch (DirectoryException de) |
| | | { |
| | |
| | | NameForm nf; |
| | | try |
| | | { |
| | | nf = NameFormSyntax.decodeNameForm(v.getValue(), schema, false); |
| | | nf = NameFormSyntax.decodeNameForm(v.getValue(), schema, true); |
| | | } |
| | | catch (DirectoryException de) |
| | | { |
| | |
| | | try |
| | | { |
| | | dsr = DITStructureRuleSyntax.decodeDITStructureRule( |
| | | v.getValue(), schema, false); |
| | | v.getValue(), schema, true); |
| | | } |
| | | catch (DirectoryException de) |
| | | { |
| | |
| | | |
| | | |
| | | /** |
| | | * This test case covers the problem identified in issue #1318. In that |
| | | * issue, a problem arose if the following elements occurred in the following |
| | | * order in a single modify request: |
| | | * |
| | | * <OL> |
| | | * <LI>Delete an existing object class</LI> |
| | | * <LI>Add a new attribute type</LI> |
| | | * <LI>Add a new object class (different from the one that was removed) that |
| | | * depends on the new attribute type</LI> |
| | | * </OL> |
| | | * |
| | | * The problem was that in the process of removing the object class in step 1, |
| | | * the server checks to see if the same object class is going to be re-added |
| | | * again later. It does that by looking through the remaining modifications |
| | | * in the operation and for each modification that would add a new object |
| | | * class we decode it to see if it has the same OID. The process of decoding |
| | | * that object class would fail because it depended on a new attribute type |
| | | * that wasn't yet defined in the schema, and the server wasn't told to ignore |
| | | * missing schema elements. |
| | | * |
| | | * @throws Exception If an unexpected problem occurs. |
| | | */ |
| | | @Test() |
| | | public void testRemoveAndAddObjectClassIssue1318() |
| | | throws Exception |
| | | { |
| | | String path = TestCaseUtils.createTempFile( |
| | | "dn: cn=schema", |
| | | "changetype: modify", |
| | | "add: objectClasses", |
| | | "objectClasses: ( testissue1318oc1-oid NAME 'testIssue1381OC1' )", |
| | | "", |
| | | "dn: cn=schema", |
| | | "changetype: modify", |
| | | "delete: objectClasses", |
| | | "objectClasses: ( testissue1318oc1-oid NAME 'testIssue1381OC1' )", |
| | | "-", |
| | | "add: attributeTypes", |
| | | "attributeTypes: ( testissue1318at-oid NAME 'testIssue1381AT' )", |
| | | "-", |
| | | "add: objectClasses", |
| | | "objectClasses: ( testissue1318oc2-oid NAME 'testIssue1381OC2' " + |
| | | "MUST testIssue1381AT )"); |
| | | |
| | | String[] args = |
| | | { |
| | | "-h", "127.0.0.1", |
| | | "-p", String.valueOf(TestCaseUtils.getServerLdapPort()), |
| | | "-D", "cn=Directory Manager", |
| | | "-w", "password", |
| | | "-f", path |
| | | }; |
| | | |
| | | assertEquals(LDAPModify.mainModify(args, false, null, System.err), 0); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests to ensure that the schema subentry includes the lastmod attributes |
| | | * and that the modifiersName and modifyTimestamp attributes get updated when |
| | | * the schema is modified. |