GithubHelp home page GithubHelp logo

akamai-ccu-rest-api-connector's Introduction

Velir Akamai CCU REST connector for AEM (CQ)

Description

This bundle provides a "ready to use" OSGI connector for the new Akamai CCU REST API. This connector has been written in groovy using the http-builder framework. It is designed to enable cache invalidation for AEM/CQ CMS when assets get invalidated. It can be easily configured with your own credentials and settings. The connector provides all services that you can request via the REST API like getPurgeStatus(), getQueueStatus(), and the most important purge().

The bundle is made to be as light as possible and can be installed just by itself. You will need groovy-all to be installed along with some others bundles like httpclient, commons-collections, commons-lang ... but they usually are already there.

Implementation

There are three major classes that manage the invalidation :

  • CcuManager is the interface of the connector itself that manages a pool of connections to request the Akamai CCU REST services. It offers a simple method's signature with predefined default values to invalidate cached objects. You can invalidate by CP code or ARL depending on your strategy. This class doesn't do any processing on the urls that you pass to it. It just makes sure that the list contains only unique values and adds them to the invalidate caching request.
def response = ccuManager.purgeByUrls(["http://www.mysite.com/test", "http://www.mysite.com/test2"])
def response = ccuManager.purgeByCpCode("CPCODE1")
def response = ccuManager.purge(["http://www.mysite.com/test", "http://www.mysite.com/test2"], PurgeType.ARL, PurgeAction.REMOVE, PurgeDomain.PRODUCTION)

The minimum configuration needed for that service are your Akamai credentials : "userName" and "password".

  • AkamaiEventHandler is an event handler that listens to com/day/cq/replication by default and just adds a job to a dedicated queue ("com/velir/aem/akamai/ccu/impl/FlushAkamaiItemsJob") if the path to invalidate begins with one of the values specified in the list "pathsHandled" (By default it is /content/dam).

  • FlushAkamaiItemsJob is the job that listens to the queue "com/velir/aem/akamai/ccu/impl/FlushAkamaiItemsJob" and calls the CCuManager.purgeByUrls(...) with the list of paths to invalidate. These paths are prepended by the rootUrl that represent the scheme + the domain without / at the end. ex: rootSiteUrl = "http://www.velir.com" and url = "/test" => The path to invalidate will be "http://www.velir.com/test"

You don't have to use the whole thing -- you could easily just use the CCuManager to invalidate your cache without using the listener.

Configuration

Each of these classes can be configured to fit you need and your Akamai credentials. In your JCR repository under /apps/your_app/config.author/ you can add the following configuration files:

  • CcuManagerImpl: com.velir.aem.akamai.ccu.impl.CcuManagerImpl.xml
<?xml version="1.0" encoding="UTF-8"?>
<jcr:root xmlns:sling="http://sling.apache.org/jcr/sling/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0"
    jcr:primaryType="sling:OsgiConfig"
    rootCcuUrl="https://api.ccu.akamai.com"
	userName="your_username"
	password="your_password"
	defaultPurgeAction="remove"
	defaultPurgeDomain="production"/>

userName/password: The credentials that you use to connect to the Akamai control website.

defaultPurgeAction : The default purge if not specified. - remove: (default) Remove the asset from the edge server and force the next request to the asset to reach the origin. - invalidate: Just invalidate the asset so the next query will still reach origin but can also still serve the stale value if origin is down.

defaultPurgeDomain : The default domain if not specified. - production: (default) - staging:

  • AkamaiEventHandler: com.velir.aem.akamai.ccu.impl.AkamaiEventHandler.xml
<?xml version="1.0" encoding="UTF-8"?>
<jcr:root xmlns:sling="http://sling.apache.org/jcr/sling/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0"
    jcr:primaryType="sling:OsgiConfig"
	pathsHandled="[/content/dam]"/>

pathsHandled: Comma separated list of paths that can be invalidated.

  • FlushAkamaiItemsJob: com.velir.aem.akamai.ccu.impl.FlushAkamaiItemsJob.xml
<?xml version="1.0" encoding="UTF-8"?>
<jcr:root xmlns:sling="http://sling.apache.org/jcr/sling/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0"
    jcr:primaryType="sling:OsgiConfig"
    rootSiteUrl="http://www.mysite.com"/>

rootSiteUrl: The root site url that is prepended to the path being invalidated.

Who are we

Velir is a Web Agency that provides a large scale of expertise in user experience design, content management, and marketing platform integrations. Our clients partner with us to develop and implement websites and applications powered by Sitecore and AEM/Adobe CQ. More on www.velir.com

License

This project is open source under MIT License.

More information

If you want to learn more about the CCU REST API: https://api.ccu.akamai.com/ccu/v2/docs/index.html

akamai-ccu-rest-api-connector's People

Contributors

intron avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.