47 Working with the Articles Sample Application

The Articles sample application is a simple content management application for managing article assets. When you work with the application’s richly documented source code and a self-installation process, it will help you gain knowledge that you’ll find useful in developing applications.

Topics:

About the Articles Sample Application

The Articles home page displays two articles that you can edit directly in WEM from the custom interface. In this application, you can use the WebCenter Sites REST API to perform a search query from Java code and a modification asset query from JavaScript code. You will be able to run the Articles application and REST services on different application servers.

Cross-domain restrictions in JavaScript prevent AJAX calls directly from the Articles application to the REST services. Therefore, a simple ProxyController is introduced to redirect calls from JavaScript to WEM REST Web Services. Custom implementations may reuse this controller implementation.

The application's home page looks like this figure:

The Articles application is based on the Spring MVC framework. Articles includes a predefined administrative user named fwadmin with password xceladmin, who is assigned to the REST group named RestAdmin. The application's self-installer contains specifications for registering the Articles application and installing its asset model and sample articles. The application does not have internally configured sites or role-protected functions. It has a single, iframe view. Additional specifications are available in Working with the Articles Sample Application.

Launching the Articles Sample Application

To be able to launch the Articles sample application, you build and deploy it, and then run the installer.

Topics:

Building and Deploying the Articles Application

  1. Determine or create the site to which you will assign the sample Articles application. The default site is FirstSiteII (a sample WebCenter Sites CM site). It is possible that FirstSiteII is not installed on your system.

    To select or create a site, log in to WEM Admin at the URL:

    http://<server>:<port>/<cs_application_context>/login

    using the credentials of a general administrator (fwadmin/xceladmin are the default values).

    Note:

    In step 5, you specify the site you have chosen here, which allows the installer to enable the application's asset model and assets on that site.

  2. Download and install Java Development Kit 8 Update 51 (or later).
  3. Download the latest Apache Ant from http://ant.apache.org/ and place the Ant bin directory into the system PATH.
  4. Copy servlet-api.jar to the Articles application lib folder. The jar file can be taken from your application server's home directory (for example, Tomcat's servlet-api.jar is located in the home lib directory).
  5. Set the following parameters in the applicationContext.xml file (in src\articles\src\main\webapp\WEB-INF\):
    • casUrl: Specify the URL of the CAS application: http://<server>:<port>/<context_path>

    • csSiteName: Specify the name of the site that you selected in step 1.

    • csUrl: Specify the URL where the WebCenter Sites platform is running: http://<server>:<port>/<context>

    • csUserName: The default value is fwadmin. This is the application's predefined user, a general administrator with membership in the RestAdmin group which has unrestricted permissions to REST services. If you specify a different user, you must name a user equivalent to fwadmin. For instructions about creating a general administrator, see Creating Users in Administering Oracle WebCenter Sites.

    • csPassword: Specify the predefined user's password.

    • articlesUrl: Point to the URL where the sample application is accessed.

  6. Run the Ant build with the default target (enter ant on the command line).
  7. Deploy the resulting target/articles-1.0.war to an application server.

    On deployment, the following content is copied from source to target: The contents of the lib folder are copied to /WEB-INF/lib. The contents of the resources folder are copied to /WEB-INF/classes/. For information about the structure of the source application, see Developing Applications with WEM Framework.

    Note:

    The mcast port in cas-cache.xml is not replaced by the installer. The mcast port is left as @casCacheMultiCastGroupPort@ and the application will fail to deploy unless manually edited.

    A solution is to copy cas-cache.xml from WebCenter Sites into the Articles application. This can eliminate some problems associated with manually updating the mcast address and port.

  8. In the customBeans.xml file (located in the sitesinstall/config folder), specify the trusted URLs CAS can redirect a visitor to upon successful login. For example, add the following URL to the customBeans.xml file:
    <value>http://<hostname>:<portnumber>/articles-1.0/*</value>
    

Registering the Articles Sample Application

The Articles application has a self-installer, which starts running when you log in to the install.app page. The installer registers the sample application (including the view) and creates its data model and assets in the WebCenter Sites database.

Note:

Specifications for the registration asset types FW_View and FW_Application can be found in the Java API Reference for Oracle WebCenter Sites and in Registering Applications Manually in WEM Framework.

To run the Articles installer:

  1. Navigate to the install.app page:

    http://<hostname>:<portnumber>/<context_path>/install.app
    

    For example:

    http://localhost:9080/articles-1.0/install.app
    
  2. Use any credentials to log in.

    The application's predefined user, specified by csUserName and csPassword , provides you with permissions to the application. The sample application does not perform authorization checks as it does not use roles.

  3. The self-installation process invokes InstallController.java, which first registers the application (including the view, in an application Bean), then writes the sample asset type and assets to the database.

    1. InstallController.java registers the Articles application with the WEM Framework:

      • InstallController.java creates an application asset named Articles (asset type FW_Application) in the WebCenter Sites database.

        The iconurl attribute points to the URL where the icon representing the application is located.

        The layouturl attribute specifies the URL of the layout.app page (implemented by LayoutController.java). The layout.app page defines the application layout.

        The layouttype attribute takes the default (and only) value: layoutrenderer. Using the layoutrenderer value, the UI container is responsible for rendering the application's associated views by using the layout.app page, specified by layouturl.

      • InstallController.java creates a view asset named ArticlesView (asset type FW_View) in the WebCenter Sites database. The association between the view asset and the application asset is made through the views attribute in the FW_Application asset type.

    2. InstallController.java installs the application's asset model and sample assets:

      • Creates the application's FW_Article asset type in the WebCenter Sites database. (FW_Article is a basic asset type defined in InstallController.java.)

      • Enables the FW_Article asset type on the site that was specified in the csSiteName parameter in applicationContext.xml (step 5 of Building and Deploying the Articles Application).

      • Writes the two sample article assets to the FW_Article asset type tables. (The articles' text and images are stored in: /sample app/articles/src/main/resources/install.)

    3. InstallController.java creates an asset type-based index to support searches on assets of type FW_Article. (The controller specifies index configuration data.)

  4. When the installation process completes successfully, InstallController.java displays a confirmation (at http://<server>:<port>/articles/install.app), that the sample data imported successfully and directing you to the Home page (home.app).

Testing the Articles Application

Try out the Articles sample application. All you need to do is navigate to the home page and log in.

To test the Articles application:

  1. Navigate to the home.app page:
    http://<hostname>:<portnumber>/<context_path>/home.app
    

    For example:

    http://localhost:8080/articles-1.0/home.app
     
  2. Use any credentials to log in.

    The application's predefined user, specified by csUserName and csPassword , provides you with permissions to the application. The sample application does not perform authorization checks as it does not use roles.

    WEM displays the application's home page.

  3. To experiment with this application (for example assign it to other sites and add users), use WEM Admin.