Now that I have build this class, how do I instruct LSC to use it in a 2.0/xml way?
Hugh On Wed, Apr 25, 2012 at 9:58 PM, Hugh Kelley <[email protected]> wrote: > Sebastien, thanks for that guidance. > > I've muddled through my Eclipse setup (my Maven plugin is clearly broken > but I've managed to download all the jar files needed to build). > > Now I'm ready to do some testing. I see the 1.x examples ( > http://lsc-project.org/wiki/documentation/1.2/development/addingsourceconnector) > showing a custom connector in the old file format. Is there an example in > the lsc.xml format? I didn't see a setting here ( > http://lsc-project.org/wiki/documentation/2.0/configuration/service) that > seemed to fit. > > > private Map<String, LscDatasets> convertSearchEntries( > Cursor<SearchResponse> cursor) { > > TreeMap<Integer, SearchResultEntry> sortMap = new TreeMap<Integer, > SearchResultEntry>(); > > Map<String, LscDatasets> converted = new HashMap<String, > LscDatasets>(); > > for(SearchResponse sr : cursor) { > if(sr instanceof SearchResultEntry) { > SearchResultEntry sre = (SearchResultEntry) sr; > > // Tuck the object away based on the depth of its LDAP > path > sortMap.put(sre.getObjectName().getRdns().size(),sre); > } > } > > for(SearchResultEntry sre : sortMap.values()) { > converted.put(sre.getObjectName().toString(), > convertSearchEntry(sre)); > } > > return converted; > } > > Regards, > Hugh > > > On Wed, Apr 25, 2012 at 10:39 AM, Hugh Kelley <[email protected]>wrote: > >> I gave that class a quick look and it looks like it can be almost >> entirely re-used. By my estimation, I need to insert the sorting logic >> here. >> >> private Map<String, LscDatasets> convertSearchEntries( >> Cursor<SearchResponse> cursor) { >> Map<String, LscDatasets> converted = new HashMap<String, >> LscDatasets>(); >> for(SearchResponse sr : cursor) { >> if(sr instanceof SearchResultEntry) { >> SearchResultEntry sre = (SearchResultEntry) sr; >> converted.put(sre.getObjectName().toString(), >> convertSearchEntry(sre)); >> } >> } >> return converted; >> } >> >> Unfortunately, I'm an Eclipse neophyte and am struggling a bit to get a >> working project established. I need to do some self-study before I can >> actually build anything. >> >> Hugh >> >> >> >> On Tue, Apr 24, 2012 at 12:51 PM, Sébastien Bahloul < >> [email protected]> wrote: >> >>> Hi Hugh, >>> >>> If you have some time to try and implement it, start >>> from SyncReplSourceService.java class and look at the getNextId() method >>> which is storing results inside a temporary map. Don't >>> implement IAsynchronousService if you do not plan to use the event based >>> model, but use this idea inside a subclass of SimpleJndiService in which >>> you should override the getBean method. >>> >>> You will have to build the same map and before returning any result, >>> sort the map according the DN hierarchy through for example the following >>> method : >>> >>> >>> http://directory.apache.org/api/gen-docs/latest/apidocs/org/apache/directory/shared/ldap/model/name/Dn.html#isAncestorOf(org.apache.directory.shared.ldap.model.name.Dn >>> >>> Regards, >>> >>> -- >>> Sebastien BAHLOUL >>> IAM / Security specialist >>> Ldap Synchronization Connector : http://lsc-project.org >>> Blog : http://sbahloul.wordpress.com/ >>> >>> >>> >>> 2012/4/24 Hugh Kelley <[email protected]> >>> >>>> I do plan to run the sync as a recurring job (cron-like) but the >>>> destination directory is currently empty. >>>> >>>> Is it AbstractSimpleJndiService that you are proposing I customize >>>> (specifically the SearchResult property or thereabouts)? >>>> >>>> Hugh >>>> >>>> >>>> On Tue, Apr 24, 2012 at 12:19 PM, Sébastien Bahloul < >>>> [email protected]> wrote: >>>> >>>>> Hi Clement, Hugh, >>>>> >>>>> The builtin LDAP source service is effectively not designed to handle >>>>> such use case. But it is possible to write a source service that will >>>>> respect the LDAP hierarchy to send results in the correct order. >>>>> >>>>> Are you planning to run it on a periodical basis ? If so, we can >>>>> preload the whole directory, sort entries thanks to a LDAP hierarchical >>>>> sort class and manage the entries with that order. >>>>> >>>>> Regards, >>>>> -- >>>>> Sebastien BAHLOUL >>>>> IAM / Security specialist >>>>> Ldap Synchronization Connector : http://lsc-project.org >>>>> Blog : http://sbahloul.wordpress.com/ >>>>> >>>>> >>>>> >>>>> Le 24 avril 2012 18:15, Clément OUDOT <[email protected]> a écrit : >>>>> >>>>>> Le 24 avril 2012 18:07, Hugh Kelley <[email protected]> a écrit >>>>>> : >>>>>> > I am trying to use LSC to essentially "mirror" a very hierarchical >>>>>> (many >>>>>> > nested OUs) production LDAP instance into an isolated >>>>>> pre-production LDAP >>>>>> > instance. My current issue is that the updates are being >>>>>> generated in >>>>>> > reverse (or perhaps random) order, so that child objects creations >>>>>> are >>>>>> > attempted before parent objects have been created. >>>>>> > >>>>>> > See the bottom of this post for an excerpt from my LDIF. I know >>>>>> there is a >>>>>> > <sortedBy> option I can use at the connection level, but I don't >>>>>> know of any >>>>>> > LDAP attribute that could be used in a sort-by-depth manner. Are >>>>>> there any >>>>>> > clever solutions for this? >>>>>> > >>>>>> > One ideaI am exploring is to sort by whenChanged, thinking that the >>>>>> > most-recently changed objects should be the children. However, >>>>>> this >>>>>> > lsc.xml configuration appears to be invalid. >>>>>> > >>>>>> > </ldapConnection> >>>>>> > . . . . . . >>>>>> > <binaryAttributes> >>>>>> > <string>objectGUID</string> >>>>>> > </binaryAttributes> >>>>>> > <sortedBy>whenChanged</sortedBy> >>>>>> > </ldapConnection> >>>>>> > >>>>>> > ERROR - org.lsc.exception.LscConfigurationException: >>>>>> > javax.xml.bind.UnmarshalException >>>>>> > - with linked exception: >>>>>> > [org.xml.sax.SAXParseException: cvc-complex-type.2.4.d: Invalid >>>>>> content was >>>>>> > found starting with element 'sortedBy'. No child element is >>>>>> expected at this >>>>>> > point.] >>>>>> > org.lsc.exception.LscConfigurationException: >>>>>> > javax.xml.bind.UnmarshalException >>>>>> > >>>>>> >>>>>> >>>>>> sortedBy option does not work in 2.0. An issue has been opened for the >>>>>> next version: http://tools.lsc-project.org/issues/440 >>>>>> >>>>>> >>>>>> LSC is not a very good tool to synchronize a hierarchical tree, just >>>>>> for the reason you mention in your mail: entries are get in a non >>>>>> hierarchical order. Maybe someone in this list has done such >>>>>> synchronization and can help us? >>>>>> >>>>>> >>>>>> Clément. >>>>>> _______________________________________________________________ >>>>>> Ldap Synchronization Connector (LSC) - http://lsc-project.org >>>>>> >>>>>> lsc-users mailing list >>>>>> [email protected] >>>>>> http://lists.lsc-project.org/listinfo/lsc-users >>>>>> >>>>> >>>>> >>>> >>>> _______________________________________________________________ >>>> Ldap Synchronization Connector (LSC) - http://lsc-project.org >>>> >>>> lsc-users mailing list >>>> [email protected] >>>> http://lists.lsc-project.org/listinfo/lsc-users >>>> >>>> >>> >> >
_______________________________________________________________ Ldap Synchronization Connector (LSC) - http://lsc-project.org lsc-users mailing list [email protected] http://lists.lsc-project.org/listinfo/lsc-users

