Revision: 14920
Author: emmartins
Date: Tue Oct 26 10:34:31 2010
Log: [No log message]
http://code.google.com/p/mobicents/source/detail?r=14920

Modified:
/trunk/servers/sip-presence/examples/internal-rls/sbb/src/main/java/org/mobicents/slee/sipevent/examples/RLSExampleRootSbb.java /trunk/servers/sip-presence/examples/internal-rls/sbb/src/main/java/org/mobicents/slee/sipevent/examples/RLSExampleSubscriber.java /trunk/servers/sip-presence/examples/internal-rls/sbb/src/main/java/org/mobicents/slee/sipevent/examples/RLSExampleSubscriberSbb.java /trunk/servers/sip-presence/examples/internal-rls/sbb/src/main/java/org/mobicents/slee/sipevent/examples/RLSExampleSubscriberSbbLocalObject.java /trunk/servers/sip-presence/examples/internal-rls/sbb/src/main/resources/META-INF/sbb-jar.xml

=======================================
--- /trunk/servers/sip-presence/examples/internal-rls/sbb/src/main/java/org/mobicents/slee/sipevent/examples/RLSExampleRootSbb.java Thu Jul 1 08:30:01 2010 +++ /trunk/servers/sip-presence/examples/internal-rls/sbb/src/main/java/org/mobicents/slee/sipevent/examples/RLSExampleRootSbb.java Tue Oct 26 10:34:31 2010
@@ -99,10 +99,10 @@
                tracer.info("Service deactivated...");
                try {
                        try {
- for (Iterator it = getPublisherChildRelation().iterator(); it.hasNext(); ) { + for (Iterator<?> it = getPublisherChildRelation().iterator(); it.hasNext(); ) {
                                        
((RLSExamplePublisherSbbLocalObject)it.next()).stop();
                                }
- for (Iterator it = getSubscriberChildRelation().iterator(); it.hasNext(); ) { + for (Iterator<?> it = getSubscriberChildRelation().iterator(); it.hasNext(); ) {
                                        
((RLSExampleSubscriberSbbLocalObject)it.next()).stop();
                                }
                        } catch (Exception e) {
=======================================
--- /trunk/servers/sip-presence/examples/internal-rls/sbb/src/main/java/org/mobicents/slee/sipevent/examples/RLSExampleSubscriber.java Fri Dec 11 04:41:27 2009 +++ /trunk/servers/sip-presence/examples/internal-rls/sbb/src/main/java/org/mobicents/slee/sipevent/examples/RLSExampleSubscriber.java Tue Oct 26 10:34:31 2010
@@ -3,14 +3,14 @@
  */
 package org.mobicents.slee.sipevent.examples;

+import org.mobicents.slee.enabler.xdmc.XDMClientParent;
 import org.mobicents.slee.sippresence.client.PresenceClientControlParent;
-import org.mobicents.slee.xdm.server.XDMClientControlParent;

 /**
  * @author martins
  *
  */
-public interface RLSExampleSubscriber extends PresenceClientControlParent,XDMClientControlParent{ +public interface RLSExampleSubscriber extends PresenceClientControlParent,XDMClientParent{

        /**
         * Stores the parent sbb local object, to be used on callbacks
=======================================
--- /trunk/servers/sip-presence/examples/internal-rls/sbb/src/main/java/org/mobicents/slee/sipevent/examples/RLSExampleSubscriberSbb.java Wed Jul 21 05:38:08 2010 +++ /trunk/servers/sip-presence/examples/internal-rls/sbb/src/main/java/org/mobicents/slee/sipevent/examples/RLSExampleSubscriberSbb.java Tue Oct 26 10:34:31 2010
@@ -2,7 +2,8 @@

 import java.io.IOException;
 import java.io.StringWriter;
-import java.util.Map;
+import java.net.URI;
+import java.net.URISyntaxException;

 import javax.naming.Context;
 import javax.naming.InitialContext;
@@ -20,13 +21,17 @@
 import javax.slee.nullactivity.NullActivityFactory;
 import javax.xml.bind.JAXBContext;

+import org.mobicents.slee.enabler.userprofile.jpa.jmx.UserProfileControlManagement;
+import org.mobicents.slee.enabler.xdmc.XDMClientChildSbbLocalObject;
+import org.mobicents.slee.enabler.xdmc.XDMClientParentSbbLocalObject;
 import org.mobicents.slee.sipevent.server.subscription.data.Subscription;
import org.mobicents.slee.sipevent.server.subscription.data.Subscription.Event; import org.mobicents.slee.sipevent.server.subscription.data.Subscription.Status; import org.mobicents.slee.sippresence.client.PresenceClientControlParentSbbLocalObject; import org.mobicents.slee.sippresence.client.PresenceClientControlSbbLocalObject;
-import org.mobicents.slee.xdm.server.XDMClientControlParentSbbLocalObject;
-import org.mobicents.slee.xdm.server.XDMClientControlSbbLocalObject;
+import org.mobicents.slee.xdm.server.ServerConfiguration;
+import org.mobicents.xcap.client.uri.DocumentSelectorBuilder;
+import org.mobicents.xcap.client.uri.UriBuilder;
 import org.openxdm.xcap.client.appusage.resourcelists.jaxb.EntryType;
 import org.openxdm.xcap.client.appusage.resourcelists.jaxb.ListType;
import org.openxdm.xcap.client.appusage.resourcelists.jaxb.EntryType.DisplayName;
@@ -34,11 +39,6 @@
 import org.openxdm.xcap.client.appusage.rlsservices.jaxb.PackagesType;
 import org.openxdm.xcap.client.appusage.rlsservices.jaxb.RlsServices;
 import org.openxdm.xcap.client.appusage.rlsservices.jaxb.ServiceType;
-import org.openxdm.xcap.common.key.UserDocumentUriKey;
-import org.openxdm.xcap.common.key.XcapUriKey;
-import org.openxdm.xcap.common.uri.AttributeSelector;
-import org.openxdm.xcap.common.uri.DocumentSelector;
-import org.openxdm.xcap.common.uri.NodeSelector;

 /**
  *
@@ -48,66 +48,68 @@
 public abstract class RLSExampleSubscriberSbb implements javax.slee.Sbb,
        RLSExampleSubscriber {

-       String presenceDomain = System.getProperty("bind.address","127.0.0.1");
-       String subscriber = "sip:carol@"+presenceDomain;
-       String notifier = "sip:carol@"+presenceDomain+";pres-list=Default";
-       String eventPackage = "presence";
-       String contentType = "application";
-       String contentSubType = "pidf+xml";
-       int expires = 300;
-
+ private String presenceDomain = System.getProperty("bind.address","127.0.0.1");
+       private String subscriber = "sip:carol@"+presenceDomain;
+ private String notifier = "sip:carol@"+presenceDomain+";pres-list=Default";
+       private String notifierPassword = "password";
+       private String eventPackage = "presence";
+       private int expires = 300;
+       private URI uri = buildRLSServicesURI();
+
        // --- PRESENCE CLIENT CHILD SBB

        public abstract ChildRelation 
getPresenceClientControlSbbChildRelation();

- public abstract PresenceClientControlSbbLocalObject getPresenceClientControlSbbCMP();
-
-       public abstract void setPresenceClientControlSbbCMP(
-                       PresenceClientControlSbbLocalObject value);
+       private URI buildRLSServicesURI() {
+ String documentSelector = DocumentSelectorBuilder.getUserDocumentSelectorBuilder("rls-services",notifier,"index").toPercentEncodedString();
+               UriBuilder uriBuilder = new UriBuilder()
+ .setSchemeAndAuthority(ServerConfiguration.getInstance().getSchemeAndAuthority())
+                       
.setXcapRoot(ServerConfiguration.getInstance().getXcapRoot())
+                       .setDocumentSelector(documentSelector);
+               try {
+                       return uriBuilder.toURI();
+               } catch (URISyntaxException e) {
+                       throw new RuntimeException(e.getMessage(),e);
+               }
+       }

private PresenceClientControlSbbLocalObject getPresenceClientControlSbb() { - PresenceClientControlSbbLocalObject childSbb = getPresenceClientControlSbbCMP();
-               if (childSbb == null) {
+
+ final ChildRelation childRelation = getPresenceClientControlSbbChildRelation();
+               if (childRelation.isEmpty()) {
                        try {
- childSbb = (PresenceClientControlSbbLocalObject) getPresenceClientControlSbbChildRelation()
-                                       .create();
+ PresenceClientControlSbbLocalObject sbb = (PresenceClientControlSbbLocalObject) childRelation.create(); + sbb.setParentSbb((PresenceClientControlParentSbbLocalObject) sbbContext.getSbbLocalObject());
+                               return sbb;
                        } catch (Exception e) {
                                tracer.severe("Failed to create child sbb", e);
                                return null;
                        }
-                       setPresenceClientControlSbbCMP(childSbb);
-                       childSbb
- .setParentSbb((PresenceClientControlParentSbbLocalObject) this.sbbContext
-                                                       .getSbbLocalObject());
-               }
-               return childSbb;
+               }
+               else {
+ return (PresenceClientControlSbbLocalObject) childRelation.iterator().next();
+               }
        }

        // --- XDM CLIENT CHILD SBB

-       public abstract ChildRelation getXDMClientControlChildRelation();
-
- public abstract XDMClientControlSbbLocalObject getXDMClientControlChildSbbCMP();
-
-       public abstract void setXDMClientControlChildSbbCMP(
-                       XDMClientControlSbbLocalObject value);
-
-       public XDMClientControlSbbLocalObject getXDMClientControlSbb() {
- XDMClientControlSbbLocalObject childSbb = getXDMClientControlChildSbbCMP();
-               if (childSbb == null) {
+       public abstract ChildRelation getXDMClientChildRelation();
+
+       public XDMClientChildSbbLocalObject getXDMClientChildSbb() {
+               final ChildRelation childRelation = getXDMClientChildRelation();
+               if (childRelation.isEmpty()) {
                        try {
- childSbb = (XDMClientControlSbbLocalObject) getXDMClientControlChildRelation()
-                                               .create();
+ XDMClientChildSbbLocalObject sbb = (XDMClientChildSbbLocalObject) childRelation.create(); + sbb.setParentSbb((XDMClientParentSbbLocalObject) sbbContext.getSbbLocalObject());
+                               return sbb;
                        } catch (Exception e) {
                                tracer.severe("Failed to create child sbb", e);
                                return null;
                        }
-                       setXDMClientControlChildSbbCMP(childSbb);
-                       childSbb
-                                       
.setParentSbb((XDMClientControlParentSbbLocalObject) this.sbbContext
-                                                       .getSbbLocalObject());
-               }
-               return childSbb;
+               }
+               else {
+                       return (XDMClientChildSbbLocalObject) 
childRelation.iterator().next();
+               }
        }

        // --- CMPs
@@ -164,9 +166,9 @@

        public void start(String[] entryURIs) {
                try {
-                       XDMClientControlSbbLocalObject xdm = 
getXDMClientControlSbb();
-                       // insert the document
- xdm.put(new UserDocumentUriKey("rls-services",notifier,"index"), "application/rls-services+xml", getRlsServices(entryURIs).getBytes("UTF-8"),null); + UserProfileControlManagement.getInstance().addUser(notifier,notifierPassword);
+                       XDMClientChildSbbLocalObject xdm = 
getXDMClientChildSbb();
+ xdm.put(uri, "application/rls-services+xml", getRlsServices(entryURIs).getBytes("UTF-8"),notifier);
                } catch (Exception e) {
                        tracer.severe(e.getMessage(), e);
                        getParentSbbCMP().subscriberNotStarted();
@@ -177,7 +179,13 @@
                return "rls-example~"+subscriber+"~"+notifier+"~"+eventPackage;
        }

- public void putResponse(XcapUriKey key, int responseCode, String responseContent, String tag) {
+       /*
+        * (non-Javadoc)
+ * @see org.mobicents.slee.enabler.xdmc.XDMClientParent#putResponse(java.net.URI, int, java.lang.String, java.lang.String)
+        */
+       @Override
+       public void putResponse(URI uri, int responseCode, String 
responseContent,
+                       String eTag) {
tracer.info("Response to the insertion of the rls services document: status="+responseCode+",content="+responseContent);
                if (responseCode != 200 && responseCode != 201) {
                        getParentSbbCMP().subscriberNotStarted();
@@ -216,10 +224,12 @@

        private void deleteRlsServices() {
                try {
- getXDMClientControlSbb().delete(new UserDocumentUriKey("rls-services",notifier,"index"),null);
+                       XDMClientChildSbbLocalObject xdm = 
getXDMClientChildSbb();
+                       xdm.delete(uri,notifier);
                } catch (Exception e) {
                        tracer.severe(e.getMessage(), e);
                }
+               UserProfileControlManagement.getInstance().removeUser(notifier);
        }

        public void newSubscriptionError(String subscriber, String notifier,
@@ -280,53 +290,18 @@
                tracer.info("unsubscribe Ok");
        }

- public void deleteResponse(XcapUriKey key, int responseCode, String responseContent, String tag) {
-               getParentSbbCMP().subscriberStopped();
-       }
-
-       /* (non-Javadoc)
- * @see org.mobicents.slee.xdm.server.XDMClientControlParent#attributeUpdated(org.openxdm.xcap.common.uri.DocumentSelector, org.openxdm.xcap.common.uri.NodeSelector, org.openxdm.xcap.common.uri.AttributeSelector, java.util.Map, java.lang.String, java.lang.String, java.lang.String, java.lang.String)
-        */
        @Override
-       public void attributeUpdated(DocumentSelector documentSelector,
-                       NodeSelector nodeSelector, AttributeSelector 
attributeSelector,
-                       Map<String, String> namespaces, String oldETag, String 
newETag,
-                       String documentAsString, String attributeValue) {
-               // TODO Auto-generated method stub
-
+       public void deleteResponse(URI uri, int responseCode,
+                       String responseContent, String eTag) {
+               getParentSbbCMP().subscriberStopped();
        }

-       /* (non-Javadoc)
- * @see org.mobicents.slee.xdm.server.XDMClientControlParent#documentUpdated(org.openxdm.xcap.common.uri.DocumentSelector, java.lang.String, java.lang.String, java.lang.String)
+       /*
+        * (non-Javadoc)
+ * @see org.mobicents.slee.enabler.xdmc.XDMClientParent#getResponse(java.net.URI, int, java.lang.String, java.lang.String, java.lang.String)
         */
        @Override
-       public void documentUpdated(DocumentSelector documentSelector,
-                       String oldETag, String newETag, String 
documentAsString) {
-               // TODO Auto-generated method stub
-
-       }
-
-       /* (non-Javadoc)
- * @see org.mobicents.slee.xdm.server.XDMClientControlParent#elementUpdated(org.openxdm.xcap.common.uri.DocumentSelector, org.openxdm.xcap.common.uri.NodeSelector, java.util.Map, java.lang.String, java.lang.String, java.lang.String, java.lang.String)
-        */
-       @Override
-       public void elementUpdated(DocumentSelector documentSelector,
-                       NodeSelector nodeSelector, Map<String, String> 
namespaces,
-                       String oldETag, String newETag, String documentAsString,
-                       String elementAsString) {
-               // TODO Auto-generated method stub
-
-       }
-
-       /* (non-Javadoc)
- * @see org.mobicents.slee.xdm.server.XDMClientControlParent#getResponse(org.openxdm.xcap.common.key.XcapUriKey, int, java.lang.String, java.lang.String, java.lang.String)
-        */
-       @Override
-       public void getResponse(XcapUriKey key, int responseCode, String 
mimetype,
-                       String content, String eTag) {
-               // TODO Auto-generated method stub
-
-       }
+ public void getResponse(URI uri, int responseCode, String mimetype, String content, String eTag) {};

        /* (non-Javadoc)
* @see org.mobicents.slee.sippresence.client.PresenceClientControlParent#modifyPublicationError(java.lang.Object, int)
=======================================
--- /trunk/servers/sip-presence/examples/internal-rls/sbb/src/main/java/org/mobicents/slee/sipevent/examples/RLSExampleSubscriberSbbLocalObject.java Fri Dec 11 04:41:27 2009 +++ /trunk/servers/sip-presence/examples/internal-rls/sbb/src/main/java/org/mobicents/slee/sipevent/examples/RLSExampleSubscriberSbbLocalObject.java Tue Oct 26 10:34:31 2010
@@ -1,10 +1,8 @@
 package org.mobicents.slee.sipevent.examples;

+import org.mobicents.slee.enabler.xdmc.XDMClientParentSbbLocalObject;
import org.mobicents.slee.sippresence.client.PresenceClientControlParentSbbLocalObject;
-import org.mobicents.slee.xdm.server.XDMClientControlParentSbbLocalObject;
-
-public interface RLSExampleSubscriberSbbLocalObject extends RLSExampleSubscriber, PresenceClientControlParentSbbLocalObject,XDMClientControlParentSbbLocalObject {
-
-
+
+public interface RLSExampleSubscriberSbbLocalObject extends RLSExampleSubscriber, PresenceClientControlParentSbbLocalObject,XDMClientParentSbbLocalObject {

 }
=======================================
--- /trunk/servers/sip-presence/examples/internal-rls/sbb/src/main/resources/META-INF/sbb-jar.xml Thu Jul 1 08:30:01 2010 +++ /trunk/servers/sip-presence/examples/internal-rls/sbb/src/main/resources/META-INF/sbb-jar.xml Tue Oct 26 10:34:31 2010
@@ -140,8 +140,8 @@

        <sbb-ref>
                <sbb-name>InternalXDMClientControlSbb</sbb-name>
-               <sbb-vendor>org.mobicents</sbb-vendor>
-               <sbb-version>1.0</sbb-version>
+               <sbb-vendor>org.mobicents</sbb-vendor>
+               <sbb-version>1.0</sbb-version>
                <sbb-alias>xdmChildSbb</sbb-alias>
        </sbb-ref>

@@ -153,14 +153,6 @@
                        <cmp-field>
                                <cmp-field-name>parentSbbCMP</cmp-field-name>
                        </cmp-field>
-                       <cmp-field>
-                               
<cmp-field-name>xDMClientControlChildSbbCMP</cmp-field-name>
-                       </cmp-field>
-                       <cmp-field>
-                               <cmp-field-name>
-                                       presenceClientControlSbbCMP
-                               </cmp-field-name>
-                       </cmp-field>
                        <get-child-relation-method>
                                <sbb-alias-ref>presenceChildSbb</sbb-alias-ref>
                                <get-child-relation-method-name>
@@ -171,7 +163,7 @@
                        <get-child-relation-method>
                                <sbb-alias-ref>xdmChildSbb</sbb-alias-ref>
                                <get-child-relation-method-name>
-                                       getXDMClientControlChildRelation
+                                       getXDMClientChildRelation
                                </get-child-relation-method-name>
                                <default-priority>0</default-priority>
                        </get-child-relation-method>

Reply via email to