ヘッダーをスキップ
Oracle Communication and Mobility Server管理者ガイド
10gリリース3(10.1.3)
B50835-01
  目次
目次
索引
索引

戻る
戻る
 
次へ
次へ
 

9 OCMS Parlay X Presence Web Services

この章では、アプリケーション開発用の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インタフェースの説明

Presence Web Servicesは、次のインタフェースで構成されます。

表9-1 PresenceConsumerインタフェース

操作 説明

subscribePresence

Webサービスは、プレゼンス・サーバーにSUBSCRIBEを送信します。

getUserPresence

プレゼンティティのステータス変更が、SIP NOTIFYによって非同期でWebサービスに送信されるため、キャッシュされたプレゼンス・ステータスを戻します。Webサービスには、実際にはWebサービス・クライアントではなくサブスクリプションがあります。

startPresenceNotification

ウォッチャが、ユーザー・プレゼンス・ステータスの通知を受信することを示します。

endPresenceNotification

ウォッチャが、特定の通知リクエストに対してこれ以上の通知を望まないことを示します(相関器で識別)。


表9-2 PresenceNotificationインタフェース(PresenceNotificationListenerで使用)

操作 説明

statusChanged

非同期操作は、通知がリクエストされた属性が変わると、Webサービスによってコールされます。

statusEnd

通知が終了しました。このメッセージは、通知終了のエラーが発生した場合や通知を意図的に終了する場合は配信されません(endPresenceNotification操作を使用)。

notifySubscription

この非同期操作はWebサービスによってコールされ、サブスクリプションが終了したことをウォッチャ(アプリケーション)に通知します。典型的な理由として、基礎となるSIPソフト状態サブスクリプションがタイムアウトした場合や、該当ウォッチャへの追加のプレゼンス情報のブロックをプレゼンティティが決定した場合などがあります。

subscriptionEnded

この非同期メソッドは、サーバーまたはプレゼンティティが保留中のサブスクリプションを処理したことをウォッチャに通知します。


表9-3 PresenceSupplierインタフェース

操作 説明

publish

SIP PUBLISHに直接マップします。

getOpenSubscriptions

任意のウォッチャがそのプレゼンス・データをサブスクライブするかどうかをチェックするために、プレゼンティティ(サプライヤ)によってコールされます。このメソッドにマップされるSIPメッセージはありません。Webサービス・サーバーで現在保留中のサブスクリプションを戻します。

updateSubscriptionAuthorization

サプライヤはこのメソッドを使用して、オープン状態の保留中のサブスクリプションに応答します。XCAP PUTメッセージは、presence-ruleドキュメントを更新するためにXDMSサーバーに送信されます。

getMyWatchers

Webサービス・サーバーからウォッチャのローカル・リストを取得します。

getSubscribedAttributes

Webサービス・サーバーから、サブスクライブされた属性のローカル・リストを取得します。現在は、Activityのみを戻します。

blockSubscription

XDMSサーバーでXCAPドキュメントを変更して(ブロック・リストにウォッチャを入れて)、Webサービス・サーバーでのウォッチャ・サブスクリプションを終了させます。


Presence Web Servicesインタフェースの使用

この項では、インタフェースでの各操作の使用方法を、コード例を使用して説明します。

インタフェース: PresenceConsumer、操作: subscribePresence

これは、このインタフェースで別の操作を使用する前に、アプリケーションがコールする必要のある最初の操作です。この操作では次の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);

インタフェース: PresenceConsumer、操作: getUserPresence

サブスクライブされたプレゼンティティのプレゼンスを取得するには、この操作をコールします。そのユーザーがオフラインの場合、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");
    }
  }
}

インタフェース: PresenceConsumer、操作: startPresenceNotification

この操作は、ウォッチャがユーザー・プレゼンス・ステータスの通知を受信することを示します。

コード例

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);

インタフェース: PresenceConsumer、操作: endPresenceNotification

この操作は、ウォッチャが特定の通知リクエストに対してこれ以上の通知を望まないことを示します(相関器で識別)。

コード例

// Pass in the correlator used in startPresenceNotification.
mConsumer.endPresenceNotification(correlator);

インタフェース: PresenceSupplier、操作: publish and Oracle Specific Remove Presence

これは、このインタフェースで別の操作を使用する前に、アプリケーションがコールする必要のある最初の操作です。この操作では次の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);

インタフェース: PresenceSupplier、操作: getOpenSubscriptions

この操作では、ウォッチャ・リストに入れる新しいリクエストのリストを取得します。

コード例

SubscriptionRequest[] srArray = getOpenSubscriptions();
for (SubscriptionRequest sr:srArray) {
    System.out.println(sr.getWatcher() .toString());
}

インタフェース: PresenceSupplier、操作: updateSubscriptionAuthorization

この操作では、ブロック・リストまたは許可リストにウォッチャを入れることができます。

コード例

 //You always pass in Activity
pp.set.PresenceAttribute(PresenceAttributeType.Activity);
updateSubscriptionAuthorization(new URI("sip:allow@test.example.com"),
new PresencePermission[]{pp});
PresencePermission pp = new PresencePermission();
pp.setDecision(true);
//Put the user on the allow list

インタフェース: PresenceSupplier、操作: getMyWatchers

この操作では、許可リストのウォッチャのリストを取得します。

コード例

 URI[] uris;
uris = getMyWatchers();
for (URI uri:uris)
    System.out.println(uri.toString());

インタフェース: PresenceSupplier、操作: getSubscribedAttributes

この操作では、PresenceTypeAttribute.Activityの1つの項目のみが戻されます。既存のサブスクリプションが存在しない場合、例外がスローされます。

コード例

PresenceAttributeType[] pat =
getSubscriberdAttributes("sip:watcher@test.example.com");

インタフェース: PresenceSupplier、操作: blockSubscription

この操作では、ウォッチャがブロック・リストに入れられます。

コード例

blockSubscription(new URI("sip:block.this.watcher@test.example.com"));

OCMS Parlay X Presenceカスタム・エラー・コード

OCMSでは、Parlay X標準例外に対する2つの拡張機能を導入しています。

表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.