2017-06-23 14 views
1

免責事項:Javaは私がよく知っている言語ではありません。
私はアイデンティティプラットフォームのプロジェクトに取り組んでいます。エンタイトルメントクラスを使用してエンタイトルメントのリストを取得しようとしていますが、私の関数を呼び出すときにデータを出力できません。以下は私が現在持っているコードです。Javaからの戻り値

import sailpoint.api.SailPointContext; 
import sailpoint.tools.Util; 
import sailpoint.object.*; 
import sailpoint.api.*; 
import sailpoint.workflow.*; 
import java.util.*;  

    QueryOptions ops = new QueryOptions(); //This creates the Query Options 
    ops.addFilter(Filter.eq("identity.name", "UserNAME")); //Defines the Identity/IdentityName that we are searching for 

    Iterator itr = context.search(IdentityEntitlement.class, ops, "id"); //Java iterator is an interface belongs to collection framework allow us to traverse the collection and access the data element of collection without bothering the user about specific implementation of that collection it. Basically List and set collection provides the iterator. You can get Iterator from ArrayList, LinkedList, and TreeSet etc. 
    while (null != itr && itr.hasNext()) { //Run this this iteration while not null 
    String id = ((Object[]) itr.next())[0].toString(); //collect the object as a string 
    IdentityEntitlement identEnt = context.getObjectById(IdentityEntitlement.class, id); //define the IdentityEntitlement from (IdentityEntitlement.class, id); 
    System.out.println("identEnt: "+identEnt.toXml()); //Print the results 
    } 
    Util.flushIterator(itr); //End the Iterator 
+1

[最初にコードを書いてください](https://stackoverflow.com/posts/44722411/edit) –

+0

メソッドが定義されていません。あなたは何の「機能」を呼んでいますか?そして、これが "function"内のコード(Javaのメソッドと呼ばれます)の場合、呼び出し側のアクションに何かが返されていることを示す 'return'ステートメントはありません。 – Gregg

+0

私はギラードのためにそれを修正していただきありがとうございます。それは実際にはこれです:itr &&:これはbeanshell特有の問題です。 – jmsahearn

答えて

1

出力が表示されない理由の1つは、while()ループに入っていないためです。

I)は(一部訂正がしばらく行われる必要があると考える条件

while(itr.hasNext()) 
    String id = ((Object[]) itr.next())[0].toString(); 
    IdentityEntitlement identEnt =  context.getObjectById(IdentityEntitlement.class, id); 
    System.out.println("identEnt: "+identEnt.toXml()); 

あなたがこれを行う場合、あなたはおそらくあなたが探している結果を得るでしょう。

これが役立つかどうかを確認してください。

+0

戻りオブジェクトは、IdentityEntitlementを返しますか? – jmsahearn

+0

@jmsahearn答えを編集しましたので、今すぐ確認してください。 – julianff

+0

@julianff BeanShellエラーが発生しましたが、進捗しています。 – jmsahearn