Wednesday, 5 February 2014

Adobe CQ/AEM package install behaviour - filter.xml

Encountered a problem that whenever a package is deploy / installed, it will overwrite existing content and folder structure that was setup.

Using the filter.xml under META-INF/vault, we can configure it in a way that it keep existing content intact.

http://www.wemblog.com/2012/04/how-to-change-package-install-behavior.html

There are three Modes available:

  1. replace: Normal behavior. Existing content is replaced completly by the imported content, i.e. is overridden or deleted accordingly.
  2. merge: Existing content is not modified, i.e. only new content is added and none is deleted or modified
  3. update: Existing content is only updated but never deleted



Add it under META-INF/vault/filter.xml
<?xml version="1.0" encoding="UTF-8"?>

<workspaceFilter version="1.0">
    <filter root="/content" mode="update"/>
</workspaceFilter>


Advance package filtering include / exclude regular expression

http://aemfaq.blogspot.com.au/2013/04/cq5-package-filter-includeexclude.html

Example META-INF/vault/filter.xml
<?xml version="1.0" encoding="UTF-8"?>

<workspaceFilter version="1.0">
    <filter root="/content" mode="update">
        <include pattern="/content/foo/bar/*"/>
        </filter>
</workspaceFilter>



Tuesday, 14 January 2014

Java - re-using test classes across different projects | modules | packages

Reference:
http://blog.frankel.ch/re-use-your-test-classes-across-different-projects

In the POM.xml of the project|module that you have your testing code in src/test/java, include this plugin:
<project>
  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-jar-plugin</artifactId>
        <version>2.2</version>
        <executions>
          <execution>
            <goals>
              <goal>test-jar</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>
</project>

The test artifact is stored side-by-side with the main artifact once deployed in the repository. Note that the configured test-jar is bound to the install goal. E.g:
[your project|module name]/src/main/
[your project|module name]/src/test/


In the other project|module POM.xml, include this dependency:
<dependency>
  <groupId>com.rookiegeek.foobar</groupId>
  <artifactId>foo-bar</artifactId>
  <version>1.0.0</version>
  <type>test-jar</type>
  <scope>test</scope>
</dependency>

The type has to be test-jar instead of simply jar in order to Maven to pick the attached artifact and not the main one. Also, note although you could configure the dependency with a classifier instead of a type, the current documentation warns about possible bugs and favor the type configuration.

Monday, 16 December 2013

How to list and sort directories by size in Linux/Unix

Had a brain freeze and forgot how to list all files within a directory and sort by size - google returned me this awesome gem:
du -k | sort -nr | more

Or human readable output:
du -sh

http://snippets.aktagon.com/snippets/86-how-to-list-and-sort-directories-by-size-in-linux-unix

Thursday, 7 November 2013

CQ component - disable target in context menu

http://aemfaq.blogspot.com.au/2013/05/how-to-disable-target-context-menu-in.html

The "target" option in the context menu of a CQ component can be hidden/disable by setting cq:editConfig/cq:disableTargeting to true.


In code level:
<?xml version="1.0" encoding="UTF-8"?>
<jcr:root xmlns:cq="http://www.day.com/jcr/cq/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0"
    cq:dialogMode="floating"
    jcr:primaryType="cq:EditConfig" cq:disableTargeting="{Boolean}true"/>


Reference: http://forums.adobe.com/message/5334713