Updating Template Content in SAS Web Application Projects That Use SAS Foundation Services

Update the Context Listener Template Content

If your project contains a FoundationServicesContextListener class, you must apply the Context Listener For Local Services template. Doing so updates the FoundationServicesContextListener class to use only Local Foundation Services, and it updates the JAAS configuration for SAS 9.4. The existing login.config name is preserved when the template updates the project. In new projects, the JAAS configuration file is named jaas.config,
It is not necessary to create a deployment descriptor for AppDev Studio because the SAS 9.4 Web Infrastructure Platform provides a general purpose deployment descriptor called Platform Local Services. Applying the Context Listener For Local Services template adds or updates the sas_metadata_source.properties file so that the Platform Local Services deployment descriptor is used.
Perform the following steps to update the FoundationServicesContextListener class in the project:
  1. In the Navigator view, expand the root folder of the project to update.
  2. Right-click the .SASTemplateResources file and select Open Withthen selectText Editor.
  3. Find the line that contains the following:
    <management function="sas.foundation.services.context.listener" level="remote"
  4. Change the value of the level attribute to local.
  5. Save and close the file.
  6. From Eclipse, select Filethen selectNewthen selectOther.
  7. Expand the SAS AppDev Studio folder, select Add Template Content to Project, and then click Next.
  8. In the Project field, select the project to update.
  9. In the Templates tree, expand SAS Java Web Application and then SAS Foundation Services Support.
  10. Select Context Listener For Local Services and click Next.
  11. Click Next to accept the default Template Configuration Parameters.
  12. Due to changes for SAS 9.4, the BI Server Profile selection is blank if no metadata server connection is open, or matches the BI Server Profile of the open connection. Select the BI Server Profile for the Enterprise BI installation that you want the project to run against.
  13. If the SAS Metadata Server for the BI installation is running, you can click Test Configuration to verify that the service deployment can be read from the metadata server.
  14. Click Finish.
  15. (Optional) Expand the WebContent, WEB-INF, and conf folders in the project and delete the sas_remote_metadata_source_omr.properties file.

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

The Information Map TableView Servlet (uses SAS FS), Information Map OLAPTableView Servlet (uses SAS FS), and Information Map Default Servlet (uses SAS FS) templates can be migrated to SAS 9.4 by changing the servlet to use local services instead of remote services.
To change from local services to remote services:
  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 // Get remote and click Find.
  5. Delete the following code that starts with the found comment:
    // Get remote services attributes. The name "remote.sas.services.attributes"
    // should match the REMOTE_SERVICES_ATTRIBUTES string in the Foundation Services
    // ServletContextListener
    ServiceAttributeInterface [] attributes =
       (ServiceAttributeInterface [])getServletContext().getAttribute("remote.sas.services.attributes");
  6. After deleting the code, two errors will appear in the file where the attributes variable is used as a parameter. Delete the attributes parameter and the comma that precedes it where the two errors occur.
  7. Use the Find/Replace dialog box to make the following replacements. Optional replacements make the code more readable.
    Find
    Replace with
    Occurrences
    Required
    addRemoteUserContext
    addUserContext
    1
    Yes
    addRemoteSessionContext
    addSessionContext
    1
    No
    remoteUserService
    userService
    2
    No
    remoteSessionService
    sessionService
    2
    No
    a remote
    a
    2
    No
  8. (Optional) Delete any unused imports.
  9. Save and close the servlet source file.
  10. In the WEB-INF folder, right-click the web.xml file, and open it with a Text Editor or XML Editor.
  11. In web.xml, find the servlet declaration that corresponds to the servlet and update the init-parameters values for metadata-userid and metadata-password, if necessary.
    You can encode the password using the com.sas.util.SasPasswordString class.
  12. Save and close the web.xml file.
Rebuild the project if it is not building automatically.

Update Content for JDBC Servlet (uses SAS FS) Templates

The only changes needed for the JDBC TableView Servlet (uses SAS FS) and JDBC Default Servlet (uses SAS FS) templates are the JDBC URL and the credentials used for the JDBC connection.
To change the URL and credentials:
  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 click Find. The file scrolls to where this constant is defined.
  5. Update the host and port in the value for the JDBC_DATABASE_URL to values appropriate for the EBI installation that you want the servlet to access.
  6. Save and close the servlet source file.
  7. In the WEB-INF folder, right-click the web.xml file, and open it with a Text Editor or XML Editor.
  8. In the web.xml file, find the servlet declaration that corresponds to the servlet and update the init-parameters values for username and password, if necessary. You can encode the password using the com.sas.util.SasPasswordString class.
  9. Save and close the web.xml file.
Rebuild the project if it is not building automatically.

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

Because Remote Services is no longer used by the SAS Web Infrastructure Platform, the com.sas.webapp.contextsharing.WebappContextParams class 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.
Because the web application in this project is not based on the SAS Web Infrastructure Platform, you must perform a separate login for the SAS Web Report Viewer or Studio.
To manually update a Report Viewer Servlet template to SAS 9.4, follow these steps:
  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 single line with the sendRedirect call with the following code:
    // Build the URL with a parameter to open the report.
    String url = viewer + "?" + com.sas.web.keys.CommonKeys.PFS_REQUEST_PATH_RL 
       + "=" + java.net.URLEncoder.encode(path,"UTF-8");
    response.sendRedirect(url);
    
  6. Find the lines of code just above the try block:
    WebappContextParams params = …
    ...
    params.setParamRequestPathUrl(path);
    
    Replace them with the following:
    String viewer = sc.getInitParameter("viewer");
  7. In the Find field, enter // Get remote and click Find. The file scrolls to the comment.
  8. Delete the code that starts with the following comment:
    // Get remote services attributes.  The name "remote.sas.services.attributes"
    // should match the REMOTE_SERVICES_ATTRIBUTES string in the Foundation Services
    // ServletContextListener
    ServiceAttributeInterface [] attributes =
       (ServiceAttributeInterface [])getServletContext().getAttribute("remote.sas.services.attributes");
    
  9. After deleting the code, two errors will appear in the file where the attributes variable is used as a parameter. Delete the attributes parameter and the comma that precedes it where the two errors occur.
  10. Use the Find/Replace dialog box to make the following replacements. Optional replacements make the code more readable.
    Find
    Replace with
    Occurrences
    Required
    addRemoteUserContext
    addUserContext
    1
    Yes
    addRemoteSessionContext
    addSessionContext
    1
    Yes
    SAS_REMOTE_SESSION_CONTEXT
    SAS_SESSION_CONTEXT
    3
    No
    remoteSessionContext
    sessionContext
    3
    No
    remoteUserService
    userService
    2
    No
    remoteSessionService
    sessionService
    2
    No
    a remote
    a
    2
    No
  11. (Optional) Delete the backLabel and backDesc fields and any related code and constants. You can also delete any unused imports.
  12. Save and close the servlet source file.
  13. In the WEB-INF folder, right-click the web.xml file, and open it with a Text Editor or XML Editor.
  14. In the web.xml file, find the servlet declaration that corresponds to the servlet and update the init-parameters values for metadata-userid, metadata-password, and viewer, if necessary.
    You can encode the password using the com.sas.util.SasPasswordString class.
  15. Save and close the web.xml file.
Rebuild the project if it is not building automatically.

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

Switching the SAS Stored Process Servlet (uses SAS FS) template from using Remote Foundation Services to Local Foundation Services requires only a couple of simple changes to switch from using remote services to local services.
To update a Stored Process Servlet template:
  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 Stored Process 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 // Get remote and click Find.
  5. Delete the following code:
    // Get remote services attributes.  The name "remote.sas.services.attributes"
    // should match the REMOTE_SERVICES_ATTRIBUTES string in the Foundation Services
    // ServletContextListener
    final ServiceAttributeInterface [] attributes =
       (ServiceAttributeInterface [])getServletContext().getAttribute(
           FoundationServicesContextListener.REMOTE_SERVICES_ATTRIBUTES);
  6. After deleting the code, an error will appear in the file where the attributes variable is used as a parameter. Replace the attributes parameter with null.
  7. (Optional) Delete any unused imports.
  8. 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 and update the init-parameters values for metadata-userid and metadata-password, if necessary.
    You can encode the password using the com.sas.util.SasPasswordString class.
  11. Save and close the web.xml file.
Rebuild the project if it is not building automatically.