この章では、アプリケーション開発用のParlay X 2.1 Presence Web Servicesインタフェースに対するOCMSのサポートについて説明します。Webサービスは、Webサービスのユーザーにかわって通知を公開、サブスクライブおよびリスニングできるプレゼンス・ネットワーク・エージェントとして機能します。この章の内容は次のとおりです。
OCMSでは、「Open Service Access, Parlay X Presence Web Services, Part 14, Presence ETSI ES 202 391-14」仕様で定義されたParlay X Presence Web Serviceのパート14をサポートします。OCMS Parlay X Web Serviceは、「Open Service Access, Mapping of Parlay X Presence Web Services to Parlay/OSA APIs, Part 14, Presence Mapping, Subpart 2, Mapping to SIP/IMS Networks, ETSI TR 102 397-14-2」仕様に従って、Parlay X WebサービスをSIP/IMSネットワークにマップします。
注意: Webサービスの同期性により、Webサービスからコールバックを受信するには、クライアントはWebサービス・コールバック・インタフェースを実装する必要があります。Presenceの場合、必要なインタフェースは、「Open Service Access, Parlay X Presence Web Services, Part 14, Presence ETSI ES 202 391-14」で説明されているPresenceNotification インタフェースです。 |
Presence Web Serviceは、SIP/SIMPLEプロトコル・インタフェースを使用してIMSプレゼンス・ネットワーク要素と直接通信し、JSR-32 UACフレームワークを使用して、SIPネットワークと通信します。
Presence Web ServiceをホストするHTTPサーバーは、プレゼンス・ネットワーク・エージェントまたはParlay XからSIPへのゲートウェイです。
Presence Web Servicesは、次のインタフェースで構成されます。
PresenceConsumer: ウォッチャはこれらのメソッドを使用して、プレゼンス・データを取得します(表9-1)。
PresenceNotification: プレゼンス・コンシューマ・インタフェースは、このインタフェースで定義されたクライアント・コールバックを使用して通知を送信します(表9-2)。
PresenceNotificationListener: Parlay X PresenceNotificationインタフェースの上位にあるThin Javaラッパー・レイヤーです。Oracle拡張機能では、可能な場合、ユーザー・コンテキストが提供されます。クライアント・アプリケーションはこのインタフェースを実装し、PresenceNotificationListenerManager
のaddPresenceNotificationListener()メソッドを使用してこのインタフェースを登録する必要があります。管理者に登録すると、着信通知がある場合にインタフェースがコールされます。エンド・クライアントは、複数のリスナーを登録できます。すべてのリスナーは、着信通知があるたびにコールされます。SIPアドレス形式のユーザー・コンテキストは、コンテキスト・パラメータに渡されます。このクラスは、presencewsnotification-10.1.3.4.warに含まれています。
PresenceSupplier: プレゼンティティは、これらのメソッドを使用してプレゼンス・データを提供し、そのウォッチャによるデータへのアクセスを管理します(表9-3)。
操作 | 説明 |
---|---|
subscribePresence |
Webサービスは、プレゼンス・サーバーにSUBSCRIBEを送信します。 |
getUserPresence |
プレゼンティティのステータス変更が、SIP NOTIFYによって非同期でWebサービスに送信されるため、キャッシュされたプレゼンス・ステータスを戻します。Webサービスには、実際にはWebサービス・クライアントではなくサブスクリプションがあります。 |
startPresenceNotification |
ウォッチャが、ユーザー・プレゼンス・ステータスの通知を受信することを示します。 |
endPresenceNotification |
ウォッチャが、特定の通知リクエストに対してこれ以上の通知を望まないことを示します(相関器で識別)。 |
表9-2 PresenceNotificationインタフェース(PresenceNotificationListenerで使用)
操作 | 説明 |
---|---|
statusChanged |
非同期操作は、通知がリクエストされた属性が変わると、Webサービスによってコールされます。 |
statusEnd |
通知が終了しました。このメッセージは、通知終了のエラーが発生した場合や通知を意図的に終了する場合は配信されません(endPresenceNotification操作を使用)。 |
notifySubscription |
この非同期操作はWebサービスによってコールされ、サブスクリプションが終了したことをウォッチャ(アプリケーション)に通知します。典型的な理由として、基礎となるSIPソフト状態サブスクリプションがタイムアウトした場合や、該当ウォッチャへの追加のプレゼンス情報のブロックをプレゼンティティが決定した場合などがあります。 |
subscriptionEnded |
この非同期メソッドは、サーバーまたはプレゼンティティが保留中のサブスクリプションを処理したことをウォッチャに通知します。 |
操作 | 説明 |
---|---|
publish |
SIP PUBLISHに直接マップします。 |
getOpenSubscriptions |
任意のウォッチャがそのプレゼンス・データをサブスクライブするかどうかをチェックするために、プレゼンティティ(サプライヤ)によってコールされます。このメソッドにマップされるSIPメッセージはありません。Webサービス・サーバーで現在保留中のサブスクリプションを戻します。 |
updateSubscriptionAuthorization |
サプライヤはこのメソッドを使用して、オープン状態の保留中のサブスクリプションに応答します。XCAP PUTメッセージは、presence-ruleドキュメントを更新するためにXDMSサーバーに送信されます。 |
getMyWatchers |
Webサービス・サーバーからウォッチャのローカル・リストを取得します。 |
getSubscribedAttributes |
Webサービス・サーバーから、サブスクライブされた属性のローカル・リストを取得します。現在は、Activityのみを戻します。 |
blockSubscription |
XDMSサーバーでXCAPドキュメントを変更して(ブロック・リストにウォッチャを入れて)、Webサービス・サーバーでのウォッチャ・サブスクリプションを終了させます。 |
この項では、インタフェースでの各操作の使用方法を、コード例を使用して説明します。
これは、このインタフェースで別の操作を使用する前に、アプリケーションがコールする必要のある最初の操作です。この操作では次の2つの目的を果します。
Webサービスで、現在のHTTPセッションとユーザーを関連付けられるようにします。
少なくとも1つのプレゼンティティ(SUBSCRIBEプレゼンス・イベント)をサブスクライブして、このインタフェースで他のすべての操作にコンテキストを提供します。
// Setting the attribute to activity PresenceAttributeType pa = PresenceAttributeType.Activity; PresenceAttributeType[] pat = new PresenceAttributeType[]{pa}; // These inputs are required but not used. SimpleReference sr = new SimpleReference(); sr.setCorrelator("unique_correlator"); sr.setInterfaceName("PresenceNotification"); sr.setEndpoint(new URI ("http://127.0.0.1:8088/presencenotification/PresenceNotification")); // Calling the web service consumer.subscribePresence (new URI ("sip.presentity@test.example.com") , pat, "webcenter", sr);
サブスクライブされたプレゼンティティのプレゼンスを取得するには、この操作をコールします。そのユーザーがオフラインの場合、ActivityNone
が戻され、PresenceAttribute.note
にハードステートが書き込まれます。ActivityOther
が戻される場合、OtherValue
フィールドにアクティビティの説明が戻されます。
Name
フィールドがServiceAndDeviceNoteと等価である場合、OtherValue
は、サービス・メモとデバイス・メモを組み合せたものになります。プレゼンティティが複数のクライアントに記録される場合、複数のServiceAndDeviceNoteが存在する可能性があることに注意してください。
PresenceAttributeType pat = new PresenceAttributeType(){PresenceAttributeType.Activity}; PresenceAttribute[] resultPA = consumer.getUserPresence(new URI(presentity),pat); for (int i = 0; i < resultPA.length; i++){ PresenceAttribute pa = resultPA[i]; // Check to see if it is an activity type. if (pa.getTypeAndValue().getUnionElement() == PresenceAttributeType.Activity){ // Get the presence status. System.out.println("Activity: " + pa.getTypeAndValue().getActivity().toString()); // Get the customized presence note. if (pa.getNote().length() > 0){ System.out.println("Note: " + pa1.getNote()); } } // If this is of type Other, then we need to extract // different type of information. if (pa.getTypeAndValue().getUnionElement() == PresenceAttributeType.Other){ // This is "ActivityOther", a custom presence status. if (pa.getTypeAndValue().getOther() .getName().compareToIgnoreCase("ActivityOther") == 0){ System.out.println("Other Activity->" + pa.getTypeAndValue().getOther().getValue() + "\n"); } else { // Currently, the only other value beside ActivityOther is // "ServiceAndDeviceNote" which is the service note + // device note. System.out.println("Combined Note->" + pa.getTypeAndValue().getOther().getValue() + "\n"); } } }
この操作は、ウォッチャがユーザー・プレゼンス・ステータスの通知を受信することを示します。
SimpleReference sr = getNotificationReference(presentity); TimeMetric freq = new TimeMetric(); freq.setMetric(TimeMetrics.Minute); TimeMetric duration = new TimeMetric(); duration.setMetric(TimeMetrics.Minute); PresenceAttributeType pa = PresenceAttributeType.Activity; PresenceAttributeType[] pat = new PresenceAttributeType[] { pa }; mConsumer.startPresenceNotification(new URI(presentity), pat, sr, freq, duration, 0, false);
この操作は、ウォッチャが特定の通知リクエストに対してこれ以上の通知を望まないことを示します(相関器で識別)。
これは、このインタフェースで別の操作を使用する前に、アプリケーションがコールする必要のある最初の操作です。この操作では次の3つの目的を果します。
Webサービスで、現在のHTTPセッションとユーザーを関連付けられるようにします。
ユーザーのプレゼンス・ステータスを公開します。
Webサービスがウォッチャ・リクエストを追跡できるようにwatcher-infoをサブスクライブします。
PUBLISHを実行する際、関連する属性が3つあります。これらの属性をPresenceAttribute構造に設定して、PUBLISHメソッドに渡すことができます。
カスタマイズ・メモのあるプレゼンス・ステータス: これはOracle Communicatorの「My Presence」テキスト・ボックスに構成されたカスタマイズ・メモです。<note>要素は、プレゼンス情報データ・フォーマット(PIDF)XMLファイルの<person> 要素に含まれています。
デバイス・メモ: Oracle Communicatorによって暗黙的に挿入されます。またはWebサービスから挿入されます。<note>要素は、プレゼンス情報データ・フォーマット(PIDF)XMLファイルの<device>要素に含まれています。
サービス・メモ: Oracle Communicatorプリファレンスの「Presence」タブに構成されています。<note>要素は、プレゼンス情報データ・フォーマット(PIDF)XMLファイルの<tuple>要素に含まれています。
// PresenceAttribute contains presence status and note. typeValue.setUnionElement(PresenceAttributeType.Activity); typeValue.setActivity(activity); paActivity.setTypeAndValue(typeValue); // Setting the customized note here. paActivity.setNote(activityNote); paActivity.setLastChange(dateTime); // Create the PresenceAttribute containing device note. AttributeTypeAndValue typeValueOther = createATV(); PresenceAttribute paOther = new PresenceAttribute(); // Device note is carried in a PresenceAttributeType.Other typeValueOther.setUnionElement(PresenceAttributeType.Other); // Set the name to "DeviceNote" to indicate the value // should be used as device note. other.setName("DeviceNote"); other.setValue(deviceName); typeValueOther.setOther(other); paOther.setTypeAndValue(typeValueOther); // Create the PresenceAttribute containing service note. AttributeTypeAndValue typeValueOther1 = createATV(); PresenceAttribute paOther1 = new PresenceAttribute(); // Service note is carried in another // PresenceAttributeType.Other typeValueOther1.setUnionElement(PresenceAttributeType.Other); OtherValue other1 = new OtherValue(); // Set the name to "ServiceNote" to indicate the value // should be used as device note. other1.setName("ServiceNote"); other1.setValue(serviceName); typeValueOther1.setOther(other1); paOther1.setTypeAndValue(typeValueOther1); // The note is not used. Can be anything. paOther1.setNote("OracleExtension"); paOther1.setLastChange(dateTime); //Unpublish Functionality Implemented by OCMS //To perform an "Unpublish", set OtherValue to (Expires, 0) //OtherValue other = new OtherValue(); //other.setName("Expires"); //other.setValue(0); //typeValue.setOther (other); //typeValue.setUnionElement(PresenceAttributeTypeOther); paArray = new PresenceAttribute[]{paActivity,paOther,paOther1}; // Calling the publish method by passing the PresenceAttribute // array containing the presence status, device note and service // note. publish(paArray);
この操作では、ブロック・リストまたは許可リストにウォッチャを入れることができます。
OCMSでは、Parlay X標準例外に対する2つの拡張機能を導入しています。
PresencePolicyExceptionはPolicyExceptionを拡張します。
PresenceServiceExceptionはServiceExceptionを拡張します。
表9-4と表9-5では、エラー・コードと関連するエラー・メッセージについて説明しています。
表9-4 OCMS Parlay X Presenceカスタム・エラー・コード: PresencePolicyException
エラー・コード | エラー・メッセージ |
---|---|
SDP20201 |
Watcher is on the block, polite-block or pending list. |
SDP20202 |
Subscription is pending. |
表9-5 OCMS Parlay X Presenceカスタム・エラー・コード: PresenceServiceException
エラー・コード | エラー・メッセージ |
---|---|
SDP20101 |
Invalid result from XDMS server. |
SDP20102 |
Invalid HTTP session data. |
SDP20103 |
Invalid URI. |
SDP20104 |
Peer unavailable. |
SDP20105 |
Unknownhost. |
SDP20106 |
Service not available. |
SDP20107 |
Internal error. |
SDP20108 |
User unauthenticated. |