try
{
monitor.reportProgress( BrowserCoreMessages.model__loading_schema );
// check if schema is cached
Schema schema = browserConnection.getSchema();
if ( schema == Schema.DEFAULT_SCHEMA )
{
ReloadSchemasJob.reloadSchema( browserConnection, monitor );
}
else if ( rootDSE.getAttribute( IRootDSE.ROOTDSE_ATTRIBUTE_SUBSCHEMASUBENTRY ) != null )
{
// check if schema is up-to-date
SearchParameter sp = new SearchParameter();
sp.setSearchBase( new LdapDN( rootDSE.getAttribute( IRootDSE.ROOTDSE_ATTRIBUTE_SUBSCHEMASUBENTRY )
.getStringValue() ) );
sp.setFilter( Schema.SCHEMA_FILTER );
sp.setScope( SearchScope.OBJECT );
sp.setReturningAttributes( new String[]
{ IAttribute.OPERATIONAL_ATTRIBUTE_CREATE_TIMESTAMP,
IAttribute.OPERATIONAL_ATTRIBUTE_MODIFY_TIMESTAMP, } );
ISearch search = new Search( browserConnection, sp );
SearchJob.searchAndUpdateModel( browserConnection, search, monitor );
ISearchResult[] results = search.getSearchResults();
if ( results != null && results.length == 1 )
{
String schemaTimestamp = results[0]
.getAttribute( IAttribute.OPERATIONAL_ATTRIBUTE_MODIFY_TIMESTAMP ) != null ? results[0]
.getAttribute( IAttribute.OPERATIONAL_ATTRIBUTE_MODIFY_TIMESTAMP ).getStringValue() : null;
if ( schemaTimestamp == null )
{
schemaTimestamp = results[0]
.getAttribute( IAttribute.OPERATIONAL_ATTRIBUTE_CREATE_TIMESTAMP ) != null ? results[0]
.getAttribute( IAttribute.OPERATIONAL_ATTRIBUTE_CREATE_TIMESTAMP ).getStringValue()
: null;
}
String cacheTimestamp = schema.getModifyTimestamp() != null ? schema.getModifyTimestamp()
: schema.getCreateTimestamp();
if ( cacheTimestamp == null
|| ( cacheTimestamp != null && schemaTimestamp != null && schemaTimestamp
.compareTo( cacheTimestamp ) > 0 ) )
{
ReloadSchemasJob.reloadSchema( browserConnection, monitor );