Part 6 of the AEM Content Services tutorial covers ensuring all the necessary packages, configuration and content are on AEM Publish to allow consumption from the FAQ App.

Tutorial table of contents

Serve content from AEM Author

Note:

In production scenarios, AEM Content Services should serve content from AEM Publish, and from directly from AEM Author.

This section enables the FAQ App to connect directly to AEM Author, rather than AEM Publish, in the even the learners computer is unable to run both AEM Author and AEM Publish simultaneously. Serving the content from AEM Author requires anonymous access to be enabled via the Apache Sling Authenticator OSGi service, which is a security concern on live AEM systems.

If AEM Publish cannot be run, the Part 6b AEM package can be installed on AEM Author to:

If only AEM Author is used, skip to the Part 7 of the tutorial, as the rest of Part 6 concerns publishing content and configuration to AEM Publish.

Publishing the content for AEM Content Services

The configuration and content created to drive the FAQs through AEM Content Services should be published to AEM Publish for consumption.

Because AEM Content Services is built from Configuration, Assets and Pages, all of these pieces automatically enjoy AEM's OOTB content managment capabilities, including Workflow for review and processing, and activation/deactivation for pushing and pulling content from the public AEM Content Services end-points.

Note:

While it is possible to expose content using AEM Content Services directly from AEM Author, this should only be done for intra-organizational consumers and with caution. Potential pitfalls include:

  • AEM Author content is protected by default, requiring consuming Apps to provide credentials.
  • Evolving the Content Fragment Models, Template definitions and API Page authoring is immediately reflected on AEM Author (as the publication gateway does not exist). This can result in a volatile API that may break consuming Apps.
  • Traditionally AEM Author content is not cached at dispatcher. Special consideration should be taken to address if/how the JSON content can be safely cached or how to mitigate the load.

The preferred paradigm is to publish the content to AEM Publish, as described in this tutorial.

  1. Ensure any required Service Packs, Feature Packs and AEM Core Components and We.Retail application packages, as described in Part 1,  are installed on AEM Publish.

  2. Publish the FAQ Content Fragment Model

    1. Navigate to Tools > Assets > Content Fragment Models > We.Retail
    2. Select the FAQ Content Fragment Model
    3. Tap Publish in the top action bar
  3. part_6-_publish_pageswreferences

    Publish the API pages and all references (templates, assets, etc.)

    1. Navigate to AEM > Sites > We.Retail
    2. Select the API page
    3. Tap the Manage Publication in the top action bar
    4. Leaving the default Publish action as-is, tap Next in the top action bar
    5. Select the API page
    6. Tap +Include Children
    7. Uncheck all options in the Include Children modal
    8. Tap Done
    9. Tap Publish in the top action bar

    The page publication should publish all unpublished references as well, including:

    • The FAQ Main API Template
    • The FAQ Listing API Template
    • All references FAQ Content Fragments
    • Any other referenced content (ie. the Logo image)

    If changes are made to this content or configuration after the initial publication, make sure to re-publish to see the effects on AEM Publish.

  4. Lastly, the FAQ Content Fragment Model must be made anonymously accessible on AEM Publish.

    part_6_-_aem_publishpermissions

    On AEM Pubish, open CRXDE Lite.

    1. Ensure you are logged in as admin (or a user that can manage ACLs)
    2. Navigate to /conf/we-retail/settings/dam
    3. Select the cfm node
    4. Tap Access Control in the bottom-left pane
    5. Tap the + to add an ACL
    6. Add an ACE
      1. Principal: everyone
      2. Type: allow
      3. Privileges: jcr:read
    7. Log out of AEM Publish to return to anonymous state

Cross-Origin Resource Sharing (CORS) set up on AEM Publish

CORS (Cross-Origin Resource Sharing) must be enabled on AEM Publish to allow the React-based FAQ App to connect to AEM Publish and consume content. 

  1. As the admin user, access http://localhost:4503/system/console/configMgr
  2. Create a new configuration policy for the Adobe Granite Cross-Origin Resource Sharing Policy
  3. Set the Allowed Origins to http://localhost
  4. Set the Allowed Origins (Regexp) to .*
  5. Set the Allowed Methods to GET
    • Steps 3-4 allows the FAQ App to run on any host/port; This is only acceptable for local, tutorial use
  6. Click Save when done
2017-11-03_at_4_20pm

Verify AEM Publish

  1. In a new Web browser, ensure you are logged out of AEM Publish and request the following URLs (substituting http://localhost:4503 for whatever host:port AEM Publish is running on).

    These requests should return the same JSON response as when the corresponding AEM Author end-points were reviewed. If they do not, ensure all Publications succeeded (check the Replication queues) and review the error.log for AEM Publish.

Next step

Optionally, install the aem-content-service-tutorial.part6 solution package via AEM Publish's AEM's Package Manager. This package contains the configurations and content outlined in this part of the tutorials

This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License  Twitter™ and Facebook posts are not covered under the terms of Creative Commons.

Legal Notices   |   Online Privacy Policy