cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Use this method to get a link attribute

Use this method to get a link attribute

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;
}
Comments

Hello,

This looks like a very useful utility. Thank you for sharing it!

I was wondering, though, why you set the "value" variable to an empty string then check later if it is an empty string in order to conditionally return null. I think if you initialize "value" to null and remove lines 14 through 18, the logic will be the same.

It might also be nice to have the "attributeValue" null check alone as the initial if-condition in your if-else-if chain.

Just a few ideas to streamline the logic, let me know if I missed something!

Erik

Erik, you are spot on. Thanks for pointing these out.

For getting identities for a particular link, the following can be used.

Filter filter1 = Filter.collectionCondition("links", (Filter.or(Filter.eq("application.name", "Active Directory"))));
QueryOptions qo = new QueryOptions();
qo.addFilter(filter1);
List idOb = context.getObjects(Identity.class, qo);

Version history
Revision #:
2 of 2
Last update:
‎May 09, 2023 08:05 PM
Updated by: