Fill PDF forms in an AEM Service
If you want to provide a download of customized PDF files, you can go the full-fledged way and buy into the Adobe world or build a slim custom solution which brings no additional cost. This post shows a simple usecase where a PDF form is uploaded to DAM and later filled inside an OSGi service and delivered to the user by a Servlet. Dependencies: Apache PDFBox There are multiple open source PDF libraries we could use, but in the end Apache PDFBox1 is the weapon of choice.
Sample Application for the AEM-Solr Integration
After two quite theoretic posts about the basics of Solr in AEM and the schema configuration it’s time for a practical one. If you have a local AEM instance running, you can use the application I pushed into the solr-aem Github repository1 to get a running website with Solr integration. The README.md2 gives a detailed view on the application therefor I constrain the blog post to the basics. The application includes a simple Search page where Paging3, Highlighting4 and Spell checking5 are used.
Setup a Solr schema.xml for AEM
Now that we have successfully convinced AEM to use Solr as Indexer, the next step is to create a Schema which is used by Solr for Index/Query Processing. Why do we need a schema? Solr does not know anything about your data structure but you want it to perform complex operation like fulltext searches, faceting etc. To allow Solr to create a fast index, you need to define which fields you want to index and which operations should be performed upon index or query1.
Create an AEM index utilizing Solr
Last month I discussed the options to use Elasticsearch as search engine for AEM content. The presented approach required a custom implementation of a replication agent available on Github1. As an alternative I’ll demonstrate how the build in functionality of Jackrabbit Oak2 to index into Solr3 can be used. Just like Elasticsearch4 Solr is a search platform based on Lucene5. By default Jackrabbit uses the embedded Lucene index in AEM to create an index both for internal queries and custom, application-specific queries (using XPath and SQL-2).
Import Wikipedia Pages into AEM
Testing a search-engine like ElasticSearch in AEM requires a certain amount of pages you can index and search into. There are multiple great sources for content available but (of course) none of them provides an export into AEM. For example you can download dumps from Stackoverflow1 or Wikipedia2. I think espacially Wikipedia dumps are a quite interesting source of content as they are available in nearly (?) all languages (e.
AEM: Map local filesystem into crx repository
With the wide introduction of sightly into AEM development it became more and more useful to mount a Filesystem into a local AEM instance. Now you can edit sightly and other files in your favorite IDE and see the changes in AEM without the need of a deployment. On the sling website you can find and download1 the FileSystem Provider which brings this functionality. You can install it in the Felix console and need to configure the local path and the webapp root in crx.
AEM: Rebuild Client Libraries
In some situations you might need to rebuild your client libraries manually.
Search AEM Content index in Elasticsearch
In the last blog post I gave a brief introduction into the integration of Elasticsearch1 into AEM. This followup will explain how the indexed data can be used in a search application in AEM. Although you can use every Elasticsearch client you want (e.g. the Java REST Client2), an easy way is the usage of one of the two Searches implemented in this package. Both Search classes (Search.java3 and PageSearch.
Index AEM Content with Elasticsearch
With the build-in Lucene Index1 in AEM, most of the requirements for a flexible and fast search can be implemented with minimal effort and no need for additional dependencies. The functionality for queries is wrapped in the QueryBuilder API2 and the index configuration3 done in CRX. A query can search in multiple fields for values or full-text and provide scoring, excerpts etc. Depending on the supported languages, you can also configure Analyzers4 for Stemming, Stop Words etc.
AEM: Handling Page-Replication events with a custom Transport Handler
An usual approach to react to different events in AEM is the implementation of an Event Handler1. In your implementation you subscribe to one or more event topics which are then passed into the void handleEvent(Event event) method. The interface for an Event Handler is quite simple, so this is a very lean approach. You can find an example in Adobe’s Knowledge Base Although you can subscribe to the Replication Event2, there are some usecases where an EventHandler might not work for you.
Deploy Elasticsearch Rest Client into OSGi
Up until Elasticsearch 5.0.0 alpha 4 the official Elasticsearch Java client required the complete Elasticsearch distributable included in your application. Although there are several alternative clients available, the new Java Rest Client brings most of the functionallity bundled in a small package. Since the artifact published by elastic does not contain the required OSGi bundle information I created a wrapper you can find on Github1. Dependencies All dependencies are inherited from the RestClient and available as OSGi Bundles: