Split Apache OAK stores

Split Apache OAK stores

Overview

One of big projects drawbacks is a size of Apache OAK which is growing very fast due to big amount of assets , binary files, background processes which are care about repository data consistency, updates and so on. Of cause we can use compaction every week but there is exists another approach – split segment and blob store out of Tar files (which is an OOTB store implementation). One of the available option is to split NodeStore and BlobStore. More about BlobStore you can read here – click. Continue reading “Split Apache OAK stores”

New Configuration Approach for AEM 6

Since OSGI R6 we can beautify old style configurations for AEM 6 and create more readable, maintainable and loosely coupled code. In this target Declarative Services 1.3 (DS 1.3)will assists to us. Let’s consider how this can be reached step by step in scope of AEM 6 and Java 8. I wouldn’t provide a long description with explanation all pros and cons of this approach, what Declarative Services is and other things. Anyway you can simply google it if it’s interesting for you. Continue reading “New Configuration Approach for AEM 6”

JCR-SQL2 Query with Examples

Introduction

OOTB Apache OAK allow to create queries on SQL(deprecated), XPath(deprecated), JCR-JQOM and JCR-SQL2. It’s obvious that there is not a good point to explain deprecated SQL and XPath. This is a little How-To article which try to cower JCR-SQL2 queries for Apache Jackrabbit/OAK. Apache OAK has a more strict JCR-SQL2 syntax therefore some queries which are working correct on Apache Jackrabbit wouldn’t be executed on Apache OAK so we should always hold this in mind. Anyway let’s deal with JCR-SQL2 queries.
Continue reading “JCR-SQL2 Query with Examples”

How to make JSP scriplets on Java 7, Java 8 and above on Apache Sling and Adobe AEM

Sling implementation allow to render JSP with scriplets (of cause we using scriplets instead of Groovy console for hot-fixes). By default JSP compiler allow to write code compatible with Java 6 therefore if on server we has JVM version greater than 6 and desire to write code for recent JVM with additional benefits like Diamond operators from Java 7 or Lambdas and Streams from Java 8 we should configure JSP Scripts Handler to process required Java version otherwise we will see the compilation error: Continue reading “How to make JSP scriplets on Java 7, Java 8 and above on Apache Sling and Adobe AEM”

How to deal with request parameters encoding in AEM

When Sling receiving a request from any submitted form it parses it in two phases:

  1.  Sling get raw input data and identity transform bytes to chars as the original data was in ISO-8859-1 encoding.
  2. Locates _charset_ parameter which should be specified in every submitted form. This parameter specify form data original encoding. On second phase encoding will be resolved as:
    1. All names of the parameters are re-encoded
    2. The parameter values are re-encoded, unless the parameter value is an uploaded file. Actually the parameter (not the files of course) are internally as byte[]() where the conversion to a string is done on the fly (and yes, the conversion using the _charset_ character encoding is of course cached for performance reasons)
    3. If the parameter is an uploaded file, the file name is re-encoded on the fly when accessed

Good news that _charset_ parameter in Sling up to 2.2.4 is optional, so we can omit it. In this case second phase will resolve encoding based on sling.default.parameter.encoding property within org.apache.sling.engine.impl.SlingMainServlet.

Note: if sling.default.parameter.encoding wasn’t specified – second phase wouldn’t be reached and all not ASCII submitted text data will be encoded incorrectly.

For configuration sling.default.parameter.encoding we should open /system/console/configMgr/org.apache.sling.engine.parameters and set appropriate Default Parameter Encoding value:

configure_request_parameters_encoding_in_aem

How to close user session after inactivity in AEM or Apache Sling

When user request the site Sling back-end will instantiate a new session for it or using previously opened (Of cause this is a common case for application server). But a lot of opened sessions can impact performance therefore not active sessions must be closed. Time of inactivity depends on business requirements. For close user session after inactivity we should:

  1.  Open configuration path:
    /system/console/configMgr/org.apache.jackrabbit.oak.security.authentication.token.TokenConfigurationImpl
  2. Set appropriate value for Token Expiration property (Expiration time of login tokens in ms.)
    Configuration for Close user session after inactivity in AEM