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