Community Tip - If community subscription notifications are filling up your inbox you can set up a daily digest and get all your notifications in a single email. X
Hello ,
My user have role " role001" in 3 differents ProductContext .
How can i get programmatically this 3 productContext when i login with my user .
Thank You
Solved! Go to Solution.
Hello @AB_9905442
You can use following code to get the contexts.
example contains user as a null but you need to find the WTUser.
WTUser user = null; // you need to search for the user WTPrincipal = WTUser
String contextRoleName = "PRODUCT MANAGER"; //internal context role name
Enumeration parentGroups = user.parentGroups();
while (parentGroups.hasMoreElements())
{
WTPrincipalReference wtref = (WTPrincipalReference) parentGroups.nextElement();
WTPrincipal principal = (WTPrincipal) wtref.getObject();
if (principal.getName().equalsIgnoreCase(contextRoleName))
{
if (principal instanceof WTGroup)
{
WTContainer container = ((WTGroup) principal).getContainer();
System.out.println(container.getName()); //this is the context
}
}
}
PetrH
Hello @AB_9905442
You can use following code to get the contexts.
example contains user as a null but you need to find the WTUser.
WTUser user = null; // you need to search for the user WTPrincipal = WTUser
String contextRoleName = "PRODUCT MANAGER"; //internal context role name
Enumeration parentGroups = user.parentGroups();
while (parentGroups.hasMoreElements())
{
WTPrincipalReference wtref = (WTPrincipalReference) parentGroups.nextElement();
WTPrincipal principal = (WTPrincipal) wtref.getObject();
if (principal.getName().equalsIgnoreCase(contextRoleName))
{
if (principal instanceof WTGroup)
{
WTContainer container = ((WTGroup) principal).getContainer();
System.out.println(container.getName()); //this is the context
}
}
}
PetrH