Skip to content
This repository has been archived by the owner on Jan 21, 2024. It is now read-only.

Custom Context Roots for IBM Connections

Paul Bastide edited this page Dec 7, 2015 · 1 revision

In your Connections deployment, you may have defined custom context roots for your applications. Because the SDK assumes that the default mappings are used, you will need to add a configuration option to your managed-beans to make sure API requests reach their destination.

For example, the root of the files application is usually mapped to https://exampleConnections.com/files.

It could be the case that this was changed to be https://exampleConnections.com/myfiles or https://exampleconnsrv.com/filesContext, for example.

In this article you'll learn how to configure the service mappings in the SDK.

Standard Context Roots

You can view an atom feed containing the configuration of all services if you know one context root. The easiest way is to go to https://exampleConnections.com, and when it brings you to the homepage use the homepage context root to find the rest. The typical homepage is: https://exampleConnections.com/homepage/web/updates/#myStream/imFollowing/all

So we then go to https://exampleConnections.com/homepage/serviceconfig and see something like this:

<entry>
    <category term="service-config" scheme="http://www.ibm.com/xmlns/prod/sn/type"></category>
    <title type="text">activities</title>
    <id>urn:lsid:ibm.com:config:activities:com.ibm.sn</id>
    <link href="https://exampleConnections.com/activities" rel="alternate" type="text/html"></link>
    <link href="https://exampleConnections.com/activities" rel="http://www.ibm.com/xmlns/prod/sn/alternate-ssl" type="text/html"></link>
    <updated>2014-06-18T14:48:41.835Z</updated>
</entry>
<entry>
    <category term="service-config" scheme="http://www.ibm.com/xmlns/prod/sn/type"></category>
    <title type="text">homepage</title>
    <id>urn:lsid:ibm.com:config:homepage:com.ibm.sn</id>
    <link href="https://exampleConnections.com/homepage" rel="alternate" type="text/html"></link>
    <link href="https://exampleConnections.com/homepage" rel="http://www.ibm.com/xmlns/prod/sn/alternate-ssl" type="text/html"></link>
    <updated>2014-06-18T14:48:41.835Z</updated>
</entry>
<entry>
    <category term="service-config" scheme="http://www.ibm.com/xmlns/prod/sn/type"></category>
    <title type="text">forums</title>
    <id>urn:lsid:ibm.com:config:forums:com.ibm.sn</id>
    <link href="https://exampleConnections.com/forums" rel="alternate" type="text/html"></link>
    <link href="https://exampleConnections.com/forums" rel="http://www.ibm.com/xmlns/prod/sn/alternate-ssl" type="text/html"></link>
    <updated>2014-06-18T14:48:41.835Z</updated>
</entry>

We can see that activities is mapped to /activities, and homepage is mapped to /homepage, but forums is mapped to /customforums

Configuring the SDK to use the new Context Root

Open up your managed-beans.xml configuration file and find the endpoint that you are using to make requests. A basic connections bean might look like this:

<!-- Connections Basic -->
<managed-bean>
    <managed-bean-name>connections</managed-bean-name>
    <managed-bean-class>com.ibm.sbt.services.endpoints.ConnectionsBasicEndpoint</managed-bean-class>
    <managed-bean-scope>session</managed-bean-scope>
    <managed-property>
        <property-name>url</property-name>
        <value>%{connections.url}</value>
    </managed-property>
    <managed-property>
        <property-name>apiVersion</property-name>
        <value>%{connections.apiVersion}</value>
    </managed-property>
    <managed-property>
        <property-name>credentialStore</property-name>
        <value>CredStore</value>
    </managed-property>
    <managed-property>
        <property-name>authenticationPage</property-name>
        <value>/sbt/loginForm.html?endpoint=connections</value>
    </managed-property>
    <managed-property>
        <property-name>authenticationService</property-name>
        <value>communities/service/atom/communities/my</value>
    </managed-property>
</managed-bean>

To map forums to customforums, add a new <managed-property> element, called serviceMappings, to the managed-bean.

<managed-property>
    <property-name>serviceMappings</property-name>
    <map-entries>
        <map-entry>
            <key>forums</key>
            <value>customforums</value>
        </map-entry>
    </map-entries>
</managed-property>

Restart your server and you're done! All requests to the forum service will now go through customforums instead of forums.

You can add multiple <map-entry> elements insides the <map-entries> element.

<managed-property>
    <property-name>serviceMappings</property-name>
    <map-entries>
        <map-entry>
            <key>forums</key>
            <value>customforums</value>
        </map-entry>
        <map-entry>
            <key>connections</key>
            <value>common</value>
        </map-entry>
    </map-entries>
</managed-property>
connections -> common

Special mention is given to this as it's a commonly used service mapping. The activitystream service sends requests through exampleConnections.com/connections, but this is often mapped to exampleConnections.com/common. Follow the same procedure as with the forums service to correct this behaviour.