Thursday, May 16, 2019

Adobe Experience Manager (AEM) Link Transformer

I've been taught the wrong way to configure the Adobe Experience Manager (AEM) /etc/mappings in the past. There's zero documentation about how your URL, rendered from the Path Browser widget, gets Transformed to a relative URL hiding /content/sitename. Everyone says that the node name is important (it's not). So after spending an hour trying to sort this out, here's how it works.

You can create your own Link Rewriter by implementing the org.apache.sling.rewriter.Transformer interface. Adobe comes with one out-of-the-box that will use the Sling Mappings for Resource Resolution (a.k.a. /etc/mappings). The key is setting up your /etc/mapping correctly.

Here's an example of an /etc/mapping for a SSL (https) Site:


The OOTB Link Transformer will traverse your configured /etc/map directory from top to bottom, based on the node order. This is why setting the "jcr:primaryType" to "sling:OrderedFolder" is so important.

As it traverses the nodes, the first sling:internalRedirect regex that matches the link path will be used to rewrite the URL to what is set in the sling:match property. It uses the following values to rewrite the link:

  • Protocol is selected based on the parent http or https;
  • The regex grouping(s) that are created from the sling:internalRedirect property are used when rewriting the link; and
  • The link will be rewritten using a combination of the protocol and the sling:match regex.


This is why using a sling:OrderedFolder is so important. As all sites should be https; if we have multiple sites and domains, and we offer linking via AEM Path Browser between them, we need to configure the sites to create fully qualified URLs with https. Without an Ordered Folder, http configurations would be ordered above https and this wouldn't work. Same with doing multiple mappings within a protocol node.

Finally, whatever domain is configured to at the Dispatcher will be used as part of Link Transformer to match and write a relative path. So...

  • If your domain is bmxcode.com and that points to your reverse proxy;
  • Your domain bmxcode.blogspot.com points at your AEM instance; then
  • Set your "sling:match: property to "bmxcode.blogspot.com/$1" and this will rewrite your links as relative URLs (without the protocol and domain).


Hope this helps!

Friday, March 31, 2017

Adobe Activation Core Services (DTM) integrating with Adboe Experience Manager (AEM)

Adobe has rebranded their Dynamic Tag Manager (DTM) to now be called Activation Core Services.

There are two ways to integrate Adobe Experience Manager to Activation Core Services:
  • The Nice Way - Using Cloud Integrations
  • The Nasty Way - Adding the Head and Foot scripts directly to your templates.
I'm not going to go through the Nasty way, except that it's quick, dirty and, well, nasty!

Configuring it via Cloud Services you need to get your Marketing Cloud API token. To get this, you need to contact Adobe Client Care for API token by emailing clientcare@adobe.com.

https://helpx.adobe.com/dtm/kb/How_to_retrieve_API_token_for_DTM_account.html

Friday, October 28, 2016

Using Maven to create an RPM distribution

I've been digging around trying to find the minimum POM configuration to create an RPM distribution using Maven. Here it is for anyone else who needs it.

Friday, September 16, 2016

AEM Quick Tips

How to find the runmode
http://host:port/system/console/status-System%20Properties
Listed as sling.run.modes

How to find the version info
http://host:port/system/console/status-productinfo

Wednesday, August 24, 2016

Setting up an AEM 6.2 project with Archetype 10

Adobe hasn't released a new Archetype for Adobe Experience Manager 6.1 and 6.2, so the AEM dependancies have not been updated to use the aem-uber.jar. I noticed this when I extended WCMUse in 6.2 and it was not deprecated. This has been replaced by WCMUsePojo in 6.2. Here's what you need to do to get your AEM project working with aem-uber.jar.

Update the AEM dependency in the project root pom.xml file:

Update the referenced dependencies in the core, it.tests, ui.apps and ui.content module pom.xml files:

That should do it, now WCMUse is deprecated!

Thursday, July 28, 2016

Content Fragment Templates in AEM 6.2 means content centric sites!

Just had the opportunity to start digging through the AEM 6.2 changes, upgrades and improvements and I've stumbled across Content Fragment Templates. WOW! So many times I've seen, heard and been requested to be able to create Content Types and reuse content snippets in an easy and manageable fashion in AEM, and now it's possible.

Content Fragment Templates will allow us to create fragments of content, containing a combination of text, images and whatever we want, in a template format, with renditions, then drag and drop it into a page as if we were adding in an Asset. Great news for replying to every RFP that asks for this!

Check it out on the Adobe AEM Help:

https://helpx.adobe.com/experience-manager/using/content-fragments.html

Wednesday, June 8, 2016

AEM Lucene Index was corrupted after unexpected shutdown

We were seeing the following error message appearing in the error.log files after a recent AWS outage unexpectedly shutdown the whole EC2 instance:
org.apache.jackrabbit.oak.plugins.index.lucene.IndexTracker Could not access the Lucene index at /oak:index/lucene
java.io.EOFException: reached end of stream after reading 0 bytes; 32468 bytes expected
        at com.google.common.io.ByteStreams.readFully(ByteStreams.java:697)
        at org.apache.jackrabbit.oak.plugins.index.lucene.OakDirectory$OakIndexFile.loadBlob(OakDirectory.java:218)
        at org.apache.jackrabbit.oak.plugins.index.lucene.OakDirectory$OakIndexFile.readBytes(OakDirectory.java:262)
        at org.apache.jackrabbit.oak.plugins.index.lucene.OakDirectory$OakIndexInput.readBytes(OakDirectory.java:348)
        at org.apache.jackrabbit.oak.plugins.index.lucene.OakDirectory$OakIndexInput.readByte(OakDirectory.java:354)
        ...
AEM did not shut down cleanly when the AWS outage occurred. This log message had pushed the error.log file up to 40+ GB in size.

The first thing I checked was the "Lucene Index statistics" in the JMX Console. On a working Publish instance, this was returning the Lucene Index statistics with an Index Size of 1.2GB. On our suspect instance it was showing no statistics.

To fix this issue, we needed to kick off a Lucene Reindex. To do this you need to login to CRXDE on the instance, navigate to /oak:index/lucene and set the reindex attribute to true.

We were unable login to CRXDE. Our solution was to restart the instance, login as soon as it was available and set the reindex flag. If this solution doesn't work, you can temporarily disable the Oak Lucene bundle (named "Oak Lucene (org.apache.jackrabbit.oak-lucene)"), login to CRXDE and set the reindex flag and finally re-enable the Oak Lucene bundle.

Tuesday, May 31, 2016

Cheeky Git Commands

Just storing the list of git commands I seem to always come back to trying to find. Will reference the original source when possible.

Update the remote branch list on your local (Detlus Knowldge)
$ git remote update origin --prune

Replace the local version with the remote version
$ # fetch the latest changes
$ git fetch origin
$
$ # reset the branch to fetched changes (assuming you're working on master)
$ git reset --hard origin/master

Rename a local branch (pre-push to origin)
$ # checkout the branch to rename
$ git checkout branch-name
$ 
$ # rename the branch
$ git branch -m new-branch-name

Push and track a local branch to origin
$ # switch the branch to push and track
$ git checkout branch-name
$ 
$ # push the branch to origin
$ git push -u origin branch-name

Friday, May 6, 2016

ACS Commons twitter4j bundle not resolved

We were getting an annoying error in our log files due to the ACS Commons Twitter integration not being able to resolve the twitter4j dependancy. We were seeing this in the logs and one of the bundles remained in an "Installed" state.
06.05.2016 10:11:22.263 *INFO* [OsgiInstallerImpl] org.apache.sling.installer.core.impl.tasks.BundleStartTask Could not start bundle com.adobe.acs.acs-aem-commons-bundle-twitter [519]. Reason: {}. Wil
l retry.
org.osgi.framework.BundleException: Unresolved constraint in bundle com.adobe.acs.acs-aem-commons-bundle-twitter [519]: Unable to resolve 519.0: missing requirement [519.0] osgi.wiring.package; (&(osg
i.wiring.package=twitter4j)(version>=3.0.5)(!(version>=4.0.0)))
        at org.apache.felix.framework.Felix.resolveBundleRevision(Felix.java:3980)
        at org.apache.felix.framework.Felix.startBundle(Felix.java:2043)
        at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:976)
        at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:963)
        at org.apache.sling.installer.core.impl.tasks.BundleStartTask.execute(BundleStartTask.java:93)
        at org.apache.sling.installer.core.impl.OsgiInstallerImpl.executeTasks(OsgiInstallerImpl.java:735)
        at org.apache.sling.installer.core.impl.OsgiInstallerImpl.run(OsgiInstallerImpl.java:249)
        at java.lang.Thread.run(Thread.java:745)
In the OSGi Bundles, we're seeing the following:
After a bit of digging I came across the ACS AEM Bundles page and there it is, our missing twitter4j bundle!

Installing the com.adobe.acs.bundles.twitter4j-content-1.0.0.zip bundle resolved the missing constraints, allowed the ACS Commons Twitter bundle to be installed and got rid of the constant errors.

Hope this helps someone else out there!

Thursday, April 21, 2016

AEM Quartz Scheduler Cron Expressions

AEM uses the Quartz Scheduler to configure scheduled services. The full details of the schedule expression can be found at at the Quartz Scheduler Tutorial Lesson 6: CronTrigger.

Wednesday, April 20, 2016

Easier way to find AEM cURL Commands

We've been in the process of automating everything on AEM 6.0 and this means we have to dig around and find the cURL commands that we need to run from our Puppet scripts. I used to follow the technique where I would look for the POST request after clicking a button in AEM, then looking for the URL and what parameters were passed down, then manually compile a cURL command.

This has now all changed!

In Chrome, you can now open the Developer Tools, select the Network Tab, complete your POST request, then right click on the POST URL and select "Copy as cURL". This generates the cURL command! On Chrome Windows, it gives you the option to select a CMD or Bash version.
From here you can strip out what's not necessary and you're good to go!

Tuesday, April 19, 2016

The AEM 6.0 SP2 Author Primary and Standby Switch

I spent a couple hours getting a AEM 6.0 Service Pack 2 Author Standby switched to the Author Primary. The How to Run AEM with TarMK Cold Standby doc gives some great details about to create and configure the TarMK Cold Standby. There was a bit of a fail in the details of switching the Cold Standby to become the Primary.

After a bit of digging I came across Jayan Kandathil's blog post at CQ-OPS: How to Configure an AEM 6 “Cold Standby” Failover Instance and it pointed the the missing step in AEM 6.0.

Assuming that the Author Primary and Standby are active, working and syncing data, the steps to switch the Standby to Primary should go:

  1. Shutdown the Author Primary (it's failed anyway).
  2. Shutdown the Author Standby.
  3. Snapshot/backup the Author Standby crx-quickstart directory (to use when creating the the new Author Standby).
  4. On the Author Standby instance, move (if testing) or delete (if failover) the /crx-quickstart/install/install.standby directory.
  5. On the Author Standby instance, create the /crx-quickstart/install/install.primary directory. Add in the 3 required config files for the Author Primary.
  6. On the Author Standby instance, update the /crx-quickstart/bin/start script and set the runmode from "standby" to "primary"
  7. On the Author Standby instance, start AEM. This is now the Author Primary.
If you don't remove the install.standby, it still starts in Standby mode. In Standby mode, you can access the System Console, but you have no access to the CRXDE or to AEM Sites. Removing the directory is what ensures that it has started as the AEM Primary.

Monday, January 18, 2016

Creating a file in AEM via CURL

I've just come across a requirement to create a status.html file that's purely used as a health check file. to move a stack in or out of the load-balance pool. If the file exists (returns a 200) then the node is in the pool; if it 404's then it's out of the pool.

Searching around I couldn't find much until I came across this post on the Adobe Forums: How do i create a nt:file using Curl? and that gave me the correct command to use.
echo "OK" | curl -u admin:admin -T - http://localhost:4502/etc/hc/status.html
What we're doing here is creating the contents of the file using echo and piping this into the "-T -" as the file contents. Pretty nifty!

Friday, December 4, 2015

Setting up IntelliJ for AEM 6.1

I'm lucky enough to run my development on a MacBook Pro. I like the Terminal that's offered and after you get over using your thumb on the command key instead of your pinky on the Ctrl key, you're off and running! Here's how I set up IntelliJ for Mac.

If brew is your friend, cask is your bestie! Install both of these to set up your MacBook in minutes, all from the Terminal! It will set up and configure all the tools we need to set up IntelliJ. Here's the steps to install brew and cask, otherwise you can follow the details on each site.
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
brew install caskroom/cask/brew-cask
You'll have to enter your MacBook password for each and within a few minutes you're set up to start installing everything else. From the Terminal we can now search brew and cask to find the applications we need to install simply by running a search.
brew search enter-search-term...
First off the bat we need Java JDK 8 for AEM 6.1 so let's install Java 8 from the Terminal with Brew Cask.
brew cask install java
Now we want Apache Maven so that we can build our AEM Project. This one comes from Brew.
brew install maven
We might need GIT...
brew install git
And finally we want IntelliJ IDEA Community Edition...
brew cask install intellij-idea
Done! Now all our default software is installed!

Finally we need to install IntelliVault so that we can interact with the CRX repository. Open Eclipse then select Configure > Plugins > Browse Repositories... then type IntelliVault and install. IntelliJ will be restarted.

While this is restarting, we need to get a copy of FileVault. This comes as part of an AEM install located under <aem-install>/crx-quickstart/opt/filevault. Unzip filevault.zip.

After IntelliJ has restarted, navigate to Preferences > Other Settings > IntelliVault and update the following:

  • Vault Directory: <unzipped-filevalut.zip-dir>/bin


Tuesday, October 27, 2015

Bicycle Motocross - The tribute to BMX Bandits

Corey Bohan, Mike 'Hucker' Clark and Leanna Curtis have teamed up with Red Bull to bring new school flavour to the 80s cult classic, BMX Bandits.


The movie screams 80's! They're all wearing 80's style race pants, helmets and gloves. Hucker is rocking his 80's moustache. The BMX bikes have lashings of chrome and are dressed with Skyway Tuff's, rear brakes and custom pad sets.

One of the cool features was Corey Bohan's BMX bike. Watching closely at the start you can see that it has a custom BOHAN BMX padset and BOHAN BMX decals made to look just like the 80's Mongoose decals.

Watch for the Redline and Haro in the final race scene!

Tuesday, October 20, 2015

How to Remove Yellowing from a BMX Seat

A lot of old school BMX products deteriorate with age. One of the common deterioration found to white BMX seats is yellowing. Here is a Kashimax Handler BMX seat from 1987 that is in perfect condition, except for the yellowing.
The yellowing is caused by mildew growing within the pores of the seat. The best way to remove this without using harsh chemicals and potentially damaging the seat is to leave it hanging in direct sunlight for a few weeks.

I left the seat above for 6 months hanging from my bedroom window where it received direct afternoon sunlight over summer. Here it is now!
The yellowing is completely gone and the seat looks brand new! This seat is going onto my TBC Cobra Quad build.

I hope this tip helps someone else out.

Friday, October 16, 2015

Cranks for the TBC Cobra Quad

I picked up the Tioga chainring and Tioga spider as part of the TBC Cobra Quad purchase. The frame colour was matched to the spider and it suited nicely.

The Takagi CR-MO cranks came on another BMX bike that I purchased. They were a bit rusted and still had bits of the original candy blue. I stripped what was left of the candy blue, citric acid bathed the cranks and gave them a hand polish to get them up to a nice survivor look.

Friday, October 9, 2015

Anlun Stem Saved for the TBC Cobra Quad

Picked up this Anlun Freestyle stem on a $40 BMX find that popped up chained outside the local train station with a for sale sign on it. The whole BMX bike was covered in white house paint. A quick strip and polish and it's come up a nice survivor look.

When I pulled the stem apart, there was problems with the quill staying inside the stem head. I bought a sharp centre punch and gave the knurling a few taps to expand the quill size and help it to fit snugly into the stem head. I added a little Loctite to make sure it stayed in place when I did ride it.

Monday, September 28, 2015

Developing Page Content in AEM for a Future Release - Launches

We've had a requirement that has come from a customer who has basically said...
Each region/section of the home page is modified by a different content owner. They make changes independently of each other and they would like to have their region/section published independently.
Adobe Experience Manager (AEM) is a page-centric content management system at its core. You build pages from templates and components. There are other CMS's, such as OpenText Web Experience Manager (WEM) that are content-centric. You build content items and assign them to channels and/or a template to build a page.

Our customer has been using a content-centric CMS for almost a decade and old habits die slow. There has been a huge push to get things working "like the old system".

When you dig to the root of this requirement, what they are really after is a way to efficiently develop the content on an activated page for a future release while still maintaining the production content. That's where AEM has offered Launches!

To create a Launch from the Touch UI console, navigate to any page within the Sites Menu, click on Create > Create Launch. There is no need to navigate to the page that you want to create a Launch for as you are forced to navigate to it through the Launch Wizard. Navigate through to your page and click Next.
There are two main options when creating a launch; to create the launch with existing content or to create a launch using a new template to replace the page.

If you create a launch using a new template, you are creating a new page with a new template that will replace the existing page. The final step you are asked to select the new template before you create the launch.

If you select to use existing content then you can select to exclude sub pages and/or inherit source page live data. By default sub pages are copied over as part of a launch. Check the exclude sub pages box if you do not want the sub pages to be included as part of a launch. Inheriting source page live data is a feature that allows you to treat the launch page in the same way as a Live Copy page. Checking this option allows the launch page to stay in sync with any changes made to the source/live page unless you cancel inheritance.

The References section shows you how many Launches are associated with a page. To work with the content within a Launch, select the page and click References > Launches > Launch Title > Go to the page. This will open up the Launch Page.
If you have select to inherit the source page live data, you will need to Cancel inheritance on any component you want to modify. If the page does not inherit the source page live data, you can just change the page at will.

Launches also allow you to create a Nested Launches (Launch within a Launch). This is a very powerful feature but can also become very complicated! The key thing is that inheritance works from the point where it has been cancelled or from the source page. Sub Launches are labelled as the Launch Title (Parent Launch Title).

To promote a Launch, select the page and click References > Launches > Launch Title > Promote launch. From here you can specify the Scope (to promote the full launch or just the page changes and sub pages) and you can specify the Target if this is a Nested Launch. After the promotion has run, you can publish the page changes.

To delete a Launch from the Touch UI console, navigate to Tools > Operations > Launches. This will take you back into the Classic UI console. From here you can select and delete a configured Launch.