Corporation Server User Manual

Using the Presence Web Services Interfaces
6-4 Oracle Communication and Mobility Server Developer’s Guide
// These inputs are required but not used.
SimpleReference sr = new SimpleReference();
sr.setCorrelator("unused_correlator");
sr.setInterfaceName("unused_interfacename");
sr.setEndpoint(new URI ("http://unused.com"));
// Calling the web service
consumer.subscribePresence (new URI
("sip.presentity@test.example.com") , pat, "unused", sr);
Interface: PresenceConsumer, Operation: getUserPresence
Call this operation to retrieve a subscribed presentity presence. If the person is offline,
it returns ActivityNone and the hardstate note will be written to
PresenceAttribute.note. If it returns ActivityOther, the description of the
activity is returned in the OtherValue field.
If the Name field is equal to "ServiceAndDeviceNote", OtherValue is a combination
of the service note and the device note. Note that there can be more than one
"ServiceAndDeviceNote" when the presentity is logged into multiple clients.
Code Example
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");
}
}
}