Thoughts On Metro and CQ5

I’ve recently been spending some time getting to know Windows 8 Metro Style Apps. One of the guiding principles that Microsoft is touting with Metro style apps is that content reigns above all. This ties well into Adobe’s CQ5 because, as we know, CQ5 is the preeminent content management system on the market today.

CQ is the facility by which content is created and managed. The underlying infrastructure of Apache Sling and the CRX content repository make accessing the data quite simple. Once the content is created in CQ, it can then be accessed via a rest call to Sling. Sling will then return the requested content in a JSON formatted string. The content being access can be changed by changing the URL. This is a function of Slng’s RESTful architecture.

One of the interesting things about building Metro style apps is that you have the option of a variety of languages to choose from: C#, JavaScript, VisualBasic, and F#. Since JSON and JavaScript go together like peas and carrots, that seems to be the natural route to take. Libraries for binary protocols like AMF exist for C#, but since we’re dealing with Sling and the JSON data it can provide, we’ll still with JavaScript.

Visual Studio comes with some templates for free form and grid applications. Any JavaScript framework that supports IE10 can be used to build Metro style apps. Unfortunately that rules out Sencha Touch at this time as it only supports WebKit based browsers.

The amalgamation of these two technologies comes together when we use CQ and Sling to serve data restfully to Metro style apps. This REST interface to the content allows the movement of content in both directions, into and out of the application.

CQ becomes the perfect facility for authoring and approving the content in Metro style applications. Using CQ presents the ability to use the incredibly powerful authoring facilities within CQ as well as the workflow engine that CQ also provides.

Adobe CQ5 and Windows 8 Metro Style apps are a match that will prove to provide that focus on content that Microsoft says is paramount. CQ5 will provide the content management facilities that make content available not just to Windows 8 Metro style apps, but the web and other apps as well. This is truly a match made in digital heaven.

Developing For CQ5 With IntelliJ IDEA 11

Adobe CQ5 is a powerful web content management platform built on top of theJava Content Repository (JCR), Apache Sling, and OSGi in the form of Apache Felix. Adobe offers their own IDE for developing with CQ5 called CRXDE, but it has, in my eyes, a major downfall. It’s based on Eclipse. Anyone who knows me well, knows I abhor Eclipse with a passion. Instead, I choose to use IntelliJ IDEA from JetBrains. It is, in my mind, a more powerful IDE, has more comprehensive language support out of the box, and is much more user-friendly than Eclipse. I commonly tell people that IntelliJ IDEA is what Eclipse wants to be when it grows up.

Recently, I’ve been doing more and more with CQ5. As I get more into it, I want to get away from Ecipse and back to the IDE I know and love. So I went out search the Internet for documentation on how to setup IntelliJ and CQ5. There are few resources out there, but they’re all either outdated (based on old versions of IntelliJ or CQ), or incomplete. I’ve decided to document my setup here for anyone else that is interested in setting up IntelliJ and getting started with CQ5.

For the sake of argument, this post is going to assume you know what you’re doing with CQ5. If not, I highly suggest you get up to speed before proceeding.

Requirements:

Once you have your CQ5 instance up and running, we’ll want to create a new project, so to do this we’ll have to leverage CRXDE, the browser-based “lite” IDE which comes with CQ5.

  1. Under the “/apps” folder, create a new folder and call it “sampleApp”
  2. Under the “sampleApp” folder, create a folder called “components”
  3. Under the “sampleApp” folder, create a folder called “templates”
  4. Under the “sampleApp” folder, create a folder called “install”
  5. Click the “Save All” button

This creates our project structure in the JCR. Next, we’ll need to setup a design folder for the project. To do this, we’ll need to use the Tools section of the CQ5 admin. From the tree that is presented, choose the “Designs” folder and click “New”. Enter the following property values:

  • Title: Sample App Design
  • Name: sampleApp
  • Template: Design Page Template

Once you have these values entered, click “Create”

Next, we will want to install the FileVault tool. Adobe outlines the process pretty well. Instructions on installing FileVault (a.k.a. VLT) can be found here. Just get vlt ready to use, don’t go through any of the SVN steps that Adobe outlines. That’s more than we want right now.

Once FileVault is setup, we’re ready to get into IntelliJ and setup the projects that we’ll need for CQ5. We’ll come back to FileVault later.

Launch IntelliJ and create a new project of type “Maven Module”. When presented with the Maven setup screen, enter the following information:

When the project is done setting up, you’ll need to create a folder under “src/main” called “content”. Under the new “content” folder, create another called “META-INF”. Within that META-INF folder, create a file called “filter.xml” with the following contents (feel free to copy & paste, and save the file when you’re done):

<?xml version="1.0" encoding="UTF-8"?>
<!-- Defines which repository items are generally included -->
<workspaceFilter version="1.0">
    <filter root="/apps/myApp" />
    <filter root="/etc/designs/myApp" />
	<filter root="/libs/foundation" />
</workspaceFilter>

Next, we’ll revisit the vlt tool. We’ll use it to checkout the CQ5 content into our project. Open a command line tool and change the current directory to “<ProjectRoot>/src/main/content”. Execute the command vlt –credentials admin:admin co http://localhost:4502/crx. This will create the folder “jcr_root” under your “content” folder, and recursively checks out the folders we specified in the filter.xml file. It also creates some FileVault metadata files, but no need to concern yourself with those.

Once you have the files checked out into our project, you’ll need to setup the dependencies that the project will need. Adobe would have you copy the JAR files from the CQ server or setup the CQ server as an Apache Archiva server, but I find it’s easier to just setup the Adobe Maven repo within your POM, or set it up in your central proxy, and use that. In this example, we’ll just set it up as another repo in our pom.xml file by adding the following code:

 

<repositories>
    <repository>
      <id>day-central</id>
      <name>Day Central (repo.adobe.com)</name>
      <url>http://repo.adobe.com/archiva/repository/day-central</url>
    </repository>
</repositories>

This allows us to use the following dependencies in our Maven configuration:

 

<dependency>
	<groupId>com.day.cq.wcm</groupId>
	<artifactId>cq-wcm-api</artifactId>
	<version>5.4.0</version>
</dependency>
<dependency>
	<groupId>com.day.cq</groupId>
	<artifactId>cq-commons</artifactId>
	<version>5.4.6</version>
</dependency>
<dependency>
    <groupId>com.day.cq.wcm</groupId>
    <artifactId>cq-wcm-taglib</artifactId>
    <version>5.4.0</version>
</dependency>
<dependency>
	<groupId>com.day.cq.wcm</groupId>
	<artifactId>cq-wcm-foundation</artifactId>
	<version>5.4.2</version>
</dependency>
<dependency>
	<groupId>org.apache.sling</groupId>
	<artifactId>org.apache.sling.api</artifactId>
	<version>2.2.0</version>
</dependency>

Note: Check your Apache Felix console (http://localhost:4502/system/console/bundles) for the version numbers the use for the various components as they relate to your install

This concludes the setup of the UI portion of the project, next we’ll turn to the core, which is what you’ll use to write any additional OSGi bundles that will be needed in your UI pre. From the file menu of IntelliJ, click “New Module”. Again, we will create, from scratch, a Maven Module. The Maven settings should be as follows:

Once the project is created, you need to add some more settings to the pom.xml file for the project:

 

<packaging>bundle</packaging>
<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <configuration>
                <source>1.5</source>
                <target>1.5</target>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.felix</groupId>
            <artifactId>maven-bundle-plugin</artifactId>
            <version>1.4.3</version>
            <extensions>true</extensions>
            <configuration>
                <instructions>
                    <Export-Package> com.day.cq5.sampleApp.*;version=${project.version} </Export-Package>
                </instructions>
            </configuration>
        </plugin>
    </plugins>
</build>
<dependencies>
    <dependency>
        <groupId>com.day.cq.wcm</groupId>
        <artifactId>cq-wcm-api</artifactId>
        <version>5.4.0</version>
    </dependency>
    <dependency>
        <groupId>com.day.cq</groupId>
        <artifactId>cq-commons</artifactId>
        <version>5.4.6</version>
    </dependency>
    <dependency>
        <groupId>org.apache.sling</groupId>
        <artifactId>org.apache.sling.api</artifactId>
        <version>2.2.0</version>
    </dependency>
</dependencies>

Note: Again, as before, make sure you check your Apache Felix console (http://localhost:4502/system/console/bundles) for the version numbers the use for the various components as they relate to your install

Once Maven has resolved the dependencies, right-click on the “src/main/java” folder and choose “New Package”. Enter a name of “com.day.cq5.sampleApp” and press OK. At this point, you have successfully setup a CQ5 project in IntelliJ IDEA 11. However, there are some caveats to how you actually make use of this. Before we get into that, I suggest you setup some shortcuts to using FileVault. You can also download a JCR plugin for IntelliJ if you like as well. That plugin may or may not help you in development.

Scripting with IntelliJ IDEA and CQ5 follows the same pattern that Adobe prescribes for scripting with Eclipse:

  1. Use CRXDE Lite (http://localhost:4502/crxde) to create a template and a component
  2. Use VLT to update the file system with the new files
  3. Develop the component script(s), i.e. JSPs, with IntelliJ IDEA
  4. Check the changes back into the JCR with VLT

Developing Java pre with IntelliJ for use in CQ5 is a bit trickier. What you’ll need to do is, in IntelliJ, add the “core” project as a dependency of the “ui” project. This will give you access to the Java pre you’re creating as you’re creating your templates for the UI. Before testing the pre on the server, you will need to install your bundle on the server. The following steps outline this process for you:

  1. Run the “install” maven goal for the “core” project. This will generate a jar file in the target directory of your “core” project.
  2. Copy that jar file to the “install” directory under the “jcr_root” directory in your “ui” project.
  3. Open a terminal and change the current directory to the “jcr_root” directory in your “ui” project.
  4. You can use the command vlt st -v to see any changes on the file system that are not in sync with the JCR.
  5. Place the jar file under version control with the command vlt add apps/sampleApp/install/your-jar-file-name.jar -v
  6. Commit the changes with vlt ci -v. This will take your template and jar file changes into the JCR.

Once your changes are into the JCR, you can view them by refreshing the CQ5 page that uses your template.

Hopefully, this will help get you up and running with IntelliJ IDEA as your IDE for CQ5 development. You will find that it is a much more powerful IDE for JSP development and is also much more fun to use than Eclipse. With a little configuration and patience, it can also be the ideal IDE for CQ5 development.

Amazon Introduces the Kindle Fire, Content Still Reigns

Amazon has entered the tablet market.  The Kindle Fire, however is not an “iPad killer”.  Calling it that is to miss the point completely.  Amazon has a wealth of content that they want to sell you.  Kindle books, the Amazon MP3 StoreAmazon VOD, and the Amazon App Store for Android.  All of these services, Amazon wants you to use, and they want to make it easier for you to access these services.  All of these content services that Amazon has been developing, including Amazon Web Serives, have been leading to the Kindle Fire.

The Kindle Fire simply serves as a conduit to that multitude of that content that Amazon has to offer, just as the iOS device of your choice is a conduit to the content available in the iTunes Store and the iOS App Store.  People forget that without the content, all these devices can do are personal information tasks (contacts, calendars, email) and surf the web.  This content is what adds the real value to the iPad and the Kindle Fire. The content makes the device.

Amazon will succeed here because they have what other entrants into this space don’t have (looking at you RIM), a strong and thriving content ecosystem.  Kindle books outsell their dead tree counterparts in a lot of cases these days.  Amazon VOD delivers content just as quickly as iTunes, and with an Amazon Prime membership, becomes even more attractive.  The Amazon MP3 store is routinely cheaper than iTunes and the Cloud Player enables a “listen anywhere” experience that iOS is just now implementing.  The Amazon App Store for Android has a “try it” feature that no other app store can offer.  Their content is primed and ready, they just needed a device to bring it all together, and today we got that.

The device is not the big story here.  The device is a commodity.  The ease-of-access to the content is the big story, along with the new web browser, but that’s a whole other ball of wax (privacy concerns, anyone?).  This is the first real challenger to the iOS ecosystem, and I think that because of the content it brings to the table, it will have the best chance of succeeding.

Geolocation Custom Swiz Metadata Processor

It’s metadata processor time again! I love the Swiz Framework because it’s so powerful, yet simple when you need it to be simple. That being said, it’s also got the ability to be easily extended in the form of custom metadata processors. codeviously, I’ve worked with creating a [Scheduled("5000")]metadata processor, but this time decided to take a mobile twist. AIR for Android gives us some new functionality with relation to reading the GPS unit of the device. There’s a new Geolocation class within the AIR API that gives you access to the data coming from the GPS. It can be a bit gnarly to work with and it’s not necessarily the easiest thing to understand.

The [Geolocation] metadata processor seeks to simplify this usage as much as possible. To use it, you have to declare it in your Swiz configuration just as you would any other metadata processor:

<fx:Declarations>

<geolocation:GeolocationSetup id="geoSetup" stopOnDeactivate="true"updateInterval="30000"/>

<swiz:Swiz>
<swiz:beanProviders>
<config:Beans/>
</swiz:beanProviders>

<swiz:config>
<swiz:SwizConfig
setUpEventType="{ Event.ADDED_TO_STAGE }"
setUpEventPhase="{ EventPhase.CAPTURING_PHASE }"
setUpEventPriority="50"
tearDownEventType="{ Event.REMOVED_FROM_STAGE }"
tearDownEventPhase="{ EventPhase.CAPTURING_PHASE }"
tearDownEventPriority="50"
eventPackages="org.andypowell.examples.events"
viewPackages="org.andypowell.examples.views"
defaultFaultHandler="genericFaultHandler"
defaultDispatcher="global"/>
</swiz:config>
<swiz:customProcessors>
<processors:GeolocationProcessor config="{geoSetup}"/>
</swiz:customProcessors>
</swiz:Swiz>

</fx:Declarations>

This is pretty straightforward, however, you’ll see another tag up there too:GeolocationSetup. This tag allows you to specify the updateInterval, or how long the app will wait until it tries to grab a new reading from the GPS, and thestopOnDeactivate variable. StopOnDeactivate will shutdown the GPS listeners when the application is moved to the background. There is generally not a reason why you’d set this to false since it has the possibility to kill your device’s battery by constantly polling the GPS.

Usage of the Geolocation metadata tag is pretty straightforward, as well.

...

[Geolocation]
public function updateLocation(latitude:Number,longitude:Number):void{
...
}

...

The method updateLocation will automatically be called at the updateInterval’s next run.

What does this mean for the developer who wants to use this? It means you don’t have to mess with setting up listeners with NativeApplication or listeners for Geolocation when it updates the lat/lon. It really simplifies the whole process for you. Head over to my github page and download the metadata processor and examples for yourself. Remember, it requires the Flex 4.5 SDK so make sure you grab that first.

HTML5, AIR for Android, and Geolocation

What Is A Flash Camp?

A Discussion on Flash and HTML5

Flash Camp Phoenix is Next Week (1/29/10)

The New Hotness of A Revamped Process

Flash Camp Atlanta Is Next Week