Reputation: 43
I am trying to export the file.
my Code is below:
import java.io.FileWriter;
import java.io.File;
import java.io.BufferedWriter;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.*;
String appname = "Abc";
String path = "//home/exportfile//";
String filename = path+"ApplicationExport-"+appname+".txt";
String ret = "false";
QueryOptions ops = new QueryOptions();
Filter [] filters = new Filter[1];
filters[0] = Filter.eq("application.name", appname);
ops.add(filters);
List props = new ArrayList();
props.add("identity.name");
//Do search
Iterator it = context.search(Link.class, ops, props);
//Build file and export header row
BufferedWriter out = new BufferedWriter(new FileWriter(filename));
out.write("IdentityName,UserName,WorkforceID,Organization");
out.newLine();
//Iterate Search Results
if (it!=null)
{
while ( it.hasNext() ) {
//Get link and create object
Object [] record = it.next();
String identityName = (String) record[0];
Identity user = (Identity) context.getObject(Identity.class, identityName);
//Get Identity attributes for export
String workforceid = (String) user.getAttribute("workforceID");
//Get application attributes for export
String userid="";
String org="";
List links = user.getLinks();
if (links!=null)
{
Iterator lit = links.iterator();
while (lit.hasNext())
{
Link l = lit.next();
String lname = l.getApplicationName();
if (lname.equalsIgnoreCase(appname))
{
userid = (String) l.getAttribute("User Name");
sailpoint.tools.xml.PersistentArrayList orgList = (sailpoint.tools.xml.PersistentArrayList) l.getAttribute("Organization");
}
}
}
//Output file
out.write(identityName+","+userid+","+workforceid+","+org);
out.newLine();
out.flush();
}
ret="true";
}
//Close file and return
out.close();
return ret;
Code is writing the value for 3 columns except Organization column. Not sure why?
Can you pls help me to identify what is wrong with the code. Or what i am missing.
By the way, Organization column is multivalue i.e. that column might have more than one value.
so the final output should be,
IdentityName, UserName, WorkforceID, Organization
1, abc, 123, internal
1, abc, 123, external
Any help would be greatly appreciated.
Upvotes: 0
Views: 1040
Reputation: 17930
you defined org=""
so it'll write an empty string.
You get an organization list:
sailpoint.tools.xml.PersistentArrayList orgList = (sailpoint.tools.xml.PersistentArrayList) l.getAttribute("Organization");
this object probably have methods for getting the values you need, so you can do something like:
org = orgList.getOrganization();
Of course this is just an example, since i don't know the exact structure of the object, using an IDE you can explore the different methods this object has and find out what you need.
Upvotes: 0
Reputation: 66637
String org=""; is empty. It seems no where you assigned value to org, so empty value is being written to file.
Upvotes: 1