Skip to Content.
Sympa Menu

grouper-users - RE: [grouper-users] Re: JEXL With Conditionals in media.properties

Subject: Grouper Users - Open Discussion List

List archive

RE: [grouper-users] Re: JEXL With Conditionals in media.properties


Chronological Thread 
  • From: Chris Hyzer <>
  • To: Colin Hudler <>, "" <>
  • Subject: RE: [grouper-users] Re: JEXL With Conditionals in media.properties
  • Date: Fri, 11 Jun 2010 15:12:54 -0400
  • Accept-language: en-US
  • Acceptlanguage: en-US

Well, the custom method doesn't work in jexl if not registered with the
context. So I added support in Grouper 1.6 just to load classes if not
registered (otherwise we would need a callback to register things). This is
fine for things in the server side configs, but now that users can customize
their simple membership update screen, its not secure to allow them to call
any static method in an EL. So this defaults to not allowed, and if we need
it somewhere where we use EL, we can turn it on. I did change the
substituteExpressionLanguage method to handle curlies in scripts in 1.6...
here is the test case

/**
*
* @param group
* @return string
*/
public static String transformGroup(Group group) {
return "hey: " + group.getNameDb();
}

/**
*
*/
public void testSubstituteExpressionLanguage() {
Group group = new Group();
group.setNameDb("someName");
Map<String, Object> substituteMap = new HashMap<String, Object>();
substituteMap.put("group", group);
String nameDb = null;

nameDb = GrouperUtil.substituteExpressionLanguage("${group.nameDb}
${group.nameDb}", substituteMap);
assertEquals("someName someName", nameDb);

try {
nameDb =
GrouperUtil.substituteExpressionLanguage("${java.lang.System.currentTimeMillis()}",
substituteMap);
fail("Shouldnt get here");
} catch (Exception e) {
//good
}

nameDb =
GrouperUtil.substituteExpressionLanguage("${java.lang.System.currentTimeMillis()}",
substituteMap, true);
assertTrue(Long.parseLong(nameDb) > 0);
nameDb =
GrouperUtil.substituteExpressionLanguage("${edu.internet2.middleware.grouper.util.GrouperUtilTest.transformGroup(group)}",
substituteMap, true);
assertEquals("hey: someName", nameDb);

nameDb = GrouperUtil.substituteExpressionLanguage("${if (true) { 'hello';
} } ${group.nameDb}", substituteMap);
assertEquals("hello someName", nameDb);
nameDb = GrouperUtil.substituteExpressionLanguage("${if (true) { if
(true){ 'hello'; }}} ${group.nameDb}", substituteMap);
assertEquals("hello someName", nameDb);
nameDb = GrouperUtil.substituteExpressionLanguage("${if (true) { if
(true){ 'hello'; }}} ${if (true) { if (true){ 'hello'; }}} ${group.nameDb}",
substituteMap);
assertEquals("hello hello someName", nameDb);
}



-----Original Message-----
From: Colin Hudler
[mailto:]

Sent: Friday, June 11, 2010 1:35 PM
To:

Subject: Re: [grouper-users] Re: JEXL With Conditionals in media.properties

On 06/11/2010 12:16 PM, Chris Hyzer wrote:
<snip>
> I didn't really expect complex scripts with curlies... whoops. Btw,
> Grouper 1.6 has jexl2...
>
<snip>

Okay, for my simple needs in this case, jexl2 will work, since I can write

${empty subject.attr ? 'has it' : 'does not have it' }

instead of if () [else] with the curlies.

Also, thanks for the suggestions. I think I might just try a custom
method, or somehow make the need for it disappear.



Archive powered by MHonArc 2.6.16.

Top of Page