diff --git a/SoObjects/SOGo/LDAPSource.m b/SoObjects/SOGo/LDAPSource.m index 1ed4d7bd1..ff07d43f2 100644 --- a/SoObjects/SOGo/LDAPSource.m +++ b/SoObjects/SOGo/LDAPSource.m @@ -440,6 +440,8 @@ groupObjectClasses: (NSArray *) newGroupObjectClasses - (NGLdapConnection *) _ldapConnection { NGLdapConnection *ldapConnection; + NSString *value, *key; + SOGoCache *cache; NS_DURING { @@ -459,7 +461,20 @@ groupObjectClasses: (NSArray *) newGroupObjectClasses if (!_schema) { _schema = [LDAPSourceSchema new]; - [_schema readSchemaFromConnection: ldapConnection]; + cache = [SOGoCache sharedCache]; + key = [NSString stringWithFormat: @"schema:%@", _sourceID]; + value = [cache valueForKey: key]; + + if (value) + { + [_schema setSchema: (NSMutableDictionary *)[value objectFromJSONString]]; + } + else + { + // We go check in the LDAP directory + [_schema readSchemaFromConnection: ldapConnection]; + [cache setValue: [_schema jsonRepresentation] forKey: key]; + } } } else diff --git a/SoObjects/SOGo/LDAPSourceSchema.h b/SoObjects/SOGo/LDAPSourceSchema.h index cf6598967..2fd7bc85f 100644 --- a/SoObjects/SOGo/LDAPSourceSchema.h +++ b/SoObjects/SOGo/LDAPSourceSchema.h @@ -1,8 +1,6 @@ /* LDAPSourceSchema.h - this file is part of SOGo * - * Copyright (C) 2011 Inverse inc - * - * Author: Wolfgang Sourdeau + * Copyright (C) 2011-2021 Inverse inc * * This file is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -34,11 +32,15 @@ - (void) readSchemaFromConnection: (NGLdapConnection *) conn; +- (void) setSchema: (NSMutableDictionary *) newSchema; + - (NSArray *) fieldsForClass: (NSString *) className; /* merged list of attributes with unique names */ - (NSArray *) fieldsForClasses: (NSArray *) className; +- (NSString *) jsonRepresentation; + @end #endif /* LDAPSOURCESCHEMA_H */ diff --git a/SoObjects/SOGo/LDAPSourceSchema.m b/SoObjects/SOGo/LDAPSourceSchema.m index 796251324..6d7c1cc1a 100644 --- a/SoObjects/SOGo/LDAPSourceSchema.m +++ b/SoObjects/SOGo/LDAPSourceSchema.m @@ -1,8 +1,6 @@ /* LDAPSourceSchema.m - this file is part of SOGo * - * Copyright (C) 2011 Inverse inc - * - * Author: Wolfgang Sourdeau + * Copyright (C) 2011-2021 Inverse inc * * This file is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -239,6 +237,12 @@ fillSchemaFromEntry (NSMutableDictionary *schema, NGLdapEntry *entry) } } +- (void) setSchema: (NSMutableDictionary *) newSchema +{ + ASSIGN (schema, newSchema); + [schema release]; +} + static void fillFieldsForClass (NSMutableDictionary *schema, NSString *schemaName, NSMutableArray *fields) @@ -289,4 +293,9 @@ fillFieldsForClass (NSMutableDictionary *schema, NSString *schemaName, return [fieldHash allKeys]; } +- (NSString *) jsonRepresentation +{ + return [schema jsonRepresentation]; +} + @end