The package location of Communities APIs is subject to change when upgrading from one major release to the next.
HTTP API - POST Requests
The HTTP API POST endpoints are PostOperation classes defined by implementing the SlingPostOperation interface (package org.apache.sling.servlets.post ).
The PostOperation endpont implementation sets sling.post.operation to a value to which the operation will respond. All POST requests with an:operation parameter set to that value will be delegated to this implementation class.
The PostOperation invokes the SocialOperation which performs the actions necessary for the operation.
The PostOperation receives the result from the SocialOperation and returns the appropriate response to the client.
An OperationExcepton can be thrown when performing an operation if the request is not valid or some other error occurs, such as internal errors, bad parameter values, improper permissions, etc. An OperationException is composed of an HTTP status code and an error message, which are returned to the client as the response to the PostOperatoin .
The social component framework recommends that the business logic responsible for performing the operation not be implemented within the SocialOperation class, but instead delegated to an OSGi service. Using an OSGi service for business logic allows a SocialComponent , acted upon by a SocialOperation endpoint, to be integrated with other code and have different business logic applied.
All OperationService classes extend AbstractOperationService , allowing additional extensions which can hook into the operation being performed. Each operation in the service is represented by a SocialOperation class. The OperationExtensions class can be invoked during operation execution by calling the methods
- performBeforeActions() Allows for pre-checks/pre-processing and validations
- performAfterActions() Allows for further modification of resources or invoking custom events, workflows, etc
OperationExtension classes are custom pieces of code that can be injected into an operation allowing for customization of operations to meet business needs. The consumers of the component can dynamically and incrementally add functionality to the component. The extension/hook pattern allows developers to focus exclusively on the extensions themselves and removes the need for copying and overriding entire operations and components.
Sample code is available in the Adobe Marketing Cloud GitHub repository. Search for projects prefixed with either aem-communities or aem-scf .
View the Coding Guidelines section for various coding guidelines and best practices for AEM Communities developers.
See also Storage Resource Provider (SRP) for UGC to learn about accessing user generated content.