So after a lot of debugging I managed to make it "compile and run".

Let me vent here a little bit and rant about Java: Errors in Java are an 
abomination and whoever thought that any of these extremely verbose but 
content-deflated debugging outputs are of any use to anyone trying to find the 
problem as fast as possible should get publicly flailed. </rant>

Having said that, I have found out a little about the way javascript works in 
JSC and I am writing this here, so other people might use it as a reference:


-          Of course, functions defined in an external js-file _can_ have 
arguments, so you can pass variables from beans within lsc.xml, i.e.

js:generateEduPersonAffiliation(srcBean.getDatasetValuesById("eduPersonPrimaryAffiliation"))

-          The javascript usable is a pretty standard one, so don't expect 
fancy and/or new functions. Suffice it to say, the javascript is dependent on 
your Java installed, so there you are. As an advice, the more basic your 
javascript code, the better. Trust me, some error outputs can be extremely 
misleading and won't help you debug the problem. Better keep that in mind and 
keep your code simple.

-          Most interestingly: Not everything you code in your js-file will be 
javascript! Some can be Java! For instance, in the above example  
srcBean.getDatasetValuesById("eduPersonPrimaryAffiliation") will return a 
Java-Array (thus you have to use Java-Methods), even though you use it in 
javascript. Keep that in mind!

Hope that helps another person at some point.

All the best,
Alex.


Von: lsc-users [mailto:[email protected]] Im Auftrag von 
Alexander Herr
Gesendet: Friday, 16 June 2017 16:40
An: General discussions and help for Ldap Synchronization Connector (LSC) - 
Start here! <[email protected]>
Betreff: [lsc-users] Syntax error if using external javascript-file

So I have to use more complicated scripts for synchronizing from OpenLDAP to 
AD, thus I externalized the javascript logic into an external file, as 
described here:
https://lsc-project.org/documentation/2.1/scripting/start

However, once I use the <scriptInclude> markup (and it picks up my file), 
previous scripts stop working and I get a "syntax error" exception. This is 
weird!
I also tried moving the failing parts themselves into the external js-file, but 
that does not make it work either.

One thing I noticed though: In the documentation, the test() function in the 
example does not receive arguments. Are arguments supported for functions in 
external js-files?

Any other idea, why this isn't working?

All the best,
Alex.
_______________________________________________________________
Ldap Synchronization Connector (LSC) - http://lsc-project.org

lsc-users mailing list
[email protected]
https://lists.lsc-project.org/cgi-bin/mailman/listinfo/lsc-users

Reply via email to