6 Replies Latest reply on Mar 3, 2015 12:01 PM by pawans

    Any better way to define multiple connects services in app.xml?

    pawans

      Hello Jivers,

      I have an add-on which has multiple apps in it.

      Each connects to a different jive connects service endpoint.

       

      I have defined the service endpoints in app.xml as follows

       

      <Require feature="jive-connects-v1">
         <Param name="alias:service1|title:Group Service 1">jive:service://service1</Param>
         <Param name="alias:service2|title:Group Service 2">jive:service://service2</Param>
         <Param name="alias:service3|title:Group Service 3">jive:service://service3</Param>
      </Require>
      
      

       

       

      Lets say I just have one service defined. Now when user opens one of the apps, a popup to link to a service is displayed.

       

      Screen Shot 2015-02-24 at 12.03.44 AM.png

       

      Now I have multiple services defined in one app.xml, this popup shows all services even though only one of them is used by current app.

       

      Screen Shot 2015-02-24 at 3.47.17 PM.png

       

      Is there a way to avoid displaying multiple services on this popup, but still have all apps in one node server?

      I want to ensure only the service required for the current app is displayed.

       

      Any thing i can do in app.xml? may be multiple configs? something?

       

      Right now I have 6 apps on one node server, 3 of them user 3 different connects end points and 3 without any dependency on connects service.

      I want to keep all apps in one node jive-sdk server.

       

      Ryan Rutan, Aron Racho any clues on this?

        • Re: Any better way to define multiple connects services in app.xml?
          Ryan Rutan

          Pawan Shah - Have you broken up your apps into different apps in your Add-On?  Each app.xml should only have the services it uses.  Could you share your add-on structure?

            • Re: Any better way to define multiple connects services in app.xml?
              pawans

              Hi Ryan,

              I have added a structure similar to my app.xml in another community question here -->  When does a "link to service" popup appears for apps (wrt connects api)

               

              Putting the structure here for others to check (the actual app.xml has many more actions with filters)

               

              In the xml below the app1 uses service1 and app2 uses service2. app3 and app4 don't use any service.

               

              <?xml version="1.0" encoding="UTF-8"?>

              <Module specificationVersion="1">

                  <ModulePrefs title="Jive apps"

                               description=""

                               author=""

                               author_affiliation=""

                               author_email="">

               

               

                      <Require feature="dynamic-height"/>

                      <Require feature="embedded-experiences"/>

                      <Require feature="jive-core-v2" />

                      <Require feature="jive-core-v3"/>

                      <Require feature="minimessage"/>

                      <Require feature="setprefs"/>

                      <Require feature="osapi"/>

                      <Require feature="views"/>

                      <Require feature="jive-connects-v1">

                          <Param name="alias:service1|title:Group Service">jive:service://service2</Param>

                          <Param name="alias:service2|title:User Service">jive:service://service2</Param>

                      </Require>

                      <Require feature="actions">

                          <Param name="action-contributions">

                              <![CDATA[

                             <action id="org.jive.app1"

                                     path="jive/actions/places/group"

                                     label="App1"

                                     view="app1"

                               />

                              <action id="org.jive.app2"

                                      path="jive/actions/places/group"

                                      label="App2"

                                      view="app2"

                              />

                              <action id="org.jive.app3"

                                      path="jive/tabs/places/group"

                                      label="App3"

                                      view="app3"

                              />

                              <action id="org.jive.app4"

                                      path="jive/tabs/places/group"

                                      label="App4"

                                      view="app4"

                              />

                ]]>

                

                          </Param>

                      </Require>

                  </ModulePrefs>

                

                  <Content type="html" view="app1" href="app1.html" preferred_height="400" preferred_width="500"  />

                  <Content type="html" view="app2" href="app2.html" preferred_height="400" preferred_width="500"  />

                  <Content type="html" view="app3" href="app3.html" preferred_height="1000"/>

                  <Content type="html" view="app4" href="app4.html" preferred_height="1000"/>

               

              </Module>

               

               

               

              For now we fixed the problem by having a common url for both services, just a different end point.

              We registered the endpoint in connects console as add-ons services and added the same in app.xml as follow -

               

                      <Require feature="jive-connects-v1">

                          <Param name="alias:AddOnService|title:addOns">jive:service://addOns</Param>

                      </Require>

               

              Now the url registered in add-on services is something like https://myserver.com,

              On my server side this url has two end points which look something like https://myserver.com/groups and https://myserver.com/users

               

              Initially my connects call for both apps with their services was just calling the alias like this

               

                      osapi.jive.connects.post({

                          authz:"signed",

                          alias: "service1",

                          headers : { "Content-Type" : "application/json" },

                          format: 'json',

                          "body": {......}

                      }).execute(function(data){

               

              and

               

                      osapi.jive.connects.post({

                          authz:"signed",

                          alias: "service2",

                          headers : { "Content-Type" : "application/json" },

                          format: 'json',

                          "body": {......}

                      }).execute(function(data){

               

              Now my connects call has extra param called href along with alias like this

               

                     osapi.jive.connects.post({

                          authz:"signed",

                          alias: "addOnService",

                         href:"groups",

                          headers : { "Content-Type" : "application/json" },

                          format: 'json',

                          "body": {......}

                      }).execute(function(data){

               

              and

               

                      osapi.jive.connects.post({

                          authz:"signed",

                          alias: "service2",

                           href:"users",

                          headers : { "Content-Type" : "application/json" },

                          format: 'json',

                          "body": {......}

                      }).execute(function(data){

               

               

              The way this fixes my problem is now for all apps which depend on some connects alias, will see one service name in the popup, which is more generic like add-ons services.

              While making an ajax call, each app will add its required href along with the alias as now all services are deployed at one place.

               

              This solution is still better as it avoids showing multiple services in the popup like what the previous app.xml was doing.

              Is there a better way to add multiple services in app.xml? or what we have done is good?