Hi People,
One of the most common operations in any of IIQ projects is to get link attribute value for various business use case operations. For example, you may need to fetch the samAccountName of an AD user for, lets say generating a LAN ID or we may need to fetch msExchHideFromAddressLists for checking GAL visibility of an Exchange user or maybe need LASTUSEDATE of a Mainframe application to check inactivity.
Here is a simple utility method which can be reused every time. Remember to check for empty or null link / string before calling this method. Happy coding!
public String getLinkValue (Link link, String anyAttribute){
log.debug("Start method getLinkValue.");
Object attributeValue = link.getAttribute(anyAttribute);
String value = null;
if (attributeValue!=null){
if (attributeValue instanceof String){
value = (String)attributeValue;
} else if (attributeValue instanceof List){
for (String each : attributeValue){
value=value+each;
}
} else if (attributeValue instanceof Boolean){
value=(String)attributeValue.toString();
}
}
log.debug("End method getLinkValue.");
return value;
}