Obtaining Page Information in JSON Format
- Topics:
- Developing
CREATED FOR:
- Developer
To obtain the page information, send a request to the PageInfo servlet to obtain the page metadata in JSON format.
The PageInfo servlet returns information about resources in the respository. The servlet is bound to the URL https://<server>:<port>/libs/wcm/core/content/pageinfo.json
and uses the path
parameter to identify the resource. The following example URL returns information about the /content/we-retail/us/en
node:
http://localhost:4502/libs/wcm/core/content/pageinfo.json?path=/content/we-retail/us/en
- Single Page Applications
- Native Mobile Applications
- Other channels and touch-points external to AEM
Page Information Providers
Page components can be associated with one or more com.day.cq.wcm.api.PageInfoProvider
services that generate page metadata. The PageInfo servlet calls each PageInfoProvider service and aggregates the metadata:
- The HTTP client sends a request to the PageInfo servlet, which includes the URL of the page.
- The PageInfo servlet discovers which component renders the page.
- The PageInfo servlet calls each PageInfoProvider that is associated with the component.
- The servlet aggregates the metadata that each PageInfoProvider returns and adds the metadata to the HTTP response in a JSON object.
Default Page Information Providers
The /libs/foundation/components/page
component is associated with the following PageInfoProvider services:
- Default Page Status Provider: Information about the page status, such as whether it is locked, whether the page is the payload of an active workflow, and which workflows are available for the page.
- Live Relationship Info Provider: Information regarding Multi Site Management (MSM), such as whether the page is part of a Blue Print, and whether it is a Live Copy.
- Content Language Servlet: The language of the current page, and information about each language in which the page is available.
- Workflow Status Provider: Status information about the running workflow that has the page as a payload.
- Workflow Package Info Provider: Information about each workflow package that is stored in the repository, and whether each package contains the current resource.
- Emulator Info Provider: Information about the mobile device emulators that are available for this resource. If the page component does not render mobile pages, no emulators are available.
- Annotations Info Provider: Information about annotations that are on the page.
For example, the PageInfo servlet returns the following JSON response for the /content/we-retail/us/en
node:
{
"status":{
"path":"/content/we-retail/us/en",
"isLocked":false,
"lockOwner":"",
"canUnlock":false,
"lastModified":1467202845038,
"lastModifiedBy":"admin",
"timeUntilValid":0,
"onTime":0,
"offTime":0,
"replication":{
"numQueued":0
},
"isDesignable":true,
"isDeveloper":true
},
"isPage":true,
"pageResourceType":"weretail/components/structure/page",
"enableFragmentIdentifier":false,
"workflow":{
"isRunning":false
},
"workflows":{
"wcm":{
"models":[
{
"wid":"/etc/workflow/models/dam/adddamsize/jcr:content/model",
"label":"Add Asset Size",
"label_xss":"Add Asset Size"
},
{
"wid":"/etc/workflow/models/ac-newsletter-workflow-simple/jcr:content/model",
"label":"Approve for Adobe Campaign",
"label_xss":"Approve for Adobe Campaign"
},
{
"wid":"/etc/workflow/models/dam/dam-autotag-assets/jcr:content/model",
"label":"DAM Smart Tag Assets",
"label_xss":"DAM Smart Tag Assets"
},
{
"wid":"/etc/workflow/models/dam/update_asset/jcr:content/model",
"label":"DAM Update Asset",
"label_xss":"DAM Update Asset"
},
{
"wid":"/etc/workflow/models/cloudservices/DTM_bundle_download/jcr:content/model",
"label":"Default DTM Bundle Download",
"label_xss":"Default DTM Bundle Download"
},
{
"wid":"/etc/workflow/models/dam/dam_download_asset/jcr:content/model",
"label":"Download Asset",
"label_xss":"Download Asset"
},
{
"wid":"/etc/workflow/models/dam/dynamic-media-video-thumbnail-replacement/jcr:content/model",
"label":"Dynamic Media Video Thumbnail Replacement",
"label_xss":"Dynamic Media Video Thumbnail Replacement"
},
{
"wid":"/etc/workflow/models/dam/dynamic-media-video-user-uploaded-thumbnail/jcr:content/model",
"label":"Dynamic Media Video User Uploaded Thumbnail Process",
"label_xss":"Dynamic Media Video User Uploaded Thumbnail Process"
},
{
"wid":"/etc/workflow/models/projects/approval_workflow/jcr:content/model",
"label":"Project Approval Workflow",
"label_xss":"Project Approval Workflow"
},
{
"wid":"/etc/workflow/models/publish_example/jcr:content/model",
"label":"Publish Example",
"label_xss":"Publish Example"
},
{
"wid":"/etc/workflow/models/publish_to_campaign/jcr:content/model",
"label":"Publish to Adobe Campaign",
"label_xss":"Publish to Adobe Campaign"
},
{
"wid":"/etc/workflow/models/s7dam/request_to_publish_to_youtube/jcr:content/model",
"label":"Publish to YouTube",
"label_xss":"Publish to YouTube"
},
{
"wid":"/etc/workflow/models/projects/request_copy/jcr:content/model",
"label":"Request Copy",
"label_xss":"Request Copy"
},
{
"wid":"/etc/workflow/models/request_for_activation/jcr:content/model",
"label":"Request for Activation",
"label_xss":"Request for Activation"
},
{
"wid":"/etc/workflow/models/request_for_deactivation/jcr:content/model",
"label":"Request for Deactivation",
"label_xss":"Request for Deactivation"
},
{
"wid":"/etc/workflow/models/request_for_deletion/jcr:content/model",
"label":"Request for Deletion",
"label_xss":"Request for Deletion"
},
{
"wid":"/etc/workflow/models/request_to_complete_move_operation/jcr:content/model",
"label":"Request to complete Move operation",
"label_xss":"Request to complete Move operation"
},
{
"wid":"/etc/workflow/models/screens-update-asset/jcr:content/model",
"label":"Screens Update Asset",
"label_xss":"Screens Update Asset"
},
{
"wid":"/etc/workflow/models/s7dam/request_to_remove_from_youtube/jcr:content/model",
"label":"Unpublish from YouTube",
"label_xss":"Unpublish from YouTube"
},
{
"wid":"/etc/workflow/models/wcm-translation/create_language_copy/jcr:content/model",
"label":"WCM: Create Language Copy",
"label_xss":"WCM: Create Language Copy"
},
{
"wid":"/etc/workflow/models/wcm-translation/prepare_translation_project/jcr:content/model",
"label":"WCM: Prepare Translation Project",
"label_xss":"WCM: Prepare Translation Project"
},
{
"wid":"/etc/workflow/models/wcm-translation/translate-i18n-dictionary/jcr:content/model",
"label":"WCM: Prepare and Translate I18n-Dictionary",
"label_xss":"WCM: Prepare and Translate I18n-Dictionary"
},
{
"wid":"/etc/workflow/models/wcm-translation/sync_translation_job/jcr:content/model",
"label":"WCM: Sync Translation Job",
"label_xss":"WCM: Sync Translation Job"
},
{
"wid":"/etc/workflow/models/wcm-translation/update_language_copy/jcr:content/model",
"label":"WCM: Update Language Copy",
"label_xss":"WCM: Update Language Copy"
}
]
},
"translation":{
"models":[
{
"wid":"/etc/workflow/models/dam/adddamsize/jcr:content/model",
"label":"Add Asset Size",
"label_xss":"Add Asset Size"
},
{
"wid":"/etc/workflow/models/ac-newsletter-workflow-simple/jcr:content/model",
"label":"Approve for Adobe Campaign",
"label_xss":"Approve for Adobe Campaign"
},
{
"wid":"/etc/workflow/models/dam/dam-autotag-assets/jcr:content/model",
"label":"DAM Smart Tag Assets",
"label_xss":"DAM Smart Tag Assets"
},
{
"wid":"/etc/workflow/models/cloudservices/DTM_bundle_download/jcr:content/model",
"label":"Default DTM Bundle Download",
"label_xss":"Default DTM Bundle Download"
},
{
"wid":"/etc/workflow/models/dam/dam_download_asset/jcr:content/model",
"label":"Download Asset",
"label_xss":"Download Asset"
},
{
"wid":"/etc/workflow/models/dam/dynamic-media-video-thumbnail-replacement/jcr:content/model",
"label":"Dynamic Media Video Thumbnail Replacement",
"label_xss":"Dynamic Media Video Thumbnail Replacement"
},
{
"wid":"/etc/workflow/models/dam/dynamic-media-video-user-uploaded-thumbnail/jcr:content/model",
"label":"Dynamic Media Video User Uploaded Thumbnail Process",
"label_xss":"Dynamic Media Video User Uploaded Thumbnail Process"
},
{
"wid":"/etc/workflow/models/projects/approval_workflow/jcr:content/model",
"label":"Project Approval Workflow",
"label_xss":"Project Approval Workflow"
},
{
"wid":"/etc/workflow/models/publish_to_campaign/jcr:content/model",
"label":"Publish to Adobe Campaign",
"label_xss":"Publish to Adobe Campaign"
},
{
"wid":"/etc/workflow/models/s7dam/request_to_publish_to_youtube/jcr:content/model",
"label":"Publish to YouTube",
"label_xss":"Publish to YouTube"
},
{
"wid":"/etc/workflow/models/projects/request_copy/jcr:content/model",
"label":"Request Copy",
"label_xss":"Request Copy"
},
{
"wid":"/etc/workflow/models/request_for_deletion/jcr:content/model",
"label":"Request for Deletion",
"label_xss":"Request for Deletion"
},
{
"wid":"/etc/workflow/models/request_to_complete_move_operation/jcr:content/model",
"label":"Request to complete Move operation",
"label_xss":"Request to complete Move operation"
},
{
"wid":"/etc/workflow/models/screens-update-asset/jcr:content/model",
"label":"Screens Update Asset",
"label_xss":"Screens Update Asset"
},
{
"wid":"/etc/workflow/models/translation/jcr:content/model",
"label":"Translation Prepare",
"label_xss":"Translation Prepare"
},
{
"wid":"/etc/workflow/models/s7dam/request_to_remove_from_youtube/jcr:content/model",
"label":"Unpublish from YouTube",
"label_xss":"Unpublish from YouTube"
}
]
}
},
"translation":{
},
"design":{
"path":"/conf/we-retail/settings/wcm/templates/hero-page/policies",
"lastModified":0
},
"componentsRef":"/libs/wcm/core/content/components.1497341312569.json",
"editableTemplate":"/conf/we-retail/settings/wcm/templates/hero-page",
"msm":{
"msm:isLiveCopy":true,
"msm:isInBlueprint":false,
"msm:isSource":false
},
"launches":{
"isLaunch":false,
"isInLaunch":false
},
"language":"en",
"languages":{
"rows":[
{
"path":"/content/we-retail/us/en",
"exists":true,
"hasContent":true,
"lastModified":0,
"iso":"en",
"country":"gb",
"language":"English"
},
{
"path":"/content/we-retail/us/es",
"exists":true,
"hasContent":true,
"lastModified":0,
"iso":"es",
"country":"es",
"language":"Spanish"
}
]
},
"workflowInfo":{
"isRunning":false
},
"workflowPackageInfo":{
"workflowPackages":[
],
"selectedWorkflowPackages":[
],
"runningSelectedWorkflowPackages":[
]
},
"emulators":{
"groups":{
"responsive":{
"title":"Responsive Devices",
"description":"The devices in this group are able to display a website built using responsive design patterns.",
"path":"/etc/mobile/groups/responsive",
"galaxy5":{
"text":"Galaxy S5",
"action":"start",
"path":"/libs/wcm/mobile/components/emulators/galaxy5",
"canRotate":true,
"hasTouchScrolling":true,
"contentCssPath":"/etc/mobile/groups/responsive/static.css",
"width":1080,
"height":1920,
"device-pixel-ratio":3
},
"ipad":{
"text":"iPad",
"action":"start",
"path":"/libs/wcm/mobile/components/emulators/ios/ipad",
"canRotate":true,
"hasTouchScrolling":true,
"contentCssPath":"/etc/mobile/groups/responsive/static.css",
"width":768,
"height":1024,
"device-pixel-ratio":1
},
"iphone5":{
"text":"iPhone 5",
"action":"start",
"path":"/libs/wcm/mobile/components/emulators/ios/iphone5",
"canRotate":true,
"hasTouchScrolling":true,
"contentCssPath":"/etc/mobile/groups/responsive/static.css",
"width":640,
"height":1136,
"device-pixel-ratio":2
},
"iphone6":{
"text":"iPhone 6",
"action":"start",
"path":"/libs/wcm/mobile/components/emulators/ios/iphone6",
"canRotate":true,
"hasTouchScrolling":true,
"contentCssPath":"/etc/mobile/groups/responsive/static.css",
"width":750,
"height":1334,
"device-pixel-ratio":2
},
"iphone4":{
"text":"iPhone 4",
"action":"start",
"path":"/libs/wcm/mobile/components/emulators/ios/iphone4",
"canRotate":true,
"hasTouchScrolling":true,
"contentCssPath":"/etc/mobile/groups/responsive/static.css",
"width":640,
"height":960,
"device-pixel-ratio":2
},
"iphone6plus":{
"text":"iPhone 6 Plus",
"action":"start",
"path":"/libs/wcm/mobile/components/emulators/ios/iphone6plus",
"canRotate":true,
"hasTouchScrolling":true,
"contentCssPath":"/etc/mobile/groups/responsive/static.css",
"width":1080,
"height":1920,
"device-pixel-ratio":2.6
},
"nexuss":{
"text":"Nexus S",
"action":"start",
"path":"/libs/wcm/mobile/components/emulators/nexuss",
"canRotate":true,
"hasTouchScrolling":true,
"contentCssPath":"/etc/mobile/groups/responsive/static.css",
"width":320,
"height":533,
"device-pixel-ratio":1
}
}
}
},
"annotations":[
],
"permissions":{
"modify":true,
"replicate":true,
"read":true,
"create":true,
"delete":true,
"acl_read":true,
"acl_edit":true
},
"isTargetable":"true",
"responsive":{
"breakpoints":{
"phone":{
"width":650,
"title":"Smaller Screen"
},
"tablet":{
"width":1200,
"title":"Tablet"
}
}
}
}
Filtering Workflow Package Information
Configure the Day CQ WCM Workflow Package Info Provider service so that it returns information about only the workflow packages in which you are interested. By default, the Workflow Package Info Provider service returns information about every workflow package in the repository. Iterating over a subset of workflow packages uses less server resources.
The ID of the service is com.day.cq.wcm.workflow.impl.WorkflowPackageInfoProvider
. To create a filter, specify a value for a workflowpackageinfoprovider.filter
property.
Property values are prefixed with a + or - character followed by the package path:
- The path is the path of the root node of the workflow package. The path uses the FileVault syntax.
- To include a package, use the + prefix.
- To exclude a package, use the - prefix.
The service applies the cumulative result of all filters. For example, the following filter values exclude all workflow packages except for those in the Editions folder:
-/etc/workflow/packages(/.*)?
+/etc/workflow/packages/Editions(/.*)?
For example, to configure the service using CRXDE Lite:
-
Open CRXDE Lite (http://localhost:4502/crx/de).
-
In the config folder of your application, create a node:
- Name:
com.day.cq.wcm.workflow.impl.WorkflowPackageInfoProvider
- Type:
sling:OsgiConfig
- Name:
-
Select the node and add a property:
- Name:
workflowpackageinfoprovider.filter
- Type:
String[]
- Value: The path to the workflow package using the correct format.
- Name:
-
Click Save All.
To configure the service in your project source:
-
Locate or create the config folder for your AEM application in your project source.
For example, if you used the multimodule archetype of the Content Package Maven Plugin to create your project, the folder path is
<projectroot>/content/src/ for example content/src/main/content/jcr_root/apps/<appname>/config
. -
In the config folder, create a text file named com.day.cq.wcm.workflow.impl.WorkflowPackageInfoProvider.xml
-
Copy the following text to the file:
<?xml version="1.0" encoding="UTF-8"?> <jcr:root xmlns:sling="https://sling.apache.org/jcr/sling/1.0" xmlns:jcr="https://www.jcp.org/jcr/1.0" jcr:primaryType="sling:OsgiConfig" workflowpackageinfoprovider.filter="[]"/>
-
Inside the brackets (
[]
) that surround theworkflowpackageinfoprovider.filter
property, type a comma-separated list of filter values similar to the following example:workflowpackageinfoprovider.filter="[-/etc/workflow/packages(/.*)?,+/etc/workflow/packages/Editions(/.*)?]"/>
-
Save the file.
Creating a Page Information Provider
Create a custom Page Information Provider service to add page metadata that your application can easily obtain.
-
Implement the
com.day.cq.wcm.api.PageInfoProvider
interface. -
Bundle and deploy the class as an OSGi service.
-
Create a page component in your application. Use
foundation/components/page
as the value of thesling:resourceSuperType
property. -
Add a node below the component node named
cq:infoProviders
. -
Below the
cq:infoProviders
node, add a node for your PageInfoProvider service. You can specify any name for the node. -
Add the following property to your PageInfoProvider node:
- Name: className
- Type: String
- Value: The PID of your PageInfoProvider service.
For resources that use your application page component as the sling:resourceType
, the PageInfo servlet returns the custom PageInfoProvider metadata in addition to the default PageInfoProvider metadata.
Example PageInfoProvider implementation
The following Java class implements PageInfoProvider and returns the published URL of the current page resource.
package com.adobe.example;
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Properties;
import org.apache.felix.scr.annotations.Property;
import org.apache.felix.scr.annotations.ReferenceCardinality;
import org.apache.felix.scr.annotations.Service;
import org.apache.felix.scr.annotations.Reference;
import org.apache.sling.api.SlingHttpServletRequest;
import org.apache.sling.api.resource.Resource;
import org.apache.sling.api.resource.ResourceResolver;
import org.apache.sling.commons.json.JSONException;
import org.apache.sling.commons.json.JSONObject;
import com.day.cq.wcm.api.Page;
import com.day.cq.wcm.api.PageInfoProvider;
@Component(metatype = false)
@Properties({
@Property(name="service.description", value="Returns the public URL of a resource.")
})
@Service
public class PageUrlInfoProvider implements PageInfoProvider {
@Reference(cardinality = ReferenceCardinality.OPTIONAL_UNARY)
private com.day.cq.commons.Externalizer externalizer;
private String fetchExternalUrl(ResourceResolver rr, String path) {
return externalizer.publishLink(rr, path);
}
public void updatePageInfo(SlingHttpServletRequest request, JSONObject info, Resource resource)
throws JSONException {
Page page = resource.adaptTo(Page.class);
JSONObject urlinfo = new JSONObject();
urlinfo.put("publishURL", fetchExternalUrl(null,page.getPath()));
info.put("URLs",urlinfo);
}
}
The following example, in CRXDE Lite, shows the page component that is configured to use the PageUrlInfoProvider service:
The PageUrlInfoProvider service returns the following data for the /content/we-retail/us/en
node:
"URLs": {
"publishURL": "http://localhost:4503/content/we-retail/us/en"
}
Experience Manager
- Developing User Guide overview
- Introduction for Developers
- Getting Started Developing AEM Sites - WKND Tutorial
- AEM Core Concepts
- Structure of the AEM Touch-Enabled UI
- Concepts of the AEM Touch-Enabled UI
- AEM Development - Guidelines and Best Practices
- Using Client-Side Libraries
- Developing and Page Diff
- Editor Limitations
- The CSRF Protection Framework
- Data Modeling - David Nuescheler’s Model
- Contributing to AEM
- Security
- Reference Materials
- Create a Fully-Featured Website (Classic UI)
- Designs and the Designer (Classic UI)
- Platform
- Sling Cheatsheet
- Using Sling Adapters
- Tag Libraries
- Templates
- Using the Sling Resource Merger in AEM
- Overlays
- Naming Conventions
- Creating a New Granite UI Field Component
- Query Builder
- Tagging
- Customizing Pages shown by the Error Handler
- Custom Node Types
- Adding Fonts for Graphic-Rendering
- Connecting to SQL Databases
- Externalizing URLs
- Creating and Consuming Jobs for Offloading
- Configuring Cookie Usage
- How to programmatically access the AEM JCR
- Integrating Services with the JMX Console
- Developing the Bulk Editor
- Developing Reports
- eCommerce
- Components
- Core Components
- Style System
- Components Overview
- AEM Components - The Basics
- Developing AEM Components
- Developing AEM Components - Code Samples
- JSON Exporter for Content Services
- Enabling JSON Export for a Component
- Image Editor
- Decoration Tag
- Using Hide Conditions
- Configuring Multiple In-Place Editors
- Developer Mode
- Testing Your UI
- Components for Content Fragments
- Obtaining Page Information in JSON Format
- Internationalization
- Classic UI Components
- Headless Experience Management
- Headless and Hybrid with AEM
- Enabling JSON Export for a Component
- Single Page Applications
- SPA Introduction and Walkthrough
- SPA WKND Tutorial
- Getting Started with SPAs in AEM - React
- Getting Started with SPAs in AEM - Angular
- Implementing a React Component for SPA
- SPA Deep Dives
- SPA Editor Overview
- Developing SPAs for AEM
- SPA Blueprint
- SPA Page Component
- Dynamic Model to Component Mapping for SPAs
- SPA Model Routing
- SPA and Adobe Experience Platform Launch Integration
- SPA and Server-Side Rendering
- SPA Reference Materials
- HTTP API
- Content Fragments
- Experience Fragments
- Development Tools
- Development Tools
- AEM Modernization Tools
- Dialog Editor
- Dialog Conversion Tool
- Developing with CRXDE Lite
- Managing Packages Using Maven
- How to Develop AEM Projects Using Eclipse
- How to Build AEM Projects using Apache Maven
- How to Develop AEM Projects using IntelliJ IDEA
- How to use the VLT Tool
- How to use the Proxy Server Tool
- AEM Brackets Extension
- AEM Developer Tools for Eclipse
- AEM Repo Tool
- Personalization
- Extending AEM
- Customizing Page Authoring
- Customizing the Consoles
- Customizing Views of Page Properties
- Configuring your Page for Bulk Editing of Page Properties
- Customizing and Extending Content Fragments
- Extending Workflows
- Extending the Multi Site Manager
- Tracking and Analytics
- Cloud Services
- Creating Custom Extensions
- Forms
- Integrating Services with the JMX Console
- Developing the Bulk Editor
- Extending Classic UI
- Testing
- Best Practices
- Best Practices Overview
- AEM Development Guidelines and Best Practices
- Development Best Practices
- Content Architecture
- Software Architecture
- We.Retail Reference Implementation
- We.Retail Reference Implementation
- Trying out Content Fragments in We.Retail
- Trying out Core Components in We.Retail
- Trying out Editable Templates in We.Retail
- Trying out Responsive Layout in We.Retail
- Trying out the Globalized Site Structure in We.Retail
- Trying out Experience Fragments in We.Retail
- Coding Tips
- Code pitfalls
- OSGI Bundles
- JCR Integration
- Code Samples
- Troubleshooting Slow Queries
- Mobile Web
The Perfect Blend: A New Era of Collaboration with AEM and Workfront
Adobe Customer Success Webinars
Wednesday, Apr 2, 5:00 PM UTC
Explore how Adobe Experience Manager and Workfront integrate to help teams move from ideation to delivery without the usual bottlenecks, ensuring content is organized, on-brand, and ready to go live faster.
RegisterB2B Reimagined: Transforming Go-to-Market Strategies for Profitable Growth
B2B brands are facing a digital revolution. Buyers expect hyper-relevant content and self-service, while internally AI is transforming...
Wed, Mar 19, 1:00 PM PDT (8:00 PM UTC)
Rapid Feature Releases with AEM Cloud: Telegraph Media Group’s RDE Strategy
Hear how Telegraph Media Group, the award-winning publisher of The Daily Telegraph, The Sunday Telegraph, The Telegraph Magazine,...
Wed, Mar 19, 3:30 PM PDT (10:30 PM UTC)
Connect with Experience League at Summit!
Get front-row access to top sessions, hands-on activities, and networking—wherever you are!
Learn more