/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
* This is the class used to implement LDAP's GetSchema call.
*
* It subclasses HierMemDirContext for most of the functionality. It
* overrides functions that cause the schema definitions to change.
* In such a case, it write the schema to the LdapServer and (assuming
* there are no errors), calls it's superclass's equivalent function.
* Thus, the schema tree and the LDAP server's schema attributes are
* always in sync.
*/
static private final boolean debug = false;
private boolean setupMode = true;
private int objectType;
throws NamingException {
try {
return root;
} catch (NamingException e) {
throw e;
}
}
// Called by createNewCtx
this.objectType = objectType;
}
// override HierMemDirCtx.close to prevent premature GC of shared data
}
// override to ignore obj and use attrs
// treat same as createSubcontext
throws NamingException {
if (!setupMode) {
throw new IllegalArgumentException("obj must be null");
}
// Update server
}
// Update in-memory copy
}
boolean useFactory) throws NamingException {
if (!setupMode) {
throw new SchemaViolationException(
"Cannot bind arbitrary object; use createSubcontext()");
} else {
}
}
// override to use bind() instead
throws NamingException {
try {
throw new SchemaViolationException(
"Cannot replace existing schema object");
} catch (NameNotFoundException e) {
}
}
boolean useFactory) throws NamingException {
if (!setupMode) {
throw new SchemaViolationException(
"Cannot bind arbitrary object; use createSubcontext()");
} else {
}
}
if (!setupMode) {
// Update server
try {
// Lookup entry from memory
} catch (NameNotFoundException e) {
return;
}
}
// Update in-memory copy
}
throws NamingException {
if (!setupMode) {
throw new SchemaViolationException("Cannot rename a schema object");
} else {
}
}
if (!setupMode) {
// Update server
try {
// Lookup entry from memory
} catch (NameNotFoundException e) {
return;
}
}
// Update in-memory copy
super.doDestroySubcontext(name);
}
// Called to create oc, attr, syntax or matching rule roots and leaf entries
throws NamingException{
try {
setupMode = true;
(LdapSchemaCtx) super.doCreateSubcontext(
return answer;
} finally {
setupMode = false;
}
}
throws NamingException {
throw new SchemaViolationException(
"Must supply attributes describing schema");
}
if (!setupMode) {
// Update server
}
// Update in-memory copy
return newEntry;
}
throws NamingException {
}
return copy;
}
throws NamingException {
if (setupMode) {
super.doModifyAttributes(mods);
} else {
// Apply modifications to copy
// Update server copy
// Update in-memory copy
}
}
// we override this so the superclass creates the right kind of contexts
// Default is to create LEAF objects; caller will change after creation
// if necessary
return ctx;
}
throws NamingException {
switch (objectType) {
case OBJECTCLASS_ROOT:
break;
case ATTRIBUTE_ROOT:
break;
case SYNTAX_ROOT:
break;
case MATCHRULE_ROOT:
break;
case SCHEMA_ROOT:
throw new SchemaViolationException(
"Cannot create new entry under schema root");
default:
throw new SchemaViolationException(
"Cannot create child of schema object");
}
//System.err.println((String)schemaAttr.get());
}
/**
* When we delete an entry, we use the original to make sure that
* any formatting inconsistencies are eliminated.
* This is because we're just deleting a value from an attribute
* on the server and there might not be any checks for extra spaces
* or parens.
*/
throws NamingException {
switch (objectType) {
case OBJECTCLASS_ROOT:
break;
case ATTRIBUTE_ROOT:
break;
case SYNTAX_ROOT:
break;
case MATCHRULE_ROOT:
break;
case SCHEMA_ROOT:
throw new SchemaViolationException(
"Cannot delete schema root");
default:
throw new SchemaViolationException(
"Cannot delete child of schema object");
}
}
/**
* When we modify an entry, we use the original attribute value
* in the schema to make sure that any formatting inconsistencies
* are eliminated. A modification is done by deleting the original
* value and adding a new value with the modification.
*/
switch (objectType) {
case OBJECTCLASS:
break;
case ATTRIBUTE:
break;
case SYNTAX:
break;
case MATCHRULE:
break;
default:
throw new SchemaViolationException(
"Cannot modify schema root");
}
}
final static private class SchemaInfo {
private int port;
private boolean hasLdapsScheme;
this.schemaEntryName = schemaEntryName;
this.schemaEntry = schemaEntry;
}
if (schemaEntry != null) {
schemaEntry.close();
schemaEntry = null;
}
}
// Use subschemasubentry name as DN
}
throws NamingException {
if (schemaEntry == null) {
}
}
if (schemaEntry == null) {
}
}
}
}