本文整理汇总了Java中org.apache.directory.api.ldap.model.schema.registries.Schema类的典型用法代码示例。如果您正苦于以下问题:Java Schema类的具体用法?Java Schema怎么用?Java Schema使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Schema类属于org.apache.directory.api.ldap.model.schema.registries包,在下文中一共展示了Schema类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: updateSchemas
import org.apache.directory.api.ldap.model.schema.registries.Schema; //导入依赖的package包/类
private void updateSchemas( SchemaObject schemaObject )
{
String schemaName = schemaObject.getSchemaName();
Schema schema;
if ( Strings.isEmpty( schemaName ) || "null".equals( schemaName ) )
{
schemaName = "default";
schema = schemaMap.get( schemaName );
}
else
{
schema = schemaMap.get( schemaName );
}
if ( schema == null )
{
schema = new DefaultSchema( this, schemaName );
schemaMap.put( schemaName, schema );
}
schema.getContent().add( new SchemaObjectWrapper( schemaObject ) );
}
示例2: getAllSchemas
import org.apache.directory.api.ldap.model.schema.registries.Schema; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public List<Schema> getAllSchemas()
{
List<Schema> schemas = new ArrayList<>();
for ( Schema schema : schemaMap.values() )
{
if ( schema.isEnabled() )
{
schemas.add( schema );
}
}
return schemas;
}
示例3: loadSchemaObjects
import org.apache.directory.api.ldap.model.schema.registries.Schema; //导入依赖的package包/类
private List<Entry> loadSchemaObjects( String schemaObjectType, Schema... schemas ) throws LdapException,
IOException
{
Map<String, List<Entry>> m = scObjEntryMap.get( schemaObjectType );
List<Entry> atList = new ArrayList<>();
for ( Schema s : schemas )
{
List<Entry> preLoaded = m.get( s.getSchemaName() );
if ( preLoaded != null )
{
atList.addAll( preLoaded );
}
}
return atList;
}
示例4: loadAllEnabled
import org.apache.directory.api.ldap.model.schema.registries.Schema; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public boolean loadAllEnabled() throws LdapException
{
Schema[] schemas = new Schema[schemaMap.size()];
int i = 0;
for ( Schema schema : schemaMap.values() )
{
if ( schema.isEnabled() )
{
schemas[i++] = schema;
}
}
Schema[] enabledSchemas = new Schema[i];
System.arraycopy( schemas, 0, enabledSchemas, 0, i );
return loadWithDeps( enabledSchemas );
}
示例5: unload
import org.apache.directory.api.ldap.model.schema.registries.Schema; //导入依赖的package包/类
/**
* Unload the schema from the registries. We will unload everything accordingly to the two flags :
* - isRelaxed
* - disabledAccepted
*/
private boolean unload( Registries registries, Schema schema ) throws LdapException
{
if ( schema == null )
{
LOG.info( "The schema is null" );
return false;
}
// First avoid unloading twice the same schema
if ( !registries.isSchemaLoaded( schema.getSchemaName() ) )
{
return true;
}
if ( schema.isEnabled() )
{
LOG.info( "Unloading {} schema: \n{}", schema.getSchemaName(), schema );
deleteSchemaObjects( schema, registries );
registries.schemaUnloaded( schema );
}
return true;
}
示例6: getSchema
import org.apache.directory.api.ldap.model.schema.registries.Schema; //导入依赖的package包/类
/**
* Get the schema from its name. Return the Other reference if there
* is no schema name. Throws a NPE if the schema is not loaded.
*/
private Schema getSchema( String schemaName, Registries registries )
{
if ( Strings.isEmpty( schemaName ) )
{
schemaName = MetaSchemaConstants.SCHEMA_OTHER;
}
Schema schema = registries.getLoadedSchema( schemaName );
if ( schema == null )
{
String msg = I18n.err( I18n.ERR_10009, schemaName );
LOG.error( msg );
}
return schema;
}
示例7: loadAllEnabledRelaxed
import org.apache.directory.api.ldap.model.schema.registries.Schema; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public boolean loadAllEnabledRelaxed() throws LdapException
{
Schema[] enabledSchemas = new Schema[schemaMap.size()];
int i = 0;
for ( Schema schema : schemaMap.values() )
{
if ( schema.isEnabled() )
{
enabledSchemas[i++] = schema;
}
}
return loadWithDepsRelaxed( enabledSchemas );
}
示例8: DefaultSchemaManager
import org.apache.directory.api.ldap.model.schema.registries.Schema; //导入依赖的package包/类
/**
* Creates a new instance of DefaultSchemaManager with the default schema schemaLoader
*
* @param schemas The list of schema to load
*/
public DefaultSchemaManager( Collection<Schema> schemas )
{
// Default to the the root (one schemaManager for all the entries
namingContext = Dn.ROOT_DSE;
for ( Schema schema : schemas )
{
schemaMap.put( schema.getSchemaName(), schema );
}
errors = new ArrayList<>();
registries = new Registries();
factory = new SchemaEntityFactory();
isRelaxed = STRICT;
}
示例9: toArray
import org.apache.directory.api.ldap.model.schema.registries.Schema; //导入依赖的package包/类
/**
* Transform a String[] array of schema to a Schema[]
*/
private Schema[] toArray( String... schemas ) throws LdapException
{
Schema[] schemaArray = new Schema[schemas.length];
int n = 0;
for ( String schemaName : schemas )
{
Schema schema = schemaMap.get( schemaName );
if ( schema != null )
{
schemaArray[n++] = schema;
}
else
{
throw new LdapUnwillingToPerformException( ResultCodeEnum.UNWILLING_TO_PERFORM, I18n.err(
I18n.ERR_11001, schemaName ) );
}
}
return schemaArray;
}
示例10: addSchemaObjects
import org.apache.directory.api.ldap.model.schema.registries.Schema; //导入依赖的package包/类
private void addSchemaObjects( Schema schema, Registries registries ) throws LdapException
{
// Create a content container for this schema
registries.addSchema( schema.getSchemaName() );
schemaMap.put( schema.getSchemaName(), schema );
// And inject any existing SchemaObject into the registries
try
{
addComparators( schema, registries );
addNormalizers( schema, registries );
addSyntaxCheckers( schema, registries );
addSyntaxes( schema, registries );
addMatchingRules( schema, registries );
addAttributeTypes( schema, registries );
addObjectClasses( schema, registries );
//addMatchingRuleUses( schema, registries );
//addDitContentRules( schema, registries );
//addNameForms( schema, registries );
//addDitStructureRules( schema, registries );
}
catch ( IOException ioe )
{
throw new LdapOtherException( ioe.getMessage(), ioe );
}
}
示例11: deleteSchemaObjects
import org.apache.directory.api.ldap.model.schema.registries.Schema; //导入依赖的package包/类
/**
* Delete all the schemaObjects for a given schema from the registries
*/
private void deleteSchemaObjects( Schema schema, Registries registries ) throws LdapException
{
Map<String, Set<SchemaObjectWrapper>> schemaObjects = registries.getObjectBySchemaName();
Set<SchemaObjectWrapper> content = schemaObjects.get( Strings.toLowerCaseAscii( schema.getSchemaName() ) );
List<SchemaObject> toBeDeleted = new ArrayList<>();
if ( content != null )
{
// Build an intermediate list to avoid concurrent modifications
for ( SchemaObjectWrapper schemaObjectWrapper : content )
{
toBeDeleted.add( schemaObjectWrapper.get() );
}
for ( SchemaObject schemaObject : toBeDeleted )
{
registries.delete( errors, schemaObject );
}
}
}
示例12: getEnabled
import org.apache.directory.api.ldap.model.schema.registries.Schema; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public List<Schema> getEnabled()
{
List<Schema> enabled = new ArrayList<>();
for ( Schema schema : registries.getLoadedSchemas().values() )
{
if ( schema.isEnabled() )
{
enabled.add( schema );
}
}
return enabled;
}
示例13: getAttributes
import org.apache.directory.api.ldap.model.schema.registries.Schema; //导入依赖的package包/类
/**
* Get a SchemaObject as an Entry
*
* @param obj The schema oobject to convert
* @param schema The schema which this object belongs to
* @param schemaManager The SchemaManager
* @return The converted schema object as an Entry
* @throws LdapException If we can't convert teh schema object
*/
public Entry getAttributes( SchemaObject obj, Schema schema, SchemaManager schemaManager ) throws LdapException
{
if ( obj instanceof LdapSyntax )
{
return convert( ( LdapSyntax ) obj, schema, schemaManager );
}
else if ( obj instanceof MatchingRule )
{
return convert( ( MatchingRule ) obj, schema, schemaManager );
}
else if ( obj instanceof AttributeType )
{
return convert( ( AttributeType ) obj, schema, schemaManager );
}
else if ( obj instanceof ObjectClass )
{
return convert( ( ObjectClass ) obj, schema, schemaManager );
}
else if ( obj instanceof MatchingRuleUse )
{
return convert( ( MatchingRuleUse ) obj, schema, schemaManager );
}
else if ( obj instanceof DitStructureRule )
{
return convert( ( DitStructureRule ) obj, schema, schemaManager );
}
else if ( obj instanceof DitContentRule )
{
return convert( ( DitContentRule ) obj, schema, schemaManager );
}
else if ( obj instanceof NameForm )
{
return convert( ( NameForm ) obj, schema, schemaManager );
}
throw new IllegalArgumentException( "nknown SchemaObject type: " + obj.getClass() );
}
示例14: convert
import org.apache.directory.api.ldap.model.schema.registries.Schema; //导入依赖的package包/类
/**
* Converts a Schema to an Entry
*
* @param schema The Schema to convert
* @param schemaManager The SchemaManager
* @return An Entry containing the converted Schema
* @throws LdapException If the conversion failed
*/
public Entry convert( Schema schema, SchemaManager schemaManager ) throws LdapException
{
Entry entry = new DefaultEntry( schemaManager );
entry.put( SchemaConstants.OBJECT_CLASS_AT, SchemaConstants.TOP_OC, MetaSchemaConstants.META_SCHEMA_OC );
entry.put( SchemaConstants.CN_AT, schema.getSchemaName() );
entry.put( SchemaConstants.CREATORS_NAME_AT, schema.getOwner() );
entry.put( SchemaConstants.CREATE_TIMESTAMP_AT, DateUtils.getGeneralizedTime() );
if ( schema.isDisabled() )
{
entry.put( MetaSchemaConstants.M_DISABLED_AT, "TRUE" );
}
String[] dependencies = schema.getDependencies();
if ( dependencies != null && dependencies.length > 0 )
{
Attribute attr = new DefaultAttribute(
schemaManager.getAttributeType( MetaSchemaConstants.M_DEPENDENCIES_AT ) );
for ( String dependency : dependencies )
{
attr.add( dependency );
}
entry.put( attr );
}
return entry;
}
示例15: setup
import org.apache.directory.api.ldap.model.schema.registries.Schema; //导入依赖的package包/类
@BeforeClass
public static void setup() throws Exception
{
workingDirectory = System.getProperty( "workingDirectory" );
if ( workingDirectory == null )
{
String path = MatchingRuleTest.class.getResource( "" ).getPath();
int targetPos = path.indexOf( "target" );
workingDirectory = path.substring( 0, targetPos + 6 );
}
schemaRepository = new File( workingDirectory, "schema" );
// Cleanup the target directory
FileUtils.deleteDirectory( schemaRepository );
SchemaLdifExtractor extractor = new DefaultSchemaLdifExtractor( new File( workingDirectory ) );
extractor.extractOrCopy();
LdifSchemaLoader loader = new LdifSchemaLoader( schemaRepository );
schemaManager = new DefaultSchemaManager( loader );
for ( Schema schema : loader.getAllSchemas() )
{
schema.enable();
}
schemaManager.loadAllEnabled();
}