| | |
| | | import org.forgerock.opendj.ldap.ModificationType; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.forgerock.opendj.ldap.SearchScope; |
| | | import org.forgerock.opendj.ldap.schema.CoreSchema; |
| | | import org.forgerock.opendj.ldap.schema.MatchingRule; |
| | | import org.forgerock.opendj.ldap.schema.ObjectClassType; |
| | | import org.forgerock.opendj.ldap.schema.SchemaBuilder; |
| | | import org.forgerock.opendj.ldap.schema.Syntax; |
| | | import org.opends.server.admin.server.ConfigurationChangeListener; |
| | | import org.opends.server.admin.std.server.SchemaBackendCfg; |
| | | import org.opends.server.api.AlertGenerator; |
| | |
| | | import org.opends.server.schema.MatchingRuleUseSyntax; |
| | | import org.opends.server.schema.NameFormSyntax; |
| | | import org.opends.server.schema.ObjectClassSyntax; |
| | | import org.opends.server.schema.SchemaUpdater; |
| | | import org.opends.server.types.*; |
| | | import org.opends.server.util.BackupManager; |
| | | import org.opends.server.util.DynamicConstants; |
| | |
| | | */ |
| | | private String stripMinUpperBoundRegEx = "\\{\\d+\\}"; |
| | | |
| | | |
| | | private ServerContext serverContext; |
| | | |
| | | /** |
| | | * Creates a new backend with the provided information. All backend |
| | |
| | | @Override |
| | | public void configureBackend(SchemaBackendCfg cfg, ServerContext serverContext) throws ConfigException |
| | | { |
| | | this.serverContext = serverContext; |
| | | |
| | | // Make sure that a configuration entry was provided. If not, then we will |
| | | // not be able to complete initialization. |
| | | if (cfg == null) |
| | |
| | | LDAPSyntaxDescription lsd; |
| | | try |
| | | { |
| | | lsd = LDAPSyntaxDescriptionSyntax.decodeLDAPSyntax(v, newSchema, false); |
| | | lsd = LDAPSyntaxDescriptionSyntax.decodeLDAPSyntax(v, serverContext, newSchema, false, false); |
| | | } |
| | | catch (DirectoryException de) |
| | | { |
| | |
| | | LDAPSyntaxDescription lsd; |
| | | try |
| | | { |
| | | lsd = LDAPSyntaxDescriptionSyntax.decodeLDAPSyntax(v, newSchema, false); |
| | | lsd = LDAPSyntaxDescriptionSyntax.decodeLDAPSyntax(v, serverContext, newSchema, false, true); |
| | | } |
| | | catch (DirectoryException de) |
| | | { |
| | |
| | | throws DirectoryException |
| | | { |
| | | //Check if there is an existing syntax with this oid. |
| | | String oid = ldapSyntaxDesc.getLdapSyntaxDescriptionSyntax().getOID(); |
| | | String oid = ldapSyntaxDesc.getSyntax().getOID(); |
| | | |
| | | // We allow only unimplemented syntaxes to be substituted. |
| | | if(schema.getSyntax(oid) !=null) |
| | |
| | | message); |
| | | } |
| | | |
| | | LDAPSyntaxDescription existingLSD = |
| | | schema.getLdapSyntaxDescription(oid); |
| | | LDAPSyntaxDescription existingLSD = schema.getLdapSyntaxDescription(oid); |
| | | SchemaUpdater schemaUpdater = serverContext.getSchemaUpdater(); |
| | | org.forgerock.opendj.ldap.schema.Schema newSchema = null; |
| | | |
| | | // If there is no existing lsd, then we're adding a new ldapsyntax. |
| | | // Otherwise, we're replacing an existing one. |
| | |
| | | { |
| | | schema.registerLdapSyntaxDescription(ldapSyntaxDesc, false); |
| | | addNewSchemaElement(modifiedSchemaFiles, ldapSyntaxDesc); |
| | | |
| | | // update schema NG |
| | | newSchema = schemaUpdater.getSchemaBuilder().buildSyntax(ldapSyntaxDesc.getSyntax()).addToSchema().toSchema(); |
| | | schemaUpdater.updateSchema(newSchema); |
| | | } |
| | | else |
| | | { |
| | | schema.deregisterLdapSyntaxDescription(existingLSD); |
| | | schema.registerLdapSyntaxDescription(ldapSyntaxDesc, false); |
| | | // update schema NG |
| | | SchemaBuilder schemaBuilder = schemaUpdater.getSchemaBuilder(); |
| | | schemaBuilder.removeSyntax(oid); |
| | | newSchema = schemaBuilder.buildSyntax(ldapSyntaxDesc.getSyntax()).addToSchema().toSchema(); |
| | | schemaUpdater.updateSchema(newSchema); |
| | | |
| | | schema.rebuildDependentElements(existingLSD); |
| | | replaceExistingSchemaElement(modifiedSchemaFiles, ldapSyntaxDesc, |
| | | existingLSD); |
| | | replaceExistingSchemaElement(modifiedSchemaFiles, ldapSyntaxDesc, existingLSD); |
| | | } |
| | | } |
| | | |
| | |
| | | Set<String> modifiedSchemaFiles) |
| | | throws DirectoryException |
| | | { |
| | | //See if the specified ldap syntax description is actually defined in the |
| | | //server schema. If not, then fail. Note that we are checking only the |
| | | //real part of the ldapsyntaxes attribute. A virtual value is not searched |
| | | // and hence never deleted. |
| | | String oid = ldapSyntaxDesc.getLdapSyntaxDescriptionSyntax().getOID(); |
| | | /* |
| | | * See if the specified ldap syntax description is actually defined in the |
| | | * server schema. If not, then fail. Note that we are checking only the real |
| | | * part of the ldapsyntaxes attribute. A virtual value is not searched and |
| | | * hence never deleted. |
| | | */ |
| | | String oid = ldapSyntaxDesc.getSyntax().getOID(); |
| | | LDAPSyntaxDescription removeLSD = schema.getLdapSyntaxDescription(oid); |
| | | |
| | | if (removeLSD == null || !removeLSD.equals(ldapSyntaxDesc)) |
| | |
| | | throw new DirectoryException(ResultCode.UNWILLING_TO_PERFORM, message); |
| | | } |
| | | |
| | | // update schema NG |
| | | SchemaUpdater schemaUpdater = serverContext.getSchemaUpdater(); |
| | | SchemaBuilder schemaBuilder = schemaUpdater.getSchemaBuilder(); |
| | | schemaBuilder.removeSyntax(oid); |
| | | schemaUpdater.updateSchema(schemaBuilder.toSchema()); |
| | | |
| | | schema.deregisterLdapSyntaxDescription(removeLSD); |
| | | String schemaFile = getSchemaFile(removeLSD); |
| | | if (schemaFile != null) |
| | |
| | | TreeSet<String> modifiedSchemaFiles = new TreeSet<String>(); |
| | | |
| | | // Get the attributeTypes attribute from the entry. |
| | | AttributeTypeSyntax attrTypeSyntax; |
| | | try |
| | | Syntax attrTypeSyntax = schema.getSyntax(SYNTAX_ATTRIBUTE_TYPE_OID); |
| | | if (attrTypeSyntax == null) |
| | | { |
| | | attrTypeSyntax = (AttributeTypeSyntax) |
| | | schema.getSyntax(SYNTAX_ATTRIBUTE_TYPE_OID); |
| | | if (attrTypeSyntax == null) |
| | | { |
| | | attrTypeSyntax = new AttributeTypeSyntax(); |
| | | attrTypeSyntax.initializeSyntax(null); |
| | | } |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | logger.traceException(e); |
| | | |
| | | attrTypeSyntax = new AttributeTypeSyntax(); |
| | | attrTypeSyntax = CoreSchema.getAttributeTypeDescriptionSyntax(); |
| | | } |
| | | |
| | | AttributeType attributeAttrType = |
| | | schema.getAttributeType(ATTR_ATTRIBUTE_TYPES_LC); |
| | | AttributeType attributeAttrType = schema.getAttributeType(ATTR_ATTRIBUTE_TYPES_LC); |
| | | if (attributeAttrType == null) |
| | | { |
| | | attributeAttrType = |
| | |
| | | |
| | | // loop on the objectClasses from the entry, search if they are |
| | | // already in the current schema, add them if not. |
| | | ObjectClassSyntax ocSyntax; |
| | | try |
| | | Syntax ocSyntax = schema.getSyntax(SYNTAX_OBJECTCLASS_OID); |
| | | if (ocSyntax == null) |
| | | { |
| | | ocSyntax = (ObjectClassSyntax) schema.getSyntax(SYNTAX_OBJECTCLASS_OID); |
| | | if (ocSyntax == null) |
| | | { |
| | | ocSyntax = new ObjectClassSyntax(); |
| | | ocSyntax.initializeSyntax(null); |
| | | } |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | logger.traceException(e); |
| | | |
| | | ocSyntax = new ObjectClassSyntax(); |
| | | ocSyntax = CoreSchema.getObjectClassDescriptionSyntax(); |
| | | } |
| | | |
| | | AttributeType objectclassAttrType = |