RESTful JSON Notification Service

Set up the preferences

  • Add the 'RestfulJsonNotificationService.serviceUrls' preference and specify your service(s). 

    • You may add more than one Url by clicking on the "Add Value" link

 

Using Optional Parameters

The parameters included with the call to a REST service are set in the Spring configuration. See file applicationContext.xml (notification-portlet-webapp/src/main/webapp/WEB-INF/context/). In that file the Spring bean restfulJsonNotificationServices is configured accordingly and you can revise the "urlParameters" property based on your needs. By default, the url pattern will be similar to this: "https://university.edu/yourFeed/{username}"

<bean id="restfulJsonNotificationService" class="org.jasig.portlet.notice.service.rest.RestfulJsonNotificationService">
        <property name="name" value="restfulJsonNotificationService"/>       
        <property name="usernameEvaluator">
            <bean class="org.jasig.portlet.notice.service.rest.StringLiteralParameterEvaluator"
               p:value="${restfulJsonNotificationService.basicauth.username}"/>
        </property>
        <property name="passwordEvaluator">
            <bean class="org.jasig.portlet.notice.service.rest.StringLiteralParameterEvaluator"
              p:value="${restfulJsonNotificationService.basicauth.password}"/>
        </property>
        <property name="urlParameters">
            <util:map>
                <entry key="username">
                    <bean class="org.jasig.portlet.notice.service.rest.UserAttributeParameterEvaluator">
                        <property name="userAttributeKey" value="user.login.id"/>
                    </bean>
                </entry>
            </util:map>
        </property>
        <property name="restTemplate">
            <bean class="org.springframework.web.client.RestTemplate">
                <property name="requestFactory">
                    <bean class="org.springframework.http.client.CommonsClientHttpRequestFactory">
                        <property name="httpClient" ref="httpClient" />
                    </bean>
                </property>
            </bean>
        </property>
   </bean>

 

Optional Authentication

Another item to note is that you can also configure the REST web service call to include basic authentication to provide some security. See the notifications.properties (notification-portlet-webapp/src/main/filters/notifications.properties) file for where to set the value for username and password.

# Use this file for filter expressions

# Set values for these to use HTTP basic AuthN with the RestfulJsonNotificationService
environment.build.restfulJsonNotificationService.basicauth.username=
environment.build.restfulJsonNotificationService.basicauth.password=