Revision: 17394
Author: emmartins
Date: Fri Mar 18 05:55:40 2011
Log: Update Issue 2340
Functionalities needed in the SIP Subscription Client enabler, to send
subscribe's with content and event params.
http://code.google.com/p/mobicents/source/detail?r=17394
Modified:
/trunk/servers/jain-slee/enablers/sip-subscription-client/example/sbb/src/main/java/org/mobicents/slee/enabler/sip/example/SubscriptionClientParentSbb.java
/trunk/servers/jain-slee/enablers/sip-subscription-client/sbb/src/main/java/org/mobicents/slee/enabler/sip/SubscriptionClientChild.java
/trunk/servers/jain-slee/enablers/sip-subscription-client/sbb/src/main/java/org/mobicents/slee/enabler/sip/SubscriptionClientChildSbb.java
/trunk/servers/jain-slee/enablers/sip-subscription-client/sbb/src/main/java/org/mobicents/slee/enabler/sip/SubscriptionException.java
/trunk/servers/jain-slee/enablers/sip-subscription-client/sbb/src/main/resources/META-INF/sbb-jar.xml
=======================================
---
/trunk/servers/jain-slee/enablers/sip-subscription-client/example/sbb/src/main/java/org/mobicents/slee/enabler/sip/example/SubscriptionClientParentSbb.java
Wed Jan 5 22:39:10 2011
+++
/trunk/servers/jain-slee/enablers/sip-subscription-client/example/sbb/src/main/java/org/mobicents/slee/enabler/sip/example/SubscriptionClientParentSbb.java
Fri Mar 18 05:55:40 2011
@@ -98,7 +98,7 @@
try {
child = (SubscriptionClientChildSbbLocalObject)
this.getSubscriptionClientChildSbbChildRelation().create();
child.setParentSbb((SubscriptionClientParentSbbLocalObject)
this.sbbContext.getSbbLocalObject());
-
child.subscribe("sip:[email protected]:5090", "secret_name", "sip:[email protected]:5090", "presence",
61, "application", "pidf+xml"); // null
+
child.subscribe("sip:[email protected]:5090", "secret_name", "sip:[email protected]:5090",
61, "presence",null, "application", "pidf+xml"); // null
} catch (TransactionRequiredLocalException e) {
// TODO Auto-generated catch block
e.printStackTrace();
=======================================
---
/trunk/servers/jain-slee/enablers/sip-subscription-client/sbb/src/main/java/org/mobicents/slee/enabler/sip/SubscriptionClientChild.java
Wed Jan 5 22:39:10 2011
+++
/trunk/servers/jain-slee/enablers/sip-subscription-client/sbb/src/main/java/org/mobicents/slee/enabler/sip/SubscriptionClientChild.java
Fri Mar 18 05:55:40 2011
@@ -17,6 +17,8 @@
*/
package org.mobicents.slee.enabler.sip;
+import java.util.Map;
+
/**
*
* Interface for SIP-Subscruption-Client.
@@ -39,21 +41,34 @@
public String getNotifier();
- // TODO: should there be eventTemplate also ?
/**
* creates an internal subscription
*
- * @param subscriber
- * @param notifier
- * @param eventPackage
- * @param subscriptionId
- * @param expires
- * @param contentType
- * @param contentSubtype
+ * @param subscriber - usually an URI, for instance
sip:[email protected]. It identifies entity on behalf which enabler
wants to subscribe
+ * @param notifier - usually an URI identifying notifier.
+ * @param expires - timeout value, measured in seconds, it indicates time
gap between resubscribes/termination of subscription
+ * @param eventPackage - event package to which subscirber wants to
subscribe, ie. <b>presence</b>, <b>presence.oma</b>,<b>xcap-diff</b> .. etc.
+ * @param eventsParameters - parameters which should be passed with
event, ie. <b>diff-processing</b>
+ * @param acceptedContentType - main MIME type of expected event content
+ * @param acceptedContentSubtype - sub MIME type of expected event
content
* @throws SubscriptionException
*/
- public void subscribe(String subscriber, String subscriberdisplayName,
String notifier, String eventPackage, int expires,
- String contentType, String contentSubtype) throws
SubscriptionException;
+ public void subscribe(String subscriber, String subscriberdisplayName,
String notifier, int expires, String eventPackage, Map<String, String>
eventsParameters,
+ String acceptedContentType, String acceptedContentSubtype) throws
SubscriptionException;
+
+ /**
+ * Similar to
+ * {@link #subscribe(String, String, String, int, String, Map, String,
String)}
+ * , however this method allows to send content within subscribe. It is
+ * useful in case like XCAP Diff subscription for instance.
+ *
+ * @param contentType - main MIME type of content
+ * @param contentSubType - sub MIME type of content
+ * @param content - content, ie. xml resource list.
+ * @throws SubscriptionException
+ */
+ public void subscribe(String subscriber, String subscriberdisplayName,
String notifier, int expires, String eventPackage, Map<String, String>
eventParameters,
+ String acceptedContentType, String acceptedContentSubtype, String
contentType, String contentSubType, String content) throws
SubscriptionException;
/**
* Requests the termination of an internal subscription.
=======================================
---
/trunk/servers/jain-slee/enablers/sip-subscription-client/sbb/src/main/java/org/mobicents/slee/enabler/sip/SubscriptionClientChildSbb.java
Thu Jan 6 06:13:04 2011
+++
/trunk/servers/jain-slee/enablers/sip-subscription-client/sbb/src/main/java/org/mobicents/slee/enabler/sip/SubscriptionClientChildSbb.java
Fri Mar 18 05:55:40 2011
@@ -1,6 +1,8 @@
package org.mobicents.slee.enabler.sip;
import java.text.ParseException;
+import java.util.HashMap;
+import java.util.Map;
import javax.naming.Context;
import javax.naming.InitialContext;
@@ -93,10 +95,11 @@
public String getNotifier() {
return getNotifierCMP();
}
+
@Override
- public void subscribe(String subscriber, String subscriberdisplayName,
String notifier, String eventPackage, int expires,
- String contentType, String contentSubType) throws SubscriptionException
{
+ public void subscribe(String subscriber, String subscriberdisplayName,
String notifier, int expires, String eventPackage, Map<String, String>
eventOpts,
+ String acceptedContentType, String acceptedContentSubtype, String
contentType, String contentSubType, String content) throws
SubscriptionException {
if (getSubscriber() != null) {
throw new IllegalStateException("Active subscription found for: " +
getSubscriber() + ", events: " + getEventPackage());
}
@@ -122,21 +125,36 @@
}
// content MAY be null? contentType and contentSubType MUST not
- if (contentType == null) {
- throw new IllegalArgumentException("contentType argument must not be
null!");
- }
- if (contentSubType == null) {
- throw new IllegalArgumentException("contentSubType argument must not be
null!");
+ if (acceptedContentType == null) {
+ throw new IllegalArgumentException("acceptedContentType argument must
not be null!");
+ }
+ if (acceptedContentSubtype == null) {
+ throw new IllegalArgumentException("acceptedContentSubtype argument
must not be null!");
}
+ if(content!=null)
+ {
+ if (contentType == null) {
+ throw new IllegalArgumentException("contentType argument must not be
null!");
+ }
+ if (contentSubType == null) {
+ throw new IllegalArgumentException("contentSubType argument must not
be null!");
+ }
+ }
+
// store all data.
this.setSubscriberCMP(subscriber);
this.setNotifierCMP(notifier);
+ this.setAcceptedContentTypeCMP(acceptedContentType);
+ this.setAcceptedContentSubTypeCMP(acceptedContentSubtype);
+ this.setEventPackageCMP(eventPackage);
+ this.setEventParametersCMP( new HashMap<String,String>(
eventOpts));
+
+ //also store content if present, this is used for proper forging
refresh requests
this.setContentTypeCMP(contentType);
this.setContentSubTypeCMP(contentSubType);
- this.setEventPackageCMP(eventPackage);
-
+ this.setContentCMP(content);
// lets get started
ActivityContextInterface aci = null;
try {
@@ -145,7 +163,8 @@
Address to = addressFactory.createAddress(notifier);
DialogActivity dialogActivity =
sleeSipProvider.getNewDialog(from,to);
- Request subscribeRequest = createInitialSubscribe(dialogActivity,
eventPackage, expires, contentType, contentSubType);
+ Request subscribeRequest = createInitialSubscribe(dialogActivity,
expires, eventPackage,eventOpts ,acceptedContentType,
acceptedContentSubtype, contentType, contentSubType, content);
+
// DA
aci =
this.sipActivityContextInterfaceFactory.getActivityContextInterface(dialogActivity);
setSubscribeRequestTypeCMP(SubscribeRequestType.NEW);
@@ -172,6 +191,13 @@
}
throw new SubscriptionException("Failed to create dialog or send
SUBSRIBE", e);
}
+
+ }
+
+ @Override
+ public void subscribe(String subscriber, String subscriberdisplayName,
String notifier, int expires,String eventPackage, Map<String, String>
eventOpts,
+ String acceptedContentType, String acceptedSubType) throws
SubscriptionException {
+ this.subscribe(subscriber, subscriberdisplayName, notifier, expires,
eventPackage, eventOpts, acceptedContentType, acceptedSubType, null, null,
null);
}
@Override
@@ -216,7 +242,11 @@
public abstract String getSubscriberCMP();
public abstract void setSubscriberCMP(String s);
-
+
+ public abstract void setEventParametersCMP(HashMap<String,String> opts);
//note cant be generic Map interface, cause its not serializable.
+
+ public abstract HashMap<String,String> getEventParametersCMP();
+
public abstract String getNotifierCMP();
public abstract void setNotifierCMP(String s);
@@ -225,6 +255,14 @@
public abstract void setExpiresCMP(int s);
+ public abstract String getAcceptedContentTypeCMP();
+
+ public abstract void setAcceptedContentTypeCMP(String s);
+
+ public abstract String getAcceptedContentSubTypeCMP();
+
+ public abstract void setAcceptedContentSubTypeCMP(String s);
+
public abstract String getContentTypeCMP();
public abstract void setContentTypeCMP(String s);
@@ -232,6 +270,10 @@
public abstract String getContentSubTypeCMP();
public abstract void setContentSubTypeCMP(String s);
+
+ public abstract String getContentCMP();
+
+ public abstract void setContentCMP(String s);
public abstract SubscribeRequestType getSubscribeRequestTypeCMP();
@@ -372,7 +414,7 @@
notify.setContentSubType(contentType.getContentSubType());
notify.setContent(new String(request.getRawContent()));
notify.setNotifier(getNotifierCMP());
- notify.setSubscriber(getSubscriberCMP());
+ notify.setSubscriber(getSubscriberCMP());
// check, whats in header.
SubscriptionStateHeader subscriptionStateHeader =
(SubscriptionStateHeader) request.getHeader(SubscriptionStateHeader.NAME);
@@ -588,6 +630,9 @@
}
/**
+ * @param content
+ * @param contentSubType
+ * @param contentType
* @param subscriber
* @param subscriberdisplayName
* @param notifier
@@ -597,8 +642,8 @@
* @throws InvalidArgumentException
* @throws SipException
*/
- protected Request createInitialSubscribe(DialogActivity da, String
eventPackage, int expires,
- String contentType, String contentSubType) throws ParseException,
InvalidArgumentException, SipException {
+ protected Request createInitialSubscribe(DialogActivity da, int
expires,String eventPackage, Map<String, String> eventsOptions,
+ String acceptedContentType, String acceptedCubType, String contentType,
String contentSubType, String content) throws ParseException,
InvalidArgumentException, SipException {
final Request request = da.createRequest(Request.SUBSCRIBE);
@@ -608,9 +653,16 @@
request.setHeader(contactHeader);
EventHeader eventHeader =
this.headerFactory.createEventHeader(eventPackage);
+ if(eventsOptions!=null)
+ {
+ for(Map.Entry<String, String> e:
eventsOptions.entrySet())
+ {
+ eventHeader.setParameter(e.getKey(),
e.getValue());
+ }
+ }
request.addHeader(eventHeader);
- AcceptHeader acceptHeader =
this.headerFactory.createAcceptHeader(contentType, contentSubType);
+ AcceptHeader acceptHeader =
this.headerFactory.createAcceptHeader(acceptedContentType, acceptedCubType);
request.addHeader(acceptHeader);
ExpiresHeader expiresHeader =
this.headerFactory.createExpiresHeader(expires);
@@ -622,6 +674,13 @@
request.addHeader(routeHeader);
}
+ //now add content if present
+ if(content!=null)
+ {
+ ContentTypeHeader cth =
this.headerFactory.createContentTypeHeader(contentType, contentSubType);
+ request.setContent(content.getBytes(), cth); //this will set Content
Length Header
+ }
+
return request;
}
@@ -648,12 +707,21 @@
ExpiresHeader expiresHeader =
this.headerFactory.createExpiresHeader(expires);
request.addHeader(expiresHeader);
+ //TODO: store event header in cmp?
EventHeader eventHeader = (EventHeader)
request.getHeader(EventHeader.NAME);
if (eventHeader == null) {
eventHeader =
this.headerFactory.createEventHeader(getEventPackageCMP());
+ if(getEventParametersCMP()!=null)
+ {
+ for(Map.Entry<String, String> e:
getEventParametersCMP().entrySet())
+ {
+ eventHeader.setParameter(e.getKey(),
e.getValue());
+ }
+ }
request.addHeader(eventHeader);
- }
- AcceptHeader acceptHeader =
this.headerFactory.createAcceptHeader(getContentTypeCMP(),
getContentSubTypeCMP());
+
+ }
+ AcceptHeader acceptHeader =
this.headerFactory.createAcceptHeader(getAcceptedContentTypeCMP(),
getAcceptedContentSubTypeCMP());
request.addHeader(acceptHeader);
return request;
=======================================
---
/trunk/servers/jain-slee/enablers/sip-subscription-client/sbb/src/main/java/org/mobicents/slee/enabler/sip/SubscriptionException.java
Tue Dec 28 07:40:22 2010
+++
/trunk/servers/jain-slee/enablers/sip-subscription-client/sbb/src/main/java/org/mobicents/slee/enabler/sip/SubscriptionException.java
Fri Mar 18 05:55:40 2011
@@ -26,7 +26,7 @@
/**
*
*/
- SubscriptionException() {
+ public SubscriptionException() {
super();
// TODO Auto-generated constructor stub
}
@@ -35,7 +35,7 @@
* @param message
* @param cause
*/
- SubscriptionException(String message, Throwable cause) {
+ public SubscriptionException(String message, Throwable cause) {
super(message, cause);
// TODO Auto-generated constructor stub
}
@@ -43,7 +43,7 @@
/**
* @param message
*/
- SubscriptionException(String message) {
+ public SubscriptionException(String message) {
super(message);
// TODO Auto-generated constructor stub
}
@@ -51,7 +51,7 @@
/**
* @param cause
*/
- SubscriptionException(Throwable cause) {
+ public SubscriptionException(Throwable cause) {
super(cause);
// TODO Auto-generated constructor stub
}
=======================================
---
/trunk/servers/jain-slee/enablers/sip-subscription-client/sbb/src/main/resources/META-INF/sbb-jar.xml
Wed Jan 5 22:39:10 2011
+++
/trunk/servers/jain-slee/enablers/sip-subscription-client/sbb/src/main/resources/META-INF/sbb-jar.xml
Fri Mar 18 05:55:40 2011
@@ -37,6 +37,14 @@
<cmp-field-name>expiresCMP</cmp-field-name>
</cmp-field>
<cmp-field>
+ <description></description>
+
<cmp-field-name>acceptedContentTypeCMP</cmp-field-name>
+ </cmp-field>
+ <cmp-field>
+ <description></description>
+
<cmp-field-name>acceptedContentSubTypeCMP</cmp-field-name>
+ </cmp-field>
+ <cmp-field>
<description></description>
<cmp-field-name>contentTypeCMP</cmp-field-name>
</cmp-field>
@@ -45,9 +53,17 @@
<cmp-field-name>contentSubTypeCMP</cmp-field-name>
</cmp-field>
<cmp-field>
+ <description></description>
+
<cmp-field-name>contentCMP</cmp-field-name>
+ </cmp-field>
+ <cmp-field>
<description></description>
<cmp-field-name>subscribeRequestTypeCMP</cmp-field-name>
</cmp-field>
+ <cmp-field>
+ <description></description>
+
<cmp-field-name>eventParametersCMP</cmp-field-name>
+ </cmp-field>
</sbb-abstract-class>
<sbb-local-interface>
<sbb-local-interface-name>org.mobicents.slee.enabler.sip.SubscriptionClientChildSbbLocalObject</sbb-local-interface-name>