By: valsaraj viswanathan user 23 Sep 2016 at 1 a.m. CDT

5 Responses
valsaraj viswanathan gravatar
Hi, I would like to know the user of manage custom scripts > cache refresh section. Is it possible to use this to print values of refreshed entries? It would be helpful if you can share more details, there is not much info available in https://gluu.org/docs/oxtrust/configuration/#manage-custom-scripts. Here is the python script in that section. When this will be triggered and where can we see the print messages? > from org.xdi.model.custom.script.type.user import CacheRefreshType > from org.xdi.util import StringHelper, ArrayHelper > from java.util import Arrays, ArrayList > from org.gluu.oxtrust.model import GluuCustomAttribute > > import java > > class CacheRefresh(CacheRefreshType): > def __init__(self, currentTimeMillis): > self.currentTimeMillis = currentTimeMillis > > def init(self, configurationAttributes): > print "Cache refresh. Initialization" > print "Cache refresh. Initialized successfully" > > return True > > def destroy(self, configurationAttributes): > print "Cache refresh. Destroy" > print "Cache refresh. Destroyed successfully" > return True > > # Update user entry before persist it > # user is org.gluu.oxtrust.model.GluuCustomPerson > # configurationAttributes is java.util.Map<String, SimpleCustomProperty> > def updateUser(self, user, configurationAttributes): > print "Cache refresh. UpdateUser method" > > attributes = user.getCustomAttributes() > > # Add new attribute preferredLanguage > # attrPrefferedLanguage = GluuCustomAttribute("preferredLanguage", "en-us") > # attributes.add(attrPrefferedLanguage) > > # Add new attribute userPassword > # attrUserPassword = GluuCustomAttribute("userPassword", "test") > # attributes.add(attrUserPassword) > > # Update givenName attribute > for attribute in attributes: > attrName = attribute.getName() > if (("givenname" == StringHelper.toLowerCase(attrName)) and StringHelper.isNotEmpty(attribute.getValue())): > print StringHelper.removeMultipleSpaces(attribute.getValue()) + " (updated)" > # attribute.setValue(StringHelper.removeMultipleSpaces(attribute.getValue()) + " (updated)") > > return True > > def getApiVersion(self): > return 1 Thanks!

By Mohib Zico Account Admin 23 Sep 2016 at 7:01 a.m. CDT

Mohib Zico gravatar
>> Is it possible to use this to print values of refreshed entries? It's already showing updated entries. Also possible to customize that python script and print any test value you want. CR related logs are: oxtrust_cache_refresh.log, oxtrust_cache_refresh_python.log.

By valsaraj viswanathan user 23 Sep 2016 at 7:21 a.m. CDT

valsaraj viswanathan gravatar
It is not showing values of updated entries, only showing n entries updated message. I checked oxtrust_cache_refresh.log and oxtrust_cache_refresh_python.log. oxtrust_cache_refresh_python.log size is 0. What I expect is when CR occurs, the values fetched and persisted from source ldap will be in oxtrust_cache_refresh_python.log. As per above script in question, I expect those print messages to appear in this log. Please clarify.

By Mohib Zico Account Admin 23 Sep 2016 at 7:38 a.m. CDT

Mohib Zico gravatar
>> As per above script in question, I expect those print messages to appear in this log. Please clarify. If you want to print something, you need to put print statements and what to print in python code; I don't see any.

By valsaraj viswanathan user 23 Sep 2016 at 7:54 a.m. CDT

valsaraj viswanathan gravatar
There is no message appeared in log.

By Mohib Zico Account Admin 23 Sep 2016 at 8:11 a.m. CDT

Mohib Zico gravatar
Have you ran Cache Refresh yet? If yes.. then please zip all logs under /opt/tomcat/logs/ and share with us; we will take a look.