Updating Template Content in SAS Web Application Projects That Use the SAS Web Infrastructure Platform

Update Content for an Examples Welcome Page Template

The Examples Welcome Page creates a JSP page that detects the presence of a particular HTTP session attribute to determine whether a Log Off link should be displayed. The HTTP session attribute to test for has changed in SAS 9.4.
To update the HTTP session attribute:
  1. Expand the WebContent folder.
  2. Right-click the sas_examples.jsp file or the appropriate JSP file if you chose a different name, and select Open Withthen selectText Editor.
  3. Change sas.framework.userid to com.sas.services.session.SessionContextInterface
  4. Save and close the file.

Update Content for a SAS Web Infrastructure Platform Application Metadata Creation Template

The following process updates the content from a SAS Web Infrastructure Platform Application Metadata Creation template to work with a new SAS 9.4 Enterprise BI server by re-applying the template to the project and selecting the SAS 9.4 BI Server Profile that you want to use with the project.
To reapply the metadata creation template:
  1. Expand the project's metadata folder.
  2. If manual changes have been made to the Application.xml file in that folder, or if you are unsure if manual modifications have been made, then rename the Application.xml file to ApplicationOld.xml.
  3. From the main menu, select Filethen selectNewthen selectOther.
  4. Expand SAS AppDev Studio, select Add Template Content to Project, and click Next.
  5. In the Project field, select the project to update.
  6. In the Templates tree, expand the SAS Java Web Application and SAS Web Infrastructure Platform Support categories, and then select SAS Web Infrastructure Application Metadata Creation.
    Click Next.
  7. Due to changes for SAS 9.4, the BI Server Profile selection is either blank if no metadata server connection is open, or matches the BI Server Profile of the open connection. Select the BI Server Profile for which you want to initially create the application metadata.
  8. Update the Application Name and Description.
  9. Update the Protocol, and Web Server Host and port to match the ADS Apache Tomcat server (or server of your choice).
  10. Click Finish to apply the template.
When the template wizard finishes reapplying the template, the Application.xml file is automatically opened in the XML Editor. The file includes a commented-out example of how to define properties in the new format used by the SAS Application Metadata Utility. If properties were added to the ApplicationOld.xml file, you can copy these properties to the new Application.xml file. Also, if the ApplicationOld.xml file contains other edits for settings like the description, then you can copy those changes from the ApplicationOld.xml file to the Application.xml file.
Since the SAS Web Infrastructure Platform uses Foundation services internally, the switch to Local Foundation Services means that reapplying the template will add the JAAS configuration needed by the web application. When the template is reapplied, a jaas.config file is added, and the launchParameters.txt file updated for SAS 9.4.
Run the create metadata script to actually create the server metadata. Because the SAS Application Metadata Utility now creates the application metadata, a Software Component object representing the application metadata will be visible in the metadata folder tree. The default location is /Products/SAS AppDev Studio/<name of application>. It is specified by the Folder attribute of the Application element in the Application.xml file. The delete metadata script deletes the application metadata, but does not delete any of the folders that SAS Application Metadata Utility creates in the folder tree.

Update Content for Information Map Servlet (uses SAS WIP) Templates

The Information Map TableView Servlet (uses SAS WIP), Information Map OLAPTableView Servlet (uses SAS WIP), and Information Map Default Servlet (uses SAS WIP) templates can be migrated to SAS 9.4 with a simple change to the servlet.
To update the template content:
  1. In the Project Explorer, expand the Java Resources folder, the src folder, and then the folder or folders that represent the packages where the servlet for the Information Map Servlet template was placed. The default folder is servlets.
  2. Right-click the Information Map servlet source file and select Open.
  3. From the main menu, select Editthen selectFind/Replace.
  4. In the Find field, enter REMOTE_SESSION_CONTEXT and select Find. The file scrolls to CommonKeys.REMOTE_SESSION_CONTEXT.
  5. In the Replace with field, enter SESSION_CONTEXT and select Replace.
  6. Save and close the servlet source file.
Rebuild the project if it is not building automatically.
The SAS 9.4 version of the ExamplesSessionBindingListener associated with these templates does not contain support for remote SessionContexts and UserContexts, but is otherwise unchanged from SAS AppDev Studio 3.41. Thus, you are not required to make the ExamplesSessionBindingListener in the migrated project match the 9.4 version for the web application to function correctly. This also applies for the other template types in this section.

Update Content for JDBC Servlet (uses SAS WIP) Templates

The two templates, JDBC TableView Servlet (uses SAS WIP) and JDBC Default Servlet (uses SAS WIP), can be migrated to SAS 9.4 by updating how the JDBC user name and password values are obtained. Obtaining these values from the UserContext of the currently logged in user does not work in SAS 9.4. The SAS 9.4 versions of these templates have been modified to work the same way as the templates based on SAS 9.4 Foundation Services. This means that the JDBC user name and password are hardcoded in the servlet init-parameters.
Necessarily, implementing a way of obtaining user-specific JDBC credentials instead of hardcoded credentials is left to the customer. If the original code to obtain the JDBC user name and password from the UserContext is still in place, then this code can be modified to match the SAS 9.4 template behavior.
To update the template code:
  1. In the Project Explorer, expand the Java Resources folder, the src folder, and then the folder or folders that represent the packages where the servlet for the JDBC Servlet template was placed. The default folder is servlets.
  2. Right-click the JDBC servlet source file and select Open.
  3. From the main menu, select Editthen selectFind/Replace.
  4. In the Find field, enter JDBC_DATABASE_URL and select Find. The file scrolls to where the JDBC_DATABASE_URL constant is defined.
  5. Change the JDBC_DATABASE_URL value to match the SAS EBI or BI installation that you want to run against.
  6. In the Find field of the Find/Replace dialog box, enter Get credentials and click Find. The file scrolls to the comment Get credentials from user context.
  7. Replace that comment and the 5 lines that follow it with the following code:
    ServletConfig sc = getServletConfig();
    String username = sc.getInitParameter("username");
    String password = sc.getInitParameter("password");
  8. (Optional) Delete any unused imports, and then save and close the servlet source file.
  9. In the WEB-INF folder, right-click the web.xml file, and open it with a Text Editor or XML Editor.
  10. In the web.xml file, find the servlet declaration that corresponds to the servlet modified in step 5.
  11. Append as child elements of that servlet declaration the following init-parameter specifications:
    <init-param>
        <param-name>username</param-name>
        <param-value>your jdbc username</param-value>
    </init-param>
    <init-param>
        <param-name>password</param-name>
        <param-value>your jdbc password</param-value>
    </init-param>
    Ensure that the specified username has Log on as a batch job permission. You can encode the password using the com.sas.util.SasPasswordString class.
  12. Save and close the web.xml file.

Update Content for a Report Viewer Servlet (uses SAS Web Report Viewer and SAS WIP) Template

Because Remote Services are no longer used by the SAS Web Infrastructure Platform, the com.sas.webapp.contextsharing.WebappContextParams cannot be used to display a report or information map in SAS Web Report Viewer or SAS Web Report Studio. Instead, URL parameters are now used to communicate the same information.
To manually update a Report Viewer Servlet template to current SAS 9.4 behavior:
  1. In the Project Explorer, expand the Java Resources folder, the src folder, and then the folder or folders that represent the packages where the servlet for the Report Viewer Servlet template was placed. The default folder is servlets.
  2. Right-click the Report Viewer servlet source file and select Open.
  3. From the main menu, select Editthen selectFind/Replace.
  4. In the Find field, enter sendRedirect and click Find. The file scrolls to where the sendRedirect method is called within a try block.
  5. Replace the line with the sendRedirect call with the following code (note the altered sendRedirect call at the end):
    // Build URL with parameters to open the report.
    String url = viewer + "&" + CommonKeys.PFS_REQUEST_PATH_URL 
       + "=" + URLEncoder.encode(path,"UTF-8")
       + "&" + CommonKeys.PFS_REQUEST_BACKURL_LIST 
       + "=" + URLEncoder.encode(request.getRequestURL().toString(), "UTF-8")
       + "&" + CommonKeys.PFS_REQUEST_BACKLABEL_LIST 
       + "=" + URLEncoder.encode(backLabel,"UTF-8")
       + "&" + CommonKeys.PFS_REQUEST_BACKDESCRIPTION_LIST 
       + "=" + URLEncoder.encode(backDesc, "UTF-8");
    response.sendRedirect(url);
    Be sure to add an import for java.net.URLEncoder if one is not already present.
  6. Delete the lines of code just above the try block:
    SessionContextInterface remoteSessionContext = …
    ...
    params.setParamRequestPathUrl(path);
  7. In the Find field of the Find/Replace dialog box, enter REMOTE_USER_CONTEXT and click Find. The file scrolls to CommonKeys.REMOTE_USER_CONTEXT.
  8. In the Replace with field, enter USER_CONTEXT and click Replace.
  9. (Optional) Delete any unused imports.
  10. Save and close the servlet source file.
Rebuild the project if it is not building automatically.

Update the Java Files for a SAS Stored Process Servlet (uses SAS WIP) Template

Switching the SAS Stored Process Servlet (uses SAS WIP) template from using Remote Foundation Services to Local Foundation Services resulted in several files changing. One of these files is StoredProcessConnection.java. One way to update this file is to add a new stored process template to the project. Another way, documented below, is to add a stored process template to a new temporary project, and copy the file from the new project. The remaining files can be updated manually.
To create the temporary project and add the stored process template:
  1. Select Filethen selectNewthen selectOther, expand SAS AppDev Studio, and select SAS Web Application Project. Then click Next.
  2. Enter a name for this temporary project and click Next.
  3. Enable Add Template Content, and select the SAS Stored Process Servlet (uses SAS WIP) template under the SAS Web Application Examples category. Click Next.
  4. Click Next and then select a BI Server Profile. Click Next again.
    The BI Server Metadata Server for this profile must be running.
  5. If not already connected to a BI Server, click the Change button and log on.
  6. Click the Change button in the Stored Process section, and select a stored process.
  7. Click OK, and then click Finish.
To copy the StoredProcessConnection.java file:
  1. In the Project Explorer view for the new temporary project, expand Java Resources, src, and support.storedprocess.
  2. Expand the same items in the project being migrated.
  3. Select the StoredProcessConnection.java file in the source project, and then right-click and select Copy.
  4. In the migrated project, right-click the support.storedprocess package, and select Paste.
  5. When prompted to confirm overwriting, click Yes.
  6. Delete the temporary project.
To update the remaining files:
  1. In the Project Explorer view for the migrated project, expand the Java Resources folder, the src folder, and then the folder that represents the package where the servlet for the Stored Process Servlet template was placed. The default folder is servlets.
  2. Right-click the stored process servlet source file and select Open.
  3. From the main menu, select Editthen selectFind/Replace.
  4. Use Find/Replace to make the following replacements. Optional replacements make the code read more accurately.
    Find
    Replace with
    Occurrences
    Required
    setRemoteInformationService
    setInformationService
    1
    Yes
    setRemoteStoredProcessService
    setStoredProcessService
    1
    Yes
    REMOTE_USER_CONTEXT
    USER_CONTEXT
    1
    Yes
    REMOTE_SESSION_CONTEXT
    SESSION_CONTEXT
    1
    Yes
    remoteInformationService
    informationService
    5
    No
    remoteStoredProcessService
    storedProcessService
    5
    No
    the remote
    the
    2
    No
  5. Save and close the servlet source file.
  6. In the Project Explorer view for the migrated project, expand WebContent, WEB-INF, and spring-config folders.
  7. Right-click the webapp-config.xml file and select Open.
  8. For the bean definition in the file that corresponds to the stored process servlet just updated, replace the two child property elements with the following:
    <property name="informationService" ref="localInformationService"></property>
    <property name="storedProcessService" ref="localStoredProcessService"></property>
    
  9. Save and close the file.
Repeat the last set of steps for each additional stored process servlet in the project that you want to update. Rebuild the project if it is not building automatically.