private void dropClassInternal(final String className) { acquireSchemaWriteLock(); try { if (getDatabase().getTransaction().isActive()) throw new IllegalStateException("Cannot drop a class inside a transaction"); if (className == null) throw new IllegalArgumentException("Class name is null"); getDatabase().checkSecurity(ORule.ResourceGeneric.SCHEMA, ORole.PERMISSION_DELETE); final String key = className.toLowerCase(); final OClass cls = classes.get(key); if (cls == null) throw new OSchemaException("Class '" + className + "' was not found in current database"); if (!cls.getSubclasses().isEmpty()) throw new OSchemaException( "Class '" + className + "' cannot be dropped because it has sub classes. Remove the dependencies before trying to drop it again"); checkEmbedded(getDatabase().getStorage()); for (OClass superClass : cls.getSuperClasses()) { // REMOVE DEPENDENCY FROM SUPERCLASS ((OClassImpl) superClass).removeBaseClassInternal(cls); } deleteDefaultCluster(cls); dropClassIndexes(cls); classes.remove(key); if (cls.getShortName() != null) // REMOVE THE ALIAS TOO classes.remove(cls.getShortName().toLowerCase()); removeClusterClassMap(cls); } finally { releaseSchemaWriteLock(); } }