OIM API - Code Snippet to Get Catalog UDF Value.

public String getCatalogUDFValue(String entityKey, String entityType, String udfName) throws CatalogException {
        OIMType type;
        String udfValue;
                   
        //get catalog service
        CatalogService catalogService = Platform.getService(CatalogService.class);
        
        if("ApplicationInstance".equalsIgnoreCase(entityType))
            type = OIMType.ApplicationInstance;
        else if("Entitlement".equalsIgnoreCase(entityType))
            type = OIMType.Entitlement;
        else if("Role".equalsIgnoreCase(entityType))
            type = OIMType.Role;
        
        Catalog catalog = catalogService.getCatalogItemDetails(null, entityKey, type, null);
        List<MetaData> metadata = catalog.getMetadata();

        for(MetaData metadataObject : metadata){
            MetaDataDefinition metdataDefinition = metadataObject.getMetaDataDefinition();            
            String columnName = metdataDefinition.getDbColumnName();
            
            if(columnName.equalsIgnoreCase(udfName)){
                udfValue = metadataObject.getValue();
                System.out.println(udfValue);
            }
        }
       return udfValue; 
 }

No comments:

Post a Comment