Reference Guide

Table Of Contents
<filter-name>Token Authentication Filter</filter-name>
<filter-class>com.hp.sdn.rs.misc.TokenAuthFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>Token Authentication Filter</filter-name>
<url-pattern>/app/rs/*</url-pattern>
</filter-mapping>
</web-app>
Now update the switches view from Creating Views on page 198 under the “hm.js” listing to make
the remote call as illustrated in the following listing:
hm.js Requesting Data to the Controller:
...
// Create a view with a toolbar button
function load(view) {
v.setToolbar(def.tbButton(view.mkId('btn'), view.lion('button'), '',
function () {
$.get('/sdn/ui/health/app/rs/hm', function(data) {
v.setContent($('<span/>').append(data));
});
}));
}
...
As seen in the code the view connects to the relative path “/sdn/ui/health/app/rs/hm so the
connection is opened to the same controller that generated the web page. The prefix
“/sdn/ui/healthmust match the web.context.path property defined in Module Configuration on
page 201 under the “hm-ui/pom.xml to generate .war” listing. The infix “app/rsis given by the
Jersey Servlet mapping configuration in GUI-Specific REST API on page 204 under the “UI Module
Web Application (web.xml) Defining Jersey Servlet” listing, and the suffix “hm” is the relative path
of the resource given by the @Path annotation in the GUI-Specific REST API on page 204 under
the “SwitchResource.java” listing.
In this case, the response media type (in SwitchResource) is defined as TEXT_PLAN. This means
that the data parameter of the $.get() function callback is filled in with a plain string. The media
type can also be defined as APPLICATION_JSON and return a JSON formatted string. In which
case, the JavaScript [40] data parameter would be an object.
No need to worry about authentication because the SKI framework automatically includes the
authentication token generated after login (Figure 40) into the HTTP request headers.
Now try the application’s user interface again. Build and install the application as described in
Building the Application on page 146 and Installing the Application on page 147. After installing
the application refresh the SDN Controller GUI as illustrated at the top part of Figure 58; the
application’s GUI entry will appear as illustrated at the bottom part of Figure 58. Now the
message returned by SwitchResource can be seen after clicking theRefresh Data” button.
207