ファイルをエクスポートしようとしています。
私のコードは以下です:
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;
コードは、組織列を除く 3 つの列の値を書き込んでいます。なぜかわからない?
コードの何が問題なのかを特定するのを手伝ってくれませんか。または私が欠けているもの。
ところで、Organization 列は複数値です。つまり、その列には複数の値が含まれる場合があります。
したがって、最終出力は次のようになります。
IdentityName, UserName, WorkforceID, Organization
1, abc, 123, internal
1, abc, 123, external
どんな助けでも大歓迎です。